comparison OrthancServer/RadiotherapyRestApi.cpp @ 529:bd2087bb6450 dicom-rt

access to rois
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 29 Aug 2013 17:59:09 +0200
parents e318e9d49815
children b22312081388
comparison
equal deleted inserted replaced
526:e318e9d49815 529:bd2087bb6450
42 42
43 #define REFERENCED_STUDY_SEQUENCE "0008,1110" 43 #define REFERENCED_STUDY_SEQUENCE "0008,1110"
44 #define REFERENCED_SOP_INSTANCE_UID "0008,1155" 44 #define REFERENCED_SOP_INSTANCE_UID "0008,1155"
45 #define FRAME_OF_REFERENCE_UID "0020,0052" 45 #define FRAME_OF_REFERENCE_UID "0020,0052"
46 #define REFERENCED_FRAME_OF_REFERENCE_SEQUENCE "3006,0010" 46 #define REFERENCED_FRAME_OF_REFERENCE_SEQUENCE "3006,0010"
47 #define STRUCTURE_SET_ROI_SEQUENCE "3006,0020"
48 #define ROI_NUMBER "3006,0022"
49 #define ROI_NAME "3006,0026"
50 #define ROI_GENERATION_ALGORITHM "3006,0036"
51 #define ROI_CONTOUR_SEQUENCE "3006,0039"
52 #define REFERENCED_ROI_NUMBER "3006,0084"
53 #define ROI_DISPLAY_COLOR "3006,002a"
47 54
48 namespace Orthanc 55 namespace Orthanc
49 { 56 {
50 static bool CheckSeriesModality(Json::Value& study, 57 static bool CheckSeriesModality(Json::Value& study,
51 Json::Value& series, 58 Json::Value& series,
151 result["RelatedSeries"].append(study["Series"][i].asString()); 158 result["RelatedSeries"].append(study["Series"][i].asString());
152 } 159 }
153 } 160 }
154 } 161 }
155 162
163
156 call.GetOutput().AnswerJson(result); 164 call.GetOutput().AnswerJson(result);
157 } 165 }
158 } 166 }
159 167
160 168
169 static void GetRtStructuresListOfROIs(RestApi::GetCall& call)
170 {
171 RETRIEVE_CONTEXT(call);
172
173 Json::Value study, series, content;
174 std::string frameOfReference;
175 if (GetRtStructuresInfo(study, series, content, frameOfReference, context, call.GetUriComponent("id", "")))
176 {
177 Json::Value result(Json::arrayValue);
178
179 if (content.isMember(STRUCTURE_SET_ROI_SEQUENCE))
180 {
181 for (Json::Value::ArrayIndex i = 0; i < content[STRUCTURE_SET_ROI_SEQUENCE]["Value"].size(); i++)
182 {
183 if (content[STRUCTURE_SET_ROI_SEQUENCE]["Value"][i].isMember(ROI_NUMBER))
184 {
185 result.append(content[STRUCTURE_SET_ROI_SEQUENCE]["Value"][i][ROI_NUMBER]["Value"].asString());
186 }
187 }
188 }
189
190 call.GetOutput().AnswerJson(result);
191 }
192 }
193
194
195 static void GetRtStructuresROI(RestApi::GetCall& call)
196 {
197 RETRIEVE_CONTEXT(call);
198
199 Json::Value study, series, content;
200 std::string frameOfReference;
201 if (GetRtStructuresInfo(study, series, content, frameOfReference, context, call.GetUriComponent("id", "")))
202 {
203 if (content.isMember(STRUCTURE_SET_ROI_SEQUENCE) &&
204 content.isMember(ROI_CONTOUR_SEQUENCE))
205 {
206 Json::Value result;
207
208 bool found = false;
209 for (Json::Value::ArrayIndex i = 0; i < content[STRUCTURE_SET_ROI_SEQUENCE]["Value"].size(); i++)
210 {
211 if (content[STRUCTURE_SET_ROI_SEQUENCE]["Value"][i].isMember(ROI_NUMBER) &&
212 content[STRUCTURE_SET_ROI_SEQUENCE]["Value"][i].isMember(ROI_NAME) &&
213 content[STRUCTURE_SET_ROI_SEQUENCE]["Value"][i][ROI_NUMBER]["Value"].asString() == call.GetUriComponent("roi", ""))
214 {
215 result["Number"] = call.GetUriComponent("roi", "");
216 result["Name"] = content[STRUCTURE_SET_ROI_SEQUENCE]["Value"][i][ROI_NAME]["Value"].asString();
217 result["GenerationAlgorithm"] = content[STRUCTURE_SET_ROI_SEQUENCE]["Value"][i][ROI_GENERATION_ALGORITHM]["Value"].asString();
218 found = true;
219 }
220 }
221
222 if (!found)
223 {
224 return;
225 }
226
227 found = false;
228
229 for (Json::Value::ArrayIndex i = 0; i < content[ROI_CONTOUR_SEQUENCE]["Value"].size(); i++)
230 {
231 if (content[ROI_CONTOUR_SEQUENCE]["Value"][i].isMember(REFERENCED_ROI_NUMBER) &&
232 content[ROI_CONTOUR_SEQUENCE]["Value"][i].isMember(ROI_DISPLAY_COLOR) &&
233 content[ROI_CONTOUR_SEQUENCE]["Value"][i][REFERENCED_ROI_NUMBER]["Value"].asString() == call.GetUriComponent("roi", ""))
234 {
235 result["DisplayColor"] = content[ROI_CONTOUR_SEQUENCE]["Value"][i][ROI_DISPLAY_COLOR]["Value"].asString();
236 found = true;
237 }
238 }
239
240 if (found)
241 {
242 call.GetOutput().AnswerJson(result);
243 }
244 }
245 }
246 }
247
248
161 RadiotherapyRestApi::RadiotherapyRestApi(ServerContext& context) : OrthancRestApi(context) 249 RadiotherapyRestApi::RadiotherapyRestApi(ServerContext& context) : OrthancRestApi(context)
162 { 250 {
163 Register("/series/{id}/rt-structures", GetRtStructuresInfo); 251 Register("/series/{id}/rt-structures", GetRtStructuresInfo);
164 } 252 Register("/series/{id}/rt-structures/roi", GetRtStructuresListOfROIs);
253 Register("/series/{id}/rt-structures/roi/{roi}", GetRtStructuresROI);
254 }
255
165 } 256 }
166 257
167 258
168 // curl http://localhost:8042/series/0b9e2bb2-605a59aa-f27c0260-9cc4faf6-9d8bf457/rt-structures 259 // curl http://localhost:8042/series/0b9e2bb2-605a59aa-f27c0260-9cc4faf6-9d8bf457/rt-structures
169 // curl http://localhost:8042/series/ef041e6b-c855e775-f7e0f7fe-dc3c17dc-533cb8c5/rt-structures 260 // curl http://localhost:8042/series/ef041e6b-c855e775-f7e0f7fe-dc3c17dc-533cb8c5/rt-structures