annotate OrthancFramework/Sources/DicomFormat/DicomMap.cpp @ 5044:6fed78e13233

Refactored DicomMap to handle sequences when needed
author Alain Mazy <am@osimis.io>
date Tue, 28 Jun 2022 17:45:09 +0200
parents 1c08cd68250a
children ea9e2680da6f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 53
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: 1206
diff changeset
4 * Department, University Hospital of Liege, Belgium
4870
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
9 * modify it under the terms of the GNU Lesser General Public License
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
11 * the License, or (at your option) any later version.
136
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 84
diff changeset
12 *
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
16 * Lesser General Public License for more details.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
19 * License along with this program. If not, see
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
20 * <http://www.gnu.org/licenses/>.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
824
a811bdf8b8eb precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 730
diff changeset
24 #include "../PrecompiledHeaders.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "DicomMap.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include <stdio.h>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include <memory>
4933
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
29 #include <boost/algorithm/string/join.hpp>
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
30
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3690
diff changeset
31 #include "../Compatibility.h"
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
32 #include "../Endianness.h"
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
33 #include "../Logging.h"
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 53
diff changeset
34 #include "../OrthancException.h"
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
35 #include "../Toolbox.h"
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
36 #include "DicomArray.h"
5038
f8bea9c1c0fc reduce dependencies to DCMTK (e.g. for plugins)
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
37
f8bea9c1c0fc reduce dependencies to DCMTK (e.g. for plugins)
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
38 #if ORTHANC_ENABLE_DCMTK == 1
5036
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4982
diff changeset
39 #include "../DicomParsing/FromDcmtkBridge.h"
5038
f8bea9c1c0fc reduce dependencies to DCMTK (e.g. for plugins)
Alain Mazy <am@osimis.io>
parents: 5036
diff changeset
40 #endif
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 53
diff changeset
42 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 {
4933
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
44 // WARNING: the DEFAULT list of main dicom tags below are the list as they
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
45 // were in Orthanc 1.10 before we introduced the dynamic main dicom tags.
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
46 // This list has not changed since Orthanc 1.4.2 and had a single change since
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
47 // Orthanc 0.9.5.
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
48 // These lists have a specific signature. When a resource does not have
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
49 // the metadata "MainDicomTagsSignature", we'll assume that they were stored
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
50 // with an Orthanc prior to 1.11. It is therefore very important that you never
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
51 // change these lists !
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
52
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
53 static const DicomTag DEFAULT_PATIENT_MAIN_DICOM_TAGS[] =
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
55 // { DicomTag(0x0010, 0x1010), "PatientAge" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
56 // { DicomTag(0x0010, 0x1040), "PatientAddress" },
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
57 DICOM_TAG_PATIENT_NAME,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
58 DICOM_TAG_PATIENT_BIRTH_DATE,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
59 DICOM_TAG_PATIENT_SEX,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
60 DICOM_TAG_OTHER_PATIENT_IDS,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
61 DICOM_TAG_PATIENT_ID,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
62
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 };
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
64
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
65 static const DicomTag DEFAULT_STUDY_MAIN_DICOM_TAGS[] =
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
66 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
67 // { DicomTag(0x0010, 0x1020), "PatientSize" },
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
68 // { DicomTag(0x0010, 0x1030), "PatientWeight" },
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
69 DICOM_TAG_STUDY_DATE,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
70 DICOM_TAG_STUDY_TIME,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
71 DICOM_TAG_STUDY_ID,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
72 DICOM_TAG_STUDY_DESCRIPTION,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
73 DICOM_TAG_ACCESSION_NUMBER,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
74 DICOM_TAG_STUDY_INSTANCE_UID,
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
75 // New in db v6
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
76 DICOM_TAG_REQUESTED_PROCEDURE_DESCRIPTION,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
77 DICOM_TAG_INSTITUTION_NAME,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
78 DICOM_TAG_REQUESTING_PHYSICIAN,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
79 DICOM_TAG_REFERRING_PHYSICIAN_NAME
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
80 };
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
81
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
82 static const DicomTag DEFAULT_SERIES_MAIN_DICOM_TAGS[] =
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
84 // { DicomTag(0x0010, 0x1080), "MilitaryRank" },
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
85 DICOM_TAG_SERIES_DATE,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
86 DICOM_TAG_SERIES_TIME,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
87 DICOM_TAG_MODALITY,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
88 DICOM_TAG_MANUFACTURER,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
89 DICOM_TAG_STATION_NAME,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
90 DICOM_TAG_SERIES_DESCRIPTION,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
91 DICOM_TAG_BODY_PART_EXAMINED,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
92 DICOM_TAG_SEQUENCE_NAME,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
93 DICOM_TAG_PROTOCOL_NAME,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
94 DICOM_TAG_SERIES_NUMBER,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
95 DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
96 DICOM_TAG_IMAGES_IN_ACQUISITION,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
97 DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
98 DICOM_TAG_NUMBER_OF_SLICES,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
99 DICOM_TAG_NUMBER_OF_TIME_SLICES,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
100 DICOM_TAG_SERIES_INSTANCE_UID,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
101
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
102 // New in db v6
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
103 DICOM_TAG_IMAGE_ORIENTATION_PATIENT,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
104 DICOM_TAG_SERIES_TYPE,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
105 DICOM_TAG_OPERATOR_NAME,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
106 DICOM_TAG_PERFORMED_PROCEDURE_STEP_DESCRIPTION,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
107 DICOM_TAG_ACQUISITION_DEVICE_PROCESSING_DESCRIPTION,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
108 DICOM_TAG_CONTRAST_BOLUS_AGENT
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
109 };
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
110
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
111 static const DicomTag DEFAULT_INSTANCE_MAIN_DICOM_TAGS[] =
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
112 {
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
113 DICOM_TAG_INSTANCE_CREATION_DATE,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
114 DICOM_TAG_INSTANCE_CREATION_TIME,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
115 DICOM_TAG_ACQUISITION_NUMBER,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
116 DICOM_TAG_IMAGE_INDEX,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
117 DICOM_TAG_INSTANCE_NUMBER,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
118 DICOM_TAG_NUMBER_OF_FRAMES,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
119 DICOM_TAG_TEMPORAL_POSITION_IDENTIFIER,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
120 DICOM_TAG_SOP_INSTANCE_UID,
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
121
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
122 // New in db v6
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
123 DICOM_TAG_IMAGE_POSITION_PATIENT,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
124 DICOM_TAG_IMAGE_COMMENTS,
2804
d88970f1ffbf fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
125
d88970f1ffbf fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
126 /**
d88970f1ffbf fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
127 * Main DICOM tags that are not part of any release of the
d88970f1ffbf fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
128 * database schema yet, and that will be part of future db v7. In
d88970f1ffbf fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
129 * the meantime, the user must call "/tools/reconstruct" once to
d88970f1ffbf fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
130 * access these tags if the corresponding DICOM files where
d88970f1ffbf fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
131 * indexed in the database by an older version of Orthanc.
d88970f1ffbf fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
132 **/
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
133 DICOM_TAG_IMAGE_ORIENTATION_PATIENT // New in Orthanc 1.4.2
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 };
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
137
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
138
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
139 class DicomMap::MainDicomTagsConfiguration
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
140 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
141 private:
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
142 friend DicomMap;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
143
4982
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
144 std::set<DicomTag> patientsMainDicomTagsByLevel_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
145 std::set<DicomTag> studiesMainDicomTagsByLevel_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
146 std::set<DicomTag> seriesMainDicomTagsByLevel_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
147 std::set<DicomTag> instancesMainDicomTagsByLevel_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
148
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
149 std::set<DicomTag> allMainDicomTags_;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
150
4933
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
151 std::map<ResourceType, std::string> signatures_;
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
152 std::map<ResourceType, std::string> defaultSignatures_;
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
153
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
154 MainDicomTagsConfiguration()
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
155 {
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
156 ResetDefaultMainDicomTags();
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
157 }
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
158
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
159 void ResetDefaultMainDicomTags()
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
160 {
4982
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
161 patientsMainDicomTagsByLevel_.clear();
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
162 studiesMainDicomTagsByLevel_.clear();
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
163 seriesMainDicomTagsByLevel_.clear();
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
164 instancesMainDicomTagsByLevel_.clear();
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
165
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
166 allMainDicomTags_.clear();
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
167
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
168 // by default, initialize with the previous static list (up to 1.10.0)
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
169 LoadDefaultMainDicomTags(ResourceType_Patient);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
170 LoadDefaultMainDicomTags(ResourceType_Study);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
171 LoadDefaultMainDicomTags(ResourceType_Series);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
172 LoadDefaultMainDicomTags(ResourceType_Instance);
4933
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
173
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
174 defaultSignatures_[ResourceType_Patient] = signatures_[ResourceType_Patient];
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
175 defaultSignatures_[ResourceType_Study] = signatures_[ResourceType_Study];
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
176 defaultSignatures_[ResourceType_Series] = signatures_[ResourceType_Series];
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
177 defaultSignatures_[ResourceType_Instance] = signatures_[ResourceType_Instance];
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
178 }
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
179
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
180 std::string ComputeSignature(const std::set<DicomTag>& tags)
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
181 {
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
182 // std::set are sorted by default (which is important for us !)
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
183 std::set<std::string> tagsIds;
4981
d0c34145320c cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4960
diff changeset
184 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it)
4933
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
185 {
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
186 tagsIds.insert(it->Format());
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
187 }
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
188
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4933
diff changeset
189 std::string signatureText = boost::algorithm::join(tagsIds, ";");
4933
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
190
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4933
diff changeset
191 return signatureText;
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
192 }
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
193
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
194 void LoadDefaultMainDicomTags(ResourceType level)
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
195 {
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
196 const DicomTag* tags = NULL;
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
197 size_t size;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
198
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
199 switch (level)
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
200 {
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
201 case ResourceType_Patient:
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
202 tags = DEFAULT_PATIENT_MAIN_DICOM_TAGS;
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
203 size = sizeof(DEFAULT_PATIENT_MAIN_DICOM_TAGS) / sizeof(DicomTag);
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
204 break;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
205
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
206 case ResourceType_Study:
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
207 tags = DEFAULT_STUDY_MAIN_DICOM_TAGS;
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
208 size = sizeof(DEFAULT_STUDY_MAIN_DICOM_TAGS) / sizeof(DicomTag);
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
209 break;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
210
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
211 case ResourceType_Series:
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
212 tags = DEFAULT_SERIES_MAIN_DICOM_TAGS;
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
213 size = sizeof(DEFAULT_SERIES_MAIN_DICOM_TAGS) / sizeof(DicomTag);
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
214 break;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
215
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
216 case ResourceType_Instance:
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
217 tags = DEFAULT_INSTANCE_MAIN_DICOM_TAGS;
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
218 size = sizeof(DEFAULT_INSTANCE_MAIN_DICOM_TAGS) / sizeof(DicomTag);
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
219 break;
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
220
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
221 default:
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
222 throw OrthancException(ErrorCode_ParameterOutOfRange);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
223 }
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
224
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
225 assert(tags != NULL &&
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
226 size != 0);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
227
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
228 for (size_t i = 0; i < size; i++)
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
229 {
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
230 AddMainDicomTag(tags[i], level);
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
231 }
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
232
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
233 }
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
234
4982
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
235
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
236 std::set<DicomTag>& GetMainDicomTagsByLevel(ResourceType level)
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
237 {
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
238 switch (level)
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
239 {
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
240 case ResourceType_Patient:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
241 return patientsMainDicomTagsByLevel_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
242
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
243 case ResourceType_Study:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
244 return studiesMainDicomTagsByLevel_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
245
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
246 case ResourceType_Series:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
247 return seriesMainDicomTagsByLevel_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
248
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
249 case ResourceType_Instance:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
250 return instancesMainDicomTagsByLevel_;
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
251
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
252 default:
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
253 throw OrthancException(ErrorCode_InternalError);
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
254 }
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
255 }
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
256
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
257 public:
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
258 // Singleton pattern
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
259 static MainDicomTagsConfiguration& GetInstance()
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
260 {
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
261 static MainDicomTagsConfiguration parameters;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
262 return parameters;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
263 }
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
264
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
265 void AddMainDicomTag(const DicomTag& tag, ResourceType level)
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
266 {
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
267 const std::set<DicomTag>& existingLevelTags = GetMainDicomTagsByLevel(level);
4982
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
268
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
269 if (existingLevelTags.find(tag) != existingLevelTags.end())
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
270 {
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
271 throw OrthancException(ErrorCode_MainDicomTagsMultiplyDefined, tag.Format() + " is already defined");
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
272 }
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
273
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
274
4982
40fd2a485a84 fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4981
diff changeset
275 GetMainDicomTagsByLevel(level).insert(tag);
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
276 allMainDicomTags_.insert(tag);
4933
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
277 signatures_[level] = ComputeSignature(GetMainDicomTagsByLevel(level));
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
278 }
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
279
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
280 const std::set<DicomTag>& GetAllMainDicomTags() const
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
281 {
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
282 return allMainDicomTags_;
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
283 }
4933
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
284
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
285 const std::string& GetMainDicomTagsSignature(ResourceType level)
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
286 {
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
287 assert(signatures_.find(level) != signatures_.end());
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
288
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
289 return signatures_[level];
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
290 }
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
291
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
292 const std::string& GetDefaultMainDicomTagsSignature(ResourceType level)
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
293 {
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
294 assert(defaultSignatures_.find(level) != defaultSignatures_.end());
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
295
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
296 return defaultSignatures_[level];
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
297 }
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
298
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
299 };
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
300
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
301
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
302 void DicomMap::SetValueInternal(uint16_t group,
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
303 uint16_t element,
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
304 DicomValue* value)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 DicomTag tag(group, element);
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
307 Content::iterator it = content_.find(tag);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
309 if (it != content_.end())
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 delete it->second;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 it->second = value;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
316 content_.insert(std::make_pair(tag, value));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 void DicomMap::Clear()
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
323 for (Content::iterator it = content_.begin(); it != content_.end(); ++it)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 {
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
325 assert(it->second != NULL);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 delete it->second;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
329 content_.clear();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331
4296
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
332 void DicomMap::SetNullValue(uint16_t group, uint16_t element)
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
333 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
334 SetValueInternal(group, element, new DicomValue);
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
335 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
336
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
337 void DicomMap::SetNullValue(const DicomTag &tag)
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
338 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
339 SetValueInternal(tag.GetGroup(), tag.GetElement(), new DicomValue);
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
340 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
341
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
342 void DicomMap::SetValue(uint16_t group, uint16_t element, const DicomValue &value)
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
343 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
344 SetValueInternal(group, element, value.Clone());
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
345 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
346
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
347 void DicomMap::SetValue(const DicomTag &tag, const DicomValue &value)
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
348 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
349 SetValueInternal(tag.GetGroup(), tag.GetElement(), value.Clone());
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
350 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
351
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
352 void DicomMap::SetValue(const DicomTag &tag, const std::string &str, bool isBinary)
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
353 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
354 SetValueInternal(tag.GetGroup(), tag.GetElement(), new DicomValue(str, isBinary));
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
355 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
356
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
357 void DicomMap::SetValue(uint16_t group, uint16_t element, const std::string &str, bool isBinary)
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
358 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
359 SetValueInternal(group, element, new DicomValue(str, isBinary));
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
360 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
361
5044
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
362 void DicomMap::SetValue(const DicomTag& tag, const Json::Value& value)
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
363 {
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
364 SetValueInternal(tag.GetGroup(), tag.GetElement(), new DicomValue(value));
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
365 }
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
366
4296
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
367 bool DicomMap::HasTag(uint16_t group, uint16_t element) const
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
368 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
369 return HasTag(DicomTag(group, element));
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
370 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
371
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
372 bool DicomMap::HasTag(const DicomTag &tag) const
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
373 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
374 return content_.find(tag) != content_.end();
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
375 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
376
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
377 const DicomValue &DicomMap::GetValue(uint16_t group, uint16_t element) const
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
378 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
379 return GetValue(DicomTag(group, element));
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
380 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
381
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382
4936
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
383 static void ExtractTagsInternal(DicomMap& result,
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
384 const DicomMap::Content& source,
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
385 const std::set<DicomTag>& mainDicomTags)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 result.Clear();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
389 for (std::set<DicomTag>::const_iterator itmt = mainDicomTags.begin();
4981
d0c34145320c cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4960
diff changeset
390 itmt != mainDicomTags.end(); ++itmt)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 {
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
392 DicomMap::Content::const_iterator it = source.find(*itmt);
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
393 if (it != source.end())
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
395 result.SetValue(it->first, *it->second /* value will be cloned */);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399
4936
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
400 void DicomMap::ExtractTags(DicomMap& result, const std::set<DicomTag>& tags) const
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
401 {
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
402 result.Clear();
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
403
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
404 for (std::set<DicomTag>::const_iterator itmt = tags.begin();
4981
d0c34145320c cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4960
diff changeset
405 itmt != tags.end(); ++itmt)
4936
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
406 {
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
407 DicomMap::Content::const_iterator it = content_.find(*itmt);
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
408 if (it != content_.end())
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
409 {
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
410 result.SetValue(it->first, *it->second /* value will be cloned */);
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
411 }
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
412 }
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
413 }
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
414
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4933
diff changeset
415 void DicomMap::ExtractResourceInformation(DicomMap& result, ResourceType level) const
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4933
diff changeset
416 {
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
417 const std::set<DicomTag>& mainDicomTags = DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTagsByLevel(level);
4936
8422e4f99a18 Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4935
diff changeset
418 ExtractTagsInternal(result, content_, mainDicomTags);
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4933
diff changeset
419 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421 void DicomMap::ExtractPatientInformation(DicomMap& result) const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 {
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4933
diff changeset
423 ExtractResourceInformation(result, ResourceType_Patient);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426 void DicomMap::ExtractStudyInformation(DicomMap& result) const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427 {
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4933
diff changeset
428 ExtractResourceInformation(result, ResourceType_Study);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 void DicomMap::ExtractSeriesInformation(DicomMap& result) const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
432 {
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4933
diff changeset
433 ExtractResourceInformation(result, ResourceType_Series);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 void DicomMap::ExtractInstanceInformation(DicomMap& result) const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437 {
4935
acd3f72e2a21 split ExpandResource in 2: read from DB and serialize to json. This will allow us to merge requested tags from both the DB and the file system
Alain Mazy <am@osimis.io>
parents: 4933
diff changeset
438 ExtractResourceInformation(result, ResourceType_Instance);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441
4297
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4296
diff changeset
442 DicomMap::~DicomMap()
4296
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
443 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
444 Clear();
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
445 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
446
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
447 size_t DicomMap::GetSize() const
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
448 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
449 return content_.size();
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
450 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
451
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
452
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 DicomMap* DicomMap::Clone() const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3690
diff changeset
455 std::unique_ptr<DicomMap> result(new DicomMap);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
457 for (Content::const_iterator it = content_.begin(); it != content_.end(); ++it)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
459 result->content_.insert(std::make_pair(it->first, it->second->Clone()));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462 return result.release();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
464
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
466 void DicomMap::Assign(const DicomMap& other)
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
467 {
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
468 Clear();
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
469
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
470 for (Content::const_iterator it = other.content_.begin(); it != other.content_.end(); ++it)
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
471 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
472 content_.insert(std::make_pair(it->first, it->second->Clone()));
1310
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
473 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
474 }
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
475
61ce8147f30d custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
476
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 const DicomValue& DicomMap::GetValue(const DicomTag& tag) const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478 {
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
479 const DicomValue* value = TestAndGetValue(tag);
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
480
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
481 if (value)
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
482 {
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
483 return *value;
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
484 }
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
485 else
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
486 {
730
309e686b41e7 better logging about nonexistent tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
487 throw OrthancException(ErrorCode_InexistentTag);
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
488 }
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
489 }
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
490
4296
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
491 const DicomValue *DicomMap::TestAndGetValue(uint16_t group, uint16_t element) const
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
492 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
493 return TestAndGetValue(DicomTag(group, element));
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
494 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4214
diff changeset
495
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
496
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
497 const DicomValue* DicomMap::TestAndGetValue(const DicomTag& tag) const
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
498 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
499 Content::const_iterator it = content_.find(tag);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
501 if (it == content_.end())
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
502 {
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
503 return NULL;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506 {
80
6212bf978584 status of series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 77
diff changeset
507 return it->second;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
510
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
511
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512 void DicomMap::Remove(const DicomTag& tag)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
514 Content::iterator it = content_.find(tag);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
515 if (it != content_.end())
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517 delete it->second;
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
518 content_.erase(it);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
519 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
520 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
521
5036
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4982
diff changeset
522 void DicomMap::RemoveTags(const std::set<DicomTag>& tags)
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4982
diff changeset
523 {
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4982
diff changeset
524 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it)
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4982
diff changeset
525 {
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4982
diff changeset
526 Remove(*it);
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4982
diff changeset
527 }
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4982
diff changeset
528 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
529
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
530 static void SetupFindTemplate(DicomMap& result,
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
531 const std::set<DicomTag>& mainDicomTags)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
532 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
533 result.Clear();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
534
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
535 for (std::set<DicomTag>::const_iterator itmt = mainDicomTags.begin();
4981
d0c34145320c cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4960
diff changeset
536 itmt != mainDicomTags.end(); ++itmt)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
537 {
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
538 result.SetValue(*itmt, "", false);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
539 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
540 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
541
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
542 void DicomMap::SetupFindPatientTemplate(DicomMap& result)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
543 {
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
544 const std::set<DicomTag>& mainDicomTags = DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTagsByLevel(ResourceType_Patient);
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
545 SetupFindTemplate(result, mainDicomTags);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
546 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
547
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
548 void DicomMap::SetupFindStudyTemplate(DicomMap& result)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
549 {
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
550 const std::set<DicomTag>& mainDicomTags = DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTagsByLevel(ResourceType_Study);
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
551 SetupFindTemplate(result, mainDicomTags);
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
552 result.SetValue(DICOM_TAG_ACCESSION_NUMBER, "", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
553 result.SetValue(DICOM_TAG_PATIENT_ID, "", false);
1848
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
554
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
555 // These main DICOM tags are only indirectly related to the
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
556 // General Study Module, remove them
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
557 result.Remove(DICOM_TAG_INSTITUTION_NAME);
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
558 result.Remove(DICOM_TAG_REQUESTING_PHYSICIAN);
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
559 result.Remove(DICOM_TAG_REQUESTED_PROCEDURE_DESCRIPTION);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
560 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
561
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
562 void DicomMap::SetupFindSeriesTemplate(DicomMap& result)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
563 {
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
564 const std::set<DicomTag>& mainDicomTags = DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTagsByLevel(ResourceType_Series);
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
565 SetupFindTemplate(result, mainDicomTags);
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
566 result.SetValue(DICOM_TAG_ACCESSION_NUMBER, "", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
567 result.SetValue(DICOM_TAG_PATIENT_ID, "", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
568 result.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, "", false);
1372
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
569
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
570 // These tags are considered as "main" by Orthanc, but are not in the Series module
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
571 result.Remove(DicomTag(0x0008, 0x0070)); // Manufacturer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
572 result.Remove(DicomTag(0x0008, 0x1010)); // Station name
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
573 result.Remove(DicomTag(0x0018, 0x0024)); // Sequence name
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
574 result.Remove(DICOM_TAG_CARDIAC_NUMBER_OF_IMAGES);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
575 result.Remove(DICOM_TAG_IMAGES_IN_ACQUISITION);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
576 result.Remove(DICOM_TAG_NUMBER_OF_SLICES);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
577 result.Remove(DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1364
diff changeset
578 result.Remove(DICOM_TAG_NUMBER_OF_TIME_SLICES);
1706
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1702
diff changeset
579 result.Remove(DICOM_TAG_IMAGE_ORIENTATION_PATIENT);
1848
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1841
diff changeset
580 result.Remove(DICOM_TAG_SERIES_TYPE);
1850
68854412c7bc new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
581 result.Remove(DICOM_TAG_ACQUISITION_DEVICE_PROCESSING_DESCRIPTION);
68854412c7bc new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
582 result.Remove(DICOM_TAG_CONTRAST_BOLUS_AGENT);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
583 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
585 void DicomMap::SetupFindInstanceTemplate(DicomMap& result)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586 {
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
587 const std::set<DicomTag>& mainDicomTags = DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTagsByLevel(ResourceType_Instance);
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
588 SetupFindTemplate(result, mainDicomTags);
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
589 result.SetValue(DICOM_TAG_ACCESSION_NUMBER, "", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
590 result.SetValue(DICOM_TAG_PATIENT_ID, "", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
591 result.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, "", false);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
592 result.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, "", false);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
593 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
594
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
595
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
596 void DicomMap::CopyTagIfExists(const DicomMap& source,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
597 const DicomTag& tag)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
598 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
599 if (source.HasTag(tag))
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
601 SetValue(tag, source.GetValue(tag));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
602 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
603 }
562
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
604
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
605
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
606 bool DicomMap::IsMainDicomTag(const DicomTag& tag, ResourceType level)
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
607 {
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
608 const std::set<DicomTag>& mainDicomTags = DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTagsByLevel(level);
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
609 return mainDicomTags.find(tag) != mainDicomTags.end();
562
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
610 }
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
611
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
612 bool DicomMap::IsMainDicomTag(const DicomTag& tag)
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
613 {
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
614 return (IsMainDicomTag(tag, ResourceType_Patient) ||
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
615 IsMainDicomTag(tag, ResourceType_Study) ||
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
616 IsMainDicomTag(tag, ResourceType_Series) ||
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
617 IsMainDicomTag(tag, ResourceType_Instance));
f64e3838d6e1 refactoring enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 433
diff changeset
618 }
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
619
4944
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
620 static bool IsGenericComputedTag(const DicomTag& tag)
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
621 {
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
622 return tag == DICOM_TAG_RETRIEVE_URL ||
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
623 tag == DICOM_TAG_RETRIEVE_AE_TITLE;
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
624 }
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
625
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
626 bool DicomMap::IsComputedTag(const DicomTag& tag)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
627 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
628 return (IsComputedTag(tag, ResourceType_Patient) ||
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
629 IsComputedTag(tag, ResourceType_Study) ||
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
630 IsComputedTag(tag, ResourceType_Series) ||
4944
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
631 IsComputedTag(tag, ResourceType_Instance) ||
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
632 IsGenericComputedTag(tag));
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
633 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
634
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
635 bool DicomMap::IsComputedTag(const DicomTag& tag, ResourceType level)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
636 {
4944
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
637
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
638 switch (level)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
639 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
640 case ResourceType_Patient:
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
641 return (
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
642 tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES ||
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
643 tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES ||
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
644 tag == DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
645 );
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
646 case ResourceType_Study:
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
647 return (
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
648 tag == DICOM_TAG_MODALITIES_IN_STUDY ||
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
649 tag == DICOM_TAG_SOP_CLASSES_IN_STUDY ||
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
650 tag == DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES ||
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
651 tag == DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
652 );
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
653 case ResourceType_Series:
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
654 return (
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
655 tag == DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
656 );
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
657 case ResourceType_Instance:
4944
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
658 return (
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
659 tag == DICOM_TAG_INSTANCE_AVAILABILITY
f377d5643538 new Warnings configuration + InstanceAvailability tag
Alain Mazy <am@osimis.io>
parents: 4940
diff changeset
660 );
4940
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
661 default:
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
662 throw OrthancException(ErrorCode_ParameterOutOfRange);
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
663 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
664 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
665
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
666 bool DicomMap::HasOnlyComputedTags(const std::set<DicomTag>& tags)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
667 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
668 if (tags.size() == 0)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
669 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
670 return false;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
671 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
672
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
673 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
674 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
675 if (!IsComputedTag(*it))
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
676 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
677 return false;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
678 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
679 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
680 return true;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
681 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
682
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
683 bool DicomMap::HasComputedTags(const std::set<DicomTag>& tags)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
684 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
685 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
686 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
687 if (IsComputedTag(*it))
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
688 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
689 return true;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
690 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
691 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
692
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
693 return false;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
694 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
695
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
696 bool DicomMap::HasComputedTags(const std::set<DicomTag>& tags, ResourceType level)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
697 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
698 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it)
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
699 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
700 if (IsComputedTag(*it, level))
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
701 {
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
702 return true;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
703 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
704 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
705 return false;
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
706 }
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
707
304514ce84ee tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents: 4936
diff changeset
708
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
709 const std::set<DicomTag>& DicomMap::GetMainDicomTags(ResourceType level)
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
710 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
711 return DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTagsByLevel(level);
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
712 }
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
713
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
714 const std::set<DicomTag>& DicomMap::GetAllMainDicomTags()
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
715 {
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
716 return DicomMap::MainDicomTagsConfiguration::GetInstance().GetAllMainDicomTags();
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
717 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
718
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
719 void DicomMap::AddMainDicomTag(const DicomTag& tag, ResourceType level)
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
720 {
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
721 DicomMap::MainDicomTagsConfiguration::GetInstance().AddMainDicomTag(tag, level);
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
722 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
723
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
724 void DicomMap::ResetDefaultMainDicomTags()
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
725 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
726 DicomMap::MainDicomTagsConfiguration::GetInstance().ResetDefaultMainDicomTags();
567
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 562
diff changeset
727 }
1206
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
728
4933
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
729 const std::string& DicomMap::GetMainDicomTagsSignature(ResourceType level)
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
730 {
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
731 return DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTagsSignature(level);
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
732 }
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
733
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
734 const std::string& DicomMap::GetDefaultMainDicomTagsSignature(ResourceType level)
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
735 {
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
736 return DicomMap::MainDicomTagsConfiguration::GetInstance().GetDefaultMainDicomTagsSignature(level);
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
737 }
312c6f4da888 adding MainDicomTags signatures
Alain Mazy <am@osimis.io>
parents: 4932
diff changeset
738
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
739 void DicomMap::GetTags(std::set<DicomTag>& tags) const
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
740 {
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
741 tags.clear();
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
742
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
743 for (Content::const_iterator it = content_.begin();
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
744 it != content_.end(); ++it)
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
745 {
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
746 tags.insert(it->first);
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
747 }
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1310
diff changeset
748 }
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
749
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
750
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
751 static uint16_t ReadLittleEndianUint16(const char* dicom)
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
752 {
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
753 const uint8_t* p = reinterpret_cast<const uint8_t*>(dicom);
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
754
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
755 return (static_cast<uint16_t>(p[0]) |
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
756 (static_cast<uint16_t>(p[1]) << 8));
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
757 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
758
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
759
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
760 static uint32_t ReadLittleEndianUint32(const char* dicom)
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
761 {
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
762 const uint8_t* p = reinterpret_cast<const uint8_t*>(dicom);
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
763
4214
7b011cfda135 working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4213
diff changeset
764 return (static_cast<uint32_t>(p[0]) |
7b011cfda135 working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4213
diff changeset
765 (static_cast<uint32_t>(p[1]) << 8) |
7b011cfda135 working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4213
diff changeset
766 (static_cast<uint32_t>(p[2]) << 16) |
7b011cfda135 working on DicomStreamReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4213
diff changeset
767 (static_cast<uint32_t>(p[3]) << 24));
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
768 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
769
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
770
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
771 static bool ValidateTag(const ValueRepresentation& vr,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
772 const std::string& value)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
773 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
774 switch (vr)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
775 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
776 case ValueRepresentation_ApplicationEntity:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
777 return value.size() <= 16;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
778
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
779 case ValueRepresentation_AgeString:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
780 return (value.size() == 4 &&
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
781 isdigit(value[0]) &&
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
782 isdigit(value[1]) &&
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
783 isdigit(value[2]) &&
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
784 (value[3] == 'D' || value[3] == 'W' || value[3] == 'M' || value[3] == 'Y'));
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
785
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
786 case ValueRepresentation_AttributeTag:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
787 return value.size() == 4;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
788
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
789 case ValueRepresentation_CodeString:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
790 return value.size() <= 16;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
791
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
792 case ValueRepresentation_Date:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
793 return value.size() <= 18;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
794
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
795 case ValueRepresentation_DecimalString:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
796 return value.size() <= 16;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
797
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
798 case ValueRepresentation_DateTime:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
799 return value.size() <= 54;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
800
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
801 case ValueRepresentation_FloatingPointSingle:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
802 return value.size() == 4;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
803
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
804 case ValueRepresentation_FloatingPointDouble:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
805 return value.size() == 8;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
806
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
807 case ValueRepresentation_IntegerString:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
808 return value.size() <= 12;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
809
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
810 case ValueRepresentation_LongString:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
811 return value.size() <= 64;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
812
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
813 case ValueRepresentation_LongText:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
814 return value.size() <= 10240;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
815
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
816 case ValueRepresentation_OtherByte:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
817 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
818
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
819 case ValueRepresentation_OtherDouble:
2013
f6e68c0c2737 fix for msvc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2008
diff changeset
820 return value.size() <= (static_cast<uint64_t>(1) << 32) - 8;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
821
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
822 case ValueRepresentation_OtherFloat:
2013
f6e68c0c2737 fix for msvc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2008
diff changeset
823 return value.size() <= (static_cast<uint64_t>(1) << 32) - 4;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
824
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
825 case ValueRepresentation_OtherLong:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
826 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
827
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
828 case ValueRepresentation_OtherWord:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
829 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
830
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
831 case ValueRepresentation_PersonName:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
832 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
833
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
834 case ValueRepresentation_ShortString:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
835 return value.size() <= 16;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
836
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
837 case ValueRepresentation_SignedLong:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
838 return value.size() == 4;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
839
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
840 case ValueRepresentation_Sequence:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
841 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
842
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
843 case ValueRepresentation_SignedShort:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
844 return value.size() == 2;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
845
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
846 case ValueRepresentation_ShortText:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
847 return value.size() <= 1024;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
848
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
849 case ValueRepresentation_Time:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
850 return value.size() <= 28;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
851
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
852 case ValueRepresentation_UnlimitedCharacters:
2013
f6e68c0c2737 fix for msvc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2008
diff changeset
853 return value.size() <= (static_cast<uint64_t>(1) << 32) - 2;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
854
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
855 case ValueRepresentation_UniqueIdentifier:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
856 return value.size() <= 64;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
857
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
858 case ValueRepresentation_UnsignedLong:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
859 return value.size() == 4;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
860
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
861 case ValueRepresentation_Unknown:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
862 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
863
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
864 case ValueRepresentation_UniversalResource:
2013
f6e68c0c2737 fix for msvc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2008
diff changeset
865 return value.size() <= (static_cast<uint64_t>(1) << 32) - 2;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
866
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
867 case ValueRepresentation_UnsignedShort:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
868 return value.size() == 2;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
869
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
870 case ValueRepresentation_UnlimitedText:
2013
f6e68c0c2737 fix for msvc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2008
diff changeset
871 return value.size() <= (static_cast<uint64_t>(1) << 32) - 2;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
872
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
873 default:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
874 // Assume unsupported tags are OK
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
875 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
876 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
877 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
878
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
879
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
880 static void RemoveTagPadding(std::string& value,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
881 const ValueRepresentation& vr)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
882 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
883 /**
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
884 * Remove padding from character strings, if need be. For the time
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
885 * being, only the UI VR is supported.
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
886 * http://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_6.2.html
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
887 **/
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
888
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
889 switch (vr)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
890 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
891 case ValueRepresentation_UniqueIdentifier:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
892 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
893 /**
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
894 * "Values with a VR of UI shall be padded with a single
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
895 * trailing NULL (00H) character when necessary to achieve even
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
896 * length."
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
897 **/
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
898
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
899 if (!value.empty() &&
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
900 value[value.size() - 1] == '\0')
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
901 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
902 value.resize(value.size() - 1);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
903 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
904
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
905 break;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
906 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
907
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
908 /**
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
909 * TODO implement other VR
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
910 **/
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
911
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
912 default:
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
913 // No padding is applicable to this VR
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
914 break;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
915 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
916 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
917
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
918
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
919 static bool ReadNextTag(DicomTag& tag,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
920 ValueRepresentation& vr,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
921 std::string& value,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
922 const char* dicom,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
923 size_t size,
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
924 size_t& position)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
925 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
926 /**
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
927 * http://dicom.nema.org/medical/dicom/current/output/chtml/part05/chapter_7.html#sect_7.1.2
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
928 * This function reads a data element with Explicit VR encoded using Little-Endian.
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
929 **/
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
930
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
931 if (position + 6 > size)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
932 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
933 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
934 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
935
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
936 tag = DicomTag(ReadLittleEndianUint16(dicom + position),
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
937 ReadLittleEndianUint16(dicom + position + 2));
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
938
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
939 vr = StringToValueRepresentation(std::string(dicom + position + 4, 2), true);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
940 if (vr == ValueRepresentation_NotSupported)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
941 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
942 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
943 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
944
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
945 // http://dicom.nema.org/medical/dicom/current/output/chtml/part05/chapter_7.html#sect_7.1.2
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
946 if (vr == ValueRepresentation_ApplicationEntity /* AE */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
947 vr == ValueRepresentation_AgeString /* AS */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
948 vr == ValueRepresentation_AttributeTag /* AT */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
949 vr == ValueRepresentation_CodeString /* CS */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
950 vr == ValueRepresentation_Date /* DA */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
951 vr == ValueRepresentation_DecimalString /* DS */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
952 vr == ValueRepresentation_DateTime /* DT */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
953 vr == ValueRepresentation_FloatingPointSingle /* FL */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
954 vr == ValueRepresentation_FloatingPointDouble /* FD */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
955 vr == ValueRepresentation_IntegerString /* IS */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
956 vr == ValueRepresentation_LongString /* LO */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
957 vr == ValueRepresentation_LongText /* LT */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
958 vr == ValueRepresentation_PersonName /* PN */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
959 vr == ValueRepresentation_ShortString /* SH */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
960 vr == ValueRepresentation_SignedLong /* SL */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
961 vr == ValueRepresentation_SignedShort /* SS */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
962 vr == ValueRepresentation_ShortText /* ST */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
963 vr == ValueRepresentation_Time /* TM */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
964 vr == ValueRepresentation_UniqueIdentifier /* UI */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
965 vr == ValueRepresentation_UnsignedLong /* UL */ ||
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
966 vr == ValueRepresentation_UnsignedShort /* US */)
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
967 {
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
968 /**
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
969 * This is Table 7.1-2. "Data Element with Explicit VR of AE,
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
970 * AS, AT, CS, DA, DS, DT, FL, FD, IS, LO, LT, PN, SH, SL, SS,
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
971 * ST, TM, UI, UL and US"
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
972 **/
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
973 if (position + 8 > size)
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
974 {
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
975 return false;
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
976 }
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
977
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
978 uint16_t length = ReadLittleEndianUint16(dicom + position + 6);
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
979 if (position + 8 + length > size)
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
980 {
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
981 return false;
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
982 }
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
983
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
984 value.assign(dicom + position + 8, length);
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
985 position += (8 + length);
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
986 }
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
987 else
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
988 {
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
989 /**
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
990 * This is Table 7.1-1. "Data Element with Explicit VR other
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
991 * than as shown in Table 7.1-2"
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
992 **/
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
993 if (position + 12 > size)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
994 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
995 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
996 }
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
997
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
998 uint16_t reserved = ReadLittleEndianUint16(dicom + position + 6);
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
999 if (reserved != 0)
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1000 {
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1001 return false;
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1002 }
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1003
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1004 uint32_t length = ReadLittleEndianUint32(dicom + position + 8);
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1005 if (position + 12 + length > size)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1006 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1007 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1008 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1009
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1010 value.assign(dicom + position + 12, length);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1011 position += (12 + length);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1012 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1013
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1014 if (!ValidateTag(vr, value))
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1015 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1016 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1017 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1018
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1019 RemoveTagPadding(value, vr);
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1020
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1021 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1022 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1023
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1024
3840
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1025 bool DicomMap::IsDicomFile(const void* dicom,
3771
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1026 size_t size)
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1027 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1028 /**
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1029 * http://dicom.nema.org/medical/dicom/current/output/chtml/part10/chapter_7.html
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1030 * According to Table 7.1-1, besides the "DICM" DICOM prefix, the
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1031 * file preamble (i.e. dicom[0..127]) should not be taken into
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1032 * account to determine whether the file is or is not a DICOM file.
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1033 **/
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1034
3840
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1035 const uint8_t* p = reinterpret_cast<const uint8_t*>(dicom);
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1036
3771
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1037 return (size >= 132 &&
3840
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1038 p[128] == 'D' &&
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1039 p[129] == 'I' &&
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1040 p[130] == 'C' &&
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1041 p[131] == 'M');
3771
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1042 }
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1043
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1044
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1045 bool DicomMap::ParseDicomMetaInformation(DicomMap& result,
3840
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1046 const void* dicom,
3771
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1047 size_t size)
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1048 {
74889e6f6d68 fix memory issues if parsing invalid DICOM file
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3713
diff changeset
1049 if (!IsDicomFile(dicom, size))
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1050 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1051 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1052 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1053
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1054
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1055 /**
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1056 * The DICOM File Meta Information must be encoded using the
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1057 * Explicit VR Little Endian Transfer Syntax
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1058 * (UID=1.2.840.10008.1.2.1).
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1059 **/
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1060
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1061 result.Clear();
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1062
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1063 // First, we read the "File Meta Information Group Length" tag
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1064 // (0002,0000) to know where to stop reading the meta header
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1065 size_t position = 132;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1066
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1067 DicomTag tag(0x0000, 0x0000); // Dummy initialization
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1068 ValueRepresentation vr;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1069 std::string value;
3840
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1070 if (!ReadNextTag(tag, vr, value, reinterpret_cast<const char*>(dicom), size, position) ||
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1071 tag.GetGroup() != 0x0002 ||
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1072 tag.GetElement() != 0x0000 ||
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1073 vr != ValueRepresentation_UnsignedLong ||
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1074 value.size() != 4)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1075 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1076 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1077 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1078
4213
be2eca8b02e1 testing DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4199
diff changeset
1079 size_t stopPosition = position + ReadLittleEndianUint32(value.c_str());
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1080 if (stopPosition > size)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1081 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1082 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1083 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1084
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1085 while (position < stopPosition)
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1086 {
3840
e7003b2203a7 fixing signature of DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3771
diff changeset
1087 if (ReadNextTag(tag, vr, value, reinterpret_cast<const char*>(dicom), size, position))
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1088 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1089 result.SetValue(tag, value, IsBinaryValueRepresentation(vr));
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1090 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1091 else
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1092 {
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1093 return false;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1094 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1095 }
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1096
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1097 return true;
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1098 }
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1099
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1100
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1101 static std::string ValueAsString(const DicomMap& summary,
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1102 const DicomTag& tag)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1103 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1104 const DicomValue& value = summary.GetValue(tag);
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1105 if (value.IsNull())
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1106 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1107 return "(null)";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1108 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1109 else
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1110 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1111 return value.GetContent();
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1112 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1113 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1114
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1115
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1116 void DicomMap::LogMissingTagsForStore() const
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1117 {
4501
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1118 std::string patientId, studyInstanceUid, seriesInstanceUid, sopInstanceUid;
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1119
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1120 if (HasTag(DICOM_TAG_PATIENT_ID))
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1121 {
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1122 patientId = ValueAsString(*this, DICOM_TAG_PATIENT_ID);
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1123 }
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1124
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1125 if (HasTag(DICOM_TAG_STUDY_INSTANCE_UID))
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1126 {
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1127 studyInstanceUid = ValueAsString(*this, DICOM_TAG_STUDY_INSTANCE_UID);
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1128 }
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1129
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1130 if (HasTag(DICOM_TAG_SERIES_INSTANCE_UID))
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1131 {
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1132 seriesInstanceUid = ValueAsString(*this, DICOM_TAG_SERIES_INSTANCE_UID);
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1133 }
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1134
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1135 if (HasTag(DICOM_TAG_SOP_INSTANCE_UID))
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1136 {
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1137 sopInstanceUid = ValueAsString(*this, DICOM_TAG_SOP_INSTANCE_UID);
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1138 }
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1139
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1140 LogMissingTagsForStore(patientId, studyInstanceUid, seriesInstanceUid, sopInstanceUid);
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1141 }
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1142
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1143
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1144 void DicomMap::LogMissingTagsForStore(const std::string& patientId,
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1145 const std::string& studyInstanceUid,
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1146 const std::string& seriesInstanceUid,
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1147 const std::string& sopInstanceUid)
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1148 {
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1149 std::string s, t;
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1150
4501
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1151 if (!patientId.empty())
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1152 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1153 if (t.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1154 t += ", ";
4501
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1155 t += "PatientID=" + patientId;
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1156 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1157 else
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1158 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1159 if (s.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1160 s += ", ";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1161 s += "PatientID";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1162 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1163
4501
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1164 if (!studyInstanceUid.empty())
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1165 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1166 if (t.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1167 t += ", ";
4501
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1168 t += "StudyInstanceUID=" + studyInstanceUid;
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1169 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1170 else
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1171 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1172 if (s.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1173 s += ", ";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1174 s += "StudyInstanceUID";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1175 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1176
4501
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1177 if (!seriesInstanceUid.empty())
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1178 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1179 if (t.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1180 t += ", ";
4501
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1181 t += "SeriesInstanceUID=" + seriesInstanceUid;
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1182 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1183 else
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1184 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1185 if (s.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1186 s += ", ";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1187 s += "SeriesInstanceUID";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1188 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1189
4501
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1190 if (!sopInstanceUid.empty())
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1191 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1192 if (t.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1193 t += ", ";
4501
11c2ddb4e2ca FromDcmtkBridge::LogMissingTagsForStore()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
1194 t += "SOPInstanceUID=" + sopInstanceUid;
2380
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1195 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1196 else
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1197 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1198 if (s.size() > 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1199 s += ", ";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1200 s += "SOPInstanceUID";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1201 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1202
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1203 if (t.size() == 0)
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1204 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1205 LOG(ERROR) << "Store has failed because all the required tags (" << s << ") are missing (is it a DICOMDIR file?)";
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1206 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1207 else
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1208 {
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1209 LOG(ERROR) << "Store has failed because required tags (" << s << ") are missing for the following instance: " << t;
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1210 }
96b3ec054b69 reorganization in macros
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
1211 }
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1212
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1213
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1214 bool DicomMap::LookupStringValue(std::string& result,
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1215 const DicomTag& tag,
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1216 bool allowBinary) const
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1217 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1218 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1219
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1220 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1221 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1222 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1223 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1224 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1225 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1226 return value->CopyToString(result, allowBinary);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1227 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1228 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1229
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1230 bool DicomMap::ParseInteger32(int32_t& result,
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1231 const DicomTag& tag) const
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1232 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1233 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1234
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1235 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1236 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1237 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1238 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1239 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1240 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1241 return value->ParseInteger32(result);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1242 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1243 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1244
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1245 bool DicomMap::ParseInteger64(int64_t& result,
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1246 const DicomTag& tag) const
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1247 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1248 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1249
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1250 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1251 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1252 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1253 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1254 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1255 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1256 return value->ParseInteger64(result);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1257 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1258 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1259
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1260 bool DicomMap::ParseUnsignedInteger32(uint32_t& result,
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1261 const DicomTag& tag) const
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1262 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1263 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1264
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1265 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1266 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1267 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1268 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1269 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1270 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1271 return value->ParseUnsignedInteger32(result);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1272 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1273 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1274
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1275 bool DicomMap::ParseUnsignedInteger64(uint64_t& result,
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1276 const DicomTag& tag) const
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1277 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1278 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1279
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1280 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1281 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1282 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1283 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1284 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1285 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1286 return value->ParseUnsignedInteger64(result);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1287 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1288 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1289
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1290 bool DicomMap::ParseFloat(float& result,
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1291 const DicomTag& tag) const
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1292 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1293 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1294
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1295 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1296 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1297 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1298 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1299 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1300 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1301 return value->ParseFloat(result);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1302 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1303 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1304
3690
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1305 bool DicomMap::ParseFirstFloat(float& result,
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1306 const DicomTag& tag) const
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1307 {
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1308 const DicomValue* value = TestAndGetValue(tag);
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1309
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1310 if (value == NULL)
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1311 {
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1312 return false;
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1313 }
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1314 else
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1315 {
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1316 return value->ParseFirstFloat(result);
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1317 }
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1318 }
a9ce35d67c3c implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3678
diff changeset
1319
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1320 bool DicomMap::ParseDouble(double& result,
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1321 const DicomTag& tag) const
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1322 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1323 const DicomValue* value = TestAndGetValue(tag);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1324
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1325 if (value == NULL)
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1326 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1327 return false;
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1328 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1329 else
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1330 {
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1331 return value->ParseDouble(result);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1332 }
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2380
diff changeset
1333 }
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1334
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1335
5044
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1336 void DicomMap::FromDicomAsJson(const Json::Value& dicomAsJson, bool append, bool parseSequences)
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1337 {
3498
957e06cbe76a additional check
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
1338 if (dicomAsJson.type() != Json::objectValue)
957e06cbe76a additional check
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
1339 {
957e06cbe76a additional check
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
1340 throw OrthancException(ErrorCode_BadFileFormat);
957e06cbe76a additional check
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
1341 }
957e06cbe76a additional check
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
1342
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
1343 if (!append)
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
1344 {
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
1345 Clear();
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
1346 }
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1347
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1348 Json::Value::Members tags = dicomAsJson.getMemberNames();
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1349 for (Json::Value::Members::const_iterator
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1350 it = tags.begin(); it != tags.end(); ++it)
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1351 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1352 DicomTag tag(0, 0);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1353 if (!DicomTag::ParseHexadecimal(tag, it->c_str()))
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1354 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1355 throw OrthancException(ErrorCode_CorruptedFile);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1356 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1357
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1358 const Json::Value& value = dicomAsJson[*it];
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1359
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1360 if (value.type() != Json::objectValue ||
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1361 !value.isMember("Type") ||
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1362 !value.isMember("Value") ||
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1363 value["Type"].type() != Json::stringValue)
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1364 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1365 throw OrthancException(ErrorCode_CorruptedFile);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1366 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1367
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1368 if (value["Type"] == "String")
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1369 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1370 if (value["Value"].type() != Json::stringValue)
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1371 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1372 throw OrthancException(ErrorCode_CorruptedFile);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1373 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1374 else
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1375 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1376 SetValue(tag, value["Value"].asString(), false /* not binary */);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1377 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1378 }
5044
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1379 else if (value["Type"] == "Sequence" && parseSequences)
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1380 {
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1381 if (value["Value"].type() != Json::arrayValue)
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1382 {
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1383 printf("%s", dicomAsJson.toStyledString().c_str());
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1384 throw OrthancException(ErrorCode_CorruptedFile);
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1385 }
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1386 else
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1387 {
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1388 SetValue(tag, value["Value"]);
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1389 }
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1390 }
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1391 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1392 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1393
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
1394
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1395 void DicomMap::Merge(const DicomMap& other)
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1396 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1397 for (Content::const_iterator it = other.content_.begin();
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1398 it != other.content_.end(); ++it)
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1399 {
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1400 assert(it->second != NULL);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1401
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1402 if (content_.find(it->first) == content_.end())
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1403 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1404 content_[it->first] = it->second->Clone();
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1405 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1406 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1407 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1408
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1409
3678
26c6d47467a9 DicomMap::MergeMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3653
diff changeset
1410 void DicomMap::MergeMainDicomTags(const DicomMap& other,
26c6d47467a9 DicomMap::MergeMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3653
diff changeset
1411 ResourceType level)
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1412 {
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
1413 const std::set<DicomTag>& mainDicomTags = DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTagsByLevel(level);
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1414
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
1415 for (std::set<DicomTag>::const_iterator itmt = mainDicomTags.begin();
4981
d0c34145320c cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4960
diff changeset
1416 itmt != mainDicomTags.end(); ++itmt)
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1417 {
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
1418 Content::const_iterator found = other.content_.find(*itmt);
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1419
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1420 if (found != other.content_.end() &&
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
1421 content_.find(*itmt) == content_.end())
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1422 {
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1423 assert(found->second != NULL);
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
1424 content_[*itmt] = found->second->Clone();
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1425 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1426 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1427 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1428
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1429
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1430 void DicomMap::ExtractMainDicomTags(const DicomMap& other)
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1431 {
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1432 Clear();
3678
26c6d47467a9 DicomMap::MergeMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3653
diff changeset
1433 MergeMainDicomTags(other, ResourceType_Patient);
26c6d47467a9 DicomMap::MergeMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3653
diff changeset
1434 MergeMainDicomTags(other, ResourceType_Study);
26c6d47467a9 DicomMap::MergeMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3653
diff changeset
1435 MergeMainDicomTags(other, ResourceType_Series);
26c6d47467a9 DicomMap::MergeMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3653
diff changeset
1436 MergeMainDicomTags(other, ResourceType_Instance);
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1437 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1438
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
1439
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1440 bool DicomMap::HasOnlyMainDicomTags() const
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1441 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
1442 const std::set<DicomTag>& allMainDicomTags = DicomMap::MainDicomTagsConfiguration::GetInstance().GetAllMainDicomTags();
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1443
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1444 for (Content::const_iterator it = content_.begin(); it != content_.end(); ++it)
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1445 {
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
1446 if (allMainDicomTags.find(it->first) == allMainDicomTags.end())
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1447 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1448 return false;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1449 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1450 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1451
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1452 return true;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1453 }
5036
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4982
diff changeset
1454
5044
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1455 void DicomMap::ExtractSequences(DicomMap& result) const
5036
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4982
diff changeset
1456 {
5044
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1457 result.Clear();
5036
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4982
diff changeset
1458
5044
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1459 for (Content::const_iterator it = content_.begin(); it != content_.end(); ++it)
5036
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4982
diff changeset
1460 {
5044
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1461 if (it->second->IsSequence())
5036
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4982
diff changeset
1462 {
5044
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1463 result.SetValue(it->first, it->second->GetSequenceContent());
5036
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4982
diff changeset
1464 }
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4982
diff changeset
1465 }
877bc3b96476 Handle Dicom sequences in ExtraMainDicomTags and save them in the 'MainDicomSequences' metadata
Alain Mazy <am@osimis.io>
parents: 4982
diff changeset
1466 }
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
1467
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1468 void DicomMap::Serialize(Json::Value& target) const
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1469 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1470 target = Json::objectValue;
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1471
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1472 for (Content::const_iterator it = content_.begin(); it != content_.end(); ++it)
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1473 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1474 assert(it->second != NULL);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1475
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1476 std::string tag = it->first.Format();
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1477
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1478 Json::Value value;
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1479 it->second->Serialize(value);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1480
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1481 target[tag] = value;
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1482 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1483 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1484
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1485
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1486 void DicomMap::Unserialize(const Json::Value& source)
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1487 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1488 Clear();
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1489
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1490 if (source.type() != Json::objectValue)
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1491 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1492 throw OrthancException(ErrorCode_BadFileFormat);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1493 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1494
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1495 Json::Value::Members tags = source.getMemberNames();
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1496
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1497 for (size_t i = 0; i < tags.size(); i++)
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1498 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1499 DicomTag tag(0, 0);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1500
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1501 if (!DicomTag::ParseHexadecimal(tag, tags[i].c_str()) ||
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1502 content_.find(tag) != content_.end())
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1503 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1504 throw OrthancException(ErrorCode_BadFileFormat);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1505 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1506
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3690
diff changeset
1507 std::unique_ptr<DicomValue> value(new DicomValue);
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1508 value->Unserialize(source[tags[i]]);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1509
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1510 content_[tag] = value.release();
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1511 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
1512 }
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1513
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1514
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1515 void DicomMap::FromDicomWeb(const Json::Value& source)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1516 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1517 static const char* const ALPHABETIC = "Alphabetic";
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1518 static const char* const IDEOGRAPHIC = "Ideographic";
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1519 static const char* const INLINE_BINARY = "InlineBinary";
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1520 static const char* const PHONETIC = "Phonetic";
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1521 static const char* const VALUE = "Value";
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1522 static const char* const VR = "vr";
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1523
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1524 Clear();
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1525
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1526 if (source.type() != Json::objectValue)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1527 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1528 throw OrthancException(ErrorCode_BadFileFormat);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1529 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1530
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1531 Json::Value::Members tags = source.getMemberNames();
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1532
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1533 for (size_t i = 0; i < tags.size(); i++)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1534 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1535 const Json::Value& item = source[tags[i]];
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1536 DicomTag tag(0, 0);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1537
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1538 if (item.type() != Json::objectValue ||
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1539 !item.isMember(VR) ||
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1540 item[VR].type() != Json::stringValue ||
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1541 !DicomTag::ParseHexadecimal(tag, tags[i].c_str()))
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1542 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1543 throw OrthancException(ErrorCode_BadFileFormat);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1544 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1545
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1546 ValueRepresentation vr = StringToValueRepresentation(item[VR].asString(), false);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1547
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1548 if (item.isMember(INLINE_BINARY))
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1549 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1550 const Json::Value& value = item[INLINE_BINARY];
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1551
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1552 if (value.type() == Json::stringValue)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1553 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1554 std::string decoded;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1555 Toolbox::DecodeBase64(decoded, value.asString());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1556 SetValue(tag, decoded, true /* binary data */);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1557 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1558 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1559 else if (!item.isMember(VALUE))
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1560 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1561 // Tag is present, but it has a null value
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1562 SetValue(tag, "", false /* not binary */);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1563 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1564 else
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1565 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1566 const Json::Value& value = item[VALUE];
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1567
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1568 if (value.type() == Json::arrayValue)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1569 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1570 bool supported = true;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1571
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1572 std::string s;
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1573 for (Json::Value::ArrayIndex j = 0; j < value.size() && supported; j++)
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1574 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1575 if (!s.empty())
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1576 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1577 s += '\\';
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1578 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1579
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1580 switch (value[j].type())
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1581 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1582 case Json::objectValue:
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1583 if (vr == ValueRepresentation_PersonName &&
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1584 value[j].type() == Json::objectValue)
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1585 {
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1586 if (value[j].isMember(ALPHABETIC) &&
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1587 value[j][ALPHABETIC].type() == Json::stringValue)
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1588 {
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1589 s += value[j][ALPHABETIC].asString();
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1590 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1591
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1592 bool hasIdeographic = false;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1593
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1594 if (value[j].isMember(IDEOGRAPHIC) &&
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1595 value[j][IDEOGRAPHIC].type() == Json::stringValue)
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1596 {
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1597 s += '=' + value[j][IDEOGRAPHIC].asString();
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1598 hasIdeographic = true;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1599 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1600
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1601 if (value[j].isMember(PHONETIC) &&
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1602 value[j][PHONETIC].type() == Json::stringValue)
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1603 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1604 if (!hasIdeographic)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1605 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1606 s += '=';
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1607 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1608
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1609 s += '=' + value[j][PHONETIC].asString();
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1610 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1611 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1612 else
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1613 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1614 // This is the case of sequences
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1615 supported = false;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1616 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1617
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1618 break;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1619
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1620 case Json::stringValue:
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1621 s += value[j].asString();
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1622 break;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1623
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1624 case Json::intValue:
4788
b47ee86a0d10 support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4501
diff changeset
1625 s += boost::lexical_cast<std::string>(value[j].asInt64());
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1626 break;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1627
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1628 case Json::uintValue:
4788
b47ee86a0d10 support 64 bit integers in DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4501
diff changeset
1629 s += boost::lexical_cast<std::string>(value[j].asUInt64());
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1630 break;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1631
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1632 case Json::realValue:
4199
fbc49a65340a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
1633 s += boost::lexical_cast<std::string>(value[j].asDouble());
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1634 break;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1635
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1636 default:
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1637 break;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1638 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1639 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1640
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1641 if (supported)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1642 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1643 SetValue(tag, s, false /* not binary */);
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1644 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1645 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1646 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1647 }
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
1648 }
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1649
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1650
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1651 std::string DicomMap::GetStringValue(const DicomTag& tag,
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1652 const std::string& defaultValue,
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1653 bool allowBinary) const
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1654 {
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1655 std::string s;
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1656 if (LookupStringValue(s, tag, allowBinary))
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1657 {
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1658 return s;
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1659 }
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1660 else
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1661 {
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1662 return defaultValue;
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1663 }
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1664 }
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1665
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1666
3551
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1667 void DicomMap::RemoveBinaryTags()
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1668 {
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1669 Content kept;
3551
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1670
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1671 for (Content::iterator it = content_.begin(); it != content_.end(); ++it)
3551
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1672 {
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1673 assert(it->second != NULL);
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1674
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1675 if (!it->second->IsBinary() &&
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1676 !it->second->IsNull())
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1677 {
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1678 kept[it->first] = it->second;
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1679 }
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1680 else
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1681 {
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1682 delete it->second;
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1683 }
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1684 }
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1685
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1686 content_ = kept;
3551
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1687 }
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1688
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3518
diff changeset
1689
5044
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1690 void DicomMap::RemoveSequences()
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1691 {
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1692 Content kept;
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1693
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1694 for (Content::iterator it = content_.begin(); it != content_.end(); ++it)
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1695 {
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1696 assert(it->second != NULL);
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1697
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1698 if (!it->second->IsSequence())
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1699 {
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1700 kept[it->first] = it->second;
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1701 }
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1702 else
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1703 {
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1704 delete it->second;
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1705 }
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1706 }
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1707
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1708 content_ = kept;
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1709 }
6fed78e13233 Refactored DicomMap to handle sequences when needed
Alain Mazy <am@osimis.io>
parents: 5040
diff changeset
1710
3650
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1711 void DicomMap::DumpMainDicomTags(Json::Value& target,
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1712 ResourceType level) const
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1713 {
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
1714 const std::set<DicomTag>& mainDicomTags = DicomMap::MainDicomTagsConfiguration::GetInstance().GetMainDicomTagsByLevel(level);
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1715
3650
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1716 target = Json::objectValue;
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1717
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1718 for (Content::const_iterator it = content_.begin(); it != content_.end(); ++it)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1719 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1720 assert(it->second != NULL);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1721
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1722 if (!it->second->IsBinary() &&
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1723 !it->second->IsNull())
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1724 {
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
1725 std::set<DicomTag>::const_iterator found = mainDicomTags.find(it->first);
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1726
4932
b7ce2bb6b881 refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
Alain Mazy <am@osimis.io>
parents: 4870
diff changeset
1727 if (found != mainDicomTags.end())
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1728 {
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
1729 #if ORTHANC_ENABLE_DCMTK == 1
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
1730 target[FromDcmtkBridge::GetTagName(*found, "")] = it->second->GetContent();
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
1731 #else
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
1732 target[found->Format()] = it->second->GetContent();
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
1733 #endif
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1734 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1735 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3650
diff changeset
1736 }
3650
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1737 }
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1738
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1739
5040
1c08cd68250a removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
Alain Mazy <am@osimis.io>
parents: 5038
diff changeset
1740
3650
e5811a9f8df0 removing DicomMap::LoadMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1741
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1742 void DicomMap::Print(FILE* fp) const
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1743 {
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1744 DicomArray a(*this);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1745 a.Print(fp);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3498
diff changeset
1746 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1747 }