Mercurial > hg > orthanc
annotate OrthancServer/Sources/ResourceFinder.cpp @ 5789:40ad08b75d84 find-refactoring
cleanup + W005
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 17 Sep 2024 17:16:42 +0200 |
parents | 61c9e5df64d7 |
children | a3d283f61304 |
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); |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
59 request_.GetChildrenSpecification(childLevel).SetRetrieveIdentifiers(true); |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
60 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
61 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
62 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
63 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
64 void ResourceFinder::InjectChildrenCountComputedTag(DicomMap& requestedTags, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
65 DicomTag tag, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
66 const FindResponse::Resource& resource, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
67 ResourceType level) const |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
68 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
69 if (IsRequestedComputedTag(tag)) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
70 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
71 const std::set<std::string>& children = resource.GetChildrenIdentifiers(level); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
72 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
|
73 } |
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 void ResourceFinder::InjectComputedTags(DicomMap& requestedTags, |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
78 const FindResponse::Resource& resource) const |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
79 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
80 switch (resource.GetLevel()) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
81 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
82 case ResourceType_Patient: |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
83 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
|
84 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
|
85 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
|
86 break; |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
87 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
88 case ResourceType_Study: |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
89 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
|
90 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
|
91 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
92 if (IsRequestedComputedTag(DICOM_TAG_MODALITIES_IN_STUDY)) |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
93 { |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
94 std::set<std::string> modalities; |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
95 resource.GetChildrenMainDicomTagValues(modalities, ResourceType_Series, DICOM_TAG_MODALITY); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
96 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
97 std::string s; |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
98 Toolbox::JoinStrings(s, modalities, "\\"); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
99 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
100 requestedTags.SetValue(DICOM_TAG_MODALITIES_IN_STUDY, s, false); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
101 } |
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 if (IsRequestedComputedTag(DICOM_TAG_SOP_CLASSES_IN_STUDY)) |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
104 { |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
105 std::set<std::string> classes; |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
106 resource.GetChildrenMetadataValues(classes, ResourceType_Instance, MetadataType_Instance_SopClassUid); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
107 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
108 std::string s; |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
109 Toolbox::JoinStrings(s, classes, "\\"); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
110 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
111 requestedTags.SetValue(DICOM_TAG_SOP_CLASSES_IN_STUDY, s, false); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
112 } |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5668
diff
changeset
|
113 |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
114 break; |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
115 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
116 case ResourceType_Series: |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
117 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
|
118 break; |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
119 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
120 case ResourceType_Instance: |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
121 if (IsRequestedComputedTag(DICOM_TAG_INSTANCE_AVAILABILITY)) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
122 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
123 requestedTags.SetValue(DICOM_TAG_INSTANCE_AVAILABILITY, "ONLINE", false); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
124 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
125 break; |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
126 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
127 default: |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
128 throw OrthancException(ErrorCode_InternalError); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
129 } |
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 |
5608 | 133 SeriesStatus ResourceFinder::GetSeriesStatus(uint32_t& expectedNumberOfInstances, |
5689 | 134 const FindResponse::Resource& resource) |
5608 | 135 { |
5689 | 136 if (resource.GetLevel() != ResourceType_Series) |
5608 | 137 { |
138 throw OrthancException(ErrorCode_BadParameterType); | |
139 } | |
140 | |
141 std::string s; | |
142 if (!resource.LookupMetadata(s, ResourceType_Series, MetadataType_Series_ExpectedNumberOfInstances) || | |
143 !SerializationToolbox::ParseUnsignedInteger32(expectedNumberOfInstances, s)) | |
144 { | |
145 return SeriesStatus_Unknown; | |
146 } | |
147 | |
5674 | 148 std::set<std::string> values; |
149 resource.GetChildrenMetadataValues(values, ResourceType_Instance, MetadataType_Instance_IndexInSeries); | |
5608 | 150 |
151 std::set<int64_t> instances; | |
152 | |
5674 | 153 for (std::set<std::string>::const_iterator |
5608 | 154 it = values.begin(); it != values.end(); ++it) |
155 { | |
156 int64_t index; | |
157 | |
158 if (!SerializationToolbox::ParseInteger64(index, *it)) | |
159 { | |
160 return SeriesStatus_Unknown; | |
161 } | |
162 | |
163 if (index <= 0 || | |
164 index > static_cast<int64_t>(expectedNumberOfInstances)) | |
165 { | |
166 // Out-of-range instance index | |
167 return SeriesStatus_Inconsistent; | |
168 } | |
169 | |
170 if (instances.find(index) != instances.end()) | |
171 { | |
172 // Twice the same instance index | |
173 return SeriesStatus_Inconsistent; | |
174 } | |
175 | |
176 instances.insert(index); | |
177 } | |
178 | |
179 if (instances.size() == static_cast<size_t>(expectedNumberOfInstances)) | |
180 { | |
181 return SeriesStatus_Complete; | |
182 } | |
183 else | |
184 { | |
185 return SeriesStatus_Missing; | |
186 } | |
187 } | |
188 | |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
189 static void GetMainDicomSequencesFromMetadata(DicomMap& target, const FindResponse::Resource& resource, ResourceType level) |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
190 { |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
191 // read all main sequences from DB |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
192 std::string serializedSequences; |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
193 if (resource.LookupMetadata(serializedSequences, resource.GetLevel(), MetadataType_MainDicomSequences)) |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
194 { |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
195 Json::Value jsonMetadata; |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
196 Toolbox::ReadJson(jsonMetadata, serializedSequences); |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
197 |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
198 if (jsonMetadata["Version"].asInt() == 1) |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
199 { |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
200 target.FromDicomAsJson(jsonMetadata["Sequences"], true /* append */, true /* parseSequences */); |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
201 } |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
202 else |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
203 { |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
204 throw OrthancException(ErrorCode_NotImplemented); |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
205 } |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
206 } |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
207 } |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
208 |
5608 | 209 |
210 void ResourceFinder::Expand(Json::Value& target, | |
211 const FindResponse::Resource& resource, | |
5709
476b1db52110
removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5702
diff
changeset
|
212 ServerIndex& index, |
5713
d851a54e49b7
removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5709
diff
changeset
|
213 DicomToJsonFormat format, |
d851a54e49b7
removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5709
diff
changeset
|
214 bool includeAllMetadata) const |
5608 | 215 { |
216 /** | |
217 * This method closely follows "SerializeExpandedResource()" in | |
5689 | 218 * "ServerContext.cpp" from Orthanc 1.12.4. |
5608 | 219 **/ |
220 | |
5713
d851a54e49b7
removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5709
diff
changeset
|
221 if (!expand_) |
d851a54e49b7
removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5709
diff
changeset
|
222 { |
d851a54e49b7
removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5709
diff
changeset
|
223 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
d851a54e49b7
removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5709
diff
changeset
|
224 } |
d851a54e49b7
removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5709
diff
changeset
|
225 |
5608 | 226 if (resource.GetLevel() != request_.GetLevel()) |
227 { | |
228 throw OrthancException(ErrorCode_InternalError); | |
229 } | |
230 | |
231 target = Json::objectValue; | |
232 | |
233 target["Type"] = GetResourceTypeText(resource.GetLevel(), false, true); | |
234 target["ID"] = resource.GetIdentifier(); | |
235 | |
236 switch (resource.GetLevel()) | |
237 { | |
238 case ResourceType_Patient: | |
239 break; | |
240 | |
241 case ResourceType_Study: | |
242 target["ParentPatient"] = resource.GetParentIdentifier(); | |
243 break; | |
244 | |
245 case ResourceType_Series: | |
246 target["ParentStudy"] = resource.GetParentIdentifier(); | |
247 break; | |
248 | |
249 case ResourceType_Instance: | |
250 target["ParentSeries"] = resource.GetParentIdentifier(); | |
251 break; | |
252 | |
253 default: | |
254 throw OrthancException(ErrorCode_InternalError); | |
255 } | |
256 | |
257 if (resource.GetLevel() != ResourceType_Instance) | |
258 { | |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
259 const std::set<std::string>& children = resource.GetChildrenIdentifiers(GetChildResourceType(resource.GetLevel())); |
5608 | 260 |
261 Json::Value c = Json::arrayValue; | |
262 for (std::set<std::string>::const_iterator | |
263 it = children.begin(); it != children.end(); ++it) | |
264 { | |
265 c.append(*it); | |
266 } | |
267 | |
268 switch (resource.GetLevel()) | |
269 { | |
270 case ResourceType_Patient: | |
271 target["Studies"] = c; | |
272 break; | |
273 | |
274 case ResourceType_Study: | |
275 target["Series"] = c; | |
276 break; | |
277 | |
278 case ResourceType_Series: | |
279 target["Instances"] = c; | |
280 break; | |
281 | |
282 default: | |
283 throw OrthancException(ErrorCode_InternalError); | |
284 } | |
285 } | |
286 | |
287 switch (resource.GetLevel()) | |
288 { | |
289 case ResourceType_Patient: | |
290 case ResourceType_Study: | |
291 break; | |
292 | |
293 case ResourceType_Series: | |
294 { | |
295 uint32_t expectedNumberOfInstances; | |
296 SeriesStatus status = GetSeriesStatus(expectedNumberOfInstances, resource); | |
297 | |
298 target["Status"] = EnumerationToString(status); | |
299 | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
300 static const char* const EXPECTED_NUMBER_OF_INSTANCES = "ExpectedNumberOfInstances"; |
5608 | 301 |
302 if (status == SeriesStatus_Unknown) | |
303 { | |
304 target[EXPECTED_NUMBER_OF_INSTANCES] = Json::nullValue; | |
305 } | |
306 else | |
307 { | |
308 target[EXPECTED_NUMBER_OF_INSTANCES] = expectedNumberOfInstances; | |
309 } | |
310 | |
311 break; | |
312 } | |
313 | |
314 case ResourceType_Instance: | |
315 { | |
316 FileInfo info; | |
317 if (resource.LookupAttachment(info, FileContentType_Dicom)) | |
318 { | |
319 target["FileSize"] = static_cast<Json::UInt64>(info.GetUncompressedSize()); | |
320 target["FileUuid"] = info.GetUuid(); | |
321 } | |
322 else | |
323 { | |
324 throw OrthancException(ErrorCode_InternalError); | |
325 } | |
326 | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
327 static const char* const INDEX_IN_SERIES = "IndexInSeries"; |
5608 | 328 |
329 std::string s; | |
5702 | 330 uint32_t indexInSeries; |
5608 | 331 if (resource.LookupMetadata(s, ResourceType_Instance, MetadataType_Instance_IndexInSeries) && |
5702 | 332 SerializationToolbox::ParseUnsignedInteger32(indexInSeries, s)) |
5608 | 333 { |
5702 | 334 target[INDEX_IN_SERIES] = indexInSeries; |
5608 | 335 } |
336 else | |
337 { | |
338 target[INDEX_IN_SERIES] = Json::nullValue; | |
339 } | |
340 | |
341 break; | |
342 } | |
343 | |
344 default: | |
345 throw OrthancException(ErrorCode_InternalError); | |
346 } | |
347 | |
348 std::string s; | |
349 if (resource.LookupMetadata(s, resource.GetLevel(), MetadataType_AnonymizedFrom)) | |
350 { | |
351 target["AnonymizedFrom"] = s; | |
352 } | |
353 | |
354 if (resource.LookupMetadata(s, resource.GetLevel(), MetadataType_ModifiedFrom)) | |
355 { | |
356 target["ModifiedFrom"] = s; | |
357 } | |
358 | |
359 if (resource.GetLevel() == ResourceType_Patient || | |
360 resource.GetLevel() == ResourceType_Study || | |
361 resource.GetLevel() == ResourceType_Series) | |
362 { | |
363 target["IsStable"] = !index.IsUnstableResource(resource.GetLevel(), resource.GetInternalId()); | |
364 | |
365 if (resource.LookupMetadata(s, resource.GetLevel(), MetadataType_LastUpdate)) | |
366 { | |
367 target["LastUpdate"] = s; | |
368 } | |
369 } | |
370 | |
371 { | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
372 DicomMap allMainDicomTags; |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
373 resource.GetMainDicomTags(allMainDicomTags, resource.GetLevel()); |
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 // read all main sequences from DB |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
376 GetMainDicomSequencesFromMetadata(allMainDicomTags, resource, resource.GetLevel()); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
377 |
5608 | 378 static const char* const MAIN_DICOM_TAGS = "MainDicomTags"; |
379 static const char* const PATIENT_MAIN_DICOM_TAGS = "PatientMainDicomTags"; | |
380 | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
381 // TODO-FIND : Ignore "null" values |
5608 | 382 |
383 DicomMap levelMainDicomTags; | |
384 allMainDicomTags.ExtractResourceInformation(levelMainDicomTags, resource.GetLevel()); | |
385 | |
386 target[MAIN_DICOM_TAGS] = Json::objectValue; | |
5709
476b1db52110
removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5702
diff
changeset
|
387 FromDcmtkBridge::ToJson(target[MAIN_DICOM_TAGS], levelMainDicomTags, format); |
5608 | 388 |
389 if (resource.GetLevel() == ResourceType_Study) | |
390 { | |
391 DicomMap patientMainDicomTags; | |
392 allMainDicomTags.ExtractPatientInformation(patientMainDicomTags); | |
393 | |
394 target[PATIENT_MAIN_DICOM_TAGS] = Json::objectValue; | |
5709
476b1db52110
removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5702
diff
changeset
|
395 FromDcmtkBridge::ToJson(target[PATIENT_MAIN_DICOM_TAGS], patientMainDicomTags, format); |
5608 | 396 } |
397 } | |
398 | |
399 { | |
400 Json::Value labels = Json::arrayValue; | |
401 | |
402 for (std::set<std::string>::const_iterator | |
403 it = resource.GetLabels().begin(); it != resource.GetLabels().end(); ++it) | |
404 { | |
405 labels.append(*it); | |
406 } | |
407 | |
408 target["Labels"] = labels; | |
409 } | |
410 | |
5713
d851a54e49b7
removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5709
diff
changeset
|
411 if (includeAllMetadata) // new in Orthanc 1.12.4 |
5608 | 412 { |
413 const std::map<MetadataType, std::string>& m = resource.GetMetadata(resource.GetLevel()); | |
414 | |
415 Json::Value metadata = Json::objectValue; | |
416 | |
417 for (std::map<MetadataType, std::string>::const_iterator it = m.begin(); it != m.end(); ++it) | |
418 { | |
419 metadata[EnumerationToString(it->first)] = it->second; | |
420 } | |
421 | |
422 target["Metadata"] = metadata; | |
423 } | |
424 } | |
425 | |
426 | |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
427 void ResourceFinder::UpdateRequestLimits() |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
428 { |
5690
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
429 // By default, use manual paging |
5693 | 430 pagingMode_ = PagingMode_FullManual; |
5690
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 if (databaseLimits_ != 0) |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
433 { |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
434 request_.SetLimits(0, databaseLimits_ + 1); |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
435 } |
5692
7c11a71927a9
improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5690
diff
changeset
|
436 else |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
437 { |
5692
7c11a71927a9
improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5690
diff
changeset
|
438 request_.ClearLimits(); |
7c11a71927a9
improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5690
diff
changeset
|
439 } |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
440 |
5693 | 441 if (lookup_.get() == NULL && |
442 (hasLimitsSince_ || hasLimitsCount_)) | |
5692
7c11a71927a9
improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5690
diff
changeset
|
443 { |
5693 | 444 pagingMode_ = PagingMode_FullDatabase; |
445 request_.SetLimits(limitsSince_, limitsCount_); | |
446 } | |
447 | |
448 if (lookup_.get() != NULL && | |
449 isSimpleLookup_ && | |
450 (hasLimitsSince_ || hasLimitsCount_)) | |
451 { | |
452 /** | |
453 * TODO-FIND: "IDatabaseWrapper::ApplyLookupResources()" only | |
454 * accept the "limit" argument. The "since" must be implemented | |
455 * manually. | |
456 **/ | |
457 | |
458 if (hasLimitsSince_ && | |
459 limitsSince_ != 0) | |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
460 { |
5693 | 461 pagingMode_ = PagingMode_ManualSkip; |
462 request_.SetLimits(0, limitsCount_ + limitsSince_); | |
5692
7c11a71927a9
improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5690
diff
changeset
|
463 } |
5693 | 464 else |
465 { | |
466 pagingMode_ = PagingMode_FullDatabase; | |
467 request_.SetLimits(0, limitsCount_); | |
468 } | |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
469 } |
5690
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
470 |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
471 // 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
|
472 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
473 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
474 |
5608 | 475 ResourceFinder::ResourceFinder(ResourceType level, |
476 bool expand) : | |
477 request_(level), | |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
478 databaseLimits_(0), |
5693 | 479 isSimpleLookup_(true), |
480 pagingMode_(PagingMode_FullManual), | |
481 hasLimitsSince_(false), | |
482 hasLimitsCount_(false), | |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
483 limitsSince_(0), |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
484 limitsCount_(0), |
5608 | 485 expand_(expand), |
5617
8905ffa45fc2
started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5616
diff
changeset
|
486 allowStorageAccess_(true), |
5789 | 487 isWarning002Enabled_(false), |
488 isWarning004Enabled_(false), | |
489 isWarning005Enabled_(false) | |
5608 | 490 { |
5789 | 491 { |
492 OrthancConfiguration::ReaderLock lock; | |
493 isWarning002Enabled_ = lock.GetConfiguration().IsWarningEnabled(Warnings_002_InconsistentDicomTagsInDb); | |
494 isWarning004Enabled_ = lock.GetConfiguration().IsWarningEnabled(Warnings_004_NoMainDicomTagsSignature); | |
495 isWarning005Enabled_ = lock.GetConfiguration().IsWarningEnabled(Warnings_005_RequestingTagFromLowerResourceLevel); | |
496 } | |
497 | |
498 | |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
499 UpdateRequestLimits(); |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
500 |
5608 | 501 if (expand) |
502 { | |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5617
diff
changeset
|
503 request_.SetRetrieveMainDicomTags(true); |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5617
diff
changeset
|
504 request_.SetRetrieveMetadata(true); |
5608 | 505 request_.SetRetrieveLabels(true); |
506 | |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
507 switch (level) |
5608 | 508 { |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
509 case ResourceType_Patient: |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
510 request_.GetChildrenSpecification(ResourceType_Study).SetRetrieveIdentifiers(true); |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
511 break; |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
512 |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
513 case ResourceType_Study: |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
514 request_.GetChildrenSpecification(ResourceType_Series).SetRetrieveIdentifiers(true); |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
515 request_.SetRetrieveParentIdentifier(true); |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
516 break; |
5608 | 517 |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
518 case ResourceType_Series: |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
519 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
|
520 request_.GetChildrenSpecification(ResourceType_Instance).SetRetrieveIdentifiers(true); |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
521 request_.SetRetrieveParentIdentifier(true); |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
522 break; |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
523 |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
524 case ResourceType_Instance: |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
525 request_.SetRetrieveAttachments(true); // for FileSize & FileUuid |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
526 request_.SetRetrieveParentIdentifier(true); |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
527 break; |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
528 |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
529 default: |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
530 throw OrthancException(ErrorCode_ParameterOutOfRange); |
5608 | 531 } |
532 } | |
533 } | |
534 | |
535 | |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
536 void ResourceFinder::SetDatabaseLimits(uint64_t limits) |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
537 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
538 databaseLimits_ = limits; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
539 UpdateRequestLimits(); |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
540 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
541 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
542 |
5693 | 543 void ResourceFinder::SetLimitsSince(uint64_t since) |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
544 { |
5693 | 545 if (hasLimitsSince_) |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
546 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
547 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
548 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
549 else |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
550 { |
5693 | 551 hasLimitsSince_ = true; |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
552 limitsSince_ = since; |
5693 | 553 UpdateRequestLimits(); |
554 } | |
555 } | |
556 | |
557 | |
558 void ResourceFinder::SetLimitsCount(uint64_t count) | |
559 { | |
560 if (hasLimitsCount_) | |
561 { | |
562 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
563 } | |
564 else | |
565 { | |
566 hasLimitsCount_ = true; | |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
567 limitsCount_ = count; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
568 UpdateRequestLimits(); |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
569 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
570 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
571 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
572 |
5682
fd4c5e064cbe
started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
573 void ResourceFinder::SetDatabaseLookup(const DatabaseLookup& lookup) |
fd4c5e064cbe
started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
574 { |
5694 | 575 MainDicomTagsRegistry registry; |
576 | |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
577 lookup_.reset(lookup.Clone()); |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
578 |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
579 for (size_t i = 0; i < lookup.GetConstraintsCount(); i++) |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
580 { |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
581 DicomTag tag = lookup.GetConstraint(i).GetTag(); |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
582 if (IsComputedTag(tag)) |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
583 { |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
584 AddRequestedTag(tag); |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
585 } |
5694 | 586 else |
587 { | |
588 ResourceType level; | |
589 DicomTagType tagType; | |
590 registry.LookupTag(level, tagType, tag); | |
591 if (tagType == DicomTagType_Generic) | |
592 { | |
593 AddRequestedTag(tag); | |
594 } | |
595 } | |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
596 } |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
597 |
5693 | 598 isSimpleLookup_ = registry.NormalizeLookup(request_.GetDicomTagConstraints(), lookup, request_.GetLevel()); |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
599 |
5690
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
600 // "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
|
601 |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
602 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
|
603 { |
5690
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
604 const DatabaseConstraint& constraint = request_.GetDicomTagConstraints().GetConstraint(i); |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
605 if (constraint.GetLevel() == request_.GetLevel()) |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
606 { |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
607 request_.SetRetrieveMainDicomTags(true); |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
608 } |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
609 else if (IsResourceLevelAboveOrEqual(constraint.GetLevel(), request_.GetLevel())) |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
610 { |
5690
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
611 request_.GetParentSpecification(constraint.GetLevel()).SetRetrieveMainDicomTags(true); |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
612 } |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
613 else |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
614 { |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
615 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
|
616 << " 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
|
617 << 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
|
618 } |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
619 |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
620 if (IsComputedTag(constraint.GetTag())) |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
621 { |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
622 // Sanity check |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
623 throw OrthancException(ErrorCode_InternalError); |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
624 } |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
625 } |
5692
7c11a71927a9
improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5690
diff
changeset
|
626 |
7c11a71927a9
improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5690
diff
changeset
|
627 UpdateRequestLimits(); |
5682
fd4c5e064cbe
started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
628 } |
fd4c5e064cbe
started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
629 |
fd4c5e064cbe
started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
630 |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
631 void ResourceFinder::AddRequestedTag(const DicomTag& tag) |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
632 { |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
633 requestedTags_.insert(tag); |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
634 |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
635 if (DicomMap::IsMainDicomTag(tag, ResourceType_Patient)) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
636 { |
5620
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
637 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
|
638 { |
5697 | 639 request_.SetRetrieveMainDicomTags(true); |
5620
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
640 } |
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
641 else |
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
642 { |
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
643 /** |
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
644 * 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
|
645 * 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
|
646 **/ |
5697 | 647 if (request_.GetLevel() == ResourceType_Study) |
648 { | |
649 request_.SetRetrieveMainDicomTags(true); | |
650 } | |
651 else | |
652 { | |
653 request_.GetParentSpecification(ResourceType_Study).SetRetrieveMainDicomTags(true); | |
654 } | |
5620
4bfd885fb45f
optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
655 } |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
656 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
657 else if (DicomMap::IsMainDicomTag(tag, ResourceType_Study)) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
658 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
659 if (request_.GetLevel() == ResourceType_Patient) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
660 { |
5789 | 661 if (isWarning005Enabled_) |
662 { | |
663 LOG(WARNING) << "W005: Requested tag " << tag.Format() | |
664 << " should only be read at the study, series, or instance level"; | |
665 } | |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
666 request_.SetRetrieveOneInstanceMetadataAndAttachments(true); // we might need to get it from one instance |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
667 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
668 else |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
669 { |
5697 | 670 if (request_.GetLevel() == ResourceType_Study) |
671 { | |
672 request_.SetRetrieveMainDicomTags(true); | |
673 } | |
674 else | |
675 { | |
676 request_.GetParentSpecification(ResourceType_Study).SetRetrieveMainDicomTags(true); | |
677 } | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
678 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
679 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
680 else if (DicomMap::IsMainDicomTag(tag, ResourceType_Series)) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
681 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
682 if (request_.GetLevel() == ResourceType_Patient || |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
683 request_.GetLevel() == ResourceType_Study) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
684 { |
5789 | 685 if (isWarning005Enabled_) |
686 { | |
687 LOG(WARNING) << "W005: Requested tag " << tag.Format() | |
688 << " should only be read at the series or instance level"; | |
689 } | |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
690 request_.SetRetrieveOneInstanceMetadataAndAttachments(true); // we might need to get it from one instance |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
691 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
692 else |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
693 { |
5697 | 694 if (request_.GetLevel() == ResourceType_Series) |
695 { | |
696 request_.SetRetrieveMainDicomTags(true); | |
697 } | |
698 else | |
699 { | |
700 request_.GetParentSpecification(ResourceType_Series).SetRetrieveMainDicomTags(true); | |
701 } | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
702 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
703 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
704 else if (DicomMap::IsMainDicomTag(tag, ResourceType_Instance)) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
705 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
706 if (request_.GetLevel() == ResourceType_Patient || |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
707 request_.GetLevel() == ResourceType_Study || |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
708 request_.GetLevel() == ResourceType_Series) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
709 { |
5789 | 710 if (isWarning005Enabled_) |
711 { | |
712 LOG(WARNING) << "W005: Requested tag " << tag.Format() | |
713 << " should only be read at the instance level"; | |
714 } | |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
715 request_.SetRetrieveOneInstanceMetadataAndAttachments(true); // we might need to get it from one instance |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
716 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
717 else |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
718 { |
5699
e8e028aed89f
c-find tests pass using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5697
diff
changeset
|
719 request_.SetRetrieveMainDicomTags(true); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
720 } |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
721 } |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
722 else if (tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
723 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
724 ConfigureChildrenCountComputedTag(tag, ResourceType_Patient, ResourceType_Study); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
725 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
726 else if (tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
727 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
728 ConfigureChildrenCountComputedTag(tag, ResourceType_Patient, ResourceType_Series); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
729 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
730 else if (tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
731 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
732 ConfigureChildrenCountComputedTag(tag, ResourceType_Patient, ResourceType_Instance); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
733 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
734 else if (tag == DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES) |
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 ConfigureChildrenCountComputedTag(tag, ResourceType_Study, ResourceType_Series); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
737 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
738 else if (tag == DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
739 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
740 ConfigureChildrenCountComputedTag(tag, ResourceType_Study, ResourceType_Instance); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
741 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
742 else if (tag == DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
743 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
744 ConfigureChildrenCountComputedTag(tag, ResourceType_Series, ResourceType_Instance); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
745 } |
5668
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
746 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
|
747 { |
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
748 requestedComputedTags_.insert(tag); |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5674
diff
changeset
|
749 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
|
750 } |
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
751 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
|
752 { |
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
753 requestedComputedTags_.insert(tag); |
5752
717acb0ea546
fix DICOMWeb integration tests
Alain Mazy <am@orthanc.team>
parents:
5714
diff
changeset
|
754 if (request_.GetLevel() < ResourceType_Series) |
717acb0ea546
fix DICOMWeb integration tests
Alain Mazy <am@orthanc.team>
parents:
5714
diff
changeset
|
755 { |
717acb0ea546
fix DICOMWeb integration tests
Alain Mazy <am@orthanc.team>
parents:
5714
diff
changeset
|
756 request_.GetChildrenSpecification(ResourceType_Series).AddMainDicomTag(DICOM_TAG_MODALITY); |
717acb0ea546
fix DICOMWeb integration tests
Alain Mazy <am@orthanc.team>
parents:
5714
diff
changeset
|
757 } |
717acb0ea546
fix DICOMWeb integration tests
Alain Mazy <am@orthanc.team>
parents:
5714
diff
changeset
|
758 else if (request_.GetLevel() == ResourceType_Instance) // this happens in QIDO-RS when searching for instances without specifying a StudyInstanceUID -> all Study level tags must be included in the response |
717acb0ea546
fix DICOMWeb integration tests
Alain Mazy <am@orthanc.team>
parents:
5714
diff
changeset
|
759 { |
717acb0ea546
fix DICOMWeb integration tests
Alain Mazy <am@orthanc.team>
parents:
5714
diff
changeset
|
760 request_.GetParentSpecification(ResourceType_Series).SetRetrieveMainDicomTags(true); |
717acb0ea546
fix DICOMWeb integration tests
Alain Mazy <am@orthanc.team>
parents:
5714
diff
changeset
|
761 } |
5668
bd1352bd9d82
configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
762 } |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
763 else if (tag == DICOM_TAG_INSTANCE_AVAILABILITY) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
764 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
765 requestedComputedTags_.insert(tag); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
766 } |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
767 else |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
768 { |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
769 // This is neither a main DICOM tag, nor a computed DICOM tag: |
5789 | 770 // We might need to access a DICOM file or the MainDicomSequences metadata |
771 | |
772 request_.SetRetrieveMetadata(true); | |
773 | |
5610
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
774 if (request_.GetLevel() != ResourceType_Instance) |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
775 { |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
776 request_.SetRetrieveOneInstanceMetadataAndAttachments(true); |
5610
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
777 } |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
778 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
779 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
780 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
781 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
782 void ResourceFinder::AddRequestedTags(const std::set<DicomTag>& tags) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
783 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
784 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
|
785 { |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
786 AddRequestedTag(*it); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
787 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
788 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
789 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
790 |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
791 static void InjectRequestedTags(DicomMap& target, |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
792 std::set<DicomTag>& remainingRequestedTags /* in & out */, |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
793 const FindResponse::Resource& resource, |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
794 ResourceType level/*, |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
795 const std::set<DicomTag>& tags*/) |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
796 { |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
797 if (!remainingRequestedTags.empty()) |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
798 { |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
799 DicomMap m; |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
800 resource.GetAllMainDicomTags(m); // DicomTags from DB |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
801 GetMainDicomSequencesFromMetadata(m, resource, resource.GetLevel()); // DicomSequences from metadata |
5787
42ef98bb3c13
Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents:
5774
diff
changeset
|
802 |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
803 // check which tags have been saved in DB; that's the way to know if they are missing because they were not saved or because they have no value |
5787
42ef98bb3c13
Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents:
5774
diff
changeset
|
804 std::set<DicomTag> savedMainDicomTags; |
42ef98bb3c13
Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents:
5774
diff
changeset
|
805 std::string signature = DicomMap::GetDefaultMainDicomTagsSignature(ResourceType_Study); // default signature in case it's not in the metadata (= the signature for 1.11.0) |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
806 if (resource.LookupMetadata(signature, resource.GetLevel(), MetadataType_MainDicomTagsSignature)) |
5787
42ef98bb3c13
Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents:
5774
diff
changeset
|
807 { |
42ef98bb3c13
Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents:
5774
diff
changeset
|
808 if (level == ResourceType_Study) // when we retrieve the study tags, we actually also get the patient tags that are also saved at study level but not included in the signature |
42ef98bb3c13
Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents:
5774
diff
changeset
|
809 { |
42ef98bb3c13
Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents:
5774
diff
changeset
|
810 signature += ";" + DicomMap::GetDefaultMainDicomTagsSignature(ResourceType_Patient); // append the default signature (from before 1.11.0) |
42ef98bb3c13
Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents:
5774
diff
changeset
|
811 } |
42ef98bb3c13
Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents:
5774
diff
changeset
|
812 |
42ef98bb3c13
Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents:
5774
diff
changeset
|
813 FromDcmtkBridge::ParseListOfTags(savedMainDicomTags, signature); |
42ef98bb3c13
Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents:
5774
diff
changeset
|
814 } |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
815 |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
816 std::set<DicomTag> copiedTags; |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
817 for (std::set<DicomTag>::const_iterator it = remainingRequestedTags.begin(); it != remainingRequestedTags.end(); ++it) |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
818 { |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
819 if (target.CopyTagIfExists(m, *it)) |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
820 { |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
821 copiedTags.insert(*it); |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
822 } |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
823 else if (savedMainDicomTags.find(*it) != savedMainDicomTags.end()) // the tag should have been saved in DB but has no value so we consider it has been copied |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
824 { |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
825 copiedTags.insert(*it); |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
826 } |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5665
diff
changeset
|
827 } |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
828 |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
829 Toolbox::RemoveSets(remainingRequestedTags, copiedTags); |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
830 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
831 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
832 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
833 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
834 static void ReadMissingTagsFromStorageArea(DicomMap& requestedTags, |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
835 ServerContext& context, |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
836 const FindRequest& request, |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
837 const FindResponse::Resource& resource, |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
838 const std::set<DicomTag>& missingTags) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
839 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
840 OrthancConfiguration::ReaderLock lock; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
841 if (lock.GetConfiguration().IsWarningEnabled(Warnings_001_TagsBeingReadFromStorage)) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
842 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
843 std::string missings; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
844 FromDcmtkBridge::FormatListOfTags(missings, missingTags); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
845 |
5699
e8e028aed89f
c-find tests pass using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5697
diff
changeset
|
846 LOG(WARNING) << "W001: Accessing DICOM tags from storage when accessing " |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
847 << Orthanc::GetResourceTypeText(resource.GetLevel(), false, false) |
5764 | 848 << " " << resource.GetIdentifier() |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
849 << ": " << missings; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
850 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
851 |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
852 // TODO-FIND: What do we do if the DICOM has been removed since the request? |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
853 // Do we fail, or do we skip the resource? |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
854 |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
855 Json::Value tmpDicomAsJson; |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
856 |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
857 if (request.GetLevel() == ResourceType_Instance && |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
858 request.IsRetrieveMetadata() && |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
859 request.IsRetrieveAttachments()) |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
860 { |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
861 LOG(INFO) << "Will retrieve missing DICOM tags from instance: " << resource.GetIdentifier(); |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
862 |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
863 context.ReadDicomAsJson(tmpDicomAsJson, resource.GetIdentifier(), resource.GetMetadata(ResourceType_Instance), |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
864 resource.GetAttachments(), missingTags /* ignoreTagLength */); |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
865 } |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
866 else if (request.GetLevel() != ResourceType_Instance && |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
867 request.IsRetrieveOneInstanceMetadataAndAttachments()) |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
868 { |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
869 LOG(INFO) << "Will retrieve missing DICOM tags from instance: " << resource.GetOneInstancePublicId(); |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
870 |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
871 context.ReadDicomAsJson(tmpDicomAsJson, resource.GetOneInstancePublicId(), resource.GetOneInstanceMetadata(), |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
872 resource.GetOneInstanceAttachments(), missingTags /* ignoreTagLength */); |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
873 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
874 else |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
875 { |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
876 // TODO-FIND: This fallback shouldn't be necessary |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
877 |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
878 FindRequest requestDicomAttachment(request.GetLevel()); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
879 requestDicomAttachment.SetOrthancId(request.GetLevel(), resource.GetIdentifier()); |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
880 |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
881 if (request.GetLevel() == ResourceType_Instance) |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
882 { |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
883 requestDicomAttachment.SetRetrieveMetadata(true); |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
884 requestDicomAttachment.SetRetrieveAttachments(true); |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
885 } |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
886 else |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
887 { |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
888 requestDicomAttachment.SetRetrieveOneInstanceMetadataAndAttachments(true); |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
889 } |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
890 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
891 FindResponse responseDicomAttachment; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
892 context.GetIndex().ExecuteFind(responseDicomAttachment, requestDicomAttachment); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
893 |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
894 if (responseDicomAttachment.GetSize() != 1) |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
895 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
896 throw OrthancException(ErrorCode_InexistentFile); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
897 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
898 else |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
899 { |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
900 const FindResponse::Resource& response = responseDicomAttachment.GetResourceByIndex(0); |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
901 const std::string instancePublicId = response.GetIdentifier(); |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
902 LOG(INFO) << "Will retrieve missing DICOM tags from instance: " << instancePublicId; |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
903 |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
904 if (request.GetLevel() == ResourceType_Instance) |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
905 { |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
906 context.ReadDicomAsJson(tmpDicomAsJson, response.GetIdentifier(), response.GetMetadata(ResourceType_Instance), |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
907 response.GetAttachments(), missingTags /* ignoreTagLength */); |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
908 } |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
909 else |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
910 { |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
911 context.ReadDicomAsJson(tmpDicomAsJson, response.GetOneInstancePublicId(), response.GetOneInstanceMetadata(), |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
912 response.GetOneInstanceAttachments(), missingTags /* ignoreTagLength */); |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5764
diff
changeset
|
913 } |
5665
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
914 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
915 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
916 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
917 DicomMap tmpDicomMap; |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
918 tmpDicomMap.FromDicomAsJson(tmpDicomAsJson, false /* append */, true /* parseSequences*/); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
919 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
920 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
|
921 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
922 assert(!requestedTags.HasTag(*it)); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
923 if (tmpDicomMap.HasTag(*it)) |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
924 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
925 requestedTags.SetValue(*it, tmpDicomMap.GetValue(*it)); |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
926 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
927 else |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
928 { |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
929 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
|
930 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
931 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
932 } |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
933 |
d8c86698110c
implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
934 |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
935 void ResourceFinder::Execute(IVisitor& visitor, |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5620
diff
changeset
|
936 ServerContext& context) const |
5608 | 937 { |
5764 | 938 bool isWarning002Enabled = false; |
5787
42ef98bb3c13
Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents:
5774
diff
changeset
|
939 bool isWarning004Enabled = false; |
5764 | 940 |
941 { | |
942 OrthancConfiguration::ReaderLock lock; | |
943 isWarning002Enabled = lock.GetConfiguration().IsWarningEnabled(Warnings_002_InconsistentDicomTagsInDb); | |
5787
42ef98bb3c13
Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents:
5774
diff
changeset
|
944 isWarning004Enabled = lock.GetConfiguration().IsWarningEnabled(Warnings_004_NoMainDicomTagsSignature); |
5764 | 945 } |
946 | |
5608 | 947 FindResponse response; |
948 context.GetIndex().ExecuteFind(response, request_); | |
949 | |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
950 bool complete; |
5693 | 951 |
952 switch (pagingMode_) | |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
953 { |
5693 | 954 case PagingMode_FullDatabase: |
955 case PagingMode_ManualSkip: | |
956 complete = true; | |
957 break; | |
958 | |
959 case PagingMode_FullManual: | |
960 complete = (databaseLimits_ == 0 || | |
961 response.GetSize() <= databaseLimits_); | |
962 break; | |
963 | |
964 default: | |
965 throw OrthancException(ErrorCode_InternalError); | |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
966 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
967 |
5690
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
968 if (lookup_.get() != NULL) |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
969 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
970 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
|
971 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
972 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
973 size_t countResults = 0; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
974 size_t skipped = 0; |
5608 | 975 |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
976 for (size_t i = 0; i < response.GetSize(); i++) |
5608 | 977 { |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
978 const FindResponse::Resource& resource = response.GetResourceByIndex(i); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
979 |
5774
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
980 #if 0 |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
981 { |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
982 Json::Value v; |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
983 resource.DebugExport(v, request_); |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
984 std::cout << v.toStyledString(); |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
985 } |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
986 #endif |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
987 |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
988 DicomMap outRequestedTags; |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
989 |
5789 | 990 if (HasRequestedTags()) |
5608 | 991 { |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
992 std::set<DicomTag> remainingRequestedTags = requestedTags_; // at this point, all requested tags are "missing" |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
993 |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
994 InjectComputedTags(outRequestedTags, resource); |
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
995 Toolbox::RemoveSets(remainingRequestedTags, requestedComputedTags_); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
996 |
5789 | 997 InjectRequestedTags(outRequestedTags, remainingRequestedTags, resource, ResourceType_Patient); |
998 InjectRequestedTags(outRequestedTags, remainingRequestedTags, resource, ResourceType_Study); | |
999 InjectRequestedTags(outRequestedTags, remainingRequestedTags, resource, ResourceType_Series); | |
1000 InjectRequestedTags(outRequestedTags, remainingRequestedTags, resource, ResourceType_Instance); | |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
1001 |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
1002 if (!remainingRequestedTags.empty()) |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1003 { |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1004 if (!allowStorageAccess_) |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1005 { |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1006 throw OrthancException(ErrorCode_BadSequenceOfCalls, |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1007 "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
|
1008 } |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1009 else |
5610
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
1010 { |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
1011 ReadMissingTagsFromStorageArea(outRequestedTags, context, request_, resource, remainingRequestedTags); |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1012 } |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1013 } |
5764 | 1014 |
1015 std::string mainDicomTagsSignature; | |
1016 if (isWarning002Enabled && | |
1017 resource.LookupMetadata(mainDicomTagsSignature, resource.GetLevel(), MetadataType_MainDicomTagsSignature) && | |
1018 mainDicomTagsSignature != DicomMap::GetMainDicomTagsSignature(resource.GetLevel())) | |
1019 { | |
1020 LOG(WARNING) << "W002: " << Orthanc::GetResourceTypeText(resource.GetLevel(), false , false) | |
5789 | 1021 << " has been stored with another version of Main Dicom Tags list, you should POST to /" |
1022 << Orthanc::GetResourceTypeText(resource.GetLevel(), true, false) | |
1023 << "/" << resource.GetIdentifier() | |
1024 << "/reconstruct to update the list of tags saved in DB or run the Housekeeper plugin. Some MainDicomTags might be missing from this answer."; | |
5764 | 1025 } |
5789 | 1026 else if (isWarning004Enabled && |
1027 request_.IsRetrieveMetadata() && | |
5787
42ef98bb3c13
Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents:
5774
diff
changeset
|
1028 !resource.LookupMetadata(mainDicomTagsSignature, resource.GetLevel(), MetadataType_MainDicomTagsSignature)) |
42ef98bb3c13
Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents:
5774
diff
changeset
|
1029 { |
5789 | 1030 LOG(WARNING) << "W004: " << Orthanc::GetResourceTypeText(resource.GetLevel(), false , false) |
1031 << " has been stored with an old Orthanc version and does not have a MainDicomTagsSignature, you should POST to /" | |
1032 << Orthanc::GetResourceTypeText(resource.GetLevel(), true, false) | |
1033 << "/" << resource.GetIdentifier() | |
1034 << "/reconstruct to update the list of tags saved in DB or run the Housekeeper plugin. Some MainDicomTags might be missing from this answer."; | |
5787
42ef98bb3c13
Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents:
5774
diff
changeset
|
1035 } |
5764 | 1036 |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1037 } |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1038 |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1039 bool match = true; |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1040 |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1041 if (lookup_.get() != NULL) |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1042 { |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1043 DicomMap tags; |
5690
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5689
diff
changeset
|
1044 resource.GetAllMainDicomTags(tags); |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
1045 tags.Merge(outRequestedTags); |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1046 match = lookup_->IsMatch(tags); |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1047 } |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1048 |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1049 if (match) |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1050 { |
5693 | 1051 if (pagingMode_ == PagingMode_FullDatabase) |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1052 { |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
1053 visitor.Apply(resource, outRequestedTags); |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1054 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1055 else |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1056 { |
5693 | 1057 if (hasLimitsSince_ && |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1058 skipped < limitsSince_) |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1059 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1060 skipped++; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1061 } |
5693 | 1062 else if (hasLimitsCount_ && |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1063 countResults >= limitsCount_) |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1064 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1065 // Too many results, don't mark as complete |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1066 complete = false; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1067 break; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1068 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1069 else |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1070 { |
5788
61c9e5df64d7
handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents:
5787
diff
changeset
|
1071 visitor.Apply(resource, outRequestedTags); |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1072 countResults++; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1073 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1074 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1075 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1076 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1077 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1078 if (complete) |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1079 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1080 visitor.MarkAsComplete(); |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1081 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1082 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1083 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1084 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1085 void ResourceFinder::Execute(Json::Value& target, |
5709
476b1db52110
removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5702
diff
changeset
|
1086 ServerContext& context, |
5713
d851a54e49b7
removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5709
diff
changeset
|
1087 DicomToJsonFormat format, |
d851a54e49b7
removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5709
diff
changeset
|
1088 bool includeAllMetadata) const |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1089 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1090 class Visitor : public IVisitor |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1091 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1092 private: |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1093 const ResourceFinder& that_; |
5709
476b1db52110
removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5702
diff
changeset
|
1094 ServerIndex& index_; |
476b1db52110
removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5702
diff
changeset
|
1095 Json::Value& target_; |
476b1db52110
removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5702
diff
changeset
|
1096 DicomToJsonFormat format_; |
476b1db52110
removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5702
diff
changeset
|
1097 bool hasRequestedTags_; |
5713
d851a54e49b7
removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5709
diff
changeset
|
1098 bool includeAllMetadata_; |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1099 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1100 public: |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1101 Visitor(const ResourceFinder& that, |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1102 ServerIndex& index, |
5696
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5694
diff
changeset
|
1103 Json::Value& target, |
5709
476b1db52110
removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5702
diff
changeset
|
1104 DicomToJsonFormat format, |
5713
d851a54e49b7
removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5709
diff
changeset
|
1105 bool hasRequestedTags, |
d851a54e49b7
removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5709
diff
changeset
|
1106 bool includeAllMetadata) : |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1107 that_(that), |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1108 index_(index), |
5696
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5694
diff
changeset
|
1109 target_(target), |
5709
476b1db52110
removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5702
diff
changeset
|
1110 format_(format), |
5713
d851a54e49b7
removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5709
diff
changeset
|
1111 hasRequestedTags_(hasRequestedTags), |
d851a54e49b7
removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5709
diff
changeset
|
1112 includeAllMetadata_(includeAllMetadata) |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1113 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1114 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1115 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1116 virtual void Apply(const FindResponse::Resource& resource, |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1117 const DicomMap& requestedTags) ORTHANC_OVERRIDE |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1118 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1119 if (that_.expand_) |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1120 { |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1121 Json::Value item; |
5713
d851a54e49b7
removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5709
diff
changeset
|
1122 that_.Expand(item, resource, index_, format_, includeAllMetadata_); |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1123 |
5696
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5694
diff
changeset
|
1124 if (hasRequestedTags_) |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1125 { |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1126 static const char* const REQUESTED_TAGS = "RequestedTags"; |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1127 item[REQUESTED_TAGS] = Json::objectValue; |
5709
476b1db52110
removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5702
diff
changeset
|
1128 FromDcmtkBridge::ToJson(item[REQUESTED_TAGS], requestedTags, format_); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
1129 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
1130 |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1131 target_.append(item); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5608
diff
changeset
|
1132 } |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1133 else |
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1134 { |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1135 target_.append(resource.GetIdentifier()); |
5686
11575590e493
integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5682
diff
changeset
|
1136 } |
5608 | 1137 } |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1138 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1139 virtual void MarkAsComplete() ORTHANC_OVERRIDE |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1140 { |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1141 } |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1142 }; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1143 |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1144 target = Json::arrayValue; |
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1145 |
5789 | 1146 Visitor visitor(*this, context.GetIndex(), target, format, HasRequestedTags(), includeAllMetadata); |
5688
d0a264b803f1
first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5686
diff
changeset
|
1147 Execute(visitor, context); |
5608 | 1148 } |
5615
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1149 |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1150 |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1151 bool ResourceFinder::ExecuteOneResource(Json::Value& target, |
5709
476b1db52110
removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5702
diff
changeset
|
1152 ServerContext& context, |
5713
d851a54e49b7
removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5709
diff
changeset
|
1153 DicomToJsonFormat format, |
d851a54e49b7
removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5709
diff
changeset
|
1154 bool includeAllMetadata) const |
5615
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1155 { |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1156 Json::Value answer; |
5713
d851a54e49b7
removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5709
diff
changeset
|
1157 Execute(answer, context, format, includeAllMetadata); |
5615
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1158 |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1159 if (answer.type() != Json::arrayValue) |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1160 { |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1161 throw OrthancException(ErrorCode_InternalError); |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1162 } |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1163 else if (answer.size() > 1) |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1164 { |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1165 throw OrthancException(ErrorCode_DatabasePlugin); |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1166 } |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1167 else if (answer.empty()) |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1168 { |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1169 // 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
|
1170 return false; |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1171 } |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1172 else |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1173 { |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1174 target = answer[0]; |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1175 return true; |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1176 } |
a10978a5e65c
expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5612
diff
changeset
|
1177 } |
5608 | 1178 } |