annotate OrthancServer/Sources/Database/Compatibility/GenericFind.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 4640b7ae9a11
children 1e92fb051fd7
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
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * 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
9 * 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
10 * 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
11 * License, or (at your option) any later version.
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * 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
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * 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
16 * General Public License for more details.
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * 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
19 * 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
20 **/
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 #include "GenericFind.h"
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
5592
1e2631b8b9af GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5590
diff changeset
25 #include "../../../../OrthancFramework/Sources/DicomFormat/DicomArray.h"
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "../../../../OrthancFramework/Sources/OrthancException.h"
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
28 #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
29
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 namespace Orthanc
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 namespace Compatibility
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
35 static bool IsRequestWithoutContraint(const FindRequest& request)
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
36 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
37 return (request.GetDicomTagConstraintsCount() == 0 &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
38 request.GetMetadataConstraintsCount() == 0 &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
39 request.GetLabels().empty() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
40 request.GetOrdering().empty());
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
41 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
42
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
43 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
44 const FindRequest& request)
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
46 if (IsRequestWithoutContraint(request) &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
47 !request.GetOrthancIdentifiers().HasPatientId() &&
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 !request.GetOrthancIdentifiers().HasStudyId() &&
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 !request.GetOrthancIdentifiers().HasSeriesId() &&
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
50 !request.GetOrthancIdentifiers().HasInstanceId())
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 if (request.HasLimits())
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 {
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
54 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
55 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 else
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 {
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
58 transaction_.GetAllPublicIds(identifiers, request.GetLevel());
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 }
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
61 else if (IsRequestWithoutContraint(request) &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
62 request.GetOrthancIdentifiers().HasPatientId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
63 !request.GetOrthancIdentifiers().HasStudyId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
64 !request.GetOrthancIdentifiers().HasSeriesId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
65 !request.GetOrthancIdentifiers().HasInstanceId())
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
66 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
67 identifiers.push_back(request.GetOrthancIdentifiers().GetPatientId());
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
68 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
69 else if (IsRequestWithoutContraint(request) &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
70 !request.GetOrthancIdentifiers().HasPatientId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
71 request.GetOrthancIdentifiers().HasStudyId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
72 !request.GetOrthancIdentifiers().HasSeriesId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
73 !request.GetOrthancIdentifiers().HasInstanceId())
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
74 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
75 identifiers.push_back(request.GetOrthancIdentifiers().GetStudyId());
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
76 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
77 else if (IsRequestWithoutContraint(request) &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
78 !request.GetOrthancIdentifiers().HasPatientId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
79 !request.GetOrthancIdentifiers().HasStudyId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
80 request.GetOrthancIdentifiers().HasSeriesId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
81 !request.GetOrthancIdentifiers().HasInstanceId())
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
82 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
83 identifiers.push_back(request.GetOrthancIdentifiers().GetSeriesId());
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
84 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
85 else if (IsRequestWithoutContraint(request) &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
86 !request.GetOrthancIdentifiers().HasPatientId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
87 !request.GetOrthancIdentifiers().HasStudyId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
88 !request.GetOrthancIdentifiers().HasSeriesId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
89 request.GetOrthancIdentifiers().HasInstanceId())
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
90 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
91 identifiers.push_back(request.GetOrthancIdentifiers().GetInstanceId());
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
92 }
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 else
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 {
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
95 throw OrthancException(ErrorCode_NotImplemented); // Not supported
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
96 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
97 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
98
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
99
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
100 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
101 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
102 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
103 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
104 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
105 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
106
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
107 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
108 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
109 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
110 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
111 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
112 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
113 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
114 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
115 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
116 else
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
117 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
118 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
119 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
120 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
121 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
122
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
123
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
124 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
125 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
126 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
127 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
128 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
129 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
130
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
131 case 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
132 if (request.IsRetrieveMainDicomTags(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
133 request.IsRetrieveMetadata(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
134 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
135 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
136 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
137 else
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
138 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
139 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
140 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
141
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
142 case 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
143 if (request.IsRetrieveMainDicomTags(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
144 request.IsRetrieveMetadata(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
145 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
146 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
147 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
148 else if (request.IsRetrieveMainDicomTags(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
149 request.IsRetrieveMetadata(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
150 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
151 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
152 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
153 else
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
154 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
155 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
156 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
157
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
158 case 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
159 if (request.IsRetrieveMainDicomTags(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
160 request.IsRetrieveMetadata(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
161 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
162 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
163 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
164 else if (request.IsRetrieveMainDicomTags(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
165 request.IsRetrieveMetadata(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
166 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
167 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
168 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
169 else if (request.IsRetrieveMainDicomTags(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
170 request.IsRetrieveMetadata(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
171 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
172 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
173 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
174 else
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
175 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
176 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
177 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
178
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
179 default:
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
180 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
181 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
182 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
183
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
184
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
185 void GenericFind::ExecuteExpand(FindResponse& response,
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
186 const FindRequest& request,
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
187 const std::string& identifier)
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
188 {
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
189 int64_t internalId;
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
190 ResourceType level;
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
191 std::string parent;
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
192
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
193 if (request.IsRetrieveParentIdentifier())
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
194 {
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
195 if (!transaction_.LookupResourceAndParent(internalId, level, parent, identifier))
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
196 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
197 return; // The resource is not available anymore
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
198 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
199
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
200 if (level == ResourceType_Patient)
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
201 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
202 if (!parent.empty())
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
203 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
204 throw OrthancException(ErrorCode_DatabasePlugin);
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
205 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
206 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
207 else
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
208 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
209 if (parent.empty())
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
210 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
211 throw OrthancException(ErrorCode_DatabasePlugin);
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
212 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
213 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
214 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
215 else
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
216 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
217 if (!transaction_.LookupResource(internalId, level, identifier))
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
218 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
219 return; // The resource is not available anymore
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
220 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
221 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
222
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
223 if (level != request.GetLevel())
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
224 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
225 throw OrthancException(ErrorCode_DatabasePlugin);
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227
5606
6e2dad336446 added "IsStable" field in expanded resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5596
diff changeset
228 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
229
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
230 if (request.IsRetrieveParentIdentifier())
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
231 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
232 assert(!parent.empty());
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
233 resource->SetParentIdentifier(parent);
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
234 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
235
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
236 {
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
237 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
238 ResourceType currentLevel = level;
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
239 const ResourceType topLevel = GetTopLevelOfInterest(request);
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
240
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
241 for (;;)
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
242 {
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
243 if (request.IsRetrieveMainDicomTags(currentLevel))
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
244 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
245 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
246 }
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 if (request.IsRetrieveMetadata(currentLevel))
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
249 {
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
250 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
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 if (currentLevel == topLevel)
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
254 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
255 break;
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
256 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
257 else
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
258 {
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
259 int64_t parentId;
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
260 if (transaction_.LookupParent(parentId, currentId))
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 currentId = parentId;
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
263 currentLevel = GetParentResourceType(currentLevel);
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
264 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
265 else
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
266 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
267 throw OrthancException(ErrorCode_DatabasePlugin);
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
268 }
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
269 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
270 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
271 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
272
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
273 if (request.IsRetrieveLabels())
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
274 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
275 transaction_.ListLabels(resource->GetLabels(), internalId);
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
276 }
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
277
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
278 if (request.IsRetrieveAttachments())
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
279 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
280 std::set<FileContentType> attachments;
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
281 transaction_.ListAvailableAttachments(attachments, internalId);
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
282
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
283 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
284 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
285 FileInfo info;
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
286 int64_t revision;
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
287 if (transaction_.LookupAttachment(info, revision, internalId, *it) &&
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
288 info.GetContentType() == *it)
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
289 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
290 resource->AddAttachment(info);
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
291 }
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
292 else
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
293 {
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
294 throw OrthancException(ErrorCode_DatabasePlugin);
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
295 }
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
296 }
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
297 }
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
298
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
299 if (request.IsRetrieveChildrenIdentifiers())
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
300 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
301 std::list<std::string> children;
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
302 transaction_.GetChildrenPublicId(children, internalId);
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
304 for (std::list<std::string>::const_iterator it = children.begin(); it != children.end(); ++it)
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 {
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
306 resource->AddChildIdentifier(*it);
5565
def06a42e5ef Updated FindRequest & FindResponse definitions
Alain Mazy <am@orthanc.team>
parents: 5554
diff changeset
307 }
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
308 }
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
310 for (std::set<MetadataType>::const_iterator it = request.GetRetrieveChildrenMetadata().begin();
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
311 it != request.GetRetrieveChildrenMetadata().end(); ++it)
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
312 {
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
313 std::list<std::string> values;
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
314 transaction_.GetChildrenMetadata(values, internalId, *it);
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
315 resource->AddChildrenMetadata(*it, values);
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
316 }
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
317
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
318 if (request.IsRetrieveOneInstanceIdentifier())
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
319 {
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
320 int64_t currentId = internalId;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
321 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
322
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
323 while (currentLevel != ResourceType_Instance)
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
324 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
325 std::list<int64_t> children;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
326 transaction_.GetChildrenInternalId(children, currentId);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
327 if (children.empty())
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
328 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
329 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
330 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
331 else
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
332 {
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
333 currentId = children.front();
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
334 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
335 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
336 }
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
337
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
338 resource->SetOneInstanceIdentifier(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
339 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
340
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
341 response.Add(resource.release());
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 }