Files
GUI/src/forms/scan/PatientInformationForm.cpp
2024-04-29 17:58:17 +08:00

88 lines
3.2 KiB
C++

#include "PatientInformationForm.h"
#include "ui_PatientInformationForm.h"
#include "json/cJSON.h"
#include "event/EventCenter.h"
#include "json/ScanJson.h"
#include "models/User.h"
PatientInformationForm::PatientInformationForm(QWidget* parent)
: QWidget(parent)
, mUI(new Ui::PatientInformationForm)
, mInfo(nullptr)
, mJsonStr(nullptr)
{
mUI->setupUi(this);
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() {
mUI->retranslateUi(this);
});
}
PatientInformationForm::~PatientInformationForm()
{
delete mUI;
delete mJsonStr;
}
void PatientInformationForm::setPatientInformation(PatientInformationPointer information) {
if(information)
{
mUI->mPatientID->setText(information->ID);
mUI->mPatientBirthday->setText(information->BirthDate);
mUI->mPatientName->setText(information->Name);
mUI->mPatientGender->setText(information->Sex);
mUI->mPaitenAccessionNumber->setText(information->AccessionNumber);
}
else
{
mUI->mPatientID->clear();
mUI->mPatientBirthday->clear();
mUI->mPatientName->clear();
mUI->mPatientGender->clear();
mUI->mPaitenAccessionNumber->clear();
}
if (mInfo)
{
mInfo->deleteLater();
}
mInfo = information;
}
PatientInformationPointer PatientInformationForm::getPatientInformation()
{
return mInfo->Copy();
}
int PatientInformationForm::getProtocol()
{
return mCurrentProtocol;
}
QString PatientInformationForm::getPatientID()
{
return mUI->mPatientID->text();
}
const char* PatientInformationForm::getCurrentPatientJsonString(bool empty)
{
cJSON* patientInfoObject = cJSON_CreateObject();
cJSON_AddItemToObject(patientInfoObject, "PatientName", cJSON_CreateString(mInfo->Name.toStdString().data()));
cJSON_AddItemToObject(patientInfoObject, "PatientID", cJSON_CreateString(mInfo->ID.toStdString().data()));
cJSON_AddItemToObject(patientInfoObject, "AccessionNumber", cJSON_CreateString(mInfo->AccessionNumber.toStdString().data()));
cJSON_AddItemToObject(patientInfoObject, "PatientSex", cJSON_CreateString(mInfo->Sex.toStdString().data()));
cJSON_AddItemToObject(patientInfoObject, "PatientBirthDate",
cJSON_CreateString(mInfo->BirthDate.replace("/", "").replace("-", "").replace(' ', '.').toStdString().data()));
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(User::Current()->getUserName().toStdString().c_str()));
cJSON_AddItemToObject(patientInfoObject, "InstitutionName", cJSON_CreateString("EQ9"));
cJSON_AddItemToObject(patientInfoObject, "InstitutionAddress", cJSON_CreateString("HZ"));
cJSON* rootObject = cJSON_CreateObject();
cJSON_AddItemToObject(rootObject, "Patient Info", patientInfoObject);
delete mJsonStr;
mJsonStr = cJSON_PrintUnformatted (rootObject);
ScanJson::Current()->store(rootObject);
return mJsonStr;
}