annotate UnitTestsSources/DicomMapTests.cpp @ 3651:46cb00e4adbb

DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 05 Feb 2020 13:22:02 +0100
parents 94f4a18a79cc
children 4922bdd046dd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1850
diff changeset
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
3640
94f4a18a79cc upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3581
diff changeset
5 * Copyright (C) 2017-2020 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
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "gtest/gtest.h"
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../Core/OrthancException.h"
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3201
diff changeset
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
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 using namespace Orthanc;
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 TEST(DicomMap, MainTags)
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 {
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID, ResourceType_Patient));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 ASSERT_FALSE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID, ResourceType_Study));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_STUDY_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_ACCESSION_NUMBER));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_SERIES_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_SOP_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 std::set<DicomTag> s;
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 DicomMap::GetMainDicomTags(s);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_STUDY_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_ACCESSION_NUMBER));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SERIES_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SOP_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 DicomMap::GetMainDicomTags(s, ResourceType_Patient);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_STUDY_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 DicomMap::GetMainDicomTags(s, ResourceType_Study);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_STUDY_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_ACCESSION_NUMBER));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 DicomMap::GetMainDicomTags(s, ResourceType_Series);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SERIES_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 DicomMap::GetMainDicomTags(s, ResourceType_Instance);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SOP_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 }
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 TEST(DicomMap, Tags)
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 {
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
92 std::set<DicomTag> s;
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
93
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 DicomMap m;
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
95 m.GetTags(s);
1492
9f66a12eb8fc fix warnings for gcc 5
jodogne
parents: 1368
diff changeset
96 ASSERT_EQ(0u, s.size());
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
97
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 ASSERT_FALSE(m.HasTag(DICOM_TAG_PATIENT_NAME));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 ASSERT_TRUE(m.HasTag(DICOM_TAG_PATIENT_NAME));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 ASSERT_TRUE(m.HasTag(0x0010, 0x0010));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
104 m.GetTags(s);
1492
9f66a12eb8fc fix warnings for gcc 5
jodogne
parents: 1368
diff changeset
105 ASSERT_EQ(1u, s.size());
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
106 ASSERT_EQ(DICOM_TAG_PATIENT_NAME, *s.begin());
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
107
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
114 m.GetTags(s);
1492
9f66a12eb8fc fix warnings for gcc 5
jodogne
parents: 1368
diff changeset
115 ASSERT_EQ(2u, s.size());
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
116
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 m.Remove(DICOM_TAG_PATIENT_ID);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 ASSERT_THROW(m.GetValue(0x0010, 0x0020), OrthancException);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
120 m.GetTags(s);
1492
9f66a12eb8fc fix warnings for gcc 5
jodogne
parents: 1368
diff changeset
121 ASSERT_EQ(1u, s.size());
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
122 ASSERT_EQ(DICOM_TAG_PATIENT_NAME, *s.begin());
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
123
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 ASSERT_THROW(mm->GetValue(DICOM_TAG_PATIENT_ID), OrthancException);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
132 DicomValue v;
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 ASSERT_TRUE(v.IsNull());
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 }
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 TEST(DicomMap, FindTemplates)
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 {
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 DicomMap m;
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 DicomMap::SetupFindPatientTemplate(m);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 ASSERT_TRUE(m.HasTag(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 DicomMap::SetupFindStudyTemplate(m);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 ASSERT_TRUE(m.HasTag(DICOM_TAG_STUDY_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 ASSERT_TRUE(m.HasTag(DICOM_TAG_ACCESSION_NUMBER));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 DicomMap::SetupFindSeriesTemplate(m);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 ASSERT_TRUE(m.HasTag(DICOM_TAG_SERIES_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 DicomMap::SetupFindInstanceTemplate(m);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 ASSERT_TRUE(m.HasTag(DICOM_TAG_SOP_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
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
7b6925b0890d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
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
d2268c7a7ede fix unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1492
diff changeset
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;
3519
fc26659493b6 added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents: 3497
diff changeset
242 unsigned int ui;
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
243 std::string s;
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
244
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
245 m.SetValue(DICOM_TAG_PATIENT_NAME, " ", false); // Empty value
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
246 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
247 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
248 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
249 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
250 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
251 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
252
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
253 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
254 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
255 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
256 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
257 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
258 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
259 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
260
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
261 ASSERT_FALSE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false));
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
262 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, true));
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
263 ASSERT_EQ("0", s);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
264
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
265
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
266 // 2**31-1
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
267 m.SetValue(DICOM_TAG_PATIENT_NAME, "2147483647", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
268 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
269 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
270 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
271 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
272 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
273 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
274 ASSERT_FLOAT_EQ(2147483647.0f, f);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
275 ASSERT_DOUBLE_EQ(2147483647.0, d);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
276 ASSERT_EQ(2147483647, i);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
277 ASSERT_EQ(2147483647ll, j);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
278 ASSERT_EQ(2147483647u, k);
2418
abc275c0a44d fix msvc 2008
jodogne
parents: 2416
diff changeset
279 ASSERT_EQ(2147483647ull, l);
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
280
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
281 // Test shortcuts
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
282 m.SetValue(DICOM_TAG_PATIENT_NAME, "42", false);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
283 ASSERT_TRUE(m.ParseFloat(f, DICOM_TAG_PATIENT_NAME));
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
284 ASSERT_TRUE(m.ParseDouble(d, DICOM_TAG_PATIENT_NAME));
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
285 ASSERT_TRUE(m.ParseInteger32(i, DICOM_TAG_PATIENT_NAME));
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
286 ASSERT_TRUE(m.ParseInteger64(j, DICOM_TAG_PATIENT_NAME));
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
287 ASSERT_TRUE(m.ParseUnsignedInteger32(k, DICOM_TAG_PATIENT_NAME));
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
288 ASSERT_TRUE(m.ParseUnsignedInteger64(l, DICOM_TAG_PATIENT_NAME));
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
289 ASSERT_FLOAT_EQ(42.0f, f);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
290 ASSERT_DOUBLE_EQ(42.0, d);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
291 ASSERT_EQ(42, i);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
292 ASSERT_EQ(42ll, j);
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
293 ASSERT_EQ(42u, k);
2418
abc275c0a44d fix msvc 2008
jodogne
parents: 2416
diff changeset
294 ASSERT_EQ(42ull, l);
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
295
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
296 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false));
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
297 ASSERT_EQ("42", s);
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
298 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, true));
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
299 ASSERT_EQ("42", s);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
300
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
301
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
302 // 2**31
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
303 m.SetValue(DICOM_TAG_PATIENT_NAME, "2147483648", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
304 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
305 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
306 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
307 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
308 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
309 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
310 ASSERT_FLOAT_EQ(2147483648.0f, f);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
311 ASSERT_DOUBLE_EQ(2147483648.0, d);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
312 ASSERT_EQ(2147483648ll, j);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
313 ASSERT_EQ(2147483648u, k);
2418
abc275c0a44d fix msvc 2008
jodogne
parents: 2416
diff changeset
314 ASSERT_EQ(2147483648ull, l);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
315
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
316 // 2**32-1
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
317 m.SetValue(DICOM_TAG_PATIENT_NAME, "4294967295", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
318 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
319 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
320 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
321 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
322 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
323 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
324 ASSERT_FLOAT_EQ(4294967295.0f, f);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
325 ASSERT_DOUBLE_EQ(4294967295.0, d);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
326 ASSERT_EQ(4294967295ll, j);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
327 ASSERT_EQ(4294967295u, k);
2418
abc275c0a44d fix msvc 2008
jodogne
parents: 2416
diff changeset
328 ASSERT_EQ(4294967295ull, l);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
329
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
330 // 2**32
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
331 m.SetValue(DICOM_TAG_PATIENT_NAME, "4294967296", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
332 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
333 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
334 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
335 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
336 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
337 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
338 ASSERT_FLOAT_EQ(4294967296.0f, f);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
339 ASSERT_DOUBLE_EQ(4294967296.0, d);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
340 ASSERT_EQ(4294967296ll, j);
2418
abc275c0a44d fix msvc 2008
jodogne
parents: 2416
diff changeset
341 ASSERT_EQ(4294967296ull, l);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
342
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
343 m.SetValue(DICOM_TAG_PATIENT_NAME, "-1", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
344 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
345 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
346 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
347 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
348 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
349 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
350 ASSERT_FLOAT_EQ(-1.0f, f);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
351 ASSERT_DOUBLE_EQ(-1.0, d);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
352 ASSERT_EQ(-1, i);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
353 ASSERT_EQ(-1ll, j);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
354
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
355 // -2**31
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
356 m.SetValue(DICOM_TAG_PATIENT_NAME, "-2147483648", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
357 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
358 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
359 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
360 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
361 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
362 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
363 ASSERT_FLOAT_EQ(-2147483648.0f, f);
2829
61fdb06e389a fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
364 ASSERT_DOUBLE_EQ(-2147483648.0, d);
61fdb06e389a fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
365 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
366 ASSERT_EQ(-2147483648ll, j);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
367
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
368 // -2**31 - 1
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
369 m.SetValue(DICOM_TAG_PATIENT_NAME, "-2147483649", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
370 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
371 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
372 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
373 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
374 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
375 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
376 ASSERT_FLOAT_EQ(-2147483649.0f, f);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
377 ASSERT_DOUBLE_EQ(-2147483649.0, d);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
378 ASSERT_EQ(-2147483649ll, j);
3519
fc26659493b6 added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents: 3497
diff changeset
379
fc26659493b6 added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents: 3497
diff changeset
380
fc26659493b6 added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents: 3497
diff changeset
381 // "800\0" in US COLMUNS tag
fc26659493b6 added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents: 3497
diff changeset
382 m.SetValue(DICOM_TAG_COLUMNS, "800\0", false);
fc26659493b6 added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents: 3497
diff changeset
383 ASSERT_TRUE(m.GetValue(DICOM_TAG_COLUMNS).ParseFirstUnsignedInteger(ui));
3541
4beabcea3a5c Orthanc-1.5.8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3520
diff changeset
384 ASSERT_EQ(800u, ui);
3519
fc26659493b6 added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents: 3497
diff changeset
385 m.SetValue(DICOM_TAG_COLUMNS, "800", false);
fc26659493b6 added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents: 3497
diff changeset
386 ASSERT_TRUE(m.GetValue(DICOM_TAG_COLUMNS).ParseFirstUnsignedInteger(ui));
3541
4beabcea3a5c Orthanc-1.5.8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3520
diff changeset
387 ASSERT_EQ(800u, ui);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
388 }
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
389
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
390
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
391 TEST(DicomMap, Serialize)
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 Json::Value s;
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
394
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
395 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
396 DicomMap m;
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
397 m.SetValue(DICOM_TAG_PATIENT_NAME, "Hello", false);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
398 m.SetValue(DICOM_TAG_STUDY_DESCRIPTION, "Binary", true);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
399 m.SetNullValue(DICOM_TAG_SERIES_DESCRIPTION);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
400 m.Serialize(s);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
401 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
402
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
403 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
404 DicomMap m;
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
405 m.Unserialize(s);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
406
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
407 const DicomValue* v = m.TestAndGetValue(DICOM_TAG_ACCESSION_NUMBER);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
408 ASSERT_TRUE(v == NULL);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
409
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
410 v = m.TestAndGetValue(DICOM_TAG_PATIENT_NAME);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
411 ASSERT_TRUE(v != NULL);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
412 ASSERT_FALSE(v->IsNull());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
413 ASSERT_FALSE(v->IsBinary());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
414 ASSERT_EQ("Hello", v->GetContent());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
415
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
416 v = m.TestAndGetValue(DICOM_TAG_STUDY_DESCRIPTION);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
417 ASSERT_TRUE(v != NULL);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
418 ASSERT_FALSE(v->IsNull());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
419 ASSERT_TRUE(v->IsBinary());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
420 ASSERT_EQ("Binary", v->GetContent());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
421
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
422 v = m.TestAndGetValue(DICOM_TAG_SERIES_DESCRIPTION);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
423 ASSERT_TRUE(v != NULL);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
424 ASSERT_TRUE(v->IsNull());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
425 ASSERT_FALSE(v->IsBinary());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
426 ASSERT_THROW(v->GetContent(), OrthancException);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
427 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
428 }
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
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
431
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
432 TEST(DicomMap, DicomAsJson)
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
433 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
434 // 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
435 const unsigned char raw[] = { 0x63, 0x72, 0xe2, 0x6e, 0x65 };
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
436 std::string latin1((char*) &raw[0], sizeof(raw) / sizeof(char));
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
437
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3212
diff changeset
438 std::string utf8 = Toolbox::ConvertToUtf8(latin1, Encoding_Latin1, false);
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
439
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
440 ParsedDicomFile dicom(false);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
441 dicom.SetEncoding(Encoding_Latin1);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
442 dicom.ReplacePlainString(DICOM_TAG_PATIENT_NAME, "Hello");
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
443 dicom.ReplacePlainString(DICOM_TAG_STUDY_DESCRIPTION, utf8);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
444 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
445 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
446 dicom.ReplacePlainString(DICOM_TAG_PIXEL_DATA, "binary");
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
447 dicom.ReplacePlainString(DICOM_TAG_ROWS, "512");
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
448
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
449 DcmDataset& dataset = *dicom.GetDcmtkObject().getDataset();
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
450 dataset.insertEmptyElement(DCM_StudyID, OFFalse);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
451
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 std::auto_ptr<DcmSequenceOfItems> sequence(new DcmSequenceOfItems(DCM_ReferencedSeriesSequence));
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 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
456 std::auto_ptr<DcmItem> item(new DcmItem);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
457 item->putAndInsertString(DCM_ReferencedSOPInstanceUID, "nope", OFFalse);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
458 ASSERT_TRUE(sequence->insert(item.release(), false, false).good());
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
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
461 ASSERT_TRUE(dataset.insert(sequence.release(), false, false).good());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
462 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
463
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
464
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
465 // Check re-encoding
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
466 DcmElement* element = NULL;
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
467 ASSERT_TRUE(dataset.findAndGetElement(DCM_StudyDescription, 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
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
470 char* c = NULL;
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
471 ASSERT_TRUE(element != NULL &&
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
472 element->isLeaf() &&
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
473 element->isaString() &&
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
474 element->getString(c).good());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
475 ASSERT_EQ(0, memcmp(c, raw, latin1.length()));
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_TRUE(dataset.findAndGetElement(DCM_Rows, element).good() &&
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
478 element != NULL &&
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
479 element->getTag().getEVR() == EVR_US);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
480
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
481 DicomInstanceToStore toStore;
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
482 toStore.SetParsedDicomFile(dicom);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
483
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
484 DicomMap m;
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
485 m.FromDicomAsJson(toStore.GetJson());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
486
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
487 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
488
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
489 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).IsBinary());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
490 ASSERT_EQ("Hello", m.GetValue(DICOM_TAG_PATIENT_NAME).GetContent());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
491
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
492 ASSERT_FALSE(m.GetValue(DICOM_TAG_STUDY_DESCRIPTION).IsBinary());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
493 ASSERT_EQ(utf8, m.GetValue(DICOM_TAG_STUDY_DESCRIPTION).GetContent());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
494
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
495 ASSERT_FALSE(m.HasTag(DICOM_TAG_MANUFACTURER)); // Too long
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
496 ASSERT_FALSE(m.HasTag(DICOM_TAG_PIXEL_DATA)); // Pixel data
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
497 ASSERT_FALSE(m.HasTag(DICOM_TAG_REFERENCED_SERIES_SEQUENCE)); // Sequence
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
498 ASSERT_EQ(DICOM_TAG_REFERENCED_SERIES_SEQUENCE.GetGroup(), DCM_ReferencedSeriesSequence.getGroup());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
499 ASSERT_EQ(DICOM_TAG_REFERENCED_SERIES_SEQUENCE.GetElement(), DCM_ReferencedSeriesSequence.getElement());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
500
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
501 ASSERT_TRUE(m.HasTag(DICOM_TAG_SERIES_DESCRIPTION)); // Maximum length
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
502 ASSERT_FALSE(m.GetValue(DICOM_TAG_SERIES_DESCRIPTION).IsBinary());
3040
07ab06af90ed preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3015
diff changeset
503 ASSERT_EQ(ORTHANC_MAXIMUM_TAG_LENGTH,
07ab06af90ed preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3015
diff changeset
504 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
505
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
506 ASSERT_FALSE(m.GetValue(DICOM_TAG_ROWS).IsBinary());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
507 ASSERT_EQ("512", m.GetValue(DICOM_TAG_ROWS).GetContent());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
508
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
509 ASSERT_FALSE(m.GetValue(DICOM_TAG_STUDY_ID).IsNull());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
510 ASSERT_FALSE(m.GetValue(DICOM_TAG_STUDY_ID).IsBinary());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
511 ASSERT_EQ("", m.GetValue(DICOM_TAG_STUDY_ID).GetContent());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
512
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
513 DicomArray a(m);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
514 ASSERT_EQ(6u, a.GetSize());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
515
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
516
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
517 //dicom.SaveToFile("/tmp/test.dcm");
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
518 //std::cout << toStore.GetJson() << std::endl;
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
519 //a.Print(stdout);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
520 }
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
521
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
522
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
523
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
524 TEST(DicomMap, ExtractMainDicomTags)
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
525 {
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
526 DicomMap b;
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
527 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
528 ASSERT_TRUE(b.HasOnlyMainDicomTags());
3006
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 DicomMap a;
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
532 a.SetValue(DICOM_TAG_PATIENT_NAME, "A", false);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
533 a.SetValue(DICOM_TAG_STUDY_DESCRIPTION, "B", false);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
534 a.SetValue(DICOM_TAG_SERIES_DESCRIPTION, "C", false);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
535 a.SetValue(DICOM_TAG_NUMBER_OF_FRAMES, "D", false);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
536 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
537 ASSERT_FALSE(a.HasOnlyMainDicomTags());
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
538 b.ExtractMainDicomTags(a);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
539 }
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 ASSERT_EQ(4u, b.GetSize());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
542 ASSERT_EQ("A", b.GetValue(DICOM_TAG_PATIENT_NAME).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
543 ASSERT_EQ("B", b.GetValue(DICOM_TAG_STUDY_DESCRIPTION).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
544 ASSERT_EQ("C", b.GetValue(DICOM_TAG_SERIES_DESCRIPTION).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
545 ASSERT_EQ("D", b.GetValue(DICOM_TAG_NUMBER_OF_FRAMES).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
546 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
547 ASSERT_TRUE(b.HasOnlyMainDicomTags());
3006
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 b.SetValue(DICOM_TAG_PATIENT_NAME, "G", false);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
550
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
551 {
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
552 DicomMap a;
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
553 a.SetValue(DICOM_TAG_PATIENT_NAME, "A", false);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
554 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
555 ASSERT_FALSE(a.HasOnlyMainDicomTags());
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
556 b.Merge(a);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
557 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
558
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
559 ASSERT_EQ(5u, b.GetSize());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
560 ASSERT_EQ("G", b.GetValue(DICOM_TAG_PATIENT_NAME).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
561 ASSERT_EQ("B", b.GetValue(DICOM_TAG_STUDY_DESCRIPTION).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
562 ASSERT_EQ("C", b.GetValue(DICOM_TAG_SERIES_DESCRIPTION).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
563 ASSERT_EQ("D", b.GetValue(DICOM_TAG_NUMBER_OF_FRAMES).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
564 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
565 ASSERT_FALSE(b.HasOnlyMainDicomTags());
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
566 }
3187
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
567
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
568
3551
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
569 TEST(DicomMap, RemoveBinary)
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
570 {
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
571 DicomMap b;
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
572 b.SetValue(DICOM_TAG_PATIENT_NAME, "A", false);
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
573 b.SetValue(DICOM_TAG_PATIENT_ID, "B", true);
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
574 b.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, DicomValue()); // NULL
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
575 b.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, DicomValue("C", false));
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
576 b.SetValue(DICOM_TAG_SOP_INSTANCE_UID, DicomValue("D", true));
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
577
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
578 b.RemoveBinaryTags();
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
579
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
580 std::string s;
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
581 ASSERT_EQ(2u, b.GetSize());
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
582 ASSERT_TRUE(b.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false)); ASSERT_EQ("A", s);
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
583 ASSERT_TRUE(b.LookupStringValue(s, DICOM_TAG_SERIES_INSTANCE_UID, false)); ASSERT_EQ("C", s);
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
584 }
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
585
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
586
3187
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
587
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
588 TEST(DicomWebJson, Multiplicity)
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
589 {
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
590 // 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
591
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
592 ParsedDicomFile dicom(false);
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
593 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
594 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
595 dicom.ReplacePlainString(DICOM_TAG_IMAGE_POSITION_PATIENT, "");
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
596
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
597 DicomWebJsonVisitor visitor;
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
598 dicom.Apply(visitor);
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 {
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
601 const Json::Value& tag = visitor.GetResult() ["00200037"]; // ImageOrientationPatient
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
602 const Json::Value& value = tag["Value"];
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
603
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
604 ASSERT_EQ(EnumerationToString(ValueRepresentation_DecimalString), tag["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
605 ASSERT_EQ(2u, tag.getMemberNames().size());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
606 ASSERT_EQ(3u, value.size());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
607 ASSERT_EQ(Json::realValue, value[1].type());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
608 ASSERT_FLOAT_EQ(1.0f, value[0].asFloat());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
609 ASSERT_FLOAT_EQ(2.3f, value[1].asFloat());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
610 ASSERT_FLOAT_EQ(4.0f, value[2].asFloat());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
611 }
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
612
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
613 {
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
614 const Json::Value& tag = visitor.GetResult() ["00200032"]; // ImagePositionPatient
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
615 ASSERT_EQ(EnumerationToString(ValueRepresentation_DecimalString), tag["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
616 ASSERT_EQ(1u, tag.getMemberNames().size());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
617 }
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
618
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
619 std::string xml;
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
620 visitor.FormatXml(xml);
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
621
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
622 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
623 DicomMap m;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
624 m.FromDicomWeb(visitor.GetResult());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
625 ASSERT_EQ(3u, m.GetSize());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
626
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
627 std::string s;
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
628 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false));
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
629 ASSERT_EQ("SB1^SB2^SB3^SB4^SB5", s);
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
630 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_IMAGE_POSITION_PATIENT, false));
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
631 ASSERT_TRUE(s.empty());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
632
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
633 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_IMAGE_ORIENTATION_PATIENT, false));
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
634
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
635 std::vector<std::string> v;
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
636 Toolbox::TokenizeString(v, s, '\\');
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
637 ASSERT_FLOAT_EQ(1.0f, boost::lexical_cast<float>(v[0]));
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
638 ASSERT_FLOAT_EQ(2.3f, boost::lexical_cast<float>(v[1]));
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
639 ASSERT_FLOAT_EQ(4.0f, boost::lexical_cast<float>(v[2]));
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
640 }
3187
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
641 }
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
642
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
643
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
644 TEST(DicomWebJson, NullValue)
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
645 {
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
646 // 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
647
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
648 ParsedDicomFile dicom(false);
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
649 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
650
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
651 DicomWebJsonVisitor visitor;
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
652 dicom.Apply(visitor);
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
653
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
654 {
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
655 const Json::Value& tag = visitor.GetResult() ["00200037"];
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
656 const Json::Value& value = tag["Value"];
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
657
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
658 ASSERT_EQ(EnumerationToString(ValueRepresentation_DecimalString), tag["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
659 ASSERT_EQ(2u, tag.getMemberNames().size());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
660 ASSERT_EQ(4u, value.size());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
661 ASSERT_EQ(Json::realValue, value[0].type());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
662 ASSERT_EQ(Json::nullValue, value[1].type());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
663 ASSERT_EQ(Json::nullValue, value[2].type());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
664 ASSERT_EQ(Json::realValue, value[3].type());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
665 ASSERT_FLOAT_EQ(1.5f, value[0].asFloat());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
666 ASSERT_FLOAT_EQ(2.5f, value[3].asFloat());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
667 }
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
668
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
669 std::string xml;
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
670 visitor.FormatXml(xml);
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
671
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
672 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
673 DicomMap m;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
674 m.FromDicomWeb(visitor.GetResult());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
675 ASSERT_EQ(1u, m.GetSize());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
676
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
677 std::string s;
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
678 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_IMAGE_ORIENTATION_PATIENT, false));
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
679
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
680 std::vector<std::string> v;
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
681 Toolbox::TokenizeString(v, s, '\\');
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
682 ASSERT_FLOAT_EQ(1.5f, boost::lexical_cast<float>(v[0]));
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
683 ASSERT_TRUE(v[1].empty());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
684 ASSERT_TRUE(v[2].empty());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
685 ASSERT_FLOAT_EQ(2.5f, boost::lexical_cast<float>(v[3]));
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
686 }
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
687 }
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
688
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
689
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
690 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
691 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
692 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
693 {
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
694 // 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
695 // "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
696 // 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
697
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
698 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
699
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
700 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
701 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
702 {
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
703 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
704 }
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
705
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
706 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
707 }
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
708
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
709
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
710 TEST(DicomWebJson, ValueRepresentation)
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
711 {
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
712 // 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
713
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
714 ParsedDicomFile dicom(false);
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
715 dicom.ReplacePlainString(DicomTag(0x0040, 0x0241), "AE");
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
716 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
717 SetTagKey(dicom, DicomTag(0x0020, 0x9165), DicomTag(0x0010, 0x0020));
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
718 dicom.ReplacePlainString(DicomTag(0x0008, 0x0052), "CS");
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
719 dicom.ReplacePlainString(DicomTag(0x0008, 0x0012), "DA");
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
720 dicom.ReplacePlainString(DicomTag(0x0010, 0x1020), "42"); // DS
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
721 dicom.ReplacePlainString(DicomTag(0x0008, 0x002a), "DT");
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
722 dicom.ReplacePlainString(DicomTag(0x0010, 0x9431), "43"); // FL
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
723 dicom.ReplacePlainString(DicomTag(0x0008, 0x1163), "44"); // FD
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
724 dicom.ReplacePlainString(DicomTag(0x0008, 0x1160), "45"); // IS
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
725 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
726 dicom.ReplacePlainString(DicomTag(0x0010, 0x4000), "LT");
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
727 dicom.ReplacePlainString(DicomTag(0x0028, 0x2000), "OB");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
728 dicom.ReplacePlainString(DicomTag(0x7fe0, 0x0009), "OD");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
729 dicom.ReplacePlainString(DicomTag(0x0064, 0x0009), "OF");
3210
4a1c47e20685 fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
730 dicom.ReplacePlainString(DicomTag(0x0066, 0x0040), "46");
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
731 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
732 dicom.ReplacePlainString(DicomTag(0x0028, 0x1201), "OWOW");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
733 dicom.ReplacePlainString(DicomTag(0x0010, 0x0010), "PN");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
734 dicom.ReplacePlainString(DicomTag(0x0008, 0x0050), "SH");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
735 dicom.ReplacePlainString(DicomTag(0x0018, 0x6020), "-15"); // SL
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
736 dicom.ReplacePlainString(DicomTag(0x0018, 0x9219), "-16"); // SS
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
737 dicom.ReplacePlainString(DicomTag(0x0008, 0x0081), "ST");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
738 dicom.ReplacePlainString(DicomTag(0x0008, 0x0013), "TM");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
739 dicom.ReplacePlainString(DicomTag(0x0008, 0x0119), "UC");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
740 dicom.ReplacePlainString(DicomTag(0x0008, 0x0016), "UI");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
741 dicom.ReplacePlainString(DicomTag(0x0008, 0x1161), "128"); // UL
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
742 dicom.ReplacePlainString(DicomTag(0x4342, 0x1234), "UN"); // Inexistent tag
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
743 dicom.ReplacePlainString(DicomTag(0x0008, 0x0120), "UR");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
744 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
745 dicom.ReplacePlainString(DicomTag(0x0040, 0x0031), "UT");
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
746
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
747 DicomWebJsonVisitor visitor;
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
748 dicom.Apply(visitor);
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
749
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
750 std::string s;
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
751
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
752 // The tag (0002,0002) is "Media Storage SOP Class UID" and is
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
753 // automatically copied by DCMTK from tag (0008,0016)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
754 ASSERT_EQ("UI", visitor.GetResult() ["00020002"]["vr"].asString());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
755 ASSERT_EQ("UI", visitor.GetResult() ["00020002"]["Value"][0].asString());
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
756 ASSERT_EQ("AE", visitor.GetResult() ["00400241"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
757 ASSERT_EQ("AE", visitor.GetResult() ["00400241"]["Value"][0].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
758 ASSERT_EQ("AS", visitor.GetResult() ["00101010"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
759 ASSERT_EQ("AS", visitor.GetResult() ["00101010"]["Value"][0].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
760 ASSERT_EQ("AT", visitor.GetResult() ["00209165"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
761 ASSERT_EQ("00100020", visitor.GetResult() ["00209165"]["Value"][0].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
762 ASSERT_EQ("CS", visitor.GetResult() ["00080052"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
763 ASSERT_EQ("CS", visitor.GetResult() ["00080052"]["Value"][0].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
764 ASSERT_EQ("DA", visitor.GetResult() ["00080012"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
765 ASSERT_EQ("DA", visitor.GetResult() ["00080012"]["Value"][0].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
766 ASSERT_EQ("DS", visitor.GetResult() ["00101020"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
767 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
768 ASSERT_EQ("DT", visitor.GetResult() ["0008002A"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
769 ASSERT_EQ("DT", visitor.GetResult() ["0008002A"]["Value"][0].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
770 ASSERT_EQ("FL", visitor.GetResult() ["00109431"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
771 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
772 ASSERT_EQ("FD", visitor.GetResult() ["00081163"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
773 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
774 ASSERT_EQ("IS", visitor.GetResult() ["00081160"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
775 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
776 ASSERT_EQ("LO", visitor.GetResult() ["00080070"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
777 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
778 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
779 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
780
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
781 ASSERT_EQ("OB", visitor.GetResult() ["00282000"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
782 Toolbox::DecodeBase64(s, visitor.GetResult() ["00282000"]["InlineBinary"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
783 ASSERT_EQ("OB", s);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
784
3210
4a1c47e20685 fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
785 #if DCMTK_VERSION_NUMBER >= 361
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
786 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
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() ["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
789 #endif
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
790
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
791 Toolbox::DecodeBase64(s, visitor.GetResult() ["7FE00009"]["InlineBinary"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
792 ASSERT_EQ("OD", s);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
793
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
794 ASSERT_EQ("OF", visitor.GetResult() ["00640009"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
795 Toolbox::DecodeBase64(s, visitor.GetResult() ["00640009"]["InlineBinary"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
796 ASSERT_EQ("OF", s);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
797
3210
4a1c47e20685 fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
798 #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
799 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
800 Toolbox::DecodeBase64(s, visitor.GetResult() ["00660040"]["InlineBinary"].asString());
3211
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3210
diff changeset
801 ASSERT_EQ("46", s);
3210
4a1c47e20685 fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
802 #elif DCMTK_VERSION_NUMBER == 361
4a1c47e20685 fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
803 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
804 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
805 #elif DCMTK_VERSION_NUMBER > 361
4a1c47e20685 fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
806 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
807 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
808 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
809 #endif
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
810
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
811 ASSERT_EQ("OW", visitor.GetResult() ["00281201"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
812 Toolbox::DecodeBase64(s, visitor.GetResult() ["00281201"]["InlineBinary"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
813 ASSERT_EQ("OWOW", s);
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 ASSERT_EQ("PN", visitor.GetResult() ["00100010"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
816 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
817
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
818 ASSERT_EQ("SH", visitor.GetResult() ["00080050"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
819 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
820
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
821 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
822 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
823
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
824 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
825 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
826
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
827 ASSERT_EQ("ST", visitor.GetResult() ["00080081"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
828 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
829
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
830 ASSERT_EQ("TM", visitor.GetResult() ["00080013"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
831 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
832
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
833 #if DCMTK_VERSION_NUMBER >= 361
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
834 ASSERT_EQ("UC", visitor.GetResult() ["00080119"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
835 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
836 #else
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
837 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
838 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
839 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
840 #endif
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
841
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
842 ASSERT_EQ("UI", visitor.GetResult() ["00080016"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
843 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
844
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
845 ASSERT_EQ("UL", visitor.GetResult() ["00081161"]["vr"].asString());
3212
304184684107 Orthanc-1.5.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3211
diff changeset
846 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
847
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
848 ASSERT_EQ("UN", visitor.GetResult() ["43421234"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
849 Toolbox::DecodeBase64(s, visitor.GetResult() ["43421234"]["InlineBinary"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
850 ASSERT_EQ("UN", s);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
851
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
852 #if DCMTK_VERSION_NUMBER >= 361
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
853 ASSERT_EQ("UR", visitor.GetResult() ["00080120"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
854 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
855 #else
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
856 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
857 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
858 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
859 #endif
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
860
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
861 #if DCMTK_VERSION_NUMBER >= 361
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
862 ASSERT_EQ("US", visitor.GetResult() ["00080301"]["vr"].asString());
3212
304184684107 Orthanc-1.5.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3211
diff changeset
863 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
864 #else
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
865 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
866 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
867 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
868 #endif
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
869
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
870 ASSERT_EQ("UT", visitor.GetResult() ["00400031"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
871 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
872
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
873 std::string xml;
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
874 visitor.FormatXml(xml);
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
875
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
876 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
877 DicomMap m;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
878 m.FromDicomWeb(visitor.GetResult());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
879 ASSERT_EQ(31u, m.GetSize());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
880
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
881 std::string s;
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
882 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0002, 0x0002), false)); ASSERT_EQ("UI", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
883 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0040, 0x0241), false)); ASSERT_EQ("AE", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
884 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0010, 0x1010), false)); ASSERT_EQ("AS", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
885 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0020, 0x9165), false)); ASSERT_EQ("00100020", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
886 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0052), false)); ASSERT_EQ("CS", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
887 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0012), false)); ASSERT_EQ("DA", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
888 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0010, 0x1020), false)); ASSERT_EQ("42", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
889 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x002a), false)); ASSERT_EQ("DT", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
890 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0010, 0x9431), false)); ASSERT_EQ("43", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
891 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x1163), false)); ASSERT_EQ("44", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
892 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x1160), false)); ASSERT_EQ("45", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
893 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0070), false)); ASSERT_EQ("LO", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
894 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0010, 0x4000), false)); ASSERT_EQ("LT", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
895 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0028, 0x2000), true)); ASSERT_EQ("OB", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
896 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x7fe0, 0x0009), true)); ASSERT_EQ("OD", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
897 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0064, 0x0009), true)); ASSERT_EQ("OF", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
898 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0028, 0x1201), true)); ASSERT_EQ("OWOW", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
899 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0010, 0x0010), false)); ASSERT_EQ("PN", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
900 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0050), false)); ASSERT_EQ("SH", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
901 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0018, 0x6020), false)); ASSERT_EQ("-15", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
902 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0018, 0x9219), false)); ASSERT_EQ("-16", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
903 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0081), false)); ASSERT_EQ("ST", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
904 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0013), false)); ASSERT_EQ("TM", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
905 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0119), false)); ASSERT_EQ("UC", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
906 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0016), false)); ASSERT_EQ("UI", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
907 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x1161), false)); ASSERT_EQ("128", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
908 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x4342, 0x1234), true)); ASSERT_EQ("UN", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
909 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0120), false)); ASSERT_EQ("UR", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
910 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0301), false)); ASSERT_EQ("17", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
911 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0040, 0x0031), false)); ASSERT_EQ("UT", s);
3497
db71bd11affc fix unit tests if dcmtk != 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
912
db71bd11affc fix unit tests if dcmtk != 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
913 #if DCMTK_VERSION_NUMBER == 361
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
914 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0066, 0x0040), false));
3497
db71bd11affc fix unit tests if dcmtk != 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
915 #else
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
916 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0066, 0x0040), true));
3497
db71bd11affc fix unit tests if dcmtk != 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
917 #endif
db71bd11affc fix unit tests if dcmtk != 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
918 ASSERT_EQ("46", s);
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
919 }
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
920 }
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
921
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
922
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
923 TEST(DicomWebJson, Sequence)
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
924 {
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
925 ParsedDicomFile dicom(false);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
926
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
927 {
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
928 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
929
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
930 for (unsigned int i = 0; i < 3; i++)
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
931 {
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
932 std::auto_ptr<DcmItem> item(new DcmItem);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
933 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
934 item->putAndInsertString(DCM_ReferencedSOPInstanceUID, s.c_str(), OFFalse);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
935 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
936 }
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
937
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
938 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
939 }
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
940
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
941 DicomWebJsonVisitor visitor;
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
942 dicom.Apply(visitor);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
943
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
944 ASSERT_EQ("SQ", visitor.GetResult() ["00081115"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
945 ASSERT_EQ(3u, visitor.GetResult() ["00081115"]["Value"].size());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
946
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
947 std::set<std::string> items;
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
948
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
949 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
950 {
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
951 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
952 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
953 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
954 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
955 }
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
956
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
957 ASSERT_EQ(3u, items.size());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
958 ASSERT_TRUE(items.find("item0") != items.end());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
959 ASSERT_TRUE(items.find("item1") != items.end());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
960 ASSERT_TRUE(items.find("item2") != items.end());
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
961
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
962 std::string xml;
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
963 visitor.FormatXml(xml);
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
964
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
965 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
966 DicomMap m;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
967 m.FromDicomWeb(visitor.GetResult());
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
968 ASSERT_EQ(0u, m.GetSize()); // Sequences are not handled by DicomMap
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
969 }
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
970 }
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
971
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
972
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
973 TEST(DicomWebJson, PixelSpacing)
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
974 {
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
975 // Test related to locales: Make sure that decimal separator is
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
976 // correctly handled (dot "." vs comma ",")
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
977 ParsedDicomFile source(false);
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
978 source.ReplacePlainString(DICOM_TAG_PIXEL_SPACING, "1.5\\1.3");
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
979
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
980 DicomWebJsonVisitor visitor;
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
981 source.Apply(visitor);
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
982
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
983 DicomMap target;
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
984 target.FromDicomWeb(visitor.GetResult());
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
985
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
986 ASSERT_EQ("DS", visitor.GetResult() ["00280030"]["vr"].asString());
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
987 ASSERT_FLOAT_EQ(1.5f, visitor.GetResult() ["00280030"]["Value"][0].asFloat());
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
988 ASSERT_FLOAT_EQ(1.3f, visitor.GetResult() ["00280030"]["Value"][1].asFloat());
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
989
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
990 std::string s;
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
991 ASSERT_TRUE(target.LookupStringValue(s, DICOM_TAG_PIXEL_SPACING, false));
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
992 ASSERT_EQ(s, "1.5\\1.3");
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
993 }
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
994
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
995
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
996 TEST(DicomMap, MainTagNames)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
997 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
998 ASSERT_EQ(3, ResourceType_Instance - ResourceType_Patient);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
999
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1000 for (int i = ResourceType_Patient; i <= ResourceType_Instance; i++)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1001 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1002 ResourceType level = static_cast<ResourceType>(i);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1003
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1004 std::set<DicomTag> tags;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1005 DicomMap::GetMainDicomTags(tags, level);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1006
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1007 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1008 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1009 DicomMap a;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1010 a.SetValue(*it, "TEST", false);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1011
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1012 Json::Value json;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1013 a.DumpMainDicomTags(json, level);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1014
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1015 ASSERT_EQ(Json::objectValue, json.type());
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1016 ASSERT_EQ(1u, json.getMemberNames().size());
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1017
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1018 std::string name = json.getMemberNames() [0];
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1019 EXPECT_EQ(name, FromDcmtkBridge::GetTagName(*it, ""));
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1020
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1021 DicomMap b;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1022 b.ParseMainDicomTags(json, level);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1023
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1024 ASSERT_EQ(1u, b.GetSize());
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1025 ASSERT_EQ("TEST", b.GetStringValue(*it, "", false));
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1026
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1027 std::string main = it->GetMainTagsName();
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1028 if (!main.empty())
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1029 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1030 ASSERT_EQ(main, name);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1031 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1032 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1033 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1034 }