diff --git a/src/patientinformationform.cpp b/src/patientinformationform.cpp index 72f943f..812ba12 100644 --- a/src/patientinformationform.cpp +++ b/src/patientinformationform.cpp @@ -1,6 +1,6 @@ #include "patientinformationform.h" #include "ui_patientinformationform.h" - +#include "json/cJSON.h" PatientInformationForm::PatientInformationForm(QWidget *parent) : QWidget(parent), ui(new Ui::PatientInformationForm) @@ -11,7 +11,8 @@ PatientInformationForm::PatientInformationForm(QWidget *parent) : PatientInformationForm::~PatientInformationForm() { delete ui; - if (inf) delete inf; + delete inf; + delete jsonstr; } void PatientInformationForm::setPatientInformation(PatientInformation* information) { @@ -23,6 +24,7 @@ void PatientInformationForm::setPatientInformation(PatientInformation* informati } void PatientInformationForm::setProtocol(int type) { + currentProtocol = type; switch(type) { case 0: @@ -34,3 +36,22 @@ void PatientInformationForm::setProtocol(int type) { 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; +} diff --git a/src/patientinformationform.h b/src/patientinformationform.h index 6ed1091..b07a0a0 100644 --- a/src/patientinformationform.h +++ b/src/patientinformationform.h @@ -16,9 +16,12 @@ public: ~PatientInformationForm(); 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; }; #endif // PATIENTINFORMATIONFORM_H