Refactor dialog package.

This commit is contained in:
Krad
2022-06-13 11:21:44 +08:00
parent 9a233251dc
commit 69a506ff94
27 changed files with 870 additions and 828 deletions

View File

@@ -4,61 +4,62 @@
#include "event/EventCenter.h"
#include "json/ScanJson.h"
PatientInformationForm::PatientInformationForm(QWidget* parent) :
QWidget(parent),
ui(new Ui::PatientInformationForm)
PatientInformationForm::PatientInformationForm(QWidget* parent)
: QWidget(parent)
, mUI(new Ui::PatientInformationForm)
, mInfo(nullptr)
, mJsonStr(nullptr)
{
ui->setupUi(this);
mUI->setupUi(this);
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() {
ui->retranslateUi(this);
});
mUI->retranslateUi(this);
});
}
PatientInformationForm::~PatientInformationForm()
{
delete ui;
delete inf;
delete jsonstr;
delete mUI;
delete mInfo;
delete mJsonStr;
}
void PatientInformationForm::setPatientInformation(PatientInformation* information) {
ui->lbl_ID->setText(information->ID);
ui->lbl_Date->setText(information->BirthDate);
ui->lbl_Name->setText(information->Name);
ui->lbl_Sex->setText(information->Sex);
inf = information;
mUI->lbl_ID->setText(information->ID);
mUI->lbl_Date->setText(information->BirthDate);
mUI->lbl_Name->setText(information->Name);
mUI->lbl_Sex->setText(information->Sex);
mInfo = information;
}
void PatientInformationForm::setProtocol(int type) {
currentProtocol = type;
mCurrentProtocol = type;
switch (type)
{
case 0:
ui->lbl_Protocol->setText(tr("LEFT ONLY"));
mUI->lbl_Protocol->setText(tr("LEFT ONLY"));
break;
case 1:
default:
ui->lbl_Protocol->setText(tr("RIGHT ONLY"));
mUI->lbl_Protocol->setText(tr("RIGHT ONLY"));
break;
}
}
const char* PatientInformationForm::getCurrentPatientJsonString(bool empty) {
cJSON* root = cJSON_CreateObject();
cJSON_AddItemToObject(root, "PatientName", cJSON_CreateString(ui->lbl_Name->text().replace(' ', '_').toStdString().data()));
cJSON_AddItemToObject(root, "PatientID", cJSON_CreateString(ui->lbl_ID->text().replace(' ', '_').toStdString().data()));
cJSON_AddItemToObject(root, "PatientSex", cJSON_CreateString(ui->lbl_Sex->text().toStdString().data()));
cJSON_AddItemToObject(root, "PatientName", cJSON_CreateString(mUI->lbl_Name->text().replace(' ', '_').toStdString().data()));
cJSON_AddItemToObject(root, "PatientID", cJSON_CreateString(mUI->lbl_ID->text().replace(' ', '_').toStdString().data()));
cJSON_AddItemToObject(root, "PatientSex", cJSON_CreateString(mUI->lbl_Sex->text().toStdString().data()));
cJSON_AddItemToObject(root, "PatientBirthDate",
cJSON_CreateString(ui->lbl_Date->text().replace("/", "").replace("-", "").replace(' ', '.').toStdString().data()));
cJSON_AddItemToObject(root, "Laterality", cJSON_CreateString(currentProtocol ? "R" : "L"));
cJSON_CreateString(mUI->lbl_Date->text().replace("/", "").replace("-", "").replace(' ', '.').toStdString().data()));
cJSON_AddItemToObject(root, "Laterality", cJSON_CreateString(mCurrentProtocol ? "R" : "L"));
cJSON_AddItemToObject(root, "IsEmptyData", cJSON_CreateNumber(empty ? 1 : 0));
cJSON_AddItemToObject(root, "OperatorName", cJSON_CreateString("Bob"));
cJSON_AddItemToObject(root, "ReferringPhysicianName", cJSON_CreateString("XX"));
cJSON_AddItemToObject(root, "InstitutionName", cJSON_CreateString("EQ9"));
cJSON_AddItemToObject(root, "InstitutionAddress", cJSON_CreateString("HZ"));
delete jsonstr;
jsonstr = cJSON_Print(root);
delete mJsonStr;
mJsonStr = cJSON_Print(root);
ScanJson::Current()->store(root);
return jsonstr;
return mJsonStr;
}

View File

@@ -13,15 +13,15 @@ class PatientInformationForm : public QWidget
public:
explicit PatientInformationForm(QWidget *parent = nullptr);
~PatientInformationForm();
~PatientInformationForm() override;
void setPatientInformation(PatientInformation* information);
void setProtocol(int type);
const char * getCurrentPatientJsonString(bool emptyScan);
private:
Ui::PatientInformationForm *ui;
PatientInformation* inf = nullptr;
int currentProtocol = 0;
char * jsonstr = nullptr;
Ui::PatientInformationForm *mUI;
PatientInformation* mInfo = nullptr;
int mCurrentProtocol = 0;
char * mJsonStr = nullptr;
};
#endif // PATIENTINFORMATIONFORM_H