Mercurial > hg > orthanc
diff OrthancServer/Search/LookupIdentifierQuery.cpp @ 2121:7e8889bc95c6
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 07 Nov 2016 11:28:12 +0100 |
parents | a657f7772e69 |
children | a3a65de1840f |
line wrap: on
line diff
--- a/OrthancServer/Search/LookupIdentifierQuery.cpp Mon Nov 07 11:19:19 2016 +0100 +++ b/OrthancServer/Search/LookupIdentifierQuery.cpp Mon Nov 07 11:28:12 2016 +0100 @@ -43,67 +43,6 @@ namespace Orthanc { - static const DicomTag patientIdentifiers[] = - { - DICOM_TAG_PATIENT_ID, - DICOM_TAG_PATIENT_NAME, - DICOM_TAG_PATIENT_BIRTH_DATE - }; - - static const DicomTag studyIdentifiers[] = - { - DICOM_TAG_PATIENT_ID, - DICOM_TAG_PATIENT_NAME, - DICOM_TAG_PATIENT_BIRTH_DATE, - DICOM_TAG_STUDY_INSTANCE_UID, - DICOM_TAG_ACCESSION_NUMBER, - DICOM_TAG_STUDY_DESCRIPTION, - DICOM_TAG_STUDY_DATE - }; - - static const DicomTag seriesIdentifiers[] = - { - DICOM_TAG_SERIES_INSTANCE_UID - }; - - static const DicomTag instanceIdentifiers[] = - { - DICOM_TAG_SOP_INSTANCE_UID - }; - - - void LookupIdentifierQuery::LoadIdentifiers(const DicomTag*& tags, - size_t& size, - ResourceType level) - { - switch (level) - { - case ResourceType_Patient: - tags = patientIdentifiers; - size = sizeof(patientIdentifiers) / sizeof(DicomTag); - break; - - case ResourceType_Study: - tags = studyIdentifiers; - size = sizeof(studyIdentifiers) / sizeof(DicomTag); - break; - - case ResourceType_Series: - tags = seriesIdentifiers; - size = sizeof(seriesIdentifiers) / sizeof(DicomTag); - break; - - case ResourceType_Instance: - tags = instanceIdentifiers; - size = sizeof(instanceIdentifiers) / sizeof(DicomTag); - break; - - default: - throw OrthancException(ErrorCode_ParameterOutOfRange); - } - } - - LookupIdentifierQuery::Disjunction::~Disjunction() { for (size_t i = 0; i < disjunction_.size(); i++) @@ -131,27 +70,6 @@ } - - bool LookupIdentifierQuery::IsIdentifier(const DicomTag& tag, - ResourceType level) - { - const DicomTag* tags; - size_t size; - - LoadIdentifiers(tags, size, level); - - for (size_t i = 0; i < size; i++) - { - if (tag == tags[i]) - { - return true; - } - } - - return false; - } - - void LookupIdentifierQuery::AddConstraint(DicomTag tag, IdentifierConstraintType type, const std::string& value) @@ -169,56 +87,6 @@ } - std::string LookupIdentifierQuery::NormalizeIdentifier(const std::string& value) - { - std::string t; - t.reserve(value.size()); - - for (size_t i = 0; i < value.size(); i++) - { - if (value[i] == '%' || - value[i] == '_') - { - t.push_back(' '); // These characters might break wildcard queries in SQL - } - else if (isascii(value[i]) && - !iscntrl(value[i]) && - (!isspace(value[i]) || value[i] == ' ')) - { - t.push_back(value[i]); - } - } - - Toolbox::ToUpperCase(t); - - return Toolbox::StripSpaces(t); - } - - - void LookupIdentifierQuery::StoreIdentifiers(IDatabaseWrapper& database, - int64_t resource, - ResourceType level, - const DicomMap& map) - { - const DicomTag* tags; - size_t size; - - LoadIdentifiers(tags, size, level); - - for (size_t i = 0; i < size; i++) - { - const DicomValue* value = map.TestAndGetValue(tags[i]); - if (value != NULL && - !value->IsNull() && - !value->IsBinary()) - { - std::string s = NormalizeIdentifier(value->GetContent()); - database.SetIdentifierTag(resource, tags[i], s); - } - } - } - - void LookupIdentifierQuery::Apply(std::list<std::string>& result, IDatabaseWrapper& database) {