Mercurial > hg > orthanc
annotate OrthancServer/Sources/Database/FindResponse.cpp @ 5621:732ec9feeea8 find-refactoring
introduction of FindRequest::ChildrenRetrieveSpecification
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 11 May 2024 15:43:07 +0200 |
parents | 1864b16bc7b1 |
children | 3f13db27b399 |
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 |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
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" |
5595
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
27 #include "../../../OrthancFramework/Sources/SerializationToolbox.h" |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
29 #include <boost/lexical_cast.hpp> |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 #include <cassert> |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 namespace Orthanc |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 { |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
35 class FindResponse::MainDicomTagsAtLevel::DicomValue : public boost::noncopyable |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
36 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
37 public: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
38 enum ValueType |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
39 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
40 ValueType_String, |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
41 ValueType_Null |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
42 }; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
43 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
44 private: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
45 ValueType type_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
46 std::string value_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
47 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
48 public: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
49 DicomValue(ValueType type, |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
50 const std::string& value) : |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
51 type_(type), |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
52 value_(value) |
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 } |
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 ValueType GetType() const |
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 return type_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
59 } |
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 const std::string& GetValue() const |
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 switch (type_) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
64 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
65 case ValueType_Null: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
66 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
67 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
68 case ValueType_String: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
69 return value_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
70 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
71 default: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
72 throw OrthancException(ErrorCode_ParameterOutOfRange); |
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 }; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
76 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
77 |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
78 FindResponse::MainDicomTagsAtLevel::~MainDicomTagsAtLevel() |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
79 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
80 for (MainDicomTags::iterator it = mainDicomTags_.begin(); it != mainDicomTags_.end(); ++it) |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
81 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
82 assert(it->second != NULL); |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
83 delete it->second; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
84 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
85 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
86 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
87 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
88 void FindResponse::MainDicomTagsAtLevel::AddNullDicomTag(uint16_t group, |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
89 uint16_t element) |
5586
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 const DicomTag tag(group, element); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
92 |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
93 if (mainDicomTags_.find(tag) == mainDicomTags_.end()) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
94 { |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
95 mainDicomTags_[tag] = new DicomValue(DicomValue::ValueType_Null, ""); |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
96 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
97 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
98 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
99 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
100 } |
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 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
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 FindResponse::MainDicomTagsAtLevel::AddStringDicomTag(uint16_t group, |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
105 uint16_t element, |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
106 const std::string& value) |
5586
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 const DicomTag tag(group, element); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
109 |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
110 if (mainDicomTags_.find(tag) == mainDicomTags_.end()) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
111 { |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
112 mainDicomTags_[tag] = new DicomValue(DicomValue::ValueType_String, value); |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
113 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
114 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
115 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
116 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
117 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
118 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
119 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
120 |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
121 void FindResponse::MainDicomTagsAtLevel::Export(DicomMap& target) const |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
122 { |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
123 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
|
124 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
125 assert(it->second != NULL); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
126 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
127 switch (it->second->GetType()) |
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 case DicomValue::ValueType_String: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
130 target.SetValue(it->first, it->second->GetValue(), false /* not binary */); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
131 break; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
132 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
133 case DicomValue::ValueType_Null: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
134 target.SetNullValue(it->first); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
135 break; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
136 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
137 default: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
138 throw OrthancException(ErrorCode_InternalError); |
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 } |
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 |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
144 void FindResponse::Resource::AddChildIdentifier(const std::string& identifier) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
145 { |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
146 if (childrenIdentifiers_.find(identifier) == childrenIdentifiers_.end()) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
147 { |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
148 childrenIdentifiers_.insert(identifier); |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
149 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
150 else |
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 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
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 } |
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 |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
157 FindResponse::MainDicomTagsAtLevel& FindResponse::Resource::GetMainDicomTagsAtLevel(ResourceType level) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 { |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
159 if (!IsResourceLevelAboveOrEqual(level, level_)) |
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 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
|
162 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
163 |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
164 switch (level) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 { |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
166 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
|
167 return mainDicomTagsPatient_; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
168 |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
169 case ResourceType_Study: |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
170 return mainDicomTagsStudy_; |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
171 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
172 case ResourceType_Series: |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
173 return mainDicomTagsSeries_; |
5586
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 case ResourceType_Instance: |
5596
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 mainDicomTagsInstance_; |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
177 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
178 default: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
179 throw OrthancException(ErrorCode_ParameterOutOfRange); |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
184 void FindResponse::Resource::AddMetadata(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
|
185 MetadataType metadata, |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
186 const std::string& value) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 { |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
188 std::map<MetadataType, std::string>& m = GetMetadata(level); |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
189 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
190 if (m.find(metadata) != m.end()) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 throw OrthancException(ErrorCode_BadSequenceOfCalls); // Metadata already present |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 { |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
196 m[metadata] = value; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
197 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
198 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
199 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
200 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
201 std::map<MetadataType, std::string>& FindResponse::Resource::GetMetadata(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
|
202 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
203 if (!IsResourceLevelAboveOrEqual(level, level_)) |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
204 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
205 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
|
206 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
207 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
208 switch (level) |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
209 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
210 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
|
211 return metadataPatient_; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
212 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
213 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
|
214 return metadataStudy_; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
215 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
216 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
|
217 return metadataSeries_; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
218 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
219 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
|
220 return metadataInstance_; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
221 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
222 default: |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
223 throw OrthancException(ErrorCode_ParameterOutOfRange); |
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 } |
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 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
228 bool FindResponse::Resource::LookupMetadata(std::string& value, |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
229 ResourceType level, |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
230 MetadataType metadata) const |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 { |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
232 const std::map<MetadataType, std::string>& m = GetMetadata(level); |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
234 std::map<MetadataType, std::string>::const_iterator found = m.find(metadata); |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
235 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
236 if (found == m.end()) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
237 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
238 return false; |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 { |
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
|
242 value = found->second; |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
243 return true; |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
244 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
246 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
247 |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
248 FindResponse::Resource::~Resource() |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
249 { |
5595
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
250 for (ChildrenMetadata::iterator it = childrenMetadata_.begin(); it != childrenMetadata_.end(); ++it) |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
251 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
252 assert(it->second != NULL); |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
253 delete it->second; |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
254 } |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
255 } |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
256 |
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
257 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
258 void FindResponse::Resource::SetParentIdentifier(const std::string& id) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
259 { |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
260 if (level_ == ResourceType_Patient) |
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 throw OrthancException(ErrorCode_BadParameterType); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
263 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
264 else if (HasParentIdentifier()) |
5554
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 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
267 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
268 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
269 { |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
270 parentIdentifier_.reset(new std::string(id)); |
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 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
273 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
274 |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
275 const std::string& FindResponse::Resource::GetParentIdentifier() const |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
276 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
277 if (level_ == ResourceType_Patient) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
278 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
279 throw OrthancException(ErrorCode_BadParameterType); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
280 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
281 else if (HasParentIdentifier()) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
282 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
283 return *parentIdentifier_; |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
284 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
285 else |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
286 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
287 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
288 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
289 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
290 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
291 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
292 bool FindResponse::Resource::HasParentIdentifier() const |
5586
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 if (level_ == ResourceType_Patient) |
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 throw OrthancException(ErrorCode_BadParameterType); |
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 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
299 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
300 return parentIdentifier_.get() != NULL; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
301 } |
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 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
304 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
305 void FindResponse::Resource::AddLabel(const std::string& label) |
5586
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 if (labels_.find(label) == labels_.end()) |
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 labels_.insert(label); |
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 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
312 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
313 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
314 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
315 } |
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 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
318 void FindResponse::Resource::AddAttachment(const FileInfo& attachment) |
5586
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 if (attachments_.find(attachment.GetContentType()) == attachments_.end()) |
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 attachments_[attachment.GetContentType()] = attachment; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
323 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
324 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
325 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
326 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
327 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
328 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
329 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
330 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
331 bool FindResponse::Resource::LookupAttachment(FileInfo& target, FileContentType type) const |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
332 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
333 std::map<FileContentType, FileInfo>::const_iterator it = attachments_.find(type); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
334 if (it != attachments_.end()) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
335 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
336 target = it->second; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
337 return true; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
338 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
339 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
340 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
341 return false; |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
342 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
343 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
344 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
345 |
5595
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
346 void FindResponse::Resource::AddChildrenMetadata(MetadataType metadata, |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
347 const std::list<std::string>& values) |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
348 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
349 if (childrenMetadata_.find(metadata) == childrenMetadata_.end()) |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
350 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
351 childrenMetadata_[metadata] = new std::list<std::string>(values); |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
352 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
353 else |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
354 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
355 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
356 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
357 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
358 |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
359 |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
360 bool FindResponse::Resource::LookupChildrenMetadata(std::list<std::string>& values, |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
361 MetadataType metadata) const |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
362 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
363 ChildrenMetadata::const_iterator found = childrenMetadata_.find(metadata); |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
364 if (found == childrenMetadata_.end()) |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
365 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
366 return false; |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
367 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
368 else |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
369 { |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
370 assert(found->second != NULL); |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
371 values = *found->second; |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
372 return true; |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
373 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
374 } |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
375 |
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
376 |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
377 void FindResponse::Resource::SetOneInstanceIdentifier(const std::string& id) |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
378 { |
5610
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
379 if (level_ == ResourceType_Instance) |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
380 { |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
381 throw OrthancException(ErrorCode_BadParameterType); |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
382 } |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
383 else if (HasOneInstanceIdentifier()) |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
384 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
385 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
386 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
387 else |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
388 { |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
389 oneInstanceIdentifier_.reset(new std::string(id)); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
390 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
391 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
392 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
393 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
394 const std::string& FindResponse::Resource::GetOneInstanceIdentifier() const |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
395 { |
5610
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
396 if (level_ == ResourceType_Instance) |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
397 { |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
398 throw OrthancException(ErrorCode_BadParameterType); |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
399 } |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
400 else if (HasOneInstanceIdentifier()) |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
401 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
402 return *oneInstanceIdentifier_; |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
403 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
404 else |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
405 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
406 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
407 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
408 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
409 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
410 |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
411 bool FindResponse::Resource::HasOneInstanceIdentifier() const |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
412 { |
5610
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
413 if (level_ == ResourceType_Instance) |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
414 { |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
415 throw OrthancException(ErrorCode_BadParameterType); |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
416 } |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
417 else |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
418 { |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
419 return oneInstanceIdentifier_.get() != NULL; |
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
420 } |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
421 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
422 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
423 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
424 static void DebugDicomMap(Json::Value& target, |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
425 const 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
|
426 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
427 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
|
428 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
|
429 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
430 if (a.GetElement(i).GetValue().IsNull()) |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
431 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
432 target[a.GetElement(i).GetTag().Format()] = Json::nullValue; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
433 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
434 else if (a.GetElement(i).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
|
435 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
436 target[a.GetElement(i).GetTag().Format()] = a.GetElement(i).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
|
437 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
438 else |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
439 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
440 throw OrthancException(ErrorCode_InternalError); |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
441 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
442 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
443 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
444 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
445 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
446 static void DebugMetadata(Json::Value& target, |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
447 const std::map<MetadataType, std::string>& m) |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
448 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
449 target = Json::objectValue; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
450 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
451 for (std::map<MetadataType, std::string>::const_iterator it = m.begin(); it != m.end(); ++it) |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
452 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
453 target[EnumerationToString(it->first)] = it->second; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
454 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
455 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
456 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
457 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
458 static void DebugAddAttachment(Json::Value& target, |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
459 const FileInfo& info) |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
460 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
461 Json::Value u = Json::arrayValue; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
462 u.append(info.GetUuid()); |
5602 | 463 u.append(static_cast<Json::UInt64>(info.GetUncompressedSize())); |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
464 target[EnumerationToString(info.GetContentType())] = u; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
465 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
466 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
467 void FindResponse::Resource::DebugExport(Json::Value& target, |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
468 const FindRequest& request) const |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
469 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
470 target = Json::objectValue; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
471 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
472 target["Level"] = EnumerationToString(GetLevel()); |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
473 target["ID"] = GetIdentifier(); |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
474 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
475 if (request.IsRetrieveParentIdentifier()) |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
476 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
477 target["ParentID"] = GetParentIdentifier(); |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
478 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
479 |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
480 if (request.IsRetrieveMainDicomTags()) |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
481 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
482 DicomMap m; |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
483 GetMainDicomTags(m, request.GetLevel()); |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
484 DebugDicomMap(target[EnumerationToString(GetLevel())]["MainDicomTags"], m); |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
485 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
486 |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
487 if (request.IsRetrieveMetadata()) |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
488 { |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
489 DebugMetadata(target[EnumerationToString(GetLevel())]["Metadata"], GetMetadata(request.GetLevel())); |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
490 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
491 |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
492 static const ResourceType levels[4] = { ResourceType_Patient, ResourceType_Study, ResourceType_Series, ResourceType_Instance }; |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
493 |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
494 for (size_t i = 0; i < 4; i++) |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
495 { |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
496 const char* level = EnumerationToString(levels[i]); |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
497 |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
498 if (levels[i] != request.GetLevel() && |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
499 IsResourceLevelAboveOrEqual(levels[i], request.GetLevel())) |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
500 { |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
501 if (request.GetParentRetrieveSpecification(levels[i]).IsRetrieveMainDicomTags()) |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
502 { |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
503 DicomMap m; |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
504 GetMainDicomTags(m, levels[i]); |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
505 DebugDicomMap(target[level]["MainDicomTags"], m); |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
506 } |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
507 |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
508 if (request.GetParentRetrieveSpecification(levels[i]).IsRetrieveMainDicomTags()) |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
509 { |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
510 DebugMetadata(target[level]["Metadata"], GetMetadata(levels[i])); |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
511 } |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
512 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
513 |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
514 if (levels[i] != request.GetLevel() && |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
515 IsResourceLevelAboveOrEqual(request.GetLevel(), levels[i])) |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
516 { |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
517 if (request.GetChildrenRetrieveSpecification(levels[i]).IsRetrieveIdentifiers()) |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
518 { |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
519 if (levels[i] != GetChildResourceType(request.GetLevel())) |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
520 { |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
521 throw OrthancException(ErrorCode_NotImplemented); // TODO-FIND |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
522 } |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
523 else |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
524 { |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
525 Json::Value v = Json::arrayValue; |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
526 for (std::set<std::string>::const_iterator it = childrenIdentifiers_.begin(); |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
527 it != childrenIdentifiers_.end(); ++it) |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
528 { |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
529 v.append(*it); |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
530 } |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
531 target[level]["Identifiers"] = v; |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
532 } |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
533 } |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
534 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
535 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
536 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
537 if (request.IsRetrieveLabels()) |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
538 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
539 Json::Value v = Json::arrayValue; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
540 for (std::set<std::string>::const_iterator it = labels_.begin(); |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
541 it != labels_.end(); ++it) |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
542 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
543 v.append(*it); |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
544 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
545 target["Labels"] = v; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
546 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
547 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
548 if (request.IsRetrieveAttachments()) |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
549 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
550 Json::Value v = Json::objectValue; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
551 for (std::map<FileContentType, FileInfo>::const_iterator it = attachments_.begin(); |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
552 it != attachments_.end(); ++it) |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
553 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
554 if (it->first != it->second.GetContentType()) |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
555 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
556 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
|
557 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
558 else |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
559 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
560 DebugAddAttachment(v, it->second); |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
561 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
562 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
563 target["Attachments"] = v; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
564 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
565 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
566 for (std::set<MetadataType>::const_iterator it = request.GetRetrieveChildrenMetadata().begin(); |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
567 it != request.GetRetrieveChildrenMetadata().end(); ++it) |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
568 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
569 std::list<std::string> l; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
570 if (LookupChildrenMetadata(l, *it)) |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
571 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
572 Json::Value v = Json::arrayValue; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
573 for (std::list<std::string>::const_iterator it2 = l.begin(); it2 != l.end(); ++it2) |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
574 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
575 v.append(*it2); |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
576 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
577 target["ChildrenMetadata"][EnumerationToString(*it)] = v; |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
578 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
579 else |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
580 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
581 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
|
582 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
583 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
584 |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
585 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
|
586 { |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
587 target["OneInstance"] = GetOneInstanceIdentifier(); |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
588 } |
5594
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
589 } |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
590 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
591 |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
592 FindResponse::~FindResponse() |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
593 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
594 for (size_t i = 0; i < items_.size(); i++) |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
595 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
596 assert(items_[i] != NULL); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
597 delete items_[i]; |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
598 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
599 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
600 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
601 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
602 void FindResponse::Add(Resource* item /* takes ownership */) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
603 { |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
604 std::unique_ptr<Resource> protection(item); |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
605 |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
606 if (item == NULL) |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
607 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
608 throw OrthancException(ErrorCode_NullPointer); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
609 } |
5588
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
610 else if (!items_.empty() && |
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
611 items_[0]->GetLevel() != item->GetLevel()) |
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
612 { |
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
613 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
|
614 } |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
615 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
616 { |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
617 const std::string& id = item->GetIdentifier(); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
618 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
619 if (index_.find(id) == index_.end()) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
620 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
621 items_.push_back(protection.release()); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
622 index_[id] = item; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
623 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
624 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
625 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
626 throw OrthancException(ErrorCode_BadSequenceOfCalls, "This resource has already been added: " + id); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
627 } |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
628 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
629 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
630 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
631 |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
632 const FindResponse::Resource& FindResponse::GetResourceByIndex(size_t index) const |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
633 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
634 if (index >= items_.size()) |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
635 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
636 throw OrthancException(ErrorCode_ParameterOutOfRange); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
637 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
638 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
639 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
640 assert(items_[index] != NULL); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
641 return *items_[index]; |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
642 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
643 } |
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
|
644 |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
645 |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
646 FindResponse::Resource& FindResponse::GetResourceByIdentifier(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
|
647 { |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
648 Index::const_iterator found = index_.find(id); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
649 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
650 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
|
651 { |
5588
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
652 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
|
653 } |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
654 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
655 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
656 assert(found->second != NULL); |
5588
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
657 return *found->second; |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
658 } |
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
|
659 } |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
660 } |