comparison OrthancServer/DatabaseWrapperBase.cpp @ 1727:1ae29c5e52fb db-changes

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 20 Oct 2015 14:50:10 +0200
parents a7c05bbfaf6a
children 4941494b5dd8
comparison
equal deleted inserted replaced
1725:a7c05bbfaf6a 1727:1ae29c5e52fb
664 return s.Step(); 664 return s.Step();
665 } 665 }
666 666
667 667
668 void DatabaseWrapperBase::LookupIdentifier(std::list<int64_t>& target, 668 void DatabaseWrapperBase::LookupIdentifier(std::list<int64_t>& target,
669 ResourceType level,
669 const DicomTag& tag, 670 const DicomTag& tag,
670 const std::string& value) 671 const std::string& value)
671 { 672 {
672 assert(tag == DICOM_TAG_PATIENT_ID || 673 assert((level == ResourceType_Patient && tag == DICOM_TAG_PATIENT_ID) ||
673 tag == DICOM_TAG_STUDY_INSTANCE_UID || 674 (level == ResourceType_Study && tag == DICOM_TAG_STUDY_INSTANCE_UID) ||
674 tag == DICOM_TAG_SERIES_INSTANCE_UID || 675 (level == ResourceType_Study && tag == DICOM_TAG_ACCESSION_NUMBER) ||
675 tag == DICOM_TAG_SOP_INSTANCE_UID || 676 (level == ResourceType_Series && tag == DICOM_TAG_SERIES_INSTANCE_UID) ||
676 tag == DICOM_TAG_ACCESSION_NUMBER); 677 (level == ResourceType_Instance && tag == DICOM_TAG_SOP_INSTANCE_UID));
677 678
678 SQLite::Statement s(db_, SQLITE_FROM_HERE, 679 SQLite::Statement s(db_, SQLITE_FROM_HERE,
679 "SELECT id FROM DicomIdentifiers WHERE tagGroup=? AND tagElement=? and value=?"); 680 "SELECT d.id FROM DicomIdentifiers as d, Resources as r WHERE "
680 681 "d.id = r.internalId AND r.resourceType=? AND d.tagGroup=? AND d.tagElement=? and d.value=?");
681 s.BindInt(0, tag.GetGroup()); 682
682 s.BindInt(1, tag.GetElement()); 683 s.BindInt(0, level);
683 s.BindString(2, value); 684 s.BindInt(1, tag.GetGroup());
685 s.BindInt(2, tag.GetElement());
686 s.BindString(3, value);
684 687
685 target.clear(); 688 target.clear();
686 689
687 while (s.Step()) 690 while (s.Step())
688 { 691 {