#include "PatientDetailForm.h" #include "ui_PatientDetailForm.h" #include #include #include #include #include "event/EventCenter.h" PatientDetailForm::PatientDetailForm(QWidget* parent) : QWidget(parent), mUI(new Ui::PatientDetailForm) { mUI->setupUi(this); mUI->hideBtn->setSizePolicy(QSizePolicy::Policy::Expanding, QSizePolicy::Policy::Preferred); mUI->hideBtn->setObjectName("btnHidePanel"); mUI->hideBtn->setText(tr(" Hide Panel")); connect(mUI->hideBtn, &QToolButton::clicked, [=](){ emit hideBtnClicked(); }); mUI->tbxDob->setDisplayFormat("yyyy/MM/dd"); mUI->tbxID->setEnabled(false); mUI->tbxID->setObjectName("displayLineEdit"); mUI->tbxDob->setEnabled(false); mUI->tbxDob->setObjectName("displayLineEdit"); mUI->tbxName->setEnabled(false); mUI->tbxName->setObjectName("displayLineEdit"); mUI->tbxSex->setEnabled(false); mUI->tbxSex->setObjectName("displayLineEdit"); mUI->rtbxComment->setEnabled(false); mUI->rtbxComment->setObjectName("displayLineEdit"); connect(EventCenter::Default(), &EventCenter::ReloadLanguage, this,&PatientDetailForm::reloadLanguage); } void PatientDetailForm::reloadLanguage() { mUI->retranslateUi(this); mUI->tbxSex->setText(mStore.Sex == "F" ? tr("Female") : (mStore.Sex == "M" ? tr("Male") : tr("Other"))); } PatientDetailForm::~PatientDetailForm() { delete mUI; } void PatientDetailForm::setPatientInformation(PatientInformation* information) { if (information) { mUI->tbxID->setText(information->ID); mUI->tbxDob->setDate(QDate::fromString(information->BirthDate, "yyyy-MM-dd")); mUI->tbxName->setText(information->Name); mUI->rtbxComment->setText(information->Comment); mUI->tbxSex->setText(information->Sex == "F" ? tr("Female") : (information->Sex == "M" ? tr("Male") : tr("Other"))); mCurrentPatientUID = information->PatientUID; mAddDate = information->AddDate; mStore.Sex = information->Sex; mStore.AccessionNumber = information->AccessionNumber; storePatientInformation(); } } void PatientDetailForm::clearPatientInformation() { mUI->tbxID->clear(); mUI->tbxDob->setDate(QDate::currentDate()); mUI->tbxName->clear(); mUI->tbxSex->clear(); mUI->rtbxComment->clear(); mCurrentPatientUID.clear(); mAddDate.clear(); } void PatientDetailForm::storePatientInformation() { mStore.PatientUID = mCurrentPatientUID; mStore.AddDate = mAddDate; mStore.ID = mUI->tbxID->text(); mStore.BirthDate = mUI->tbxDob->date().toString("yyyy-MM-dd"); mStore.Name = mUI->tbxName->text(); mStore.Comment = mUI->rtbxComment->toPlainText(); }