annotate OrthancServer/Sources/ResourceFinder.cpp @ 5615:a10978a5e65c find-refactoring

expansion of single resources using ResourceFinder
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 09 May 2024 12:24:29 +0200
parents 599ce5ed126c
children 1e92fb051fd7
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
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * License, or (at your option) any later version.
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * General Public License for more details.
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
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 #include "PrecompiledHeadersServer.h"
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "ResourceFinder.h"
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h"
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
27 #include "../../OrthancFramework/Sources/Logging.h"
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include "../../OrthancFramework/Sources/OrthancException.h"
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include "../../OrthancFramework/Sources/SerializationToolbox.h"
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
30 #include "OrthancConfiguration.h"
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 #include "ServerContext.h"
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 #include "ServerIndex.h"
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 namespace Orthanc
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 SeriesStatus ResourceFinder::GetSeriesStatus(uint32_t& expectedNumberOfInstances,
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 const FindResponse::Resource& resource) const
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 if (request_.GetLevel() != ResourceType_Series)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 throw OrthancException(ErrorCode_BadParameterType);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 std::string s;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 if (!resource.LookupMetadata(s, ResourceType_Series, MetadataType_Series_ExpectedNumberOfInstances) ||
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 !SerializationToolbox::ParseUnsignedInteger32(expectedNumberOfInstances, s))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 return SeriesStatus_Unknown;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 std::list<std::string> values;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 if (!resource.LookupChildrenMetadata(values, MetadataType_Instance_IndexInSeries))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 throw OrthancException(ErrorCode_BadSequenceOfCalls);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 std::set<int64_t> instances;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 for (std::list<std::string>::const_iterator
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 it = values.begin(); it != values.end(); ++it)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 int64_t index;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 if (!SerializationToolbox::ParseInteger64(index, *it))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 return SeriesStatus_Unknown;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 if (index <= 0 ||
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 index > static_cast<int64_t>(expectedNumberOfInstances))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 // Out-of-range instance index
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 return SeriesStatus_Inconsistent;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 if (instances.find(index) != instances.end())
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 // Twice the same instance index
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 return SeriesStatus_Inconsistent;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 instances.insert(index);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 if (instances.size() == static_cast<size_t>(expectedNumberOfInstances))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 return SeriesStatus_Complete;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 else
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 return SeriesStatus_Missing;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
97 static void InjectRequestedTags(DicomMap& requestedTags,
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
98 std::set<DicomTag>& missingTags /* out */,
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
99 const FindResponse::Resource& resource,
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
100 ResourceType level,
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
101 const std::set<DicomTag>& tags)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
102 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
103 if (!tags.empty())
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
104 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
105 DicomMap m;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
106 resource.GetMainDicomTags(m, level);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
107
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
108 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
109 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
110 std::string value;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
111 if (m.LookupStringValue(value, *it, false /* not binary */))
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
112 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
113 requestedTags.SetValue(*it, value, false /* not binary */);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
114 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
115 else
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
116 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
117 // This is the case where the Housekeeper should be run
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
118 missingTags.insert(*it);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
119 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
120 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
121 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
122 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
123
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
124
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 void ResourceFinder::Expand(Json::Value& target,
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 const FindResponse::Resource& resource,
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 ServerIndex& index) const
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 /**
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 * This method closely follows "SerializeExpandedResource()" in
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 * "ServerContext.cpp" from Orthanc 1.12.3.
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 **/
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 if (resource.GetLevel() != request_.GetLevel())
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 throw OrthancException(ErrorCode_InternalError);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 target = Json::objectValue;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 target["Type"] = GetResourceTypeText(resource.GetLevel(), false, true);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 target["ID"] = resource.GetIdentifier();
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 switch (resource.GetLevel())
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 case ResourceType_Patient:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 case ResourceType_Study:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 target["ParentPatient"] = resource.GetParentIdentifier();
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 case ResourceType_Series:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 target["ParentStudy"] = resource.GetParentIdentifier();
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 case ResourceType_Instance:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 target["ParentSeries"] = resource.GetParentIdentifier();
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 default:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 throw OrthancException(ErrorCode_InternalError);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 if (resource.GetLevel() != ResourceType_Instance)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 const std::set<std::string>& children = resource.GetChildrenIdentifiers();
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 Json::Value c = Json::arrayValue;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 for (std::set<std::string>::const_iterator
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 it = children.begin(); it != children.end(); ++it)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 c.append(*it);
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 switch (resource.GetLevel())
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 case ResourceType_Patient:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 target["Studies"] = c;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 case ResourceType_Study:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 target["Series"] = c;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 case ResourceType_Series:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 target["Instances"] = c;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 default:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 throw OrthancException(ErrorCode_InternalError);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 switch (resource.GetLevel())
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 case ResourceType_Patient:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 case ResourceType_Study:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 case ResourceType_Series:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 uint32_t expectedNumberOfInstances;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 SeriesStatus status = GetSeriesStatus(expectedNumberOfInstances, resource);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 target["Status"] = EnumerationToString(status);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
208 static const char* const EXPECTED_NUMBER_OF_INSTANCES = "ExpectedNumberOfInstances";
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 if (status == SeriesStatus_Unknown)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 target[EXPECTED_NUMBER_OF_INSTANCES] = Json::nullValue;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 else
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 target[EXPECTED_NUMBER_OF_INSTANCES] = expectedNumberOfInstances;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 case ResourceType_Instance:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 FileInfo info;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 if (resource.LookupAttachment(info, FileContentType_Dicom))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 target["FileSize"] = static_cast<Json::UInt64>(info.GetUncompressedSize());
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 target["FileUuid"] = info.GetUuid();
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 else
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 throw OrthancException(ErrorCode_InternalError);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
235 static const char* const INDEX_IN_SERIES = "IndexInSeries";
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 std::string s;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 uint32_t index;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 if (resource.LookupMetadata(s, ResourceType_Instance, MetadataType_Instance_IndexInSeries) &&
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 SerializationToolbox::ParseUnsignedInteger32(index, s))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 target[INDEX_IN_SERIES] = index;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 else
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 target[INDEX_IN_SERIES] = Json::nullValue;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 break;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 default:
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 throw OrthancException(ErrorCode_InternalError);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 std::string s;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 if (resource.LookupMetadata(s, resource.GetLevel(), MetadataType_AnonymizedFrom))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 target["AnonymizedFrom"] = s;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 if (resource.LookupMetadata(s, resource.GetLevel(), MetadataType_ModifiedFrom))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 target["ModifiedFrom"] = s;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 if (resource.GetLevel() == ResourceType_Patient ||
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 resource.GetLevel() == ResourceType_Study ||
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 resource.GetLevel() == ResourceType_Series)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 target["IsStable"] = !index.IsUnstableResource(resource.GetLevel(), resource.GetInternalId());
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 if (resource.LookupMetadata(s, resource.GetLevel(), MetadataType_LastUpdate))
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 target["LastUpdate"] = s;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 {
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
280 DicomMap allMainDicomTags;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
281 resource.GetMainDicomTags(allMainDicomTags, resource.GetLevel());
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
282
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
283 /**
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
284 * This section was part of "StatelessDatabaseOperations::ExpandResource()"
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
285 * in Orthanc <= 1.12.3
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
286 **/
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
287
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
288 // read all main sequences from DB
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
289 std::string serializedSequences;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
290 if (resource.LookupMetadata(serializedSequences, resource.GetLevel(), MetadataType_MainDicomSequences))
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
291 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
292 Json::Value jsonMetadata;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
293 Toolbox::ReadJson(jsonMetadata, serializedSequences);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
294
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
295 if (jsonMetadata["Version"].asInt() == 1)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
296 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
297 allMainDicomTags.FromDicomAsJson(jsonMetadata["Sequences"], true /* append */, true /* parseSequences */);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
298 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
299 else
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
300 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
301 throw OrthancException(ErrorCode_NotImplemented);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
302 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
303 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
304
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
305 /**
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
306 * End of section from StatelessDatabaseOperations
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
307 **/
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
308
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
309
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 static const char* const MAIN_DICOM_TAGS = "MainDicomTags";
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 static const char* const PATIENT_MAIN_DICOM_TAGS = "PatientMainDicomTags";
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
313 // TODO-FIND : Ignore "null" values
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 DicomMap levelMainDicomTags;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 allMainDicomTags.ExtractResourceInformation(levelMainDicomTags, resource.GetLevel());
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 target[MAIN_DICOM_TAGS] = Json::objectValue;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 FromDcmtkBridge::ToJson(target[MAIN_DICOM_TAGS], levelMainDicomTags, format_);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 if (resource.GetLevel() == ResourceType_Study)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 DicomMap patientMainDicomTags;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 allMainDicomTags.ExtractPatientInformation(patientMainDicomTags);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 target[PATIENT_MAIN_DICOM_TAGS] = Json::objectValue;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 FromDcmtkBridge::ToJson(target[PATIENT_MAIN_DICOM_TAGS], patientMainDicomTags, format_);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 Json::Value labels = Json::arrayValue;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 for (std::set<std::string>::const_iterator
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 it = resource.GetLabels().begin(); it != resource.GetLabels().end(); ++it)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 labels.append(*it);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 target["Labels"] = labels;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 if (includeAllMetadata_) // new in Orthanc 1.12.4
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345 const std::map<MetadataType, std::string>& m = resource.GetMetadata(resource.GetLevel());
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 Json::Value metadata = Json::objectValue;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 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
350 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 metadata[EnumerationToString(it->first)] = it->second;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 target["Metadata"] = metadata;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359 ResourceFinder::ResourceFinder(ResourceType level,
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 bool expand) :
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361 request_(level),
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 expand_(expand),
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 format_(DicomToJsonFormat_Human),
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
364 hasRequestedTags_(false),
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365 includeAllMetadata_(false)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 if (expand)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369 request_.SetRetrieveMainDicomTags(level, true);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 request_.SetRetrieveMetadata(level, true);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 request_.SetRetrieveLabels(true);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 if (level == ResourceType_Series)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 request_.AddRetrieveChildrenMetadata(MetadataType_Instance_IndexInSeries); // required for the SeriesStatus
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378 if (level == ResourceType_Instance)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380 request_.SetRetrieveAttachments(true); // for FileSize & FileUuid
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 else
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384 request_.SetRetrieveChildrenIdentifiers(true);
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 if (level != ResourceType_Patient)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 request_.SetRetrieveParentIdentifier(true);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
395 void ResourceFinder::AddRequestedTags(const DicomTag& tag)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
396 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
397 if (DicomMap::IsMainDicomTag(tag, ResourceType_Patient))
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
398 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
399 request_.SetRetrieveMainDicomTags(ResourceType_Patient, true);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
400 request_.SetRetrieveMetadata(ResourceType_Patient, true);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
401 requestedPatientTags_.insert(tag);
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 else if (DicomMap::IsMainDicomTag(tag, ResourceType_Study))
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
404 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
405 if (request_.GetLevel() == ResourceType_Patient)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
406 {
5612
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
407 LOG(WARNING) << "Requested tag " << tag.Format()
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
408 << " should only be read at the study, series, or instance level";
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
409 requestedTagsFromFileStorage_.insert(tag);
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
410 request_.SetRetrieveOneInstanceIdentifier(true);
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
411 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
412 else
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
413 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
414 request_.SetRetrieveMainDicomTags(ResourceType_Study, true);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
415 request_.SetRetrieveMetadata(ResourceType_Study, true);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
416 requestedStudyTags_.insert(tag);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
417 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
418 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
419 else if (DicomMap::IsMainDicomTag(tag, ResourceType_Series))
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
420 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
421 if (request_.GetLevel() == ResourceType_Patient ||
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
422 request_.GetLevel() == ResourceType_Study)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
423 {
5612
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
424 LOG(WARNING) << "Requested tag " << tag.Format()
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
425 << " should only be read at the series or instance level";
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
426 requestedTagsFromFileStorage_.insert(tag);
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
427 request_.SetRetrieveOneInstanceIdentifier(true);
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
428 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
429 else
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
430 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
431 request_.SetRetrieveMainDicomTags(ResourceType_Series, true);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
432 request_.SetRetrieveMetadata(ResourceType_Series, true);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
433 requestedSeriesTags_.insert(tag);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
434 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
435 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
436 else if (DicomMap::IsMainDicomTag(tag, ResourceType_Instance))
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
437 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
438 if (request_.GetLevel() == ResourceType_Patient ||
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
439 request_.GetLevel() == ResourceType_Study ||
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
440 request_.GetLevel() == ResourceType_Series)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
441 {
5612
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
442 LOG(WARNING) << "Requested tag " << tag.Format()
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
443 << " should only be read at the instance level";
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
444 requestedTagsFromFileStorage_.insert(tag);
599ce5ed126c added more tolerance to behave like previous releases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5610
diff changeset
445 request_.SetRetrieveOneInstanceIdentifier(true);
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
446 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
447 else
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
448 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
449 // Main DICOM tags from the instance level will be retrieved anyway
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
450 assert(request_.IsRetrieveMainDicomTags(ResourceType_Instance));
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
451 assert(request_.IsRetrieveMetadata(ResourceType_Instance));
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
452 requestedInstanceTags_.insert(tag);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
453 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
454 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
455 else
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
456 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
457 // This is not a main DICOM tag: We will be forced to access the DICOM file anyway
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
458 requestedTagsFromFileStorage_.insert(tag);
5610
d4b570834d3a adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
459
d4b570834d3a adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
460 if (request_.GetLevel() != ResourceType_Instance)
d4b570834d3a adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
461 {
d4b570834d3a adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
462 request_.SetRetrieveOneInstanceIdentifier(true);
d4b570834d3a adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
463 }
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
464 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
465
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
466 hasRequestedTags_ = true;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
467 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
468
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
469
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
470 void ResourceFinder::AddRequestedTags(const std::set<DicomTag>& tags)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
471 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
472 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
473 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
474 AddRequestedTags(*it);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
475 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
476 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
477
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
478
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 void ResourceFinder::Execute(Json::Value& target,
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480 ServerContext& context)
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482 FindResponse response;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483 context.GetIndex().ExecuteFind(response, request_);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485 target = Json::arrayValue;
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
487 for (size_t i = 0; i < response.GetSize(); i++)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
488 {
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
489 const FindResponse::Resource& resource = response.GetResourceByIndex(i);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
490
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
491 if (expand_)
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
492 {
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493 Json::Value item;
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
494 Expand(item, resource, context.GetIndex());
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
495
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
496 std::set<DicomTag> missingTags = requestedTagsFromFileStorage_;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
497
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
498 DicomMap requestedTags;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
499 InjectRequestedTags(requestedTags, missingTags, resource, ResourceType_Patient, requestedPatientTags_);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
500 InjectRequestedTags(requestedTags, missingTags, resource, ResourceType_Study, requestedStudyTags_);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
501 InjectRequestedTags(requestedTags, missingTags, resource, ResourceType_Series, requestedSeriesTags_);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
502 InjectRequestedTags(requestedTags, missingTags, resource, ResourceType_Instance, requestedInstanceTags_);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
503
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
504 if (!missingTags.empty())
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
505 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
506 OrthancConfiguration::ReaderLock lock;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
507 if (lock.GetConfiguration().IsWarningEnabled(Warnings_001_TagsBeingReadFromStorage))
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
508 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
509 std::string missings;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
510 FromDcmtkBridge::FormatListOfTags(missings, missingTags);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
511
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
512 LOG(WARNING) << "W001: Accessing Dicom tags from storage when accessing "
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
513 << Orthanc::GetResourceTypeText(resource.GetLevel(), false, false)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
514 << ": " << missings;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
515 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
516
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
517 std::string instancePublicId;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
518
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
519 if (request_.IsRetrieveOneInstanceIdentifier())
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
520 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
521 instancePublicId = resource.GetOneInstanceIdentifier();
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
522 }
5610
d4b570834d3a adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
523 else if (request_.GetLevel() == ResourceType_Instance)
d4b570834d3a adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
524 {
d4b570834d3a adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
525 instancePublicId = resource.GetIdentifier();
d4b570834d3a adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
526 }
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
527 else
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
528 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
529 FindRequest requestDicomAttachment(request_.GetLevel());
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
530 requestDicomAttachment.SetOrthancId(request_.GetLevel(), resource.GetIdentifier());
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
531 requestDicomAttachment.SetRetrieveOneInstanceIdentifier(true);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
532
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
533 FindResponse responseDicomAttachment;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
534 context.GetIndex().ExecuteFind(responseDicomAttachment, requestDicomAttachment);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
535
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
536 if (responseDicomAttachment.GetSize() != 1 ||
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
537 !responseDicomAttachment.GetResourceByIndex(0).HasOneInstanceIdentifier())
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
538 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
539 throw OrthancException(ErrorCode_InexistentFile);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
540 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
541 else
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
542 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
543 instancePublicId = responseDicomAttachment.GetResourceByIndex(0).GetOneInstanceIdentifier();
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
544 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
545 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
546
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
547 LOG(INFO) << "Will retrieve missing DICOM tags from instance: " << instancePublicId;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
548
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
549 Json::Value tmpDicomAsJson;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
550 context.ReadDicomAsJson(tmpDicomAsJson, instancePublicId, missingTags /* ignoreTagLength */);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
551
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
552 DicomMap tmpDicomMap;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
553 tmpDicomMap.FromDicomAsJson(tmpDicomAsJson, false /* append */, true /* parseSequences*/);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
554
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
555 for (std::set<DicomTag>::const_iterator it = missingTags.begin(); it != missingTags.end(); ++it)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
556 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
557 assert(!requestedTags.HasTag(*it));
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
558 if (tmpDicomMap.HasTag(*it))
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
559 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
560 requestedTags.SetValue(*it, tmpDicomMap.GetValue(*it));
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
561 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
562 else
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
563 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
564 requestedTags.SetNullValue(*it); // TODO-FIND: Is this compatible with Orthanc <= 1.12.3?
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
565 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
566 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
567 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
568
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
569 if (hasRequestedTags_)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
570 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
571 static const char* const REQUESTED_TAGS = "RequestedTags";
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
572 item[REQUESTED_TAGS] = Json::objectValue;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
573 FromDcmtkBridge::ToJson(item[REQUESTED_TAGS], requestedTags, format_);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
574 }
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
575
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
576 target.append(item);
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
577 }
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
578 else
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
579 {
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5608
diff changeset
580 target.append(resource.GetIdentifier());
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
582 }
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
583 }
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
584
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
585
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
586 bool ResourceFinder::ExecuteOneResource(Json::Value& target,
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
587 ServerContext& context)
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
588 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
589 Json::Value answer;
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
590 Execute(answer, context);
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
591
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
592 if (answer.type() != Json::arrayValue)
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
593 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
594 throw OrthancException(ErrorCode_InternalError);
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
595 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
596 else if (answer.size() > 1)
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
597 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
598 throw OrthancException(ErrorCode_DatabasePlugin);
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
599 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
600 else if (answer.empty())
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
601 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
602 // 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
603 return false;
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
604 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
605 else
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
606 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
607 target = answer[0];
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
608 return true;
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
609 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5612
diff changeset
610 }
5608
3d0aa94b44b3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
611 }