Mercurial > hg > orthanc
annotate Core/DicomFormat/DicomTag.cpp @ 1228:e0f7014d39a4
Instances without PatientID are now allowed
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 21 Nov 2014 09:12:38 +0100 |
parents | 1ea4094d077c |
children | 6164f7200c43 |
rev | line source |
---|---|
0 | 1 /** |
59 | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
689 | 3 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege, |
0 | 4 * Belgium |
5 * | |
6 * This program is free software: you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License, or (at your option) any later version. | |
136 | 10 * |
11 * In addition, as a special exception, the copyright holders of this | |
12 * program give permission to link the code of its release with the | |
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
14 * that use the same license as the "OpenSSL" library), and distribute | |
15 * the linked executables. You must obey the GNU General Public License | |
16 * in all respects for all of the code used other than "OpenSSL". If you | |
17 * modify file(s) with this exception, you may extend this exception to | |
18 * your version of the file(s), but you are not obligated to do so. If | |
19 * you do not wish to do so, delete this exception statement from your | |
20 * version. If you delete this exception statement from all source files | |
21 * in the program, then also delete it here. | |
0 | 22 * |
23 * This program is distributed in the hope that it will be useful, but | |
24 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
26 * General Public License for more details. | |
27 * | |
28 * You should have received a copy of the GNU General Public License | |
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
30 **/ | |
31 | |
32 | |
824
a811bdf8b8eb
precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
33 #include "../PrecompiledHeaders.h" |
0 | 34 #include "DicomTag.h" |
35 | |
59 | 36 #include "../OrthancException.h" |
0 | 37 |
38 #include <iostream> | |
39 #include <iomanip> | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
40 #include <stdio.h> |
0 | 41 |
59 | 42 namespace Orthanc |
0 | 43 { |
44 bool DicomTag::operator< (const DicomTag& other) const | |
45 { | |
46 if (group_ < other.group_) | |
47 return true; | |
48 | |
49 if (group_ > other.group_) | |
50 return false; | |
51 | |
52 return element_ < other.element_; | |
53 } | |
54 | |
55 | |
56 std::ostream& operator<< (std::ostream& o, const DicomTag& tag) | |
57 { | |
58 using namespace std; | |
59 ios_base::fmtflags state = o.flags(); | |
60 o.flags(ios::right | ios::hex); | |
61 o << "(" << setfill('0') << setw(4) << tag.GetGroup() | |
62 << "," << setw(4) << tag.GetElement() << ")"; | |
63 o.flags(state); | |
64 return o; | |
65 } | |
66 | |
67 | |
35
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
68 std::string DicomTag::Format() const |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
69 { |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
70 char b[16]; |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
71 sprintf(b, "%04x,%04x", group_, element_); |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
72 return std::string(b); |
f6d12037f886
full json vs. simplified json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
73 } |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
74 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
75 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
76 const char* DicomTag::GetMainTagsName() const |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
77 { |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
78 if (*this == DICOM_TAG_ACCESSION_NUMBER) |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
79 return "AccessionNumber"; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
80 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
81 if (*this == DICOM_TAG_SOP_INSTANCE_UID) |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
82 return "SOPInstanceUID"; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
83 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
84 if (*this == DICOM_TAG_PATIENT_ID) |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
85 return "PatientID"; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
86 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
87 if (*this == DICOM_TAG_SERIES_INSTANCE_UID) |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
88 return "SeriesInstanceUID"; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
89 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
90 if (*this == DICOM_TAG_STUDY_INSTANCE_UID) |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
91 return "StudyInstanceUID"; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
92 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
93 if (*this == DICOM_TAG_PIXEL_DATA) |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
94 return "PixelData"; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
95 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
96 if (*this == DICOM_TAG_IMAGE_INDEX) |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
97 return "ImageIndex"; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
98 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
99 if (*this == DICOM_TAG_INSTANCE_NUMBER) |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
100 return "InstanceNumber"; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
101 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
102 if (*this == DICOM_TAG_NUMBER_OF_SLICES) |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
103 return "NumberOfSlices"; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
104 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
105 if (*this == DICOM_TAG_NUMBER_OF_FRAMES) |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
106 return "NumberOfFrames"; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
107 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
108 if (*this == DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES) |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
109 return "CardiacNumberOfImages"; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
110 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
111 if (*this == DICOM_TAG_IMAGES_IN_ACQUISITION) |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
112 return "ImagesInAcquisition"; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
113 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
114 if (*this == DICOM_TAG_PATIENT_NAME) |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
115 return "PatientName"; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
116 |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
117 return ""; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
136
diff
changeset
|
118 } |
961 | 119 |
120 | |
121 void DicomTag::GetTagsForModule(std::set<DicomTag>& target, | |
122 ResourceType module) | |
123 { | |
124 // REFERENCE: 11_03pu.pdf, DICOM PS 3.3 2011 - Information Object Definitions | |
125 target.clear(); | |
126 | |
127 switch (module) | |
128 { | |
129 case ResourceType_Patient: | |
130 // This is Table C.7-1 "Patient Module Attributes" (p. 373) | |
131 target.insert(DicomTag(0x0010, 0x0010)); // Patient's name | |
132 target.insert(DicomTag(0x0010, 0x0020)); // Patient ID | |
133 target.insert(DicomTag(0x0010, 0x0030)); // Patient's birth date | |
134 target.insert(DicomTag(0x0010, 0x0040)); // Patient's sex | |
135 target.insert(DicomTag(0x0008, 0x1120)); // Referenced patient sequence | |
136 target.insert(DicomTag(0x0010, 0x0032)); // Patient's birth time | |
137 target.insert(DicomTag(0x0010, 0x1000)); // Other patient IDs | |
138 target.insert(DicomTag(0x0010, 0x1002)); // Other patient IDs sequence | |
139 target.insert(DicomTag(0x0010, 0x1001)); // Other patient names | |
140 target.insert(DicomTag(0x0010, 0x2160)); // Ethnic group | |
141 target.insert(DicomTag(0x0010, 0x4000)); // Patient comments | |
142 target.insert(DicomTag(0x0010, 0x2201)); // Patient species description | |
143 target.insert(DicomTag(0x0010, 0x2202)); // Patient species code sequence | |
144 target.insert(DicomTag(0x0010, 0x2292)); // Patient breed description | |
145 target.insert(DicomTag(0x0010, 0x2293)); // Patient breed code sequence | |
146 target.insert(DicomTag(0x0010, 0x2294)); // Breed registration sequence | |
147 target.insert(DicomTag(0x0010, 0x2297)); // Responsible person | |
148 target.insert(DicomTag(0x0010, 0x2298)); // Responsible person role | |
149 target.insert(DicomTag(0x0010, 0x2299)); // Responsible organization | |
150 target.insert(DicomTag(0x0012, 0x0062)); // Patient identity removed | |
151 target.insert(DicomTag(0x0012, 0x0063)); // De-identification method | |
152 target.insert(DicomTag(0x0012, 0x0064)); // De-identification method code sequence | |
153 | |
154 // Table 10-18 ISSUER OF PATIENT ID MACRO (p. 112) | |
155 target.insert(DicomTag(0x0010, 0x0021)); // Issuer of Patient ID | |
156 target.insert(DicomTag(0x0010, 0x0024)); // Issuer of Patient ID qualifiers sequence | |
157 break; | |
158 | |
159 case ResourceType_Study: | |
160 // This is Table C.7-3 "General Study Module Attributes" (p. 378) | |
161 target.insert(DicomTag(0x0020, 0x000d)); // Study instance UID | |
162 target.insert(DicomTag(0x0008, 0x0020)); // Study date | |
163 target.insert(DicomTag(0x0008, 0x0030)); // Study time | |
164 target.insert(DicomTag(0x0008, 0x0090)); // Referring physician's name | |
165 target.insert(DicomTag(0x0008, 0x0096)); // Referring physician identification sequence | |
166 target.insert(DicomTag(0x0020, 0x0010)); // Study ID | |
167 target.insert(DicomTag(0x0008, 0x0050)); // Accession number | |
168 target.insert(DicomTag(0x0008, 0x0051)); // Issuer of accession number sequence | |
169 target.insert(DicomTag(0x0008, 0x1030)); // Study description | |
170 target.insert(DicomTag(0x0008, 0x1048)); // Physician(s) of record | |
171 target.insert(DicomTag(0x0008, 0x1049)); // Physician(s) of record identification sequence | |
172 target.insert(DicomTag(0x0008, 0x1060)); // Name of physician(s) reading study | |
173 target.insert(DicomTag(0x0008, 0x1062)); // Physician(s) reading study identification sequence | |
174 target.insert(DicomTag(0x0032, 0x1034)); // Requesting service code sequence | |
175 target.insert(DicomTag(0x0008, 0x1110)); // Referenced study sequence | |
176 target.insert(DicomTag(0x0008, 0x1032)); // Procedure code sequence | |
177 target.insert(DicomTag(0x0040, 0x1012)); // Reason for performed procedure code sequence | |
178 break; | |
179 | |
180 case ResourceType_Series: | |
181 // This is Table C.7-5 "General Series Module Attributes" (p. 385) | |
962 | 182 target.insert(DicomTag(0x0008, 0x0060)); // Modality |
183 target.insert(DicomTag(0x0020, 0x000e)); // Series Instance UID | |
184 target.insert(DicomTag(0x0020, 0x0011)); // Series Number | |
185 target.insert(DicomTag(0x0020, 0x0060)); // Laterality | |
186 target.insert(DicomTag(0x0008, 0x0021)); // Series Date | |
187 target.insert(DicomTag(0x0008, 0x0031)); // Series Time | |
188 target.insert(DicomTag(0x0008, 0x1050)); // Performing Physicians’ Name | |
189 target.insert(DicomTag(0x0008, 0x1052)); // Performing Physician Identification Sequence | |
190 target.insert(DicomTag(0x0018, 0x1030)); // Protocol Name | |
191 target.insert(DicomTag(0x0008, 0x103e)); // Series Description | |
192 target.insert(DicomTag(0x0008, 0x103f)); // Series Description Code Sequence | |
193 target.insert(DicomTag(0x0008, 0x1070)); // Operators' Name | |
194 target.insert(DicomTag(0x0008, 0x1072)); // Operator Identification Sequence | |
195 target.insert(DicomTag(0x0008, 0x1111)); // Referenced Performed Procedure Step Sequence | |
196 target.insert(DicomTag(0x0008, 0x1250)); // Related Series Sequence | |
197 target.insert(DicomTag(0x0018, 0x0015)); // Body Part Examined | |
198 target.insert(DicomTag(0x0018, 0x5100)); // Patient Position | |
199 target.insert(DicomTag(0x0028, 0x0108)); // Smallest Pixel Value in Series | |
200 target.insert(DicomTag(0x0029, 0x0109)); // Largest Pixel Value in Series | |
201 target.insert(DicomTag(0x0040, 0x0275)); // Request Attributes Sequence | |
202 target.insert(DicomTag(0x0010, 0x2210)); // Anatomical Orientation Type | |
203 | |
204 // Table 10-16 PERFORMED PROCEDURE STEP SUMMARY MACRO ATTRIBUTES | |
205 target.insert(DicomTag(0x0040, 0x0253)); // Performed Procedure Step ID | |
206 target.insert(DicomTag(0x0040, 0x0244)); // Performed Procedure Step Start Date | |
207 target.insert(DicomTag(0x0040, 0x0245)); // Performed Procedure Step Start Time | |
208 target.insert(DicomTag(0x0040, 0x0254)); // Performed Procedure Step Description | |
209 target.insert(DicomTag(0x0040, 0x0260)); // Performed Protocol Code Sequence | |
210 target.insert(DicomTag(0x0040, 0x0280)); // Comments on the Performed Procedure Step | |
961 | 211 break; |
212 | |
213 case ResourceType_Instance: | |
214 // This is Table C.12-1 "SOP Common Module Attributes" (p. 1207) | |
962 | 215 target.insert(DicomTag(0x0008, 0x0016)); // SOP Class UID |
216 target.insert(DicomTag(0x0008, 0x0018)); // SOP Instance UID | |
217 target.insert(DicomTag(0x0008, 0x0005)); // Specific Character Set | |
218 target.insert(DicomTag(0x0008, 0x0012)); // Instance Creation Date | |
219 target.insert(DicomTag(0x0008, 0x0013)); // Instance Creation Time | |
220 target.insert(DicomTag(0x0008, 0x0014)); // Instance Creator UID | |
221 target.insert(DicomTag(0x0008, 0x001a)); // Related General SOP Class UID | |
222 target.insert(DicomTag(0x0008, 0x001b)); // Original Specialized SOP Class UID | |
223 target.insert(DicomTag(0x0008, 0x0110)); // Coding Scheme Identification Sequence | |
224 target.insert(DicomTag(0x0008, 0x0201)); // Timezone Offset From UTC | |
225 target.insert(DicomTag(0x0018, 0xa001)); // Contributing Equipment Sequence | |
226 target.insert(DicomTag(0x0020, 0x0013)); // Instance Number | |
227 target.insert(DicomTag(0x0100, 0x0410)); // SOP Instance Status | |
228 target.insert(DicomTag(0x0100, 0x0420)); // SOP Authorization DateTime | |
229 target.insert(DicomTag(0x0100, 0x0424)); // SOP Authorization Comment | |
230 target.insert(DicomTag(0x0100, 0x0426)); // Authorization Equipment Certification Number | |
231 target.insert(DicomTag(0x0400, 0x0500)); // Encrypted Attributes Sequence | |
232 target.insert(DicomTag(0x0400, 0x0561)); // Original Attributes Sequence | |
233 target.insert(DicomTag(0x0040, 0xa390)); // HL7 Structured Document Reference Sequence | |
234 target.insert(DicomTag(0x0028, 0x0303)); // Longitudinal Temporal Information Modified | |
235 | |
236 // Table C.12-6 "DIGITAL SIGNATURES MACRO ATTRIBUTES" (p. 1216) | |
237 target.insert(DicomTag(0x4ffe, 0x0001)); // MAC Parameters sequence | |
238 target.insert(DicomTag(0xfffa, 0xfffa)); // Digital signatures sequence | |
961 | 239 break; |
240 | |
962 | 241 // TODO IMAGE MODULE? |
242 | |
961 | 243 default: |
244 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
245 } | |
246 } | |
1162 | 247 |
248 | |
249 bool DicomTag::IsIdentifier() const | |
250 { | |
251 return (*this == DICOM_TAG_PATIENT_ID || | |
252 *this == DICOM_TAG_STUDY_INSTANCE_UID || | |
253 *this == DICOM_TAG_ACCESSION_NUMBER || | |
254 *this == DICOM_TAG_SERIES_INSTANCE_UID || | |
255 *this == DICOM_TAG_SOP_INSTANCE_UID); | |
256 } | |
0 | 257 } |