Mercurial > hg > orthanc
changeset 1276:6164f7200c43
refactoring modules
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 23 Jan 2015 14:42:33 +0100 |
parents | 4287285709d1 |
children | 46bca019587e |
files | Core/DicomFormat/DicomTag.cpp Core/DicomFormat/DicomTag.h Core/Enumerations.h OrthancServer/OrthancRestApi/OrthancRestResources.cpp UnitTestsSources/DicomMapTests.cpp |
diffstat | 5 files changed, 44 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- 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<DicomTag>& 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
--- 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<DicomTag>& target, - ResourceType module); + DicomModule module); bool IsIdentifier() const; };
--- 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
--- 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<DicomTag> Module; - Module module; - DicomTag::GetTagsForModule(module, queryLevel); + typedef std::set<DicomTag> 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 <enum ResourceType resourceType> + template <enum ResourceType resourceType, + enum DicomModule module> 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<ResourceType_Instance>); - Register("/patients/{id}/module", GetModule<ResourceType_Patient>); - Register("/series/{id}/module", GetModule<ResourceType_Series>); - Register("/studies/{id}/module", GetModule<ResourceType_Study>); - Register("/studies/{id}/module-patient", GetPatientModuleForStudy); + Register("/instances/{id}/module", GetModule<ResourceType_Instance, DicomModule_Instance>); + Register("/patients/{id}/module", GetModule<ResourceType_Patient, DicomModule_Patient>); + Register("/series/{id}/module", GetModule<ResourceType_Series, DicomModule_Series>); + Register("/studies/{id}/module", GetModule<ResourceType_Study, DicomModule_Study>); + Register("/studies/{id}/module-patient", GetModule<ResourceType_Study, DicomModule_Patient>); Register("/instances/{id}/file", GetInstanceFile); Register("/instances/{id}/export", ExportInstanceFile);
--- 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<DicomTag> module, main; - DicomTag::GetTagsForModule(module, level); + std::set<DicomTag> moduleTags, main; + DicomTag::GetTagsForModule(moduleTags, module); DicomMap::GetMainDicomTags(main, level); // The main dicom tags are a subset of the module for (std::set<DicomTag>::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); }