annotate OrthancServer/Sources/Database/Compatibility/GenericFind.cpp @ 5666:aa231c18b9d2 find-refactoring

adding computed tags
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 04 Jul 2024 18:31:54 +0200
parents 3f13db27b399
children 93dff1fccf36
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
12d8a1a266e9 introduction of FindRequest and FindResponse
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
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 *
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * This program is free software: you can redistribute it and/or
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * modify it under the terms of the GNU General Public License as
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * published by the Free Software Foundation, either version 3 of the
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * License, or (at your option) any later version.
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 *
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * General Public License for more details.
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 *
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "GenericFind.h"
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
5592
1e2631b8b9af GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5590
diff changeset
26 #include "../../../../OrthancFramework/Sources/DicomFormat/DicomArray.h"
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include "../../../../OrthancFramework/Sources/OrthancException.h"
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
29 #include <stack>
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
30
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 namespace Orthanc
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 namespace Compatibility
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
36 static bool IsRequestWithoutContraint(const FindRequest& request)
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
37 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
38 return (request.GetDicomTagConstraintsCount() == 0 &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
39 request.GetMetadataConstraintsCount() == 0 &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
40 request.GetLabels().empty() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
41 request.GetOrdering().empty());
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
42 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
43
5617
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
44 static void GetChildren(std::list<int64_t>& target,
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
45 IDatabaseWrapper::ITransaction& transaction,
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
46 const std::list<int64_t>& resources)
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
47 {
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
48 target.clear();
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
49
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
50 for (std::list<int64_t>::const_iterator it = resources.begin(); it != resources.end(); ++it)
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
51 {
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
52 std::list<int64_t> tmp;
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
53 transaction.GetChildrenInternalId(tmp, *it);
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
54 target.splice(target.begin(), tmp);
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
55 }
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
56 }
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
57
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
58 static void GetChildren(std::list<std::string>& target,
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
59 IDatabaseWrapper::ITransaction& transaction,
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
60 const std::list<int64_t>& resources)
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
61 {
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
62 target.clear();
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
63
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
64 for (std::list<int64_t>::const_iterator it = resources.begin(); it != resources.end(); ++it)
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
65 {
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
66 std::list<std::string> tmp;
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
67 transaction.GetChildrenPublicId(tmp, *it);
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
68 target.splice(target.begin(), tmp);
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
69 }
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
70 }
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
71
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
72 static void GetChildrenIdentifiers(std::list<std::string>& children,
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
73 IDatabaseWrapper::ITransaction& transaction,
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
74 const OrthancIdentifiers& identifiers,
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
75 ResourceType topLevel,
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
76 ResourceType bottomLevel)
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
77 {
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
78 if (!IsResourceLevelAboveOrEqual(topLevel, bottomLevel) ||
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
79 topLevel == bottomLevel)
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
80 {
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
81 throw OrthancException(ErrorCode_InternalError);
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
82 }
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
83
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
84 std::list<int64_t> currentResources;
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
85 ResourceType currentLevel;
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
86
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
87 {
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
88 int64_t id;
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
89 if (!transaction.LookupResource(id, currentLevel, identifiers.GetLevel(topLevel)) ||
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
90 currentLevel != topLevel)
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
91 {
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
92 throw OrthancException(ErrorCode_InexistentItem);
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
93 }
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
94
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
95 currentResources.push_back(id);
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
96 }
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
97
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
98 while (currentLevel != bottomLevel)
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
99 {
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
100 ResourceType nextLevel = GetChildResourceType(currentLevel);
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
101 if (nextLevel == bottomLevel)
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
102 {
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
103 GetChildren(children, transaction, currentResources);
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
104 }
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
105 else
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
106 {
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
107 std::list<int64_t> nextResources;
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
108 GetChildren(nextResources, transaction, currentResources);
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
109 currentResources.swap(nextResources);
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
110 }
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
111
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
112 currentLevel = nextLevel;
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
113 }
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
114 }
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
115
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
116 void GenericFind::ExecuteFind(std::list<std::string>& identifiers,
5614
4640b7ae9a11 moving normalization of constraints into FindRequest
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5609
diff changeset
117 const FindRequest& request)
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 {
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
119 if (IsRequestWithoutContraint(request) &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
120 !request.GetOrthancIdentifiers().HasPatientId() &&
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 !request.GetOrthancIdentifiers().HasStudyId() &&
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 !request.GetOrthancIdentifiers().HasSeriesId() &&
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
123 !request.GetOrthancIdentifiers().HasInstanceId())
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 if (request.HasLimits())
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 {
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
127 transaction_.GetAllPublicIds(identifiers, request.GetLevel(), request.GetLimitsSince(), request.GetLimitsCount());
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 else
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 {
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
131 transaction_.GetAllPublicIds(identifiers, request.GetLevel());
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 }
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
134 else if (IsRequestWithoutContraint(request) &&
5616
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5615
diff changeset
135 request.GetLevel() == ResourceType_Patient &&
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
136 request.GetOrthancIdentifiers().HasPatientId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
137 !request.GetOrthancIdentifiers().HasStudyId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
138 !request.GetOrthancIdentifiers().HasSeriesId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
139 !request.GetOrthancIdentifiers().HasInstanceId())
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
140 {
5617
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
141 // TODO-FIND: This is a trivial case for which no transaction is needed
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
142 identifiers.push_back(request.GetOrthancIdentifiers().GetPatientId());
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
143 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
144 else if (IsRequestWithoutContraint(request) &&
5616
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5615
diff changeset
145 request.GetLevel() == ResourceType_Study &&
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
146 !request.GetOrthancIdentifiers().HasPatientId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
147 request.GetOrthancIdentifiers().HasStudyId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
148 !request.GetOrthancIdentifiers().HasSeriesId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
149 !request.GetOrthancIdentifiers().HasInstanceId())
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
150 {
5617
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
151 // TODO-FIND: This is a trivial case for which no transaction is needed
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
152 identifiers.push_back(request.GetOrthancIdentifiers().GetStudyId());
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
153 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
154 else if (IsRequestWithoutContraint(request) &&
5616
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5615
diff changeset
155 request.GetLevel() == ResourceType_Series &&
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
156 !request.GetOrthancIdentifiers().HasPatientId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
157 !request.GetOrthancIdentifiers().HasStudyId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
158 request.GetOrthancIdentifiers().HasSeriesId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
159 !request.GetOrthancIdentifiers().HasInstanceId())
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
160 {
5617
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
161 // TODO-FIND: This is a trivial case for which no transaction is needed
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
162 identifiers.push_back(request.GetOrthancIdentifiers().GetSeriesId());
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
163 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
164 else if (IsRequestWithoutContraint(request) &&
5616
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5615
diff changeset
165 request.GetLevel() == ResourceType_Instance &&
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
166 !request.GetOrthancIdentifiers().HasPatientId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
167 !request.GetOrthancIdentifiers().HasStudyId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
168 !request.GetOrthancIdentifiers().HasSeriesId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
169 request.GetOrthancIdentifiers().HasInstanceId())
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
170 {
5617
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
171 // TODO-FIND: This is a trivial case for which no transaction is needed
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
172 identifiers.push_back(request.GetOrthancIdentifiers().GetInstanceId());
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
173 }
5617
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
174 else if (IsRequestWithoutContraint(request) &&
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
175 (request.GetLevel() == ResourceType_Study ||
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
176 request.GetLevel() == ResourceType_Series ||
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
177 request.GetLevel() == ResourceType_Instance) &&
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
178 request.GetOrthancIdentifiers().HasPatientId() &&
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
179 !request.GetOrthancIdentifiers().HasStudyId() &&
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
180 !request.GetOrthancIdentifiers().HasSeriesId() &&
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
181 !request.GetOrthancIdentifiers().HasInstanceId())
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
182 {
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
183 GetChildrenIdentifiers(identifiers, transaction_, request.GetOrthancIdentifiers(), ResourceType_Patient, request.GetLevel());
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
184 }
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
185 else if (IsRequestWithoutContraint(request) &&
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
186 (request.GetLevel() == ResourceType_Series ||
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
187 request.GetLevel() == ResourceType_Instance) &&
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
188 !request.GetOrthancIdentifiers().HasPatientId() &&
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
189 request.GetOrthancIdentifiers().HasStudyId() &&
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
190 !request.GetOrthancIdentifiers().HasSeriesId() &&
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
191 !request.GetOrthancIdentifiers().HasInstanceId())
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
192 {
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
193 GetChildrenIdentifiers(identifiers, transaction_, request.GetOrthancIdentifiers(), ResourceType_Study, request.GetLevel());
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
194 }
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
195 else if (IsRequestWithoutContraint(request) &&
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
196 request.GetLevel() == ResourceType_Instance &&
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
197 !request.GetOrthancIdentifiers().HasPatientId() &&
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
198 !request.GetOrthancIdentifiers().HasStudyId() &&
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
199 request.GetOrthancIdentifiers().HasSeriesId() &&
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
200 !request.GetOrthancIdentifiers().HasInstanceId())
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
201 {
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
202 GetChildrenIdentifiers(identifiers, transaction_, request.GetOrthancIdentifiers(), ResourceType_Series, request.GetLevel());
8905ffa45fc2 started listing of children resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5616
diff changeset
203 }
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 else
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 {
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
206 throw OrthancException(ErrorCode_NotImplemented); // Not supported
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
207 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
208 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
209
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
210
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
211 void GenericFind::RetrieveMainDicomTags(FindResponse::Resource& target,
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
212 ResourceType level,
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
213 int64_t internalId)
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
214 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
215 DicomMap m;
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
216 transaction_.GetMainDicomTags(m, internalId);
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
217
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
218 DicomArray a(m);
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
219 for (size_t i = 0; i < a.GetSize(); i++)
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
220 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
221 const DicomElement& element = a.GetElement(i);
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
222 if (element.GetValue().IsString())
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
223 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
224 target.AddStringDicomTag(level, element.GetTag().GetGroup(),
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
225 element.GetTag().GetElement(), element.GetValue().GetContent());
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
226 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
227 else
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
228 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
229 throw OrthancException(ErrorCode_BadParameterType);
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
230 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
231 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
232 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
233
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
234
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
235 static ResourceType GetTopLevelOfInterest(const FindRequest& request)
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
236 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
237 switch (request.GetLevel())
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
238 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
239 case ResourceType_Patient:
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
240 return ResourceType_Patient;
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
241
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
242 case ResourceType_Study:
5619
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
243 if (request.GetParentRetrieveSpecification(ResourceType_Patient).IsRetrieveMainDicomTags() ||
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
244 request.GetParentRetrieveSpecification(ResourceType_Patient).IsRetrieveMetadata())
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
245 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
246 return ResourceType_Patient;
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
247 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
248 else
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
249 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
250 return ResourceType_Study;
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
251 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
252
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
253 case ResourceType_Series:
5619
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
254 if (request.GetParentRetrieveSpecification(ResourceType_Patient).IsRetrieveMainDicomTags() ||
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
255 request.GetParentRetrieveSpecification(ResourceType_Patient).IsRetrieveMetadata())
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
256 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
257 return ResourceType_Patient;
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
258 }
5619
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
259 else if (request.GetParentRetrieveSpecification(ResourceType_Study).IsRetrieveMainDicomTags() ||
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
260 request.GetParentRetrieveSpecification(ResourceType_Study).IsRetrieveMetadata())
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
261 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
262 return ResourceType_Study;
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
263 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
264 else
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
265 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
266 return ResourceType_Series;
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
267 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
268
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
269 case ResourceType_Instance:
5619
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
270 if (request.GetParentRetrieveSpecification(ResourceType_Patient).IsRetrieveMainDicomTags() ||
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
271 request.GetParentRetrieveSpecification(ResourceType_Patient).IsRetrieveMetadata())
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
272 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
273 return ResourceType_Patient;
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
274 }
5619
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
275 else if (request.GetParentRetrieveSpecification(ResourceType_Study).IsRetrieveMainDicomTags() ||
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
276 request.GetParentRetrieveSpecification(ResourceType_Study).IsRetrieveMetadata())
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
277 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
278 return ResourceType_Study;
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
279 }
5619
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
280 else if (request.GetParentRetrieveSpecification(ResourceType_Series).IsRetrieveMainDicomTags() ||
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
281 request.GetParentRetrieveSpecification(ResourceType_Series).IsRetrieveMetadata())
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
282 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
283 return ResourceType_Series;
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
284 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
285 else
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
286 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
287 return ResourceType_Instance;
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
288 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
289
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
290 default:
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
291 throw OrthancException(ErrorCode_ParameterOutOfRange);
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
292 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
293 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
294
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
295
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
296 void GenericFind::ExecuteExpand(FindResponse& response,
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
297 const FindRequest& request,
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
298 const std::string& identifier)
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
299 {
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
300 int64_t internalId;
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
301 ResourceType level;
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
302 std::string parent;
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
303
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
304 if (request.IsRetrieveParentIdentifier())
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
305 {
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
306 if (!transaction_.LookupResourceAndParent(internalId, level, parent, identifier))
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
307 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
308 return; // The resource is not available anymore
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
309 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
310
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
311 if (level == ResourceType_Patient)
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
312 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
313 if (!parent.empty())
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
314 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
315 throw OrthancException(ErrorCode_DatabasePlugin);
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
316 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
317 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
318 else
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
319 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
320 if (parent.empty())
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
321 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
322 throw OrthancException(ErrorCode_DatabasePlugin);
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
323 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
324 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
325 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
326 else
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
327 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
328 if (!transaction_.LookupResource(internalId, level, identifier))
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
329 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
330 return; // The resource is not available anymore
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
331 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
332 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
333
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
334 if (level != request.GetLevel())
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
335 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
336 throw OrthancException(ErrorCode_DatabasePlugin);
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338
5606
6e2dad336446 added "IsStable" field in expanded resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5596
diff changeset
339 std::unique_ptr<FindResponse::Resource> resource(new FindResponse::Resource(request.GetLevel(), internalId, identifier));
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
340
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
341 if (request.IsRetrieveParentIdentifier())
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
342 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
343 assert(!parent.empty());
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
344 resource->SetParentIdentifier(parent);
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
345 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
346
5619
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
347 if (request.IsRetrieveMainDicomTags())
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
348 {
5619
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
349 RetrieveMainDicomTags(*resource, level, internalId);
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
350 }
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
351
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
352 if (request.IsRetrieveMetadata())
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
353 {
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
354 transaction_.GetAllMetadata(resource->GetMetadata(level), internalId);
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
355 }
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
356
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
357 {
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
358 const ResourceType topLevel = GetTopLevelOfInterest(request);
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
359
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
360 int64_t currentId = internalId;
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
361 ResourceType currentLevel = level;
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
362
5619
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
363 while (currentLevel != topLevel)
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
364 {
5619
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
365 int64_t parentId;
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
366 if (transaction_.LookupParent(parentId, currentId))
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
367 {
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
368 currentId = parentId;
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
369 currentLevel = GetParentResourceType(currentLevel);
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
370 }
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
371 else
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
372 {
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
373 throw OrthancException(ErrorCode_DatabasePlugin);
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
374 }
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
375
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
376 if (request.GetParentRetrieveSpecification(currentLevel).IsRetrieveMainDicomTags())
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
377 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
378 RetrieveMainDicomTags(*resource, currentLevel, currentId);
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
379 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
380
5619
1864b16bc7b1 added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5617
diff changeset
381 if (request.GetParentRetrieveSpecification(currentLevel).IsRetrieveMetadata())
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
382 {
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
383 transaction_.GetAllMetadata(resource->GetMetadata(currentLevel), currentId);
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
384 }
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
385 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
386 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
387
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
388 if (request.IsRetrieveLabels())
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
389 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
390 transaction_.ListLabels(resource->GetLabels(), internalId);
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
391 }
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
392
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
393 if (request.IsRetrieveAttachments())
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
394 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
395 std::set<FileContentType> attachments;
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
396 transaction_.ListAvailableAttachments(attachments, internalId);
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
397
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
398 for (std::set<FileContentType>::const_iterator it = attachments.begin(); it != attachments.end(); ++it)
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
399 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
400 FileInfo info;
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
401 int64_t revision;
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
402 if (transaction_.LookupAttachment(info, revision, internalId, *it) &&
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
403 info.GetContentType() == *it)
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
404 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
405 resource->AddAttachment(info);
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
406 }
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
407 else
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
408 {
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
409 throw OrthancException(ErrorCode_DatabasePlugin);
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
410 }
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
411 }
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
412 }
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
413
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
414 if (request.GetLevel() != ResourceType_Instance)
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
415 {
5621
732ec9feeea8 introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5619
diff changeset
416 // TODO-FIND: Retrieve other levels than immediate children
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
417 const ResourceType childLevel = GetChildResourceType(request.GetLevel());
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
419 if (request.GetChildrenRetrieveSpecification(childLevel).IsRetrieveIdentifiers())
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 {
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
421 std::list<std::string> children;
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
422 transaction_.GetChildrenPublicId(children, internalId);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
423
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
424 for (std::list<std::string>::const_iterator it = children.begin(); it != children.end(); ++it)
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
425 {
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
426 resource->AddChildIdentifier(childLevel, *it);
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
427 }
5565
def06a42e5ef Updated FindRequest & FindResponse definitions
Alain Mazy <am@orthanc.team>
parents: 5554
diff changeset
428 }
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
429 }
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
431 for (std::set<MetadataType>::const_iterator it = request.GetRetrieveChildrenMetadata().begin();
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
432 it != request.GetRetrieveChildrenMetadata().end(); ++it)
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
433 {
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
434 std::list<std::string> values;
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
435 transaction_.GetChildrenMetadata(values, internalId, *it);
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
436 resource->AddChildrenMetadata(*it, values);
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
437 }
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
438
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
439 if (request.IsRetrieveOneInstanceIdentifier() &&
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
440 !request.GetChildrenRetrieveSpecification(ResourceType_Instance).IsRetrieveIdentifiers())
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
441 {
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
442 int64_t currentId = internalId;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
443 ResourceType currentLevel = level;
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
444
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
445 while (currentLevel != ResourceType_Instance)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
446 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
447 std::list<int64_t> children;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
448 transaction_.GetChildrenInternalId(children, currentId);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
449 if (children.empty())
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
450 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
451 throw OrthancException(ErrorCode_DatabasePlugin);
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
452 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
453 else
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
454 {
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
455 currentId = children.front();
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
456 currentLevel = GetChildResourceType(currentLevel);
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
457 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
458 }
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
459
5666
aa231c18b9d2 adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5641
diff changeset
460 resource->AddChildIdentifier(ResourceType_Instance, transaction_.GetPublicId(currentId));
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
461 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
462
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
463 response.Add(resource.release());
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
464 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 }