comparison OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 1718:2b812969e136 db-changes

getting rid of an IDatabaseWrapper::LookupIdentifier flavor
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 20 Oct 2015 10:11:22 +0200
parents b80e76dd1d56
children 3b1f7e706d38
comparison
equal deleted inserted replaced
1717:3926e6317a43 1718:2b812969e136
877 { 877 {
878 GetModuleInternal(call, resourceType, module); 878 GetModuleInternal(call, resourceType, module);
879 } 879 }
880 880
881 881
882 static void AccumulateLookupResults(ServerIndex::LookupResults& result,
883 ServerIndex& index,
884 const DicomTag& tag,
885 const std::string& value)
886 {
887 ServerIndex::LookupResults tmp;
888 index.LookupIdentifier(tmp, tag, value);
889 result.insert(result.end(), tmp.begin(), tmp.end());
890 }
891
892
882 static void Lookup(RestApiPostCall& call) 893 static void Lookup(RestApiPostCall& call)
883 { 894 {
884 typedef std::list< std::pair<ResourceType, std::string> > Resources;
885
886 std::string tag; 895 std::string tag;
887 call.BodyToString(tag); 896 call.BodyToString(tag);
888 Resources resources; 897
889 898 ServerIndex::LookupResults resources;
890 OrthancRestApi::GetIndex(call).LookupIdentifier(resources, tag); 899 ServerIndex& index = OrthancRestApi::GetIndex(call);
891 900 AccumulateLookupResults(resources, index, DICOM_TAG_PATIENT_ID, tag);
892 Json::Value result = Json::arrayValue; 901 AccumulateLookupResults(resources, index, DICOM_TAG_STUDY_INSTANCE_UID, tag);
893 902 AccumulateLookupResults(resources, index, DICOM_TAG_SERIES_INSTANCE_UID, tag);
894 for (Resources::const_iterator it = resources.begin(); 903 AccumulateLookupResults(resources, index, DICOM_TAG_SOP_INSTANCE_UID, tag);
895 it != resources.end(); ++it) 904
905 Json::Value result = Json::arrayValue;
906 for (ServerIndex::LookupResults::const_iterator
907 it = resources.begin(); it != resources.end(); ++it)
896 { 908 {
897 ResourceType type = it->first; 909 ResourceType type = it->first;
898 const std::string& id = it->second; 910 const std::string& id = it->second;
899 911
900 Json::Value item = Json::objectValue; 912 Json::Value item = Json::objectValue;