Mercurial > hg > orthanc
annotate OrthancServer/ServerToolbox.cpp @ 1669:a412ad57f0f9 db-changes
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 01 Oct 2015 11:55:25 +0200 |
parents | de1413733c97 |
children | 0bbcfd9695e5 |
rev | line source |
---|---|
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics |
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * This program is free software: you can redistribute it and/or |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * modify it under the terms of the GNU General Public License as |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * published by the Free Software Foundation, either version 3 of the |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * License, or (at your option) any later version. |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * In addition, as a special exception, the copyright holders of this |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * program give permission to link the code of its release with the |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * that use the same license as the "OpenSSL" library), and distribute |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * the linked executables. You must obey the GNU General Public License |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * in all respects for all of the code used other than "OpenSSL". If you |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * modify file(s) with this exception, you may extend this exception to |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * your version of the file(s), but you are not obligated to do so. If |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * you do not wish to do so, delete this exception statement from your |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * version. If you delete this exception statement from all source files |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 * in the program, then also delete it here. |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 * |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 * This program is distributed in the hope that it will be useful, but |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 * WITHOUT ANY WARRANTY; without even the implied warranty of |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 * General Public License for more details. |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 * |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 * You should have received a copy of the GNU General Public License |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 **/ |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
33 #include "PrecompiledHeadersServer.h" |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 #include "ServerToolbox.h" |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 |
1486
f967bdf8534e
refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
36 #include "../Core/Logging.h" |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 #include "../Core/OrthancException.h" |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
38 #include "../Core/DicomFormat/DicomArray.h" |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
39 #include "ParsedDicomFile.h" |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 |
234 | 41 #include <cassert> |
42 | |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 namespace Orthanc |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 { |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
45 namespace Toolbox |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 { |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
47 void SimplifyTags(Json::Value& target, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
48 const Json::Value& source) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
49 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
50 assert(source.isObject()); |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
52 target = Json::objectValue; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
53 Json::Value::Members members = source.getMemberNames(); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
54 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
55 for (size_t i = 0; i < members.size(); i++) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
56 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
57 const Json::Value& v = source[members[i]]; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
58 const std::string& name = v["Name"].asString(); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
59 const std::string& type = v["Type"].asString(); |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
61 if (type == "String") |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
62 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
63 target[name] = v["Value"].asString(); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
64 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
65 else if (type == "TooLong" || |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
66 type == "Null") |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
67 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
68 target[name] = Json::nullValue; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
69 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
70 else if (type == "Sequence") |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
71 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
72 const Json::Value& array = v["Value"]; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
73 assert(array.isArray()); |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
75 Json::Value children = Json::arrayValue; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
76 for (Json::Value::ArrayIndex i = 0; i < array.size(); i++) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
77 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
78 Json::Value c; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
79 SimplifyTags(c, array[i]); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
80 children.append(c); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
81 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
82 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
83 target[name] = children; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
84 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
85 else |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
86 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
87 assert(0); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
88 } |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 } |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
90 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
91 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
92 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
93 void LogMissingRequiredTag(const DicomMap& summary) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
94 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
95 std::string s, t; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
96 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
97 if (summary.HasTag(DICOM_TAG_PATIENT_ID)) |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 { |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
99 if (t.size() > 0) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
100 t += ", "; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
101 t += "PatientID=" + summary.GetValue(DICOM_TAG_PATIENT_ID).AsString(); |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 } |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
103 else |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 { |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
105 if (s.size() > 0) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
106 s += ", "; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
107 s += "PatientID"; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
108 } |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
110 if (summary.HasTag(DICOM_TAG_STUDY_INSTANCE_UID)) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
111 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
112 if (t.size() > 0) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
113 t += ", "; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
114 t += "StudyInstanceUID=" + summary.GetValue(DICOM_TAG_STUDY_INSTANCE_UID).AsString(); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
115 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
116 else |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
117 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
118 if (s.size() > 0) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
119 s += ", "; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
120 s += "StudyInstanceUID"; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
121 } |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
123 if (summary.HasTag(DICOM_TAG_SERIES_INSTANCE_UID)) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
124 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
125 if (t.size() > 0) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
126 t += ", "; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
127 t += "SeriesInstanceUID=" + summary.GetValue(DICOM_TAG_SERIES_INSTANCE_UID).AsString(); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
128 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
129 else |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
130 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
131 if (s.size() > 0) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
132 s += ", "; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
133 s += "SeriesInstanceUID"; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
134 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
135 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
136 if (summary.HasTag(DICOM_TAG_SOP_INSTANCE_UID)) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
137 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
138 if (t.size() > 0) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
139 t += ", "; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
140 t += "SOPInstanceUID=" + summary.GetValue(DICOM_TAG_SOP_INSTANCE_UID).AsString(); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
141 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
142 else |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
143 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
144 if (s.size() > 0) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
145 s += ", "; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
146 s += "SOPInstanceUID"; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
147 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
148 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
149 if (t.size() == 0) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
150 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
151 LOG(ERROR) << "Store has failed because all the required tags (" << s << ") are missing (is it a DICOMDIR file?)"; |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 } |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 else |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 { |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
155 LOG(ERROR) << "Store has failed because required tags (" << s << ") are missing for the following instance: " << t; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
156 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
157 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
158 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
159 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
160 void SetMainDicomTags(IDatabaseWrapper& database, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
161 int64_t resource, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
162 ResourceType level, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
163 const DicomMap& dicomSummary, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
164 bool includeIdentifiers) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
165 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
166 // WARNING: The database should be locked with a transaction! |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
167 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
168 DicomMap tags; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
169 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
170 switch (level) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
171 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
172 case ResourceType_Patient: |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
173 dicomSummary.ExtractPatientInformation(tags); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
174 break; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
175 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
176 case ResourceType_Study: |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
177 dicomSummary.ExtractStudyInformation(tags); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
178 break; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
179 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
180 case ResourceType_Series: |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
181 dicomSummary.ExtractSeriesInformation(tags); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
182 break; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
183 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
184 case ResourceType_Instance: |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
185 dicomSummary.ExtractInstanceInformation(tags); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
186 break; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
187 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
188 default: |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
189 throw OrthancException(ErrorCode_InternalError); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
190 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
191 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
192 DicomArray flattened(tags); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
193 for (size_t i = 0; i < flattened.GetSize(); i++) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
194 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
195 const DicomElement& element = flattened.GetElement(i); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
196 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
197 if (includeIdentifiers || |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
198 !element.GetTag().IsIdentifier()) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
199 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
200 database.SetMainDicomTag(resource, element.GetTag(), element.GetValue().AsString()); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
201 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
202 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
203 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
204 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
205 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
206 bool FindOneChildInstance(int64_t& result, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
207 IDatabaseWrapper& database, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
208 int64_t resource, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
209 ResourceType type) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
210 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
211 for (;;) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
212 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
213 if (type == ResourceType_Instance) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
214 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
215 result = resource; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
216 return true; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
217 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
218 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
219 std::list<int64_t> children; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
220 database.GetChildrenInternalId(children, resource); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
221 if (children.empty()) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
222 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
223 return false; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
224 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
225 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
226 resource = children.front(); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
227 type = GetChildResourceType(type); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
228 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
229 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
230 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
231 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
232 void ReconstructMainDicomTags(IDatabaseWrapper& database, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
233 IStorageArea& storageArea, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
234 ResourceType level) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
235 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
236 // WARNING: The database should be locked with a transaction! |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
237 |
1669
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
238 const char* plural = NULL; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
239 |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
240 switch (level) |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
241 { |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
242 case ResourceType_Patient: |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
243 plural = "patients"; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
244 break; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
245 |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
246 case ResourceType_Study: |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
247 plural = "studies"; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
248 break; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
249 |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
250 case ResourceType_Series: |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
251 plural = "series"; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
252 break; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
253 |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
254 case ResourceType_Instance: |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
255 plural = "instances"; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
256 break; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
257 |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
258 default: |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
259 throw OrthancException(ErrorCode_InternalError); |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
260 } |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
261 |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
262 LOG(WARNING) << "Upgrade: Reconstructing the main DICOM tags of all the " << plural << "..."; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
263 |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
264 std::list<std::string> resources; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
265 database.GetAllPublicIds(resources, level); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
266 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
267 for (std::list<std::string>::const_iterator |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
268 it = resources.begin(); it != resources.end(); it++) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
269 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
270 // Locate the resource and one of its child instances |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
271 int64_t resource, instance; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
272 ResourceType tmp; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
273 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
274 if (!database.LookupResource(resource, tmp, *it) || |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
275 tmp != level || |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
276 !FindOneChildInstance(instance, database, resource, level)) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
277 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
278 throw OrthancException(ErrorCode_InternalError); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
279 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
280 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
281 // Get the DICOM file attached to some instances in the resource |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
282 FileInfo attachment; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
283 if (!database.LookupAttachment(attachment, instance, FileContentType_Dicom)) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
284 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
285 throw OrthancException(ErrorCode_InternalError); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
286 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
287 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
288 // Read and parse the content of the DICOM file |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
289 std::string content; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
290 storageArea.Read(content, attachment.GetUuid(), FileContentType_Dicom); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
291 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
292 ParsedDicomFile dicom(content); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
293 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
294 // Update the tags of this resource |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
295 DicomMap dicomSummary; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
296 dicom.Convert(dicomSummary); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
297 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
298 database.ClearMainDicomTags(resource); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
299 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
300 switch (level) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
301 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
302 case ResourceType_Patient: |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
303 Toolbox::SetMainDicomTags(database, resource, ResourceType_Patient, dicomSummary, true); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
304 break; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
305 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
306 case ResourceType_Study: |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
307 Toolbox::SetMainDicomTags(database, resource, ResourceType_Study, dicomSummary, true); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
308 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
309 // Duplicate the patient tags at the study level |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
310 Toolbox::SetMainDicomTags(database, resource, ResourceType_Patient, dicomSummary, false); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
311 break; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
312 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
313 case ResourceType_Series: |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
314 Toolbox::SetMainDicomTags(database, resource, ResourceType_Series, dicomSummary, true); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
315 break; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
316 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
317 case ResourceType_Instance: |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
318 Toolbox::SetMainDicomTags(database, resource, ResourceType_Instance, dicomSummary, true); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
319 break; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
320 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
321 default: |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
322 throw OrthancException(ErrorCode_InternalError); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
323 } |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
324 } |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
325 } |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
326 } |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
327 } |