Mercurial > hg > orthanc
annotate OrthancServer/Plugins/Samples/MultitenantDicom/PluginToolbox.cpp @ 5487:33f8e180edcf
upgraded static build to dcmtk 3.6.8
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 09 Jan 2024 17:34:33 +0100 |
parents | 48b8dae6dc77 |
children | f7adfb22e20e |
rev | line source |
---|---|
5273
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5371
diff
changeset
|
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium |
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5371
diff
changeset
|
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
5273
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
5371
a8385880902f
fix incorrect license for MultitenantDicom plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5273
diff
changeset
|
9 * modify it under the terms of the GNU General Public License as |
a8385880902f
fix incorrect license for MultitenantDicom plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5273
diff
changeset
|
10 * published by the Free Software Foundation, either version 3 of the |
a8385880902f
fix incorrect license for MultitenantDicom plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5273
diff
changeset
|
11 * License, or (at your option) any later version. |
5273
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, but |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
5371
a8385880902f
fix incorrect license for MultitenantDicom plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5273
diff
changeset
|
16 * General Public License for more details. |
5273
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * |
5371
a8385880902f
fix incorrect license for MultitenantDicom plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5273
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
a8385880902f
fix incorrect license for MultitenantDicom plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5273
diff
changeset
|
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
5273
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 **/ |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 #include "PluginToolbox.h" |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #include "../../../../OrthancFramework/Sources/OrthancException.h" |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 #include "../../../../OrthancFramework/Sources/SerializationToolbox.h" |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 #include "../../../../OrthancFramework/Sources/Toolbox.h" |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 #include "../Common/OrthancPluginCppWrapper.h" |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 namespace PluginToolbox |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 bool IsValidLabel(const std::string& label) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 if (label.empty()) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 return false; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 if (label.size() > 64) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 // This limitation is for MySQL, which cannot use a TEXT |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 // column of undefined length as a primary key |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 return false; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 for (size_t i = 0; i < label.size(); i++) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 if (!(label[i] == '_' || |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 label[i] == '-' || |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 (label[i] >= 'a' && label[i] <= 'z') || |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 (label[i] >= 'A' && label[i] <= 'Z') || |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 (label[i] >= '0' && label[i] <= '9'))) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 return false; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 return true; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 Orthanc::ResourceType ParseQueryRetrieveLevel(const std::string& level) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 if (level == "PATIENT") |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 return Orthanc::ResourceType_Patient; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 else if (level == "STUDY") |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 return Orthanc::ResourceType_Study; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 else if (level == "SERIES") |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 return Orthanc::ResourceType_Series; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 else if (level == "INSTANCE") |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 return Orthanc::ResourceType_Instance; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 else |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol, "Bad value for QueryRetrieveLevel in DICOM C-FIND: " + level); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 bool IsSameAETitle(bool isStrict, |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 const std::string& aet1, |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 const std::string& aet2) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 if (isStrict) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 // Case-sensitive matching |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 return aet1 == aet2; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 else |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 // Case-insensitive matching (default) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 std::string tmp1, tmp2; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 Orthanc::Toolbox::ToLowerCase(tmp1, aet1); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 Orthanc::Toolbox::ToLowerCase(tmp2, aet2); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 return tmp1 == tmp2; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 bool LookupAETitle(std::string& name, |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 Orthanc::RemoteModalityParameters& parameters, |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 bool isStrict, |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 const std::string& aet) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 Json::Value modalities; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 if (!OrthancPlugins::RestApiGet(modalities, "/modalities?expand", false)) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Unable to obtain the list of the remote modalities"); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 std::vector<std::string> names = modalities.getMemberNames(); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 for (size_t i = 0; i < names.size(); i++) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 parameters = Orthanc::RemoteModalityParameters(modalities[names[i]]); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 if (IsSameAETitle(isStrict, parameters.GetApplicationEntityTitle(), aet)) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 name = names[i]; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 return true; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 return false; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 void ParseLabels(std::set<std::string>& targetLabels, |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 LabelsConstraint& targetConstraint, |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 const Json::Value& serverConfig) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 Orthanc::SerializationToolbox::ReadSetOfStrings(targetLabels, serverConfig, KEY_LABELS); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 for (std::set<std::string>::const_iterator it = targetLabels.begin(); it != targetLabels.end(); ++it) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 if (!PluginToolbox::IsValidLabel(*it)) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, "Invalid label: " + *it); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 std::string s = Orthanc::SerializationToolbox::ReadString(serverConfig, KEY_LABELS_CONSTRAINT, KEY_ALL); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 targetConstraint = PluginToolbox::StringToLabelsConstraint(s); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 void AddLabelsToFindRequest(Json::Value& request, |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 const std::set<std::string>& labels, |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 LabelsConstraint constraint) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 Json::Value items = Json::arrayValue; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 for (std::set<std::string>::const_iterator it = labels.begin(); it != labels.end(); ++it) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 items.append(*it); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 request[KEY_LABELS] = items; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 switch (constraint) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 case LabelsConstraint_All: |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 request[KEY_LABELS_CONSTRAINT] = KEY_ALL; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 break; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 case LabelsConstraint_Any: |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 request[KEY_LABELS_CONSTRAINT] = KEY_ANY; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 break; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 case LabelsConstraint_None: |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 request[KEY_LABELS_CONSTRAINT] = KEY_NONE; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 break; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 default: |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 LabelsConstraint StringToLabelsConstraint(const std::string& s) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 if (s == KEY_ALL) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 return LabelsConstraint_All; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 else if (s == KEY_ANY) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 return LabelsConstraint_Any; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 else if (s == KEY_NONE) |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 return LabelsConstraint_None; |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 else |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 { |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, "Bad value for constraint of labels: " + s); |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 } |
7cb1b851f5c8
Added a sample plugin bringing multitenant DICOM support through labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 } |