Mercurial > hg > orthanc
diff OrthancServer/ServerIndex.cpp @ 3006:0e1755e5efd0
DicomMap::ExtractMainDicomTags()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 13 Dec 2018 12:37:10 +0100 |
parents | 96089d1aba4d |
children | 8336204d95dc 4e43e67f8ecf |
line wrap: on
line diff
--- a/OrthancServer/ServerIndex.cpp Wed Dec 12 15:42:33 2018 +0100 +++ b/OrthancServer/ServerIndex.cpp Thu Dec 13 12:37:10 2018 +0100 @@ -2248,6 +2248,78 @@ } + bool ServerIndex::GetAllMainDicomTags(DicomMap& result, + const std::string& instancePublicId) + { + result.Clear(); + + boost::mutex::scoped_lock lock(mutex_); + + // Lookup for the requested resource + int64_t instance; + ResourceType type; + if (!db_.LookupResource(instance, type, instancePublicId) || + type != ResourceType_Instance) + { + return false; + } + else + { + DicomMap tmp; + + db_.GetMainDicomTags(tmp, instance); + result.Merge(tmp); + + int64_t series; + if (!db_.LookupParent(series, instance)) + { + throw OrthancException(ErrorCode_InternalError); + } + + tmp.Clear(); + db_.GetMainDicomTags(tmp, series); + result.Merge(tmp); + + int64_t study; + if (!db_.LookupParent(study, series)) + { + throw OrthancException(ErrorCode_InternalError); + } + + tmp.Clear(); + db_.GetMainDicomTags(tmp, study); + result.Merge(tmp); + +#ifndef NDEBUG + { + // Sanity test to check that all the main DICOM tags from the + // patient level are copied at the study level + + int64_t patient; + if (!db_.LookupParent(patient, study)) + { + throw OrthancException(ErrorCode_InternalError); + } + + tmp.Clear(); + db_.GetMainDicomTags(tmp, study); + + std::set<DicomTag> patientTags; + tmp.GetTags(patientTags); + + for (std::set<DicomTag>::const_iterator + it = patientTags.begin(); it != patientTags.end(); ++it) + { + assert(result.HasTag(*it)); + } + } +#endif + + return true; + } + } + + bool ServerIndex::LookupResourceType(ResourceType& type, const std::string& publicId) {