Mercurial > hg > orthanc
comparison OrthancServer/OrthancFindRequestHandler.cpp @ 565:c931ac02db82 find-move-scp
refactoring of find class
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 18 Sep 2013 16:58:27 +0200 |
parents | |
children | 0bedf8ff9288 |
comparison
equal
deleted
inserted
replaced
562:f64e3838d6e1 | 565:c931ac02db82 |
---|---|
1 /** | |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, | |
4 * Belgium | |
5 * | |
6 * This program is free software: you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License, or (at your option) any later version. | |
10 * | |
11 * In addition, as a special exception, the copyright holders of this | |
12 * program give permission to link the code of its release with the | |
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
14 * that use the same license as the "OpenSSL" library), and distribute | |
15 * the linked executables. You must obey the GNU General Public License | |
16 * in all respects for all of the code used other than "OpenSSL". If you | |
17 * modify file(s) with this exception, you may extend this exception to | |
18 * your version of the file(s), but you are not obligated to do so. If | |
19 * you do not wish to do so, delete this exception statement from your | |
20 * version. If you delete this exception statement from all source files | |
21 * in the program, then also delete it here. | |
22 * | |
23 * This program is distributed in the hope that it will be useful, but | |
24 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
26 * General Public License for more details. | |
27 * | |
28 * You should have received a copy of the GNU General Public License | |
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
30 **/ | |
31 | |
32 #include "OrthancFindRequestHandler.h" | |
33 | |
34 #include <glog/logging.h> | |
35 | |
36 #include "../Core/DicomFormat/DicomArray.h" | |
37 | |
38 namespace Orthanc | |
39 { | |
40 void OrthancFindRequestHandler::Handle(const DicomMap& input, | |
41 DicomFindAnswers& answers) | |
42 { | |
43 LOG(WARNING) << "Find-SCU request received"; | |
44 | |
45 /** | |
46 * Retrieve the query level. | |
47 **/ | |
48 | |
49 const DicomValue* levelTmp = input.TestAndGetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL); | |
50 if (levelTmp == NULL) | |
51 { | |
52 throw OrthancException(ErrorCode_BadRequest); | |
53 } | |
54 | |
55 ResourceType level = StringToResourceType(levelTmp->AsString().c_str()); | |
56 | |
57 if (level != ResourceType_Patient && | |
58 level != ResourceType_Study && | |
59 level != ResourceType_Series) | |
60 { | |
61 throw OrthancException(ErrorCode_NotImplemented); | |
62 } | |
63 | |
64 | |
65 /** | |
66 * Retrieve the constraints of the query. | |
67 **/ | |
68 | |
69 DicomArray query(input); | |
70 | |
71 DicomMap constraintsTmp; | |
72 DicomMap wildcardConstraintsTmp; | |
73 | |
74 for (size_t i = 0; i < query.GetSize(); i++) | |
75 { | |
76 if (!query.GetElement(i).GetValue().IsNull() && | |
77 query.GetElement(i).GetTag() != DICOM_TAG_QUERY_RETRIEVE_LEVEL && | |
78 query.GetElement(i).GetTag() != DICOM_TAG_SPECIFIC_CHARACTER_SET) | |
79 { | |
80 DicomTag tag = query.GetElement(i).GetTag(); | |
81 std::string value = query.GetElement(i).GetValue().AsString(); | |
82 | |
83 if (value.find('*') != std::string::npos || | |
84 value.find('?') != std::string::npos || | |
85 value.find('\\') != std::string::npos || | |
86 value.find('-') != std::string::npos) | |
87 { | |
88 wildcardConstraintsTmp.SetValue(tag, value); | |
89 } | |
90 else | |
91 { | |
92 constraintsTmp.SetValue(tag, value); | |
93 } | |
94 } | |
95 } | |
96 | |
97 DicomArray constraints(constraintsTmp); | |
98 DicomArray wildcardConstraints(wildcardConstraintsTmp); | |
99 | |
100 // http://www.itk.org/Wiki/DICOM_QueryRetrieve_Explained | |
101 // http://dicomiseasy.blogspot.be/2012/01/dicom-queryretrieve-part-i.html | |
102 | |
103 constraints.Print(stdout); | |
104 printf("\n"); fflush(stdout); | |
105 wildcardConstraints.Print(stdout); | |
106 printf("\n"); fflush(stdout); | |
107 } | |
108 } |