Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 5826:d73dfb4548c6 find-refactoring
tools/find: ParentPatient and co ..
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Mon, 07 Oct 2024 10:51:27 +0200 |
parents | 881cd0965146 |
children | 7030fa489669 |
comparison
equal
deleted
inserted
replaced
5825:881cd0965146 | 5826:d73dfb4548c6 |
---|---|
3250 static const char* const KEY_LABELS_CONSTRAINT = "LabelsConstraint"; // New in Orthanc 1.12.0 | 3250 static const char* const KEY_LABELS_CONSTRAINT = "LabelsConstraint"; // New in Orthanc 1.12.0 |
3251 static const char* const KEY_ORDER_BY = "OrderBy"; // New in Orthanc 1.12.5 | 3251 static const char* const KEY_ORDER_BY = "OrderBy"; // New in Orthanc 1.12.5 |
3252 static const char* const KEY_ORDER_BY_KEY = "Key"; // New in Orthanc 1.12.5 | 3252 static const char* const KEY_ORDER_BY_KEY = "Key"; // New in Orthanc 1.12.5 |
3253 static const char* const KEY_ORDER_BY_TYPE = "Type"; // New in Orthanc 1.12.5 | 3253 static const char* const KEY_ORDER_BY_TYPE = "Type"; // New in Orthanc 1.12.5 |
3254 static const char* const KEY_ORDER_BY_DIRECTION = "Direction"; // New in Orthanc 1.12.5 | 3254 static const char* const KEY_ORDER_BY_DIRECTION = "Direction"; // New in Orthanc 1.12.5 |
3255 | 3255 static const char* const KEY_PARENT_PATIENT = "ParentPatient"; // New in Orthanc 1.12.5 |
3256 static const char* const KEY_PARENT_STUDY = "ParentStudy"; // New in Orthanc 1.12.5 | |
3257 static const char* const KEY_PARENT_SERIES = "ParentSeries"; // New in Orthanc 1.12.5 | |
3256 | 3258 |
3257 if (call.IsDocumentation()) | 3259 if (call.IsDocumentation()) |
3258 { | 3260 { |
3259 OrthancRestApi::DocumentDicomFormat(call, DicomToJsonFormat_Human); | 3261 OrthancRestApi::DocumentDicomFormat(call, DicomToJsonFormat_Human); |
3260 | 3262 |
3285 .SetRequestField(KEY_LABELS, RestApiCallDocumentation::Type_JsonListOfStrings, | 3287 .SetRequestField(KEY_LABELS, RestApiCallDocumentation::Type_JsonListOfStrings, |
3286 "List of strings specifying which labels to look for in the resources (new in Orthanc 1.12.0)", true) | 3288 "List of strings specifying which labels to look for in the resources (new in Orthanc 1.12.0)", true) |
3287 .SetRequestField(KEY_LABELS_CONSTRAINT, RestApiCallDocumentation::Type_String, | 3289 .SetRequestField(KEY_LABELS_CONSTRAINT, RestApiCallDocumentation::Type_String, |
3288 "Constraint on the labels, can be `All`, `Any`, or `None` (defaults to `All`, new in Orthanc 1.12.0)", true) | 3290 "Constraint on the labels, can be `All`, `Any`, or `None` (defaults to `All`, new in Orthanc 1.12.0)", true) |
3289 .SetRequestField(KEY_ORDER_BY, RestApiCallDocumentation::Type_JsonListOfObjects, | 3291 .SetRequestField(KEY_ORDER_BY, RestApiCallDocumentation::Type_JsonListOfObjects, |
3290 "Array of associative arrays containing the requested ordering", true) | 3292 "Array of associative arrays containing the requested ordering (new in Orthanc 1.12.5)", true) |
3293 .SetRequestField(KEY_PARENT_PATIENT, RestApiCallDocumentation::Type_String, | |
3294 "Limit the reported resources to descendants of this patient (new in Orthanc 1.12.5)", true) | |
3295 .SetRequestField(KEY_PARENT_STUDY, RestApiCallDocumentation::Type_String, | |
3296 "Limit the reported resources to descendants of this study (new in Orthanc 1.12.5)", true) | |
3297 .SetRequestField(KEY_PARENT_SERIES, RestApiCallDocumentation::Type_String, | |
3298 "Limit the reported resources to descendants of this series (new in Orthanc 1.12.5)", true) | |
3291 .AddAnswerType(MimeType_Json, "JSON array containing either the Orthanc identifiers, or detailed information " | 3299 .AddAnswerType(MimeType_Json, "JSON array containing either the Orthanc identifiers, or detailed information " |
3292 "about the reported resources (if `Expand` argument is `true`)"); | 3300 "about the reported resources (if `Expand` argument is `true`)"); |
3293 return; | 3301 return; |
3294 } | 3302 } |
3295 | 3303 |
3353 else if (request.isMember(KEY_ORDER_BY) && | 3361 else if (request.isMember(KEY_ORDER_BY) && |
3354 request[KEY_ORDER_BY].type() != Json::arrayValue) | 3362 request[KEY_ORDER_BY].type() != Json::arrayValue) |
3355 { | 3363 { |
3356 throw OrthancException(ErrorCode_BadRequest, | 3364 throw OrthancException(ErrorCode_BadRequest, |
3357 "Field \"" + std::string(KEY_ORDER_BY) + "\" must be an array"); | 3365 "Field \"" + std::string(KEY_ORDER_BY) + "\" must be an array"); |
3366 } | |
3367 else if (request.isMember(KEY_PARENT_PATIENT) && | |
3368 request[KEY_PARENT_PATIENT].type() != Json::stringValue) | |
3369 { | |
3370 throw OrthancException(ErrorCode_BadRequest, | |
3371 "Field \"" + std::string(KEY_PARENT_PATIENT) + "\" must be a string"); | |
3372 } | |
3373 else if (request.isMember(KEY_PARENT_STUDY) && | |
3374 request[KEY_PARENT_STUDY].type() != Json::stringValue) | |
3375 { | |
3376 throw OrthancException(ErrorCode_BadRequest, | |
3377 "Field \"" + std::string(KEY_PARENT_STUDY) + "\" must be a string"); | |
3378 } | |
3379 else if (request.isMember(KEY_PARENT_SERIES) && | |
3380 request[KEY_PARENT_SERIES].type() != Json::stringValue) | |
3381 { | |
3382 throw OrthancException(ErrorCode_BadRequest, | |
3383 "Field \"" + std::string(KEY_PARENT_SERIES) + "\" must be a string"); | |
3358 } | 3384 } |
3359 else if (true) | 3385 else if (true) |
3360 { | 3386 { |
3361 /** | 3387 /** |
3362 * EXPERIMENTAL VERSION | 3388 * EXPERIMENTAL VERSION |
3478 else | 3504 else |
3479 { | 3505 { |
3480 throw OrthancException(ErrorCode_BadRequest, "Field \"" + std::string(KEY_LABELS_CONSTRAINT) + "\" must be \"All\", \"Any\", or \"None\""); | 3506 throw OrthancException(ErrorCode_BadRequest, "Field \"" + std::string(KEY_LABELS_CONSTRAINT) + "\" must be \"All\", \"Any\", or \"None\""); |
3481 } | 3507 } |
3482 } | 3508 } |
3509 | |
3510 if (request.isMember(KEY_PARENT_PATIENT)) // New in Orthanc 1.12.5 | |
3511 { | |
3512 finder.SetOrthancId(ResourceType_Patient, request[KEY_PARENT_PATIENT].asString()); | |
3513 } | |
3514 else if (request.isMember(KEY_PARENT_STUDY)) | |
3515 { | |
3516 finder.SetOrthancId(ResourceType_Study, request[KEY_PARENT_STUDY].asString()); | |
3517 } | |
3518 else if (request.isMember(KEY_PARENT_SERIES)) | |
3519 { | |
3520 finder.SetOrthancId(ResourceType_Series, request[KEY_PARENT_SERIES].asString()); | |
3521 } | |
3483 | 3522 |
3484 if (request.isMember(KEY_ORDER_BY)) // New in Orthanc 1.12.5 | 3523 if (request.isMember(KEY_ORDER_BY)) // New in Orthanc 1.12.5 |
3485 { | 3524 { |
3486 for (Json::Value::ArrayIndex i = 0; i < request[KEY_ORDER_BY].size(); i++) | 3525 for (Json::Value::ArrayIndex i = 0; i < request[KEY_ORDER_BY].size(); i++) |
3487 { | 3526 { |