annotate OrthancServer/Sources/ResourceFinder.cpp @ 5856:d1dea8ad74a6 find-refactoring

implement StorageAccessOnFind for answers
author Alain Mazy <am@orthanc.team>
date Mon, 04 Nov 2024 21:51:24 +0100
parents aeb9f63923b1
children 66fd63b8601e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 *
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * This program is free software: you can redistribute it and/or
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * modify it under the terms of the GNU General Public License as
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * published by the Free Software Foundation, either version 3 of the
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * License, or (at your option) any later version.
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 *
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * General Public License for more details.
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 *
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "PrecompiledHeadersServer.h"
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "ResourceFinder.h"
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include "../../OrthancFramework/Sources/OrthancException.h"
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #include "ServerContext.h"
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "ServerIndex.h"
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 namespace Orthanc
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 SeriesStatus ResourceFinder::GetSeriesStatus(uint32_t& expectedNumberOfInstances,
5689
c14776d25491 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5688
diff changeset
134 const FindResponse::Resource& resource)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 {
5689
c14776d25491 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5688
diff changeset
136 if (resource.GetLevel() != ResourceType_Series)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 throw OrthancException(ErrorCode_BadParameterType);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 std::string s;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 if (!resource.LookupMetadata(s, ResourceType_Series, MetadataType_Series_ExpectedNumberOfInstances) ||
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 !SerializationToolbox::ParseUnsignedInteger32(expectedNumberOfInstances, s))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 return SeriesStatus_Unknown;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147
5674
74f3aab95886 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5672
diff changeset
148 std::set<std::string> values;
74f3aab95886 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5672
diff changeset
149 resource.GetChildrenMetadataValues(values, ResourceType_Instance, MetadataType_Instance_IndexInSeries);
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 std::set<int64_t> instances;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
5674
74f3aab95886 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5672
diff changeset
153 for (std::set<std::string>::const_iterator
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 it = values.begin(); it != values.end(); ++it)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 int64_t index;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 if (!SerializationToolbox::ParseInteger64(index, *it))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 return SeriesStatus_Unknown;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 if (index <= 0 ||
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 index > static_cast<int64_t>(expectedNumberOfInstances))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 // Out-of-range instance index
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 return SeriesStatus_Inconsistent;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 if (instances.find(index) != instances.end())
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 // Twice the same instance index
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 return SeriesStatus_Inconsistent;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 instances.insert(index);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 if (instances.size() == static_cast<size_t>(expectedNumberOfInstances))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 return SeriesStatus_Complete;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 else
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 return SeriesStatus_Missing;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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;
5790
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
193 if (resource.LookupMetadata(serializedSequences, level, MetadataType_MainDicomSequences))
5788
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
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 void ResourceFinder::Expand(Json::Value& target,
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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,
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
213 DicomToJsonFormat format) const
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 /**
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 * This method closely follows "SerializeExpandedResource()" in
5689
c14776d25491 simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5688
diff changeset
217 * "ServerContext.cpp" from Orthanc 1.12.4.
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 **/
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
220 if (responseContent_ == ResponseContentFlags_ID)
5713
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
221 {
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
222 throw OrthancException(ErrorCode_BadSequenceOfCalls);
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
223 }
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
224
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 if (resource.GetLevel() != request_.GetLevel())
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 throw OrthancException(ErrorCode_InternalError);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 target = Json::objectValue;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 target["Type"] = GetResourceTypeText(resource.GetLevel(), false, true);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 target["ID"] = resource.GetIdentifier();
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
235 if (responseContent_ & ResponseContentFlags_Parent)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 {
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
237 switch (resource.GetLevel())
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
238 {
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
239 case ResourceType_Patient:
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
240 break;
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
242 case ResourceType_Study:
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
243 target["ParentPatient"] = resource.GetParentIdentifier();
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
244 break;
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
246 case ResourceType_Series:
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
247 target["ParentStudy"] = resource.GetParentIdentifier();
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
248 break;
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
250 case ResourceType_Instance:
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
251 target["ParentSeries"] = resource.GetParentIdentifier();
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
252 break;
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
254 default:
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
255 throw OrthancException(ErrorCode_InternalError);
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
256 }
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
259 if ((responseContent_ & ResponseContentFlags_Children) && (resource.GetLevel() != ResourceType_Instance))
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 {
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
261 const std::set<std::string>& children = resource.GetChildrenIdentifiers(GetChildResourceType(resource.GetLevel()));
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 Json::Value c = Json::arrayValue;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 for (std::set<std::string>::const_iterator
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 it = children.begin(); it != children.end(); ++it)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 c.append(*it);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 switch (resource.GetLevel())
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 case ResourceType_Patient:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 target["Studies"] = c;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 case ResourceType_Study:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 target["Series"] = c;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 case ResourceType_Series:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 target["Instances"] = c;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 default:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 throw OrthancException(ErrorCode_InternalError);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 switch (resource.GetLevel())
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 case ResourceType_Patient:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 case ResourceType_Study:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 case ResourceType_Series:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 {
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
297 if ((responseContent_ & ResponseContentFlags_Status) || (responseContent_ & ResponseContentFlags_MetadataLegacy) )
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
298 {
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
299 uint32_t expectedNumberOfInstances;
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
300 SeriesStatus status = GetSeriesStatus(expectedNumberOfInstances, resource);
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
301
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
302 if (responseContent_ & ResponseContentFlags_Status )
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
303 {
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
304 target["Status"] = EnumerationToString(status);
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
305 }
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
307 if (responseContent_ & ResponseContentFlags_MetadataLegacy)
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
308 {
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
309 static const char* const EXPECTED_NUMBER_OF_INSTANCES = "ExpectedNumberOfInstances";
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
310
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
311 if (status == SeriesStatus_Unknown)
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
312 {
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
313 target[EXPECTED_NUMBER_OF_INSTANCES] = Json::nullValue;
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
314 }
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
315 else
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
316 {
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
317 target[EXPECTED_NUMBER_OF_INSTANCES] = expectedNumberOfInstances;
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
318 }
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
319 }
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 case ResourceType_Instance:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 {
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
326 if (responseContent_ & ResponseContentFlags_AttachmentsLegacy)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 {
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
328 FileInfo info;
5852
ea547160f27e StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5840
diff changeset
329 int64_t revision;
ea547160f27e StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5840
diff changeset
330 if (resource.LookupAttachment(info, revision, FileContentType_Dicom))
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
331 {
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
332 target["FileSize"] = static_cast<Json::UInt64>(info.GetUncompressedSize());
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
333 target["FileUuid"] = info.GetUuid();
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
334 }
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
335 else
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
336 {
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
337 throw OrthancException(ErrorCode_InternalError);
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
338 }
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
341 if (responseContent_ & ResponseContentFlags_MetadataLegacy)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 {
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
343 static const char* const INDEX_IN_SERIES = "IndexInSeries";
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
344
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
345 std::string s;
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
346 uint32_t indexInSeries;
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
347 if (resource.LookupMetadata(s, ResourceType_Instance, MetadataType_Instance_IndexInSeries) &&
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
348 SerializationToolbox::ParseUnsignedInteger32(indexInSeries, s))
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
349 {
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
350 target[INDEX_IN_SERIES] = indexInSeries;
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
351 }
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
352 else
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
353 {
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
354 target[INDEX_IN_SERIES] = Json::nullValue;
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
355 }
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 default:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361 throw OrthancException(ErrorCode_InternalError);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 std::string s;
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
365 if (responseContent_ & ResponseContentFlags_MetadataLegacy)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 {
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
367 if (resource.LookupMetadata(s, resource.GetLevel(), MetadataType_AnonymizedFrom))
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
368 {
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
369 target["AnonymizedFrom"] = s;
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
370 }
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
372 if (resource.LookupMetadata(s, resource.GetLevel(), MetadataType_ModifiedFrom))
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
373 {
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
374 target["ModifiedFrom"] = s;
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
375 }
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
377 if (resource.GetLevel() == ResourceType_Patient ||
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
378 resource.GetLevel() == ResourceType_Study ||
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
379 resource.GetLevel() == ResourceType_Series)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380 {
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
381 if (resource.LookupMetadata(s, resource.GetLevel(), MetadataType_LastUpdate))
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
382 {
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
383 target["LastUpdate"] = s;
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
384 }
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
388 if (responseContent_ & ResponseContentFlags_IsStable)
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
389 {
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
390 if (resource.GetLevel() == ResourceType_Patient ||
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
391 resource.GetLevel() == ResourceType_Study ||
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
392 resource.GetLevel() == ResourceType_Series)
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
393 {
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
394 target["IsStable"] = !index.IsUnstableResource(resource.GetLevel(), resource.GetInternalId());
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
395 }
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
396 }
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
397
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
398 if (responseContent_ & ResponseContentFlags_MainDicomTags)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399 {
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
400 DicomMap allMainDicomTags;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
401 resource.GetMainDicomTags(allMainDicomTags, resource.GetLevel());
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
402
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
403 // read all main sequences from DB
5788
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
404 GetMainDicomSequencesFromMetadata(allMainDicomTags, resource, resource.GetLevel());
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
405
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406 static const char* const MAIN_DICOM_TAGS = "MainDicomTags";
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 static const char* const PATIENT_MAIN_DICOM_TAGS = "PatientMainDicomTags";
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
409 // TODO-FIND : Ignore "null" values
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 DicomMap levelMainDicomTags;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 allMainDicomTags.ExtractResourceInformation(levelMainDicomTags, resource.GetLevel());
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414 target[MAIN_DICOM_TAGS] = Json::objectValue;
5709
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
415 FromDcmtkBridge::ToJson(target[MAIN_DICOM_TAGS], levelMainDicomTags, format);
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417 if (resource.GetLevel() == ResourceType_Study)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419 DicomMap patientMainDicomTags;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 allMainDicomTags.ExtractPatientInformation(patientMainDicomTags);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 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
423 FromDcmtkBridge::ToJson(target[PATIENT_MAIN_DICOM_TAGS], patientMainDicomTags, format);
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
427 if (responseContent_ & ResponseContentFlags_Labels)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 Json::Value labels = Json::arrayValue;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 for (std::set<std::string>::const_iterator
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
432 it = resource.GetLabels().begin(); it != resource.GetLabels().end(); ++it)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434 labels.append(*it);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437 target["Labels"] = labels;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
440 if (responseContent_ & ResponseContentFlags_Metadata) // new in Orthanc 1.12.4
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
442 const std::map<MetadataType, std::string>& m = resource.GetMetadata(resource.GetLevel());
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 Json::Value metadata = Json::objectValue;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
446 for (std::map<MetadataType, std::string>::const_iterator it = m.begin(); it != m.end(); ++it)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
447 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 metadata[EnumerationToString(it->first)] = it->second;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
449 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
450
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
451 target["Metadata"] = metadata;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452 }
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
453
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
454 if (responseContent_ & ResponseContentFlags_Attachments) // new in Orthanc 1.12.5
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
455 {
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
456 const std::map<FileContentType, FileInfo>& attachments = resource.GetAttachments();
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
457
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
458 target["Attachments"] = Json::arrayValue;
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
459
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
460 for (std::map<FileContentType, FileInfo>::const_iterator it = attachments.begin(); it != attachments.end(); ++it)
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
461 {
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
462 Json::Value attachment = Json::objectValue;
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
463 attachment["Uuid"] = it->second.GetUuid();
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
464 attachment["ContentType"] = it->second.GetContentType();
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
465 attachment["UncompressedSize"] = Json::Value::UInt64(it->second.GetUncompressedSize());
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
466 attachment["CompressedSize"] = Json::Value::UInt64(it->second.GetCompressedSize());
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
467 attachment["UncompressedMD5"] = it->second.GetUncompressedMD5();
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
468 attachment["CompressedMD5"] = it->second.GetCompressedMD5();
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
469
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
470 target["Attachments"].append(attachment);
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
471 }
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
472 }
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475
5840
b24b61331566 pagination: fixed compat with ODBC that does not support ExtendedFind
Alain Mazy <am@orthanc.team>
parents: 5837
diff changeset
476 void ResourceFinder::UpdateRequestLimits(ServerContext& context)
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
477 {
5840
b24b61331566 pagination: fixed compat with ODBC that does not support ExtendedFind
Alain Mazy <am@orthanc.team>
parents: 5837
diff changeset
478 if (context.GetIndex().HasFindSupport()) // in this case, limits are fully implemented in DB
5835
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
479 {
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
480 pagingMode_ = PagingMode_FullDatabase;
5690
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
481
5835
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
482 if (hasLimitsSince_ || hasLimitsCount_)
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
483 {
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
484 pagingMode_ = PagingMode_FullDatabase;
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
485 if (databaseLimits_ != 0 && limitsCount_ > databaseLimits_)
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
486 {
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
487 LOG(WARNING) << "ResourceFinder: 'Limit' is larger than LimitFindResults/LimitFindInstances configurations, using limit fron the configuration file";
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
488 limitsCount_ = databaseLimits_;
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
489 }
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
490
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
491 request_.SetLimits(limitsSince_, limitsCount_);
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
492 }
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
493 else if (databaseLimits_ != 0)
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
494 {
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
495 request_.SetLimits(0, databaseLimits_);
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
496 }
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
497
5690
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
498 }
5692
7c11a71927a9 improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5690
diff changeset
499 else
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
500 {
5835
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
501 // By default, use manual paging
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
502 pagingMode_ = PagingMode_FullManual;
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
503
5835
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
504 if (databaseLimits_ != 0)
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
505 {
5835
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
506 request_.SetLimits(0, databaseLimits_ + 1);
5692
7c11a71927a9 improved handling of limits
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5690
diff changeset
507 }
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
508 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
509 {
5835
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
510 request_.ClearLimits();
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
511 }
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
512
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
513 if (lookup_.get() == NULL &&
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
514 (hasLimitsSince_ || hasLimitsCount_))
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
515 {
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
516 pagingMode_ = PagingMode_FullDatabase;
5835
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
517 request_.SetLimits(limitsSince_, limitsCount_);
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
518 }
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
519
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
520 if (lookup_.get() != NULL &&
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
521 isSimpleLookup_ &&
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
522 (hasLimitsSince_ || hasLimitsCount_))
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
523 {
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
524 /**
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
525 * TODO-FIND: "IDatabaseWrapper::ApplyLookupResources()" only
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
526 * accept the "limit" argument. The "since" must be implemented
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
527 * manually.
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
528 **/
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
529
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
530 if (hasLimitsSince_ &&
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
531 limitsSince_ != 0)
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
532 {
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
533 pagingMode_ = PagingMode_ManualSkip;
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
534 request_.SetLimits(0, limitsCount_ + limitsSince_);
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
535 }
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
536 else
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
537 {
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
538 pagingMode_ = PagingMode_FullDatabase;
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
539 request_.SetLimits(0, limitsCount_);
7c61bdf925fc simplified limit handling + Limit argument is now clipped by LimitFindResults
Alain Mazy <am@orthanc.team>
parents: 5829
diff changeset
540 }
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
541 }
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
542 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
543 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
544
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
545
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
546 ResourceFinder::ResourceFinder(ResourceType level,
5856
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
547 ResponseContentFlags responseContent,
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
548 FindStorageAccessMode storageAccessMode) :
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
549 request_(level),
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
550 databaseLimits_(0),
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
551 isSimpleLookup_(true),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
552 pagingMode_(PagingMode_FullManual),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
553 hasLimitsSince_(false),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
554 hasLimitsCount_(false),
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
555 limitsSince_(0),
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
556 limitsCount_(0),
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
557 responseContent_(responseContent),
5856
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
558 storageAccessMode_(storageAccessMode),
5789
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
559 isWarning002Enabled_(false),
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
560 isWarning004Enabled_(false),
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
561 isWarning005Enabled_(false)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
562 {
5789
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
563 {
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
564 OrthancConfiguration::ReaderLock lock;
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
565 isWarning002Enabled_ = lock.GetConfiguration().IsWarningEnabled(Warnings_002_InconsistentDicomTagsInDb);
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
566 isWarning004Enabled_ = lock.GetConfiguration().IsWarningEnabled(Warnings_004_NoMainDicomTagsSignature);
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
567 isWarning005Enabled_ = lock.GetConfiguration().IsWarningEnabled(Warnings_005_RequestingTagFromLowerResourceLevel);
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
568 }
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
569
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
570 request_.SetRetrieveMainDicomTags(responseContent_ & ResponseContentFlags_MainDicomTags);
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
571 request_.SetRetrieveMetadata((responseContent_ & ResponseContentFlags_Metadata) || (responseContent_ & ResponseContentFlags_MetadataLegacy));
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
572 request_.SetRetrieveLabels(responseContent_ & ResponseContentFlags_Labels);
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
573
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
574 switch (level)
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
575 {
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
576 case ResourceType_Patient:
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
577 request_.GetChildrenSpecification(ResourceType_Study).SetRetrieveIdentifiers(responseContent_ & ResponseContentFlags_Children);
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
578 request_.SetRetrieveAttachments(responseContent_ & ResponseContentFlags_Attachments);
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
579 break;
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
580
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
581 case ResourceType_Study:
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
582 request_.GetChildrenSpecification(ResourceType_Series).SetRetrieveIdentifiers(responseContent_ & ResponseContentFlags_Children);
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
583 request_.SetRetrieveParentIdentifier(responseContent_ & ResponseContentFlags_Parent);
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
584 request_.SetRetrieveAttachments(responseContent_ & ResponseContentFlags_Attachments);
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
585 break;
5621
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
586
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
587 case ResourceType_Series:
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
588 if (responseContent_ & ResponseContentFlags_Status)
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
589 {
5676
b744a2cf408a shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5674
diff changeset
590 request_.GetChildrenSpecification(ResourceType_Instance).AddMetadata(MetadataType_Instance_IndexInSeries); // required for the SeriesStatus
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
591 }
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
592 request_.GetChildrenSpecification(ResourceType_Instance).SetRetrieveIdentifiers(responseContent_ & ResponseContentFlags_Children);
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
593 request_.SetRetrieveParentIdentifier(responseContent_ & ResponseContentFlags_Parent);
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
594 request_.SetRetrieveAttachments(responseContent_ & ResponseContentFlags_Attachments);
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
595 break;
5621
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
596
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
597 case ResourceType_Instance:
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
598 request_.SetRetrieveAttachments((responseContent_ & ResponseContentFlags_AttachmentsLegacy) // for FileSize & FileUuid
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
599 || (responseContent_ & ResponseContentFlags_Attachments));
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
600 request_.SetRetrieveParentIdentifier(true);
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
601 break;
5621
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5620
diff changeset
602
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
603 default:
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
604 throw OrthancException(ErrorCode_ParameterOutOfRange);
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
606 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
607
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
608
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
609 void ResourceFinder::SetDatabaseLimits(uint64_t limits)
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
610 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
611 databaseLimits_ = limits;
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
612 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
613
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
614
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
615 void ResourceFinder::SetLimitsSince(uint64_t since)
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
616 {
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
617 if (hasLimitsSince_)
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
618 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
619 throw OrthancException(ErrorCode_BadSequenceOfCalls);
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
620 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
621 else
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
622 {
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
623 hasLimitsSince_ = true;
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
624 limitsSince_ = since;
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
625 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
626 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
627
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
628
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
629 void ResourceFinder::SetLimitsCount(uint64_t count)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
630 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
631 if (hasLimitsCount_)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
632 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
633 throw OrthancException(ErrorCode_BadSequenceOfCalls);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
634 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
635 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
636 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
637 hasLimitsCount_ = true;
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
638 limitsCount_ = count;
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
639 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
640 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
641
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
642
5682
fd4c5e064cbe started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5676
diff changeset
643 void ResourceFinder::SetDatabaseLookup(const DatabaseLookup& lookup)
fd4c5e064cbe started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5676
diff changeset
644 {
5694
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
645 MainDicomTagsRegistry registry;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
646
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
647 lookup_.reset(lookup.Clone());
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
648
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
649 for (size_t i = 0; i < lookup.GetConstraintsCount(); i++)
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
650 {
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
651 DicomTag tag = lookup.GetConstraint(i).GetTag();
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
652 if (IsComputedTag(tag))
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
653 {
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
654 AddRequestedTag(tag);
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
655 }
5694
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
656 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
657 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
658 ResourceType level;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
659 DicomTagType tagType;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
660 registry.LookupTag(level, tagType, tag);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
661 if (tagType == DicomTagType_Generic)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
662 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
663 AddRequestedTag(tag);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
664 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5693
diff changeset
665 }
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
666 }
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
667
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
668 isSimpleLookup_ = registry.NormalizeLookup(request_.GetDicomTagConstraints(), lookup, request_.GetLevel());
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
669
5690
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
670 // "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
671
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
672 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
673 {
5828
7030fa489669 tools/find: QueryMetadata
Alain Mazy <am@orthanc.team>
parents: 5795
diff changeset
674 const DatabaseDicomTagConstraint& constraint = request_.GetDicomTagConstraints().GetConstraint(i);
5690
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
675 if (constraint.GetLevel() == request_.GetLevel())
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
676 {
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
677 request_.SetRetrieveMainDicomTags(true);
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
678 }
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
679 else if (IsResourceLevelAboveOrEqual(constraint.GetLevel(), request_.GetLevel()))
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
680 {
5690
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
681 request_.GetParentSpecification(constraint.GetLevel()).SetRetrieveMainDicomTags(true);
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
682 }
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
683 else
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
684 {
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
685 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
686 << " 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
687 << 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
688 }
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
689
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
690 if (IsComputedTag(constraint.GetTag()))
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
691 {
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
692 // Sanity check
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
693 throw OrthancException(ErrorCode_InternalError);
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
694 }
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
695 }
5682
fd4c5e064cbe started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5676
diff changeset
696 }
fd4c5e064cbe started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5676
diff changeset
697
fd4c5e064cbe started refactoring of ServerContext::Apply()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5676
diff changeset
698
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
699 void ResourceFinder::AddRequestedTag(const DicomTag& tag)
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
700 {
5788
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
701 requestedTags_.insert(tag);
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
702
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
703 if (DicomMap::IsMainDicomTag(tag, ResourceType_Patient))
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
704 {
5620
4bfd885fb45f optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5619
diff changeset
705 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
706 {
5697
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
707 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
708 }
4bfd885fb45f optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5619
diff changeset
709 else
4bfd885fb45f optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5619
diff changeset
710 {
4bfd885fb45f optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5619
diff changeset
711 /**
4bfd885fb45f optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5619
diff changeset
712 * 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
713 * 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
714 **/
5697
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
715 if (request_.GetLevel() == ResourceType_Study)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
716 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
717 request_.SetRetrieveMainDicomTags(true);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
718 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
719 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
720 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
721 request_.GetParentSpecification(ResourceType_Study).SetRetrieveMainDicomTags(true);
5790
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
722 request_.GetParentSpecification(ResourceType_Study).SetRetrieveMetadata(true); // to get the MainDicomSequences
5697
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
723 }
5620
4bfd885fb45f optimization as patient-level tags are copied at study level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5619
diff changeset
724 }
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
725 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
726 else if (DicomMap::IsMainDicomTag(tag, ResourceType_Study))
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
727 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
728 if (request_.GetLevel() == ResourceType_Patient)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
729 {
5789
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
730 if (isWarning005Enabled_)
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
731 {
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
732 LOG(WARNING) << "W005: Requested tag " << tag.Format()
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
733 << " should only be read at the study, series, or instance level";
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
734 }
5788
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
735 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
736 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
737 else
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
738 {
5697
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
739 if (request_.GetLevel() == ResourceType_Study)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
740 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
741 request_.SetRetrieveMainDicomTags(true);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
742 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
743 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
744 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
745 request_.GetParentSpecification(ResourceType_Study).SetRetrieveMainDicomTags(true);
5790
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
746 request_.GetParentSpecification(ResourceType_Study).SetRetrieveMetadata(true); // to get the MainDicomSequences
5697
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
747 }
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
748 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
749 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
750 else if (DicomMap::IsMainDicomTag(tag, ResourceType_Series))
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
751 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
752 if (request_.GetLevel() == ResourceType_Patient ||
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
753 request_.GetLevel() == ResourceType_Study)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
754 {
5789
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
755 if (isWarning005Enabled_)
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
756 {
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
757 LOG(WARNING) << "W005: Requested tag " << tag.Format()
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
758 << " should only be read at the series or instance level";
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
759 }
5788
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
760 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
761 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
762 else
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
763 {
5697
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
764 if (request_.GetLevel() == ResourceType_Series)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
765 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
766 request_.SetRetrieveMainDicomTags(true);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
767 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
768 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
769 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
770 request_.GetParentSpecification(ResourceType_Series).SetRetrieveMainDicomTags(true);
5790
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
771 request_.GetParentSpecification(ResourceType_Series).SetRetrieveMetadata(true); // to get the MainDicomSequences
5697
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5696
diff changeset
772 }
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
773 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
774 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
775 else if (DicomMap::IsMainDicomTag(tag, ResourceType_Instance))
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
776 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
777 if (request_.GetLevel() == ResourceType_Patient ||
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
778 request_.GetLevel() == ResourceType_Study ||
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
779 request_.GetLevel() == ResourceType_Series)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
780 {
5789
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
781 if (isWarning005Enabled_)
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
782 {
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
783 LOG(WARNING) << "W005: Requested tag " << tag.Format()
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
784 << " should only be read at the instance level";
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
785 }
5788
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
786 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
787 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
788 else
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
789 {
5699
e8e028aed89f c-find tests pass using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5697
diff changeset
790 request_.SetRetrieveMainDicomTags(true);
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
791 }
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
792 }
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
793 else if (tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES)
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
794 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
795 ConfigureChildrenCountComputedTag(tag, ResourceType_Patient, ResourceType_Study);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
796 }
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
797 else if (tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES)
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
798 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
799 ConfigureChildrenCountComputedTag(tag, ResourceType_Patient, ResourceType_Series);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
800 }
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
801 else if (tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES)
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
802 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
803 ConfigureChildrenCountComputedTag(tag, ResourceType_Patient, ResourceType_Instance);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
804 }
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
805 else if (tag == DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES)
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
806 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
807 ConfigureChildrenCountComputedTag(tag, ResourceType_Study, ResourceType_Series);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
808 }
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
809 else if (tag == DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES)
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
810 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
811 ConfigureChildrenCountComputedTag(tag, ResourceType_Study, ResourceType_Instance);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
812 }
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
813 else if (tag == DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES)
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
814 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
815 ConfigureChildrenCountComputedTag(tag, ResourceType_Series, ResourceType_Instance);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
816 }
5668
bd1352bd9d82 configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5667
diff changeset
817 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
818 {
bd1352bd9d82 configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5667
diff changeset
819 requestedComputedTags_.insert(tag);
5676
b744a2cf408a shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5674
diff changeset
820 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
821 }
bd1352bd9d82 configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5667
diff changeset
822 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
823 {
bd1352bd9d82 configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5667
diff changeset
824 requestedComputedTags_.insert(tag);
5752
717acb0ea546 fix DICOMWeb integration tests
Alain Mazy <am@orthanc.team>
parents: 5714
diff changeset
825 if (request_.GetLevel() < ResourceType_Series)
717acb0ea546 fix DICOMWeb integration tests
Alain Mazy <am@orthanc.team>
parents: 5714
diff changeset
826 {
717acb0ea546 fix DICOMWeb integration tests
Alain Mazy <am@orthanc.team>
parents: 5714
diff changeset
827 request_.GetChildrenSpecification(ResourceType_Series).AddMainDicomTag(DICOM_TAG_MODALITY);
717acb0ea546 fix DICOMWeb integration tests
Alain Mazy <am@orthanc.team>
parents: 5714
diff changeset
828 }
717acb0ea546 fix DICOMWeb integration tests
Alain Mazy <am@orthanc.team>
parents: 5714
diff changeset
829 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
830 {
717acb0ea546 fix DICOMWeb integration tests
Alain Mazy <am@orthanc.team>
parents: 5714
diff changeset
831 request_.GetParentSpecification(ResourceType_Series).SetRetrieveMainDicomTags(true);
717acb0ea546 fix DICOMWeb integration tests
Alain Mazy <am@orthanc.team>
parents: 5714
diff changeset
832 }
5668
bd1352bd9d82 configuring requests for ModalitiesInStudy and SOPClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5667
diff changeset
833 }
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
834 else if (tag == DICOM_TAG_INSTANCE_AVAILABILITY)
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
835 {
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
836 requestedComputedTags_.insert(tag);
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
837 }
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
838 else
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
839 {
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
840 // This is neither a main DICOM tag, nor a computed DICOM tag:
5789
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
841 // We might need to access a DICOM file or the MainDicomSequences metadata
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
842
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
843 request_.SetRetrieveMetadata(true);
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
844
5610
d4b570834d3a adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
845 if (request_.GetLevel() != ResourceType_Instance)
d4b570834d3a adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
846 {
5772
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
847 request_.SetRetrieveOneInstanceMetadataAndAttachments(true);
5610
d4b570834d3a adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
848 }
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
849 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
850 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
851
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
852
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
853 void ResourceFinder::AddRequestedTags(const std::set<DicomTag>& tags)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
854 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
855 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
856 {
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
857 AddRequestedTag(*it);
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
858 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
859 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
860
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
861
5788
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
862 static void InjectRequestedTags(DicomMap& target,
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
863 std::set<DicomTag>& remainingRequestedTags /* in & out */,
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
864 const FindResponse::Resource& resource,
5788
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
865 ResourceType level/*,
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
866 const std::set<DicomTag>& tags*/)
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
867 {
5790
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
868 if (!remainingRequestedTags.empty() && level <= resource.GetLevel())
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
869 {
5787
42ef98bb3c13 Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents: 5774
diff changeset
870 std::set<DicomTag> savedMainDicomTags;
5790
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
871
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
872 DicomMap m;
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
873 resource.GetMainDicomTags(m, level); // read DicomTags from DB
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
874
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
875 if (resource.GetMetadata(level).size() > 0)
5787
42ef98bb3c13 Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents: 5774
diff changeset
876 {
5790
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
877 GetMainDicomSequencesFromMetadata(m, resource, level); // read DicomSequences from metadata
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
878
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
879 // 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
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
880
5795
9990b4140c1c fix unit tests
Alain Mazy <am@orthanc.team>
parents: 5794
diff changeset
881 std::string signature = DicomMap::GetDefaultMainDicomTagsSignatureFrom1_11(level); // default signature in case it's not in the metadata (= the signature for 1.11.0)
5790
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
882 if (resource.LookupMetadata(signature, level, MetadataType_MainDicomTagsSignature))
5787
42ef98bb3c13 Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents: 5774
diff changeset
883 {
5790
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
884 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
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
885 {
5795
9990b4140c1c fix unit tests
Alain Mazy <am@orthanc.team>
parents: 5794
diff changeset
886 signature += ";" + DicomMap::GetDefaultMainDicomTagsSignatureFrom1_11(ResourceType_Patient); // append the default signature (from before 1.11.0)
5790
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
887 }
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
888
a3d283f61304 improved handling of DicomSequences in parent
Alain Mazy <am@orthanc.team>
parents: 5789
diff changeset
889 FromDcmtkBridge::ParseListOfTags(savedMainDicomTags, signature);
5787
42ef98bb3c13 Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents: 5774
diff changeset
890 }
42ef98bb3c13 Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents: 5774
diff changeset
891 }
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
892
5788
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
893 std::set<DicomTag> copiedTags;
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
894 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
895 {
5788
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
896 if (target.CopyTagIfExists(m, *it))
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
897 {
5788
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
898 copiedTags.insert(*it);
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
899 }
5788
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
900 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
901 {
5788
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
902 copiedTags.insert(*it);
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
903 }
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5665
diff changeset
904 }
5788
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
905
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
906 Toolbox::RemoveSets(remainingRequestedTags, copiedTags);
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
907 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
908 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
909
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
910
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
911 static void ReadMissingTagsFromStorageArea(DicomMap& requestedTags,
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
912 ServerContext& context,
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
913 const FindRequest& request,
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
914 const FindResponse::Resource& resource,
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
915 const std::set<DicomTag>& missingTags)
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 OrthancConfiguration::ReaderLock lock;
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
918 if (lock.GetConfiguration().IsWarningEnabled(Warnings_001_TagsBeingReadFromStorage))
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 std::string missings;
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
921 FromDcmtkBridge::FormatListOfTags(missings, missingTags);
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
922
5699
e8e028aed89f c-find tests pass using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5697
diff changeset
923 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
924 << Orthanc::GetResourceTypeText(resource.GetLevel(), false, false)
5764
db4bd2f9e8d2 re-enable W002 again
Alain Mazy <am@orthanc.team>
parents: 5752
diff changeset
925 << " " << resource.GetIdentifier()
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
926 << ": " << missings;
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
927 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
928
5772
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
929 // 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
930 // 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
931
5772
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
932 Json::Value tmpDicomAsJson;
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
933
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
934 if (request.GetLevel() == ResourceType_Instance &&
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
935 request.IsRetrieveMetadata() &&
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
936 request.IsRetrieveAttachments())
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
937 {
5772
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
938 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
939
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
940 context.ReadDicomAsJson(tmpDicomAsJson, resource.GetIdentifier(), resource.GetMetadata(ResourceType_Instance),
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
941 resource.GetAttachments(), missingTags /* ignoreTagLength */);
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
942 }
5772
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
943 else if (request.GetLevel() != ResourceType_Instance &&
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
944 request.IsRetrieveOneInstanceMetadataAndAttachments())
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
945 {
5772
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
946 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
947
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
948 context.ReadDicomAsJson(tmpDicomAsJson, resource.GetOneInstancePublicId(), resource.GetOneInstanceMetadata(),
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
949 resource.GetOneInstanceAttachments(), missingTags /* ignoreTagLength */);
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
950 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
951 else
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
952 {
5772
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
953 // TODO-FIND: This fallback shouldn't be necessary
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
954
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
955 FindRequest requestDicomAttachment(request.GetLevel());
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
956 requestDicomAttachment.SetOrthancId(request.GetLevel(), resource.GetIdentifier());
5772
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
957
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
958 if (request.GetLevel() == ResourceType_Instance)
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
959 {
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
960 requestDicomAttachment.SetRetrieveMetadata(true);
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
961 requestDicomAttachment.SetRetrieveAttachments(true);
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
962 }
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
963 else
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
964 {
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
965 requestDicomAttachment.SetRetrieveOneInstanceMetadataAndAttachments(true);
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
966 }
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
967
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
968 FindResponse responseDicomAttachment;
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
969 context.GetIndex().ExecuteFind(responseDicomAttachment, requestDicomAttachment);
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
970
5772
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
971 if (responseDicomAttachment.GetSize() != 1)
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
972 {
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
973 throw OrthancException(ErrorCode_InexistentFile);
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
974 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
975 else
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
976 {
5772
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
977 const FindResponse::Resource& response = responseDicomAttachment.GetResourceByIndex(0);
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
978 const std::string instancePublicId = response.GetIdentifier();
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
979 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
980
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
981 if (request.GetLevel() == ResourceType_Instance)
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
982 {
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
983 context.ReadDicomAsJson(tmpDicomAsJson, response.GetIdentifier(), response.GetMetadata(ResourceType_Instance),
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
984 response.GetAttachments(), missingTags /* ignoreTagLength */);
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
985 }
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
986 else
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
987 {
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
988 context.ReadDicomAsJson(tmpDicomAsJson, response.GetOneInstancePublicId(), response.GetOneInstanceMetadata(),
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
989 response.GetOneInstanceAttachments(), missingTags /* ignoreTagLength */);
093a8693ba16 replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5764
diff changeset
990 }
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
991 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
992 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
993
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
994 DicomMap tmpDicomMap;
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
995 tmpDicomMap.FromDicomAsJson(tmpDicomAsJson, false /* append */, true /* parseSequences*/);
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
996
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
997 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
998 {
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
999 assert(!requestedTags.HasTag(*it));
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
1000 if (tmpDicomMap.HasTag(*it))
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
1001 {
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
1002 requestedTags.SetValue(*it, tmpDicomMap.GetValue(*it));
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
1003 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
1004 else
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
1005 {
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
1006 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
1007 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
1008 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
1009 }
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
1010
5837
82fc95cc168c /tools/count-resources
Alain Mazy <am@orthanc.team>
parents: 5835
diff changeset
1011 uint64_t ResourceFinder::Count(ServerContext& context) const
82fc95cc168c /tools/count-resources
Alain Mazy <am@orthanc.team>
parents: 5835
diff changeset
1012 {
82fc95cc168c /tools/count-resources
Alain Mazy <am@orthanc.team>
parents: 5835
diff changeset
1013 uint64_t count = 0;
82fc95cc168c /tools/count-resources
Alain Mazy <am@orthanc.team>
parents: 5835
diff changeset
1014 context.GetIndex().ExecuteCount(count, request_);
82fc95cc168c /tools/count-resources
Alain Mazy <am@orthanc.team>
parents: 5835
diff changeset
1015 return count;
82fc95cc168c /tools/count-resources
Alain Mazy <am@orthanc.team>
parents: 5835
diff changeset
1016 }
82fc95cc168c /tools/count-resources
Alain Mazy <am@orthanc.team>
parents: 5835
diff changeset
1017
5665
d8c86698110c implemented computed tag: Instance Availability
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
1018
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1019 void ResourceFinder::Execute(IVisitor& visitor,
5840
b24b61331566 pagination: fixed compat with ODBC that does not support ExtendedFind
Alain Mazy <am@orthanc.team>
parents: 5837
diff changeset
1020 ServerContext& context)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1021 {
5840
b24b61331566 pagination: fixed compat with ODBC that does not support ExtendedFind
Alain Mazy <am@orthanc.team>
parents: 5837
diff changeset
1022 UpdateRequestLimits(context);
b24b61331566 pagination: fixed compat with ODBC that does not support ExtendedFind
Alain Mazy <am@orthanc.team>
parents: 5837
diff changeset
1023
5764
db4bd2f9e8d2 re-enable W002 again
Alain Mazy <am@orthanc.team>
parents: 5752
diff changeset
1024 bool isWarning002Enabled = false;
5787
42ef98bb3c13 Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents: 5774
diff changeset
1025 bool isWarning004Enabled = false;
5855
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1026 bool isWarning006Enabled = false;
5856
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1027 bool isWarning007Enabled = false;
5764
db4bd2f9e8d2 re-enable W002 again
Alain Mazy <am@orthanc.team>
parents: 5752
diff changeset
1028
db4bd2f9e8d2 re-enable W002 again
Alain Mazy <am@orthanc.team>
parents: 5752
diff changeset
1029 {
db4bd2f9e8d2 re-enable W002 again
Alain Mazy <am@orthanc.team>
parents: 5752
diff changeset
1030 OrthancConfiguration::ReaderLock lock;
db4bd2f9e8d2 re-enable W002 again
Alain Mazy <am@orthanc.team>
parents: 5752
diff changeset
1031 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
1032 isWarning004Enabled = lock.GetConfiguration().IsWarningEnabled(Warnings_004_NoMainDicomTagsSignature);
5855
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1033 isWarning006Enabled = lock.GetConfiguration().IsWarningEnabled(Warnings_006_RequestingTagFromMetaHeader);
5856
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1034 isWarning007Enabled = lock.GetConfiguration().IsWarningEnabled(Warnings_007_MissingRequestedTagsNotReadFromDisk);
5764
db4bd2f9e8d2 re-enable W002 again
Alain Mazy <am@orthanc.team>
parents: 5752
diff changeset
1035 }
db4bd2f9e8d2 re-enable W002 again
Alain Mazy <am@orthanc.team>
parents: 5752
diff changeset
1036
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1037 FindResponse response;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1038 context.GetIndex().ExecuteFind(response, request_);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1039
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1040 bool complete;
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
1041
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
1042 switch (pagingMode_)
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1043 {
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
1044 case PagingMode_FullDatabase:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
1045 case PagingMode_ManualSkip:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
1046 complete = true;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
1047 break;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
1048
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
1049 case PagingMode_FullManual:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
1050 complete = (databaseLimits_ == 0 ||
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
1051 response.GetSize() <= databaseLimits_);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
1052 break;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
1053
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
1054 default:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
1055 throw OrthancException(ErrorCode_InternalError);
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1056 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1057
5690
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
1058 if (lookup_.get() != NULL)
5688
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 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
1061 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1062
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1063 size_t countResults = 0;
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1064 size_t skipped = 0;
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1065
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
1066 for (size_t i = 0; i < response.GetSize(); i++)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1067 {
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
1068 const FindResponse::Resource& resource = response.GetResourceByIndex(i);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
1069
5774
f96abfe08946 implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5772
diff changeset
1070 #if 0
f96abfe08946 implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5772
diff changeset
1071 {
f96abfe08946 implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5772
diff changeset
1072 Json::Value v;
f96abfe08946 implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5772
diff changeset
1073 resource.DebugExport(v, request_);
f96abfe08946 implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5772
diff changeset
1074 std::cout << v.toStyledString();
f96abfe08946 implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5772
diff changeset
1075 }
f96abfe08946 implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5772
diff changeset
1076 #endif
f96abfe08946 implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5772
diff changeset
1077
5788
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
1078 DicomMap outRequestedTags;
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1079
5789
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
1080 if (HasRequestedTags())
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1081 {
5788
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
1082 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
1083
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
1084 InjectComputedTags(outRequestedTags, resource);
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
1085 Toolbox::RemoveSets(remainingRequestedTags, requestedComputedTags_);
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
1086
5789
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
1087 InjectRequestedTags(outRequestedTags, remainingRequestedTags, resource, ResourceType_Patient);
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
1088 InjectRequestedTags(outRequestedTags, remainingRequestedTags, resource, ResourceType_Study);
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
1089 InjectRequestedTags(outRequestedTags, remainingRequestedTags, resource, ResourceType_Series);
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
1090 InjectRequestedTags(outRequestedTags, remainingRequestedTags, resource, ResourceType_Instance);
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
1091
5855
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1092 if (DicomMap::HasMetaInformationTags(remainingRequestedTags)) // we are not able to retrieve meta information in RequestedTags
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1093 {
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1094 std::set<DicomTag> metaTagsToRemove;
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1095 for (std::set<DicomTag>::const_iterator it = remainingRequestedTags.begin(); it != remainingRequestedTags.end(); ++it)
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1096 {
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1097 if (it->GetGroup() == 0x0002)
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1098 {
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1099 metaTagsToRemove.insert(*it);
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1100 }
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1101 }
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1102
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1103 if (isWarning006Enabled)
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1104 {
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1105 std::string joinedMetaTags;
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1106 FromDcmtkBridge::FormatListOfTags(joinedMetaTags, metaTagsToRemove);
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1107 LOG(WARNING) << "W006: Unable to include tags from the Meta Header in 'RequestedTags'. Skipping them: " << joinedMetaTags;
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1108 }
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1109
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1110 Toolbox::RemoveSets(remainingRequestedTags, metaTagsToRemove);
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1111 }
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1112
aeb9f63923b1 ignore tags from meta header in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5852
diff changeset
1113
5793
a8055aebc6cb added standard MainDicomTags that are used in QIDO-RS
Alain Mazy <am@orthanc.team>
parents: 5790
diff changeset
1114 if (!remainingRequestedTags.empty() &&
a8055aebc6cb added standard MainDicomTags that are used in QIDO-RS
Alain Mazy <am@orthanc.team>
parents: 5790
diff changeset
1115 !DicomMap::HasOnlyComputedTags(remainingRequestedTags)) // if the only remaining tags are computed tags, it is worthless to read them from disk
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1116 {
5856
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1117 if (IsStorageAccessAllowedOnAnswers())
5610
d4b570834d3a adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
1118 {
5788
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
1119 ReadMissingTagsFromStorageArea(outRequestedTags, context, request_, resource, remainingRequestedTags);
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1120 }
5856
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1121 else if (isWarning007Enabled)
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1122 {
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1123 std::string joinedTags;
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1124 FromDcmtkBridge::FormatListOfTags(joinedTags, remainingRequestedTags);
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1125 LOG(WARNING) << "W007: Unable to include requested tags since 'StorageAccessOnFind' does not allow accessing the storage to build answers: " << joinedTags;
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1126 }
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1127 }
5764
db4bd2f9e8d2 re-enable W002 again
Alain Mazy <am@orthanc.team>
parents: 5752
diff changeset
1128
db4bd2f9e8d2 re-enable W002 again
Alain Mazy <am@orthanc.team>
parents: 5752
diff changeset
1129 std::string mainDicomTagsSignature;
db4bd2f9e8d2 re-enable W002 again
Alain Mazy <am@orthanc.team>
parents: 5752
diff changeset
1130 if (isWarning002Enabled &&
db4bd2f9e8d2 re-enable W002 again
Alain Mazy <am@orthanc.team>
parents: 5752
diff changeset
1131 resource.LookupMetadata(mainDicomTagsSignature, resource.GetLevel(), MetadataType_MainDicomTagsSignature) &&
db4bd2f9e8d2 re-enable W002 again
Alain Mazy <am@orthanc.team>
parents: 5752
diff changeset
1132 mainDicomTagsSignature != DicomMap::GetMainDicomTagsSignature(resource.GetLevel()))
db4bd2f9e8d2 re-enable W002 again
Alain Mazy <am@orthanc.team>
parents: 5752
diff changeset
1133 {
db4bd2f9e8d2 re-enable W002 again
Alain Mazy <am@orthanc.team>
parents: 5752
diff changeset
1134 LOG(WARNING) << "W002: " << Orthanc::GetResourceTypeText(resource.GetLevel(), false , false)
5789
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
1135 << " has been stored with another version of Main Dicom Tags list, you should POST to /"
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
1136 << Orthanc::GetResourceTypeText(resource.GetLevel(), true, false)
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
1137 << "/" << resource.GetIdentifier()
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
1138 << "/reconstruct to update the list of tags saved in DB or run the Housekeeper plugin. Some MainDicomTags might be missing from this answer.";
5764
db4bd2f9e8d2 re-enable W002 again
Alain Mazy <am@orthanc.team>
parents: 5752
diff changeset
1139 }
5789
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
1140 else if (isWarning004Enabled &&
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
1141 request_.IsRetrieveMetadata() &&
5787
42ef98bb3c13 Do not read from disk when not required
Alain Mazy <am@orthanc.team>
parents: 5774
diff changeset
1142 !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
1143 {
5789
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
1144 LOG(WARNING) << "W004: " << Orthanc::GetResourceTypeText(resource.GetLevel(), false , false)
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
1145 << " has been stored with an old Orthanc version and does not have a MainDicomTagsSignature, you should POST to /"
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
1146 << Orthanc::GetResourceTypeText(resource.GetLevel(), true, false)
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
1147 << "/" << resource.GetIdentifier()
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
1148 << "/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
1149 }
5764
db4bd2f9e8d2 re-enable W002 again
Alain Mazy <am@orthanc.team>
parents: 5752
diff changeset
1150
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1151 }
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1152
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1153 bool match = true;
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1154
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1155 if (lookup_.get() != NULL)
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1156 {
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1157 DicomMap tags;
5690
708952bd869c integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5689
diff changeset
1158 resource.GetAllMainDicomTags(tags);
5788
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
1159 tags.Merge(outRequestedTags);
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1160 match = lookup_->IsMatch(tags);
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1161 }
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1162
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1163 if (match)
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1164 {
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
1165 if (pagingMode_ == PagingMode_FullDatabase)
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1166 {
5788
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
1167 visitor.Apply(resource, outRequestedTags);
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1168 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1169 else
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1170 {
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
1171 if (hasLimitsSince_ &&
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1172 skipped < limitsSince_)
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1173 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1174 skipped++;
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1175 }
5693
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5692
diff changeset
1176 else if (hasLimitsCount_ &&
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1177 countResults >= limitsCount_)
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1178 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1179 // Too many results, don't mark as complete
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1180 complete = false;
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1181 break;
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1182 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1183 else
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1184 {
5788
61c9e5df64d7 handling of sequences from DB in RequestedTags
Alain Mazy <am@orthanc.team>
parents: 5787
diff changeset
1185 visitor.Apply(resource, outRequestedTags);
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1186 countResults++;
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1187 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1188 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1189 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1190 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1191
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1192 if (complete)
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1193 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1194 visitor.MarkAsComplete();
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1195 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1196 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1197
5856
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1198 bool ResourceFinder::IsStorageAccessAllowedOnAnswers()
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1199 {
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1200 switch (storageAccessMode_)
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1201 {
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1202 case FindStorageAccessMode_DiskOnAnswer:
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1203 case FindStorageAccessMode_DiskOnLookupAndAnswer:
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1204 return true;
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1205 case FindStorageAccessMode_DatabaseOnly:
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1206 return false;
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1207 default:
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1208 throw OrthancException(ErrorCode_InternalError);
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1209 }
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1210 }
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1211
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1212
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1213 bool ResourceFinder::IsStorageAccessOnLookup()
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1214 {
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1215 switch (storageAccessMode_)
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1216 {
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1217 case FindStorageAccessMode_DiskOnAnswer:
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1218 return false;
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1219 case FindStorageAccessMode_DiskOnLookupAndAnswer:
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1220 case FindStorageAccessMode_DatabaseOnly:
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1221 return true;
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1222 default:
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1223 throw OrthancException(ErrorCode_InternalError);
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1224 }
d1dea8ad74a6 implement StorageAccessOnFind for answers
Alain Mazy <am@orthanc.team>
parents: 5855
diff changeset
1225 }
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1226
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1227 void ResourceFinder::Execute(Json::Value& target,
5709
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
1228 ServerContext& context,
5713
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1229 DicomToJsonFormat format,
5840
b24b61331566 pagination: fixed compat with ODBC that does not support ExtendedFind
Alain Mazy <am@orthanc.team>
parents: 5837
diff changeset
1230 bool includeAllMetadata)
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1231 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1232 class Visitor : public IVisitor
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1233 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1234 private:
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1235 const ResourceFinder& that_;
5709
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
1236 ServerIndex& index_;
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
1237 Json::Value& target_;
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
1238 DicomToJsonFormat format_;
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
1239 bool hasRequestedTags_;
5713
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1240 bool includeAllMetadata_;
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1241
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1242 public:
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1243 Visitor(const ResourceFinder& that,
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1244 ServerIndex& index,
5696
0f8b6214308a preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5694
diff changeset
1245 Json::Value& target,
5709
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
1246 DicomToJsonFormat format,
5713
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1247 bool hasRequestedTags,
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1248 bool includeAllMetadata) :
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1249 that_(that),
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1250 index_(index),
5696
0f8b6214308a preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5694
diff changeset
1251 target_(target),
5709
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
1252 format_(format),
5713
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1253 hasRequestedTags_(hasRequestedTags),
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1254 includeAllMetadata_(includeAllMetadata)
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1255 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1256 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1257
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1258 virtual void Apply(const FindResponse::Resource& resource,
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1259 const DicomMap& requestedTags) ORTHANC_OVERRIDE
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1260 {
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
1261 if (that_.responseContent_ != ResponseContentFlags_ID)
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1262 {
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1263 Json::Value item;
5829
963945d780d6 tools/find ResponseContent
Alain Mazy <am@orthanc.team>
parents: 5828
diff changeset
1264 that_.Expand(item, resource, index_, format_);
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1265
5696
0f8b6214308a preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5694
diff changeset
1266 if (hasRequestedTags_)
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1267 {
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1268 static const char* const REQUESTED_TAGS = "RequestedTags";
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1269 item[REQUESTED_TAGS] = Json::objectValue;
5709
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
1270 FromDcmtkBridge::ToJson(item[REQUESTED_TAGS], requestedTags, format_);
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
1271 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
1272
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1273 target_.append(item);
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
1274 }
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1275 else
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1276 {
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1277 target_.append(resource.GetIdentifier());
5686
11575590e493 integrating DatabaseLookup into ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5682
diff changeset
1278 }
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1279 }
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1280
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1281 virtual void MarkAsComplete() ORTHANC_OVERRIDE
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1282 {
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1283 }
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1284 };
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1285
5840
b24b61331566 pagination: fixed compat with ODBC that does not support ExtendedFind
Alain Mazy <am@orthanc.team>
parents: 5837
diff changeset
1286 UpdateRequestLimits(context);
b24b61331566 pagination: fixed compat with ODBC that does not support ExtendedFind
Alain Mazy <am@orthanc.team>
parents: 5837
diff changeset
1287
5688
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1288 target = Json::arrayValue;
d0a264b803f1 first implementation of database paging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5686
diff changeset
1289
5789
40ad08b75d84 cleanup + W005
Alain Mazy <am@orthanc.team>
parents: 5788
diff changeset
1290 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
1291 Execute(visitor, context);
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1292 }
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1293
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1294
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1295 bool ResourceFinder::ExecuteOneResource(Json::Value& target,
5709
476b1db52110 removed the "format_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5702
diff changeset
1296 ServerContext& context,
5713
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1297 DicomToJsonFormat format,
5840
b24b61331566 pagination: fixed compat with ODBC that does not support ExtendedFind
Alain Mazy <am@orthanc.team>
parents: 5837
diff changeset
1298 bool includeAllMetadata)
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1299 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1300 Json::Value answer;
5713
d851a54e49b7 removed "includeAllMetadata_" member from ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5709
diff changeset
1301 Execute(answer, context, format, includeAllMetadata);
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1302
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1303 if (answer.type() != Json::arrayValue)
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1304 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1305 throw OrthancException(ErrorCode_InternalError);
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1306 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1307 else if (answer.size() > 1)
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1308 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1309 throw OrthancException(ErrorCode_DatabasePlugin);
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1310 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1311 else if (answer.empty())
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1312 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1313 // 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
1314 return false;
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1315 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1316 else
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1317 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1318 target = answer[0];
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1319 return true;
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1320 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
1321 }
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1322 }