2022-06-14 17:15:23 +08:00
|
|
|
#include "PatientInformationForm.h"
|
|
|
|
|
#include "ui_PatientInformationForm.h"
|
2021-10-14 14:38:31 +08:00
|
|
|
#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"
|
2023-08-21 14:22:41 +08:00
|
|
|
#include "models/User.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;
|
2021-10-12 17:43:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
2021-10-12 17:43:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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-10-14 14:38:31 +08:00
|
|
|
|
2023-08-21 14:22:41 +08:00
|
|
|
const char* PatientInformationForm::getCurrentPatientJsonString(bool empty)
|
|
|
|
|
{
|
|
|
|
|
cJSON* patientInfoObject = cJSON_CreateObject();
|
|
|
|
|
cJSON_AddItemToObject(patientInfoObject, "PatientName", cJSON_CreateString(mUI->lbl_Name->text().replace(' ', '_').toStdString().data()));
|
|
|
|
|
cJSON_AddItemToObject(patientInfoObject, "PatientID", cJSON_CreateString(mUI->lbl_ID->text().replace(' ', '_').toStdString().data()));
|
|
|
|
|
cJSON_AddItemToObject(patientInfoObject, "PatientSex", cJSON_CreateString(mUI->lbl_Sex->text().toStdString().data()));
|
|
|
|
|
cJSON_AddItemToObject(patientInfoObject, "PatientBirthDate",
|
2022-06-13 11:21:44 +08:00
|
|
|
cJSON_CreateString(mUI->lbl_Date->text().replace("/", "").replace("-", "").replace(' ', '.').toStdString().data()));
|
2023-08-21 14:22:41 +08:00
|
|
|
cJSON_AddItemToObject(patientInfoObject, "Laterality", cJSON_CreateString(mCurrentProtocol ? "R" : "L"));
|
|
|
|
|
cJSON_AddItemToObject(patientInfoObject, "IsEmptyData", cJSON_CreateNumber(empty ? 1 : 0));
|
|
|
|
|
cJSON_AddItemToObject(patientInfoObject, "OperatorName", cJSON_CreateString(User::Current()->getUserName().toStdString().c_str()));
|
|
|
|
|
cJSON_AddItemToObject(patientInfoObject, "ReferringPhysicianName", cJSON_CreateString("XX"));
|
|
|
|
|
cJSON_AddItemToObject(patientInfoObject, "InstitutionName", cJSON_CreateString("EQ9"));
|
|
|
|
|
cJSON_AddItemToObject(patientInfoObject, "InstitutionAddress", cJSON_CreateString("HZ"));
|
|
|
|
|
|
|
|
|
|
cJSON* rootObject = cJSON_CreateObject();
|
|
|
|
|
cJSON_AddItemToObject(rootObject, "Patient Info", patientInfoObject);
|
2022-06-13 11:21:44 +08:00
|
|
|
delete mJsonStr;
|
2023-08-21 14:22:41 +08:00
|
|
|
mJsonStr = cJSON_PrintUnformatted (rootObject);
|
|
|
|
|
ScanJson::Current()->store(rootObject);
|
2022-06-13 11:21:44 +08:00
|
|
|
return mJsonStr;
|
2021-10-14 14:38:31 +08:00
|
|
|
}
|