comparison OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 964:cc7a4ae474c1

simplify has a GET argument
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 26 Jun 2014 18:17:18 +0200
parents 81134ea872ff
children 83622b0f544c
comparison
equal deleted inserted replaced
963:81134ea872ff 964:cc7a4ae474c1
151 { 151 {
152 call.GetOutput().AnswerJson(full); 152 call.GetOutput().AnswerJson(full);
153 } 153 }
154 } 154 }
155 155
156
157 static void GetInstanceTagsBis(RestApi::GetCall& call)
158 {
159 bool simplify = call.HasArgument("simplify");
160
161 if (simplify)
162 {
163 GetInstanceTags<true>(call);
164 }
165 else
166 {
167 GetInstanceTags<false>(call);
168 }
169 }
170
156 171
157 static void ListFrames(RestApi::GetCall& call) 172 static void ListFrames(RestApi::GetCall& call)
158 { 173 {
159 Json::Value instance; 174 Json::Value instance;
160 if (OrthancRestApi::GetIndex(call).LookupResource(instance, call.GetUriComponent("id", ""), ResourceType_Instance)) 175 if (OrthancRestApi::GetIndex(call).LookupResource(instance, call.GetUriComponent("id", ""), ResourceType_Instance))
664 679
665 return true; 680 return true;
666 } 681 }
667 682
668 683
669
670 template <bool simplify>
671 static void GetSharedTags(RestApi::GetCall& call) 684 static void GetSharedTags(RestApi::GetCall& call)
672 { 685 {
673 ServerContext& context = OrthancRestApi::GetContext(call); 686 ServerContext& context = OrthancRestApi::GetContext(call);
674 std::string publicId = call.GetUriComponent("id", ""); 687 std::string publicId = call.GetUriComponent("id", "");
688 bool simplify = call.HasArgument("simplify");
675 689
676 Json::Value sharedTags; 690 Json::Value sharedTags;
677 if (ExtractSharedTags(sharedTags, context, publicId)) 691 if (ExtractSharedTags(sharedTags, context, publicId))
678 { 692 {
679 // Success: Send the value of the shared tags 693 // Success: Send the value of the shared tags
689 } 703 }
690 } 704 }
691 } 705 }
692 706
693 707
694 template <enum ResourceType resourceType, bool simplify> 708 template <enum ResourceType resourceType>
695 static void GetModule(RestApi::GetCall& call) 709 static void GetModule(RestApi::GetCall& call)
696 { 710 {
697 ServerContext& context = OrthancRestApi::GetContext(call); 711 ServerContext& context = OrthancRestApi::GetContext(call);
698 std::string publicId = call.GetUriComponent("id", ""); 712 std::string publicId = call.GetUriComponent("id", "");
713 bool simplify = call.HasArgument("simplify");
699 714
700 typedef std::set<DicomTag> Module; 715 typedef std::set<DicomTag> Module;
701 Module module; 716 Module module;
702 DicomTag::GetTagsForModule(module, resourceType); 717 DicomTag::GetTagsForModule(module, resourceType);
703 718
764 Register("/instances/{id}/statistics", GetResourceStatistics); 779 Register("/instances/{id}/statistics", GetResourceStatistics);
765 Register("/patients/{id}/statistics", GetResourceStatistics); 780 Register("/patients/{id}/statistics", GetResourceStatistics);
766 Register("/studies/{id}/statistics", GetResourceStatistics); 781 Register("/studies/{id}/statistics", GetResourceStatistics);
767 Register("/series/{id}/statistics", GetResourceStatistics); 782 Register("/series/{id}/statistics", GetResourceStatistics);
768 783
769 Register("/patients/{id}/shared-tags", GetSharedTags<false>); 784 Register("/patients/{id}/shared-tags", GetSharedTags);
770 Register("/patients/{id}/simplified-shared-tags", GetSharedTags<true>); 785 Register("/series/{id}/shared-tags", GetSharedTags);
771 Register("/series/{id}/shared-tags", GetSharedTags<false>); 786 Register("/studies/{id}/shared-tags", GetSharedTags);
772 Register("/series/{id}/simplified-shared-tags", GetSharedTags<true>); 787
773 Register("/studies/{id}/shared-tags", GetSharedTags<false>); 788 Register("/instances/{id}/module", GetModule<ResourceType_Instance>);
774 Register("/studies/{id}/simplified-shared-tags", GetSharedTags<true>); 789 Register("/patients/{id}/module", GetModule<ResourceType_Patient>);
775 790 Register("/series/{id}/module", GetModule<ResourceType_Series>);
776 Register("/instances/{id}/module", GetModule<ResourceType_Instance, false>); 791 Register("/studies/{id}/module", GetModule<ResourceType_Study>);
777 Register("/patients/{id}/module", GetModule<ResourceType_Patient, false>);
778 Register("/series/{id}/module", GetModule<ResourceType_Series, false>);
779 Register("/studies/{id}/module", GetModule<ResourceType_Study, false>);
780 Register("/instances/{id}/simplified-module", GetModule<ResourceType_Instance, true>);
781 Register("/patients/{id}/simplified-module", GetModule<ResourceType_Patient, true>);
782 Register("/series/{id}/simplified-module", GetModule<ResourceType_Series, true>);
783 Register("/studies/{id}/simplified-module", GetModule<ResourceType_Study, true>);
784 792
785 Register("/instances/{id}/file", GetInstanceFile); 793 Register("/instances/{id}/file", GetInstanceFile);
786 Register("/instances/{id}/export", ExportInstanceFile); 794 Register("/instances/{id}/export", ExportInstanceFile);
787 Register("/instances/{id}/tags", GetInstanceTags<false>); 795 Register("/instances/{id}/tags", GetInstanceTagsBis);
788 Register("/instances/{id}/simplified-tags", GetInstanceTags<true>); 796 Register("/instances/{id}/simplified-tags", GetInstanceTags<true>);
789 Register("/instances/{id}/frames", ListFrames); 797 Register("/instances/{id}/frames", ListFrames);
790 798
791 Register("/instances/{id}/frames/{frame}/preview", GetImage<ImageExtractionMode_Preview>); 799 Register("/instances/{id}/frames/{frame}/preview", GetImage<ImageExtractionMode_Preview>);
792 Register("/instances/{id}/frames/{frame}/image-uint8", GetImage<ImageExtractionMode_UInt8>); 800 Register("/instances/{id}/frames/{frame}/image-uint8", GetImage<ImageExtractionMode_UInt8>);