Files
GUI/src/forms/scan/patientinformationform.cpp

66 lines
2.3 KiB
C++
Raw Normal View History

2021-10-09 16:38:34 +08:00
#include "patientinformationform.h"
#include "ui_patientinformationform.h"
#include "json/cJSON.h"
2021-12-30 13:33:16 +08:00
#include "event/EventCenter.h"
2022-05-11 15:44:43 +08:00
#include "json/ScanJson.h"
2021-12-30 13:33:16 +08:00
2022-06-13 11:21:44 +08:00
PatientInformationForm::PatientInformationForm(QWidget* parent)
: QWidget(parent)
, mUI(new Ui::PatientInformationForm)
, mInfo(nullptr)
, mJsonStr(nullptr)
2021-10-09 16:38:34 +08:00
{
2022-06-13 11:21:44 +08:00
mUI->setupUi(this);
2021-12-30 13:33:16 +08:00
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() {
2022-06-13 11:21:44 +08:00
mUI->retranslateUi(this);
});
2021-10-09 16:38:34 +08:00
}
PatientInformationForm::~PatientInformationForm()
{
2022-06-13 11:21:44 +08:00
delete mUI;
delete mInfo;
delete mJsonStr;
}
void PatientInformationForm::setPatientInformation(PatientInformation* information) {
2022-06-13 11:21:44 +08:00
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) {
2022-06-13 11:21:44 +08:00
mCurrentProtocol = type;
2021-12-30 13:33:16 +08:00
switch (type)
{
case 0:
2022-06-13 11:21:44 +08:00
mUI->lbl_Protocol->setText(tr("LEFT ONLY"));
2021-12-30 13:33:16 +08:00
break;
case 1:
default:
2022-06-13 11:21:44 +08:00
mUI->lbl_Protocol->setText(tr("RIGHT ONLY"));
2021-12-30 13:33:16 +08:00
break;
}
2021-10-09 16:38:34 +08:00
}
2021-12-30 13:33:16 +08:00
const char* PatientInformationForm::getCurrentPatientJsonString(bool empty) {
cJSON* root = cJSON_CreateObject();
2022-06-13 11:21:44 +08:00
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()));
2021-12-30 13:33:16 +08:00
cJSON_AddItemToObject(root, "PatientBirthDate",
2022-06-13 11:21:44 +08:00
cJSON_CreateString(mUI->lbl_Date->text().replace("/", "").replace("-", "").replace(' ', '.').toStdString().data()));
cJSON_AddItemToObject(root, "Laterality", cJSON_CreateString(mCurrentProtocol ? "R" : "L"));
2021-12-30 13:33:16 +08:00
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"));
2022-06-13 11:21:44 +08:00
delete mJsonStr;
mJsonStr = cJSON_Print(root);
2022-05-11 15:44:43 +08:00
ScanJson::Current()->store(root);
2022-06-13 11:21:44 +08:00
return mJsonStr;
}