Files
GUI/src/forms/select/PatientDetailForm.cpp
2024-05-14 17:34:58 +08:00

121 lines
3.8 KiB
C++

#include "PatientDetailForm.h"
#include <QListView>
#include <QToolButton>
#include <QButtonGroup>
#include <QDateTime>
#include <qboxlayout.h>
#include <QFormLayout>
#include <QLabel>
#include <qdebug.h>
#include <qwidget.h>
#include "event/EventCenter.h"
PatientDetailForm::PatientDetailForm(QWidget* parent) :
QWidget(parent)
, mLblPatInfTitle(new QLabel(this))
, mLblDOB(new QLabel(this))
, mLblName(new QLabel(this))
, mLblPatID(new QLabel(this))
, mLblSex(new QLabel(this))
, mLblAccno(new QLabel(this))
, mLblAddDate(new QLabel(this))
{
mLblPatInfTitle->setObjectName("PatInfTitle");
mLblDOB->setObjectName("displayDetail");
mLblName->setObjectName("displayDetail");
mLblPatID->setObjectName("displayDetail");
mLblSex->setObjectName("displayDetail");
mLblAccno->setObjectName("displayDetail");
mLblAddDate->setObjectName("displayDetail");
auto layout = new QVBoxLayout(this);
// mLblPatInfTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
mLblPatInfTitle->setAlignment(Qt::AlignCenter);
layout->addWidget(mLblPatInfTitle);
mLblPatInfTitle->setText(tr("Patient Detail"));
addDetailLabel(layout,tr("Name")+":", mLblName);
addDetailLabel(layout,tr("Gender")+":", mLblSex);
addDetailLabel(layout,tr("Birth Date")+":", mLblDOB);
addDetailLabel(layout,tr("PatientID")+":", mLblPatID);
addDetailLabel(layout,tr("AccNo")+":", mLblAccno);
auto widgetLayout = new QHBoxLayout;
layout->addLayout(widgetLayout);
mLblAddDateTitle = new QLabel(tr("Add Date")+":",this);
mLblAddDateTitle->setObjectName("displayTitle");
widgetLayout->addWidget(mLblAddDateTitle);
widgetLayout->addWidget(mLblAddDate);
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, this,&PatientDetailForm::reloadLanguage);
layout->addSpacerItem(new QSpacerItem(2,2,QSizePolicy::Expanding, QSizePolicy::Expanding));
}
void PatientDetailForm::addDetailLabel(QVBoxLayout *layout, const QString& aTitleText, QLabel* aLabel)
{
auto widgetLayout = new QHBoxLayout;
layout->addLayout(widgetLayout);
auto lblTitle = new QLabel(aTitleText,this);
mBtnList.append(lblTitle);
lblTitle->setObjectName("displayTitle");
widgetLayout->addWidget(lblTitle);
widgetLayout->addWidget(aLabel);
}
void PatientDetailForm::reloadLanguage() {
mLblSex->setText(mStore.Sex == "F" ? tr("Female") : (mStore.Sex == "M" ? tr("Male") : tr("Other")));
QList<std::string> strArray = {"Name","Gender","Birth Date","PatientID","AccNo"};
for (size_t i = 0; i < strArray.length(); i++)
{
mBtnList[i]->setText(tr(strArray[i].data())+":");
}
mLblAddDateTitle->setText(tr("Add Date")+":");
mLblPatInfTitle->setText(tr("Patient Detail"));
}
PatientDetailForm::~PatientDetailForm()
{
}
void PatientDetailForm::setPatientInformation(PatientInformation* information) {
if (information)
{
mLblPatID->setText(information->ID);
mLblDOB->setText(information->BirthDate);
mLblName->setText(information->Name);
mLblSex->setText((information->Sex == "F" ? tr("Female") : (information->Sex == "M" ? tr("Male") : tr("Other"))));
mCurrentPatientUID = information->PatientUID;
mLblAddDate->setText(QDateTime::fromString(information->AddDate, Qt::ISODate).toString("yyyy-MM-dd HH:mm:ss"));
mLblAccno->setText(information->AccessionNumber);
mStore = *information;
}
}
void PatientDetailForm::clearPatientInformation() {
mLblPatID->clear();
mLblDOB->clear();
mLblName->clear();
mLblSex->clear();
mLblAddDate->clear();
mLblAccno->clear();
}
void PatientDetailForm::confirmModeOn(int protocol)
{
mLblPatInfTitle->setText(tr("Scan with this Patient?"));
mLblAddDate->setText((protocol==0?tr("Left"):tr("Right")));
mLblAddDateTitle->setText(tr("Protocol"));
}
void PatientDetailForm::storePatientInformation() {
}