Mercurial > hg > orthanc
comparison OrthancServer/OrthancFindRequestHandler.cpp @ 1859:4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 02 Dec 2015 11:22:05 +0100 |
parents | 36ab170733d6 |
children | 512b6e76f531 |
comparison
equal
deleted
inserted
replaced
1856:36ab170733d6 | 1859:4e7c318a3f69 |
---|---|
45 | 45 |
46 namespace Orthanc | 46 namespace Orthanc |
47 { | 47 { |
48 static void AddAnswer(DicomFindAnswers& answers, | 48 static void AddAnswer(DicomFindAnswers& answers, |
49 const Json::Value& resource, | 49 const Json::Value& resource, |
50 const DicomArray& query) | 50 const DicomArray& query, |
51 const std::list<DicomTag>& sequencesToReturn) | |
51 { | 52 { |
52 DicomMap result; | 53 DicomMap result; |
53 | 54 |
54 for (size_t i = 0; i < query.GetSize(); i++) | 55 for (size_t i = 0; i < query.GetSize(); i++) |
55 { | 56 { |
56 // Fix issue 30 (QR response missing "Query/Retrieve Level" (008,0052)) | |
57 if (query.GetElement(i).GetTag() == DICOM_TAG_QUERY_RETRIEVE_LEVEL) | 57 if (query.GetElement(i).GetTag() == DICOM_TAG_QUERY_RETRIEVE_LEVEL) |
58 { | 58 { |
59 // Fix issue 30 on Google Code (QR response missing "Query/Retrieve Level" (008,0052)) | |
59 result.SetValue(query.GetElement(i).GetTag(), query.GetElement(i).GetValue()); | 60 result.SetValue(query.GetElement(i).GetTag(), query.GetElement(i).GetValue()); |
60 } | 61 } |
61 else if (query.GetElement(i).GetTag() == DICOM_TAG_SPECIFIC_CHARACTER_SET) | 62 else if (query.GetElement(i).GetTag() == DICOM_TAG_SPECIFIC_CHARACTER_SET) |
62 { | 63 { |
64 // Do not include the encoding, this is handled by class ParsedDicomFile | |
63 } | 65 } |
64 else | 66 else |
65 { | 67 { |
66 std::string tag = query.GetElement(i).GetTag().Format(); | 68 std::string tag = query.GetElement(i).GetTag().Format(); |
67 std::string value; | 69 std::string value; |
75 result.SetValue(query.GetElement(i).GetTag(), ""); | 77 result.SetValue(query.GetElement(i).GetTag(), ""); |
76 } | 78 } |
77 } | 79 } |
78 } | 80 } |
79 | 81 |
80 if (result.GetSize() == 0) | 82 if (result.GetSize() == 0 && |
83 sequencesToReturn.empty()) | |
81 { | 84 { |
82 LOG(WARNING) << "The C-FIND request does not return any DICOM tag"; | 85 LOG(WARNING) << "The C-FIND request does not return any DICOM tag"; |
83 } | 86 } |
87 else if (sequencesToReturn.empty()) | |
88 { | |
89 answers.Add(result); | |
90 } | |
84 else | 91 else |
85 { | 92 { |
86 answers.Add(result); | 93 ParsedDicomFile dicom(result); |
94 | |
95 for (std::list<DicomTag>::const_iterator tag = sequencesToReturn.begin(); | |
96 tag != sequencesToReturn.end(); ++tag) | |
97 { | |
98 std::cout << tag->Format(); | |
99 | |
100 const Json::Value& source = resource[tag->Format()]; | |
101 | |
102 if (source.type() == Json::objectValue && | |
103 source.isMember("Type") && | |
104 source.isMember("Value") && | |
105 source["Type"].asString() == "Sequence" && | |
106 source["Value"].type() == Json::arrayValue) | |
107 { | |
108 Json::Value content = Json::arrayValue; | |
109 | |
110 for (Json::Value::ArrayIndex i = 0; i < source["Value"].size(); i++) | |
111 { | |
112 Json::Value item; | |
113 Toolbox::SimplifyTags(item, source["Value"][i], DicomToJsonFormat_Short); | |
114 content.append(item); | |
115 } | |
116 | |
117 dicom.Replace(*tag, content, false); | |
118 } | |
119 } | |
120 | |
121 answers.Add(dicom); | |
87 } | 122 } |
88 } | 123 } |
89 | 124 |
90 | 125 |
91 | 126 |
124 } | 159 } |
125 | 160 |
126 | 161 |
127 void OrthancFindRequestHandler::Handle(DicomFindAnswers& answers, | 162 void OrthancFindRequestHandler::Handle(DicomFindAnswers& answers, |
128 const DicomMap& input, | 163 const DicomMap& input, |
164 const std::list<DicomTag>& sequencesToReturn, | |
129 const std::string& remoteIp, | 165 const std::string& remoteIp, |
130 const std::string& remoteAet, | 166 const std::string& remoteAet, |
131 const std::string& calledAet) | 167 const std::string& calledAet) |
132 { | 168 { |
133 /** | 169 /** |
179 << " " << FromDcmtkBridge::GetName(query.GetElement(i).GetTag()) | 215 << " " << FromDcmtkBridge::GetName(query.GetElement(i).GetTag()) |
180 << " = " << query.GetElement(i).GetValue().GetContent(); | 216 << " = " << query.GetElement(i).GetValue().GetContent(); |
181 } | 217 } |
182 } | 218 } |
183 | 219 |
220 for (std::list<DicomTag>::const_iterator it = sequencesToReturn.begin(); | |
221 it != sequencesToReturn.end(); ++it) | |
222 { | |
223 LOG(INFO) << " (" << it->Format() | |
224 << ") " << FromDcmtkBridge::GetName(*it) | |
225 << " : sequence tag whose content will be copied"; | |
226 } | |
227 | |
184 | 228 |
185 /** | 229 /** |
186 * Build up the query object. | 230 * Build up the query object. |
187 **/ | 231 **/ |
188 | 232 |
253 complete = false; | 297 complete = false; |
254 break; | 298 break; |
255 } | 299 } |
256 else | 300 else |
257 { | 301 { |
258 AddAnswer(answers, dicom, query); | 302 AddAnswer(answers, dicom, query, sequencesToReturn); |
259 } | 303 } |
260 } | 304 } |
261 } | 305 } |
262 | 306 |
263 LOG(INFO) << "Number of matching resources: " << answers.GetSize(); | 307 LOG(INFO) << "Number of matching resources: " << answers.GetSize(); |