Mercurial > hg > orthanc
annotate UnitTestsSources/DicomMapTests.cpp @ 3348:a1cd981a0f9a
more logs
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Thu, 18 Apr 2019 15:52:25 +0200 |
parents | cf8cbeb35f33 |
children | 109631ed3564 |
rev | line source |
---|---|
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
1 /** |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
3060
4e43e67f8ecf
preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3040
diff
changeset
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
6 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
8 * modify it under the terms of the GNU General Public License as |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
9 * published by the Free Software Foundation, either version 3 of the |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
10 * License, or (at your option) any later version. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
11 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
12 * In addition, as a special exception, the copyright holders of this |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
13 * program give permission to link the code of its release with the |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
15 * that use the same license as the "OpenSSL" library), and distribute |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
16 * the linked executables. You must obey the GNU General Public License |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
17 * in all respects for all of the code used other than "OpenSSL". If you |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
18 * modify file(s) with this exception, you may extend this exception to |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
19 * your version of the file(s), but you are not obligated to do so. If |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
20 * you do not wish to do so, delete this exception statement from your |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
21 * version. If you delete this exception statement from all source files |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
22 * in the program, then also delete it here. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
23 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
24 * This program is distributed in the hope that it will be useful, but |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
25 * WITHOUT ANY WARRANTY; without even the implied warranty of |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
27 * General Public License for more details. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
28 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
29 * You should have received a copy of the GNU General Public License |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
31 **/ |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
32 |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
711
diff
changeset
|
33 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
827
diff
changeset
|
34 #include "PrecompiledHeadersUnitTests.h" |
711 | 35 #include "gtest/gtest.h" |
36 | |
37 #include "../Core/OrthancException.h" | |
38 #include "../Core/DicomFormat/DicomMap.h" | |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
39 #include "../Core/DicomParsing/FromDcmtkBridge.h" |
3209
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
40 #include "../Core/DicomParsing/ToDcmtkBridge.h" |
3005
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
41 #include "../Core/DicomParsing/ParsedDicomFile.h" |
3202 | 42 #include "../Core/DicomParsing/DicomWebJsonVisitor.h" |
3005
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
43 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
44 #include "../OrthancServer/DicomInstanceToStore.h" |
711 | 45 |
46 #include <memory> | |
3005
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
47 #include <dcmtk/dcmdata/dcdeftag.h> |
3209
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
48 #include <dcmtk/dcmdata/dcvrat.h> |
711 | 49 |
50 using namespace Orthanc; | |
51 | |
52 TEST(DicomMap, MainTags) | |
53 { | |
54 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID)); | |
55 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID, ResourceType_Patient)); | |
56 ASSERT_FALSE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID, ResourceType_Study)); | |
57 | |
58 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_STUDY_INSTANCE_UID)); | |
59 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_ACCESSION_NUMBER)); | |
60 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_SERIES_INSTANCE_UID)); | |
61 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_SOP_INSTANCE_UID)); | |
62 | |
63 std::set<DicomTag> s; | |
64 DicomMap::GetMainDicomTags(s); | |
65 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_PATIENT_ID)); | |
66 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_STUDY_INSTANCE_UID)); | |
67 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_ACCESSION_NUMBER)); | |
68 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SERIES_INSTANCE_UID)); | |
69 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SOP_INSTANCE_UID)); | |
70 | |
71 DicomMap::GetMainDicomTags(s, ResourceType_Patient); | |
72 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_PATIENT_ID)); | |
73 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_STUDY_INSTANCE_UID)); | |
74 | |
75 DicomMap::GetMainDicomTags(s, ResourceType_Study); | |
76 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_STUDY_INSTANCE_UID)); | |
77 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_ACCESSION_NUMBER)); | |
78 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID)); | |
79 | |
80 DicomMap::GetMainDicomTags(s, ResourceType_Series); | |
81 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SERIES_INSTANCE_UID)); | |
82 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID)); | |
83 | |
84 DicomMap::GetMainDicomTags(s, ResourceType_Instance); | |
85 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SOP_INSTANCE_UID)); | |
86 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID)); | |
87 } | |
88 | |
89 | |
90 TEST(DicomMap, Tags) | |
91 { | |
1360 | 92 std::set<DicomTag> s; |
93 | |
711 | 94 DicomMap m; |
1360 | 95 m.GetTags(s); |
1492 | 96 ASSERT_EQ(0u, s.size()); |
1360 | 97 |
711 | 98 ASSERT_FALSE(m.HasTag(DICOM_TAG_PATIENT_NAME)); |
99 ASSERT_FALSE(m.HasTag(0x0010, 0x0010)); | |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
100 m.SetValue(0x0010, 0x0010, "PatientName", false); |
711 | 101 ASSERT_TRUE(m.HasTag(DICOM_TAG_PATIENT_NAME)); |
102 ASSERT_TRUE(m.HasTag(0x0010, 0x0010)); | |
103 | |
1360 | 104 m.GetTags(s); |
1492 | 105 ASSERT_EQ(1u, s.size()); |
1360 | 106 ASSERT_EQ(DICOM_TAG_PATIENT_NAME, *s.begin()); |
107 | |
711 | 108 ASSERT_FALSE(m.HasTag(DICOM_TAG_PATIENT_ID)); |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
109 m.SetValue(DICOM_TAG_PATIENT_ID, "PatientID", false); |
711 | 110 ASSERT_TRUE(m.HasTag(0x0010, 0x0020)); |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
111 m.SetValue(DICOM_TAG_PATIENT_ID, "PatientID2", false); |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1704
diff
changeset
|
112 ASSERT_EQ("PatientID2", m.GetValue(0x0010, 0x0020).GetContent()); |
711 | 113 |
1360 | 114 m.GetTags(s); |
1492 | 115 ASSERT_EQ(2u, s.size()); |
1360 | 116 |
711 | 117 m.Remove(DICOM_TAG_PATIENT_ID); |
118 ASSERT_THROW(m.GetValue(0x0010, 0x0020), OrthancException); | |
119 | |
1360 | 120 m.GetTags(s); |
1492 | 121 ASSERT_EQ(1u, s.size()); |
1360 | 122 ASSERT_EQ(DICOM_TAG_PATIENT_NAME, *s.begin()); |
123 | |
711 | 124 std::auto_ptr<DicomMap> mm(m.Clone()); |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1704
diff
changeset
|
125 ASSERT_EQ("PatientName", mm->GetValue(DICOM_TAG_PATIENT_NAME).GetContent()); |
711 | 126 |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
127 m.SetValue(DICOM_TAG_PATIENT_ID, "Hello", false); |
711 | 128 ASSERT_THROW(mm->GetValue(DICOM_TAG_PATIENT_ID), OrthancException); |
129 mm->CopyTagIfExists(m, DICOM_TAG_PATIENT_ID); | |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1704
diff
changeset
|
130 ASSERT_EQ("Hello", mm->GetValue(DICOM_TAG_PATIENT_ID).GetContent()); |
711 | 131 |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1704
diff
changeset
|
132 DicomValue v; |
711 | 133 ASSERT_TRUE(v.IsNull()); |
134 } | |
135 | |
136 | |
137 TEST(DicomMap, FindTemplates) | |
138 { | |
139 DicomMap m; | |
140 | |
141 DicomMap::SetupFindPatientTemplate(m); | |
142 ASSERT_TRUE(m.HasTag(DICOM_TAG_PATIENT_ID)); | |
143 | |
144 DicomMap::SetupFindStudyTemplate(m); | |
145 ASSERT_TRUE(m.HasTag(DICOM_TAG_STUDY_INSTANCE_UID)); | |
146 ASSERT_TRUE(m.HasTag(DICOM_TAG_ACCESSION_NUMBER)); | |
147 | |
148 DicomMap::SetupFindSeriesTemplate(m); | |
149 ASSERT_TRUE(m.HasTag(DICOM_TAG_SERIES_INSTANCE_UID)); | |
150 | |
151 DicomMap::SetupFindInstanceTemplate(m); | |
152 ASSERT_TRUE(m.HasTag(DICOM_TAG_SOP_INSTANCE_UID)); | |
153 } | |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
154 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
155 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
156 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
157 |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
158 static void TestModule(ResourceType level, |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
159 DicomModule module) |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
160 { |
1848
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
161 // REFERENCE: DICOM PS3.3 2015c - Information Object Definitions |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
162 // http://dicom.nema.org/medical/dicom/current/output/html/part03.html |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
163 |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
164 std::set<DicomTag> moduleTags, main; |
1368 | 165 DicomTag::AddTagsForModule(moduleTags, module); |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
166 DicomMap::GetMainDicomTags(main, level); |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
167 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
168 // The main dicom tags are a subset of the module |
1304 | 169 for (std::set<DicomTag>::const_iterator it = main.begin(); it != main.end(); ++it) |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
170 { |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
171 bool ok = moduleTags.find(*it) != moduleTags.end(); |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
172 |
1848
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
173 // Exceptions for the Study level |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
174 if (level == ResourceType_Study && |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
175 (*it == DicomTag(0x0008, 0x0080) || /* InstitutionName, from Visit identification module, related to Visit */ |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
176 *it == DicomTag(0x0032, 0x1032) || /* RequestingPhysician, from Imaging Service Request module, related to Study */ |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
177 *it == DicomTag(0x0032, 0x1060))) /* RequestedProcedureDescription, from Requested Procedure module, related to Study */ |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
178 { |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
179 ok = true; |
1848
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
180 } |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
181 |
1849
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
182 // Exceptions for the Series level |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
183 if (level == ResourceType_Series && |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
184 (*it == DicomTag(0x0008, 0x0070) || /* Manufacturer, from General Equipment Module */ |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
185 *it == DicomTag(0x0008, 0x1010) || /* StationName, from General Equipment Module */ |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
186 *it == DicomTag(0x0018, 0x0024) || /* SequenceName, from MR Image Module (SIMPLIFICATION => Series) */ |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
187 *it == DicomTag(0x0018, 0x1090) || /* CardiacNumberOfImages, from MR Image Module (SIMPLIFICATION => Series) */ |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
188 *it == DicomTag(0x0020, 0x0037) || /* ImageOrientationPatient, from Image Plane Module (SIMPLIFICATION => Series) */ |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
189 *it == DicomTag(0x0020, 0x0105) || /* NumberOfTemporalPositions, from MR Image Module (SIMPLIFICATION => Series) */ |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
190 *it == DicomTag(0x0020, 0x1002) || /* ImagesInAcquisition, from General Image Module (SIMPLIFICATION => Series) */ |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
191 *it == DicomTag(0x0054, 0x0081) || /* NumberOfSlices, from PET Series module */ |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
192 *it == DicomTag(0x0054, 0x0101) || /* NumberOfTimeSlices, from PET Series module */ |
1850
68854412c7bc
new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1849
diff
changeset
|
193 *it == DicomTag(0x0054, 0x1000) || /* SeriesType, from PET Series module */ |
68854412c7bc
new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1849
diff
changeset
|
194 *it == DicomTag(0x0018, 0x1400) || /* AcquisitionDeviceProcessingDescription, from CR/X-Ray/DX/WholeSlideMicro Image (SIMPLIFICATION => Series) */ |
68854412c7bc
new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1849
diff
changeset
|
195 *it == DicomTag(0x0018, 0x0010))) /* ContrastBolusAgent, from Contrast/Bolus module (SIMPLIFICATION => Series) */ |
1849
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
196 { |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
197 ok = true; |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
198 } |
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
199 |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
200 // Exceptions for the Instance level |
1704 | 201 if (level == ResourceType_Instance && |
1848
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
202 (*it == DicomTag(0x0020, 0x0012) || /* AccessionNumber, from General Image module */ |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
203 *it == DicomTag(0x0054, 0x1330) || /* ImageIndex, from PET Image module */ |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
204 *it == DicomTag(0x0020, 0x0100) || /* TemporalPositionIdentifier, from MR Image module */ |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
205 *it == DicomTag(0x0028, 0x0008) || /* NumberOfFrames, from Multi-frame module attributes, related to Image */ |
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
206 *it == DicomTag(0x0020, 0x0032) || /* ImagePositionPatient, from Image Plan module, related to Image */ |
2804
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
207 *it == DicomTag(0x0020, 0x0037) || /* ImageOrientationPatient, from Image Plane Module (Orthanc 1.4.2) */ |
1848
e39716f71d67
new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
208 *it == DicomTag(0x0020, 0x4000))) /* ImageComments, from General Image module */ |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
209 { |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
210 ok = true; |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
211 } |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
212 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
213 if (!ok) |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
214 { |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
215 std::cout << it->Format() << ": " << FromDcmtkBridge::GetTagName(*it, "") |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
216 << " not expected at level " << EnumerationToString(level) << std::endl; |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
217 } |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
218 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
219 EXPECT_TRUE(ok); |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
220 } |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
221 } |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
222 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
223 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
224 TEST(DicomMap, Modules) |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
225 { |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
226 TestModule(ResourceType_Patient, DicomModule_Patient); |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
227 TestModule(ResourceType_Study, DicomModule_Study); |
1849
6394a2f8f1e1
test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1848
diff
changeset
|
228 TestModule(ResourceType_Series, DicomModule_Series); // TODO |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
229 TestModule(ResourceType_Instance, DicomModule_Instance); |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
230 } |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
231 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
232 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
233 TEST(DicomMap, Parse) |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
234 { |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
235 DicomMap m; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
236 float f; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
237 double d; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
238 int32_t i; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
239 int64_t j; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
240 uint32_t k; |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
241 uint64_t l; |
2412
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
242 std::string s; |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
243 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
244 m.SetValue(DICOM_TAG_PATIENT_NAME, " ", false); // Empty value |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
245 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
246 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
247 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
248 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
249 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
250 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
251 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
252 m.SetValue(DICOM_TAG_PATIENT_NAME, "0", true); // Binary value |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
253 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
254 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
255 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
256 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
257 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
258 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
259 |
2412
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
260 ASSERT_FALSE(m.CopyToString(s, DICOM_TAG_PATIENT_NAME, false)); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
261 ASSERT_TRUE(m.CopyToString(s, DICOM_TAG_PATIENT_NAME, true)); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
262 ASSERT_EQ("0", s); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
263 |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
264 |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
265 // 2**31-1 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
266 m.SetValue(DICOM_TAG_PATIENT_NAME, "2147483647", false); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
267 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
268 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
269 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
270 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
271 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
272 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
273 ASSERT_FLOAT_EQ(2147483647.0f, f); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
274 ASSERT_DOUBLE_EQ(2147483647.0, d); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
275 ASSERT_EQ(2147483647, i); |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2412
diff
changeset
|
276 ASSERT_EQ(2147483647ll, j); |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
277 ASSERT_EQ(2147483647u, k); |
2418 | 278 ASSERT_EQ(2147483647ull, l); |
2412
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
279 |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
280 // Test shortcuts |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
281 m.SetValue(DICOM_TAG_PATIENT_NAME, "42", false); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
282 ASSERT_TRUE(m.ParseFloat(f, DICOM_TAG_PATIENT_NAME)); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
283 ASSERT_TRUE(m.ParseDouble(d, DICOM_TAG_PATIENT_NAME)); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
284 ASSERT_TRUE(m.ParseInteger32(i, DICOM_TAG_PATIENT_NAME)); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
285 ASSERT_TRUE(m.ParseInteger64(j, DICOM_TAG_PATIENT_NAME)); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
286 ASSERT_TRUE(m.ParseUnsignedInteger32(k, DICOM_TAG_PATIENT_NAME)); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
287 ASSERT_TRUE(m.ParseUnsignedInteger64(l, DICOM_TAG_PATIENT_NAME)); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
288 ASSERT_FLOAT_EQ(42.0f, f); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
289 ASSERT_DOUBLE_EQ(42.0, d); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
290 ASSERT_EQ(42, i); |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2412
diff
changeset
|
291 ASSERT_EQ(42ll, j); |
2412
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
292 ASSERT_EQ(42u, k); |
2418 | 293 ASSERT_EQ(42ull, l); |
2412
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
294 |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
295 ASSERT_TRUE(m.CopyToString(s, DICOM_TAG_PATIENT_NAME, false)); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
296 ASSERT_EQ("42", s); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
297 ASSERT_TRUE(m.CopyToString(s, DICOM_TAG_PATIENT_NAME, true)); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
298 ASSERT_EQ("42", s); |
cad393b41bc3
handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2410
diff
changeset
|
299 |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
300 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
301 // 2**31 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
302 m.SetValue(DICOM_TAG_PATIENT_NAME, "2147483648", false); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
303 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
304 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
305 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
306 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
307 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
308 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
309 ASSERT_FLOAT_EQ(2147483648.0f, f); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
310 ASSERT_DOUBLE_EQ(2147483648.0, d); |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2412
diff
changeset
|
311 ASSERT_EQ(2147483648ll, j); |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
312 ASSERT_EQ(2147483648u, k); |
2418 | 313 ASSERT_EQ(2147483648ull, l); |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
314 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
315 // 2**32-1 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
316 m.SetValue(DICOM_TAG_PATIENT_NAME, "4294967295", false); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
317 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
318 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
319 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
320 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
321 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
322 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
323 ASSERT_FLOAT_EQ(4294967295.0f, f); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
324 ASSERT_DOUBLE_EQ(4294967295.0, d); |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2412
diff
changeset
|
325 ASSERT_EQ(4294967295ll, j); |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
326 ASSERT_EQ(4294967295u, k); |
2418 | 327 ASSERT_EQ(4294967295ull, l); |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
328 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
329 // 2**32 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
330 m.SetValue(DICOM_TAG_PATIENT_NAME, "4294967296", false); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
331 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
332 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
333 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
334 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
335 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
336 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
337 ASSERT_FLOAT_EQ(4294967296.0f, f); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
338 ASSERT_DOUBLE_EQ(4294967296.0, d); |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2412
diff
changeset
|
339 ASSERT_EQ(4294967296ll, j); |
2418 | 340 ASSERT_EQ(4294967296ull, l); |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
341 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
342 m.SetValue(DICOM_TAG_PATIENT_NAME, "-1", false); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
343 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
344 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
345 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
346 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
347 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
348 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
349 ASSERT_FLOAT_EQ(-1.0f, f); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
350 ASSERT_DOUBLE_EQ(-1.0, d); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
351 ASSERT_EQ(-1, i); |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2412
diff
changeset
|
352 ASSERT_EQ(-1ll, j); |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
353 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
354 // -2**31 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
355 m.SetValue(DICOM_TAG_PATIENT_NAME, "-2147483648", false); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
356 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
357 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
358 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
359 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
360 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
361 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
362 ASSERT_FLOAT_EQ(-2147483648.0f, f); |
2829 | 363 ASSERT_DOUBLE_EQ(-2147483648.0, d); |
364 ASSERT_EQ(static_cast<int32_t>(-2147483648ll), i); | |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2412
diff
changeset
|
365 ASSERT_EQ(-2147483648ll, j); |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
366 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
367 // -2**31 - 1 |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
368 m.SetValue(DICOM_TAG_PATIENT_NAME, "-2147483649", false); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
369 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
370 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
371 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
372 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
373 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
374 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l)); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
375 ASSERT_FLOAT_EQ(-2147483649.0f, f); |
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
376 ASSERT_DOUBLE_EQ(-2147483649.0, d); |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2412
diff
changeset
|
377 ASSERT_EQ(-2147483649ll, j); |
2410
3590c936e56f
parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
378 } |
2863
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
379 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
380 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
381 TEST(DicomMap, Serialize) |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
382 { |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
383 Json::Value s; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
384 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
385 { |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
386 DicomMap m; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
387 m.SetValue(DICOM_TAG_PATIENT_NAME, "Hello", false); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
388 m.SetValue(DICOM_TAG_STUDY_DESCRIPTION, "Binary", true); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
389 m.SetNullValue(DICOM_TAG_SERIES_DESCRIPTION); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
390 m.Serialize(s); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
391 } |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
392 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
393 { |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
394 DicomMap m; |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
395 m.Unserialize(s); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
396 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
397 const DicomValue* v = m.TestAndGetValue(DICOM_TAG_ACCESSION_NUMBER); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
398 ASSERT_TRUE(v == NULL); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
399 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
400 v = m.TestAndGetValue(DICOM_TAG_PATIENT_NAME); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
401 ASSERT_TRUE(v != NULL); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
402 ASSERT_FALSE(v->IsNull()); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
403 ASSERT_FALSE(v->IsBinary()); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
404 ASSERT_EQ("Hello", v->GetContent()); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
405 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
406 v = m.TestAndGetValue(DICOM_TAG_STUDY_DESCRIPTION); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
407 ASSERT_TRUE(v != NULL); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
408 ASSERT_FALSE(v->IsNull()); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
409 ASSERT_TRUE(v->IsBinary()); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
410 ASSERT_EQ("Binary", v->GetContent()); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
411 |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
412 v = m.TestAndGetValue(DICOM_TAG_SERIES_DESCRIPTION); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
413 ASSERT_TRUE(v != NULL); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
414 ASSERT_TRUE(v->IsNull()); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
415 ASSERT_FALSE(v->IsBinary()); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
416 ASSERT_THROW(v->GetContent(), OrthancException); |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
417 } |
da12ba232119
serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2829
diff
changeset
|
418 } |
3005
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
419 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
420 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
421 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
422 TEST(DicomMap, DicomAsJson) |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
423 { |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
424 // This is a Latin-1 test string: "crane" with a circumflex accent |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
425 const unsigned char raw[] = { 0x63, 0x72, 0xe2, 0x6e, 0x65 }; |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
426 std::string latin1((char*) &raw[0], sizeof(raw) / sizeof(char)); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
427 |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3212
diff
changeset
|
428 std::string utf8 = Toolbox::ConvertToUtf8(latin1, Encoding_Latin1, false); |
3005
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
429 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
430 ParsedDicomFile dicom(false); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
431 dicom.SetEncoding(Encoding_Latin1); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
432 dicom.ReplacePlainString(DICOM_TAG_PATIENT_NAME, "Hello"); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
433 dicom.ReplacePlainString(DICOM_TAG_STUDY_DESCRIPTION, utf8); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
434 dicom.ReplacePlainString(DICOM_TAG_SERIES_DESCRIPTION, std::string(ORTHANC_MAXIMUM_TAG_LENGTH, 'a')); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
435 dicom.ReplacePlainString(DICOM_TAG_MANUFACTURER, std::string(ORTHANC_MAXIMUM_TAG_LENGTH + 1, 'a')); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
436 dicom.ReplacePlainString(DICOM_TAG_PIXEL_DATA, "binary"); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
437 dicom.ReplacePlainString(DICOM_TAG_ROWS, "512"); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
438 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
439 DcmDataset& dataset = *dicom.GetDcmtkObject().getDataset(); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
440 dataset.insertEmptyElement(DCM_StudyID, OFFalse); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
441 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
442 { |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
443 std::auto_ptr<DcmSequenceOfItems> sequence(new DcmSequenceOfItems(DCM_ReferencedSeriesSequence)); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
444 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
445 { |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
446 std::auto_ptr<DcmItem> item(new DcmItem); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
447 item->putAndInsertString(DCM_ReferencedSOPInstanceUID, "nope", OFFalse); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
448 ASSERT_TRUE(sequence->insert(item.release(), false, false).good()); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
449 } |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
450 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
451 ASSERT_TRUE(dataset.insert(sequence.release(), false, false).good()); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
452 } |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
453 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
454 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
455 // Check re-encoding |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
456 DcmElement* element = NULL; |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
457 ASSERT_TRUE(dataset.findAndGetElement(DCM_StudyDescription, element).good() && |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
458 element != NULL); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
459 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
460 char* c = NULL; |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
461 ASSERT_TRUE(element != NULL && |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
462 element->isLeaf() && |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
463 element->isaString() && |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
464 element->getString(c).good()); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
465 ASSERT_EQ(0, memcmp(c, raw, latin1.length())); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
466 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
467 ASSERT_TRUE(dataset.findAndGetElement(DCM_Rows, element).good() && |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
468 element != NULL && |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
469 element->getTag().getEVR() == EVR_US); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
470 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
471 DicomInstanceToStore toStore; |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
472 toStore.SetParsedDicomFile(dicom); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
473 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
474 DicomMap m; |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
475 m.FromDicomAsJson(toStore.GetJson()); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
476 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
477 ASSERT_EQ("ISO_IR 100", m.GetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET).GetContent()); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
478 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
479 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).IsBinary()); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
480 ASSERT_EQ("Hello", m.GetValue(DICOM_TAG_PATIENT_NAME).GetContent()); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
481 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
482 ASSERT_FALSE(m.GetValue(DICOM_TAG_STUDY_DESCRIPTION).IsBinary()); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
483 ASSERT_EQ(utf8, m.GetValue(DICOM_TAG_STUDY_DESCRIPTION).GetContent()); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
484 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
485 ASSERT_FALSE(m.HasTag(DICOM_TAG_MANUFACTURER)); // Too long |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
486 ASSERT_FALSE(m.HasTag(DICOM_TAG_PIXEL_DATA)); // Pixel data |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
487 ASSERT_FALSE(m.HasTag(DICOM_TAG_REFERENCED_SERIES_SEQUENCE)); // Sequence |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
488 ASSERT_EQ(DICOM_TAG_REFERENCED_SERIES_SEQUENCE.GetGroup(), DCM_ReferencedSeriesSequence.getGroup()); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
489 ASSERT_EQ(DICOM_TAG_REFERENCED_SERIES_SEQUENCE.GetElement(), DCM_ReferencedSeriesSequence.getElement()); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
490 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
491 ASSERT_TRUE(m.HasTag(DICOM_TAG_SERIES_DESCRIPTION)); // Maximum length |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
492 ASSERT_FALSE(m.GetValue(DICOM_TAG_SERIES_DESCRIPTION).IsBinary()); |
3040
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3015
diff
changeset
|
493 ASSERT_EQ(ORTHANC_MAXIMUM_TAG_LENGTH, |
07ab06af90ed
preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3015
diff
changeset
|
494 static_cast<int>(m.GetValue(DICOM_TAG_SERIES_DESCRIPTION).GetContent().length())); |
3005
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
495 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
496 ASSERT_FALSE(m.GetValue(DICOM_TAG_ROWS).IsBinary()); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
497 ASSERT_EQ("512", m.GetValue(DICOM_TAG_ROWS).GetContent()); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
498 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
499 ASSERT_FALSE(m.GetValue(DICOM_TAG_STUDY_ID).IsNull()); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
500 ASSERT_FALSE(m.GetValue(DICOM_TAG_STUDY_ID).IsBinary()); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
501 ASSERT_EQ("", m.GetValue(DICOM_TAG_STUDY_ID).GetContent()); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
502 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
503 DicomArray a(m); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
504 ASSERT_EQ(6u, a.GetSize()); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
505 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
506 |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
507 //dicom.SaveToFile("/tmp/test.dcm"); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
508 //std::cout << toStore.GetJson() << std::endl; |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
509 //a.Print(stdout); |
8265a6b56100
DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2863
diff
changeset
|
510 } |
3006
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
511 |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
512 |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
513 |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
514 TEST(DicomMap, ExtractMainDicomTags) |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
515 { |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
516 DicomMap b; |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
517 b.SetValue(DICOM_TAG_PATIENT_NAME, "E", false); |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3006
diff
changeset
|
518 ASSERT_TRUE(b.HasOnlyMainDicomTags()); |
3006
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
519 |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
520 { |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
521 DicomMap a; |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
522 a.SetValue(DICOM_TAG_PATIENT_NAME, "A", false); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
523 a.SetValue(DICOM_TAG_STUDY_DESCRIPTION, "B", false); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
524 a.SetValue(DICOM_TAG_SERIES_DESCRIPTION, "C", false); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
525 a.SetValue(DICOM_TAG_NUMBER_OF_FRAMES, "D", false); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
526 a.SetValue(DICOM_TAG_SLICE_THICKNESS, "F", false); |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3006
diff
changeset
|
527 ASSERT_FALSE(a.HasOnlyMainDicomTags()); |
3006
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
528 b.ExtractMainDicomTags(a); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
529 } |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
530 |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
531 ASSERT_EQ(4u, b.GetSize()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
532 ASSERT_EQ("A", b.GetValue(DICOM_TAG_PATIENT_NAME).GetContent()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
533 ASSERT_EQ("B", b.GetValue(DICOM_TAG_STUDY_DESCRIPTION).GetContent()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
534 ASSERT_EQ("C", b.GetValue(DICOM_TAG_SERIES_DESCRIPTION).GetContent()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
535 ASSERT_EQ("D", b.GetValue(DICOM_TAG_NUMBER_OF_FRAMES).GetContent()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
536 ASSERT_FALSE(b.HasTag(DICOM_TAG_SLICE_THICKNESS)); |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3006
diff
changeset
|
537 ASSERT_TRUE(b.HasOnlyMainDicomTags()); |
3006
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
538 |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
539 b.SetValue(DICOM_TAG_PATIENT_NAME, "G", false); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
540 |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
541 { |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
542 DicomMap a; |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
543 a.SetValue(DICOM_TAG_PATIENT_NAME, "A", false); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
544 a.SetValue(DICOM_TAG_SLICE_THICKNESS, "F", false); |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3006
diff
changeset
|
545 ASSERT_FALSE(a.HasOnlyMainDicomTags()); |
3006
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
546 b.Merge(a); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
547 } |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
548 |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
549 ASSERT_EQ(5u, b.GetSize()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
550 ASSERT_EQ("G", b.GetValue(DICOM_TAG_PATIENT_NAME).GetContent()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
551 ASSERT_EQ("B", b.GetValue(DICOM_TAG_STUDY_DESCRIPTION).GetContent()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
552 ASSERT_EQ("C", b.GetValue(DICOM_TAG_SERIES_DESCRIPTION).GetContent()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
553 ASSERT_EQ("D", b.GetValue(DICOM_TAG_NUMBER_OF_FRAMES).GetContent()); |
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
554 ASSERT_EQ("F", b.GetValue(DICOM_TAG_SLICE_THICKNESS).GetContent()); |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3006
diff
changeset
|
555 ASSERT_FALSE(b.HasOnlyMainDicomTags()); |
3006
0e1755e5efd0
DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3005
diff
changeset
|
556 } |
3187
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
557 |
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
558 |
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
559 |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
560 TEST(DicomWebJson, Multiplicity) |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
561 { |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
562 // http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_F.2.4.html |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
563 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
564 ParsedDicomFile dicom(false); |
3201
b69fe409cb4d
dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3200
diff
changeset
|
565 dicom.ReplacePlainString(DICOM_TAG_PATIENT_NAME, "SB1^SB2^SB3^SB4^SB5"); |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
566 dicom.ReplacePlainString(DICOM_TAG_IMAGE_ORIENTATION_PATIENT, "1\\2.3\\4"); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
567 dicom.ReplacePlainString(DICOM_TAG_IMAGE_POSITION_PATIENT, ""); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
568 |
3200
1f4a2c58e7fa
set encoding to UTF-8, IBinaryFormatter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3199
diff
changeset
|
569 Orthanc::DicomWebJsonVisitor visitor; |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
570 dicom.Apply(visitor); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
571 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
572 { |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
573 const Json::Value& tag = visitor.GetResult() ["00200037"]; |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
574 const Json::Value& value = tag["Value"]; |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
575 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
576 ASSERT_EQ(EnumerationToString(ValueRepresentation_DecimalString), tag["vr"].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
577 ASSERT_EQ(2u, tag.getMemberNames().size()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
578 ASSERT_EQ(3u, value.size()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
579 ASSERT_EQ(Json::realValue, value[1].type()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
580 ASSERT_FLOAT_EQ(1.0f, value[0].asFloat()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
581 ASSERT_FLOAT_EQ(2.3f, value[1].asFloat()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
582 ASSERT_FLOAT_EQ(4.0f, value[2].asFloat()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
583 } |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
584 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
585 { |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
586 const Json::Value& tag = visitor.GetResult() ["00200032"]; |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
587 ASSERT_EQ(EnumerationToString(ValueRepresentation_DecimalString), tag["vr"].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
588 ASSERT_EQ(1u, tag.getMemberNames().size()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
589 } |
3201
b69fe409cb4d
dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3200
diff
changeset
|
590 |
3203
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3202
diff
changeset
|
591 std::string xml; |
3201
b69fe409cb4d
dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3200
diff
changeset
|
592 visitor.FormatXml(xml); |
3187
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
593 } |
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
594 |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
595 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
596 TEST(DicomWebJson, NullValue) |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
597 { |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
598 // http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_F.2.5.html |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
599 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
600 ParsedDicomFile dicom(false); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
601 dicom.ReplacePlainString(DICOM_TAG_IMAGE_ORIENTATION_PATIENT, "1.5\\\\\\2.5"); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
602 |
3200
1f4a2c58e7fa
set encoding to UTF-8, IBinaryFormatter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3199
diff
changeset
|
603 Orthanc::DicomWebJsonVisitor visitor; |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
604 dicom.Apply(visitor); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
605 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
606 { |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
607 const Json::Value& tag = visitor.GetResult() ["00200037"]; |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
608 const Json::Value& value = tag["Value"]; |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
609 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
610 ASSERT_EQ(EnumerationToString(ValueRepresentation_DecimalString), tag["vr"].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
611 ASSERT_EQ(2u, tag.getMemberNames().size()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
612 ASSERT_EQ(4u, value.size()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
613 ASSERT_EQ(Json::realValue, value[0].type()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
614 ASSERT_EQ(Json::nullValue, value[1].type()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
615 ASSERT_EQ(Json::nullValue, value[2].type()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
616 ASSERT_EQ(Json::realValue, value[3].type()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
617 ASSERT_FLOAT_EQ(1.5f, value[0].asFloat()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
618 ASSERT_FLOAT_EQ(2.5f, value[3].asFloat()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
619 } |
3201
b69fe409cb4d
dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3200
diff
changeset
|
620 |
3203
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3202
diff
changeset
|
621 std::string xml; |
3201
b69fe409cb4d
dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3200
diff
changeset
|
622 visitor.FormatXml(xml); |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
623 } |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
624 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
625 |
3209
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
626 static void SetTagKey(ParsedDicomFile& dicom, |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
627 const DicomTag& tag, |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
628 const DicomTag& value) |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
629 { |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
630 // This function emulates a call to function |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
631 // "dicom.GetDcmtkObject().getDataset()->putAndInsertTagKey(tag, |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
632 // value)" that was not available in DCMTK 3.6.0 |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
633 |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
634 std::auto_ptr<DcmAttributeTag> element(new DcmAttributeTag(ToDcmtkBridge::Convert(tag))); |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
635 |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
636 DcmTagKey v = ToDcmtkBridge::Convert(value); |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
637 if (!element->putTagVal(v).good()) |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
638 { |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
639 throw OrthancException(ErrorCode_InternalError); |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
640 } |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
641 |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
642 dicom.GetDcmtkObject().getDataset()->insert(element.release()); |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
643 } |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
644 |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
645 |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
646 TEST(DicomWebJson, ValueRepresentation) |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
647 { |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
648 // http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_F.2.3.html |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
649 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
650 ParsedDicomFile dicom(false); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
651 dicom.ReplacePlainString(DicomTag(0x0040, 0x0241), "AE"); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
652 dicom.ReplacePlainString(DicomTag(0x0010, 0x1010), "AS"); |
3209
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
653 SetTagKey(dicom, DicomTag(0x0020, 0x9165), DicomTag(0x0010, 0x0020)); |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
654 dicom.ReplacePlainString(DicomTag(0x0008, 0x0052), "CS"); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
655 dicom.ReplacePlainString(DicomTag(0x0008, 0x0012), "DA"); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
656 dicom.ReplacePlainString(DicomTag(0x0010, 0x1020), "42"); // DS |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
657 dicom.ReplacePlainString(DicomTag(0x0008, 0x002a), "DT"); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
658 dicom.ReplacePlainString(DicomTag(0x0010, 0x9431), "43"); // FL |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
659 dicom.ReplacePlainString(DicomTag(0x0008, 0x1163), "44"); // FD |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
660 dicom.ReplacePlainString(DicomTag(0x0008, 0x1160), "45"); // IS |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
661 dicom.ReplacePlainString(DicomTag(0x0008, 0x0070), "LO"); |
3209
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
662 dicom.ReplacePlainString(DicomTag(0x0010, 0x4000), "LT"); |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
663 dicom.ReplacePlainString(DicomTag(0x0028, 0x2000), "OB"); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
664 dicom.ReplacePlainString(DicomTag(0x7fe0, 0x0009), "OD"); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
665 dicom.ReplacePlainString(DicomTag(0x0064, 0x0009), "OF"); |
3210
4a1c47e20685
fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
666 dicom.ReplacePlainString(DicomTag(0x0066, 0x0040), "46"); |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
667 ASSERT_THROW(dicom.ReplacePlainString(DicomTag(0x0028, 0x1201), "O"), OrthancException); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
668 dicom.ReplacePlainString(DicomTag(0x0028, 0x1201), "OWOW"); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
669 dicom.ReplacePlainString(DicomTag(0x0010, 0x0010), "PN"); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
670 dicom.ReplacePlainString(DicomTag(0x0008, 0x0050), "SH"); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
671 dicom.ReplacePlainString(DicomTag(0x0018, 0x6020), "-15"); // SL |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
672 dicom.ReplacePlainString(DicomTag(0x0018, 0x9219), "-16"); // SS |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
673 dicom.ReplacePlainString(DicomTag(0x0008, 0x0081), "ST"); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
674 dicom.ReplacePlainString(DicomTag(0x0008, 0x0013), "TM"); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
675 dicom.ReplacePlainString(DicomTag(0x0008, 0x0119), "UC"); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
676 dicom.ReplacePlainString(DicomTag(0x0008, 0x0016), "UI"); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
677 dicom.ReplacePlainString(DicomTag(0x0008, 0x1161), "128"); // UL |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
678 dicom.ReplacePlainString(DicomTag(0x4342, 0x1234), "UN"); // Inexistent tag |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
679 dicom.ReplacePlainString(DicomTag(0x0008, 0x0120), "UR"); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
680 dicom.ReplacePlainString(DicomTag(0x0008, 0x0301), "17"); // US |
3209
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
681 dicom.ReplacePlainString(DicomTag(0x0040, 0x0031), "UT"); |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
682 |
3200
1f4a2c58e7fa
set encoding to UTF-8, IBinaryFormatter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3199
diff
changeset
|
683 Orthanc::DicomWebJsonVisitor visitor; |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
684 dicom.Apply(visitor); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
685 |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
686 std::string s; |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
687 |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
688 ASSERT_EQ("AE", visitor.GetResult() ["00400241"]["vr"].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
689 ASSERT_EQ("AE", visitor.GetResult() ["00400241"]["Value"][0].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
690 ASSERT_EQ("AS", visitor.GetResult() ["00101010"]["vr"].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
691 ASSERT_EQ("AS", visitor.GetResult() ["00101010"]["Value"][0].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
692 ASSERT_EQ("AT", visitor.GetResult() ["00209165"]["vr"].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
693 ASSERT_EQ("00100020", visitor.GetResult() ["00209165"]["Value"][0].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
694 ASSERT_EQ("CS", visitor.GetResult() ["00080052"]["vr"].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
695 ASSERT_EQ("CS", visitor.GetResult() ["00080052"]["Value"][0].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
696 ASSERT_EQ("DA", visitor.GetResult() ["00080012"]["vr"].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
697 ASSERT_EQ("DA", visitor.GetResult() ["00080012"]["Value"][0].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
698 ASSERT_EQ("DS", visitor.GetResult() ["00101020"]["vr"].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
699 ASSERT_FLOAT_EQ(42.0f, visitor.GetResult() ["00101020"]["Value"][0].asFloat()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
700 ASSERT_EQ("DT", visitor.GetResult() ["0008002A"]["vr"].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
701 ASSERT_EQ("DT", visitor.GetResult() ["0008002A"]["Value"][0].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
702 ASSERT_EQ("FL", visitor.GetResult() ["00109431"]["vr"].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
703 ASSERT_FLOAT_EQ(43.0f, visitor.GetResult() ["00109431"]["Value"][0].asFloat()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
704 ASSERT_EQ("FD", visitor.GetResult() ["00081163"]["vr"].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
705 ASSERT_FLOAT_EQ(44.0f, visitor.GetResult() ["00081163"]["Value"][0].asFloat()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
706 ASSERT_EQ("IS", visitor.GetResult() ["00081160"]["vr"].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
707 ASSERT_FLOAT_EQ(45.0f, visitor.GetResult() ["00081160"]["Value"][0].asFloat()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
708 ASSERT_EQ("LO", visitor.GetResult() ["00080070"]["vr"].asString()); |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
709 ASSERT_EQ("LO", visitor.GetResult() ["00080070"]["Value"][0].asString()); |
3209
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
710 ASSERT_EQ("LT", visitor.GetResult() ["00104000"]["vr"].asString()); |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
711 ASSERT_EQ("LT", visitor.GetResult() ["00104000"]["Value"][0].asString()); |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
712 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
713 ASSERT_EQ("OB", visitor.GetResult() ["00282000"]["vr"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
714 Toolbox::DecodeBase64(s, visitor.GetResult() ["00282000"]["InlineBinary"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
715 ASSERT_EQ("OB", s); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
716 |
3210
4a1c47e20685
fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
717 #if DCMTK_VERSION_NUMBER >= 361 |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
718 ASSERT_EQ("OD", visitor.GetResult() ["7FE00009"]["vr"].asString()); |
3209
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
719 #else |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
720 ASSERT_EQ("UN", visitor.GetResult() ["7FE00009"]["vr"].asString()); |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
721 #endif |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
722 |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
723 Toolbox::DecodeBase64(s, visitor.GetResult() ["7FE00009"]["InlineBinary"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
724 ASSERT_EQ("OD", s); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
725 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
726 ASSERT_EQ("OF", visitor.GetResult() ["00640009"]["vr"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
727 Toolbox::DecodeBase64(s, visitor.GetResult() ["00640009"]["InlineBinary"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
728 ASSERT_EQ("OF", s); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
729 |
3210
4a1c47e20685
fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
730 #if DCMTK_VERSION_NUMBER < 361 |
3209
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
731 ASSERT_EQ("UN", visitor.GetResult() ["00660040"]["vr"].asString()); |
3210
4a1c47e20685
fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
732 Toolbox::DecodeBase64(s, visitor.GetResult() ["00660040"]["InlineBinary"].asString()); |
3211 | 733 ASSERT_EQ("46", s); |
3210
4a1c47e20685
fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
734 #elif DCMTK_VERSION_NUMBER == 361 |
4a1c47e20685
fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
735 ASSERT_EQ("UL", visitor.GetResult() ["00660040"]["vr"].asString()); |
4a1c47e20685
fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
736 ASSERT_EQ(46, visitor.GetResult() ["00660040"]["Value"][0].asInt()); |
4a1c47e20685
fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
737 #elif DCMTK_VERSION_NUMBER > 361 |
4a1c47e20685
fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
738 ASSERT_EQ("OL", visitor.GetResult() ["00660040"]["vr"].asString()); |
4a1c47e20685
fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
739 Toolbox::DecodeBase64(s, visitor.GetResult() ["00660040"]["InlineBinary"].asString()); |
4a1c47e20685
fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
740 ASSERT_EQ("46", s); |
3209
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
741 #endif |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
742 |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
743 ASSERT_EQ("OW", visitor.GetResult() ["00281201"]["vr"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
744 Toolbox::DecodeBase64(s, visitor.GetResult() ["00281201"]["InlineBinary"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
745 ASSERT_EQ("OWOW", s); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
746 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
747 ASSERT_EQ("PN", visitor.GetResult() ["00100010"]["vr"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
748 ASSERT_EQ("PN", visitor.GetResult() ["00100010"]["Value"][0]["Alphabetic"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
749 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
750 ASSERT_EQ("SH", visitor.GetResult() ["00080050"]["vr"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
751 ASSERT_EQ("SH", visitor.GetResult() ["00080050"]["Value"][0].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
752 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
753 ASSERT_EQ("SL", visitor.GetResult() ["00186020"]["vr"].asString()); |
3210
4a1c47e20685
fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
754 ASSERT_EQ(-15, visitor.GetResult() ["00186020"]["Value"][0].asInt()); |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
755 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
756 ASSERT_EQ("SS", visitor.GetResult() ["00189219"]["vr"].asString()); |
3210
4a1c47e20685
fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3209
diff
changeset
|
757 ASSERT_EQ(-16, visitor.GetResult() ["00189219"]["Value"][0].asInt()); |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
758 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
759 ASSERT_EQ("ST", visitor.GetResult() ["00080081"]["vr"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
760 ASSERT_EQ("ST", visitor.GetResult() ["00080081"]["Value"][0].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
761 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
762 ASSERT_EQ("TM", visitor.GetResult() ["00080013"]["vr"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
763 ASSERT_EQ("TM", visitor.GetResult() ["00080013"]["Value"][0].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
764 |
3209
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
765 #if DCMTK_VERSION_NUMBER >= 361 |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
766 ASSERT_EQ("UC", visitor.GetResult() ["00080119"]["vr"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
767 ASSERT_EQ("UC", visitor.GetResult() ["00080119"]["Value"][0].asString()); |
3209
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
768 #else |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
769 ASSERT_EQ("UN", visitor.GetResult() ["00080119"]["vr"].asString()); |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
770 Toolbox::DecodeBase64(s, visitor.GetResult() ["00080119"]["InlineBinary"].asString()); |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
771 ASSERT_EQ("UC", s); |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
772 #endif |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
773 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
774 ASSERT_EQ("UI", visitor.GetResult() ["00080016"]["vr"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
775 ASSERT_EQ("UI", visitor.GetResult() ["00080016"]["Value"][0].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
776 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
777 ASSERT_EQ("UL", visitor.GetResult() ["00081161"]["vr"].asString()); |
3212 | 778 ASSERT_EQ(128u, visitor.GetResult() ["00081161"]["Value"][0].asUInt()); |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
779 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
780 ASSERT_EQ("UN", visitor.GetResult() ["43421234"]["vr"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
781 Toolbox::DecodeBase64(s, visitor.GetResult() ["43421234"]["InlineBinary"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
782 ASSERT_EQ("UN", s); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
783 |
3209
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
784 #if DCMTK_VERSION_NUMBER >= 361 |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
785 ASSERT_EQ("UR", visitor.GetResult() ["00080120"]["vr"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
786 ASSERT_EQ("UR", visitor.GetResult() ["00080120"]["Value"][0].asString()); |
3209
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
787 #else |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
788 ASSERT_EQ("UN", visitor.GetResult() ["00080120"]["vr"].asString()); |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
789 Toolbox::DecodeBase64(s, visitor.GetResult() ["00080120"]["InlineBinary"].asString()); |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
790 ASSERT_EQ("UR", s); |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
791 #endif |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
792 |
3209
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
793 #if DCMTK_VERSION_NUMBER >= 361 |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
794 ASSERT_EQ("US", visitor.GetResult() ["00080301"]["vr"].asString()); |
3212 | 795 ASSERT_EQ(17u, visitor.GetResult() ["00080301"]["Value"][0].asUInt()); |
3209
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
796 #else |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
797 ASSERT_EQ("UN", visitor.GetResult() ["00080301"]["vr"].asString()); |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
798 Toolbox::DecodeBase64(s, visitor.GetResult() ["00080301"]["InlineBinary"].asString()); |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
799 ASSERT_EQ("17", s); |
f6374c36a671
documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3203
diff
changeset
|
800 #endif |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
801 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
802 ASSERT_EQ("UT", visitor.GetResult() ["00400031"]["vr"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
803 ASSERT_EQ("UT", visitor.GetResult() ["00400031"]["Value"][0].asString()); |
3201
b69fe409cb4d
dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3200
diff
changeset
|
804 |
3203
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3202
diff
changeset
|
805 std::string xml; |
3201
b69fe409cb4d
dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3200
diff
changeset
|
806 visitor.FormatXml(xml); |
3198
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
807 } |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
808 |
7724ed267b5c
unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3197
diff
changeset
|
809 |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
810 TEST(DicomWebJson, Sequence) |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
811 { |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
812 ParsedDicomFile dicom(false); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
813 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
814 { |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
815 std::auto_ptr<DcmSequenceOfItems> sequence(new DcmSequenceOfItems(DCM_ReferencedSeriesSequence)); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
816 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
817 for (unsigned int i = 0; i < 3; i++) |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
818 { |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
819 std::auto_ptr<DcmItem> item(new DcmItem); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
820 std::string s = "item" + boost::lexical_cast<std::string>(i); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
821 item->putAndInsertString(DCM_ReferencedSOPInstanceUID, s.c_str(), OFFalse); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
822 ASSERT_TRUE(sequence->insert(item.release(), false, false).good()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
823 } |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
824 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
825 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->insert(sequence.release(), false, false).good()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
826 } |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
827 |
3200
1f4a2c58e7fa
set encoding to UTF-8, IBinaryFormatter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3199
diff
changeset
|
828 Orthanc::DicomWebJsonVisitor visitor; |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
829 dicom.Apply(visitor); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
830 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
831 ASSERT_EQ("SQ", visitor.GetResult() ["00081115"]["vr"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
832 ASSERT_EQ(3u, visitor.GetResult() ["00081115"]["Value"].size()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
833 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
834 std::set<std::string> items; |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
835 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
836 for (Json::Value::ArrayIndex i = 0; i < 3; i++) |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
837 { |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
838 ASSERT_EQ(1u, visitor.GetResult() ["00081115"]["Value"][i].size()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
839 ASSERT_EQ(1u, visitor.GetResult() ["00081115"]["Value"][i]["00081155"]["Value"].size()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
840 ASSERT_EQ("UI", visitor.GetResult() ["00081115"]["Value"][i]["00081155"]["vr"].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
841 items.insert(visitor.GetResult() ["00081115"]["Value"][i]["00081155"]["Value"][0].asString()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
842 } |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
843 |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
844 ASSERT_EQ(3u, items.size()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
845 ASSERT_TRUE(items.find("item0") != items.end()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
846 ASSERT_TRUE(items.find("item1") != items.end()); |
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
847 ASSERT_TRUE(items.find("item2") != items.end()); |
3201
b69fe409cb4d
dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3200
diff
changeset
|
848 |
3203
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3202
diff
changeset
|
849 std::string xml; |
3201
b69fe409cb4d
dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3200
diff
changeset
|
850 visitor.FormatXml(xml); |
3199
9316f341e40f
unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3198
diff
changeset
|
851 } |