annotate OrthancServer/Sources/Database/Compatibility/GenericFind.cpp @ 5616:1e92fb051fd7 find-refactoring

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 09 May 2024 13:02:51 +0200
parents a10978a5e65c
children 8905ffa45fc2
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) &&
5616
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5615
diff changeset
62 request.GetLevel() == ResourceType_Patient &&
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
63 request.GetOrthancIdentifiers().HasPatientId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
64 !request.GetOrthancIdentifiers().HasStudyId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
65 !request.GetOrthancIdentifiers().HasSeriesId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
66 !request.GetOrthancIdentifiers().HasInstanceId())
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
67 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
68 identifiers.push_back(request.GetOrthancIdentifiers().GetPatientId());
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
69 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
70 else if (IsRequestWithoutContraint(request) &&
5616
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5615
diff changeset
71 request.GetLevel() == ResourceType_Study &&
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
72 !request.GetOrthancIdentifiers().HasPatientId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
73 request.GetOrthancIdentifiers().HasStudyId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
74 !request.GetOrthancIdentifiers().HasSeriesId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
75 !request.GetOrthancIdentifiers().HasInstanceId())
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 identifiers.push_back(request.GetOrthancIdentifiers().GetStudyId());
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
78 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
79 else if (IsRequestWithoutContraint(request) &&
5616
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5615
diff changeset
80 request.GetLevel() == ResourceType_Series &&
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
81 !request.GetOrthancIdentifiers().HasPatientId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
82 !request.GetOrthancIdentifiers().HasStudyId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
83 request.GetOrthancIdentifiers().HasSeriesId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
84 !request.GetOrthancIdentifiers().HasInstanceId())
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
85 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
86 identifiers.push_back(request.GetOrthancIdentifiers().GetSeriesId());
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
87 }
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
88 else if (IsRequestWithoutContraint(request) &&
5616
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5615
diff changeset
89 request.GetLevel() == ResourceType_Instance &&
5615
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
90 !request.GetOrthancIdentifiers().HasPatientId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
91 !request.GetOrthancIdentifiers().HasStudyId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
92 !request.GetOrthancIdentifiers().HasSeriesId() &&
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
93 request.GetOrthancIdentifiers().HasInstanceId())
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
94 {
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
95 identifiers.push_back(request.GetOrthancIdentifiers().GetInstanceId());
a10978a5e65c expansion of single resources using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5614
diff changeset
96 }
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 else
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 {
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
99 throw OrthancException(ErrorCode_NotImplemented); // Not supported
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
100 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
101 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
102
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
103
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
104 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
105 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
106 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
107 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
108 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
109 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
110
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
111 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
112 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
113 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
114 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
115 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
116 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
117 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
118 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
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 else
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 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
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 }
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
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 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
129 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
130 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
131 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
132 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
133 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
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 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
136 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
137 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
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_Patient;
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 else
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
142 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
143 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
144 }
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 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
147 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
148 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
149 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
150 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
151 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
152 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
153 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
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_Study;
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 else
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
158 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
159 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
160 }
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 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
163 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
164 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
165 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
166 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
167 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
168 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
169 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
170 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
171 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
172 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
173 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
174 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
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_Series;
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 else
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
179 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
180 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
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 default:
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
184 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
185 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
186 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
187
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
188
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
189 void GenericFind::ExecuteExpand(FindResponse& response,
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
190 const FindRequest& request,
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
191 const std::string& identifier)
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
192 {
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
193 int64_t internalId;
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
194 ResourceType level;
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
195 std::string parent;
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 if (request.IsRetrieveParentIdentifier())
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
198 {
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
199 if (!transaction_.LookupResourceAndParent(internalId, level, parent, identifier))
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
200 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
201 return; // The resource is not available anymore
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
202 }
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 if (level == ResourceType_Patient)
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 if (!parent.empty())
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
207 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
208 throw OrthancException(ErrorCode_DatabasePlugin);
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
209 }
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 else
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 if (parent.empty())
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 throw OrthancException(ErrorCode_DatabasePlugin);
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 }
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 else
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 if (!transaction_.LookupResource(internalId, level, identifier))
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 return; // The resource is not available anymore
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 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
226
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
227 if (level != request.GetLevel())
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
228 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
229 throw OrthancException(ErrorCode_DatabasePlugin);
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231
5606
6e2dad336446 added "IsStable" field in expanded resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5596
diff changeset
232 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
233
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
234 if (request.IsRetrieveParentIdentifier())
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
235 {
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
236 assert(!parent.empty());
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
237 resource->SetParentIdentifier(parent);
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
238 }
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
239
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 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
242 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
243 const ResourceType topLevel = GetTopLevelOfInterest(request);
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
244
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 for (;;)
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
246 {
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
247 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
248 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
249 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
250 }
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 if (request.IsRetrieveMetadata(currentLevel))
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
253 {
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
254 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
255 }
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 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
258 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
259 break;
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
260 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
261 else
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
262 {
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
263 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
264 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
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 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
267 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
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 else
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
270 {
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
271 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
272 }
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
273 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
274 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
275 }
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
276
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
277 if (request.IsRetrieveLabels())
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
278 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
279 transaction_.ListLabels(resource->GetLabels(), internalId);
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
280 }
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
281
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
282 if (request.IsRetrieveAttachments())
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
283 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
284 std::set<FileContentType> attachments;
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
285 transaction_.ListAvailableAttachments(attachments, internalId);
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
286
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
287 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
288 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
289 FileInfo info;
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
290 int64_t revision;
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
291 if (transaction_.LookupAttachment(info, revision, internalId, *it) &&
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
292 info.GetContentType() == *it)
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
293 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
294 resource->AddAttachment(info);
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 else
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
297 {
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
298 throw OrthancException(ErrorCode_DatabasePlugin);
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
299 }
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 }
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
302
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
303 if (request.IsRetrieveChildrenIdentifiers())
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
304 {
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
305 std::list<std::string> children;
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
306 transaction_.GetChildrenPublicId(children, internalId);
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
308 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
309 {
5596
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
310 resource->AddChildIdentifier(*it);
5565
def06a42e5ef Updated FindRequest & FindResponse definitions
Alain Mazy <am@orthanc.team>
parents: 5554
diff changeset
311 }
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
312 }
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
314 for (std::set<MetadataType>::const_iterator it = request.GetRetrieveChildrenMetadata().begin();
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
315 it != request.GetRetrieveChildrenMetadata().end(); ++it)
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
316 {
5595
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
317 std::list<std::string> values;
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
318 transaction_.GetChildrenMetadata(values, internalId, *it);
a87f2a56257d implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5594
diff changeset
319 resource->AddChildrenMetadata(*it, values);
5594
a906dc19264c created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5593
diff changeset
320 }
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
321
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
322 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
323 {
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
324 int64_t currentId = internalId;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
325 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
326
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
327 while (currentLevel != ResourceType_Instance)
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 std::list<int64_t> children;
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
330 transaction_.GetChildrenInternalId(children, currentId);
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
331 if (children.empty())
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
332 {
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
333 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
334 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
335 else
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 currentId = children.front();
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
338 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
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 }
5609
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
341
4690a0d2b01e preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5606
diff changeset
342 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
343 }
81a29ad7fb4b added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5595
diff changeset
344
5593
862b54b4cfe2 implemented the default multi-stage find/expand
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5592
diff changeset
345 response.Add(resource.release());
5554
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 }
12d8a1a266e9 introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348 }