Using SQLHelper to retrieve data to dataView, add simple control to edit patient panel.

This commit is contained in:
Krad
2021-10-12 10:28:30 +08:00
parent 700282bd2f
commit d03de1009d
4 changed files with 135 additions and 31 deletions

View File

@@ -16,15 +16,68 @@ EditPatientForm::EditPatientForm(QWidget *parent) :
this->ui->editcmdWidget->setLayout(layout);
ADD_TOOL_BTN(Cancel,":/icons/close_circle.png");
ADD_TOOL_BTN(Accpet,":/icons/selected.png");
btnCancel->setEnabled(false);
btnCancel->setEnabled(editEnable);
btnCancel->setToolButtonStyle(Qt::ToolButtonIconOnly);
btnCancel->setIcon(QIcon(":/icons/close_circle_d.png"));
btnAccpet->setEnabled(false);
btnCancel->setIcon(QIcon(editEnable?":/icons/close_circle.png":":/icons/close_circle_d.png"));
btnAccpet->setEnabled(editEnable);
btnAccpet->setToolButtonStyle(Qt::ToolButtonIconOnly);
btnAccpet->setIcon(QIcon(":/icons/selected_d.png"));
btnAccpet->setIcon(QIcon(editEnable?":/icons/selected.png":":/icons/selected_d.png"));
btnEditAccept = btnAccpet;
btnEditCancel = btnCancel;
connect(btnEditCancel,&QToolButton::clicked,[=](){
clearPatientInformation();
this->setEditEnable(false);
restorePatientInformation();
});
}
EditPatientForm::~EditPatientForm()
{
delete ui;
}
void EditPatientForm::setPatientInformation(PatientInformation *information) {
if (information)
{
ui->tbx_ID->setText(information->ID);
ui->tbx_Dob->setDate(QDate::fromString(information->BirthDate,"yyyy-MM-dd"));
ui->tbx_Name->setText(information->Name=="F"?"Female":(information->Name=="M"?"Male":"Other"));
currentPatientUID = information->PatientUID;
storePatientInformation();
}
}
void EditPatientForm::clearPatientInformation() {
ui->tbx_ID->setText("");
ui->tbx_Dob->setDate(QDate::currentDate());
ui->tbx_Name->setText("");
currentPatientUID = "";
}
void EditPatientForm::setEditEnable(bool enable) {
ui->tbx_ID->setEnabled(enable);
ui->tbx_Dob->setEnabled(enable);
ui->tbx_Name->setEnabled(enable);
ui->cb_Sex->setEnabled(enable);
ui->rtbx_Comment->setEnabled(enable);
btnEditAccept->setEnabled(enable);
btnEditCancel->setEnabled(enable);
btnEditCancel->setIcon(QIcon(enable?":/icons/close_circle.png":":/icons/close_circle_d.png"));
btnEditAccept->setIcon(QIcon(enable?":/icons/selected.png":":/icons/selected_d.png"));
editEnable = enable;
// ui->->setEnabled(enable);
}
void EditPatientForm::storePatientInformation() {
store.PatientUID =currentPatientUID;
store.ID = ui->tbx_ID->text();
store.BirthDate = ui->tbx_Dob->date().toString("yyyy-MM-dd");
store.Name = ui->tbx_Name->text();
}
void EditPatientForm::restorePatientInformation() {
currentPatientUID = store.PatientUID;
ui->tbx_ID->setText(store.ID);
ui->tbx_Dob->setDate(QDate::fromString(store.BirthDate,"yyyy-MM-dd"));
ui->tbx_Name->setText(store.Name);
}