# HG changeset patch # User Sebastien Jodogne # Date 1422020553 -3600 # Node ID 6164f7200c433d5ff329bfcc6d6792b88693a474 # Parent 4287285709d136114e7d6e852ce915d4b6f6a275 refactoring modules diff -r 4287285709d1 -r 6164f7200c43 Core/DicomFormat/DicomTag.cpp --- a/Core/DicomFormat/DicomTag.cpp Wed Jan 21 17:47:27 2015 +0100 +++ b/Core/DicomFormat/DicomTag.cpp Fri Jan 23 14:42:33 2015 +0100 @@ -119,14 +119,14 @@ void DicomTag::GetTagsForModule(std::set& target, - ResourceType module) + DicomModule module) { // REFERENCE: 11_03pu.pdf, DICOM PS 3.3 2011 - Information Object Definitions target.clear(); switch (module) { - case ResourceType_Patient: + case DicomModule_Patient: // This is Table C.7-1 "Patient Module Attributes" (p. 373) target.insert(DicomTag(0x0010, 0x0010)); // Patient's name target.insert(DicomTag(0x0010, 0x0020)); // Patient ID @@ -156,7 +156,7 @@ target.insert(DicomTag(0x0010, 0x0024)); // Issuer of Patient ID qualifiers sequence break; - case ResourceType_Study: + case DicomModule_Study: // This is Table C.7-3 "General Study Module Attributes" (p. 378) target.insert(DicomTag(0x0020, 0x000d)); // Study instance UID target.insert(DicomTag(0x0008, 0x0020)); // Study date @@ -177,7 +177,7 @@ target.insert(DicomTag(0x0040, 0x1012)); // Reason for performed procedure code sequence break; - case ResourceType_Series: + case DicomModule_Series: // This is Table C.7-5 "General Series Module Attributes" (p. 385) target.insert(DicomTag(0x0008, 0x0060)); // Modality target.insert(DicomTag(0x0020, 0x000e)); // Series Instance UID @@ -210,7 +210,7 @@ target.insert(DicomTag(0x0040, 0x0280)); // Comments on the Performed Procedure Step break; - case ResourceType_Instance: + case DicomModule_Instance: // This is Table C.12-1 "SOP Common Module Attributes" (p. 1207) target.insert(DicomTag(0x0008, 0x0016)); // SOP Class UID target.insert(DicomTag(0x0008, 0x0018)); // SOP Instance UID diff -r 4287285709d1 -r 6164f7200c43 Core/DicomFormat/DicomTag.h --- a/Core/DicomFormat/DicomTag.h Wed Jan 21 17:47:27 2015 +0100 +++ b/Core/DicomFormat/DicomTag.h Fri Jan 23 14:42:33 2015 +0100 @@ -85,7 +85,7 @@ friend std::ostream& operator<< (std::ostream& o, const DicomTag& tag); static void GetTagsForModule(std::set& target, - ResourceType module); + DicomModule module); bool IsIdentifier() const; }; diff -r 4287285709d1 -r 6164f7200c43 Core/Enumerations.h --- a/Core/Enumerations.h Wed Jan 21 17:47:27 2015 +0100 +++ b/Core/Enumerations.h Fri Jan 23 14:42:33 2015 +0100 @@ -274,6 +274,15 @@ PhotometricInterpretation_Unknown }; + enum DicomModule + { + DicomModule_Patient, + DicomModule_Study, + DicomModule_Series, + DicomModule_Instance, + DicomModule_Image + }; + /** * WARNING: Do not change the explicit values in the enumerations diff -r 4287285709d1 -r 6164f7200c43 OrthancServer/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Wed Jan 21 17:47:27 2015 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Fri Jan 23 14:42:33 2015 +0100 @@ -713,10 +713,14 @@ static void GetModuleInternal(RestApiGetCall& call, ResourceType resourceType, - ResourceType queryLevel) + DicomModule module) { - if (resourceType != queryLevel && - !(resourceType == ResourceType_Study && queryLevel == ResourceType_Patient)) + if (!((resourceType == ResourceType_Patient && module == DicomModule_Patient) || + (resourceType == ResourceType_Study && module == DicomModule_Patient) || + (resourceType == ResourceType_Study && module == DicomModule_Study) || + (resourceType == ResourceType_Series && module == DicomModule_Series) || + (resourceType == ResourceType_Instance && module == DicomModule_Instance) || + (resourceType == ResourceType_Instance && module == DicomModule_Image))) { throw OrthancException(ErrorCode_NotImplemented); } @@ -725,9 +729,9 @@ std::string publicId = call.GetUriComponent("id", ""); bool simplify = call.HasArgument("simplify"); - typedef std::set Module; - Module module; - DicomTag::GetTagsForModule(module, queryLevel); + typedef std::set ModuleTags; + ModuleTags moduleTags; + DicomTag::GetTagsForModule(moduleTags, module); Json::Value tags; @@ -751,9 +755,9 @@ // Filter the tags of the instance according to the module Json::Value result = Json::objectValue; - for (Module::const_iterator it = module.begin(); it != module.end(); it++) + for (ModuleTags::const_iterator tag = moduleTags.begin(); tag != moduleTags.end(); tag++) { - std::string s = it->Format(); + std::string s = tag->Format(); if (tags.isMember(s)) { result[s] = tags[s]; @@ -774,16 +778,11 @@ - template + template static void GetModule(RestApiGetCall& call) { - GetModuleInternal(call, resourceType, resourceType); - } - - - static void GetPatientModuleForStudy(RestApiGetCall& call) - { - GetModuleInternal(call, ResourceType_Study, ResourceType_Patient); + GetModuleInternal(call, resourceType, module); } @@ -938,11 +937,11 @@ Register("/series/{id}/shared-tags", GetSharedTags); Register("/studies/{id}/shared-tags", GetSharedTags); - Register("/instances/{id}/module", GetModule); - Register("/patients/{id}/module", GetModule); - Register("/series/{id}/module", GetModule); - Register("/studies/{id}/module", GetModule); - Register("/studies/{id}/module-patient", GetPatientModuleForStudy); + Register("/instances/{id}/module", GetModule); + Register("/patients/{id}/module", GetModule); + Register("/series/{id}/module", GetModule); + Register("/studies/{id}/module", GetModule); + Register("/studies/{id}/module-patient", GetModule); Register("/instances/{id}/file", GetInstanceFile); Register("/instances/{id}/export", ExportInstanceFile); diff -r 4287285709d1 -r 6164f7200c43 UnitTestsSources/DicomMapTests.cpp --- a/UnitTestsSources/DicomMapTests.cpp Wed Jan 21 17:47:27 2015 +0100 +++ b/UnitTestsSources/DicomMapTests.cpp Fri Jan 23 14:42:33 2015 +0100 @@ -133,16 +133,17 @@ -static void TestModule(ResourceType level) +static void TestModule(ResourceType level, + DicomModule module) { - std::set module, main; - DicomTag::GetTagsForModule(module, level); + std::set moduleTags, main; + DicomTag::GetTagsForModule(moduleTags, module); DicomMap::GetMainDicomTags(main, level); // The main dicom tags are a subset of the module for (std::set::const_iterator it = main.begin(); it != main.end(); it++) { - bool ok = module.find(*it) != module.end(); + bool ok = moduleTags.find(*it) != moduleTags.end(); // Exceptions for the Series level /*if ((// @@ -182,8 +183,8 @@ TEST(DicomMap, Modules) { - TestModule(ResourceType_Patient); - TestModule(ResourceType_Study); - //TestModule(ResourceType_Series); // TODO - TestModule(ResourceType_Instance); + TestModule(ResourceType_Patient, DicomModule_Patient); + TestModule(ResourceType_Study, DicomModule_Study); + //TestModule(ResourceType_Series, DicomModule_Series); // TODO + TestModule(ResourceType_Instance, DicomModule_Instance); }