Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp @ 4697:569d9ef165b1
Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 18 Jun 2021 16:08:35 +0200 |
parents | a3c6678aa7b1 |
children | d16c3c7f11ef |
comparison
equal
deleted
inserted
replaced
4696:dd6274412ff4 | 4697:569d9ef165b1 |
---|---|
458 DocumentSubmitGenericJob(call); | 458 DocumentSubmitGenericJob(call); |
459 call.GetDocumentation() | 459 call.GetDocumentation() |
460 .SetRequestField(KEY_PERMISSIVE, RestApiCallDocumentation::Type_Boolean, | 460 .SetRequestField(KEY_PERMISSIVE, RestApiCallDocumentation::Type_Boolean, |
461 "If `true`, ignore errors during the individual steps of the job.", false); | 461 "If `true`, ignore errors during the individual steps of the job.", false); |
462 } | 462 } |
463 | |
464 | |
465 static const std::string GET_SIMPLIFY = "simplify"; | |
466 static const std::string GET_FULL = "full"; | |
467 static const std::string GET_SHORT = "short"; | |
468 | |
469 static const std::string POST_SIMPLIFY = "Simplify"; | |
470 static const std::string POST_FULL = "Full"; | |
471 static const std::string POST_SHORT = "Short"; | |
472 | |
473 static const std::string DOCUMENT_SIMPLIFY = | |
474 "report the DICOM tags indexed in human-readable format " | |
475 "(using the symbolic name of the tags)"; | |
476 | |
477 static const std::string DOCUMENT_SHORT = | |
478 "report the DICOM tags indexed in hexadecimal format"; | |
479 | |
480 static const std::string DOCUMENT_FULL = | |
481 "report the DICOM tags in full format (tags indexed by their hexadecimal " | |
482 "format, associated with their symbolic name and their value)"; | |
483 | |
484 | |
485 DicomToJsonFormat OrthancRestApi::GetDicomFormat(const RestApiGetCall& call, | |
486 DicomToJsonFormat defaultFormat) | |
487 { | |
488 if (call.HasArgument(GET_SIMPLIFY)) | |
489 { | |
490 return DicomToJsonFormat_Human; | |
491 } | |
492 else if (call.HasArgument(GET_SHORT)) | |
493 { | |
494 return DicomToJsonFormat_Short; | |
495 } | |
496 else if (call.HasArgument(GET_FULL)) | |
497 { | |
498 return DicomToJsonFormat_Full; | |
499 } | |
500 else | |
501 { | |
502 return defaultFormat; | |
503 } | |
504 } | |
505 | |
506 | |
507 DicomToJsonFormat OrthancRestApi::GetDicomFormat(const Json::Value& body, | |
508 DicomToJsonFormat defaultFormat) | |
509 { | |
510 if (body.isMember(POST_SIMPLIFY) && | |
511 SerializationToolbox::ReadBoolean(body, POST_SIMPLIFY)) | |
512 { | |
513 return DicomToJsonFormat_Human; | |
514 } | |
515 else if (body.isMember(POST_SHORT) && | |
516 SerializationToolbox::ReadBoolean(body, POST_SHORT)) | |
517 { | |
518 return DicomToJsonFormat_Short; | |
519 } | |
520 else if (body.isMember(POST_FULL) && | |
521 SerializationToolbox::ReadBoolean(body, POST_FULL)) | |
522 { | |
523 return DicomToJsonFormat_Full; | |
524 } | |
525 else | |
526 { | |
527 return defaultFormat; | |
528 } | |
529 } | |
530 | |
531 | |
532 void OrthancRestApi::DocumentDicomFormat(RestApiGetCall& call, | |
533 DicomToJsonFormat defaultFormat) | |
534 { | |
535 if (defaultFormat != DicomToJsonFormat_Human) | |
536 { | |
537 call.GetDocumentation().SetHttpGetArgument( | |
538 GET_SIMPLIFY, RestApiCallDocumentation::Type_Boolean, "If present, " + DOCUMENT_SIMPLIFY, false); | |
539 } | |
540 | |
541 if (defaultFormat != DicomToJsonFormat_Short) | |
542 { | |
543 call.GetDocumentation().SetHttpGetArgument( | |
544 GET_SHORT, RestApiCallDocumentation::Type_Boolean, "If present, " + DOCUMENT_SHORT, false); | |
545 } | |
546 | |
547 if (defaultFormat != DicomToJsonFormat_Full) | |
548 { | |
549 call.GetDocumentation().SetHttpGetArgument( | |
550 GET_FULL, RestApiCallDocumentation::Type_Boolean, "If present, " + DOCUMENT_FULL, false); | |
551 } | |
552 } | |
553 | |
554 | |
555 void OrthancRestApi::DocumentDicomFormat(RestApiPostCall& call, | |
556 DicomToJsonFormat defaultFormat) | |
557 { | |
558 if (defaultFormat != DicomToJsonFormat_Human) | |
559 { | |
560 call.GetDocumentation().SetRequestField(POST_SIMPLIFY, RestApiCallDocumentation::Type_Boolean, | |
561 "If set to `true`, " + DOCUMENT_SIMPLIFY, false); | |
562 } | |
563 | |
564 if (defaultFormat != DicomToJsonFormat_Short) | |
565 { | |
566 call.GetDocumentation().SetRequestField(POST_SHORT, RestApiCallDocumentation::Type_Boolean, | |
567 "If set to `true`, " + DOCUMENT_SIMPLIFY, false); | |
568 } | |
569 | |
570 if (defaultFormat != DicomToJsonFormat_Full) | |
571 { | |
572 call.GetDocumentation().SetRequestField(POST_FULL, RestApiCallDocumentation::Type_Boolean, | |
573 "If set to `true`, " + DOCUMENT_SIMPLIFY, false); | |
574 } | |
575 } | |
463 } | 576 } |