2021-10-09 16:38:34 +08:00
|
|
|
#include "editpatientform.h"
|
|
|
|
|
#include "ui_editpatientform.h"
|
|
|
|
|
#include <QListView>
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QToolButton>
|
2021-10-12 15:07:06 +08:00
|
|
|
#include <QButtonGroup>
|
2021-10-09 16:38:34 +08:00
|
|
|
#include "guimacros.h"
|
2021-10-12 14:11:19 +08:00
|
|
|
#include <qdebug.h>
|
2021-10-09 16:38:34 +08:00
|
|
|
EditPatientForm::EditPatientForm(QWidget *parent) :
|
|
|
|
|
QWidget(parent),
|
|
|
|
|
ui(new Ui::EditPatientForm)
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
2021-10-12 15:07:06 +08:00
|
|
|
QHBoxLayout* sexlayout =new QHBoxLayout(ui->sexpanelwidget);
|
|
|
|
|
sexlayout->setMargin(6);
|
|
|
|
|
ADD_TOOL_SIZE_BTN_TO_LAYOUT(F,":/icons/female_d.png",30, sexlayout);
|
|
|
|
|
ADD_TOOL_SIZE_BTN_TO_LAYOUT(M,":/icons/male_d.png", 30,sexlayout);
|
|
|
|
|
// btnFemale->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
|
|
|
|
// btnMale->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
|
|
|
|
btnF->setObjectName("sexBtn");
|
|
|
|
|
btnM->setObjectName("sexBtn");
|
|
|
|
|
btnF->setText("Female");
|
|
|
|
|
btnM->setText("Male");
|
|
|
|
|
ui->sexpanelwidget->setEnabled(editEnable);
|
|
|
|
|
btnF->setEnabled(editEnable);
|
|
|
|
|
btnM->setEnabled(editEnable);
|
|
|
|
|
btnF->setCheckable(true);
|
|
|
|
|
btnM->setCheckable(true);
|
|
|
|
|
QButtonGroup* group= new QButtonGroup(this);
|
|
|
|
|
group->addButton(btnF);
|
|
|
|
|
group->addButton(btnM);
|
|
|
|
|
btnF->setChecked(true);
|
|
|
|
|
btnFemale=btnF;
|
|
|
|
|
btnMale=btnM;
|
|
|
|
|
QHBoxLayout* layout =new QHBoxLayout(this->ui->editcmdWidget);
|
2021-10-09 16:38:34 +08:00
|
|
|
ADD_TOOL_BTN(Cancel,":/icons/close_circle.png");
|
|
|
|
|
ADD_TOOL_BTN(Accpet,":/icons/selected.png");
|
2021-10-12 10:28:30 +08:00
|
|
|
btnCancel->setEnabled(editEnable);
|
2021-10-09 16:38:34 +08:00
|
|
|
btnCancel->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
2021-10-12 10:28:30 +08:00
|
|
|
btnCancel->setIcon(QIcon(editEnable?":/icons/close_circle.png":":/icons/close_circle_d.png"));
|
|
|
|
|
btnAccpet->setEnabled(editEnable);
|
2021-10-09 16:38:34 +08:00
|
|
|
btnAccpet->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
2021-10-12 10:28:30 +08:00
|
|
|
btnAccpet->setIcon(QIcon(editEnable?":/icons/selected.png":":/icons/selected_d.png"));
|
|
|
|
|
btnEditAccept = btnAccpet;
|
|
|
|
|
btnEditCancel = btnCancel;
|
|
|
|
|
connect(btnEditCancel,&QToolButton::clicked,[=](){
|
|
|
|
|
clearPatientInformation();
|
|
|
|
|
this->setEditEnable(false);
|
|
|
|
|
restorePatientInformation();
|
|
|
|
|
});
|
2021-10-12 10:55:51 +08:00
|
|
|
connect(btnEditAccept,&QToolButton::clicked,[=](){
|
2021-10-12 15:07:06 +08:00
|
|
|
if (ui->tbx_ID->text().isEmpty())return;
|
|
|
|
|
if (ui->tbx_Name->text().isEmpty())return;
|
2021-10-12 10:55:51 +08:00
|
|
|
storePatientInformation();
|
|
|
|
|
this->setEditEnable(false);
|
|
|
|
|
emit editAccept(getPatientInformation());
|
|
|
|
|
});
|
2021-10-09 16:38:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EditPatientForm::~EditPatientForm()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
2021-10-12 10:28:30 +08:00
|
|
|
|
|
|
|
|
void EditPatientForm::setPatientInformation(PatientInformation *information) {
|
|
|
|
|
if (information)
|
|
|
|
|
{
|
|
|
|
|
ui->tbx_ID->setText(information->ID);
|
|
|
|
|
ui->tbx_Dob->setDate(QDate::fromString(information->BirthDate,"yyyy-MM-dd"));
|
2021-10-12 14:11:19 +08:00
|
|
|
ui->tbx_Name->setText(information->Name);
|
|
|
|
|
ui->rtbx_Comment->setText(information->Comment);
|
2021-10-12 15:07:06 +08:00
|
|
|
btnFemale->setChecked(information->Sex=="F");
|
|
|
|
|
btnMale->setChecked(information->Sex!="F");
|
2021-10-12 10:28:30 +08:00
|
|
|
currentPatientUID = information->PatientUID;
|
|
|
|
|
storePatientInformation();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditPatientForm::clearPatientInformation() {
|
|
|
|
|
ui->tbx_ID->setText("");
|
|
|
|
|
ui->tbx_Dob->setDate(QDate::currentDate());
|
|
|
|
|
ui->tbx_Name->setText("");
|
2021-10-12 15:07:06 +08:00
|
|
|
btnFemale->setChecked(true);
|
|
|
|
|
btnMale->setChecked(false);
|
2021-10-12 14:11:19 +08:00
|
|
|
ui->rtbx_Comment->setText("");
|
2021-10-12 10:28:30 +08:00
|
|
|
currentPatientUID = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditPatientForm::setEditEnable(bool enable) {
|
|
|
|
|
ui->tbx_ID->setEnabled(enable);
|
|
|
|
|
ui->tbx_Dob->setEnabled(enable);
|
|
|
|
|
ui->tbx_Name->setEnabled(enable);
|
2021-10-12 15:07:06 +08:00
|
|
|
ui->sexpanelwidget->setEnabled(enable);
|
|
|
|
|
btnFemale->setEnabled(enable);
|
|
|
|
|
btnFemale->setIcon(QIcon(enable?":/icons/female.png":":/icons/female_d.png"));
|
|
|
|
|
btnMale->setEnabled(enable);
|
|
|
|
|
btnMale->setIcon(QIcon(enable?":/icons/male.png":":/icons/male_d.png"));
|
2021-10-12 10:28:30 +08:00
|
|
|
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();
|
2021-10-12 15:07:06 +08:00
|
|
|
store.Sex = btnFemale->isChecked()?"F":"M";
|
2021-10-12 14:11:19 +08:00
|
|
|
store.Comment = ui->rtbx_Comment->toPlainText();
|
|
|
|
|
qDebug()<<store.PatientUID<<","<<store.ID<<","<<store.BirthDate<<","<<store.Name<<","<<store.Sex;
|
2021-10-12 10:28:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
2021-10-12 14:11:19 +08:00
|
|
|
ui->rtbx_Comment->setText(store.Comment);
|
2021-10-12 15:07:06 +08:00
|
|
|
btnFemale->setChecked(store.Sex=="F");
|
|
|
|
|
btnMale->setChecked(store.Sex!="F");
|
|
|
|
|
// ui->cb_Sex->setCurrentText(store.Sex=="F"?"Female":(store.Name=="M"?"Male":"Other"));
|
2021-10-12 14:11:19 +08:00
|
|
|
|
2021-10-12 10:28:30 +08:00
|
|
|
}
|