Create a method to get Patient json from current patient.

This commit is contained in:
Krad
2021-10-14 14:38:31 +08:00
parent 591d042eb8
commit fca70376cc
2 changed files with 26 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
#include "patientinformationform.h" #include "patientinformationform.h"
#include "ui_patientinformationform.h" #include "ui_patientinformationform.h"
#include "json/cJSON.h"
PatientInformationForm::PatientInformationForm(QWidget *parent) : PatientInformationForm::PatientInformationForm(QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::PatientInformationForm) ui(new Ui::PatientInformationForm)
@@ -11,7 +11,8 @@ PatientInformationForm::PatientInformationForm(QWidget *parent) :
PatientInformationForm::~PatientInformationForm() PatientInformationForm::~PatientInformationForm()
{ {
delete ui; delete ui;
if (inf) delete inf; delete inf;
delete jsonstr;
} }
void PatientInformationForm::setPatientInformation(PatientInformation* information) { void PatientInformationForm::setPatientInformation(PatientInformation* information) {
@@ -23,6 +24,7 @@ void PatientInformationForm::setPatientInformation(PatientInformation* informati
} }
void PatientInformationForm::setProtocol(int type) { void PatientInformationForm::setProtocol(int type) {
currentProtocol = type;
switch(type) switch(type)
{ {
case 0: case 0:
@@ -34,3 +36,22 @@ void PatientInformationForm::setProtocol(int type) {
break; break;
} }
} }
const char *PatientInformationForm::getCurrentPatientJsonString(bool empty) {
cJSON* root=cJSON_CreateObject();
cJSON_AddItemToObject(root, "PatientName",cJSON_CreateString(ui->lbl_Name->text().toStdString().data()));
cJSON_AddItemToObject(root, "PatientID",cJSON_CreateString(ui->lbl_ID->text().toStdString().data()));
cJSON_AddItemToObject(root, "PatientSex",cJSON_CreateString(ui->lbl_Sex->text().toStdString().data()));
cJSON_AddItemToObject(root, "PatientBirthDate",
cJSON_CreateString(ui->lbl_Date->text().replace("/","").replace("-","").toStdString().data()));
cJSON_AddItemToObject(root, "Laterality",cJSON_CreateString(currentProtocol?"R":"L"));
cJSON_AddItemToObject(root, "EmptyDataFlag",cJSON_CreateNumber(empty?1:0));
cJSON_AddItemToObject(root, "OperatorName",cJSON_CreateString("Bob"));
cJSON_AddItemToObject(root, "ReferringPhysicianName",cJSON_CreateString("XX"));
cJSON_AddItemToObject(root, "InstituteName",cJSON_CreateString("EQ9"));
cJSON_AddItemToObject(root, "InstituteAddress",cJSON_CreateString("HZ"));
delete jsonstr;
jsonstr = cJSON_Print(root);
cJSON_Delete(root);
return jsonstr;
}

View File

@@ -16,9 +16,12 @@ public:
~PatientInformationForm(); ~PatientInformationForm();
void setPatientInformation(PatientInformation* information); void setPatientInformation(PatientInformation* information);
void setProtocol(int type); void setProtocol(int type);
const char * getCurrentPatientJsonString(bool emptyScan);
private: private:
Ui::PatientInformationForm *ui; Ui::PatientInformationForm *ui;
PatientInformation* inf = nullptr; PatientInformation* inf = nullptr;
int currentProtocol = 0;
char * jsonstr = nullptr;
}; };
#endif // PATIENTINFORMATIONFORM_H #endif // PATIENTINFORMATIONFORM_H