|
@@ -595,15 +595,19 @@ void ctkDICOMDatabasePrivate::insert( const ctkDICOMDataset& ctkDataset, const Q
|
|
|
}
|
|
|
|
|
|
QSqlQuery checkPatientExistsQuery(Database);
|
|
|
- //The dbPatientID is a unique number within the database, generated by the sqlite autoincrement
|
|
|
+ //The dbPatientID is a unique number within the database,
|
|
|
+ //generated by the sqlite autoincrement
|
|
|
//The patientID is the (non-unique) DICOM patient id
|
|
|
int dbPatientID = -1;
|
|
|
|
|
|
if ( patientID != "" && patientsName != "" )
|
|
|
- {
|
|
|
- //Speed up: Check if patient is the same as in last file; very probable, as all images belonging to a study have the same patient
|
|
|
- if( lastPatientID != patientID || lastPatientsBirthDate != patientsBirthDate || lastPatientsName != patientsName )
|
|
|
{
|
|
|
+ //Speed up: Check if patient is the same as in last file;
|
|
|
+ // very probable, as all images belonging to a study have the same patient
|
|
|
+ if ( lastPatientID != patientID
|
|
|
+ || lastPatientsBirthDate != patientsBirthDate
|
|
|
+ || lastPatientsName != patientsName )
|
|
|
+ {
|
|
|
// Ok, something is different from last insert, let's insert him if he's not
|
|
|
// already in the db.
|
|
|
//
|
|
@@ -621,7 +625,7 @@ void ctkDICOMDatabasePrivate::insert( const ctkDICOMDataset& ctkDataset, const Q
|
|
|
dbPatientID = checkPatientExistsQuery.value(checkPatientExistsQuery.record().indexOf("UID")).toInt();
|
|
|
}
|
|
|
else
|
|
|
- {
|
|
|
+ {
|
|
|
// Insert it
|
|
|
QSqlQuery insertPatientStatement ( Database );
|
|
|
insertPatientStatement.prepare ( "INSERT INTO Patients ('UID', 'PatientsName', 'PatientID', 'PatientsBirthDate', 'PatientsBirthTime', 'PatientsSex', 'PatientsAge', 'PatientsComments' ) values ( NULL, ?, ?, ?, ?, ?, ?, ? )" );
|
|
@@ -630,20 +634,20 @@ void ctkDICOMDatabasePrivate::insert( const ctkDICOMDataset& ctkDataset, const Q
|
|
|
insertPatientStatement.bindValue ( 2, patientsBirthDate );
|
|
|
insertPatientStatement.bindValue ( 3, patientsBirthTime );
|
|
|
insertPatientStatement.bindValue ( 4, patientsSex );
|
|
|
- // TODO: shift patient's age to study, since this is not a patient level attribute in images
|
|
|
+ // TODO: shift patient's age to study,
|
|
|
+ // since this is not a patient level attribute in images
|
|
|
// insertPatientStatement.bindValue ( 5, patientsAge );
|
|
|
insertPatientStatement.bindValue ( 6, patientComments );
|
|
|
loggedExec(insertPatientStatement);
|
|
|
dbPatientID = insertPatientStatement.lastInsertId().toInt();
|
|
|
logger.debug ( "New patient inserted: " + QString().setNum ( dbPatientID ) );
|
|
|
-
|
|
|
- }
|
|
|
+ }
|
|
|
/// keep this for the next image
|
|
|
lastPatientUID = dbPatientID;
|
|
|
lastPatientID = patientID;
|
|
|
lastPatientsBirthDate = patientsBirthDate;
|
|
|
lastPatientsName = patientsName;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
// Patient is in now. Let's continue with the study
|
|
|
|
|
@@ -706,7 +710,9 @@ void ctkDICOMDatabasePrivate::insert( const ctkDICOMDataset& ctkDataset, const Q
|
|
|
insertSeriesStatement.bindValue ( 12, static_cast<int>(temporalPosition) );
|
|
|
if ( !insertSeriesStatement.exec() )
|
|
|
{
|
|
|
- logger.error ( "Error executing statament: " + insertSeriesStatement.lastQuery() + " Error: " + insertSeriesStatement.lastError().text() );
|
|
|
+ logger.error ( "Error executing statament: "
|
|
|
+ + insertSeriesStatement.lastQuery()
|
|
|
+ + " Error: " + insertSeriesStatement.lastError().text() );
|
|
|
lastSeriesInstanceUID = "";
|
|
|
}
|
|
|
else
|