Mercurial > hg > orthanc
annotate OrthancServer/Sources/Database/FindResponse.cpp @ 5592:1e2631b8b9af find-refactoring
GenericFind::Execute() is working for a basic request
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 03 May 2024 21:26:06 +0200 |
parents | b51ee994cd6f |
children | a906dc19264c |
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 "FindResponse.h" |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #include "../../../OrthancFramework/Sources/DicomFormat/DicomInstanceHasher.h" |
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 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 #include <cassert> |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 |
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 { |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
33 class FindResponse::Resource::DicomValue : public boost::noncopyable |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
34 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
35 public: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
36 enum ValueType |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
37 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
38 ValueType_String, |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
39 ValueType_Null |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
40 }; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
41 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
42 private: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
43 ValueType type_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
44 std::string value_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
45 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
46 public: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
47 DicomValue(ValueType type, |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
48 const std::string& value) : |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
49 type_(type), |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
50 value_(value) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
51 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
52 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
53 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
54 ValueType GetType() const |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
55 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
56 return type_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
57 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
58 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
59 const std::string& GetValue() const |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
60 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
61 switch (type_) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
62 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
63 case ValueType_Null: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
64 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
65 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
66 case ValueType_String: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
67 return value_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
68 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
69 default: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
70 throw OrthancException(ErrorCode_ParameterOutOfRange); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
71 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
72 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
73 }; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
74 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
75 |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
76 void FindResponse::Resource::AddNullDicomTag(uint16_t group, |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
77 uint16_t element) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
78 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
79 const DicomTag tag(group, element); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
80 |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
81 if (mainDicomTags_.find(tag) == mainDicomTags_.end()) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
82 { |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
83 mainDicomTags_[tag] = new DicomValue(DicomValue::ValueType_Null, ""); |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
84 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
85 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
86 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
87 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
88 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
89 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
90 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
91 |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
92 void FindResponse::Resource::AddStringDicomTag(uint16_t group, |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
93 uint16_t element, |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
94 const std::string& value) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
95 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
96 const DicomTag tag(group, element); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
97 |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
98 if (mainDicomTags_.find(tag) == mainDicomTags_.end()) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
99 { |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
100 mainDicomTags_[tag] = new DicomValue(DicomValue::ValueType_String, value); |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
101 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
102 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
103 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
104 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
105 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
106 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
107 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
108 |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
109 void FindResponse::Resource::GetMainDicomTags(DicomMap& target) const |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
110 { |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
111 for (MainDicomTags::const_iterator it = mainDicomTags_.begin(); it != mainDicomTags_.end(); ++it) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
112 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
113 assert(it->second != NULL); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
114 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
115 switch (it->second->GetType()) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
116 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
117 case DicomValue::ValueType_String: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
118 target.SetValue(it->first, it->second->GetValue(), false /* not binary */); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
119 break; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
120 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
121 case DicomValue::ValueType_Null: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
122 target.SetNullValue(it->first); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
123 break; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
124 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
125 default: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
126 throw OrthancException(ErrorCode_InternalError); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
127 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
128 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
129 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
130 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
131 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
132 void FindResponse::ChildrenAtLevel::AddIdentifier(const std::string& identifier) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
133 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
134 if (identifiers_.find(identifier) == identifiers_.end()) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
135 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
136 identifiers_.insert(identifier); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
137 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
138 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
139 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
140 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
141 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
142 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
143 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
144 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
145 FindResponse::ChildrenAtLevel& FindResponse::Resource::GetChildrenAtLevel(ResourceType level) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 { |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
147 switch (level) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 { |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
149 case ResourceType_Study: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
150 if (level_ == ResourceType_Patient) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
151 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
152 return childrenStudies_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
153 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
154 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
155 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
156 throw OrthancException(ErrorCode_BadParameterType); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
157 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
158 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
159 case ResourceType_Series: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
160 if (level_ == ResourceType_Patient || |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
161 level_ == ResourceType_Study) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
162 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
163 return childrenSeries_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
164 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
165 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
166 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
167 throw OrthancException(ErrorCode_BadParameterType); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
168 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
169 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
170 case ResourceType_Instance: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
171 if (level_ == ResourceType_Patient || |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
172 level_ == ResourceType_Study || |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
173 level_ == ResourceType_Series) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
174 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
175 return childrenInstances_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
176 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
177 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
178 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
179 throw OrthancException(ErrorCode_BadParameterType); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
180 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
181 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
182 default: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
183 throw OrthancException(ErrorCode_ParameterOutOfRange); |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
188 void FindResponse::Resource::AddMetadata(MetadataType metadata, |
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
189 const std::string& value) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 if (metadata_.find(metadata) != metadata_.end()) |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 throw OrthancException(ErrorCode_BadSequenceOfCalls); // Metadata already present |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 { |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5565
diff
changeset
|
197 metadata_[metadata] = value; |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
202 bool FindResponse::Resource::LookupMetadata(std::string& value, |
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
203 MetadataType metadata) const |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 { |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5565
diff
changeset
|
205 std::map<MetadataType, std::string>::const_iterator found = metadata_.find(metadata); |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 if (found == metadata_.end()) |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 return false; |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 { |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5565
diff
changeset
|
213 value = found->second; |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 return true; |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
219 void FindResponse::Resource::ListMetadata(std::set<MetadataType>& target) const |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
220 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 target.clear(); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5565
diff
changeset
|
223 for (std::map<MetadataType, std::string>::const_iterator it = metadata_.begin(); it != metadata_.end(); ++it) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 target.insert(it->first); |
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 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
229 const std::string& FindResponse::Resource::GetParentIdentifier() const |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
230 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
231 if (level_ == ResourceType_Patient) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
232 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
233 throw OrthancException(ErrorCode_BadParameterType); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
234 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
235 else if (HasParentIdentifier()) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
236 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
237 return *parentIdentifier_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
238 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
239 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
240 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
241 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
242 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
243 } |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
244 |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
245 |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
246 FindResponse::Resource::~Resource() |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
247 { |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
248 for (MainDicomTags::iterator it = mainDicomTags_.begin(); it != mainDicomTags_.end(); ++it) |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
249 { |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
250 assert(it->second != NULL); |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
251 delete it->second; |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
252 } |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
253 } |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
254 |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
255 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
256 void FindResponse::Resource::SetParentIdentifier(const std::string& id) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
257 { |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
258 if (level_ == ResourceType_Patient) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
259 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
260 throw OrthancException(ErrorCode_BadParameterType); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
261 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
262 else if (HasParentIdentifier()) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
263 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
265 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
266 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
267 { |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
268 parentIdentifier_.reset(new std::string(id)); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
269 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
270 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
271 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
272 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
273 bool FindResponse::Resource::HasParentIdentifier() const |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
274 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
275 if (level_ == ResourceType_Patient) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
276 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
277 throw OrthancException(ErrorCode_BadParameterType); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
278 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
279 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
280 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
281 return parentIdentifier_.get() != NULL; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
282 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
283 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
284 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
285 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
286 void FindResponse::Resource::AddLabel(const std::string& label) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
287 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
288 if (labels_.find(label) == labels_.end()) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
289 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
290 labels_.insert(label); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
291 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
292 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
293 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
294 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
295 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
296 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
297 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
298 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
299 void FindResponse::Resource::AddAttachment(const FileInfo& attachment) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
300 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
301 if (attachments_.find(attachment.GetContentType()) == attachments_.end()) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
302 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
303 attachments_[attachment.GetContentType()] = attachment; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
304 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
305 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
306 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
307 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
308 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
309 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
310 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
311 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
312 bool FindResponse::Resource::LookupAttachment(FileInfo& target, FileContentType type) const |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
313 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
314 std::map<FileContentType, FileInfo>::const_iterator it = attachments_.find(type); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
315 if (it != attachments_.end()) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
316 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
317 target = it->second; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
318 return true; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
319 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
320 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
321 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
322 return false; |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
323 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
324 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
325 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
326 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
327 FindResponse::~FindResponse() |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
328 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
329 for (size_t i = 0; i < items_.size(); i++) |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
330 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
331 assert(items_[i] != NULL); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
332 delete items_[i]; |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
333 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
334 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
335 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
336 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
337 void FindResponse::Add(Resource* item /* takes ownership */) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
338 { |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
339 std::unique_ptr<Resource> protection(item); |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
340 |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
341 if (item == NULL) |
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 throw OrthancException(ErrorCode_NullPointer); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
344 } |
5588
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
345 else if (!items_.empty() && |
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
346 items_[0]->GetLevel() != item->GetLevel()) |
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
347 { |
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
348 throw OrthancException(ErrorCode_BadParameterType, "A find response must only contain resources of the same type"); |
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
349 } |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
350 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
351 { |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
352 const std::string& id = item->GetIdentifier(); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
353 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
354 if (index_.find(id) == index_.end()) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
355 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
356 items_.push_back(protection.release()); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
357 index_[id] = item; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
358 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
359 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
360 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
361 throw OrthancException(ErrorCode_BadSequenceOfCalls, "This resource has already been added: " + id); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
362 } |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
363 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
364 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
365 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
366 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
367 const FindResponse::Resource& FindResponse::GetResource(size_t index) const |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
368 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
369 if (index >= items_.size()) |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
370 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
371 throw OrthancException(ErrorCode_ParameterOutOfRange); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
372 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
373 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
374 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
375 assert(items_[index] != NULL); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
376 return *items_[index]; |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
377 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
378 } |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5565
diff
changeset
|
379 |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
380 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
381 FindResponse::Resource& FindResponse::GetResource(const std::string& id) |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5565
diff
changeset
|
382 { |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
383 Index::const_iterator found = index_.find(id); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
384 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
385 if (found == index_.end()) |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5565
diff
changeset
|
386 { |
5588
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
387 throw OrthancException(ErrorCode_InexistentItem); |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5565
diff
changeset
|
388 } |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
389 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
390 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
391 assert(found->second != NULL); |
5588
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
392 return *found->second; |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
393 } |
5568
b0b5546f1b9f
find refactor: re-use existing code. /studies?expand is almost fully implemented with new code
Alain Mazy <am@orthanc.team>
parents:
5565
diff
changeset
|
394 } |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
395 } |