diff --git a/src/forms/scan/PatientInformationForm.cpp b/src/forms/scan/PatientInformationForm.cpp index 87cee9d..891a88c 100644 --- a/src/forms/scan/PatientInformationForm.cpp +++ b/src/forms/scan/PatientInformationForm.cpp @@ -15,18 +15,18 @@ PatientInformationForm::PatientInformationForm(QWidget* parent) , mMPPSUID() , mDicomGender() { - mUI->setupUi(this); - connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() { - mUI->retranslateUi(this); + mUI->setupUi(this); + connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() { + mUI->retranslateUi(this); if(!mUI->mScanProtocol->text().isEmpty()) setExecuteProtocol(mIsExecuteProtocolLeft); mUI->mPatientGender->setText(GenderHelper::getStringfromDicomGender(mDicomGender)); - }); + }); } PatientInformationForm::~PatientInformationForm() { - delete mUI; - delete mJsonStr; + delete mUI; + delete mJsonStr; } void PatientInformationForm::setPatientInformation(PatientInformation* information) { @@ -37,6 +37,7 @@ void PatientInformationForm::setPatientInformation(PatientInformation* informati mUI->mPatientName->setText(information->Name); mDicomGender = information->Sex; mUI->mPatientGender->setText(GenderHelper::getStringfromDicomGender(mDicomGender)); + mPatientInformation.reset(information->copy()); } else { @@ -52,6 +53,11 @@ void PatientInformationForm::setPatientInformation(PatientInformation* informati } } +PatientInformation* PatientInformationForm::getPatientInformationPtr() +{ + return mPatientInformation.get(); +} + void PatientInformationForm::setAccessionNumber(AccessionInformation* aAccession) { if(aAccession == nullptr) @@ -125,8 +131,8 @@ const char* PatientInformationForm::getCurrentPatientJsonString(bool empty) cJSON_AddItemToObject(patientInfoObject, "MPPSUID", cJSON_CreateString(mMPPSUID.toStdString().data())); cJSON* rootObject = cJSON_CreateObject(); cJSON_AddItemToObject(rootObject, "Patient Info", patientInfoObject); - delete mJsonStr; + delete mJsonStr; mJsonStr = cJSON_PrintUnformatted (rootObject); ScanJson::Current()->store(rootObject); - return mJsonStr; + return mJsonStr; } diff --git a/src/forms/scan/PatientInformationForm.h b/src/forms/scan/PatientInformationForm.h index e9bb4e0..bbda380 100644 --- a/src/forms/scan/PatientInformationForm.h +++ b/src/forms/scan/PatientInformationForm.h @@ -26,7 +26,8 @@ public: void clear(); const char * getCurrentPatientJsonString(bool emptyScan); - QString getPatientID(); + QString getPatientID(); + PatientInformation* getPatientInformationPtr(); private: Ui::PatientInformationForm *mUI; @@ -37,6 +38,7 @@ private: QString mModality; QString mMPPSUID; QString mDicomGender; + QScopedPointer mPatientInformation; }; #endif // PATIENTINFORMATIONFORM_H diff --git a/src/forms/scan/ScanFormWidget.cpp b/src/forms/scan/ScanFormWidget.cpp index 9546689..91b2d93 100644 --- a/src/forms/scan/ScanFormWidget.cpp +++ b/src/forms/scan/ScanFormWidget.cpp @@ -77,7 +77,6 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout) mStartScanButton->setText(tr("Start Scan")); layout->addWidget(mStartScanButton); mStartScanButton->setEnabled(false); - mStartScanButton->setCheckable(true); layout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding)); addVerticalLine(layout); @@ -146,17 +145,16 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout) connect(mStartScanButton, &QToolButton::clicked, [this]() { - if(mStartScanButton->isChecked()) + PatientInformation* patientInfo = mPatInf->getPatientInformationPtr(); + DialogResult result = DialogManager::Default()->reuqestConfirmStartScan(patientInfo); + if(result.ResultCode == QDialog::Accepted) { + ScanProtocal protocal = static_cast(result.ResultData.toInt()); + setScanProtocal(patientInfo, protocal); LOG_USER_OPERATION(QString("Start Scan Process, ID: %1").arg(mPatInf->getPatientID())); + mStartScanButton->setEnabled(false); EventCenter::Default()->triggerEvent(GUIEvents::StartScanProcess, nullptr, nullptr); } - else - { - LOG_USER_OPERATION(QString("Stop Scan Process, ID: %1").arg(mPatInf->getPatientID())); - EventCenter::Default()->triggerEvent(GUIEvents::StopScanProcess, nullptr, nullptr); - - } }); connect(DeviceManager::Default(), &DeviceManager::startAutoLocateResult, [this](bool aResult) @@ -166,7 +164,6 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout) mAccountButton->setEnabled(false); mDrainageButton->setEnabled(false); mShutdownButton->setEnabled(false); - mStartScanButton->setText(tr("Stop Scan Process")); mScanProcessLabel->setText(getAutoLocateMessage()); } @@ -180,13 +177,14 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout) mAccountButton->setEnabled(true); mDrainageButton->setEnabled(true); mShutdownButton->setEnabled(true); - mStartScanButton->setChecked(false); - mStartScanButton->setText(tr("Start Scan")); if(ScanProcessSequence::getInstance()->getScanPositionSize() == 0) { - mStartScanButton->setEnabled(false); mPatInf->clear(); } + else + { + mStartScanButton->setEnabled(true); + } mScanProcessLabel->setText(tr("Please confirm checking patient information to start the process")); }); @@ -330,19 +328,11 @@ void ScanFormWidget::initEvents() connect(EventCenter::Default(), &EventCenter::PatientSelected, [=](QObject* sender, QObject* data) { if (data) { - PatientInformation* patientInfo = (PatientInformation*)data; - DialogResult result = DialogManager::Default()->reuqestConfirmStartScan(patientInfo); - if(result.ResultCode == QDialog::Accepted) - { - ScanProtocal protocal = static_cast(result.ResultData.toInt()); - mPatInf->setPatientInformation(patientInfo); - setScanProtocal(patientInfo, protocal); - LOG_USER_OPERATION(QString("Select Patient, ID: %1").arg(patientInfo->ID)) - mStartScanButton->setEnabled(true); - EventCenter::Default()->triggerEvent(SetSelectedPatient, nullptr, (QObject*)patientInfo); - mStartScanButton->click(); - - } + PatientInformation* patientInfo = (PatientInformation*)data; + mPatInf->setPatientInformation(patientInfo); + LOG_USER_OPERATION(QString("Select Patient, ID: %1").arg(patientInfo->ID)) + mStartScanButton->setEnabled(true); + EventCenter::Default()->triggerEvent(SetSelectedPatient, nullptr, (QObject*)patientInfo); } }); connect(EventCenter::Default(), &EventCenter::ResponseStopPreview, [=](QObject* sender, QObject* data) { diff --git a/src/forms/select/PatientInformation.cpp b/src/forms/select/PatientInformation.cpp index ffb9f9f..007183c 100644 --- a/src/forms/select/PatientInformation.cpp +++ b/src/forms/select/PatientInformation.cpp @@ -229,6 +229,55 @@ void PatientInformation::operator=(const PatientInformation& aOther) this->mRecommendAccessions = aOther.mRecommendAccessions; } +PatientInformation* PatientInformation::copy() +{ + PatientInformation* copyPatient = new PatientInformation(ID, Name, Sex, BirthDate, AddDate); + + copyPatient->PatientUID = this->PatientUID; + copyPatient->Comment = this->Comment; + + for(int i = 1; i < mAccessionList.size(); ++i) + { + AccessionInformation* original = mAccessionList[i]; + AccessionInformation* copyAccession = new AccessionInformation( + original->mAccessionNumber, + original->mPosition, + original->mScheduledStartDate, + original->mStudyUID, + original->mRPID, + original->mSPSID, + original->mModality, + original->mMPPSUID, + copyPatient, + copyPatient + ); + copyAccession->mScanCount = original->mScanCount; + copyPatient->mAccessionList.append(copyAccession); + } + + copyPatient->mSelectedScanProtocol = this->mSelectedScanProtocol; + + for(AccessionInformation* selectedAcc : mSelectedAccessions) + { + int index = mAccessionList.indexOf(selectedAcc); + if(index != -1) + { + copyPatient->mSelectedAccessions.append(copyPatient->mAccessionList[index]); + } + } + + for(AccessionInformation* recommendedAcc : mRecommendAccessions) + { + int index = mAccessionList.indexOf(recommendedAcc); + if(index != -1) + { + copyPatient->mRecommendAccessions.append(copyPatient->mAccessionList[index]); + } + } + + return copyPatient; +} + QList PatientInformation::getSelectedAccession() { return mSelectedAccessions; diff --git a/src/forms/select/PatientInformation.h b/src/forms/select/PatientInformation.h index a6a7196..bf9f712 100644 --- a/src/forms/select/PatientInformation.h +++ b/src/forms/select/PatientInformation.h @@ -55,7 +55,7 @@ public: void reloadHeaderLanguage(); QList getSelectedAccession(); AccessionInformation* findSelectedAccession(ScanProtocol aProtocol, bool aIfEmptyGetTop); - + PatientInformation* copy(); AccessionInformation* mHeader; QList mAccessionList; @@ -66,8 +66,6 @@ public: #define ADD_PATIENT_PROPERTY(val) QString val; ADD_PATIENT() #undef ADD_PATIENT_PROPERTY -// QString ScheduledStartDate; -// QString AccessionNumber; }; typedef QSharedPointer PatientInformationPointer;