comparison OrthancServer/OrthancRestApi/OrthancRestModalities.cpp @ 3370:872bd3b6ec72

"/modalities/{id}/query": New argument "Normalize"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 14 May 2019 10:30:43 +0200
parents f687e11aeb13
children d0d6bd633e4c
comparison
equal deleted inserted replaced
3369:20b38a533254 3370:872bd3b6ec72
50 50
51 namespace Orthanc 51 namespace Orthanc
52 { 52 {
53 static const char* const KEY_LEVEL = "Level"; 53 static const char* const KEY_LEVEL = "Level";
54 static const char* const KEY_QUERY = "Query"; 54 static const char* const KEY_QUERY = "Query";
55 static const char* const KEY_NORMALIZE = "Normalize";
55 static const char* const KEY_RESOURCES = "Resources"; 56 static const char* const KEY_RESOURCES = "Resources";
56 57
57 58
58 static RemoteModalityParameters MyGetModalityUsingSymbolicName(const std::string& name) 59 static RemoteModalityParameters MyGetModalityUsingSymbolicName(const std::string& name)
59 { 60 {
129 const DicomMap& fields) 130 const DicomMap& fields)
130 { 131 {
131 // Only keep the filters from "fields" that are related to the patient 132 // Only keep the filters from "fields" that are related to the patient
132 DicomMap s; 133 DicomMap s;
133 fields.ExtractPatientInformation(s); 134 fields.ExtractPatientInformation(s);
134 connection.Find(result, ResourceType_Patient, s); 135 connection.Find(result, ResourceType_Patient, s, true /* normalize */);
135 } 136 }
136 137
137 138
138 static void FindStudy(DicomFindAnswers& result, 139 static void FindStudy(DicomFindAnswers& result,
139 DicomUserConnection& connection, 140 DicomUserConnection& connection,
145 146
146 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID); 147 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID);
147 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER); 148 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER);
148 s.CopyTagIfExists(fields, DICOM_TAG_MODALITIES_IN_STUDY); 149 s.CopyTagIfExists(fields, DICOM_TAG_MODALITIES_IN_STUDY);
149 150
150 connection.Find(result, ResourceType_Study, s); 151 connection.Find(result, ResourceType_Study, s, true /* normalize */);
151 } 152 }
152 153
153 static void FindSeries(DicomFindAnswers& result, 154 static void FindSeries(DicomFindAnswers& result,
154 DicomUserConnection& connection, 155 DicomUserConnection& connection,
155 const DicomMap& fields) 156 const DicomMap& fields)
160 161
161 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID); 162 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID);
162 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER); 163 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER);
163 s.CopyTagIfExists(fields, DICOM_TAG_STUDY_INSTANCE_UID); 164 s.CopyTagIfExists(fields, DICOM_TAG_STUDY_INSTANCE_UID);
164 165
165 connection.Find(result, ResourceType_Series, s); 166 connection.Find(result, ResourceType_Series, s, true /* normalize */);
166 } 167 }
167 168
168 static void FindInstance(DicomFindAnswers& result, 169 static void FindInstance(DicomFindAnswers& result,
169 DicomUserConnection& connection, 170 DicomUserConnection& connection,
170 const DicomMap& fields) 171 const DicomMap& fields)
176 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID); 177 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID);
177 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER); 178 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER);
178 s.CopyTagIfExists(fields, DICOM_TAG_STUDY_INSTANCE_UID); 179 s.CopyTagIfExists(fields, DICOM_TAG_STUDY_INSTANCE_UID);
179 s.CopyTagIfExists(fields, DICOM_TAG_SERIES_INSTANCE_UID); 180 s.CopyTagIfExists(fields, DICOM_TAG_SERIES_INSTANCE_UID);
180 181
181 connection.Find(result, ResourceType_Instance, s); 182 connection.Find(result, ResourceType_Instance, s, true /* normalize */);
182 } 183 }
183 184
184 185
185 static void DicomFindPatient(RestApiPostCall& call) 186 static void DicomFindPatient(RestApiPostCall& call)
186 { 187 {
451 request[KEY_LEVEL].type() != Json::stringValue) 452 request[KEY_LEVEL].type() != Json::stringValue)
452 { 453 {
453 throw OrthancException(ErrorCode_BadFileFormat, 454 throw OrthancException(ErrorCode_BadFileFormat,
454 "The JSON body must contain field " + std::string(KEY_LEVEL)); 455 "The JSON body must contain field " + std::string(KEY_LEVEL));
455 } 456 }
457 else if (request.isMember(KEY_NORMALIZE) &&
458 request[KEY_NORMALIZE].type() != Json::booleanValue)
459 {
460 throw OrthancException(ErrorCode_BadFileFormat,
461 "The field " + std::string(KEY_NORMALIZE) + " must contain a Boolean");
462 }
456 else if (request.isMember(KEY_QUERY) && 463 else if (request.isMember(KEY_QUERY) &&
457 request[KEY_QUERY].type() != Json::objectValue) 464 request[KEY_QUERY].type() != Json::objectValue)
458 { 465 {
459 throw OrthancException(ErrorCode_BadFileFormat, 466 throw OrthancException(ErrorCode_BadFileFormat,
460 "The field " + std::string(KEY_QUERY) + " must contain a JSON object"); 467 "The field " + std::string(KEY_QUERY) + " must contain a JSON object");
461 } 468 }
462 else 469 else
463 { 470 {
464 std::auto_ptr<QueryRetrieveHandler> handler(new QueryRetrieveHandler(context)); 471 std::auto_ptr<QueryRetrieveHandler> handler(new QueryRetrieveHandler(context));
465 472
466 handler->SetModality(call.GetUriComponent("id", "")); 473 handler->SetModality(call.GetUriComponent("id", ""));
467 handler->SetLevel(StringToResourceType(request[KEY_LEVEL].asCString())); 474 handler->SetLevel(StringToResourceType(request[KEY_LEVEL].asCString()));
468 475
469 if (request.isMember(KEY_QUERY)) 476 if (request.isMember(KEY_QUERY))
470 { 477 {
474 for (std::map<DicomTag, std::string>::const_iterator 481 for (std::map<DicomTag, std::string>::const_iterator
475 it = query.begin(); it != query.end(); ++it) 482 it = query.begin(); it != query.end(); ++it)
476 { 483 {
477 handler->SetQuery(it->first, it->second); 484 handler->SetQuery(it->first, it->second);
478 } 485 }
486 }
487
488 if (request.isMember(KEY_NORMALIZE))
489 {
490 handler->SetFindNormalized(request[KEY_NORMALIZE].asBool());
479 } 491 }
480 492
481 AnswerQueryHandler(call, handler); 493 AnswerQueryHandler(call, handler);
482 } 494 }
483 } 495 }
770 { 782 {
771 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON object"); 783 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON object");
772 } 784 }
773 else 785 else
774 { 786 {
787 handler->SetFindNormalized(parent.GetHandler().IsFindNormalized());
775 handler->SetModality(parent.GetHandler().GetModalitySymbolicName()); 788 handler->SetModality(parent.GetHandler().GetModalitySymbolicName());
776 handler->SetLevel(CHILDREN_LEVEL); 789 handler->SetLevel(CHILDREN_LEVEL);
777 790
778 if (request.isMember(KEY_QUERY)) 791 if (request.isMember(KEY_QUERY))
779 { 792 {