Mercurial > hg > orthanc
annotate OrthancServer/ServerToolbox.cpp @ 1745:38dda23c7d7d db-changes
LookupIdentifierQuery
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 26 Oct 2015 13:47:50 +0100 |
parents | b3de74dec2d5 |
children | ca69082ab200 |
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 |
1673
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1669
diff
changeset
|
36 #include "../Core/DicomFormat/DicomArray.h" |
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1669
diff
changeset
|
37 #include "../Core/FileStorage/StorageAccessor.h" |
1486
f967bdf8534e
refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
38 #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
|
39 #include "../Core/OrthancException.h" |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
40 #include "ParsedDicomFile.h" |
1745
38dda23c7d7d
LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1744
diff
changeset
|
41 #include "LookupIdentifierQuery.h" |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 |
234 | 43 #include <cassert> |
44 | |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 namespace Orthanc |
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 namespace Toolbox |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 { |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
49 void SimplifyTags(Json::Value& target, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
50 const Json::Value& source) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
51 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
52 assert(source.isObject()); |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
54 target = Json::objectValue; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
55 Json::Value::Members members = source.getMemberNames(); |
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 for (size_t i = 0; i < members.size(); i++) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
58 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
59 const Json::Value& v = source[members[i]]; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
60 const std::string& name = v["Name"].asString(); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
61 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
|
62 |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
63 if (type == "String") |
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 target[name] = v["Value"].asString(); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
66 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
67 else if (type == "TooLong" || |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
68 type == "Null") |
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 target[name] = Json::nullValue; |
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 else if (type == "Sequence") |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
73 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
74 const Json::Value& array = v["Value"]; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
75 assert(array.isArray()); |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
77 Json::Value children = Json::arrayValue; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
78 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
|
79 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
80 Json::Value c; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
81 SimplifyTags(c, array[i]); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
82 children.append(c); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
83 } |
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 target[name] = children; |
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 else |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
88 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
89 assert(0); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
90 } |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 } |
1668
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 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
94 |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
95 static std::string ValueAsString(const DicomMap& summary, |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
96 const DicomTag& tag) |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
97 { |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
98 const DicomValue& value = summary.GetValue(tag); |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
99 if (value.IsNull()) |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
100 { |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
101 return "(null)"; |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
102 } |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
103 else |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
104 { |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
105 return value.GetContent(); |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
106 } |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
107 } |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
108 |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
109 |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
110 void LogMissingRequiredTag(const DicomMap& summary) |
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 std::string s, t; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
113 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
114 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
|
115 { |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
116 if (t.size() > 0) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
117 t += ", "; |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
118 t += "PatientID=" + ValueAsString(summary, 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
|
119 } |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
120 else |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 { |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
122 if (s.size() > 0) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
123 s += ", "; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
124 s += "PatientID"; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
125 } |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
127 if (summary.HasTag(DICOM_TAG_STUDY_INSTANCE_UID)) |
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 if (t.size() > 0) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
130 t += ", "; |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
131 t += "StudyInstanceUID=" + ValueAsString(summary, DICOM_TAG_STUDY_INSTANCE_UID); |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
132 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
133 else |
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 if (s.size() > 0) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
136 s += ", "; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
137 s += "StudyInstanceUID"; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
138 } |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
140 if (summary.HasTag(DICOM_TAG_SERIES_INSTANCE_UID)) |
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 if (t.size() > 0) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
143 t += ", "; |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
144 t += "SeriesInstanceUID=" + ValueAsString(summary, DICOM_TAG_SERIES_INSTANCE_UID); |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
145 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
146 else |
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 if (s.size() > 0) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
149 s += ", "; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
150 s += "SeriesInstanceUID"; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
151 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
152 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
153 if (summary.HasTag(DICOM_TAG_SOP_INSTANCE_UID)) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
154 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
155 if (t.size() > 0) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
156 t += ", "; |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
157 t += "SOPInstanceUID=" + ValueAsString(summary, DICOM_TAG_SOP_INSTANCE_UID); |
1668
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 else |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
160 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
161 if (s.size() > 0) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
162 s += ", "; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
163 s += "SOPInstanceUID"; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
164 } |
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 if (t.size() == 0) |
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 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
|
169 } |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 else |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 { |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
172 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
|
173 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
174 } |
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 |
1716
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
177 static void SetMainDicomTagsInternal(IDatabaseWrapper& database, |
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
178 int64_t resource, |
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
179 const DicomMap& tags) |
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
180 { |
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
181 DicomArray flattened(tags); |
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
182 |
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
183 for (size_t i = 0; i < flattened.GetSize(); i++) |
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
184 { |
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
185 const DicomElement& element = flattened.GetElement(i); |
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
186 const DicomTag& tag = element.GetTag(); |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
187 const DicomValue& value = element.GetValue(); |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
188 if (!value.IsNull() && |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
189 !value.IsBinary()) |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
190 { |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
191 database.SetMainDicomTag(resource, tag, element.GetValue().GetContent()); |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1725
diff
changeset
|
192 } |
1716
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
193 } |
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
194 } |
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
195 |
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
196 |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
197 void SetMainDicomTags(IDatabaseWrapper& database, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
198 int64_t resource, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
199 ResourceType level, |
1716
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
200 const DicomMap& dicomSummary) |
1668
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 // WARNING: The database should be locked with a transaction! |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
203 |
1745
38dda23c7d7d
LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1744
diff
changeset
|
204 LookupIdentifierQuery::StoreIdentifiers(database, resource, level, dicomSummary); |
38dda23c7d7d
LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1744
diff
changeset
|
205 |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
206 DicomMap tags; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
207 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
208 switch (level) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
209 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
210 case ResourceType_Patient: |
1745
38dda23c7d7d
LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1744
diff
changeset
|
211 dicomSummary.ExtractPatientInformation(tags); |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
212 break; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
213 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
214 case ResourceType_Study: |
1717
3926e6317a43
SetIdentifierTagInternal
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1716
diff
changeset
|
215 // Duplicate the patient tags at the study level (new in Orthanc 0.9.5 - db v6) |
1745
38dda23c7d7d
LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1744
diff
changeset
|
216 dicomSummary.ExtractPatientInformation(tags); |
38dda23c7d7d
LookupIdentifierQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1744
diff
changeset
|
217 SetMainDicomTagsInternal(database, resource, tags); |
1717
3926e6317a43
SetIdentifierTagInternal
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1716
diff
changeset
|
218 |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
219 dicomSummary.ExtractStudyInformation(tags); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
220 break; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
221 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
222 case ResourceType_Series: |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
223 dicomSummary.ExtractSeriesInformation(tags); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
224 break; |
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 case ResourceType_Instance: |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
227 dicomSummary.ExtractInstanceInformation(tags); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
228 break; |
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 default: |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
231 throw OrthancException(ErrorCode_InternalError); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
232 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
233 |
1716
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
234 SetMainDicomTagsInternal(database, resource, tags); |
1668
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 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
237 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
238 bool FindOneChildInstance(int64_t& result, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
239 IDatabaseWrapper& database, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
240 int64_t resource, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
241 ResourceType type) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
242 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
243 for (;;) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
244 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
245 if (type == ResourceType_Instance) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
246 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
247 result = resource; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
248 return true; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
249 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
250 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
251 std::list<int64_t> children; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
252 database.GetChildrenInternalId(children, resource); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
253 if (children.empty()) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
254 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
255 return false; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
256 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
257 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
258 resource = children.front(); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
259 type = GetChildResourceType(type); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
260 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
261 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
262 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
263 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
264 void ReconstructMainDicomTags(IDatabaseWrapper& database, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
265 IStorageArea& storageArea, |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
266 ResourceType level) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
267 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
268 // WARNING: The database should be locked with a transaction! |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
269 |
1669
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
270 const char* plural = NULL; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
271 |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
272 switch (level) |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
273 { |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
274 case ResourceType_Patient: |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
275 plural = "patients"; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
276 break; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
277 |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
278 case ResourceType_Study: |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
279 plural = "studies"; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
280 break; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
281 |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
282 case ResourceType_Series: |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
283 plural = "series"; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
284 break; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
285 |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
286 case ResourceType_Instance: |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
287 plural = "instances"; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
288 break; |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
289 |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
290 default: |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
291 throw OrthancException(ErrorCode_InternalError); |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
292 } |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
293 |
a412ad57f0f9
refactoring of sample plugins, OrthancPluginReconstructMainDicomTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
294 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
|
295 |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
296 std::list<std::string> resources; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
297 database.GetAllPublicIds(resources, level); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
298 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
299 for (std::list<std::string>::const_iterator |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
300 it = resources.begin(); it != resources.end(); it++) |
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 // Locate the resource and one of its child instances |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
303 int64_t resource, instance; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
304 ResourceType tmp; |
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 if (!database.LookupResource(resource, tmp, *it) || |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
307 tmp != level || |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
308 !FindOneChildInstance(instance, database, resource, level)) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
309 { |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
310 throw OrthancException(ErrorCode_InternalError); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
311 } |
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 // 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
|
314 FileInfo attachment; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
315 if (!database.LookupAttachment(attachment, instance, FileContentType_Dicom)) |
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 throw OrthancException(ErrorCode_InternalError); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
318 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
319 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
320 // Read and parse the content of the DICOM file |
1673
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1669
diff
changeset
|
321 StorageAccessor accessor(storageArea); |
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1669
diff
changeset
|
322 |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
323 std::string content; |
1673
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1669
diff
changeset
|
324 accessor.Read(content, attachment); |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
325 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
326 ParsedDicomFile dicom(content); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
327 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
328 // Update the tags of this resource |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
329 DicomMap dicomSummary; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
330 dicom.Convert(dicomSummary); |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
331 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
332 database.ClearMainDicomTags(resource); |
1716
2ca7888f8600
refactoring DicomIdentifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1713
diff
changeset
|
333 Toolbox::SetMainDicomTags(database, resource, level, dicomSummary); |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
334 } |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
335 } |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
336 } |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
337 } |