Mercurial > hg > orthanc
annotate OrthancServer/Sources/ResourceFinder.cpp @ 5692:7c11a71927a9 find-refactoring
improved handling of limits
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 11 Jul 2024 20:20:50 +0200 |
parents | 708952bd869c |
children | 023787ecaff2 |
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" |
5682
fd4c5e064cbe
started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
32 #include "Search/DatabaseLookup.h" |
5608 | 33 #include "ServerContext.h" |
34 #include "ServerIndex.h" | |
35 | |
36 | |
37 namespace Orthanc | |
38 { | |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
39 static bool IsComputedTag(const DicomTag& tag) |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
40 { |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
41 return (tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES || |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
42 tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES || |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
43 tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES || |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
44 tag == DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES || |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
45 tag == DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES || |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
46 tag == DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES || |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
47 tag == DICOM_TAG_SOP_CLASSES_IN_STUDY || |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
48 tag == DICOM_TAG_MODALITIES_IN_STUDY || |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
49 tag == DICOM_TAG_INSTANCE_AVAILABILITY); |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
50 } |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
51 |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
52 void ResourceFinder::ConfigureChildrenCountComputedTag(DicomTag tag, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
53 ResourceType parentLevel, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
54 ResourceType childLevel) |
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 (request_.GetLevel() == parentLevel) |
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 requestedComputedTags_.insert(tag); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
59 hasRequestedTags_ = true; |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
60 request_.GetChildrenSpecification(childLevel).SetRetrieveIdentifiers(true); |
5666
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 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
65 void ResourceFinder::InjectChildrenCountComputedTag(DicomMap& requestedTags, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
66 DicomTag tag, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
67 const FindResponse::Resource& resource, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
68 ResourceType level) const |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
69 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
70 if (IsRequestedComputedTag(tag)) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
71 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
72 const std::set<std::string>& children = resource.GetChildrenIdentifiers(level); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
73 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
|
74 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
75 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
76 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
77 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
78 void ResourceFinder::InjectComputedTags(DicomMap& requestedTags, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
79 const FindResponse::Resource& resource) const |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
80 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
81 switch (resource.GetLevel()) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
82 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
83 case ResourceType_Patient: |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
84 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
|
85 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
|
86 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
|
87 break; |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
88 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
89 case ResourceType_Study: |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
90 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
|
91 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
|
92 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
93 if (IsRequestedComputedTag(DICOM_TAG_MODALITIES_IN_STUDY)) |
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::set<std::string> modalities; |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
96 resource.GetChildrenMainDicomTagValues(modalities, ResourceType_Series, DICOM_TAG_MODALITY); |
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 std::string s; |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
99 Toolbox::JoinStrings(s, modalities, "\\"); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
100 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
101 requestedTags.SetValue(DICOM_TAG_MODALITIES_IN_STUDY, s, false); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
102 } |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
103 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
104 if (IsRequestedComputedTag(DICOM_TAG_SOP_CLASSES_IN_STUDY)) |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
105 { |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
106 std::set<std::string> classes; |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
107 resource.GetChildrenMetadataValues(classes, ResourceType_Instance, MetadataType_Instance_SopClassUid); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
108 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
109 std::string s; |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
110 Toolbox::JoinStrings(s, classes, "\\"); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
111 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
112 requestedTags.SetValue(DICOM_TAG_SOP_CLASSES_IN_STUDY, s, false); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
113 } |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
114 |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
115 break; |
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 case ResourceType_Series: |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
118 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
|
119 break; |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
120 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
121 case ResourceType_Instance: |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
122 if (IsRequestedComputedTag(DICOM_TAG_INSTANCE_AVAILABILITY)) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
123 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
124 requestedTags.SetValue(DICOM_TAG_INSTANCE_AVAILABILITY, "ONLINE", false); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
125 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
126 break; |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
127 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
128 default: |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
129 throw OrthancException(ErrorCode_InternalError); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
130 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
131 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
132 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
133 |
5608 | 134 SeriesStatus ResourceFinder::GetSeriesStatus(uint32_t& expectedNumberOfInstances, |
5689 | 135 const FindResponse::Resource& resource) |
5608 | 136 { |
5689 | 137 if (resource.GetLevel() != ResourceType_Series) |
5608 | 138 { |
139 throw OrthancException(ErrorCode_BadParameterType); | |
140 } | |
141 | |
142 std::string s; | |
143 if (!resource.LookupMetadata(s, ResourceType_Series, MetadataType_Series_ExpectedNumberOfInstances) || | |
144 !SerializationToolbox::ParseUnsignedInteger32(expectedNumberOfInstances, s)) | |
145 { | |
146 return SeriesStatus_Unknown; | |
147 } | |
148 | |
5674 | 149 std::set<std::string> values; |
150 resource.GetChildrenMetadataValues(values, ResourceType_Instance, MetadataType_Instance_IndexInSeries); | |
5608 | 151 |
152 std::set<int64_t> instances; | |
153 | |
5674 | 154 for (std::set<std::string>::const_iterator |
5608 | 155 it = values.begin(); it != values.end(); ++it) |
156 { | |
157 int64_t index; | |
158 | |
159 if (!SerializationToolbox::ParseInteger64(index, *it)) | |
160 { | |
161 return SeriesStatus_Unknown; | |
162 } | |
163 | |
164 if (index <= 0 || | |
165 index > static_cast<int64_t>(expectedNumberOfInstances)) | |
166 { | |
167 // Out-of-range instance index | |
168 return SeriesStatus_Inconsistent; | |
169 } | |
170 | |
171 if (instances.find(index) != instances.end()) | |
172 { | |
173 // Twice the same instance index | |
174 return SeriesStatus_Inconsistent; | |
175 } | |
176 | |
177 instances.insert(index); | |
178 } | |
179 | |
180 if (instances.size() == static_cast<size_t>(expectedNumberOfInstances)) | |
181 { | |
182 return SeriesStatus_Complete; | |
183 } | |
184 else | |
185 { | |
186 return SeriesStatus_Missing; | |
187 } | |
188 } | |
189 | |
190 | |
191 void ResourceFinder::Expand(Json::Value& target, | |
192 const FindResponse::Resource& resource, | |
193 ServerIndex& index) const | |
194 { | |
195 /** | |
196 * This method closely follows "SerializeExpandedResource()" in | |
5689 | 197 * "ServerContext.cpp" from Orthanc 1.12.4. |
5608 | 198 **/ |
199 | |
200 if (resource.GetLevel() != request_.GetLevel()) | |
201 { | |
202 throw OrthancException(ErrorCode_InternalError); | |
203 } | |
204 | |
205 target = Json::objectValue; | |
206 | |
207 target["Type"] = GetResourceTypeText(resource.GetLevel(), false, true); | |
208 target["ID"] = resource.GetIdentifier(); | |
209 | |
210 switch (resource.GetLevel()) | |
211 { | |
212 case ResourceType_Patient: | |
213 break; | |
214 | |
215 case ResourceType_Study: | |
216 target["ParentPatient"] = resource.GetParentIdentifier(); | |
217 break; | |
218 | |
219 case ResourceType_Series: | |
220 target["ParentStudy"] = resource.GetParentIdentifier(); | |
221 break; | |
222 | |
223 case ResourceType_Instance: | |
224 target["ParentSeries"] = resource.GetParentIdentifier(); | |
225 break; | |
226 | |
227 default: | |
228 throw OrthancException(ErrorCode_InternalError); | |
229 } | |
230 | |
231 if (resource.GetLevel() != ResourceType_Instance) | |
232 { | |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
233 const std::set<std::string>& children = resource.GetChildrenIdentifiers(GetChildResourceType(resource.GetLevel())); |
5608 | 234 |
235 Json::Value c = Json::arrayValue; | |
236 for (std::set<std::string>::const_iterator | |
237 it = children.begin(); it != children.end(); ++it) | |
238 { | |
239 c.append(*it); | |
240 } | |
241 | |
242 switch (resource.GetLevel()) | |
243 { | |
244 case ResourceType_Patient: | |
245 target["Studies"] = c; | |
246 break; | |
247 | |
248 case ResourceType_Study: | |
249 target["Series"] = c; | |
250 break; | |
251 | |
252 case ResourceType_Series: | |
253 target["Instances"] = c; | |
254 break; | |
255 | |
256 default: | |
257 throw OrthancException(ErrorCode_InternalError); | |
258 } | |
259 } | |
260 | |
261 switch (resource.GetLevel()) | |
262 { | |
263 case ResourceType_Patient: | |
264 case ResourceType_Study: | |
265 break; | |
266 | |
267 case ResourceType_Series: | |
268 { | |
269 uint32_t expectedNumberOfInstances; | |
270 SeriesStatus status = GetSeriesStatus(expectedNumberOfInstances, resource); | |
271 | |
272 target["Status"] = EnumerationToString(status); | |
273 | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
274 static const char* const EXPECTED_NUMBER_OF_INSTANCES = "ExpectedNumberOfInstances"; |
5608 | 275 |
276 if (status == SeriesStatus_Unknown) | |
277 { | |
278 target[EXPECTED_NUMBER_OF_INSTANCES] = Json::nullValue; | |
279 } | |
280 else | |
281 { | |
282 target[EXPECTED_NUMBER_OF_INSTANCES] = expectedNumberOfInstances; | |
283 } | |
284 | |
285 break; | |
286 } | |
287 | |
288 case ResourceType_Instance: | |
289 { | |
290 FileInfo info; | |
291 if (resource.LookupAttachment(info, FileContentType_Dicom)) | |
292 { | |
293 target["FileSize"] = static_cast<Json::UInt64>(info.GetUncompressedSize()); | |
294 target["FileUuid"] = info.GetUuid(); | |
295 } | |
296 else | |
297 { | |
298 throw OrthancException(ErrorCode_InternalError); | |
299 } | |
300 | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
301 static const char* const INDEX_IN_SERIES = "IndexInSeries"; |
5608 | 302 |
303 std::string s; | |
304 uint32_t index; | |
305 if (resource.LookupMetadata(s, ResourceType_Instance, MetadataType_Instance_IndexInSeries) && | |
306 SerializationToolbox::ParseUnsignedInteger32(index, s)) | |
307 { | |
308 target[INDEX_IN_SERIES] = index; | |
309 } | |
310 else | |
311 { | |
312 target[INDEX_IN_SERIES] = Json::nullValue; | |
313 } | |
314 | |
315 break; | |
316 } | |
317 | |
318 default: | |
319 throw OrthancException(ErrorCode_InternalError); | |
320 } | |
321 | |
322 std::string s; | |
323 if (resource.LookupMetadata(s, resource.GetLevel(), MetadataType_AnonymizedFrom)) | |
324 { | |
325 target["AnonymizedFrom"] = s; | |
326 } | |
327 | |
328 if (resource.LookupMetadata(s, resource.GetLevel(), MetadataType_ModifiedFrom)) | |
329 { | |
330 target["ModifiedFrom"] = s; | |
331 } | |
332 | |
333 if (resource.GetLevel() == ResourceType_Patient || | |
334 resource.GetLevel() == ResourceType_Study || | |
335 resource.GetLevel() == ResourceType_Series) | |
336 { | |
337 target["IsStable"] = !index.IsUnstableResource(resource.GetLevel(), resource.GetInternalId()); | |
338 | |
339 if (resource.LookupMetadata(s, resource.GetLevel(), MetadataType_LastUpdate)) | |
340 { | |
341 target["LastUpdate"] = s; | |
342 } | |
343 } | |
344 | |
345 { | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
346 DicomMap allMainDicomTags; |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
347 resource.GetMainDicomTags(allMainDicomTags, resource.GetLevel()); |
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 /** |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
350 * This section was part of "StatelessDatabaseOperations::ExpandResource()" |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
351 * in Orthanc <= 1.12.3 |
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 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
354 // read all main sequences from DB |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
355 std::string serializedSequences; |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
356 if (resource.LookupMetadata(serializedSequences, resource.GetLevel(), MetadataType_MainDicomSequences)) |
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 Json::Value jsonMetadata; |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
359 Toolbox::ReadJson(jsonMetadata, serializedSequences); |
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 if (jsonMetadata["Version"].asInt() == 1) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
362 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
363 allMainDicomTags.FromDicomAsJson(jsonMetadata["Sequences"], true /* append */, true /* parseSequences */); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
364 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
365 else |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
366 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
367 throw OrthancException(ErrorCode_NotImplemented); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
368 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
369 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
370 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
371 /** |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
372 * End of section from StatelessDatabaseOperations |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
373 **/ |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
374 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
375 |
5608 | 376 static const char* const MAIN_DICOM_TAGS = "MainDicomTags"; |
377 static const char* const PATIENT_MAIN_DICOM_TAGS = "PatientMainDicomTags"; | |
378 | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
379 // TODO-FIND : Ignore "null" values |
5608 | 380 |
381 DicomMap levelMainDicomTags; | |
382 allMainDicomTags.ExtractResourceInformation(levelMainDicomTags, resource.GetLevel()); | |
383 | |
384 target[MAIN_DICOM_TAGS] = Json::objectValue; | |
385 FromDcmtkBridge::ToJson(target[MAIN_DICOM_TAGS], levelMainDicomTags, format_); | |
386 | |
387 if (resource.GetLevel() == ResourceType_Study) | |
388 { | |
389 DicomMap patientMainDicomTags; | |
390 allMainDicomTags.ExtractPatientInformation(patientMainDicomTags); | |
391 | |
392 target[PATIENT_MAIN_DICOM_TAGS] = Json::objectValue; | |
393 FromDcmtkBridge::ToJson(target[PATIENT_MAIN_DICOM_TAGS], patientMainDicomTags, format_); | |
394 } | |
395 } | |
396 | |
397 { | |
398 Json::Value labels = Json::arrayValue; | |
399 | |
400 for (std::set<std::string>::const_iterator | |
401 it = resource.GetLabels().begin(); it != resource.GetLabels().end(); ++it) | |
402 { | |
403 labels.append(*it); | |
404 } | |
405 | |
406 target["Labels"] = labels; | |
407 } | |
408 | |
409 if (includeAllMetadata_) // new in Orthanc 1.12.4 | |
410 { | |
411 const std::map<MetadataType, std::string>& m = resource.GetMetadata(resource.GetLevel()); | |
412 | |
413 Json::Value metadata = Json::objectValue; | |
414 | |
415 for (std::map<MetadataType, std::string>::const_iterator it = m.begin(); it != m.end(); ++it) | |
416 { | |
417 metadata[EnumerationToString(it->first)] = it->second; | |
418 } | |
419 | |
420 target["Metadata"] = metadata; | |
421 } | |
422 } | |
423 | |
424 | |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
425 void ResourceFinder::UpdateRequestLimits() |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
426 { |
5690
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
427 // By default, use manual paging |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
428 isDatabasePaging_ = false; |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
429 |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
430 if (databaseLimits_ != 0) |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
431 { |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
432 request_.SetLimits(0, databaseLimits_ + 1); |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
433 } |
5692
7c11a71927a9
improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5690
diff
changeset
|
434 else |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
435 { |
5692
7c11a71927a9
improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5690
diff
changeset
|
436 request_.ClearLimits(); |
7c11a71927a9
improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5690
diff
changeset
|
437 } |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
438 |
5692
7c11a71927a9
improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5690
diff
changeset
|
439 if (hasLimits_) |
7c11a71927a9
improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5690
diff
changeset
|
440 { |
7c11a71927a9
improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5690
diff
changeset
|
441 if (lookup_.get() == NULL) |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
442 { |
5690
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
443 isDatabasePaging_ = true; |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
444 request_.SetLimits(limitsSince_, limitsCount_); |
5692
7c11a71927a9
improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5690
diff
changeset
|
445 } |
7c11a71927a9
improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5690
diff
changeset
|
446 |
7c11a71927a9
improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5690
diff
changeset
|
447 // TODO-FIND: enable database paging on "simple" lookups that involve no normalization |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
448 } |
5690
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
449 |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
450 // TODO-FIND: More cases could be added, depending on "GetDatabaseCapabilities()" |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
451 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
452 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
453 |
5608 | 454 ResourceFinder::ResourceFinder(ResourceType level, |
455 bool expand) : | |
456 request_(level), | |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
457 databaseLimits_(0), |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
458 isDatabasePaging_(true), |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
459 hasLimits_(false), |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
460 limitsSince_(0), |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
461 limitsCount_(0), |
5608 | 462 expand_(expand), |
463 format_(DicomToJsonFormat_Human), | |
5617
8905ffa45fc2
started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5616
diff
changeset
|
464 allowStorageAccess_(true), |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
465 hasRequestedTags_(false), |
5608 | 466 includeAllMetadata_(false) |
467 { | |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
468 UpdateRequestLimits(); |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
469 |
5608 | 470 if (expand) |
471 { | |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5617
diff
changeset
|
472 request_.SetRetrieveMainDicomTags(true); |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5617
diff
changeset
|
473 request_.SetRetrieveMetadata(true); |
5608 | 474 request_.SetRetrieveLabels(true); |
475 | |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
476 switch (level) |
5608 | 477 { |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
478 case ResourceType_Patient: |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
479 request_.GetChildrenSpecification(ResourceType_Study).SetRetrieveIdentifiers(true); |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
480 break; |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
481 |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
482 case ResourceType_Study: |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
483 request_.GetChildrenSpecification(ResourceType_Series).SetRetrieveIdentifiers(true); |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
484 request_.SetRetrieveParentIdentifier(true); |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
485 break; |
5608 | 486 |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
487 case ResourceType_Series: |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
488 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
|
489 request_.GetChildrenSpecification(ResourceType_Instance).SetRetrieveIdentifiers(true); |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
490 request_.SetRetrieveParentIdentifier(true); |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
491 break; |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
492 |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
493 case ResourceType_Instance: |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
494 request_.SetRetrieveAttachments(true); // for FileSize & FileUuid |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
495 request_.SetRetrieveParentIdentifier(true); |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
496 break; |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
497 |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
498 default: |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
499 throw OrthancException(ErrorCode_ParameterOutOfRange); |
5608 | 500 } |
501 } | |
502 } | |
503 | |
504 | |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
505 void ResourceFinder::SetDatabaseLimits(uint64_t limits) |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
506 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
507 databaseLimits_ = limits; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
508 UpdateRequestLimits(); |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
509 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
510 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
511 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
512 void ResourceFinder::SetLimits(uint64_t since, |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
513 uint64_t count) |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
514 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
515 if (hasLimits_) |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
516 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
517 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
518 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
519 else |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
520 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
521 hasLimits_ = true; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
522 limitsSince_ = since; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
523 limitsCount_ = count; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
524 UpdateRequestLimits(); |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
525 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
526 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
527 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
528 |
5682
fd4c5e064cbe
started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
529 void ResourceFinder::SetDatabaseLookup(const DatabaseLookup& lookup) |
fd4c5e064cbe
started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
530 { |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
531 lookup_.reset(lookup.Clone()); |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
532 |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
533 for (size_t i = 0; i < lookup.GetConstraintsCount(); i++) |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
534 { |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
535 DicomTag tag = lookup.GetConstraint(i).GetTag(); |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
536 if (IsComputedTag(tag)) |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
537 { |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
538 AddRequestedTag(tag); |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
539 } |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
540 } |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
541 |
5682
fd4c5e064cbe
started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
542 MainDicomTagsRegistry registry; |
fd4c5e064cbe
started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
543 registry.NormalizeLookup(request_.GetDicomTagConstraints(), lookup, request_.GetLevel()); |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
544 |
5690
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
545 // "request_.GetDicomTagConstraints()" only contains constraints on main DICOM tags |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
546 |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
547 for (size_t i = 0; i < request_.GetDicomTagConstraints().GetSize(); i++) |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
548 { |
5690
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
549 const DatabaseConstraint& constraint = request_.GetDicomTagConstraints().GetConstraint(i); |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
550 if (constraint.GetLevel() == request_.GetLevel()) |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
551 { |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
552 request_.SetRetrieveMainDicomTags(true); |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
553 } |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
554 else if (IsResourceLevelAboveOrEqual(constraint.GetLevel(), request_.GetLevel())) |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
555 { |
5690
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
556 request_.GetParentSpecification(constraint.GetLevel()).SetRetrieveMainDicomTags(true); |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
557 } |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
558 else |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
559 { |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
560 LOG(WARNING) << "Executing a database lookup at level " << EnumerationToString(request_.GetLevel()) |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
561 << " on main DICOM tag " << constraint.GetTag().Format() << " from an inferior level (" |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
562 << EnumerationToString(constraint.GetLevel()) << "), this will return no result"; |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
563 } |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
564 |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
565 if (IsComputedTag(constraint.GetTag())) |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
566 { |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
567 // Sanity check |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
568 throw OrthancException(ErrorCode_InternalError); |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
569 } |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
570 } |
5692
7c11a71927a9
improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5690
diff
changeset
|
571 |
7c11a71927a9
improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5690
diff
changeset
|
572 UpdateRequestLimits(); |
5682
fd4c5e064cbe
started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
573 } |
fd4c5e064cbe
started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
574 |
fd4c5e064cbe
started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
575 |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
576 void ResourceFinder::AddRequestedTag(const DicomTag& tag) |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
577 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
578 if (DicomMap::IsMainDicomTag(tag, ResourceType_Patient)) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
579 { |
5620
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
580 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
|
581 { |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
582 request_.GetParentSpecification(ResourceType_Patient).SetRetrieveMainDicomTags(true); |
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
583 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
|
584 requestedPatientTags_.insert(tag); |
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
585 } |
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
586 else |
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
587 { |
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
588 /** |
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
589 * 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
|
590 * 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
|
591 **/ |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
592 request_.GetParentSpecification(ResourceType_Study).SetRetrieveMainDicomTags(true); |
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
593 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
|
594 requestedStudyTags_.insert(tag); |
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
595 } |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
596 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
597 hasRequestedTags_ = true; |
5609
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 else if (DicomMap::IsMainDicomTag(tag, ResourceType_Study)) |
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 if (request_.GetLevel() == ResourceType_Patient) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
602 { |
5612
599ce5ed126c
added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
603 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
|
604 << " 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
|
605 requestedTagsFromFileStorage_.insert(tag); |
599ce5ed126c
added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
606 request_.SetRetrieveOneInstanceIdentifier(true); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
607 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
608 else |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
609 { |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
610 request_.GetParentSpecification(ResourceType_Study).SetRetrieveMainDicomTags(true); |
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
611 request_.GetParentSpecification(ResourceType_Study).SetRetrieveMetadata(true); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
612 requestedStudyTags_.insert(tag); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
613 } |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
614 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
615 hasRequestedTags_ = true; |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
616 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
617 else if (DicomMap::IsMainDicomTag(tag, ResourceType_Series)) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
618 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
619 if (request_.GetLevel() == ResourceType_Patient || |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
620 request_.GetLevel() == ResourceType_Study) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
621 { |
5612
599ce5ed126c
added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
622 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
|
623 << " 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
|
624 requestedTagsFromFileStorage_.insert(tag); |
599ce5ed126c
added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
625 request_.SetRetrieveOneInstanceIdentifier(true); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
626 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
627 else |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
628 { |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
629 request_.GetParentSpecification(ResourceType_Series).SetRetrieveMainDicomTags(true); |
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
630 request_.GetParentSpecification(ResourceType_Series).SetRetrieveMetadata(true); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
631 requestedSeriesTags_.insert(tag); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
632 } |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
633 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
634 hasRequestedTags_ = true; |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
635 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
636 else if (DicomMap::IsMainDicomTag(tag, ResourceType_Instance)) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
637 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
638 if (request_.GetLevel() == ResourceType_Patient || |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
639 request_.GetLevel() == ResourceType_Study || |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
640 request_.GetLevel() == ResourceType_Series) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
641 { |
5612
599ce5ed126c
added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
642 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
|
643 << " 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
|
644 requestedTagsFromFileStorage_.insert(tag); |
599ce5ed126c
added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
645 request_.SetRetrieveOneInstanceIdentifier(true); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
646 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
647 else |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
648 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
649 // 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
|
650 assert(request_.IsRetrieveMainDicomTags()); |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5617
diff
changeset
|
651 assert(request_.IsRetrieveMetadata()); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
652 requestedInstanceTags_.insert(tag); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
653 } |
5665
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 hasRequestedTags_ = true; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
656 } |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
657 else if (tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
658 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
659 ConfigureChildrenCountComputedTag(tag, ResourceType_Patient, ResourceType_Study); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
660 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
661 else if (tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
662 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
663 ConfigureChildrenCountComputedTag(tag, ResourceType_Patient, ResourceType_Series); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
664 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
665 else if (tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
666 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
667 ConfigureChildrenCountComputedTag(tag, ResourceType_Patient, ResourceType_Instance); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
668 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
669 else if (tag == DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
670 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
671 ConfigureChildrenCountComputedTag(tag, ResourceType_Study, ResourceType_Series); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
672 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
673 else if (tag == DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
674 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
675 ConfigureChildrenCountComputedTag(tag, ResourceType_Study, ResourceType_Instance); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
676 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
677 else if (tag == DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
678 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
679 ConfigureChildrenCountComputedTag(tag, ResourceType_Series, ResourceType_Instance); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
680 } |
5668
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
681 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
|
682 { |
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
683 requestedComputedTags_.insert(tag); |
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
684 hasRequestedTags_ = true; |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
685 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
|
686 } |
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
687 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
|
688 { |
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
689 requestedComputedTags_.insert(tag); |
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
690 hasRequestedTags_ = true; |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
691 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
|
692 } |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
693 else if (tag == DICOM_TAG_INSTANCE_AVAILABILITY) |
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 requestedComputedTags_.insert(tag); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
696 hasRequestedTags_ = true; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
697 } |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
698 else |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
699 { |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
700 // 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
|
701 // 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
|
702 requestedTagsFromFileStorage_.insert(tag); |
5610
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
703 |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
704 if (request_.GetLevel() != ResourceType_Instance) |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
705 { |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
706 request_.SetRetrieveOneInstanceIdentifier(true); |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
707 } |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
708 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
709 hasRequestedTags_ = true; |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
710 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
711 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
712 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
713 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
714 void ResourceFinder::AddRequestedTags(const std::set<DicomTag>& tags) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
715 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
716 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
|
717 { |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
718 AddRequestedTag(*it); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
719 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
720 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
721 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
722 |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
723 static void InjectRequestedTags(DicomMap& requestedTags, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
724 std::set<DicomTag>& missingTags /* out */, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
725 const FindResponse::Resource& resource, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
726 ResourceType level, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
727 const std::set<DicomTag>& tags) |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
728 { |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
729 if (!tags.empty()) |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
730 { |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
731 DicomMap m; |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
732 resource.GetMainDicomTags(m, level); |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
733 |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
734 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
|
735 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
736 std::string value; |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
737 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
|
738 { |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
739 requestedTags.SetValue(*it, value, false /* not binary */); |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
740 } |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
741 else |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
742 { |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
743 // This is the case where the Housekeeper should be run |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
744 missingTags.insert(*it); |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
745 } |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
746 } |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
747 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
748 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
749 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
750 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
751 static void ReadMissingTagsFromStorageArea(DicomMap& requestedTags, |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
752 ServerContext& context, |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
753 const FindRequest& request, |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
754 const FindResponse::Resource& resource, |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
755 const std::set<DicomTag>& missingTags) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
756 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
757 OrthancConfiguration::ReaderLock lock; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
758 if (lock.GetConfiguration().IsWarningEnabled(Warnings_001_TagsBeingReadFromStorage)) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
759 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
760 std::string missings; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
761 FromDcmtkBridge::FormatListOfTags(missings, missingTags); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
762 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
763 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
|
764 << Orthanc::GetResourceTypeText(resource.GetLevel(), false, false) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
765 << ": " << missings; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
766 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
767 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
768 std::string instancePublicId; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
769 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
770 if (request.IsRetrieveOneInstanceIdentifier()) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
771 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
772 instancePublicId = resource.GetOneInstanceIdentifier(); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
773 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
774 else if (request.GetLevel() == ResourceType_Instance) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
775 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
776 instancePublicId = resource.GetIdentifier(); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
777 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
778 else |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
779 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
780 FindRequest requestDicomAttachment(request.GetLevel()); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
781 requestDicomAttachment.SetOrthancId(request.GetLevel(), resource.GetIdentifier()); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
782 requestDicomAttachment.SetRetrieveOneInstanceIdentifier(true); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
783 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
784 FindResponse responseDicomAttachment; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
785 context.GetIndex().ExecuteFind(responseDicomAttachment, requestDicomAttachment); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
786 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
787 if (responseDicomAttachment.GetSize() != 1 || |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
788 !responseDicomAttachment.GetResourceByIndex(0).HasOneInstanceIdentifier()) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
789 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
790 throw OrthancException(ErrorCode_InexistentFile); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
791 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
792 else |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
793 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
794 instancePublicId = responseDicomAttachment.GetResourceByIndex(0).GetOneInstanceIdentifier(); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
795 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
796 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
797 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
798 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
|
799 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
800 // 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
|
801 // 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
|
802 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
803 Json::Value tmpDicomAsJson; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
804 context.ReadDicomAsJson(tmpDicomAsJson, instancePublicId, missingTags /* ignoreTagLength */); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
805 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
806 DicomMap tmpDicomMap; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
807 tmpDicomMap.FromDicomAsJson(tmpDicomAsJson, false /* append */, true /* parseSequences*/); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
808 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
809 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
|
810 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
811 assert(!requestedTags.HasTag(*it)); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
812 if (tmpDicomMap.HasTag(*it)) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
813 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
814 requestedTags.SetValue(*it, tmpDicomMap.GetValue(*it)); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
815 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
816 else |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
817 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
818 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
|
819 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
820 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
821 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
822 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
823 |
5682
fd4c5e064cbe
started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
824 void ResourceFinder::Execute(FindResponse& response, |
fd4c5e064cbe
started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
825 ServerIndex& index) const |
fd4c5e064cbe
started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
826 { |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
827 index.ExecuteFind(response, request_); |
5682
fd4c5e064cbe
started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
828 } |
fd4c5e064cbe
started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
829 |
fd4c5e064cbe
started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
830 |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
831 void ResourceFinder::Execute(IVisitor& visitor, |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
832 ServerContext& context) const |
5608 | 833 { |
834 FindResponse response; | |
835 context.GetIndex().ExecuteFind(response, request_); | |
836 | |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
837 bool complete; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
838 if (isDatabasePaging_) |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
839 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
840 complete = true; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
841 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
842 else |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
843 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
844 complete = (databaseLimits_ == 0 || |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
845 response.GetSize() <= databaseLimits_); |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
846 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
847 |
5690
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
848 if (lookup_.get() != NULL) |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
849 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
850 LOG(INFO) << "Number of candidate resources after fast DB filtering on main DICOM tags: " << response.GetSize(); |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
851 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
852 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
853 size_t countResults = 0; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
854 size_t skipped = 0; |
5608 | 855 |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
856 for (size_t i = 0; i < response.GetSize(); i++) |
5608 | 857 { |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
858 const FindResponse::Resource& resource = response.GetResourceByIndex(i); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
859 |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
860 DicomMap requestedTags; |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
861 |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
862 if (hasRequestedTags_) |
5608 | 863 { |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
864 InjectComputedTags(requestedTags, resource); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
865 |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
866 std::set<DicomTag> missingTags = requestedTagsFromFileStorage_; |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
867 InjectRequestedTags(requestedTags, missingTags, resource, ResourceType_Patient, requestedPatientTags_); |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
868 InjectRequestedTags(requestedTags, missingTags, resource, ResourceType_Study, requestedStudyTags_); |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
869 InjectRequestedTags(requestedTags, missingTags, resource, ResourceType_Series, requestedSeriesTags_); |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
870 InjectRequestedTags(requestedTags, missingTags, resource, ResourceType_Instance, requestedInstanceTags_); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
871 |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
872 if (!missingTags.empty()) |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
873 { |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
874 if (!allowStorageAccess_) |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
875 { |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
876 throw OrthancException(ErrorCode_BadSequenceOfCalls, |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
877 "Cannot add missing requested tags, as access to file storage is disallowed"); |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
878 } |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
879 else |
5610
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
880 { |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
881 ReadMissingTagsFromStorageArea(requestedTags, context, request_, resource, missingTags); |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
882 } |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
883 } |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
884 } |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
885 |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
886 bool match = true; |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
887 |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
888 if (lookup_.get() != NULL) |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
889 { |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
890 DicomMap tags; |
5690
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
891 resource.GetAllMainDicomTags(tags); |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
892 tags.Merge(requestedTags); |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
893 match = lookup_->IsMatch(tags); |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
894 } |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
895 |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
896 if (match) |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
897 { |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
898 if (isDatabasePaging_) |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
899 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
900 visitor.Apply(resource, hasRequestedTags_, requestedTags); |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
901 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
902 else |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
903 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
904 if (hasLimits_ && |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
905 skipped < limitsSince_) |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
906 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
907 skipped++; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
908 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
909 else if (hasLimits_ && |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
910 countResults >= limitsCount_) |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
911 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
912 // Too many results, don't mark as complete |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
913 complete = false; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
914 break; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
915 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
916 else |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
917 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
918 visitor.Apply(resource, hasRequestedTags_, requestedTags); |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
919 countResults++; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
920 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
921 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
922 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
923 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
924 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
925 if (complete) |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
926 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
927 visitor.MarkAsComplete(); |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
928 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
929 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
930 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
931 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
932 void ResourceFinder::Execute(Json::Value& target, |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
933 ServerContext& context) const |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
934 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
935 class Visitor : public IVisitor |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
936 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
937 private: |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
938 const ResourceFinder& that_; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
939 ServerIndex& index_; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
940 Json::Value& target_; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
941 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
942 public: |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
943 Visitor(const ResourceFinder& that, |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
944 ServerIndex& index, |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
945 Json::Value& target) : |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
946 that_(that), |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
947 index_(index), |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
948 target_(target) |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
949 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
950 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
951 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
952 virtual void Apply(const FindResponse::Resource& resource, |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
953 bool hasRequestedTags, |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
954 const DicomMap& requestedTags) ORTHANC_OVERRIDE |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
955 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
956 if (that_.expand_) |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
957 { |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
958 Json::Value item; |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
959 that_.Expand(item, resource, index_); |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
960 |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
961 if (hasRequestedTags) |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
962 { |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
963 static const char* const REQUESTED_TAGS = "RequestedTags"; |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
964 item[REQUESTED_TAGS] = Json::objectValue; |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
965 FromDcmtkBridge::ToJson(item[REQUESTED_TAGS], requestedTags, that_.format_); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
966 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
967 |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
968 target_.append(item); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
969 } |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
970 else |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
971 { |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
972 target_.append(resource.GetIdentifier()); |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
973 } |
5608 | 974 } |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
975 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
976 virtual void MarkAsComplete() ORTHANC_OVERRIDE |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
977 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
978 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
979 }; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
980 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
981 target = Json::arrayValue; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
982 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
983 Visitor visitor(*this, context.GetIndex(), target); |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
984 Execute(visitor, context); |
5608 | 985 } |
5615
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
986 |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
987 |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
988 bool ResourceFinder::ExecuteOneResource(Json::Value& target, |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
989 ServerContext& context) const |
5615
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
990 { |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
991 Json::Value answer; |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
992 Execute(answer, context); |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
993 |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
994 if (answer.type() != Json::arrayValue) |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
995 { |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
996 throw OrthancException(ErrorCode_InternalError); |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
997 } |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
998 else if (answer.size() > 1) |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
999 { |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1000 throw OrthancException(ErrorCode_DatabasePlugin); |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1001 } |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1002 else if (answer.empty()) |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1003 { |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1004 // 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
|
1005 return false; |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1006 } |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1007 else |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1008 { |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1009 target = answer[0]; |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1010 return true; |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1011 } |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1012 } |
5608 | 1013 } |