annotate OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp @ 4987:48b53ac404d9

New option "filename" in "/.../{id}/archive" and "/.../{id}/media"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 27 Apr 2022 16:56:53 +0200
parents 6eff25f70121
children c014ab79fca5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1819
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1165
diff changeset
4 * Department, University Hospital of Liege, Belgium
4870
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * License, or (at your option) any later version.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * General Public License for more details.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
23 #include "../PrecompiledHeadersServer.h"
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "OrthancRestApi.h"
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
26 #include "../../../OrthancFramework/Sources/Cache/SharedArchive.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
27 #include "../../../OrthancFramework/Sources/DicomNetworking/DicomAssociation.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
28 #include "../../../OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
29 #include "../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
30 #include "../../../OrthancFramework/Sources/Logging.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
31 #include "../../../OrthancFramework/Sources/SerializationToolbox.h"
3095
beeeb6096f27 removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
32
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
33 #include "../OrthancConfiguration.h"
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
34 #include "../QueryRetrieveHandler.h"
3097
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3096
diff changeset
35 #include "../ServerContext.h"
2602
c25f1a52acbc reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2589
diff changeset
36 #include "../ServerJobs/DicomModalityStoreJob.h"
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
37 #include "../ServerJobs/DicomMoveScuJob.h"
2602
c25f1a52acbc reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2589
diff changeset
38 #include "../ServerJobs/OrthancPeerStoreJob.h"
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
39 #include "../ServerToolbox.h"
3737
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
40 #include "../StorageCommitmentReports.h"
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
2573
3372c5255333 StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
42
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 namespace Orthanc
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
45 static const char* const KEY_LEVEL = "Level";
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
46 static const char* const KEY_LOCAL_AET = "LocalAet";
3370
872bd3b6ec72 "/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3345
diff changeset
47 static const char* const KEY_NORMALIZE = "Normalize";
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
48 static const char* const KEY_QUERY = "Query";
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
49 static const char* const KEY_RESOURCES = "Resources";
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
50 static const char* const KEY_TARGET_AET = "TargetAet";
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
51 static const char* const KEY_TIMEOUT = "Timeout";
4340
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
52 static const char* const KEY_CHECK_FIND = "CheckFind";
3808
7f083dfae62b new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3740
diff changeset
53 static const char* const SOP_CLASS_UID = "SOPClassUID";
7f083dfae62b new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3740
diff changeset
54 static const char* const SOP_INSTANCE_UID = "SOPInstanceUID";
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
55
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
56 static RemoteModalityParameters MyGetModalityUsingSymbolicName(const std::string& name)
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
57 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
58 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
59 return lock.GetConfiguration().GetModalityUsingSymbolicName(name);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
60 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
61
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
62
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
63 static void InjectAssociationTimeout(DicomAssociationParameters& params,
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
64 const Json::Value& body)
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
65 {
4339
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
66 if (body.type() == Json::objectValue &&
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
67 body.isMember(KEY_TIMEOUT))
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
68 {
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
69 // New in Orthanc 1.7.0
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
70 params.SetTimeout(SerializationToolbox::ReadUnsignedInteger(body, KEY_TIMEOUT));
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
71 }
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
72 }
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
73
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
74 static DicomAssociationParameters GetAssociationParameters(RestApiPostCall& call,
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
75 const Json::Value& body)
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
76 {
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
77 const std::string& localAet =
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
78 OrthancRestApi::GetContext(call).GetDefaultLocalApplicationEntityTitle();
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
79 const RemoteModalityParameters remote =
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
80 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
81
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
82 DicomAssociationParameters params(localAet, remote);
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
83 InjectAssociationTimeout(params, body);
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
84
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
85 return params;
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
86 }
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
87
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
88
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
89 static DicomAssociationParameters GetAssociationParameters(RestApiPostCall& call)
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
90 {
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
91 Json::Value body;
4339
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
92
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
93 if (!call.ParseJsonRequest(body))
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
94 {
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
95 throw OrthancException(ErrorCode_BadFileFormat, "Cannot parse the JSON body");
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
96 }
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
97
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
98 return GetAssociationParameters(call, body);
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
99 }
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
100
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
101
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
102 static void DocumentModalityParametersShared(RestApiCall& call,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
103 bool includePermissions)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
104 {
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
105 call.GetDocumentation()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
106 .SetRequestField("AET", RestApiCallDocumentation::Type_String,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
107 "AET of the remote DICOM modality", true)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
108 .SetRequestField("Host", RestApiCallDocumentation::Type_String,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
109 "Host address of the remote DICOM modality (typically, an IP address)", true)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
110 .SetRequestField("Port", RestApiCallDocumentation::Type_Number,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
111 "TCP port of the remote DICOM modality", true)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
112 .SetRequestField("Manufacturer", RestApiCallDocumentation::Type_String, "Manufacturer of the remote DICOM "
4438
4a4e33c9082d configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
113 "modality (check configuration option `DicomModalities` for possible values", false)
4a4e33c9082d configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
114 .SetRequestField("UseDicomTls", RestApiCallDocumentation::Type_Boolean, "Whether to use DICOM TLS "
4a4e33c9082d configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
115 "in the SCU connection initiated by Orthanc (new in Orthanc 1.9.0)", false);
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
116
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
117 if (includePermissions)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
118 {
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
119 call.GetDocumentation()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
120 .SetRequestField("AllowEcho", RestApiCallDocumentation::Type_Boolean,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
121 "Whether to accept C-ECHO SCU commands issued by the remote modality", false)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
122 .SetRequestField("AllowStore", RestApiCallDocumentation::Type_Boolean,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
123 "Whether to accept C-STORE SCU commands issued by the remote modality", false)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
124 .SetRequestField("AllowFind", RestApiCallDocumentation::Type_Boolean,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
125 "Whether to accept C-FIND SCU commands issued by the remote modality", false)
4888
8523078f3f4b added new configuration to authorize C-Find for worklist independently from other C-Find
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
126 .SetRequestField("AllowFindWorklist", RestApiCallDocumentation::Type_Boolean,
8523078f3f4b added new configuration to authorize C-Find for worklist independently from other C-Find
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
127 "Whether to accept C-FIND SCU commands for worklists issued by the remote modality", false)
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
128 .SetRequestField("AllowMove", RestApiCallDocumentation::Type_Boolean,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
129 "Whether to accept C-MOVE SCU commands issued by the remote modality", false)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
130 .SetRequestField("AllowGet", RestApiCallDocumentation::Type_Boolean,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
131 "Whether to accept C-GET SCU commands issued by the remote modality", false)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
132 .SetRequestField("AllowStorageCommitment", RestApiCallDocumentation::Type_Boolean,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
133 "Whether to accept storage commitment requests issued by the remote modality", false)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
134 .SetRequestField("AllowTranscoding", RestApiCallDocumentation::Type_Boolean,
4480
d0581d0b22b8 Clarifying documentation of "AllowTranscoding" in "DicomModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4463
diff changeset
135 "Whether to allow transcoding for operations initiated by this modality. "
d0581d0b22b8 Clarifying documentation of "AllowTranscoding" in "DicomModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4463
diff changeset
136 "This option applies to Orthanc C-GET SCP and to Orthanc C-STORE SCU. "
d0581d0b22b8 Clarifying documentation of "AllowTranscoding" in "DicomModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4463
diff changeset
137 "It only has an effect if the global option `EnableTranscoding` is set to `true`.", false);
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
138 }
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
139 }
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
140
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
141
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
142 /***************************************************************************
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
143 * DICOM C-Echo SCU
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
144 ***************************************************************************/
1049
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
145
4339
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
146 static void ExecuteEcho(RestApiOutput& output,
4340
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
147 const DicomAssociationParameters& parameters,
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
148 const Json::Value& body)
1049
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
149 {
4339
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
150 DicomControlUserConnection connection(parameters);
3875
ea1d32861cfc moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3874
diff changeset
151
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3876
diff changeset
152 if (connection.Echo())
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3876
diff changeset
153 {
4340
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
154 bool find = false;
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
155
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
156 if (body.type() == Json::objectValue &&
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
157 body.isMember(KEY_CHECK_FIND))
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
158 {
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
159 find = SerializationToolbox::ReadBoolean(body, KEY_CHECK_FIND);
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
160 }
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
161 else
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
162 {
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
163 OrthancConfiguration::ReaderLock lock;
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
164 find = lock.GetConfiguration().GetBooleanParameter("DicomEchoChecksFind", false);
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
165 }
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
166
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
167 if (find)
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
168 {
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
169 // Issue a C-FIND request at the study level about a random Study Instance UID
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
170 const std::string studyInstanceUid = FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Study);
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
171
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
172 DicomMap query;
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
173 query.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, studyInstanceUid, false);
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
174
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
175 DicomFindAnswers answers(false /* not a worklist */);
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
176
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
177 // The following line throws an exception if the remote modality doesn't support C-FIND
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
178 connection.Find(answers, ResourceType_Study, query, false /* normalize */);
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
179 }
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
180
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3876
diff changeset
181 // Echo has succeeded
4339
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
182 output.AnswerBuffer("{}", MimeType_Json);
1049
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
183 }
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3876
diff changeset
184 else
1049
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
185 {
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3876
diff changeset
186 // Echo has failed
4339
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
187 output.SignalError(HttpStatus_500_InternalServerError);
1049
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
188 }
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
189 }
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
190
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
191
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
192 static void DocumentEchoShared(RestApiPostCall& call)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
193 {
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
194 call.GetDocumentation()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
195 .SetRequestField(KEY_TIMEOUT, RestApiCallDocumentation::Type_Number,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
196 "Timeout for the C-ECHO command, in seconds", false)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
197 .SetRequestField(KEY_CHECK_FIND, RestApiCallDocumentation::Type_Boolean,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
198 "Issue a dummy C-FIND command after the C-GET SCU, in order to check whether the remote "
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
199 "modality knows about Orthanc. This field defaults to the value of the `DicomEchoChecksFind` "
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
200 "configuration option. New in Orthanc 1.8.1.", false);
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
201 }
4339
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
202
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
203
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
204 static void DicomEcho(RestApiPostCall& call)
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
205 {
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
206 if (call.IsDocumentation())
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
207 {
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
208 DocumentEchoShared(call);
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
209 call.GetDocumentation()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
210 .SetTag("Networking")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
211 .SetSummary("Trigger C-ECHO SCU")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
212 .SetDescription("Trigger C-ECHO SCU command against the DICOM modality whose identifier is provided in URL: "
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
213 "https://book.orthanc-server.com/users/rest.html#performing-c-echo")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
214 .SetUriArgument("id", "Identifier of the modality of interest");
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
215 return;
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
216 }
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
217
4367
189e48f4a92a Allow empty request body in "/modalities/{id}/echo"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4340
diff changeset
218 Json::Value body = Json::objectValue;
189e48f4a92a Allow empty request body in "/modalities/{id}/echo"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4340
diff changeset
219
189e48f4a92a Allow empty request body in "/modalities/{id}/echo"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4340
diff changeset
220 if (call.GetBodySize() == 0 /* allow empty body, was disallowed in Orthanc 1.7.0->1.8.1 */ ||
189e48f4a92a Allow empty request body in "/modalities/{id}/echo"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4340
diff changeset
221 call.ParseJsonRequest(body))
4340
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
222 {
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
223 const DicomAssociationParameters parameters = GetAssociationParameters(call, body);
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
224 ExecuteEcho(call.GetOutput(), parameters, body);
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
225 }
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
226 else
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
227 {
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
228 throw OrthancException(ErrorCode_BadFileFormat, "Cannot parse the JSON body");
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
229 }
4339
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
230 }
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
231
1049
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
232
4339
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
233 static void DicomEchoTool(RestApiPostCall& call)
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
234 {
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
235 if (call.IsDocumentation())
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
236 {
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
237 DocumentEchoShared(call);
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
238 DocumentModalityParametersShared(call, false);
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
239 call.GetDocumentation()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
240 .SetTag("System")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
241 .SetSummary("Trigger C-ECHO SCU")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
242 .SetDescription("Trigger C-ECHO SCU command against a DICOM modality described in the POST body, "
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
243 "without having to register the modality in some `/modalities/{id}` (new in Orthanc 1.8.1)");
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
244 return;
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
245 }
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
246
4339
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
247 Json::Value body;
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
248 if (call.ParseJsonRequest(body))
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
249 {
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
250 RemoteModalityParameters modality;
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
251 modality.Unserialize(body);
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
252
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
253 const std::string& localAet =
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
254 OrthancRestApi::GetContext(call).GetDefaultLocalApplicationEntityTitle();
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
255
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
256 DicomAssociationParameters params(localAet, modality);
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
257 InjectAssociationTimeout(params, body);
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
258
4340
6fa8bb987be2 "DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4339
diff changeset
259 ExecuteEcho(call.GetOutput(), params, body);
4339
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
260 }
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
261 else
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
262 {
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
263 throw OrthancException(ErrorCode_BadFileFormat, "Cannot parse the JSON body");
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
264 }
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
265 }
1049
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
266
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
267
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
268 /***************************************************************************
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
269 * DICOM C-Find SCU => DEPRECATED!
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
270 ***************************************************************************/
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
271
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
272 static bool MergeQueryAndTemplate(DicomMap& result,
3401
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3374
diff changeset
273 const RestApiCall& call)
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
274 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
275 Json::Value query;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
276
3401
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3374
diff changeset
277 if (!call.ParseJsonRequest(query) ||
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
278 query.type() != Json::objectValue)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
279 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
280 return false;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
281 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
282
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
283 Json::Value::Members members = query.getMemberNames();
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
284 for (size_t i = 0; i < members.size(); i++)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
285 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
286 DicomTag t = FromDcmtkBridge::ParseTag(members[i]);
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
287 result.SetValue(t, query[members[i]].asString(), false);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
288 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
289
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
290 return true;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
291 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
292
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
293
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
294 static void FindPatient(DicomFindAnswers& result,
3830
447880856ce8 removing deprecated DicomUserControl from OrthancRestModalities.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3808
diff changeset
295 DicomControlUserConnection& connection,
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
296 const DicomMap& fields)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
297 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
298 // Only keep the filters from "fields" that are related to the patient
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
299 DicomMap s;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
300 fields.ExtractPatientInformation(s);
3370
872bd3b6ec72 "/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3345
diff changeset
301 connection.Find(result, ResourceType_Patient, s, true /* normalize */);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
302 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
303
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
304
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
305 static void FindStudy(DicomFindAnswers& result,
3830
447880856ce8 removing deprecated DicomUserControl from OrthancRestModalities.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3808
diff changeset
306 DicomControlUserConnection& connection,
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
307 const DicomMap& fields)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
308 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
309 // Only keep the filters from "fields" that are related to the study
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
310 DicomMap s;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
311 fields.ExtractStudyInformation(s);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
312
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
313 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
314 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
315 s.CopyTagIfExists(fields, DICOM_TAG_MODALITIES_IN_STUDY);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
316
3370
872bd3b6ec72 "/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3345
diff changeset
317 connection.Find(result, ResourceType_Study, s, true /* normalize */);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
318 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
319
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
320 static void FindSeries(DicomFindAnswers& result,
3830
447880856ce8 removing deprecated DicomUserControl from OrthancRestModalities.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3808
diff changeset
321 DicomControlUserConnection& connection,
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
322 const DicomMap& fields)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
323 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
324 // Only keep the filters from "fields" that are related to the series
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
325 DicomMap s;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
326 fields.ExtractSeriesInformation(s);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
327
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
328 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
329 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
330 s.CopyTagIfExists(fields, DICOM_TAG_STUDY_INSTANCE_UID);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
331
3370
872bd3b6ec72 "/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3345
diff changeset
332 connection.Find(result, ResourceType_Series, s, true /* normalize */);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
333 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
334
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
335 static void FindInstance(DicomFindAnswers& result,
3830
447880856ce8 removing deprecated DicomUserControl from OrthancRestModalities.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3808
diff changeset
336 DicomControlUserConnection& connection,
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
337 const DicomMap& fields)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
338 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
339 // Only keep the filters from "fields" that are related to the instance
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
340 DicomMap s;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
341 fields.ExtractInstanceInformation(s);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
342
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
343 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
344 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
345 s.CopyTagIfExists(fields, DICOM_TAG_STUDY_INSTANCE_UID);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
346 s.CopyTagIfExists(fields, DICOM_TAG_SERIES_INSTANCE_UID);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
347
3370
872bd3b6ec72 "/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3345
diff changeset
348 connection.Find(result, ResourceType_Instance, s, true /* normalize */);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
349 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
350
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
351
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
352 static void DicomFindPatient(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 {
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
354 if (call.IsDocumentation())
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
355 {
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
356 call.GetDocumentation()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
357 .SetDeprecated()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
358 .SetTag("Networking")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
359 .SetSummary("C-FIND SCU for patients")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
360 .SetDescription("Trigger C-FIND SCU command against the DICOM modality whose identifier is provided in URL, "
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
361 "in order to find a patient. Deprecated in favor of `/modalities/{id}/query`.")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
362 .AddRequestType(MimeType_Json, "Associative array containing the query on the values of the DICOM tags")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
363 .AddAnswerType(MimeType_Json, "JSON array describing the DICOM tags of the matching patients")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
364 .SetUriArgument("id", "Identifier of the modality of interest");
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
365 return;
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
366 }
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
367
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
368 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri();
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
369
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
370 DicomMap fields;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
371 DicomMap::SetupFindPatientTemplate(fields);
3401
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3374
diff changeset
372 if (!MergeQueryAndTemplate(fields, call))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
377 DicomFindAnswers answers(false);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
379 {
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
380 DicomControlUserConnection connection(GetAssociationParameters(call));
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
381 FindPatient(answers, connection, fields);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
382 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384 Json::Value result;
4729
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
385 answers.ToJson(result, DicomToJsonFormat_Human);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
389 static void DicomFindStudy(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390 {
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
391 if (call.IsDocumentation())
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
392 {
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
393 call.GetDocumentation()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
394 .SetDeprecated()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
395 .SetTag("Networking")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
396 .SetSummary("C-FIND SCU for studies")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
397 .SetDescription("Trigger C-FIND SCU command against the DICOM modality whose identifier is provided in URL, "
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
398 "in order to find a study. Deprecated in favor of `/modalities/{id}/query`.")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
399 .AddRequestType(MimeType_Json, "Associative array containing the query on the values of the DICOM tags")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
400 .AddAnswerType(MimeType_Json, "JSON array describing the DICOM tags of the matching studies")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
401 .SetUriArgument("id", "Identifier of the modality of interest");
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
402 return;
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
403 }
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
404
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
405 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri();
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
406
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
407 DicomMap fields;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
408 DicomMap::SetupFindStudyTemplate(fields);
3401
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3374
diff changeset
409 if (!MergeQueryAndTemplate(fields, call))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
414 if (fields.GetValue(DICOM_TAG_ACCESSION_NUMBER).GetContent().size() <= 2 &&
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
415 fields.GetValue(DICOM_TAG_PATIENT_ID).GetContent().size() <= 2)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
420 DicomFindAnswers answers(false);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
421
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
422 {
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
423 DicomControlUserConnection connection(GetAssociationParameters(call));
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
424 FindStudy(answers, connection, fields);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
425 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427 Json::Value result;
4729
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
428 answers.ToJson(result, DicomToJsonFormat_Human);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
432 static void DicomFindSeries(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433 {
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
434 if (call.IsDocumentation())
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
435 {
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
436 call.GetDocumentation()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
437 .SetDeprecated()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
438 .SetTag("Networking")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
439 .SetSummary("C-FIND SCU for series")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
440 .SetDescription("Trigger C-FIND SCU command against the DICOM modality whose identifier is provided in URL, "
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
441 "in order to find a series. Deprecated in favor of `/modalities/{id}/query`.")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
442 .AddRequestType(MimeType_Json, "Associative array containing the query on the values of the DICOM tags")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
443 .AddAnswerType(MimeType_Json, "JSON array describing the DICOM tags of the matching series")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
444 .SetUriArgument("id", "Identifier of the modality of interest");
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
445 return;
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
446 }
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
447
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
448 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri();
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
449
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
450 DicomMap fields;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
451 DicomMap::SetupFindSeriesTemplate(fields);
3401
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3374
diff changeset
452 if (!MergeQueryAndTemplate(fields, call))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
457 if ((fields.GetValue(DICOM_TAG_ACCESSION_NUMBER).GetContent().size() <= 2 &&
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
458 fields.GetValue(DICOM_TAG_PATIENT_ID).GetContent().size() <= 2) ||
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
459 fields.GetValue(DICOM_TAG_STUDY_INSTANCE_UID).GetContent().size() <= 2)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
464 DicomFindAnswers answers(false);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
465
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
466 {
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
467 DicomControlUserConnection connection(GetAssociationParameters(call));
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
468 FindSeries(answers, connection, fields);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
469 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471 Json::Value result;
4729
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
472 answers.ToJson(result, DicomToJsonFormat_Human);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
476 static void DicomFindInstance(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 {
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
478 if (call.IsDocumentation())
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
479 {
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
480 call.GetDocumentation()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
481 .SetDeprecated()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
482 .SetTag("Networking")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
483 .SetSummary("C-FIND SCU for instances")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
484 .SetDescription("Trigger C-FIND SCU command against the DICOM modality whose identifier is provided in URL, "
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
485 "in order to find an instance. Deprecated in favor of `/modalities/{id}/query`.")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
486 .AddRequestType(MimeType_Json, "Associative array containing the query on the values of the DICOM tags")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
487 .AddAnswerType(MimeType_Json, "JSON array describing the DICOM tags of the matching instances")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
488 .SetUriArgument("id", "Identifier of the modality of interest");
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
489 return;
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
490 }
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
491
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
492 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri();
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
493
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
494 DicomMap fields;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
495 DicomMap::SetupFindInstanceTemplate(fields);
3401
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3374
diff changeset
496 if (!MergeQueryAndTemplate(fields, call))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
498 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
499 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
501 if ((fields.GetValue(DICOM_TAG_ACCESSION_NUMBER).GetContent().size() <= 2 &&
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
502 fields.GetValue(DICOM_TAG_PATIENT_ID).GetContent().size() <= 2) ||
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
503 fields.GetValue(DICOM_TAG_STUDY_INSTANCE_UID).GetContent().size() <= 2 ||
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
504 fields.GetValue(DICOM_TAG_SERIES_INSTANCE_UID).GetContent().size() <= 2)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
507 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
509 DicomFindAnswers answers(false);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
510
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
511 {
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
512 DicomControlUserConnection connection(GetAssociationParameters(call));
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
513 FindInstance(answers, connection, fields);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
514 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516 Json::Value result;
4729
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
517 answers.ToJson(result, DicomToJsonFormat_Human);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
519 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
520
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
521
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
522 static void CopyTagIfExists(DicomMap& target,
4205
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4153
diff changeset
523 const ParsedDicomFile& source,
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
524 const DicomTag& tag)
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
525 {
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
526 std::string tmp;
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
527 if (source.GetTagValue(tmp, tag))
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
528 {
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
529 target.SetValue(tag, tmp, false);
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
530 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
531 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
532
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
533
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
534 static void DicomFind(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535 {
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
536 if (call.IsDocumentation())
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
537 {
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
538 call.GetDocumentation()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
539 .SetDeprecated()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
540 .SetTag("Networking")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
541 .SetSummary("Hierarchical C-FIND SCU")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
542 .SetDescription("Trigger a sequence of C-FIND SCU commands against the DICOM modality whose identifier is provided in URL, "
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
543 "in order to discover a hierarchy of matching patients/studies/series. "
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
544 "Deprecated in favor of `/modalities/{id}/query`.")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
545 .AddRequestType(MimeType_Json, "Associative array containing the query on the values of the DICOM tags")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
546 .AddAnswerType(MimeType_Json, "JSON array describing the DICOM tags of the matching patients, embedding the "
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
547 "matching studies, then the matching series.")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
548 .SetUriArgument("id", "Identifier of the modality of interest");
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
549 return;
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
550 }
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
551
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
552 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri();
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
553
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
554 DicomMap m;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
555 DicomMap::SetupFindPatientTemplate(m);
3401
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3374
diff changeset
556 if (!MergeQueryAndTemplate(m, call))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
559 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
560
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
561 DicomControlUserConnection connection(GetAssociationParameters(call));
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
562
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
563 DicomFindAnswers patients(false);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
564 FindPatient(patients, connection, m);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
565
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
566 // Loop over the found patients
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
567 Json::Value result = Json::arrayValue;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
568 for (size_t i = 0; i < patients.GetSize(); i++)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
569 {
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
570 Json::Value patient;
4729
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
571 patients.ToJson(patient, i, DicomToJsonFormat_Human);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
572
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
573 DicomMap::SetupFindStudyTemplate(m);
3401
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3374
diff changeset
574 if (!MergeQueryAndTemplate(m, call))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
575 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
576 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
577 }
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
578
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
579 CopyTagIfExists(m, patients.GetAnswer(i), DICOM_TAG_PATIENT_ID);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
581 DicomFindAnswers studies(false);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
582 FindStudy(studies, connection, m);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
583
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584 patient["Studies"] = Json::arrayValue;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
585
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586 // Loop over the found studies
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
587 for (size_t j = 0; j < studies.GetSize(); j++)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
588 {
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
589 Json::Value study;
4729
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
590 studies.ToJson(study, j, DicomToJsonFormat_Human);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
591
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
592 DicomMap::SetupFindSeriesTemplate(m);
3401
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3374
diff changeset
593 if (!MergeQueryAndTemplate(m, call))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
594 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
595 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
596 }
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
597
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
598 CopyTagIfExists(m, studies.GetAnswer(j), DICOM_TAG_PATIENT_ID);
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
599 CopyTagIfExists(m, studies.GetAnswer(j), DICOM_TAG_STUDY_INSTANCE_UID);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
601 DicomFindAnswers series(false);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
602 FindSeries(series, connection, m);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
603
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
604 // Loop over the found series
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605 study["Series"] = Json::arrayValue;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
606 for (size_t k = 0; k < series.GetSize(); k++)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
607 {
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
608 Json::Value series2;
4729
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
609 series.ToJson(series2, k, DicomToJsonFormat_Human);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
610 study["Series"].append(series2);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
611 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
612
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
613 patient["Studies"].append(study);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
614 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
615
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616 result.append(patient);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
617 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
618
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
619 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
620 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
621
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
622
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
623
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
624 /***************************************************************************
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
625 * DICOM C-Find and C-Move SCU => Recommended since Orthanc 0.9.0
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
626 ***************************************************************************/
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
627
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
628 static void AnswerQueryHandler(RestApiPostCall& call,
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
629 std::unique_ptr<QueryRetrieveHandler>& handler)
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
630 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
631 ServerContext& context = OrthancRestApi::GetContext(call);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
632
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
633 if (handler.get() == NULL)
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
634 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
635 throw OrthancException(ErrorCode_NullPointer);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
636 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
637
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
638 handler->Run();
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
639
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
640 std::string s = context.GetQueryRetrieveArchive().Add(handler.release());
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
641 Json::Value result = Json::objectValue;
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
642 result["ID"] = s;
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
643 result["Path"] = "/queries/" + s;
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
644
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
645 call.GetOutput().AnswerJson(result);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
646 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
647
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
648
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
649 static void DicomQuery(RestApiPostCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
650 {
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
651 if (call.IsDocumentation())
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
652 {
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
653 call.GetDocumentation()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
654 .SetTag("Networking")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
655 .SetSummary("Trigger C-FIND SCU")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
656 .SetDescription("Trigger C-FIND SCU command against the DICOM modality whose identifier is provided in URL: "
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
657 "https://book.orthanc-server.com/users/rest.html#performing-query-retrieve-c-find-and-find-with-rest")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
658 .SetUriArgument("id", "Identifier of the modality of interest")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
659 .SetRequestField(KEY_QUERY, RestApiCallDocumentation::Type_JsonObject,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
660 "Associative array containing the filter on the values of the DICOM tags", true)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
661 .SetRequestField(KEY_LEVEL, RestApiCallDocumentation::Type_String,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
662 "Level of the query (`Patient`, `Study`, `Series` or `Instance`)", true)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
663 .SetRequestField(KEY_NORMALIZE, RestApiCallDocumentation::Type_Boolean,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
664 "Whether to normalize the query, i.e. whether to wipe out from the query, the DICOM tags "
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
665 "that are not applicable for the query-retrieve level of interest", false)
4462
da460bef88f8 "/modalities/{...}/query": New string argument "LocalAet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
666 .SetRequestField(KEY_LOCAL_AET, RestApiCallDocumentation::Type_String,
4463
522e13a60cfc "LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4462
diff changeset
667 "Local AET that is used for this commands, defaults to `DicomAet` configuration option. "
522e13a60cfc "LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4462
diff changeset
668 "Ignored if `DicomModalities` already sets `LocalAet` for this modality.", false)
4517
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
669 .SetRequestField(KEY_TIMEOUT, RestApiCallDocumentation::Type_Number,
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
670 "Timeout for the C-FIND command and subsequent C-MOVE retrievals, in seconds (new in Orthanc 1.9.1)", false)
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
671 .SetAnswerField("ID", RestApiCallDocumentation::Type_JsonObject,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
672 "Identifier of the query, to be used with `/queries/{id}`")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
673 .SetAnswerField("Path", RestApiCallDocumentation::Type_JsonObject,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
674 "Root path to the query in the REST API");
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
675 return;
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
676 }
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
677
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
678 ServerContext& context = OrthancRestApi::GetContext(call);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
679 Json::Value request;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
680
3345
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
681 if (!call.ParseJsonRequest(request) ||
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
682 request.type() != Json::objectValue)
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
683 {
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
684 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON object");
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
685 }
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
686 else if (!request.isMember(KEY_LEVEL) ||
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
687 request[KEY_LEVEL].type() != Json::stringValue)
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
688 {
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
689 throw OrthancException(ErrorCode_BadFileFormat,
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
690 "The JSON body must contain field " + std::string(KEY_LEVEL));
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
691 }
3370
872bd3b6ec72 "/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3345
diff changeset
692 else if (request.isMember(KEY_NORMALIZE) &&
872bd3b6ec72 "/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3345
diff changeset
693 request[KEY_NORMALIZE].type() != Json::booleanValue)
872bd3b6ec72 "/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3345
diff changeset
694 {
872bd3b6ec72 "/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3345
diff changeset
695 throw OrthancException(ErrorCode_BadFileFormat,
872bd3b6ec72 "/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3345
diff changeset
696 "The field " + std::string(KEY_NORMALIZE) + " must contain a Boolean");
872bd3b6ec72 "/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3345
diff changeset
697 }
3345
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
698 else if (request.isMember(KEY_QUERY) &&
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
699 request[KEY_QUERY].type() != Json::objectValue)
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
700 {
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
701 throw OrthancException(ErrorCode_BadFileFormat,
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
702 "The field " + std::string(KEY_QUERY) + " must contain a JSON object");
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
703 }
4462
da460bef88f8 "/modalities/{...}/query": New string argument "LocalAet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
704 else if (request.isMember(KEY_LOCAL_AET) &&
da460bef88f8 "/modalities/{...}/query": New string argument "LocalAet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
705 request[KEY_LOCAL_AET].type() != Json::stringValue)
da460bef88f8 "/modalities/{...}/query": New string argument "LocalAet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
706 {
da460bef88f8 "/modalities/{...}/query": New string argument "LocalAet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
707 throw OrthancException(ErrorCode_BadFileFormat,
da460bef88f8 "/modalities/{...}/query": New string argument "LocalAet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
708 "The field " + std::string(KEY_LOCAL_AET) + " must contain a string");
da460bef88f8 "/modalities/{...}/query": New string argument "LocalAet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
709 }
3345
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
710 else
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
711 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
712 std::unique_ptr<QueryRetrieveHandler> handler(new QueryRetrieveHandler(context));
3370
872bd3b6ec72 "/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3345
diff changeset
713
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
714 handler->SetModality(call.GetUriComponent("id", ""));
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
715 handler->SetLevel(StringToResourceType(request[KEY_LEVEL].asCString()));
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
716
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
717 if (request.isMember(KEY_QUERY))
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
718 {
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
719 std::map<DicomTag, std::string> query;
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
720 SerializationToolbox::ReadMapOfTags(query, request, KEY_QUERY);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
721
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
722 for (std::map<DicomTag, std::string>::const_iterator
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
723 it = query.begin(); it != query.end(); ++it)
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
724 {
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
725 handler->SetQuery(it->first, it->second);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
726 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
727 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
728
3370
872bd3b6ec72 "/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3345
diff changeset
729 if (request.isMember(KEY_NORMALIZE))
872bd3b6ec72 "/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3345
diff changeset
730 {
872bd3b6ec72 "/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3345
diff changeset
731 handler->SetFindNormalized(request[KEY_NORMALIZE].asBool());
872bd3b6ec72 "/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3345
diff changeset
732 }
872bd3b6ec72 "/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3345
diff changeset
733
4462
da460bef88f8 "/modalities/{...}/query": New string argument "LocalAet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
734 if (request.isMember(KEY_LOCAL_AET))
da460bef88f8 "/modalities/{...}/query": New string argument "LocalAet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
735 {
da460bef88f8 "/modalities/{...}/query": New string argument "LocalAet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
736 handler->SetLocalAet(request[KEY_LOCAL_AET].asString());
da460bef88f8 "/modalities/{...}/query": New string argument "LocalAet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
737 }
da460bef88f8 "/modalities/{...}/query": New string argument "LocalAet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4460
diff changeset
738
4517
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
739 if (request.isMember(KEY_TIMEOUT))
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
740 {
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
741 // New in Orthanc 1.9.1
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
742 handler->SetTimeout(SerializationToolbox::ReadUnsignedInteger(request, KEY_TIMEOUT));
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
743 }
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
744
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
745 AnswerQueryHandler(call, handler);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
746 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
747 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
748
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
749
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
750 static void ListQueries(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
751 {
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
752 if (call.IsDocumentation())
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
753 {
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
754 call.GetDocumentation()
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
755 .SetTag("Networking")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
756 .SetSummary("List query/retrieve operations")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
757 .SetDescription("List the identifiers of all the query/retrieve operations on DICOM modalities, "
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
758 "as initiated by calls to `/modalities/{id}/query`. The length of this list is bounded "
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
759 "by the `QueryRetrieveSize` configuration option of Orthanc. "
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
760 "https://book.orthanc-server.com/users/rest.html#performing-query-retrieve-c-find-and-find-with-rest")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
761 .AddAnswerType(MimeType_Json, "JSON array containing the identifiers");
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
762 return;
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
763 }
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
764
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
765 ServerContext& context = OrthancRestApi::GetContext(call);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
766
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
767 std::list<std::string> queries;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
768 context.GetQueryRetrieveArchive().List(queries);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
769
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
770 Json::Value result = Json::arrayValue;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
771 for (std::list<std::string>::const_iterator
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
772 it = queries.begin(); it != queries.end(); ++it)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
773 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
774 result.append(*it);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
775 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
776
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
777 call.GetOutput().AnswerJson(result);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
778 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
779
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
780
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
781 namespace
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
782 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
783 class QueryAccessor
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
784 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
785 private:
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
786 ServerContext& context_;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
787 SharedArchive::Accessor accessor_;
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
788 QueryRetrieveHandler* handler_;
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
789
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
790 public:
4205
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4153
diff changeset
791 explicit QueryAccessor(RestApiCall& call) :
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
792 context_(OrthancRestApi::GetContext(call)),
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
793 accessor_(context_.GetQueryRetrieveArchive(), call.GetUriComponent("id", "")),
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
794 handler_(NULL)
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
795 {
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
796 if (accessor_.IsValid())
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
797 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
798 handler_ = &dynamic_cast<QueryRetrieveHandler&>(accessor_.GetItem());
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
799 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
800 else
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
801 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
802 throw OrthancException(ErrorCode_UnknownResource);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
803 }
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
804 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
805
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
806 QueryRetrieveHandler& GetHandler() const
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
807 {
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
808 assert(handler_ != NULL);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
809 return *handler_;
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
810 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
811 };
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
812
4697
569d9ef165b1 Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4650
diff changeset
813 static void AnswerDicomMap(RestApiGetCall& call,
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
814 const DicomMap& value,
4697
569d9ef165b1 Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4650
diff changeset
815 DicomToJsonFormat format)
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
816 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
817 Json::Value full = Json::objectValue;
4697
569d9ef165b1 Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4650
diff changeset
818 FromDcmtkBridge::ToJson(full, value, format);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
819 call.GetOutput().AnswerJson(full);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
820 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
821 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
822
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
823
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
824 static void ListQueryAnswers(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
825 {
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
826 if (call.IsDocumentation())
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
827 {
4697
569d9ef165b1 Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4650
diff changeset
828 OrthancRestApi::DocumentDicomFormat(call, DicomToJsonFormat_Full);
569d9ef165b1 Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4650
diff changeset
829
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
830 call.GetDocumentation()
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
831 .SetTag("Networking")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
832 .SetSummary("List answers to a query")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
833 .SetDescription("List the indices of all the available answers resulting from a query/retrieve operation "
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
834 "on some DICOM modality, whose identifier is provided in the URL")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
835 .SetUriArgument("id", "Identifier of the query of interest")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
836 .SetHttpGetArgument("expand", RestApiCallDocumentation::Type_String,
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
837 "If present, retrieve detailed information about the individual answers", false)
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
838 .AddAnswerType(MimeType_Json, "JSON array containing the indices of the answers, or detailed information "
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
839 "about the reported answers (if `expand` argument is provided)");
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
840 return;
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
841 }
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
842
2948
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
843 const bool expand = call.HasArgument("expand");
4697
569d9ef165b1 Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4650
diff changeset
844 const DicomToJsonFormat format = OrthancRestApi::GetDicomFormat(call, DicomToJsonFormat_Full);
2948
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
845
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
846 QueryAccessor query(call);
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
847 size_t count = query.GetHandler().GetAnswersCount();
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
848
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
849 Json::Value result = Json::arrayValue;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
850 for (size_t i = 0; i < count; i++)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
851 {
2948
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
852 if (expand)
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
853 {
2988
9cc3d40e389b Orthanc 1.4.3 is now known as 1.5.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2986
diff changeset
854 // New in Orthanc 1.5.0
2948
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
855 DicomMap value;
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
856 query.GetHandler().GetAnswer(value, i);
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
857
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
858 Json::Value json = Json::objectValue;
4697
569d9ef165b1 Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4650
diff changeset
859 FromDcmtkBridge::ToJson(json, value, format);
2948
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
860
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
861 result.append(json);
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
862 }
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
863 else
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
864 {
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
865 result.append(boost::lexical_cast<std::string>(i));
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
866 }
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
867 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
868
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
869 call.GetOutput().AnswerJson(result);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
870 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
871
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
872
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
873 static void GetQueryOneAnswer(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
874 {
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
875 if (call.IsDocumentation())
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
876 {
4697
569d9ef165b1 Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4650
diff changeset
877 OrthancRestApi::DocumentDicomFormat(call, DicomToJsonFormat_Full);
569d9ef165b1 Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4650
diff changeset
878
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
879 call.GetDocumentation()
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
880 .SetTag("Networking")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
881 .SetSummary("Get one answer")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
882 .SetDescription("Get the content (DICOM tags) of one answer associated with the "
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
883 "query/retrieve operation whose identifier is provided in the URL")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
884 .SetUriArgument("id", "Identifier of the query of interest")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
885 .SetUriArgument("index", "Index of the answer")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
886 .AddAnswerType(MimeType_Json, "JSON object containing the DICOM tags of the answer");
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
887 return;
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
888 }
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
889
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
890 size_t index = boost::lexical_cast<size_t>(call.GetUriComponent("index", ""));
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
891
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
892 QueryAccessor query(call);
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
893
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
894 DicomMap map;
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
895 query.GetHandler().GetAnswer(map, index);
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
896
4697
569d9ef165b1 Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4650
diff changeset
897 AnswerDicomMap(call, map, OrthancRestApi::GetDicomFormat(call, DicomToJsonFormat_Full));
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
898 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
899
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
900
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
901 static void SubmitRetrieveJob(RestApiPostCall& call,
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
902 bool allAnswers,
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
903 size_t index)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
904 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
905 ServerContext& context = OrthancRestApi::GetContext(call);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
906
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
907 std::string targetAet;
3870
09798f2b985f added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents: 3863
diff changeset
908 int timeout = -1;
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
909
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
910 Json::Value body;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
911 if (call.ParseJsonRequest(body))
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
912 {
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
913 targetAet = Toolbox::GetJsonStringField(body, KEY_TARGET_AET, context.GetDefaultLocalApplicationEntityTitle());
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
914 timeout = Toolbox::GetJsonIntegerField(body, KEY_TIMEOUT, -1);
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
915 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
916 else
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
917 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
918 body = Json::objectValue;
3870
09798f2b985f added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents: 3863
diff changeset
919 if (call.GetBodySize() > 0)
09798f2b985f added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents: 3863
diff changeset
920 {
09798f2b985f added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents: 3863
diff changeset
921 call.BodyToString(targetAet);
09798f2b985f added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents: 3863
diff changeset
922 }
09798f2b985f added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents: 3863
diff changeset
923 else
09798f2b985f added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents: 3863
diff changeset
924 {
09798f2b985f added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents: 3863
diff changeset
925 targetAet = context.GetDefaultLocalApplicationEntityTitle();
09798f2b985f added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents: 3863
diff changeset
926 }
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
927 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
928
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
929 std::unique_ptr<DicomMoveScuJob> job(new DicomMoveScuJob(context));
4730
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4729
diff changeset
930 job->SetQueryFormat(OrthancRestApi::GetDicomFormat(body, DicomToJsonFormat_Short));
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
931
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
932 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
933 QueryAccessor query(call);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
934 job->SetTargetAet(targetAet);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
935 job->SetLocalAet(query.GetHandler().GetLocalAet());
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
936 job->SetRemoteModality(query.GetHandler().GetRemoteModality());
3875
ea1d32861cfc moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3874
diff changeset
937
ea1d32861cfc moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3874
diff changeset
938 if (timeout >= 0)
ea1d32861cfc moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3874
diff changeset
939 {
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
940 // New in Orthanc 1.7.0
3875
ea1d32861cfc moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3874
diff changeset
941 job->SetTimeout(static_cast<uint32_t>(timeout));
ea1d32861cfc moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3874
diff changeset
942 }
4517
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
943 else if (query.GetHandler().HasTimeout())
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
944 {
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
945 // New in Orthanc 1.9.1
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
946 job->SetTimeout(query.GetHandler().GetTimeout());
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
947 }
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
948
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
949 LOG(WARNING) << "Driving C-Move SCU on remote modality "
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
950 << query.GetHandler().GetRemoteModality().GetApplicationEntityTitle()
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
951 << " to target modality " << targetAet;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
952
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
953 if (allAnswers)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
954 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
955 for (size_t i = 0; i < query.GetHandler().GetAnswersCount(); i++)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
956 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
957 job->AddFindAnswer(query.GetHandler(), i);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
958 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
959 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
960 else
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
961 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
962 job->AddFindAnswer(query.GetHandler(), index);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
963 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
964 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
965
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
966 OrthancRestApi::GetApi(call).SubmitCommandsJob
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
967 (call, job.release(), true /* synchronous by default */, body);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
968 }
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
969
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
970
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
971 static void DocumentRetrieveShared(RestApiPostCall& call)
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
972 {
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
973 OrthancRestApi::DocumentSubmitCommandsJob(call);
4730
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4729
diff changeset
974 OrthancRestApi::DocumentDicomFormat(call, DicomToJsonFormat_Short);
7826ac059c31 Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4729
diff changeset
975
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
976 call.GetDocumentation()
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
977 .SetTag("Networking")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
978 .SetUriArgument("id", "Identifier of the query of interest")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
979 .SetRequestField(KEY_TARGET_AET, RestApiCallDocumentation::Type_String,
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
980 "AET of the target modality. By default, the AET of Orthanc is used, as defined in the "
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
981 "`DicomAet` configuration option.", false)
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
982 .SetRequestField(KEY_TIMEOUT, RestApiCallDocumentation::Type_Number,
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
983 "Timeout for the C-MOVE command, in seconds", false)
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
984 .AddRequestType(MimeType_PlainText, "AET of the target modality");
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
985 }
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
986
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
987
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
988 static void RetrieveOneAnswer(RestApiPostCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
989 {
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
990 if (call.IsDocumentation())
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
991 {
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
992 DocumentRetrieveShared(call);
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
993 call.GetDocumentation()
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
994 .SetSummary("Retrieve one answer")
4422
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
995 .SetDescription("Start a C-MOVE SCU command as a job, in order to retrieve one answer associated with the "
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
996 "query/retrieve operation whose identifiers are provided in the URL: "
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
997 "https://book.orthanc-server.com/users/rest.html#performing-retrieve-c-move")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
998 .SetUriArgument("index", "Index of the answer");
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
999 return;
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1000 }
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1001
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1002 size_t index = boost::lexical_cast<size_t>(call.GetUriComponent("index", ""));
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
1003 SubmitRetrieveJob(call, false, index);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1004 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1005
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1006
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1007 static void RetrieveAllAnswers(RestApiPostCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1008 {
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1009 if (call.IsDocumentation())
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1010 {
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1011 DocumentRetrieveShared(call);
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1012 call.GetDocumentation()
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1013 .SetSummary("Retrieve all answers")
4422
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1014 .SetDescription("Start a C-MOVE SCU command as a job, in order to retrieve all the answers associated with the "
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1015 "query/retrieve operation whose identifier is provided in the URL: "
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1016 "https://book.orthanc-server.com/users/rest.html#performing-retrieve-c-move");
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1017 return;
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1018 }
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1019
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
1020 SubmitRetrieveJob(call, true, 0);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1021 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1022
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1023
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1024 static void GetQueryArguments(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1025 {
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1026 if (call.IsDocumentation())
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1027 {
4697
569d9ef165b1 Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4650
diff changeset
1028 OrthancRestApi::DocumentDicomFormat(call, DicomToJsonFormat_Full);
569d9ef165b1 Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4650
diff changeset
1029
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1030 call.GetDocumentation()
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1031 .SetTag("Networking")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1032 .SetSummary("Get original query arguments")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1033 .SetDescription("Get the original DICOM filter associated with the query/retrieve operation "
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1034 "whose identifier is provided in the URL")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1035 .SetUriArgument("id", "Identifier of the query of interest")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1036 .AddAnswerType(MimeType_Json, "Content of the original query");
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1037 return;
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1038 }
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1039
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1040 QueryAccessor query(call);
4697
569d9ef165b1 Added "short", "simplify" and/or "full" options to control the format of DICOM tags wherever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4650
diff changeset
1041 AnswerDicomMap(call, query.GetHandler().GetQuery(), OrthancRestApi::GetDicomFormat(call, DicomToJsonFormat_Full));
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1042 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1043
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1044
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1045 static void GetQueryLevel(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1046 {
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1047 if (call.IsDocumentation())
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1048 {
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1049 call.GetDocumentation()
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1050 .SetTag("Networking")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1051 .SetSummary("Get level of original query")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1052 .SetDescription("Get the query level (value of the `QueryRetrieveLevel` tag) of the query/retrieve operation "
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1053 "whose identifier is provided in the URL")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1054 .SetUriArgument("id", "Identifier of the query of interest")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1055 .AddAnswerType(MimeType_PlainText, "The level");
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1056 return;
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1057 }
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1058
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1059 QueryAccessor query(call);
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1060 call.GetOutput().AnswerBuffer(EnumerationToString(query.GetHandler().GetLevel()), MimeType_PlainText);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1061 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1062
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1063
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1064 static void GetQueryModality(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1065 {
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1066 if (call.IsDocumentation())
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1067 {
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1068 call.GetDocumentation()
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1069 .SetTag("Networking")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1070 .SetSummary("Get modality of original query")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1071 .SetDescription("Get the identifier of the DICOM modality that was targeted by the query/retrieve operation "
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1072 "whose identifier is provided in the URL")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1073 .SetUriArgument("id", "Identifier of the query of interest")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1074 .AddAnswerType(MimeType_PlainText, "The identifier of the DICOM modality");
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1075 return;
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1076 }
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1077
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1078 QueryAccessor query(call);
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1079 call.GetOutput().AnswerBuffer(query.GetHandler().GetModalitySymbolicName(), MimeType_PlainText);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1080 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1081
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1082
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1083 static void DeleteQuery(RestApiDeleteCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1084 {
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1085 if (call.IsDocumentation())
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1086 {
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1087 call.GetDocumentation()
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1088 .SetTag("Networking")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1089 .SetSummary("Delete a query")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1090 .SetDescription("Delete the query/retrieve operation whose identifier is provided in the URL")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1091 .SetUriArgument("id", "Identifier of the query of interest");
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1092 return;
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1093 }
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1094
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1095 ServerContext& context = OrthancRestApi::GetContext(call);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1096 context.GetQueryRetrieveArchive().Remove(call.GetUriComponent("id", ""));
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1097 call.GetOutput().AnswerBuffer("", MimeType_PlainText);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1098 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1099
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1100
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1101 static void ListQueryOperations(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1102 {
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1103 if (call.IsDocumentation())
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1104 {
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1105 call.GetDocumentation()
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1106 .SetTag("Networking")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1107 .SetSummary("List operations on a query")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1108 .SetDescription("List the available operations for the query/retrieve operation whose identifier is provided in the URL")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1109 .SetUriArgument("id", "Identifier of the query of interest")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1110 .AddAnswerType(MimeType_Json, "JSON array containing the list of operations");
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1111 return;
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1112 }
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1113
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1114 // Ensure that the query of interest does exist
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1115 QueryAccessor query(call);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1116
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1117 RestApi::AutoListChildren(call);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1118 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1119
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1120
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1121 static void ListQueryAnswerOperations(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1122 {
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1123 if (call.IsDocumentation())
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1124 {
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1125 call.GetDocumentation()
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1126 .SetTag("Networking")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1127 .SetSummary("List operations on an answer")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1128 .SetDescription("List the available operations on an answer associated with the "
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1129 "query/retrieve operation whose identifier is provided in the URL")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1130 .SetUriArgument("id", "Identifier of the query of interest")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1131 .SetUriArgument("index", "Index of the answer")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1132 .AddAnswerType(MimeType_Json, "JSON array containing the list of operations");
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1133 return;
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1134 }
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1135
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1136 // Ensure that the query of interest does exist
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1137 QueryAccessor query(call);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1138
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1139 // Ensure that the answer of interest does exist
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1140 size_t index = boost::lexical_cast<size_t>(call.GetUriComponent("index", ""));
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
1141
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
1142 DicomMap map;
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
1143 query.GetHandler().GetAnswer(map, index);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1144
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1145 Json::Value answer = Json::arrayValue;
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1146 answer.append("content");
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1147 answer.append("retrieve");
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1148
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1149 switch (query.GetHandler().GetLevel())
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1150 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1151 case ResourceType_Patient:
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1152 answer.append("query-study");
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1153
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1154 case ResourceType_Study:
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1155 answer.append("query-series");
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1156
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1157 case ResourceType_Series:
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1158 answer.append("query-instances");
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1159 break;
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1160
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1161 default:
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1162 break;
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1163 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1164
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1165 call.GetOutput().AnswerJson(answer);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1166 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1167
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1168
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1169 template <ResourceType CHILDREN_LEVEL>
2986
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1170 static void QueryAnswerChildren(RestApiPostCall& call)
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1171 {
2988
9cc3d40e389b Orthanc 1.4.3 is now known as 1.5.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2986
diff changeset
1172 // New in Orthanc 1.5.0
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1173 assert(CHILDREN_LEVEL == ResourceType_Study ||
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1174 CHILDREN_LEVEL == ResourceType_Series ||
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1175 CHILDREN_LEVEL == ResourceType_Instance);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1176
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1177 if (call.IsDocumentation())
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1178 {
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1179 const std::string resources = GetResourceTypeText(CHILDREN_LEVEL, true /* plural */, false /* lower case */);
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1180 call.GetDocumentation()
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1181 .SetTag("Networking")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1182 .SetSummary("Query the child " + resources + " of an answer")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1183 .SetDescription("Issue a second DICOM C-FIND operation, in order to query the child " + resources +
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1184 " associated with one answer to some query/retrieve operation whose identifiers are provided in the URL")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1185 .SetUriArgument("id", "Identifier of the query of interest")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1186 .SetUriArgument("index", "Index of the answer")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1187 .SetRequestField(KEY_QUERY, RestApiCallDocumentation::Type_JsonObject,
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1188 "Associative array containing the filter on the values of the DICOM tags", true)
4517
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
1189 .SetRequestField(KEY_TIMEOUT, RestApiCallDocumentation::Type_Number,
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
1190 "Timeout for the C-FIND command, in seconds (new in Orthanc 1.9.1)", false)
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1191 .SetAnswerField("ID", RestApiCallDocumentation::Type_JsonObject,
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1192 "Identifier of the query, to be used with `/queries/{id}`")
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1193 .SetAnswerField("Path", RestApiCallDocumentation::Type_JsonObject,
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1194 "Root path to the query in the REST API");
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1195 return;
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1196 }
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1197
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1198 ServerContext& context = OrthancRestApi::GetContext(call);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1199
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
1200 std::unique_ptr<QueryRetrieveHandler> handler(new QueryRetrieveHandler(context));
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1201
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1202 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1203 const QueryAccessor parent(call);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1204 const ResourceType level = parent.GetHandler().GetLevel();
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1205
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1206 const size_t index = boost::lexical_cast<size_t>(call.GetUriComponent("index", ""));
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1207
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1208 Json::Value request;
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1209
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1210 if (index >= parent.GetHandler().GetAnswersCount())
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1211 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1212 throw OrthancException(ErrorCode_ParameterOutOfRange);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1213 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1214 else if (CHILDREN_LEVEL == ResourceType_Study &&
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1215 level != ResourceType_Patient)
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1216 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1217 throw OrthancException(ErrorCode_UnknownResource);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1218 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1219 else if (CHILDREN_LEVEL == ResourceType_Series &&
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1220 level != ResourceType_Patient &&
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1221 level != ResourceType_Study)
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1222 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1223 throw OrthancException(ErrorCode_UnknownResource);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1224 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1225 else if (CHILDREN_LEVEL == ResourceType_Instance &&
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1226 level != ResourceType_Patient &&
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1227 level != ResourceType_Study &&
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1228 level != ResourceType_Series)
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1229 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1230 throw OrthancException(ErrorCode_UnknownResource);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1231 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1232 else if (!call.ParseJsonRequest(request))
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1233 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1234 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON object");
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1235 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1236 else
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1237 {
3370
872bd3b6ec72 "/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3345
diff changeset
1238 handler->SetFindNormalized(parent.GetHandler().IsFindNormalized());
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1239 handler->SetModality(parent.GetHandler().GetModalitySymbolicName());
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1240 handler->SetLevel(CHILDREN_LEVEL);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1241
4517
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
1242 // New in Orthanc 1.9.1
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
1243 if (request.isMember(KEY_TIMEOUT))
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
1244 {
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
1245 handler->SetTimeout(SerializationToolbox::ReadUnsignedInteger(request, KEY_TIMEOUT));
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
1246 }
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
1247 else if (parent.GetHandler().HasTimeout())
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
1248 {
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
1249 handler->SetTimeout(parent.GetHandler().GetTimeout());
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
1250 }
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
1251
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1252 if (request.isMember(KEY_QUERY))
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1253 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1254 std::map<DicomTag, std::string> query;
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1255 SerializationToolbox::ReadMapOfTags(query, request, KEY_QUERY);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1256
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1257 for (std::map<DicomTag, std::string>::const_iterator
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1258 it = query.begin(); it != query.end(); ++it)
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1259 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1260 handler->SetQuery(it->first, it->second);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1261 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1262 }
2986
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1263
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1264 DicomMap answer;
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1265 parent.GetHandler().GetAnswer(answer, index);
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1266
3830
447880856ce8 removing deprecated DicomUserControl from OrthancRestModalities.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3808
diff changeset
1267 // This switch-case mimics "DicomControlUserConnection::Move()"
2986
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1268 switch (parent.GetHandler().GetLevel())
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1269 {
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1270 case ResourceType_Patient:
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1271 handler->CopyStringTag(answer, DICOM_TAG_PATIENT_ID);
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1272 break;
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1273
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1274 case ResourceType_Study:
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1275 handler->CopyStringTag(answer, DICOM_TAG_STUDY_INSTANCE_UID);
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1276 break;
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1277
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1278 case ResourceType_Series:
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1279 handler->CopyStringTag(answer, DICOM_TAG_STUDY_INSTANCE_UID);
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1280 handler->CopyStringTag(answer, DICOM_TAG_SERIES_INSTANCE_UID);
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1281 break;
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1282
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1283 case ResourceType_Instance:
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1284 handler->CopyStringTag(answer, DICOM_TAG_STUDY_INSTANCE_UID);
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1285 handler->CopyStringTag(answer, DICOM_TAG_SERIES_INSTANCE_UID);
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1286 handler->CopyStringTag(answer, DICOM_TAG_SOP_INSTANCE_UID);
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1287 break;
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1288
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1289 default:
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1290 throw OrthancException(ErrorCode_InternalError);
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1291 }
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1292 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1293 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1294
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1295 AnswerQueryHandler(call, handler);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1296 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1297
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1298
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1299
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1300 /***************************************************************************
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1301 * DICOM C-Store SCU
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1302 ***************************************************************************/
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1303
3167
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1304 static void GetInstancesToExport(Json::Value& otherArguments,
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
1305 SetOfInstancesJob& job,
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1306 const std::string& remote,
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
1307 RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1308 {
1428
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
1309 otherArguments = Json::objectValue;
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1310 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1311
1428
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
1312 Json::Value request;
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
1313 if (Toolbox::IsSHA1(call.GetBodyData(), call.GetBodySize()))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1314 {
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
1315 std::string s;
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
1316 call.BodyToString(s);
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
1317
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1318 // This is for compatibility with Orthanc <= 0.5.1.
1428
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
1319 request = Json::arrayValue;
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
1320 request.append(Toolbox::StripSpaces(s));
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1321 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1322 else if (!call.ParseJsonRequest(request))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1323 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1324 // Bad JSON request
3167
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1325 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON value");
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1326 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1327
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1328 if (request.isString())
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1329 {
1428
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
1330 std::string item = request.asString();
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
1331 request = Json::arrayValue;
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
1332 request.append(item);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1333 }
3167
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1334 else if (!request.isArray() &&
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1335 !request.isObject())
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1336 {
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1337 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON object, or a JSON array of strings");
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1338 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1339
1427
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1340 const Json::Value* resources;
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1341 if (request.isArray())
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1342 {
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1343 resources = &request;
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1344 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1345 else
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1346 {
1427
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1347 if (request.type() != Json::objectValue ||
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1348 !request.isMember(KEY_RESOURCES))
1427
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1349 {
3167
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1350 throw OrthancException(ErrorCode_BadFileFormat,
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1351 "Missing field in JSON: \"" + std::string(KEY_RESOURCES) + "\"");
1427
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1352 }
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1353
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1354 resources = &request[KEY_RESOURCES];
1427
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1355 if (!resources->isArray())
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1356 {
3167
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1357 throw OrthancException(ErrorCode_BadFileFormat,
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1358 "JSON field \"" + std::string(KEY_RESOURCES) + "\" must contain an array");
1427
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1359 }
1428
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
1360
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
1361 // Copy the remaining arguments
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
1362 Json::Value::Members members = request.getMemberNames();
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
1363 for (Json::Value::ArrayIndex i = 0; i < members.size(); i++)
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
1364 {
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
1365 otherArguments[members[i]] = request[members[i]];
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
1366 }
1427
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1367 }
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1368
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1369 bool logExportedResources;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1370
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1371 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1372 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1373 logExportedResources = lock.GetConfiguration().GetBooleanParameter("LogExportedResources", false);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1374 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1375
1427
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1376 for (Json::Value::ArrayIndex i = 0; i < resources->size(); i++)
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1377 {
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1378 if (!(*resources) [i].isString())
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1379 {
3167
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1380 throw OrthancException(ErrorCode_BadFileFormat,
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1381 "Resources to be exported must be specified as a JSON array of strings");
1427
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1382 }
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1383
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1384 std::string stripped = Toolbox::StripSpaces((*resources) [i].asString());
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1385 if (!Toolbox::IsSHA1(stripped))
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1386 {
3167
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1387 throw OrthancException(ErrorCode_BadFileFormat,
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1388 "This string is not a valid Orthanc identifier: " + stripped);
1427
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1389 }
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1390
3374
d0d6bd633e4c Reporting of "ParentResources" in "DicomModalityStore" and "DicomModalityStore" jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3370
diff changeset
1391 job.AddParentResource(stripped); // New in Orthanc 1.5.7
d0d6bd633e4c Reporting of "ParentResources" in "DicomModalityStore" and "DicomModalityStore" jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3370
diff changeset
1392
3167
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1393 context.AddChildInstances(job, stripped);
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1394
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1395 if (logExportedResources)
1427
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1396 {
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1397 context.GetIndex().LogExportedResource(stripped, remote);
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1398 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1399 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1400 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1401
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1402
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
1403 static void DicomStore(RestApiPostCall& call)
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
1404 {
4422
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1405 static const char* KEY_MOVE_ORIGINATOR_AET = "MoveOriginatorAet";
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1406 static const char* KEY_MOVE_ORIGINATOR_ID = "MoveOriginatorID";
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1407 static const char* KEY_STORAGE_COMMITMENT = "StorageCommitment";
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1408
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1409 if (call.IsDocumentation())
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1410 {
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1411 OrthancRestApi::DocumentSubmitCommandsJob(call);
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1412 call.GetDocumentation()
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1413 .SetTag("Networking")
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1414 .SetSummary("Trigger C-STORE SCU")
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1415 .SetDescription("Start a C-STORE SCU command as a job, in order to send DICOM resources stored locally "
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1416 "to some remote DICOM modality whose identifier is provided in the URL: "
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1417 "https://book.orthanc-server.com/users/rest.html#rest-store-scu")
4423
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1418 .AddRequestType(MimeType_PlainText, "The Orthanc identifier of one resource to be sent")
4422
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1419 .SetRequestField(KEY_RESOURCES, RestApiCallDocumentation::Type_JsonListOfStrings,
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1420 "List of the Orthanc identifiers of all the DICOM resources to be sent", true)
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1421 .SetRequestField(KEY_LOCAL_AET, RestApiCallDocumentation::Type_String,
4463
522e13a60cfc "LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4462
diff changeset
1422 "Local AET that is used for this commands, defaults to `DicomAet` configuration option. "
522e13a60cfc "LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4462
diff changeset
1423 "Ignored if `DicomModalities` already sets `LocalAet` for this modality.", false)
4422
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1424 .SetRequestField(KEY_MOVE_ORIGINATOR_AET, RestApiCallDocumentation::Type_String,
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1425 "Move originator AET that is used for this commands, in order to fake a C-MOVE SCU", false)
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1426 .SetRequestField(KEY_MOVE_ORIGINATOR_ID, RestApiCallDocumentation::Type_Number,
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1427 "Move originator ID that is used for this commands, in order to fake a C-MOVE SCU", false)
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1428 .SetRequestField(KEY_STORAGE_COMMITMENT, RestApiCallDocumentation::Type_Boolean,
4423
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1429 "Whether to chain C-STORE with DICOM storage commitment to validate the success of the transmission: "
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1430 "https://book.orthanc-server.com/users/storage-commitment.html#chaining-c-store-with-storage-commitment", false)
4422
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1431 .SetRequestField(KEY_TIMEOUT, RestApiCallDocumentation::Type_Number,
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1432 "Timeout for the C-STORE command, in seconds", false)
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1433 .SetUriArgument("id", "Identifier of the modality of interest");
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1434 return;
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1435 }
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1436
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
1437 ServerContext& context = OrthancRestApi::GetContext(call);
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
1438
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
1439 std::string remote = call.GetUriComponent("id", "");
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
1440
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
1441 Json::Value request;
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
1442 std::unique_ptr<DicomModalityStoreJob> job(new DicomModalityStoreJob(context));
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
1443
3167
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1444 GetInstancesToExport(request, *job, remote, call);
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1445
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1446 std::string localAet = Toolbox::GetJsonStringField
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1447 (request, KEY_LOCAL_AET, context.GetDefaultLocalApplicationEntityTitle());
3167
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1448 std::string moveOriginatorAET = Toolbox::GetJsonStringField
4422
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1449 (request, KEY_MOVE_ORIGINATOR_AET, context.GetDefaultLocalApplicationEntityTitle());
3167
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1450 int moveOriginatorID = Toolbox::GetJsonIntegerField
4422
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1451 (request, KEY_MOVE_ORIGINATOR_ID, 0 /* By default, not a C-MOVE */);
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
1452
3167
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1453 job->SetLocalAet(localAet);
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1454 job->SetRemoteModality(MyGetModalityUsingSymbolicName(remote));
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
1455
3167
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1456 if (moveOriginatorID != 0)
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1457 {
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1458 job->SetMoveOriginator(moveOriginatorAET, moveOriginatorID);
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1459 }
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
1460
3734
4fc24b69446a triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1461 // New in Orthanc 1.6.0
4422
48303e493135 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4421
diff changeset
1462 if (Toolbox::GetJsonBooleanField(request, KEY_STORAGE_COMMITMENT, false))
3734
4fc24b69446a triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1463 {
4fc24b69446a triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1464 job->EnableStorageCommitment(true);
4fc24b69446a triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1465 }
4fc24b69446a triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1466
3870
09798f2b985f added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents: 3863
diff changeset
1467 // New in Orthanc 1.7.0
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1468 if (request.isMember(KEY_TIMEOUT))
3875
ea1d32861cfc moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3874
diff changeset
1469 {
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1470 job->SetTimeout(SerializationToolbox::ReadUnsignedInteger(request, KEY_TIMEOUT));
3875
ea1d32861cfc moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3874
diff changeset
1471 }
3870
09798f2b985f added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents: 3863
diff changeset
1472
3167
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1473 OrthancRestApi::GetApi(call).SubmitCommandsJob
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1474 (call, job.release(), true /* synchronous by default */, request);
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
1475 }
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
1476
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
1477
3808
7f083dfae62b new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3740
diff changeset
1478 static void DicomStoreStraight(RestApiPostCall& call)
7f083dfae62b new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3740
diff changeset
1479 {
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1480 if (call.IsDocumentation())
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1481 {
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1482 call.GetDocumentation()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1483 .SetTag("Networking")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1484 .SetSummary("Straight C-STORE SCU")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1485 .SetDescription("Synchronously send the DICOM instance in the POST body to the remote DICOM modality "
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1486 "whose identifier is provided in URL, without having to first store it locally within Orthanc. "
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1487 "This is an alternative to command-line tools such as `storescu` from DCMTK or dcm4che.")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1488 .SetUriArgument("id", "Identifier of the modality of interest")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1489 .AddRequestType(MimeType_Dicom, "DICOM instance to be sent")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1490 .SetAnswerField(SOP_CLASS_UID, RestApiCallDocumentation::Type_String,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1491 "SOP class UID of the DICOM instance, if the C-STORE SCU has succeeded")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1492 .SetAnswerField(SOP_INSTANCE_UID, RestApiCallDocumentation::Type_String,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1493 "SOP instance UID of the DICOM instance, if the C-STORE SCU has succeeded");
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1494 return;
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1495 }
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1496
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1497 Json::Value body = Json::objectValue; // No body
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1498 DicomStoreUserConnection connection(GetAssociationParameters(call, body));
3808
7f083dfae62b new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3740
diff changeset
1499
7f083dfae62b new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3740
diff changeset
1500 std::string sopClassUid, sopInstanceUid;
3894
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3876
diff changeset
1501 connection.Store(sopClassUid, sopInstanceUid, call.GetBodyData(),
8f7ad4989fec transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3876
diff changeset
1502 call.GetBodySize(), false /* Not a C-MOVE */, "", 0);
3808
7f083dfae62b new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3740
diff changeset
1503
7f083dfae62b new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3740
diff changeset
1504 Json::Value answer = Json::objectValue;
7f083dfae62b new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3740
diff changeset
1505 answer[SOP_CLASS_UID] = sopClassUid;
7f083dfae62b new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3740
diff changeset
1506 answer[SOP_INSTANCE_UID] = sopInstanceUid;
7f083dfae62b new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3740
diff changeset
1507
7f083dfae62b new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3740
diff changeset
1508 call.GetOutput().AnswerJson(answer);
7f083dfae62b new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3740
diff changeset
1509 }
7f083dfae62b new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3740
diff changeset
1510
7f083dfae62b new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3740
diff changeset
1511
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1512 /***************************************************************************
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1513 * DICOM C-Move SCU
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1514 ***************************************************************************/
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1515
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1516 static void DicomMove(RestApiPostCall& call)
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1517 {
4423
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1518 if (call.IsDocumentation())
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1519 {
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1520 call.GetDocumentation()
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1521 .SetTag("Networking")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1522 .SetSummary("Trigger C-MOVE SCU")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1523 .SetDescription("Start a C-MOVE SCU command as a job, in order to drive the execution of a sequence of "
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1524 "C-STORE commands by some remote DICOM modality whose identifier is provided in the URL: "
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1525 "https://book.orthanc-server.com/users/rest.html#performing-c-move")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1526 .SetRequestField(KEY_RESOURCES, RestApiCallDocumentation::Type_JsonListOfStrings,
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1527 "List of the Orthanc identifiers of all the DICOM resources to be sent", true)
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1528 .SetRequestField(KEY_LEVEL, RestApiCallDocumentation::Type_String,
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1529 "Level of the query (`Patient`, `Study`, `Series` or `Instance`)", true)
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1530 .SetRequestField(KEY_LOCAL_AET, RestApiCallDocumentation::Type_String,
4463
522e13a60cfc "LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4462
diff changeset
1531 "Local AET that is used for this commands, defaults to `DicomAet` configuration option. "
522e13a60cfc "LocalAet" in "DicomModalities" to overwrite global "DicomAet" for SCU on a per-modality basis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4462
diff changeset
1532 "Ignored if `DicomModalities` already sets `LocalAet` for this modality.", false)
4423
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1533 .SetRequestField(KEY_TARGET_AET, RestApiCallDocumentation::Type_String,
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1534 "Target AET that will be used by the remote DICOM modality as a target for its C-STORE SCU "
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1535 "commands, defaults to `DicomAet` configuration option in order to do a simple query/retrieve", false)
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1536 .SetRequestField(KEY_TIMEOUT, RestApiCallDocumentation::Type_Number,
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1537 "Timeout for the C-STORE command, in seconds", false)
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1538 .SetUriArgument("id", "Identifier of the modality of interest");
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1539 return;
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1540 }
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1541
4205
d962a2996637 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4153
diff changeset
1542 const ServerContext& context = OrthancRestApi::GetContext(call);
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1543
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1544 Json::Value request;
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1545
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1546 if (!call.ParseJsonRequest(request) ||
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1547 request.type() != Json::objectValue ||
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1548 !request.isMember(KEY_RESOURCES) ||
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1549 !request.isMember(KEY_LEVEL) ||
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1550 request[KEY_RESOURCES].type() != Json::arrayValue ||
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1551 request[KEY_LEVEL].type() != Json::stringValue)
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1552 {
3345
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
1553 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON body containing fields " +
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
1554 std::string(KEY_RESOURCES) + " and " + std::string(KEY_LEVEL));
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1555 }
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1556
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1557 ResourceType level = StringToResourceType(request[KEY_LEVEL].asCString());
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1558
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
1559 std::string localAet = Toolbox::GetJsonStringField
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1560 (request, KEY_LOCAL_AET, context.GetDefaultLocalApplicationEntityTitle());
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
1561 std::string targetAet = Toolbox::GetJsonStringField
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
1562 (request, KEY_TARGET_AET, context.GetDefaultLocalApplicationEntityTitle());
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1563
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
1564 const RemoteModalityParameters source =
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1565 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
1566
3874
2effa961f67f forcing use of DicomAssociationParameters if creating an SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
1567 DicomAssociationParameters params(localAet, source);
4732
3709565bee7f fix openapi: /modalities/{id}/move not supporting jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4730
diff changeset
1568 InjectAssociationTimeout(params, request); // Handles KEY_TIMEOUT
3875
ea1d32861cfc moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3874
diff changeset
1569
3874
2effa961f67f forcing use of DicomAssociationParameters if creating an SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3870
diff changeset
1570 DicomControlUserConnection connection(params);
3870
09798f2b985f added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents: 3863
diff changeset
1571
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1572 for (Json::Value::ArrayIndex i = 0; i < request[KEY_RESOURCES].size(); i++)
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1573 {
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1574 DicomMap resource;
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1575 FromDcmtkBridge::FromJson(resource, request[KEY_RESOURCES][i]);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
1576
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
1577 connection.Move(targetAet, level, resource);
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1578 }
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1579
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1580 // Move has succeeded
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1581 call.GetOutput().AnswerBuffer("{}", MimeType_Json);
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1582 }
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1583
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1584
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1585
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1586 /***************************************************************************
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1587 * Orthanc Peers => Store client
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1588 ***************************************************************************/
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1589
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1590 static bool IsExistingPeer(const OrthancRestApi::SetOfStrings& peers,
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1591 const std::string& id)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1592 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1593 return peers.find(id) != peers.end();
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1594 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1595
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
1596 static void ListPeers(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1597 {
4418
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1598 if (call.IsDocumentation())
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1599 {
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1600 call.GetDocumentation()
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1601 .SetTag("Networking")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1602 .SetSummary("List Orthanc peers")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1603 .SetDescription("List all the Orthanc peers that are known to Orthanc. This corresponds either to the content of the "
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1604 "`OrthancPeers` configuration option, or to the information stored in the database if "
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1605 "`OrthancPeersInDatabase` is `true`.")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1606 .SetHttpGetArgument("expand", RestApiCallDocumentation::Type_String,
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1607 "If present, retrieve detailed information about the individual Orthanc peers", false)
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1608 .AddAnswerType(MimeType_Json, "JSON array containing either the identifiers of the peers, or detailed information "
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1609 "about the peers (if `expand` argument is provided)");
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1610 return;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1611 }
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1612
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1613 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1614
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1615 OrthancRestApi::SetOfStrings peers;
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1616 lock.GetConfiguration().GetListOfOrthancPeers(peers);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1617
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1618 if (call.HasArgument("expand"))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1619 {
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1620 Json::Value result = Json::objectValue;
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1621 for (OrthancRestApi::SetOfStrings::const_iterator
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1622 it = peers.begin(); it != peers.end(); ++it)
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1623 {
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1624 WebServiceParameters peer;
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
1625
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
1626 if (lock.GetConfiguration().LookupOrthancPeer(peer, *it))
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1627 {
3192
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3167
diff changeset
1628 Json::Value info;
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3167
diff changeset
1629 peer.FormatPublic(info);
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3167
diff changeset
1630 result[*it] = info;
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1631 }
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1632 }
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1633 call.GetOutput().AnswerJson(result);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1634 }
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1635 else // if expand is not present, keep backward compatibility and return an array of peers
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1636 {
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1637 Json::Value result = Json::arrayValue;
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1638 for (OrthancRestApi::SetOfStrings::const_iterator
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1639 it = peers.begin(); it != peers.end(); ++it)
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1640 {
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1641 result.append(*it);
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1642 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1643
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1644 call.GetOutput().AnswerJson(result);
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1645 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1646 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1647
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
1648 static void ListPeerOperations(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1649 {
4418
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1650 if (call.IsDocumentation())
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1651 {
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1652 call.GetDocumentation()
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1653 .SetTag("Networking")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1654 .SetSummary("List operations on peer")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1655 .SetDescription("List the operations that are available for an Orthanc peer.")
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1656 .SetUriArgument("id", "Identifier of the peer of interest")
4418
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1657 .AddAnswerType(MimeType_Json, "List of the available operations");
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1658 return;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1659 }
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1660
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1661 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1662
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1663 OrthancRestApi::SetOfStrings peers;
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1664 lock.GetConfiguration().GetListOfOrthancPeers(peers);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1665
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1666 std::string id = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1667 if (IsExistingPeer(peers, id))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1668 {
1063
0332e6e8c679 Fix automated generation of the list of resource children in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1049
diff changeset
1669 RestApi::AutoListChildren(call);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1670 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1671 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1672
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
1673 static void PeerStore(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1674 {
4423
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1675 static const char* KEY_TRANSCODE = "Transcode";
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1676 static const char* KEY_COMPRESS = "Compress";
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1677
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1678 if (call.IsDocumentation())
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1679 {
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1680 OrthancRestApi::DocumentSubmitCommandsJob(call);
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1681 call.GetDocumentation()
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1682 .SetTag("Networking")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1683 .SetSummary("Send to Orthanc peer")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1684 .SetDescription("Send DICOM resources stored locally to some remote Orthanc peer whose identifier is provided in the URL: "
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1685 "https://book.orthanc-server.com/users/rest.html#sending-one-resource")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1686 .AddRequestType(MimeType_PlainText, "The Orthanc identifier of one resource to be sent")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1687 .SetRequestField(KEY_RESOURCES, RestApiCallDocumentation::Type_JsonListOfStrings,
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1688 "List of the Orthanc identifiers of all the DICOM resources to be sent", true)
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1689 .SetRequestField(KEY_TRANSCODE, RestApiCallDocumentation::Type_String,
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1690 "Transcode to the provided DICOM transfer syntax before the actual sending", false)
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1691 .SetRequestField(KEY_COMPRESS, RestApiCallDocumentation::Type_Boolean,
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1692 "Whether to compress the DICOM instances using gzip before the actual sending", false)
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1693 .SetUriArgument("id", "Identifier of the modality of interest");
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1694 return;
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1695 }
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1696
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1697 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1698
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1699 std::string remote = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1700
1427
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
1701 Json::Value request;
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
1702 std::unique_ptr<OrthancPeerStoreJob> job(new OrthancPeerStoreJob(context));
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1703
3167
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1704 GetInstancesToExport(request, *job, remote, call);
3950
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
1705
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
1706 if (request.type() == Json::objectValue &&
4423
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1707 request.isMember(KEY_TRANSCODE))
3950
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
1708 {
4423
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1709 job->SetTranscode(SerializationToolbox::ReadString(request, KEY_TRANSCODE));
3950
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
1710 }
4153
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1711
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1712 if (request.type() == Json::objectValue &&
4423
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1713 request.isMember(KEY_COMPRESS))
4153
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1714 {
4423
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
1715 job->SetCompress(SerializationToolbox::ReadBoolean(request, KEY_COMPRESS));
4153
a4664f169cd7 "/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1716 }
3167
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1717
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1718 {
3950
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
1719 OrthancConfiguration::ReaderLock lock;
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
1720
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
1721 WebServiceParameters peer;
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
1722 if (lock.GetConfiguration().LookupOrthancPeer(peer, remote))
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
1723 {
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
1724 job->SetPeer(peer);
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
1725 }
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
1726 else
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
1727 {
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
1728 throw OrthancException(ErrorCode_UnknownResource,
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
1729 "No peer with symbolic name: " + remote);
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
1730 }
3167
860aed8258c3 Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3097
diff changeset
1731 }
3950
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
1732
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
1733 OrthancRestApi::GetApi(call).SubmitCommandsJob
5797ca4f3b8d "/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3894
diff changeset
1734 (call, job.release(), true /* synchronous by default */, request);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1735 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1736
3592
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1737 static void PeerSystem(RestApiGetCall& call)
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1738 {
4418
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1739 if (call.IsDocumentation())
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1740 {
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1741 call.GetDocumentation()
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1742 .SetTag("Networking")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1743 .SetSummary("Get peer system information")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1744 .SetDescription("Get system information about some Orthanc peer. This corresponds to doing a `GET` request "
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1745 "against the `/system` URI of the remote peer. This route can be used to test connectivity.")
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1746 .SetUriArgument("id", "Identifier of the peer of interest")
4418
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1747 .AddAnswerType(MimeType_Json, "System information about the peer");
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1748 return;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1749 }
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1750
3592
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1751 std::string remote = call.GetUriComponent("id", "");
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1752
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1753 OrthancConfiguration::ReaderLock lock;
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1754
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1755 WebServiceParameters peer;
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1756 if (lock.GetConfiguration().LookupOrthancPeer(peer, remote))
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1757 {
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1758 HttpClient client(peer, "system");
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1759 std::string answer;
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1760
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1761 client.SetMethod(HttpMethod_Get);
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1762
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1763 if (!client.Apply(answer))
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1764 {
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1765 LOG(ERROR) << "Unable to get the system info from remote Orthanc peer: " << peer.GetUrl();
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1766 call.GetOutput().SignalError(client.GetLastStatus());
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1767 return;
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1768 }
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1769
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1770 call.GetOutput().AnswerBuffer(answer, MimeType_Json);
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1771 }
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1772 else
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1773 {
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1774 throw OrthancException(ErrorCode_UnknownResource,
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1775 "No peer with symbolic name: " + remote);
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1776 }
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
1777 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1778
4338
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
1779 static void GetPeerConfiguration(RestApiGetCall& call)
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
1780 {
4418
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1781 if (call.IsDocumentation())
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1782 {
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1783 Json::Value sample;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1784 sample["HttpHeaders"] = Json::objectValue;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1785 sample["Password"] = Json::nullValue;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1786 sample["Pkcs11"] = false;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1787 sample["Url"] = "http://127.0.1.1:5000/";
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1788 sample["Username"] = "alice";
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1789 call.GetDocumentation()
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1790 .SetTag("Networking")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1791 .SetSummary("Get peer configuration")
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1792 .SetDescription("Get detailed information about the configuration of some Orthanc peer")
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1793 .SetUriArgument("id", "Identifier of the peer of interest")
4418
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1794 .AddAnswerType(MimeType_Json, "Configuration of the peer")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1795 .SetSample(sample);
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1796 return;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1797 }
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1798
4338
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
1799 OrthancConfiguration::ReaderLock lock;
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
1800 const std::string peer = call.GetUriComponent("id", "");
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
1801
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
1802 WebServiceParameters info;
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
1803 if (lock.GetConfiguration().LookupOrthancPeer(info, peer))
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
1804 {
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
1805 Json::Value answer;
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
1806 info.FormatPublic(answer);
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
1807 call.GetOutput().AnswerJson(answer);
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
1808 }
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
1809 else
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
1810 {
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
1811 throw OrthancException(ErrorCode_UnknownResource,
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
1812 "No peer with symbolic name: " + peer);
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
1813 }
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
1814 }
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
1815
4524
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1816 static void PeerStoreStraight(RestApiPostCall& call)
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1817 {
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1818 if (call.IsDocumentation())
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1819 {
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1820 call.GetDocumentation()
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1821 .SetTag("Networking")
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1822 .SetSummary("Straight store to peer")
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1823 .SetDescription("Synchronously send the DICOM instance in the POST body to the Orthanc peer "
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1824 "whose identifier is provided in URL, without having to first store it locally within Orthanc. "
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1825 "This is an alternative to command-line tools such as `curl`.")
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1826 .SetUriArgument("id", "Identifier of the modality of interest")
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1827 .AddRequestType(MimeType_Dicom, "DICOM instance to be sent")
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1828 .SetAnswerField("ID", RestApiCallDocumentation::Type_String,
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1829 "Orthanc identifier of the DICOM instance in the remote Orthanc peer")
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1830 .SetAnswerField("ParentPatient", RestApiCallDocumentation::Type_String,
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1831 "Orthanc identifier of the parent patient in the remote Orthanc peer")
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1832 .SetAnswerField("ParentStudy", RestApiCallDocumentation::Type_String,
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1833 "Orthanc identifier of the parent study in the remote Orthanc peer")
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1834 .SetAnswerField("ParentSeries", RestApiCallDocumentation::Type_String,
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1835 "Orthanc identifier of the parent series in the remote Orthanc peer")
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1836 .SetAnswerField("Path", RestApiCallDocumentation::Type_String,
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1837 "Path to the DICOM instance in the remote Orthanc server")
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1838 .SetAnswerField("Status", RestApiCallDocumentation::Type_String,
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1839 "Status of the store operation");
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1840 return;
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1841 }
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1842
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1843 const std::string peer = call.GetUriComponent("id", "");
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1844
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1845 WebServiceParameters info;
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1846
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1847 {
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1848 OrthancConfiguration::ReaderLock lock;
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1849 if (!lock.GetConfiguration().LookupOrthancPeer(info, peer))
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1850 {
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1851 throw OrthancException(ErrorCode_UnknownResource, "No peer with symbolic name: " + peer);
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1852 }
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1853 }
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1854
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1855 HttpClient client(info, "instances");
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1856 client.SetMethod(HttpMethod_Post);
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1857 client.AddHeader("Expect", "");
4650
9804d6490872 Reduced memory consumption of HTTP/REST plugins calls on POST/PUT if chunked transfer is disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4524
diff changeset
1858 client.SetExternalBody(call.GetBodyData(), call.GetBodySize());
4524
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1859
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1860 Json::Value answer;
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1861 if (client.Apply(answer))
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1862 {
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1863 call.GetOutput().AnswerJson(answer);
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1864 }
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1865 else
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1866 {
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1867 throw OrthancException(ErrorCode_NetworkProtocol, "Cannot send DICOM to remote peer: " + peer);
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1868 }
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1869 }
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1870
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
1871
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1872 // DICOM bridge -------------------------------------------------------------
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1873
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1874 static bool IsExistingModality(const OrthancRestApi::SetOfStrings& modalities,
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1875 const std::string& id)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1876 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1877 return modalities.find(id) != modalities.end();
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1878 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1879
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
1880 static void ListModalities(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1881 {
4418
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1882 if (call.IsDocumentation())
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1883 {
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1884 call.GetDocumentation()
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1885 .SetTag("Networking")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1886 .SetSummary("List DICOM modalities")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1887 .SetDescription("List all the DICOM modalities that are known to Orthanc. This corresponds either to the content of the "
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1888 "`DicomModalities` configuration option, or to the information stored in the database if "
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1889 "`DicomModalitiesInDatabase` is `true`.")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1890 .SetHttpGetArgument("expand", RestApiCallDocumentation::Type_String,
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1891 "If present, retrieve detailed information about the individual DICOM modalities", false)
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1892 .AddAnswerType(MimeType_Json, "JSON array containing either the identifiers of the modalities, or detailed information "
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1893 "about the modalities (if `expand` argument is provided)");
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1894 return;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1895 }
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1896
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1897 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1898
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1899 OrthancRestApi::SetOfStrings modalities;
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1900 lock.GetConfiguration().GetListOfDicomModalities(modalities);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1901
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1902 if (call.HasArgument("expand"))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1903 {
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1904 Json::Value result = Json::objectValue;
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1905 for (OrthancRestApi::SetOfStrings::const_iterator
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1906 it = modalities.begin(); it != modalities.end(); ++it)
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1907 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1908 const RemoteModalityParameters& remote = lock.GetConfiguration().GetModalityUsingSymbolicName(*it);
2871
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
1909
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
1910 Json::Value info;
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
1911 remote.Serialize(info, true /* force advanced format */);
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
1912 result[*it] = info;
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1913 }
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1914 call.GetOutput().AnswerJson(result);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1915 }
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1916 else // if expand is not present, keep backward compatibility and return an array of modalities ids
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1917 {
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1918 Json::Value result = Json::arrayValue;
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1919 for (OrthancRestApi::SetOfStrings::const_iterator
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1920 it = modalities.begin(); it != modalities.end(); ++it)
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1921 {
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1922 result.append(*it);
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1923 }
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1924 call.GetOutput().AnswerJson(result);
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1925 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1926 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1927
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1928
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
1929 static void ListModalityOperations(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1930 {
4418
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1931 if (call.IsDocumentation())
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1932 {
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1933 call.GetDocumentation()
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1934 .SetTag("Networking")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1935 .SetSummary("List operations on modality")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1936 .SetDescription("List the operations that are available for a DICOM modality.")
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
1937 .SetUriArgument("id", "Identifier of the DICOM modality of interest")
4418
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1938 .AddAnswerType(MimeType_Json, "List of the available operations");
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1939 return;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1940 }
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1941
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1942 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1943
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1944 OrthancRestApi::SetOfStrings modalities;
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1945 lock.GetConfiguration().GetListOfDicomModalities(modalities);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1946
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1947 std::string id = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1948 if (IsExistingModality(modalities, id))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1949 {
1063
0332e6e8c679 Fix automated generation of the list of resource children in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1049
diff changeset
1950 RestApi::AutoListChildren(call);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1951 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1952 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1953
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1954
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
1955 static void UpdateModality(RestApiPutCall& call)
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1956 {
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1957 if (call.IsDocumentation())
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1958 {
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1959 DocumentModalityParametersShared(call, true);
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1960 call.GetDocumentation()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1961 .SetTag("Networking")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1962 .SetSummary("Update DICOM modality")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1963 .SetDescription("Define a new DICOM modality, or update an existing one. This change is permanent iff. "
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1964 "`DicomModalitiesInDatabase` is `true`, otherwise it is lost at the next restart of Orthanc.")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1965 .SetUriArgument("id", "Identifier of the new/updated DICOM modality");
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1966 return;
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1967 }
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
1968
2801
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
1969 ServerContext& context = OrthancRestApi::GetContext(call);
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
1970
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1971 Json::Value json;
3401
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3374
diff changeset
1972 if (call.ParseJsonRequest(json))
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1973 {
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1974 RemoteModalityParameters modality;
2871
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
1975 modality.Unserialize(json);
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1976
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1977 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1978 OrthancConfiguration::WriterLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1979 lock.GetConfiguration().UpdateModality(call.GetUriComponent("id", ""), modality);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1980 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1981
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1982 context.SignalUpdatedModalities();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1983
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1984 call.GetOutput().AnswerBuffer("", MimeType_PlainText);
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1985 }
4339
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
1986 else
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
1987 {
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
1988 throw OrthancException(ErrorCode_BadFileFormat);
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
1989 }
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1990 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1991
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1992
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
1993 static void DeleteModality(RestApiDeleteCall& call)
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1994 {
4418
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1995 if (call.IsDocumentation())
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1996 {
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1997 call.GetDocumentation()
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1998 .SetTag("Networking")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
1999 .SetSummary("Delete DICOM modality")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2000 .SetDescription("Delete one DICOM modality. This change is permanent iff. `DicomModalitiesInDatabase` is `true`, "
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2001 "otherwise it is lost at the next restart of Orthanc.")
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
2002 .SetUriArgument("id", "Identifier of the DICOM modality of interest");
4418
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2003 return;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2004 }
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2005
2801
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
2006 ServerContext& context = OrthancRestApi::GetContext(call);
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
2007
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2008 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2009 OrthancConfiguration::WriterLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2010 lock.GetConfiguration().RemoveModality(call.GetUriComponent("id", ""));
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2011 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2012
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2013 context.SignalUpdatedModalities();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2014
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
2015 call.GetOutput().AnswerBuffer("", MimeType_PlainText);
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
2016 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
2017
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
2018
4338
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
2019 static void GetModalityConfiguration(RestApiGetCall& call)
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
2020 {
4418
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2021 if (call.IsDocumentation())
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2022 {
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2023 Json::Value sample;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2024 sample["AET"] = "ORTHANCTEST";
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2025 sample["AllowEcho"] = true;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2026 sample["AllowEventReport"] = true;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2027 sample["AllowFind"] = true;
4888
8523078f3f4b added new configuration to authorize C-Find for worklist independently from other C-Find
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
2028 sample["AllowFindWorklist"] = true;
4418
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2029 sample["AllowGet"] = true;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2030 sample["AllowMove"] = true;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2031 sample["AllowNAction"] = true;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2032 sample["AllowStore"] = true;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2033 sample["AllowTranscoding"] = true;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2034 sample["Host"] = "127.0.1.1";
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2035 sample["Manufacturer"] = "Generic";
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2036 sample["Port"] = 5001;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2037 call.GetDocumentation()
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2038 .SetTag("Networking")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2039 .SetSummary("Get modality configuration")
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2040 .SetDescription("Get detailed information about the configuration of some DICOM modality")
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
2041 .SetUriArgument("id", "Identifier of the modality of interest")
4418
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2042 .AddAnswerType(MimeType_Json, "Configuration of the modality")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2043 .SetSample(sample);
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2044 return;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2045 }
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2046
4338
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
2047 const std::string modality = call.GetUriComponent("id", "");
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
2048
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
2049 Json::Value answer;
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
2050
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
2051 {
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
2052 OrthancConfiguration::ReaderLock lock;
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
2053 lock.GetConfiguration().GetModalityUsingSymbolicName(modality).Serialize(answer, true /* force advanced format */);
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
2054 }
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
2055
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
2056 call.GetOutput().AnswerJson(answer);
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
2057 }
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
2058
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
2059
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
2060 static void UpdatePeer(RestApiPutCall& call)
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
2061 {
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2062 if (call.IsDocumentation())
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2063 {
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2064 call.GetDocumentation()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2065 .SetTag("Networking")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2066 .SetSummary("Update Orthanc peer")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2067 .SetDescription("Define a new Orthanc peer, or update an existing one. This change is permanent iff. "
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2068 "`OrthancPeersInDatabase` is `true`, otherwise it is lost at the next restart of Orthanc.")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2069 .SetUriArgument("id", "Identifier of the new/updated Orthanc peer")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2070 .SetRequestField("URL", RestApiCallDocumentation::Type_String,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2071 "URL of the root of the REST API of the remote Orthanc peer, for instance `http://localhost:8042/`", true)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2072 .SetRequestField("Username", RestApiCallDocumentation::Type_String,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2073 "Username for the credentials", false)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2074 .SetRequestField("Password", RestApiCallDocumentation::Type_String,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2075 "Password for the credentials", false)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2076 .SetRequestField("CertificateFile", RestApiCallDocumentation::Type_String,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2077 "SSL certificate for the HTTPS connections", false)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2078 .SetRequestField("CertificateKeyFile", RestApiCallDocumentation::Type_String,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2079 "Key file for the SSL certificate for the HTTPS connections", false)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2080 .SetRequestField("CertificateKeyPassword", RestApiCallDocumentation::Type_String,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2081 "Key password for the SSL certificate for the HTTPS connections", false)
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2082 .SetRequestField("HttpHeaders", RestApiCallDocumentation::Type_JsonObject,
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2083 "HTTP headers to be used for the connections to the remote peer", false);
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2084 return;
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2085 }
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2086
2801
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
2087 ServerContext& context = OrthancRestApi::GetContext(call);
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
2088
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
2089 Json::Value json;
3401
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3374
diff changeset
2090 if (call.ParseJsonRequest(json))
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
2091 {
2020
a0bd8cd55da7 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
2092 WebServiceParameters peer;
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
2093 peer.Unserialize(json);
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2094
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2095 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2096 OrthancConfiguration::WriterLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2097 lock.GetConfiguration().UpdatePeer(call.GetUriComponent("id", ""), peer);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2098 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2099
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2100 context.SignalUpdatedPeers();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2101
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
2102 call.GetOutput().AnswerBuffer("", MimeType_PlainText);
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
2103 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
2104 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
2105
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
2106
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
2107 static void DeletePeer(RestApiDeleteCall& call)
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
2108 {
4418
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2109 if (call.IsDocumentation())
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2110 {
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2111 call.GetDocumentation()
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2112 .SetTag("Networking")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2113 .SetSummary("Delete Orthanc peer")
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2114 .SetDescription("Delete one Orthanc peer. This change is permanent iff. `OrthancPeersInDatabase` is `true`, "
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2115 "otherwise it is lost at the next restart of Orthanc.")
4419
cd96c807ca3d cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4418
diff changeset
2116 .SetUriArgument("id", "Identifier of the Orthanc peer of interest");
4418
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2117 return;
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2118 }
9d6fa3da8f00 cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4367
diff changeset
2119
2801
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
2120 ServerContext& context = OrthancRestApi::GetContext(call);
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
2121
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2122 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2123 OrthancConfiguration::WriterLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2124 lock.GetConfiguration().RemovePeer(call.GetUriComponent("id", ""));
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2125 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2126
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2127 context.SignalUpdatedPeers();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
2128
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
2129 call.GetOutput().AnswerBuffer("", MimeType_PlainText);
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
2130 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
2131
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
2132
1819
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
2133 static void DicomFindWorklist(RestApiPostCall& call)
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
2134 {
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2135 if (call.IsDocumentation())
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2136 {
4729
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2137 OrthancRestApi::DocumentDicomFormat(call, DicomToJsonFormat_Human);
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2138
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2139 call.GetDocumentation()
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2140 .SetTag("Networking")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2141 .SetSummary("C-FIND SCU for worklist")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2142 .SetDescription("Trigger C-FIND SCU command against the remote worklists of the DICOM modality "
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2143 "whose identifier is provided in URL")
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2144 .SetUriArgument("id", "Identifier of the modality of interest")
4729
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2145 .SetRequestField(KEY_QUERY, RestApiCallDocumentation::Type_JsonObject,
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2146 "Associative array containing the filter on the values of the DICOM tags", true)
4421
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2147 .AddAnswerType(MimeType_Json, "JSON array describing the DICOM tags of the matching worklists");
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2148 return;
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2149 }
a7d72378e1cb cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4419
diff changeset
2150
1819
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
2151 Json::Value json;
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
2152 if (call.ParseJsonRequest(json))
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
2153 {
4729
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2154 std::unique_ptr<ParsedDicomFile> query;
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2155 DicomToJsonFormat format;
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2156
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2157 if (json.isMember(KEY_QUERY))
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2158 {
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2159 // New in Orthanc 1.9.5
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2160 query.reset(ParsedDicomFile::CreateFromJson(json[KEY_QUERY], static_cast<DicomFromJsonFlags>(0),
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2161 "" /* no private creator */));
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2162 format = OrthancRestApi::GetDicomFormat(json, DicomToJsonFormat_Human);
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2163 }
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2164 else
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2165 {
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2166 // Compatibility with Orthanc <= 1.9.4
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2167 query.reset(ParsedDicomFile::CreateFromJson(json, static_cast<DicomFromJsonFlags>(0),
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2168 "" /* no private creator */));
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2169 format = DicomToJsonFormat_Human;
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2170 }
1819
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
2171
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
2172 DicomFindAnswers answers(true);
1819
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
2173
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
2174 {
3876
92ecaf877baf improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3875
diff changeset
2175 DicomControlUserConnection connection(GetAssociationParameters(call, json));
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
2176 connection.FindWorklist(answers, *query);
1819
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
2177 }
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
2178
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
2179 Json::Value result;
4729
4e2247df6327 Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4718
diff changeset
2180 answers.ToJson(result, format);
1819
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
2181 call.GetOutput().AnswerJson(result);
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
2182 }
3345
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
2183 else
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
2184 {
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
2185 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON object");
f687e11aeb13 more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
2186 }
1819
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
2187 }
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
2188
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
2189
3737
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2190 // Storage commitment SCU ---------------------------------------------------
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2191
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2192 static void StorageCommitmentScu(RestApiPostCall& call)
3611
0ce9c1c6474f test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3602
diff changeset
2193 {
3740
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2194 static const char* const ORTHANC_RESOURCES = "Resources";
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2195 static const char* const DICOM_INSTANCES = "DicomInstances";
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2196
4423
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2197 if (call.IsDocumentation())
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2198 {
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2199 call.GetDocumentation()
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2200 .SetTag("Networking")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2201 .SetSummary("Trigger storage commitment request")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2202 .SetDescription("Trigger a storage commitment request to some remote DICOM modality whose identifier is provided "
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2203 "in the URL: https://book.orthanc-server.com/users/storage-commitment.html#storage-commitment-scu")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2204 .SetRequestField(ORTHANC_RESOURCES, RestApiCallDocumentation::Type_JsonListOfStrings,
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2205 "List of the Orthanc identifiers of the DICOM resources to be checked by storage commitment", true)
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2206 .SetRequestField(DICOM_INSTANCES, RestApiCallDocumentation::Type_JsonListOfObjects,
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2207 "List of DICOM resources that are not necessarily stored within Orthanc, but that must "
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2208 "be checked by storage commitment. This is a list of JSON objects that must contain the "
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2209 "`SOPClassUID` and `SOPInstanceUID` fields.", true)
4517
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
2210 .SetRequestField(KEY_TIMEOUT, RestApiCallDocumentation::Type_Number,
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
2211 "Timeout for the storage commitment command (new in Orthanc 1.9.1)", false)
4423
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2212 .SetAnswerField("ID", RestApiCallDocumentation::Type_JsonObject,
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2213 "Identifier of the storage commitment report, to be used with `/storage-commitment/{id}`")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2214 .SetAnswerField("Path", RestApiCallDocumentation::Type_JsonObject,
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2215 "Root path to the storage commitment report in the REST API")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2216 .SetUriArgument("id", "Identifier of the modality of interest");
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2217 return;
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2218 }
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2219
3611
0ce9c1c6474f test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3602
diff changeset
2220 ServerContext& context = OrthancRestApi::GetContext(call);
0ce9c1c6474f test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3602
diff changeset
2221
0ce9c1c6474f test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3602
diff changeset
2222 Json::Value json;
3740
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2223 if (!call.ParseJsonRequest(json) ||
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2224 json.type() != Json::objectValue)
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2225 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2226 throw OrthancException(ErrorCode_BadFileFormat,
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2227 "Must provide a JSON object with a list of resources");
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2228 }
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2229 else if (!json.isMember(ORTHANC_RESOURCES) &&
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2230 !json.isMember(DICOM_INSTANCES))
3611
0ce9c1c6474f test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3602
diff changeset
2231 {
3740
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2232 throw OrthancException(ErrorCode_BadFileFormat,
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2233 "Empty storage commitment request, one of these fields is mandatory: \"" +
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2234 std::string(ORTHANC_RESOURCES) + "\" or \"" + std::string(DICOM_INSTANCES) + "\"");
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2235 }
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2236 else
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2237 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2238 std::list<std::string> sopClassUids, sopInstanceUids;
3734
4fc24b69446a triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
2239
3740
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2240 if (json.isMember(ORTHANC_RESOURCES))
3734
4fc24b69446a triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
2241 {
3740
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2242 const Json::Value& resources = json[ORTHANC_RESOURCES];
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2243
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2244 if (resources.type() != Json::arrayValue)
3734
4fc24b69446a triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
2245 {
3740
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2246 throw OrthancException(ErrorCode_BadFileFormat,
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2247 "The \"" + std::string(ORTHANC_RESOURCES) +
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2248 "\" field must provide an array of Orthanc resources");
3734
4fc24b69446a triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
2249 }
4fc24b69446a triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
2250 else
4fc24b69446a triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
2251 {
3740
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2252 for (Json::Value::ArrayIndex i = 0; i < resources.size(); i++)
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2253 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2254 if (resources[i].type() != Json::stringValue)
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2255 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2256 throw OrthancException(ErrorCode_BadFileFormat,
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2257 "The \"" + std::string(ORTHANC_RESOURCES) +
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2258 "\" field must provide an array of strings, found: " + resources[i].toStyledString());
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2259 }
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2260
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2261 std::list<std::string> instances;
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2262 context.GetIndex().GetChildInstances(instances, resources[i].asString());
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2263
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2264 for (std::list<std::string>::const_iterator
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2265 it = instances.begin(); it != instances.end(); ++it)
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2266 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2267 std::string sopClassUid, sopInstanceUid;
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2268 DicomMap tags;
4460
6831de40acd9 New metadata automatically computed at the series level: "RemoteAET"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4438
diff changeset
2269 if (context.LookupOrReconstructMetadata(sopClassUid, *it, ResourceType_Instance, MetadataType_Instance_SopClassUid) &&
3740
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2270 context.GetIndex().GetAllMainDicomTags(tags, *it) &&
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2271 tags.LookupStringValue(sopInstanceUid, DICOM_TAG_SOP_INSTANCE_UID, false))
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2272 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2273 sopClassUids.push_back(sopClassUid);
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2274 sopInstanceUids.push_back(sopInstanceUid);
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2275 }
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2276 else
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2277 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2278 throw OrthancException(ErrorCode_InternalError,
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2279 "Cannot retrieve SOP Class/Instance UID of Orthanc instance: " + *it);
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2280 }
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2281 }
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2282 }
3734
4fc24b69446a triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
2283 }
4fc24b69446a triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
2284 }
4fc24b69446a triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
2285
3740
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2286 if (json.isMember(DICOM_INSTANCES))
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2287 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2288 const Json::Value& instances = json[DICOM_INSTANCES];
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2289
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2290 if (instances.type() != Json::arrayValue)
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2291 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2292 throw OrthancException(ErrorCode_BadFileFormat,
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2293 "The \"" + std::string(DICOM_INSTANCES) +
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2294 "\" field must provide an array of DICOM instances");
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2295 }
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2296 else
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2297 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2298 for (Json::Value::ArrayIndex i = 0; i < instances.size(); i++)
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2299 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2300 if (instances[i].type() == Json::arrayValue)
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2301 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2302 if (instances[i].size() != 2 ||
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2303 instances[i][0].type() != Json::stringValue ||
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2304 instances[i][1].type() != Json::stringValue)
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2305 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2306 throw OrthancException(ErrorCode_BadFileFormat,
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2307 "An instance entry must provide an array with 2 strings: "
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2308 "SOP Class UID and SOP Instance UID");
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2309 }
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2310 else
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2311 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2312 sopClassUids.push_back(instances[i][0].asString());
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2313 sopInstanceUids.push_back(instances[i][1].asString());
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2314 }
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2315 }
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2316 else if (instances[i].type() == Json::objectValue)
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2317 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2318 if (!instances[i].isMember(SOP_CLASS_UID) ||
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2319 !instances[i].isMember(SOP_INSTANCE_UID) ||
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2320 instances[i][SOP_CLASS_UID].type() != Json::stringValue ||
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2321 instances[i][SOP_INSTANCE_UID].type() != Json::stringValue)
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2322 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2323 throw OrthancException(ErrorCode_BadFileFormat,
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2324 "An instance entry must provide an object with 2 string fiels: "
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2325 "\"" + std::string(SOP_CLASS_UID) + "\" and \"" +
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2326 std::string(SOP_INSTANCE_UID));
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2327 }
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2328 else
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2329 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2330 sopClassUids.push_back(instances[i][SOP_CLASS_UID].asString());
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2331 sopInstanceUids.push_back(instances[i][SOP_INSTANCE_UID].asString());
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2332 }
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2333 }
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2334 else
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2335 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2336 throw OrthancException(ErrorCode_BadFileFormat,
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2337 "JSON array or object is expected to specify one "
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2338 "instance to be queried, found: " + instances[i].toStyledString());
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2339 }
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2340 }
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2341 }
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2342 }
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2343
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2344 if (sopClassUids.size() != sopInstanceUids.size())
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2345 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2346 throw OrthancException(ErrorCode_InternalError);
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2347 }
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2348
3737
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2349 const std::string transactionUid = Toolbox::GenerateDicomPrivateUniqueIdentifier();
3611
0ce9c1c6474f test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3602
diff changeset
2350
3740
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2351 if (sopClassUids.empty())
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2352 {
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2353 LOG(WARNING) << "Issuing an outgoing storage commitment request that is empty: " << transactionUid;
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2354 }
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2355
3611
0ce9c1c6474f test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3602
diff changeset
2356 {
3734
4fc24b69446a triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
2357 const RemoteModalityParameters remote =
4fc24b69446a triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
2358 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
3611
0ce9c1c6474f test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3602
diff changeset
2359
3737
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2360 const std::string& remoteAet = remote.GetApplicationEntityTitle();
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2361 const std::string& localAet = context.GetDefaultLocalApplicationEntityTitle();
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2362
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2363 // Create a "pending" storage commitment report BEFORE the
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2364 // actual SCU call in order to avoid race conditions
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2365 context.GetStorageCommitmentReports().Store(
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2366 transactionUid, new StorageCommitmentReports::Report(remoteAet));
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2367
3830
447880856ce8 removing deprecated DicomUserControl from OrthancRestModalities.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3808
diff changeset
2368 DicomAssociationParameters parameters(localAet, remote);
4517
c494ee5d0101 Added "Timeout" parameter everywhere in "/modalities/.../"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4480
diff changeset
2369 InjectAssociationTimeout(parameters, json);
3830
447880856ce8 removing deprecated DicomUserControl from OrthancRestModalities.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3808
diff changeset
2370
3740
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2371 std::vector<std::string> a(sopClassUids.begin(), sopClassUids.end());
e69c556f1913 storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3738
diff changeset
2372 std::vector<std::string> b(sopInstanceUids.begin(), sopInstanceUids.end());
3830
447880856ce8 removing deprecated DicomUserControl from OrthancRestModalities.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3808
diff changeset
2373 DicomAssociation::RequestStorageCommitment(parameters, transactionUid, a, b);
3611
0ce9c1c6474f test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3602
diff changeset
2374 }
0ce9c1c6474f test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3602
diff changeset
2375
3734
4fc24b69446a triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
2376 Json::Value result = Json::objectValue;
3737
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2377 result["ID"] = transactionUid;
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2378 result["Path"] = "/storage-commitment/" + transactionUid;
3611
0ce9c1c6474f test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3602
diff changeset
2379 call.GetOutput().AnswerJson(result);
0ce9c1c6474f test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3602
diff changeset
2380 }
0ce9c1c6474f test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3602
diff changeset
2381 }
0ce9c1c6474f test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3602
diff changeset
2382
0ce9c1c6474f test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3602
diff changeset
2383
3737
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2384 static void GetStorageCommitmentReport(RestApiGetCall& call)
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2385 {
4423
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2386 if (call.IsDocumentation())
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2387 {
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2388 call.GetDocumentation()
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2389 .SetTag("Networking")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2390 .SetSummary("Get storage commitment report")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2391 .SetDescription("Get the storage commitment report whose identifier is provided in the URL: "
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2392 "https://book.orthanc-server.com/users/storage-commitment.html#storage-commitment-scu")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2393 .SetAnswerField("Status", RestApiCallDocumentation::Type_String,
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2394 "Can be `Success`, `Failure`, or `Pending` (the latter means that no report has been received yet)")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2395 .SetAnswerField("RemoteAET", RestApiCallDocumentation::Type_String,
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2396 "AET of the remote DICOM modality")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2397 .SetAnswerField("Failures", RestApiCallDocumentation::Type_JsonListOfObjects,
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2398 "List of failures that have been encountered during the storage commitment request")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2399 .SetAnswerField("Success", RestApiCallDocumentation::Type_JsonListOfObjects,
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2400 "List of DICOM instances that have been acknowledged by the remote modality, "
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2401 "each one is reported as a JSON object containing the `SOPClassUID` and "
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2402 "`SOPInstanceUID` DICOM tags")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2403 .SetUriArgument("id", "Identifier of the storage commitment report");
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2404 return;
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2405 }
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2406
3737
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2407 ServerContext& context = OrthancRestApi::GetContext(call);
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2408
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2409 const std::string& transactionUid = call.GetUriComponent("id", "");
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2410
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2411 {
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2412 StorageCommitmentReports::Accessor accessor(
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2413 context.GetStorageCommitmentReports(), transactionUid);
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2414
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2415 if (accessor.IsValid())
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2416 {
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2417 Json::Value json;
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2418 accessor.GetReport().Format(json);
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2419 call.GetOutput().AnswerJson(json);
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2420 }
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2421 else
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2422 {
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2423 throw OrthancException(ErrorCode_InexistentItem,
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2424 "No storage commitment transaction with UID: " + transactionUid);
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2425 }
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2426 }
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2427 }
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2428
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2429
3738
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2430 static void RemoveAfterStorageCommitment(RestApiPostCall& call)
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2431 {
4423
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2432 if (call.IsDocumentation())
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2433 {
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2434 call.GetDocumentation()
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2435 .SetTag("Networking")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2436 .SetSummary("Remove after storage commitment")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2437 .SetDescription("Remove out of Orthanc, the DICOM instances that have been reported to have been properly "
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2438 "received the storage commitment report whose identifier is provided in the URL. This is "
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2439 "only possible if the `Status` of the storage commitment report is `Success`. "
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2440 "https://book.orthanc-server.com/users/storage-commitment.html#removing-the-instances")
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2441 .SetUriArgument("id", "Identifier of the storage commitment report");
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2442 return;
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2443 }
2a69b58ff3ac cont openapi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4422
diff changeset
2444
3738
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2445 ServerContext& context = OrthancRestApi::GetContext(call);
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2446
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2447 const std::string& transactionUid = call.GetUriComponent("id", "");
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2448
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2449 {
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2450 StorageCommitmentReports::Accessor accessor(
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2451 context.GetStorageCommitmentReports(), transactionUid);
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2452
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2453 if (!accessor.IsValid())
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2454 {
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2455 throw OrthancException(ErrorCode_InexistentItem,
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2456 "No storage commitment transaction with UID: " + transactionUid);
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2457 }
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2458 else if (accessor.GetReport().GetStatus() != StorageCommitmentReports::Report::Status_Success)
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2459 {
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2460 throw OrthancException(ErrorCode_BadSequenceOfCalls,
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2461 "Cannot remove DICOM instances after failure "
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2462 "in storage commitment transaction: " + transactionUid);
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2463 }
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2464 else
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2465 {
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2466 std::vector<std::string> sopInstanceUids;
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2467 accessor.GetReport().GetSuccessSopInstanceUids(sopInstanceUids);
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2468
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2469 for (size_t i = 0; i < sopInstanceUids.size(); i++)
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2470 {
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2471 std::vector<std::string> orthancId;
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2472 context.GetIndex().LookupIdentifierExact(
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2473 orthancId, ResourceType_Instance, DICOM_TAG_SOP_INSTANCE_UID, sopInstanceUids[i]);
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2474
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2475 for (size_t j = 0; j < orthancId.size(); j++)
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2476 {
4294
0923247e69f6 log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents: 4272
diff changeset
2477 CLOG(INFO, HTTP) << "Storage commitment - Removing SOP instance UID / Orthanc ID: "
4272
1661544ea94d LogCategory_REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4205
diff changeset
2478 << sopInstanceUids[i] << " / " << orthancId[j];
3738
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2479
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2480 Json::Value tmp;
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2481 context.GetIndex().DeleteResource(tmp, orthancId[j], ResourceType_Instance);
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2482 }
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2483 }
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2484
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2485 call.GetOutput().AnswerBuffer("{}", MimeType_Json);
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2486 }
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2487 }
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2488 }
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2489
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2490
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2491 void OrthancRestApi::RegisterModalities()
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2492 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2493 Register("/modalities", ListModalities);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2494 Register("/modalities/{id}", ListModalityOperations);
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
2495 Register("/modalities/{id}", UpdateModality);
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
2496 Register("/modalities/{id}", DeleteModality);
1049
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
2497 Register("/modalities/{id}/echo", DicomEcho);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2498 Register("/modalities/{id}/find-patient", DicomFindPatient);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2499 Register("/modalities/{id}/find-study", DicomFindStudy);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2500 Register("/modalities/{id}/find-series", DicomFindSeries);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2501 Register("/modalities/{id}/find-instance", DicomFindInstance);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2502 Register("/modalities/{id}/find", DicomFind);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2503 Register("/modalities/{id}/store", DicomStore);
3808
7f083dfae62b new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3740
diff changeset
2504 Register("/modalities/{id}/store-straight", DicomStoreStraight); // New in 1.6.1
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
2505 Register("/modalities/{id}/move", DicomMove);
4338
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
2506 Register("/modalities/{id}/configuration", GetModalityConfiguration); // New in 1.8.1
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2507
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
2508 // For Query/Retrieve
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
2509 Register("/modalities/{id}/query", DicomQuery);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
2510 Register("/queries", ListQueries);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
2511 Register("/queries/{id}", DeleteQuery);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
2512 Register("/queries/{id}", ListQueryOperations);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
2513 Register("/queries/{id}/answers", ListQueryAnswers);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
2514 Register("/queries/{id}/answers/{index}", ListQueryAnswerOperations);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
2515 Register("/queries/{id}/answers/{index}/content", GetQueryOneAnswer);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
2516 Register("/queries/{id}/answers/{index}/retrieve", RetrieveOneAnswer);
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
2517 Register("/queries/{id}/answers/{index}/query-instances",
2986
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
2518 QueryAnswerChildren<ResourceType_Instance>);
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
2519 Register("/queries/{id}/answers/{index}/query-series",
2986
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
2520 QueryAnswerChildren<ResourceType_Series>);
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
2521 Register("/queries/{id}/answers/{index}/query-studies",
2986
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
2522 QueryAnswerChildren<ResourceType_Study>);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
2523 Register("/queries/{id}/level", GetQueryLevel);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
2524 Register("/queries/{id}/modality", GetQueryModality);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
2525 Register("/queries/{id}/query", GetQueryArguments);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
2526 Register("/queries/{id}/retrieve", RetrieveAllAnswers);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
2527
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2528 Register("/peers", ListPeers);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2529 Register("/peers/{id}", ListPeerOperations);
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
2530 Register("/peers/{id}", UpdatePeer);
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
2531 Register("/peers/{id}", DeletePeer);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2532 Register("/peers/{id}/store", PeerStore);
3592
de1665e7b341 added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents: 3401
diff changeset
2533 Register("/peers/{id}/system", PeerSystem);
4338
1263e727d048 give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4294
diff changeset
2534 Register("/peers/{id}/configuration", GetPeerConfiguration); // New in 1.8.1
4524
f8660649ae96 added "/peers/{id}/store-straight": Synchronously send the DICOM instance in POST body to the peer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4517
diff changeset
2535 Register("/peers/{id}/store-straight", PeerStoreStraight); // New in 1.9.1
1819
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
2536
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
2537 Register("/modalities/{id}/find-worklist", DicomFindWorklist);
3611
0ce9c1c6474f test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3602
diff changeset
2538
3738
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2539 // Storage commitment
3737
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2540 Register("/modalities/{id}/storage-commitment", StorageCommitmentScu);
f29843323daf accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3734
diff changeset
2541 Register("/storage-commitment/{id}", GetStorageCommitmentReport);
3738
bff4da769f6f new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3737
diff changeset
2542 Register("/storage-commitment/{id}/remove", RemoveAfterStorageCommitment);
4339
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
2543
fc5caed6f940 "/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4338
diff changeset
2544 Register("/tools/dicom-echo", DicomEchoTool); // New in 1.8.1
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2545 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2546 }