Mercurial > hg > orthanc
comparison OrthancServer/OrthancRestApi.cpp @ 217:1ac3aacd10a5
simplifications
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 29 Nov 2012 12:22:23 +0100 |
parents | e5d5d4a9a326 |
children | 209ca3f6db62 |
comparison
equal
deleted
inserted
replaced
216:e5d5d4a9a326 | 217:1ac3aacd10a5 |
---|---|
51 std::string s = writer.write(value); | 51 std::string s = writer.write(value); |
52 output.AnswerBufferWithContentType(s, "application/json"); | 52 output.AnswerBufferWithContentType(s, "application/json"); |
53 } | 53 } |
54 | 54 |
55 void OrthancRestApi::ConnectToModality(DicomUserConnection& c, | 55 void OrthancRestApi::ConnectToModality(DicomUserConnection& c, |
56 const std::string& name) | 56 const std::string& name) |
57 { | 57 { |
58 std::string aet, address; | 58 std::string aet, address; |
59 int port; | 59 int port; |
60 GetDicomModality(name, aet, address, port); | 60 GetDicomModality(name, aet, address, port); |
61 c.SetLocalApplicationEntityTitle(GetGlobalStringParameter("DicomAet", "ORTHANC")); | 61 c.SetLocalApplicationEntityTitle(GetGlobalStringParameter("DicomAet", "ORTHANC")); |
64 c.SetDistantPort(port); | 64 c.SetDistantPort(port); |
65 c.Open(); | 65 c.Open(); |
66 } | 66 } |
67 | 67 |
68 bool OrthancRestApi::MergeQueryAndTemplate(DicomMap& result, | 68 bool OrthancRestApi::MergeQueryAndTemplate(DicomMap& result, |
69 const std::string& postData) | 69 const std::string& postData) |
70 { | 70 { |
71 Json::Value query; | 71 Json::Value query; |
72 Json::Reader reader; | 72 Json::Reader reader; |
73 | 73 |
74 if (!reader.parse(postData, query) || | 74 if (!reader.parse(postData, query) || |
86 | 86 |
87 return true; | 87 return true; |
88 } | 88 } |
89 | 89 |
90 bool OrthancRestApi::DicomFindPatient(Json::Value& result, | 90 bool OrthancRestApi::DicomFindPatient(Json::Value& result, |
91 DicomUserConnection& c, | 91 DicomUserConnection& c, |
92 const std::string& postData) | 92 const std::string& postData) |
93 { | 93 { |
94 DicomMap m; | 94 DicomMap m; |
95 DicomMap::SetupFindPatientTemplate(m); | 95 DicomMap::SetupFindPatientTemplate(m); |
96 if (!MergeQueryAndTemplate(m, postData)) | 96 if (!MergeQueryAndTemplate(m, postData)) |
97 { | 97 { |
103 answers.ToJson(result); | 103 answers.ToJson(result); |
104 return true; | 104 return true; |
105 } | 105 } |
106 | 106 |
107 bool OrthancRestApi::DicomFindStudy(Json::Value& result, | 107 bool OrthancRestApi::DicomFindStudy(Json::Value& result, |
108 DicomUserConnection& c, | 108 DicomUserConnection& c, |
109 const std::string& postData) | 109 const std::string& postData) |
110 { | 110 { |
111 DicomMap m; | 111 DicomMap m; |
112 DicomMap::SetupFindStudyTemplate(m); | 112 DicomMap::SetupFindStudyTemplate(m); |
113 if (!MergeQueryAndTemplate(m, postData)) | 113 if (!MergeQueryAndTemplate(m, postData)) |
114 { | 114 { |
126 answers.ToJson(result); | 126 answers.ToJson(result); |
127 return true; | 127 return true; |
128 } | 128 } |
129 | 129 |
130 bool OrthancRestApi::DicomFindSeries(Json::Value& result, | 130 bool OrthancRestApi::DicomFindSeries(Json::Value& result, |
131 DicomUserConnection& c, | 131 DicomUserConnection& c, |
132 const std::string& postData) | 132 const std::string& postData) |
133 { | 133 { |
134 DicomMap m; | 134 DicomMap m; |
135 DicomMap::SetupFindSeriesTemplate(m); | 135 DicomMap::SetupFindSeriesTemplate(m); |
136 if (!MergeQueryAndTemplate(m, postData)) | 136 if (!MergeQueryAndTemplate(m, postData)) |
137 { | 137 { |
150 answers.ToJson(result); | 150 answers.ToJson(result); |
151 return true; | 151 return true; |
152 } | 152 } |
153 | 153 |
154 bool OrthancRestApi::DicomFind(Json::Value& result, | 154 bool OrthancRestApi::DicomFind(Json::Value& result, |
155 DicomUserConnection& c, | 155 DicomUserConnection& c, |
156 const std::string& postData) | 156 const std::string& postData) |
157 { | 157 { |
158 DicomMap m; | 158 DicomMap m; |
159 DicomMap::SetupFindPatientTemplate(m); | 159 DicomMap::SetupFindPatientTemplate(m); |
160 if (!MergeQueryAndTemplate(m, postData)) | 160 if (!MergeQueryAndTemplate(m, postData)) |
161 { | 161 { |
220 } | 220 } |
221 | 221 |
222 | 222 |
223 | 223 |
224 bool OrthancRestApi::DicomStore(Json::Value& result, | 224 bool OrthancRestApi::DicomStore(Json::Value& result, |
225 DicomUserConnection& c, | 225 DicomUserConnection& c, |
226 const std::string& postData) | 226 const std::string& postData) |
227 { | 227 { |
228 Json::Value found(Json::objectValue); | 228 Json::Value found(Json::objectValue); |
229 | 229 |
230 if (!Toolbox::IsUuid(postData)) | 230 if (!Toolbox::IsUuid(postData)) |
231 { | 231 { |
266 return true; | 266 return true; |
267 } | 267 } |
268 | 268 |
269 | 269 |
270 OrthancRestApi::OrthancRestApi(ServerIndex& index, | 270 OrthancRestApi::OrthancRestApi(ServerIndex& index, |
271 const std::string& path) : | 271 const std::string& path) : |
272 index_(index), | 272 index_(index), |
273 storage_(path) | 273 storage_(path) |
274 { | 274 { |
275 GetListOfDicomModalities(modalities_); | 275 GetListOfDicomModalities(modalities_); |
276 } | 276 } |