Mercurial > hg > orthanc
annotate OrthancServer/Sources/ResourceFinder.cpp @ 5676:b744a2cf408a find-refactoring
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 06 Jul 2024 15:04:28 +0200 |
parents | 74f3aab95886 |
children | fd4c5e064cbe |
rev | line source |
---|---|
5608 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5641
3f13db27b399
integration mainline->find-refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5621
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
3f13db27b399
integration mainline->find-refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5621
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5608 | 7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
8 * | |
9 * This program is free software: you can redistribute it and/or | |
10 * modify it under the terms of the GNU General Public License as | |
11 * published by the Free Software Foundation, either version 3 of the | |
12 * License, or (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, but | |
15 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 * General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
24 #include "PrecompiledHeadersServer.h" | |
25 #include "ResourceFinder.h" | |
26 | |
27 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
28 #include "../../OrthancFramework/Sources/Logging.h" |
5608 | 29 #include "../../OrthancFramework/Sources/OrthancException.h" |
30 #include "../../OrthancFramework/Sources/SerializationToolbox.h" | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
31 #include "OrthancConfiguration.h" |
5608 | 32 #include "ServerContext.h" |
33 #include "ServerIndex.h" | |
34 | |
35 | |
36 namespace Orthanc | |
37 { | |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
38 void ResourceFinder::ConfigureChildrenCountComputedTag(DicomTag tag, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
39 ResourceType parentLevel, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
40 ResourceType childLevel) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
41 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
42 if (request_.GetLevel() == parentLevel) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
43 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
44 requestedComputedTags_.insert(tag); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
45 hasRequestedTags_ = true; |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
46 request_.GetChildrenSpecification(childLevel).SetRetrieveIdentifiers(true); |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
47 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
48 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
49 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
50 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
51 void ResourceFinder::InjectChildrenCountComputedTag(DicomMap& requestedTags, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
52 DicomTag tag, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
53 const FindResponse::Resource& resource, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
54 ResourceType level) const |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
55 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
56 if (IsRequestedComputedTag(tag)) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
57 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
58 const std::set<std::string>& children = resource.GetChildrenIdentifiers(level); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
59 requestedTags.SetValue(tag, boost::lexical_cast<std::string>(children.size()), false); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
60 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
61 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
62 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
63 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
64 void ResourceFinder::InjectComputedTags(DicomMap& requestedTags, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
65 const FindResponse::Resource& resource) const |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
66 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
67 switch (resource.GetLevel()) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
68 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
69 case ResourceType_Patient: |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
70 InjectChildrenCountComputedTag(requestedTags, DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES, resource, ResourceType_Study); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
71 InjectChildrenCountComputedTag(requestedTags, DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES, resource, ResourceType_Series); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
72 InjectChildrenCountComputedTag(requestedTags, DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES, resource, ResourceType_Instance); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
73 break; |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
74 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
75 case ResourceType_Study: |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
76 InjectChildrenCountComputedTag(requestedTags, DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES, resource, ResourceType_Series); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
77 InjectChildrenCountComputedTag(requestedTags, DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES, resource, ResourceType_Instance); |
5672
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
78 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
79 if (IsRequestedComputedTag(DICOM_TAG_MODALITIES_IN_STUDY)) |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
80 { |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
81 std::set<std::string> modalities; |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
82 resource.GetChildrenMainDicomTagValues(modalities, ResourceType_Series, DICOM_TAG_MODALITY); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
83 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
84 std::string s; |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
85 Toolbox::JoinStrings(s, modalities, "\\"); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
86 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
87 requestedTags.SetValue(DICOM_TAG_MODALITIES_IN_STUDY, s, false); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
88 } |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
89 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
90 if (IsRequestedComputedTag(DICOM_TAG_SOP_CLASSES_IN_STUDY)) |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
91 { |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
92 std::set<std::string> classes; |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
93 resource.GetChildrenMetadataValues(classes, ResourceType_Instance, MetadataType_Instance_SopClassUid); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
94 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
95 std::string s; |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
96 Toolbox::JoinStrings(s, classes, "\\"); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
97 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
98 requestedTags.SetValue(DICOM_TAG_SOP_CLASSES_IN_STUDY, s, false); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
99 } |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
100 |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
101 break; |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
102 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
103 case ResourceType_Series: |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
104 InjectChildrenCountComputedTag(requestedTags, DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES, resource, ResourceType_Instance); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
105 break; |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
106 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
107 case ResourceType_Instance: |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
108 if (IsRequestedComputedTag(DICOM_TAG_INSTANCE_AVAILABILITY)) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
109 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
110 requestedTags.SetValue(DICOM_TAG_INSTANCE_AVAILABILITY, "ONLINE", false); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
111 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
112 break; |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
113 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
114 default: |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
115 throw OrthancException(ErrorCode_InternalError); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
116 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
117 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
118 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
119 |
5608 | 120 SeriesStatus ResourceFinder::GetSeriesStatus(uint32_t& expectedNumberOfInstances, |
121 const FindResponse::Resource& resource) const | |
122 { | |
123 if (request_.GetLevel() != ResourceType_Series) | |
124 { | |
125 throw OrthancException(ErrorCode_BadParameterType); | |
126 } | |
127 | |
128 std::string s; | |
129 if (!resource.LookupMetadata(s, ResourceType_Series, MetadataType_Series_ExpectedNumberOfInstances) || | |
130 !SerializationToolbox::ParseUnsignedInteger32(expectedNumberOfInstances, s)) | |
131 { | |
132 return SeriesStatus_Unknown; | |
133 } | |
134 | |
5674 | 135 std::set<std::string> values; |
136 resource.GetChildrenMetadataValues(values, ResourceType_Instance, MetadataType_Instance_IndexInSeries); | |
5608 | 137 |
138 std::set<int64_t> instances; | |
139 | |
5674 | 140 for (std::set<std::string>::const_iterator |
5608 | 141 it = values.begin(); it != values.end(); ++it) |
142 { | |
143 int64_t index; | |
144 | |
145 if (!SerializationToolbox::ParseInteger64(index, *it)) | |
146 { | |
147 return SeriesStatus_Unknown; | |
148 } | |
149 | |
150 if (index <= 0 || | |
151 index > static_cast<int64_t>(expectedNumberOfInstances)) | |
152 { | |
153 // Out-of-range instance index | |
154 return SeriesStatus_Inconsistent; | |
155 } | |
156 | |
157 if (instances.find(index) != instances.end()) | |
158 { | |
159 // Twice the same instance index | |
160 return SeriesStatus_Inconsistent; | |
161 } | |
162 | |
163 instances.insert(index); | |
164 } | |
165 | |
166 if (instances.size() == static_cast<size_t>(expectedNumberOfInstances)) | |
167 { | |
168 return SeriesStatus_Complete; | |
169 } | |
170 else | |
171 { | |
172 return SeriesStatus_Missing; | |
173 } | |
174 } | |
175 | |
176 | |
177 void ResourceFinder::Expand(Json::Value& target, | |
178 const FindResponse::Resource& resource, | |
179 ServerIndex& index) const | |
180 { | |
181 /** | |
182 * This method closely follows "SerializeExpandedResource()" in | |
183 * "ServerContext.cpp" from Orthanc 1.12.3. | |
184 **/ | |
185 | |
186 if (resource.GetLevel() != request_.GetLevel()) | |
187 { | |
188 throw OrthancException(ErrorCode_InternalError); | |
189 } | |
190 | |
191 target = Json::objectValue; | |
192 | |
193 target["Type"] = GetResourceTypeText(resource.GetLevel(), false, true); | |
194 target["ID"] = resource.GetIdentifier(); | |
195 | |
196 switch (resource.GetLevel()) | |
197 { | |
198 case ResourceType_Patient: | |
199 break; | |
200 | |
201 case ResourceType_Study: | |
202 target["ParentPatient"] = resource.GetParentIdentifier(); | |
203 break; | |
204 | |
205 case ResourceType_Series: | |
206 target["ParentStudy"] = resource.GetParentIdentifier(); | |
207 break; | |
208 | |
209 case ResourceType_Instance: | |
210 target["ParentSeries"] = resource.GetParentIdentifier(); | |
211 break; | |
212 | |
213 default: | |
214 throw OrthancException(ErrorCode_InternalError); | |
215 } | |
216 | |
217 if (resource.GetLevel() != ResourceType_Instance) | |
218 { | |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
219 const std::set<std::string>& children = resource.GetChildrenIdentifiers(GetChildResourceType(resource.GetLevel())); |
5608 | 220 |
221 Json::Value c = Json::arrayValue; | |
222 for (std::set<std::string>::const_iterator | |
223 it = children.begin(); it != children.end(); ++it) | |
224 { | |
225 c.append(*it); | |
226 } | |
227 | |
228 switch (resource.GetLevel()) | |
229 { | |
230 case ResourceType_Patient: | |
231 target["Studies"] = c; | |
232 break; | |
233 | |
234 case ResourceType_Study: | |
235 target["Series"] = c; | |
236 break; | |
237 | |
238 case ResourceType_Series: | |
239 target["Instances"] = c; | |
240 break; | |
241 | |
242 default: | |
243 throw OrthancException(ErrorCode_InternalError); | |
244 } | |
245 } | |
246 | |
247 switch (resource.GetLevel()) | |
248 { | |
249 case ResourceType_Patient: | |
250 case ResourceType_Study: | |
251 break; | |
252 | |
253 case ResourceType_Series: | |
254 { | |
255 uint32_t expectedNumberOfInstances; | |
256 SeriesStatus status = GetSeriesStatus(expectedNumberOfInstances, resource); | |
257 | |
258 target["Status"] = EnumerationToString(status); | |
259 | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
260 static const char* const EXPECTED_NUMBER_OF_INSTANCES = "ExpectedNumberOfInstances"; |
5608 | 261 |
262 if (status == SeriesStatus_Unknown) | |
263 { | |
264 target[EXPECTED_NUMBER_OF_INSTANCES] = Json::nullValue; | |
265 } | |
266 else | |
267 { | |
268 target[EXPECTED_NUMBER_OF_INSTANCES] = expectedNumberOfInstances; | |
269 } | |
270 | |
271 break; | |
272 } | |
273 | |
274 case ResourceType_Instance: | |
275 { | |
276 FileInfo info; | |
277 if (resource.LookupAttachment(info, FileContentType_Dicom)) | |
278 { | |
279 target["FileSize"] = static_cast<Json::UInt64>(info.GetUncompressedSize()); | |
280 target["FileUuid"] = info.GetUuid(); | |
281 } | |
282 else | |
283 { | |
284 throw OrthancException(ErrorCode_InternalError); | |
285 } | |
286 | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
287 static const char* const INDEX_IN_SERIES = "IndexInSeries"; |
5608 | 288 |
289 std::string s; | |
290 uint32_t index; | |
291 if (resource.LookupMetadata(s, ResourceType_Instance, MetadataType_Instance_IndexInSeries) && | |
292 SerializationToolbox::ParseUnsignedInteger32(index, s)) | |
293 { | |
294 target[INDEX_IN_SERIES] = index; | |
295 } | |
296 else | |
297 { | |
298 target[INDEX_IN_SERIES] = Json::nullValue; | |
299 } | |
300 | |
301 break; | |
302 } | |
303 | |
304 default: | |
305 throw OrthancException(ErrorCode_InternalError); | |
306 } | |
307 | |
308 std::string s; | |
309 if (resource.LookupMetadata(s, resource.GetLevel(), MetadataType_AnonymizedFrom)) | |
310 { | |
311 target["AnonymizedFrom"] = s; | |
312 } | |
313 | |
314 if (resource.LookupMetadata(s, resource.GetLevel(), MetadataType_ModifiedFrom)) | |
315 { | |
316 target["ModifiedFrom"] = s; | |
317 } | |
318 | |
319 if (resource.GetLevel() == ResourceType_Patient || | |
320 resource.GetLevel() == ResourceType_Study || | |
321 resource.GetLevel() == ResourceType_Series) | |
322 { | |
323 target["IsStable"] = !index.IsUnstableResource(resource.GetLevel(), resource.GetInternalId()); | |
324 | |
325 if (resource.LookupMetadata(s, resource.GetLevel(), MetadataType_LastUpdate)) | |
326 { | |
327 target["LastUpdate"] = s; | |
328 } | |
329 } | |
330 | |
331 { | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
332 DicomMap allMainDicomTags; |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
333 resource.GetMainDicomTags(allMainDicomTags, resource.GetLevel()); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
334 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
335 /** |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
336 * This section was part of "StatelessDatabaseOperations::ExpandResource()" |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
337 * in Orthanc <= 1.12.3 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
338 **/ |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
339 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
340 // read all main sequences from DB |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
341 std::string serializedSequences; |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
342 if (resource.LookupMetadata(serializedSequences, resource.GetLevel(), MetadataType_MainDicomSequences)) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
343 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
344 Json::Value jsonMetadata; |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
345 Toolbox::ReadJson(jsonMetadata, serializedSequences); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
346 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
347 if (jsonMetadata["Version"].asInt() == 1) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
348 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
349 allMainDicomTags.FromDicomAsJson(jsonMetadata["Sequences"], true /* append */, true /* parseSequences */); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
350 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
351 else |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
352 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
353 throw OrthancException(ErrorCode_NotImplemented); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
354 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
355 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
356 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
357 /** |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
358 * End of section from StatelessDatabaseOperations |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
359 **/ |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
360 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
361 |
5608 | 362 static const char* const MAIN_DICOM_TAGS = "MainDicomTags"; |
363 static const char* const PATIENT_MAIN_DICOM_TAGS = "PatientMainDicomTags"; | |
364 | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
365 // TODO-FIND : Ignore "null" values |
5608 | 366 |
367 DicomMap levelMainDicomTags; | |
368 allMainDicomTags.ExtractResourceInformation(levelMainDicomTags, resource.GetLevel()); | |
369 | |
370 target[MAIN_DICOM_TAGS] = Json::objectValue; | |
371 FromDcmtkBridge::ToJson(target[MAIN_DICOM_TAGS], levelMainDicomTags, format_); | |
372 | |
373 if (resource.GetLevel() == ResourceType_Study) | |
374 { | |
375 DicomMap patientMainDicomTags; | |
376 allMainDicomTags.ExtractPatientInformation(patientMainDicomTags); | |
377 | |
378 target[PATIENT_MAIN_DICOM_TAGS] = Json::objectValue; | |
379 FromDcmtkBridge::ToJson(target[PATIENT_MAIN_DICOM_TAGS], patientMainDicomTags, format_); | |
380 } | |
381 } | |
382 | |
383 { | |
384 Json::Value labels = Json::arrayValue; | |
385 | |
386 for (std::set<std::string>::const_iterator | |
387 it = resource.GetLabels().begin(); it != resource.GetLabels().end(); ++it) | |
388 { | |
389 labels.append(*it); | |
390 } | |
391 | |
392 target["Labels"] = labels; | |
393 } | |
394 | |
395 if (includeAllMetadata_) // new in Orthanc 1.12.4 | |
396 { | |
397 const std::map<MetadataType, std::string>& m = resource.GetMetadata(resource.GetLevel()); | |
398 | |
399 Json::Value metadata = Json::objectValue; | |
400 | |
401 for (std::map<MetadataType, std::string>::const_iterator it = m.begin(); it != m.end(); ++it) | |
402 { | |
403 metadata[EnumerationToString(it->first)] = it->second; | |
404 } | |
405 | |
406 target["Metadata"] = metadata; | |
407 } | |
408 } | |
409 | |
410 | |
411 ResourceFinder::ResourceFinder(ResourceType level, | |
412 bool expand) : | |
413 request_(level), | |
414 expand_(expand), | |
415 format_(DicomToJsonFormat_Human), | |
5617
8905ffa45fc2
started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5616
diff
changeset
|
416 allowStorageAccess_(true), |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
417 hasRequestedTags_(false), |
5608 | 418 includeAllMetadata_(false) |
419 { | |
420 if (expand) | |
421 { | |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5617
diff
changeset
|
422 request_.SetRetrieveMainDicomTags(true); |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5617
diff
changeset
|
423 request_.SetRetrieveMetadata(true); |
5608 | 424 request_.SetRetrieveLabels(true); |
425 | |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
426 switch (level) |
5608 | 427 { |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
428 case ResourceType_Patient: |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
429 request_.GetChildrenSpecification(ResourceType_Study).SetRetrieveIdentifiers(true); |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
430 break; |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
431 |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
432 case ResourceType_Study: |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
433 request_.GetChildrenSpecification(ResourceType_Series).SetRetrieveIdentifiers(true); |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
434 request_.SetRetrieveParentIdentifier(true); |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
435 break; |
5608 | 436 |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
437 case ResourceType_Series: |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
438 request_.GetChildrenSpecification(ResourceType_Instance).AddMetadata(MetadataType_Instance_IndexInSeries); // required for the SeriesStatus |
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
439 request_.GetChildrenSpecification(ResourceType_Instance).SetRetrieveIdentifiers(true); |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
440 request_.SetRetrieveParentIdentifier(true); |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
441 break; |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
442 |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
443 case ResourceType_Instance: |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
444 request_.SetRetrieveAttachments(true); // for FileSize & FileUuid |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
445 request_.SetRetrieveParentIdentifier(true); |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
446 break; |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
447 |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
448 default: |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
449 throw OrthancException(ErrorCode_ParameterOutOfRange); |
5608 | 450 } |
451 } | |
452 } | |
453 | |
454 | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
455 void ResourceFinder::AddRequestedTags(const DicomTag& tag) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
456 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
457 if (DicomMap::IsMainDicomTag(tag, ResourceType_Patient)) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
458 { |
5620
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
459 if (request_.GetLevel() == ResourceType_Patient) |
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
460 { |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
461 request_.GetParentSpecification(ResourceType_Patient).SetRetrieveMainDicomTags(true); |
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
462 request_.GetParentSpecification(ResourceType_Patient).SetRetrieveMetadata(true); |
5620
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
463 requestedPatientTags_.insert(tag); |
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
464 } |
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
465 else |
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
466 { |
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
467 /** |
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
468 * This comes from the fact that patient-level tags are copied |
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
469 * at the study level, as implemented by "ResourcesContent::AddResource()". |
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
470 **/ |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
471 request_.GetParentSpecification(ResourceType_Study).SetRetrieveMainDicomTags(true); |
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
472 request_.GetParentSpecification(ResourceType_Study).SetRetrieveMetadata(true); |
5620
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
473 requestedStudyTags_.insert(tag); |
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
474 } |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
475 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
476 hasRequestedTags_ = true; |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
477 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
478 else if (DicomMap::IsMainDicomTag(tag, ResourceType_Study)) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
479 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
480 if (request_.GetLevel() == ResourceType_Patient) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
481 { |
5612
599ce5ed126c
added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
482 LOG(WARNING) << "Requested tag " << tag.Format() |
599ce5ed126c
added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
483 << " should only be read at the study, series, or instance level"; |
599ce5ed126c
added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
484 requestedTagsFromFileStorage_.insert(tag); |
599ce5ed126c
added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
485 request_.SetRetrieveOneInstanceIdentifier(true); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
486 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
487 else |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
488 { |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
489 request_.GetParentSpecification(ResourceType_Study).SetRetrieveMainDicomTags(true); |
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
490 request_.GetParentSpecification(ResourceType_Study).SetRetrieveMetadata(true); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
491 requestedStudyTags_.insert(tag); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
492 } |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
493 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
494 hasRequestedTags_ = true; |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
495 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
496 else if (DicomMap::IsMainDicomTag(tag, ResourceType_Series)) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
497 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
498 if (request_.GetLevel() == ResourceType_Patient || |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
499 request_.GetLevel() == ResourceType_Study) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
500 { |
5612
599ce5ed126c
added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
501 LOG(WARNING) << "Requested tag " << tag.Format() |
599ce5ed126c
added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
502 << " should only be read at the series or instance level"; |
599ce5ed126c
added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
503 requestedTagsFromFileStorage_.insert(tag); |
599ce5ed126c
added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
504 request_.SetRetrieveOneInstanceIdentifier(true); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
505 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
506 else |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
507 { |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
508 request_.GetParentSpecification(ResourceType_Series).SetRetrieveMainDicomTags(true); |
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
509 request_.GetParentSpecification(ResourceType_Series).SetRetrieveMetadata(true); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
510 requestedSeriesTags_.insert(tag); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
511 } |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
512 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
513 hasRequestedTags_ = true; |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
514 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
515 else if (DicomMap::IsMainDicomTag(tag, ResourceType_Instance)) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
516 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
517 if (request_.GetLevel() == ResourceType_Patient || |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
518 request_.GetLevel() == ResourceType_Study || |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
519 request_.GetLevel() == ResourceType_Series) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
520 { |
5612
599ce5ed126c
added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
521 LOG(WARNING) << "Requested tag " << tag.Format() |
599ce5ed126c
added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
522 << " should only be read at the instance level"; |
599ce5ed126c
added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
523 requestedTagsFromFileStorage_.insert(tag); |
599ce5ed126c
added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
524 request_.SetRetrieveOneInstanceIdentifier(true); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
525 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
526 else |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
527 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
528 // Main DICOM tags from the instance level will be retrieved anyway |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5617
diff
changeset
|
529 assert(request_.IsRetrieveMainDicomTags()); |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5617
diff
changeset
|
530 assert(request_.IsRetrieveMetadata()); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
531 requestedInstanceTags_.insert(tag); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
532 } |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
533 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
534 hasRequestedTags_ = true; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
535 } |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
536 else if (tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
537 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
538 ConfigureChildrenCountComputedTag(tag, ResourceType_Patient, ResourceType_Study); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
539 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
540 else if (tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
541 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
542 ConfigureChildrenCountComputedTag(tag, ResourceType_Patient, ResourceType_Series); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
543 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
544 else if (tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
545 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
546 ConfigureChildrenCountComputedTag(tag, ResourceType_Patient, ResourceType_Instance); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
547 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
548 else if (tag == DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
549 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
550 ConfigureChildrenCountComputedTag(tag, ResourceType_Study, ResourceType_Series); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
551 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
552 else if (tag == DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
553 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
554 ConfigureChildrenCountComputedTag(tag, ResourceType_Study, ResourceType_Instance); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
555 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
556 else if (tag == DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
557 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
558 ConfigureChildrenCountComputedTag(tag, ResourceType_Series, ResourceType_Instance); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
559 } |
5668
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
560 else if (tag == DICOM_TAG_SOP_CLASSES_IN_STUDY) |
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
561 { |
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
562 requestedComputedTags_.insert(tag); |
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
563 hasRequestedTags_ = true; |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
564 request_.GetChildrenSpecification(ResourceType_Instance).AddMetadata(MetadataType_Instance_SopClassUid); |
5668
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
565 } |
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
566 else if (tag == DICOM_TAG_MODALITIES_IN_STUDY) |
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
567 { |
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
568 requestedComputedTags_.insert(tag); |
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
569 hasRequestedTags_ = true; |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
570 request_.GetChildrenSpecification(ResourceType_Series).AddMainDicomTag(DICOM_TAG_MODALITY); |
5668
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
571 } |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
572 else if (tag == DICOM_TAG_INSTANCE_AVAILABILITY) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
573 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
574 requestedComputedTags_.insert(tag); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
575 hasRequestedTags_ = true; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
576 } |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
577 else |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
578 { |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
579 // This is neither a main DICOM tag, nor a computed DICOM tag: |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
580 // We will be forced to access the DICOM file anyway |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
581 requestedTagsFromFileStorage_.insert(tag); |
5610
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
582 |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
583 if (request_.GetLevel() != ResourceType_Instance) |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
584 { |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
585 request_.SetRetrieveOneInstanceIdentifier(true); |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
586 } |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
587 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
588 hasRequestedTags_ = true; |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
589 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
590 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
591 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
592 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
593 void ResourceFinder::AddRequestedTags(const std::set<DicomTag>& tags) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
594 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
595 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
596 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
597 AddRequestedTags(*it); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
598 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
599 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
600 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
601 |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
602 static void InjectRequestedTags(DicomMap& requestedTags, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
603 std::set<DicomTag>& missingTags /* out */, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
604 const FindResponse::Resource& resource, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
605 ResourceType level, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
606 const std::set<DicomTag>& tags) |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
607 { |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
608 if (!tags.empty()) |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
609 { |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
610 DicomMap m; |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
611 resource.GetMainDicomTags(m, level); |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
612 |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
613 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
614 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
615 std::string value; |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
616 if (m.LookupStringValue(value, *it, false /* not binary */)) |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
617 { |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
618 requestedTags.SetValue(*it, value, false /* not binary */); |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
619 } |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
620 else |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
621 { |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
622 // This is the case where the Housekeeper should be run |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
623 missingTags.insert(*it); |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
624 } |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
625 } |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
626 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
627 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
628 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
629 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
630 static void ReadMissingTagsFromStorageArea(DicomMap& requestedTags, |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
631 ServerContext& context, |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
632 const FindRequest& request, |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
633 const FindResponse::Resource& resource, |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
634 const std::set<DicomTag>& missingTags) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
635 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
636 OrthancConfiguration::ReaderLock lock; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
637 if (lock.GetConfiguration().IsWarningEnabled(Warnings_001_TagsBeingReadFromStorage)) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
638 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
639 std::string missings; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
640 FromDcmtkBridge::FormatListOfTags(missings, missingTags); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
641 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
642 LOG(WARNING) << "W001: Accessing Dicom tags from storage when accessing " |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
643 << Orthanc::GetResourceTypeText(resource.GetLevel(), false, false) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
644 << ": " << missings; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
645 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
646 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
647 std::string instancePublicId; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
648 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
649 if (request.IsRetrieveOneInstanceIdentifier()) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
650 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
651 instancePublicId = resource.GetOneInstanceIdentifier(); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
652 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
653 else if (request.GetLevel() == ResourceType_Instance) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
654 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
655 instancePublicId = resource.GetIdentifier(); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
656 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
657 else |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
658 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
659 FindRequest requestDicomAttachment(request.GetLevel()); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
660 requestDicomAttachment.SetOrthancId(request.GetLevel(), resource.GetIdentifier()); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
661 requestDicomAttachment.SetRetrieveOneInstanceIdentifier(true); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
662 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
663 FindResponse responseDicomAttachment; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
664 context.GetIndex().ExecuteFind(responseDicomAttachment, requestDicomAttachment); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
665 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
666 if (responseDicomAttachment.GetSize() != 1 || |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
667 !responseDicomAttachment.GetResourceByIndex(0).HasOneInstanceIdentifier()) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
668 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
669 throw OrthancException(ErrorCode_InexistentFile); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
670 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
671 else |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
672 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
673 instancePublicId = responseDicomAttachment.GetResourceByIndex(0).GetOneInstanceIdentifier(); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
674 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
675 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
676 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
677 LOG(INFO) << "Will retrieve missing DICOM tags from instance: " << instancePublicId; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
678 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
679 // TODO-FIND: What do we do if the DICOM has been removed since the request? |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
680 // Do we fail, or do we skip the resource? |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
681 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
682 Json::Value tmpDicomAsJson; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
683 context.ReadDicomAsJson(tmpDicomAsJson, instancePublicId, missingTags /* ignoreTagLength */); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
684 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
685 DicomMap tmpDicomMap; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
686 tmpDicomMap.FromDicomAsJson(tmpDicomAsJson, false /* append */, true /* parseSequences*/); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
687 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
688 for (std::set<DicomTag>::const_iterator it = missingTags.begin(); it != missingTags.end(); ++it) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
689 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
690 assert(!requestedTags.HasTag(*it)); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
691 if (tmpDicomMap.HasTag(*it)) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
692 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
693 requestedTags.SetValue(*it, tmpDicomMap.GetValue(*it)); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
694 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
695 else |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
696 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
697 requestedTags.SetNullValue(*it); // TODO-FIND: Is this compatible with Orthanc <= 1.12.3? |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
698 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
699 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
700 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
701 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
702 |
5608 | 703 void ResourceFinder::Execute(Json::Value& target, |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
704 ServerContext& context) const |
5608 | 705 { |
706 FindResponse response; | |
707 context.GetIndex().ExecuteFind(response, request_); | |
708 | |
709 target = Json::arrayValue; | |
710 | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
711 for (size_t i = 0; i < response.GetSize(); i++) |
5608 | 712 { |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
713 const FindResponse::Resource& resource = response.GetResourceByIndex(i); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
714 |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
715 { |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
716 Json::Value v; |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
717 resource.DebugExport(v, request_); |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
718 std::cout << v.toStyledString(); |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
719 } |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
720 |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
721 if (expand_) |
5608 | 722 { |
723 Json::Value item; | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
724 Expand(item, resource, context.GetIndex()); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
725 |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
726 if (hasRequestedTags_) |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
727 { |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
728 DicomMap requestedTags; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
729 InjectComputedTags(requestedTags, resource); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
730 |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
731 std::set<DicomTag> missingTags = requestedTagsFromFileStorage_; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
732 InjectRequestedTags(requestedTags, missingTags, resource, ResourceType_Patient, requestedPatientTags_); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
733 InjectRequestedTags(requestedTags, missingTags, resource, ResourceType_Study, requestedStudyTags_); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
734 InjectRequestedTags(requestedTags, missingTags, resource, ResourceType_Series, requestedSeriesTags_); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
735 InjectRequestedTags(requestedTags, missingTags, resource, ResourceType_Instance, requestedInstanceTags_); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
736 |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
737 if (!missingTags.empty()) |
5610
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
738 { |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
739 if (!allowStorageAccess_) |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
740 { |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
741 throw OrthancException(ErrorCode_BadSequenceOfCalls, |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
742 "Cannot add missing requested tags, as access to file storage is disallowed"); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
743 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
744 else |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
745 { |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
746 ReadMissingTagsFromStorageArea(requestedTags, context, request_, resource, missingTags); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
747 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
748 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
749 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
750 static const char* const REQUESTED_TAGS = "RequestedTags"; |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
751 item[REQUESTED_TAGS] = Json::objectValue; |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
752 FromDcmtkBridge::ToJson(item[REQUESTED_TAGS], requestedTags, format_); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
753 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
754 |
5608 | 755 target.append(item); |
756 } | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
757 else |
5608 | 758 { |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
759 target.append(resource.GetIdentifier()); |
5608 | 760 } |
761 } | |
762 } | |
5615
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
763 |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
764 |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
765 bool ResourceFinder::ExecuteOneResource(Json::Value& target, |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
766 ServerContext& context) const |
5615
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
767 { |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
768 Json::Value answer; |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
769 Execute(answer, context); |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
770 |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
771 if (answer.type() != Json::arrayValue) |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
772 { |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
773 throw OrthancException(ErrorCode_InternalError); |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
774 } |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
775 else if (answer.size() > 1) |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
776 { |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
777 throw OrthancException(ErrorCode_DatabasePlugin); |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
778 } |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
779 else if (answer.empty()) |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
780 { |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
781 // Inexistent resource (or was deleted between the first and second phases) |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
782 return false; |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
783 } |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
784 else |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
785 { |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
786 target = answer[0]; |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
787 return true; |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
788 } |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
789 } |
5608 | 790 } |