Mercurial > hg > orthanc
annotate OrthancServer/Sources/Database/FindResponse.cpp @ 5854:65f8c6dfba50 find-refactoring
cleanup
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Mon, 04 Nov 2024 17:51:46 +0100 |
parents | ea547160f27e |
children |
rev | line source |
---|---|
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
5641
3f13db27b399
integration mainline->find-refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5621
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
3f13db27b399
integration mainline->find-refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5621
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * This program is free software: you can redistribute it and/or |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * modify it under the terms of the GNU General Public License as |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * published by the Free Software Foundation, either version 3 of the |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * License, or (at your option) any later version. |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * This program is distributed in the hope that it will be useful, but |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * WITHOUT ANY WARRANTY; without even the implied warranty of |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * General Public License for more details. |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * You should have received a copy of the GNU General Public License |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 **/ |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include "FindResponse.h" |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
26 #include "../../../OrthancFramework/Sources/DicomFormat/DicomArray.h" |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 #include "../../../OrthancFramework/Sources/OrthancException.h" |
5595
a87f2a56257d
implemented FindRequest::retrieveChildrenMetadata_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5594
diff
changeset
|
28 #include "../../../OrthancFramework/Sources/SerializationToolbox.h" |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
30 #include <boost/lexical_cast.hpp> |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 #include <cassert> |
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 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 namespace Orthanc |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 { |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
36 class FindResponse::MainDicomTagsAtLevel::DicomValue : public boost::noncopyable |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
37 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
38 public: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
39 enum ValueType |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
40 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
41 ValueType_String, |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
42 ValueType_Null |
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 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
45 private: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
46 ValueType type_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
47 std::string value_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
48 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
49 public: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
50 DicomValue(ValueType type, |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
51 const std::string& value) : |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
52 type_(type), |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
53 value_(value) |
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 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
57 ValueType GetType() const |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
58 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
59 return type_; |
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 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
62 const std::string& GetValue() const |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
63 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
64 switch (type_) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
65 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
66 case ValueType_Null: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
67 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
68 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
69 case ValueType_String: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
70 return value_; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
71 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
72 default: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
73 throw OrthancException(ErrorCode_ParameterOutOfRange); |
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 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
78 |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
79 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
|
80 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
81 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
|
82 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
83 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
|
84 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
|
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 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
89 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
|
90 uint16_t element) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
91 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
92 const DicomTag tag(group, element); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
93 |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
94 if (mainDicomTags_.find(tag) == mainDicomTags_.end()) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
95 { |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
96 mainDicomTags_[tag] = new DicomValue(DicomValue::ValueType_Null, ""); |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
97 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
98 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
99 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
100 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
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 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
104 |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
105 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
|
106 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
|
107 const std::string& value) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
108 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
109 const DicomTag tag(group, element); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
110 |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
111 if (mainDicomTags_.find(tag) == mainDicomTags_.end()) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
112 { |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
113 mainDicomTags_[tag] = new DicomValue(DicomValue::ValueType_String, value); |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
114 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
115 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
116 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
117 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
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 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
121 |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
122 void FindResponse::MainDicomTagsAtLevel::Export(DicomMap& target) const |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
123 { |
5592
1e2631b8b9af
GenericFind::Execute() is working for a basic request
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5589
diff
changeset
|
124 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
|
125 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
126 assert(it->second != NULL); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
127 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
128 switch (it->second->GetType()) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
129 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
130 case DicomValue::ValueType_String: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
131 target.SetValue(it->first, it->second->GetValue(), false /* not binary */); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
132 break; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
133 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
134 case DicomValue::ValueType_Null: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
135 target.SetNullValue(it->first); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
136 break; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
137 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
138 default: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
139 throw OrthancException(ErrorCode_InternalError); |
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 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
144 |
5673 | 145 FindResponse::ChildrenInformation::~ChildrenInformation() |
146 { | |
147 for (MetadataValues::iterator it = metadataValues_.begin(); it != metadataValues_.end(); ++it) | |
148 { | |
149 assert(it->second != NULL); | |
150 delete it->second; | |
151 } | |
152 | |
153 for (MainDicomTagValues::iterator it = mainDicomTagValues_.begin(); it != mainDicomTagValues_.end(); ++it) | |
154 { | |
155 assert(it->second != NULL); | |
156 delete it->second; | |
157 } | |
158 } | |
159 | |
160 | |
5671
b4c97c51f9db
added FindResponse::Resource::ChildrenInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
161 void FindResponse::ChildrenInformation::AddIdentifier(const std::string& identifier) |
b4c97c51f9db
added FindResponse::Resource::ChildrenInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
162 { |
5750
f39406a9eda4
ExtendedFind in SQLite continued (6 tests still failing)
Alain Mazy <am@orthanc.team>
parents:
5749
diff
changeset
|
163 // The same identifier can be added through AddChildIdentifier and through AddOneInstanceIdentifier |
f39406a9eda4
ExtendedFind in SQLite continued (6 tests still failing)
Alain Mazy <am@orthanc.team>
parents:
5749
diff
changeset
|
164 identifiers_.insert(identifier); |
5671
b4c97c51f9db
added FindResponse::Resource::ChildrenInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
165 } |
b4c97c51f9db
added FindResponse::Resource::ChildrenInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
166 |
b4c97c51f9db
added FindResponse::Resource::ChildrenInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
167 |
5672
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
168 void FindResponse::ChildrenInformation::AddMetadataValue(MetadataType metadata, |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
169 const std::string& value) |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
170 { |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
171 MetadataValues::iterator found = metadataValues_.find(metadata); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
172 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
173 if (found == metadataValues_.end()) |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
174 { |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
175 std::set<std::string> s; |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
176 s.insert(value); |
5749 | 177 metadataValues_[metadata] = new std::set<std::string>(s); |
5672
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
178 } |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
179 else |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
180 { |
5673 | 181 assert(found->second != NULL); |
182 found->second->insert(value); | |
5672
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
183 } |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
184 } |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
185 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
186 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
187 void FindResponse::ChildrenInformation::GetMetadataValues(std::set<std::string>& values, |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
188 MetadataType metadata) const |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
189 { |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
190 MetadataValues::const_iterator found = metadataValues_.find(metadata); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
191 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
192 if (found == metadataValues_.end()) |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
193 { |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
194 values.clear(); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
195 } |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
196 else |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
197 { |
5673 | 198 assert(found->second != NULL); |
199 values = *found->second; | |
5672
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
200 } |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
201 } |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
202 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
203 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
204 void FindResponse::ChildrenInformation::AddMainDicomTagValue(const DicomTag& tag, |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
205 const std::string& value) |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
206 { |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
207 MainDicomTagValues::iterator found = mainDicomTagValues_.find(tag); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
208 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
209 if (found == mainDicomTagValues_.end()) |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
210 { |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
211 std::set<std::string> s; |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
212 s.insert(value); |
5749 | 213 mainDicomTagValues_[tag] = new std::set<std::string>(s); |
5672
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
214 } |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
215 else |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
216 { |
5673 | 217 assert(found->second != NULL); |
218 found->second->insert(value); | |
5672
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
219 } |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
220 } |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
221 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
222 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
223 void FindResponse::ChildrenInformation::GetMainDicomTagValues(std::set<std::string>& values, |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
224 const DicomTag& tag) const |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
225 { |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
226 MainDicomTagValues::const_iterator found = mainDicomTagValues_.find(tag); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
227 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
228 if (found == mainDicomTagValues_.end()) |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
229 { |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
230 values.clear(); |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
231 } |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
232 else |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
233 { |
5673 | 234 assert(found->second != NULL); |
235 values = *found->second; | |
5672
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
236 } |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
237 } |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
238 |
e300f22a46f0
implemented computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5671
diff
changeset
|
239 |
5671
b4c97c51f9db
added FindResponse::Resource::ChildrenInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
240 FindResponse::ChildrenInformation& FindResponse::Resource::GetChildrenInformation(ResourceType level) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
241 { |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
242 switch (level) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
243 { |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
244 case ResourceType_Study: |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
245 if (level_ == ResourceType_Patient) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
246 { |
5671
b4c97c51f9db
added FindResponse::Resource::ChildrenInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
247 return childrenStudiesInformation_; |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
248 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
249 else |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
250 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
251 throw OrthancException(ErrorCode_ParameterOutOfRange); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
252 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
253 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
254 case ResourceType_Series: |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
255 if (level_ == ResourceType_Patient || |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
256 level_ == ResourceType_Study) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
257 { |
5671
b4c97c51f9db
added FindResponse::Resource::ChildrenInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
258 return childrenSeriesInformation_; |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
259 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
260 else |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
261 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
262 throw OrthancException(ErrorCode_ParameterOutOfRange); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
263 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
264 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
265 case ResourceType_Instance: |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
266 if (level_ == ResourceType_Patient || |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
267 level_ == ResourceType_Study || |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
268 level_ == ResourceType_Series) |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
269 { |
5671
b4c97c51f9db
added FindResponse::Resource::ChildrenInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5667
diff
changeset
|
270 return childrenInstancesInformation_; |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
271 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
272 else |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
273 { |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
274 throw OrthancException(ErrorCode_ParameterOutOfRange); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
275 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
276 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
277 default: |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
278 throw OrthancException(ErrorCode_ParameterOutOfRange); |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
279 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
280 } |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
281 |
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
282 |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
283 FindResponse::MainDicomTagsAtLevel& FindResponse::Resource::GetMainDicomTagsAtLevel(ResourceType level) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
284 { |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
285 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
|
286 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
287 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
|
288 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
289 |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
290 switch (level) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
291 { |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
292 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
|
293 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
|
294 |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
295 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
|
296 return mainDicomTagsStudy_; |
5586
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 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
|
299 return mainDicomTagsSeries_; |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
300 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
301 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
|
302 return mainDicomTagsInstance_; |
5586
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 default: |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
305 throw OrthancException(ErrorCode_ParameterOutOfRange); |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
306 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
307 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
308 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
309 |
5690
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
310 void FindResponse::Resource::GetAllMainDicomTags(DicomMap& target) const |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
311 { |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
312 switch (level_) |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
313 { |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
314 // Don't reorder or add "break" below |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
315 case ResourceType_Instance: |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
316 mainDicomTagsInstance_.Export(target); |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
317 |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
318 case ResourceType_Series: |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
319 mainDicomTagsSeries_.Export(target); |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
320 |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
321 case ResourceType_Study: |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
322 mainDicomTagsStudy_.Export(target); |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
323 |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
324 case ResourceType_Patient: |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
325 mainDicomTagsPatient_.Export(target); |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
326 break; |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
327 |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
328 default: |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
329 throw OrthancException(ErrorCode_ParameterOutOfRange); |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
330 } |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
331 } |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
332 |
708952bd869c
integration tests are passing with ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5676
diff
changeset
|
333 |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
334 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
|
335 MetadataType metadata, |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
336 const std::string& value) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
337 { |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
338 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
|
339 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
340 if (m.find(metadata) != m.end()) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
341 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
342 throw OrthancException(ErrorCode_BadSequenceOfCalls); // Metadata already present |
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 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
345 { |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
346 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
|
347 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
348 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
349 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
350 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
351 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
|
352 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
353 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
|
354 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
355 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
|
356 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
357 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
358 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
|
359 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
360 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
|
361 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
|
362 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
363 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
|
364 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
|
365 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
366 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
|
367 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
|
368 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
369 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
|
370 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
|
371 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
372 default: |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
373 throw OrthancException(ErrorCode_ParameterOutOfRange); |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
374 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
375 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
376 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
377 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
378 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
|
379 ResourceType level, |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
380 MetadataType metadata) const |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
381 { |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
382 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
|
383 |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
384 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
|
385 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
386 if (found == m.end()) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
387 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
388 return false; |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
389 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
390 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
391 { |
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
|
392 value = found->second; |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
393 return true; |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
394 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
395 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
396 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
397 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
398 void FindResponse::Resource::SetParentIdentifier(const std::string& id) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
399 { |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
400 if (level_ == ResourceType_Patient) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
401 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
402 throw OrthancException(ErrorCode_BadParameterType); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
403 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
404 else if (HasParentIdentifier()) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
405 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
406 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
407 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
408 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
409 { |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
410 parentIdentifier_.reset(new std::string(id)); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
411 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
412 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
413 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
414 |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
415 const std::string& FindResponse::Resource::GetParentIdentifier() const |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
416 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
417 if (level_ == ResourceType_Patient) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
418 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
419 throw OrthancException(ErrorCode_BadParameterType); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
420 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
421 else if (HasParentIdentifier()) |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
422 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
423 return *parentIdentifier_; |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
424 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
425 else |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
426 { |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
427 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
428 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
429 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
430 |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
431 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
432 bool FindResponse::Resource::HasParentIdentifier() const |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
433 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
434 if (level_ == ResourceType_Patient) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
435 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
436 throw OrthancException(ErrorCode_BadParameterType); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
437 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
438 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
439 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
440 return parentIdentifier_.get() != NULL; |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
441 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
442 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
443 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
444 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
445 void FindResponse::Resource::AddLabel(const std::string& label) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
446 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
447 if (labels_.find(label) == labels_.end()) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
448 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
449 labels_.insert(label); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
450 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
451 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
452 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
453 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
454 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
455 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
456 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
457 |
5852
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
458 void FindResponse::Resource::AddAttachment(const FileInfo& attachment, |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
459 int64_t revision) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
460 { |
5852
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
461 if (attachments_.find(attachment.GetContentType()) == attachments_.end() && |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
462 revisions_.find(attachment.GetContentType()) == revisions_.end()) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
463 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
464 attachments_[attachment.GetContentType()] = attachment; |
5852
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
465 revisions_[attachment.GetContentType()] = revision; |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
466 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
467 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
468 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
469 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
470 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
471 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
472 |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
473 |
5852
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
474 bool FindResponse::Resource::LookupAttachment(FileInfo& target, |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
475 int64_t& revision, |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
476 FileContentType type) const |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
477 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
478 std::map<FileContentType, FileInfo>::const_iterator it = attachments_.find(type); |
5852
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
479 std::map<FileContentType, int64_t>::const_iterator it2 = revisions_.find(type); |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
480 |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
481 if (it != attachments_.end()) |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
482 { |
5852
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
483 if (it2 != revisions_.end()) |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
484 { |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
485 target = it->second; |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
486 revision = it2->second; |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
487 return true; |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
488 } |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
489 else |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
490 { |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
491 throw OrthancException(ErrorCode_InternalError); |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
492 } |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
493 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
494 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
495 { |
5852
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
496 if (it2 == revisions_.end()) |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
497 { |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
498 return false; |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
499 } |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
500 else |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
501 { |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
502 throw OrthancException(ErrorCode_InternalError); |
ea547160f27e
StatelessDatabaseOperations: reimplementing LookupAttachment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5833
diff
changeset
|
503 } |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
504 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
505 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
506 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
507 |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
508 void FindResponse::Resource::SetOneInstanceMetadataAndAttachments(const std::string& instancePublicId, |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
509 const std::map<MetadataType, std::string>& metadata, |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
510 const std::map<FileContentType, FileInfo>& attachments) |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
511 { |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
512 if (hasOneInstanceMetadataAndAttachments_) |
5610
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
513 { |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
514 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
515 } |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
516 else if (instancePublicId.empty()) |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
517 { |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
518 throw OrthancException(ErrorCode_ParameterOutOfRange); |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
519 } |
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
520 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
|
521 { |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
522 hasOneInstanceMetadataAndAttachments_ = true; |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
523 oneInstancePublicId_ = instancePublicId; |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
524 oneInstanceMetadata_ = metadata; |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
525 oneInstanceAttachments_ = attachments; |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
526 } |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
527 } |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
528 |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
529 |
5774
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
530 void FindResponse::Resource::SetOneInstancePublicId(const std::string& instancePublicId) |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
531 { |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
532 SetOneInstanceMetadataAndAttachments(instancePublicId, std::map<MetadataType, std::string>(), |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
533 std::map<FileContentType, FileInfo>()); |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
534 } |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
535 |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
536 |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
537 void FindResponse::Resource::AddOneInstanceMetadata(MetadataType metadata, |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
538 const std::string& value) |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
539 { |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
540 if (hasOneInstanceMetadataAndAttachments_) |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
541 { |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
542 if (oneInstanceMetadata_.find(metadata) == oneInstanceMetadata_.end()) |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
543 { |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
544 oneInstanceMetadata_[metadata] = value; |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
545 } |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
546 else |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
547 { |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
548 throw OrthancException(ErrorCode_BadSequenceOfCalls, "Metadata already exists"); |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
549 } |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
550 } |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
551 else |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
552 { |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
553 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
554 } |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
555 } |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
556 |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
557 |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
558 void FindResponse::Resource::AddOneInstanceAttachment(const FileInfo& attachment) |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
559 { |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
560 if (hasOneInstanceMetadataAndAttachments_) |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
561 { |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
562 if (oneInstanceAttachments_.find(attachment.GetContentType()) == oneInstanceAttachments_.end()) |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
563 { |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
564 oneInstanceAttachments_[attachment.GetContentType()] = attachment; |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
565 } |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
566 else |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
567 { |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
568 throw OrthancException(ErrorCode_BadSequenceOfCalls, "Attachment already exists"); |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
569 } |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
570 } |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
571 else |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
572 { |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
573 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
574 } |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
575 } |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
576 |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
577 |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
578 const std::string& FindResponse::Resource::GetOneInstancePublicId() const |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
579 { |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
580 if (hasOneInstanceMetadataAndAttachments_) |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
581 { |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
582 return oneInstancePublicId_; |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
583 } |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
584 else |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
585 { |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
586 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
587 } |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
588 } |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
589 |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
590 |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
591 const std::map<MetadataType, std::string>& FindResponse::Resource::GetOneInstanceMetadata() const |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
592 { |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
593 if (hasOneInstanceMetadataAndAttachments_) |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
594 { |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
595 return oneInstanceMetadata_; |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
596 } |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
597 else |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
598 { |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
599 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
600 } |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
601 } |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
602 |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
603 |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
604 const std::map<FileContentType, FileInfo>& FindResponse::Resource::GetOneInstanceAttachments() const |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
605 { |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
606 if (hasOneInstanceMetadataAndAttachments_) |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
607 { |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
608 return oneInstanceAttachments_; |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
609 } |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
610 else |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
611 { |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
612 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
5610
d4b570834d3a
adding safeguards around FindRequest::SetRetrieveOneInstanceIdentifier()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5609
diff
changeset
|
613 } |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
614 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
615 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
616 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
617 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
|
618 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
|
619 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
620 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
|
621 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
|
622 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
623 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
|
624 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
625 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
|
626 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
627 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
|
628 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
629 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
|
630 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
631 else |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
632 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
633 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
|
634 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
635 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
636 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
637 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
638 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
639 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
|
640 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
|
641 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
642 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
|
643 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
644 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
|
645 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
646 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
|
647 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
648 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
649 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
650 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
651 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
|
652 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
|
653 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
654 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
|
655 u.append(info.GetUuid()); |
5602 | 656 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
|
657 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
|
658 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
659 |
5675 | 660 |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
661 static void DebugAttachments(Json::Value& target, |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
662 const std::map<FileContentType, FileInfo>& attachments) |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
663 { |
5774
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
664 target = Json::objectValue; |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
665 for (std::map<FileContentType, FileInfo>::const_iterator it = attachments.begin(); |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
666 it != attachments.end(); ++it) |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
667 { |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
668 if (it->first != it->second.GetContentType()) |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
669 { |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
670 throw OrthancException(ErrorCode_DatabasePlugin); |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
671 } |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
672 else |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
673 { |
5774
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
674 DebugAddAttachment(target, it->second); |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
675 } |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
676 } |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
677 } |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
678 |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
679 |
5675 | 680 static void DebugSetOfStrings(Json::Value& target, |
681 const std::set<std::string>& values) | |
682 { | |
683 target = Json::arrayValue; | |
684 for (std::set<std::string>::const_iterator it = values.begin(); it != values.end(); ++it) | |
685 { | |
686 target.append(*it); | |
687 } | |
688 } | |
689 | |
690 | |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
691 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
|
692 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
|
693 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
694 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
|
695 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
696 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
|
697 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
|
698 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
699 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
|
700 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
701 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
|
702 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
703 |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
704 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
|
705 { |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
706 DicomMap m; |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
707 GetMainDicomTags(m, request.GetLevel()); |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
708 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
|
709 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
710 |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
711 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
|
712 { |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
713 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
|
714 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
715 |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
716 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
|
717 |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
718 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
|
719 { |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
720 const char* level = EnumerationToString(levels[i]); |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
721 |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
722 if (levels[i] != request.GetLevel() && |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
723 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
|
724 { |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5675
diff
changeset
|
725 if (request.GetParentSpecification(levels[i]).IsRetrieveMainDicomTags()) |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
726 { |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
727 DicomMap m; |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
728 GetMainDicomTags(m, levels[i]); |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
729 DebugDicomMap(target[level]["MainDicomTags"], m); |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
730 } |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
731 |
5702 | 732 if (request.GetParentSpecification(levels[i]).IsRetrieveMetadata()) |
5619
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
733 { |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
734 DebugMetadata(target[level]["Metadata"], GetMetadata(levels[i])); |
1864b16bc7b1
added FindRequest::ParentRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5610
diff
changeset
|
735 } |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
736 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
737 |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
738 if (levels[i] != request.GetLevel() && |
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
739 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
|
740 { |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5675
diff
changeset
|
741 if (request.GetChildrenSpecification(levels[i]).IsRetrieveIdentifiers()) |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
742 { |
5675 | 743 DebugSetOfStrings(target[level]["Identifiers"], GetChildrenInformation(levels[i]).GetIdentifiers()); |
744 } | |
5666
aa231c18b9d2
adding computed tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5641
diff
changeset
|
745 |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5675
diff
changeset
|
746 const std::set<MetadataType>& metadata = request.GetChildrenSpecification(levels[i]).GetMetadata(); |
5675 | 747 for (std::set<MetadataType>::const_iterator it = metadata.begin(); it != metadata.end(); ++it) |
748 { | |
749 std::set<std::string> values; | |
750 GetChildrenInformation(levels[i]).GetMetadataValues(values, *it); | |
751 DebugSetOfStrings(target[level]["Metadata"][EnumerationToString(*it)], values); | |
752 } | |
753 | |
5676
b744a2cf408a
shorten ParentRetrieveSpecification/ChildrenRetrieveSpecification as ParentSpecification/ChildrenSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5675
diff
changeset
|
754 const std::set<DicomTag>& tags = request.GetChildrenSpecification(levels[i]).GetMainDicomTags(); |
5675 | 755 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it) |
756 { | |
757 std::set<std::string> values; | |
758 GetChildrenInformation(levels[i]).GetMainDicomTagValues(values, *it); | |
759 DebugSetOfStrings(target[level]["MainDicomTags"][it->Format()], values); | |
5621
732ec9feeea8
introduction of FindRequest::ChildrenRetrieveSpecification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5619
diff
changeset
|
760 } |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
761 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
762 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
763 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
764 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
|
765 { |
5675 | 766 DebugSetOfStrings(target["Labels"], labels_); |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
767 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
768 |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
769 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
|
770 { |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
771 DebugAttachments(target["Attachments"], attachments_); |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
772 } |
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
773 |
5774
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
774 if (request.GetLevel() != ResourceType_Instance && |
f96abfe08946
implementation of specialized SQL commands in SQLiteDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5772
diff
changeset
|
775 request.IsRetrieveOneInstanceMetadataAndAttachments()) |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
776 { |
5772
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
777 DebugMetadata(target["OneInstance"]["Metadata"], GetOneInstanceMetadata()); |
093a8693ba16
replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5750
diff
changeset
|
778 DebugAttachments(target["OneInstance"]["Attachments"], GetOneInstanceAttachments()); |
5596
81a29ad7fb4b
added possibility to retrieve main DICOM tags and metadata at any level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5595
diff
changeset
|
779 } |
5594
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
780 } |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
781 |
a906dc19264c
created FindResponse::Resource::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5592
diff
changeset
|
782 |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
783 FindResponse::~FindResponse() |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
784 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
785 for (size_t i = 0; i < items_.size(); i++) |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
786 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
787 assert(items_[i] != NULL); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
788 delete items_[i]; |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
789 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
790 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
791 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
792 |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
793 void FindResponse::Add(Resource* item /* takes ownership */) |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
794 { |
5589
b51ee994cd6f
renamed FindResponse::Item as FindResponse::Resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5588
diff
changeset
|
795 std::unique_ptr<Resource> protection(item); |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
796 |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
797 if (item == NULL) |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
798 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
799 throw OrthancException(ErrorCode_NullPointer); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
800 } |
5588
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
801 else if (!items_.empty() && |
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
802 items_[0]->GetLevel() != item->GetLevel()) |
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
803 { |
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
804 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
|
805 } |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
806 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
807 { |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
808 const std::string& id = item->GetIdentifier(); |
5748
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
809 int64_t internalId = item->GetInternalId(); |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
810 |
5748
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
811 if (identifierIndex_.find(id) == identifierIndex_.end() && internalIdIndex_.find(internalId) == internalIdIndex_.end()) |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
812 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
813 items_.push_back(protection.release()); |
5748
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
814 identifierIndex_[id] = item; |
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
815 internalIdIndex_[internalId] = item; |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
816 } |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
817 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
818 { |
5748
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
819 throw OrthancException(ErrorCode_BadSequenceOfCalls, "This resource has already been added: " + id + "/" + boost::lexical_cast<std::string>(internalId)); |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
820 } |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
821 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
822 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
823 |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
824 |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
825 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
|
826 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
827 if (index >= items_.size()) |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
828 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
829 throw OrthancException(ErrorCode_ParameterOutOfRange); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
830 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
831 else |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
832 { |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
833 assert(items_[index] != NULL); |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
834 return *items_[index]; |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
835 } |
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
836 } |
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
|
837 |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
838 |
5609
4690a0d2b01e
preliminary support of requestedTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5602
diff
changeset
|
839 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
|
840 { |
5748
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
841 IdentifierIndex::const_iterator found = identifierIndex_.find(id); |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
842 |
5748
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
843 if (found == identifierIndex_.end()) |
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
844 { |
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
845 throw OrthancException(ErrorCode_InexistentItem); |
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
846 } |
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
847 else |
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
848 { |
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
849 assert(found->second != NULL); |
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
850 return *found->second; |
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
851 } |
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
852 } |
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
853 |
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
854 |
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
855 FindResponse::Resource& FindResponse::GetResourceByInternalId(int64_t internalId) |
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
856 { |
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
857 InternalIdIndex::const_iterator found = internalIdIndex_.find(internalId); |
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
858 |
4bc650d88463
WIP: started to implement IntegratedFind in SQLite
Alain Mazy <am@orthanc.team>
parents:
5702
diff
changeset
|
859 if (found == internalIdIndex_.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
|
860 { |
5588
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
861 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
|
862 } |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
863 else |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
864 { |
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
865 assert(found->second != NULL); |
5588
1b0fc6685f57
add index of resources into FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5586
diff
changeset
|
866 return *found->second; |
5586
fc3914c07dd3
refactoring FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5583
diff
changeset
|
867 } |
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
|
868 } |
5554
12d8a1a266e9
introduction of FindRequest and FindResponse
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
869 } |