Make the combination of patient ID and accession number unique.
This commit is contained in:
@@ -21,11 +21,11 @@
|
||||
namespace
|
||||
{
|
||||
const int ENDLINE_SPACE = 3;
|
||||
int queryValue(QSqlTableModel* model, int colID, const QVariant& var)
|
||||
int queryValue(QSqlTableModel* model, int aColIDIndex, const QVariant& aPatId, int aColAccessionNumberIndex, const QVariant& aAccessionNumber)
|
||||
{
|
||||
for (int i = 0; i < model->rowCount(); ++i)
|
||||
{
|
||||
if (model->data(model->index(i, colID)) == var) return i;
|
||||
if (model->data(model->index(i, aColIDIndex)) == aPatId && model->data(model->index(i, aColAccessionNumberIndex)) == aAccessionNumber) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -189,10 +189,10 @@ bool EditPatientDialog::updateReferenceData()
|
||||
bool isAdd = currentPatientUID.isEmpty();
|
||||
if (isAdd)
|
||||
{
|
||||
int ref_rowid = queryValue(model, 1, inf->ID);
|
||||
int ref_rowid = queryValue(model, 1, inf->ID, 2, inf->AccessionNumber);
|
||||
if (ref_rowid >= 0)
|
||||
{
|
||||
lbl_error->setText("The ID is already existed!");
|
||||
lbl_error->setText("The ID and Accession number is already existed!");
|
||||
lbl_error->setVisible(true);
|
||||
return false;
|
||||
}
|
||||
@@ -203,7 +203,7 @@ bool EditPatientDialog::updateReferenceData()
|
||||
else
|
||||
{
|
||||
inf->PatientUID = currentPatientUID;
|
||||
selectedRow = queryValue(model, 1, inf->ID);
|
||||
selectedRow = queryValue(model, 1, inf->ID, 2, inf->AccessionNumber);
|
||||
inf->AddDate = AddDate;
|
||||
}
|
||||
inf->Sex = btnSex->text() == tr("Female") ? "F" : (tr("Male") == btnSex->text() ? "M" : "O");
|
||||
|
||||
Reference in New Issue
Block a user