Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomParsing/DicomDirWriter.cpp @ 4683:7182f5732480
use of DicomPath in ParsedDicomFile
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 08 Jun 2021 12:37:48 +0200 |
parents | b6818bbef7b8 |
children | 7053502fbf97 |
rev | line source |
---|---|
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1130
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4203
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * 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
|
8 * 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
|
9 * 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
|
10 * the License, or (at your option) any later version. |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * 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
|
15 * Lesser General Public License for more details. |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
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
|
17 * 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
|
18 * 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
|
19 * <http://www.gnu.org/licenses/>. |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 **/ |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 /*========================================================================= |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 This file is based on portions of the following project: |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 Program: DCMTK 3.6.0 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 Module: http://dicom.offis.de/dcmtk.php.en |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 Copyright (C) 1994-2011, OFFIS e.V. |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 All rights reserved. |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 This software and supporting documentation were developed by |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 OFFIS e.V. |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 R&D Division Health |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 Escherweg 2 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 26121 Oldenburg, Germany |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 Redistribution and use in source and binary forms, with or without |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 modification, are permitted provided that the following conditions |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 are met: |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 - Redistributions of source code must retain the above copyright |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 notice, this list of conditions and the following disclaimer. |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 - Redistributions in binary form must reproduce the above copyright |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 notice, this list of conditions and the following disclaimer in the |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 documentation and/or other materials provided with the distribution. |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 - Neither the name of OFFIS nor the names of its contributors may be |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 used to endorse or promote products derived from this software |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 without specific prior written permission. |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 =========================================================================*/ |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 /*** |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 Validation: |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 # sudo apt-get install dicom3tools |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 # dciodvfy DICOMDIR 2>&1 | less |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 # dcentvfy DICOMDIR 2>&1 | less |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 http://www.dclunie.com/dicom3tools/dciodvfy.html |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 DICOMDIR viewer working with Wine under Linux: |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 http://www.microdicom.com/ |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 ***/ |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
90 #include "../PrecompiledHeaders.h" |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 #include "DicomDirWriter.h" |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 #include "FromDcmtkBridge.h" |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 #include "ToDcmtkBridge.h" |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
96 #include "../Compatibility.h" |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
97 #include "../Logging.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
98 #include "../OrthancException.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
99 #include "../TemporaryFile.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
100 #include "../Toolbox.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
101 #include "../SystemToolbox.h" |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 #include <dcmtk/dcmdata/dcdicdir.h> |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 #include <dcmtk/dcmdata/dcmetinf.h> |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 #include <dcmtk/dcmdata/dcdeftag.h> |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 #include <dcmtk/dcmdata/dcuid.h> |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 #include <dcmtk/dcmdata/dcddirif.h> |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 #include <dcmtk/dcmdata/dcvrui.h> |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 #include <dcmtk/dcmdata/dcsequen.h> |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 #include <dcmtk/dcmdata/dcostrmf.h> |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 #include "dcmtk/dcmdata/dcvrda.h" /* for class DcmDate */ |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 #include "dcmtk/dcmdata/dcvrtm.h" /* for class DcmTime */ |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 #include <memory> |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 namespace Orthanc |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 class DicomDirWriter::PImpl |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 private: |
2475
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
121 bool utc_; |
2422
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
122 std::string fileSetId_; |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
123 bool extendedSopClass_; |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
124 TemporaryFile file_; |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
125 std::unique_ptr<DcmDicomDir> dir_; |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 typedef std::pair<ResourceType, std::string> IndexKey; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 typedef std::map<IndexKey, DcmDirectoryRecord* > Index; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 Index index_; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 DcmDicomDir& GetDicomDir() |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 if (dir_.get() == NULL) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 dir_.reset(new DcmDicomDir(file_.GetPath().c_str(), |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 fileSetId_.c_str())); |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
138 //SetTagValue(dir_->getRootRecord(), DCM_SpecificCharacterSet, GetDicomSpecificCharacterSet(Encoding_Utf8)); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 return *dir_; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 DcmDirectoryRecord& GetRoot() |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 return GetDicomDir().getRootRecord(); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
151 static bool GetUtf8TagValue(std::string& result, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
152 DcmItem& source, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
153 Encoding encoding, |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
154 bool hasCodeExtensions, |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
155 const DcmTagKey& key) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
156 { |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
157 DcmElement* element = NULL; |
2571
a84ce82fd55b
Fix generation of DICOMDIR if PatientID is empty
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
158 result.clear(); |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
159 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
160 if (source.findAndGetElement(key, element).good()) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
161 { |
1893 | 162 char* s = NULL; |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
163 if (element->isLeaf() && |
2571
a84ce82fd55b
Fix generation of DICOMDIR if PatientID is empty
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
164 element->getString(s).good()) |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
165 { |
2571
a84ce82fd55b
Fix generation of DICOMDIR if PatientID is empty
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
166 if (s != NULL) |
a84ce82fd55b
Fix generation of DICOMDIR if PatientID is empty
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
167 { |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
168 result = Toolbox::ConvertToUtf8(s, encoding, hasCodeExtensions); |
2571
a84ce82fd55b
Fix generation of DICOMDIR if PatientID is empty
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
169 } |
a84ce82fd55b
Fix generation of DICOMDIR if PatientID is empty
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2475
diff
changeset
|
170 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
171 return true; |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
172 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
173 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
174 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
175 return false; |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
176 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
177 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
178 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
179 static void SetTagValue(DcmDirectoryRecord& target, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
180 const DcmTagKey& key, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
181 const std::string& valueUtf8) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
182 { |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
183 std::string s = Toolbox::ConvertFromUtf8(valueUtf8, Encoding_Ascii); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
184 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
185 if (!target.putAndInsertString(key, s.c_str()).good()) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
186 { |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
187 throw OrthancException(ErrorCode_InternalError); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
188 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
189 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
190 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
191 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
192 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
193 static bool CopyString(DcmDirectoryRecord& target, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
194 DcmDataset& source, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
195 Encoding encoding, |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
196 bool hasCodeExtensions, |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
197 const DcmTagKey& key, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
198 bool optional, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
199 bool copyEmpty) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
200 { |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
201 if (optional && |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
202 !source.tagExistsWithValue(key) && |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
203 !(copyEmpty && source.tagExists(key))) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
204 { |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
205 return false; |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
206 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
207 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
208 std::string value; |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
209 bool found = GetUtf8TagValue(value, source, encoding, hasCodeExtensions, key); |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
210 |
2421
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
211 if (!found) |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
212 { |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
213 // We don't raise an exception if "!optional", even if this |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
214 // results in an invalid DICOM file |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
215 value.clear(); |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
216 } |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
217 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
218 SetTagValue(target, key, value); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
219 return found; |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
220 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
221 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
222 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
223 static void CopyStringType1(DcmDirectoryRecord& target, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
224 DcmDataset& source, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
225 Encoding encoding, |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
226 bool hasCodeExtensions, |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
227 const DcmTagKey& key) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
228 { |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
229 CopyString(target, source, encoding, hasCodeExtensions, key, false, false); |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
230 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
231 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
232 static void CopyStringType1C(DcmDirectoryRecord& target, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
233 DcmDataset& source, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
234 Encoding encoding, |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
235 bool hasCodeExtensions, |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
236 const DcmTagKey& key) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
237 { |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
238 CopyString(target, source, encoding, hasCodeExtensions, key, true, false); |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
239 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
240 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
241 static void CopyStringType2(DcmDirectoryRecord& target, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
242 DcmDataset& source, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
243 Encoding encoding, |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
244 bool hasCodeExtensions, |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
245 const DcmTagKey& key) |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
246 { |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
247 CopyString(target, source, encoding, hasCodeExtensions, key, false, true); |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
248 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
249 |
2421
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
250 static void CopyStringType3(DcmDirectoryRecord& target, |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
251 DcmDataset& source, |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
252 Encoding encoding, |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
253 bool hasCodeExtensions, |
2421
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
254 const DcmTagKey& key) |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
255 { |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
256 CopyString(target, source, encoding, hasCodeExtensions, key, true, true); |
2421
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
257 } |
d0fe5ec7eb05
playing with dicomdir
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
258 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
259 |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
260 public: |
2422
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
261 PImpl() : |
2475
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
262 utc_(true), // By default, use UTC (universal time, not local time) |
2422
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
263 fileSetId_("ORTHANC_MEDIA"), |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
264 extendedSopClass_(false) |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
265 { |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
266 } |
2475
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
267 |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
268 bool IsUtcUsed() const |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
269 { |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
270 return utc_; |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
271 } |
2422
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
272 |
2475
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
273 |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
274 void SetUtcUsed(bool utc) |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
275 { |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
276 utc_ = utc; |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
277 } |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
278 |
2422
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
279 void EnableExtendedSopClass(bool enable) |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
280 { |
2422
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
281 if (enable) |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
282 { |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
283 LOG(WARNING) << "Generating a DICOMDIR with type 3 attributes, " |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
284 << "which leads to an Extended SOP Class"; |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
285 } |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
286 |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
287 extendedSopClass_ = enable; |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
288 } |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
289 |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
290 bool IsExtendedSopClass() const |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
291 { |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
292 return extendedSopClass_; |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
293 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
294 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
295 void FillPatient(DcmDirectoryRecord& record, |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
296 DcmDataset& dicom, |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
297 Encoding encoding, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
298 bool hasCodeExtensions) |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
299 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
300 // cf. "DicomDirInterface::buildPatientRecord()" |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
301 |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
302 CopyStringType1C(record, dicom, encoding, hasCodeExtensions, DCM_PatientID); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
303 CopyStringType2(record, dicom, encoding, hasCodeExtensions, DCM_PatientName); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
304 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
305 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
306 void FillStudy(DcmDirectoryRecord& record, |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
307 DcmDataset& dicom, |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
308 Encoding encoding, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
309 bool hasCodeExtensions) |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
310 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
311 // cf. "DicomDirInterface::buildStudyRecord()" |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
312 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
313 std::string nowDate, nowTime; |
2475
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
314 SystemToolbox::GetNowDicom(nowDate, nowTime, utc_); |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
315 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
316 std::string studyDate; |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
317 if (!GetUtf8TagValue(studyDate, dicom, encoding, hasCodeExtensions, DCM_StudyDate) && |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
318 !GetUtf8TagValue(studyDate, dicom, encoding, hasCodeExtensions, DCM_SeriesDate) && |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
319 !GetUtf8TagValue(studyDate, dicom, encoding, hasCodeExtensions, DCM_AcquisitionDate) && |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
320 !GetUtf8TagValue(studyDate, dicom, encoding, hasCodeExtensions, DCM_ContentDate)) |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
321 { |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
322 studyDate = nowDate; |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
323 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
324 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
325 std::string studyTime; |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
326 if (!GetUtf8TagValue(studyTime, dicom, encoding, hasCodeExtensions, DCM_StudyTime) && |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
327 !GetUtf8TagValue(studyTime, dicom, encoding, hasCodeExtensions, DCM_SeriesTime) && |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
328 !GetUtf8TagValue(studyTime, dicom, encoding, hasCodeExtensions, DCM_AcquisitionTime) && |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
329 !GetUtf8TagValue(studyTime, dicom, encoding, hasCodeExtensions, DCM_ContentTime)) |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
330 { |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
331 studyTime = nowTime; |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
332 } |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
333 |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
334 /* copy attribute values from dataset to study record */ |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
335 SetTagValue(record, DCM_StudyDate, studyDate); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
336 SetTagValue(record, DCM_StudyTime, studyTime); |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
337 CopyStringType2(record, dicom, encoding, hasCodeExtensions, DCM_StudyDescription); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
338 CopyStringType1(record, dicom, encoding, hasCodeExtensions, DCM_StudyInstanceUID); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
339 /* use type 1C instead of 1 in order to avoid unwanted overwriting */ |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
340 CopyStringType1C(record, dicom, encoding, hasCodeExtensions, DCM_StudyID); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
341 CopyStringType2(record, dicom, encoding, hasCodeExtensions, DCM_AccessionNumber); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
342 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
343 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
344 void FillSeries(DcmDirectoryRecord& record, |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
345 DcmDataset& dicom, |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
346 Encoding encoding, |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
347 bool hasCodeExtensions) |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
348 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
349 // cf. "DicomDirInterface::buildSeriesRecord()" |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
350 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
351 /* copy attribute values from dataset to series record */ |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
352 CopyStringType1(record, dicom, encoding, hasCodeExtensions, DCM_Modality); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
353 CopyStringType1(record, dicom, encoding, hasCodeExtensions, DCM_SeriesInstanceUID); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
354 /* use type 1C instead of 1 in order to avoid unwanted overwriting */ |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
355 CopyStringType1C(record, dicom, encoding, hasCodeExtensions, DCM_SeriesNumber); |
2422
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
356 |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
357 // Add extended (non-standard) type 3 tags, those are not generated by DCMTK |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
358 // http://dicom.nema.org/medical/Dicom/2016a/output/chtml/part02/sect_7.3.html |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
359 // https://groups.google.com/d/msg/orthanc-users/Y7LOvZMDeoc/9cp3kDgxAwAJ |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
360 if (extendedSopClass_) |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
361 { |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
362 CopyStringType3(record, dicom, encoding, hasCodeExtensions, DCM_SeriesDescription); |
2422
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
363 } |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
364 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
365 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
366 void FillInstance(DcmDirectoryRecord& record, |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
367 DcmDataset& dicom, |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
368 Encoding encoding, |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
369 bool hasCodeExtensions, |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
370 DcmMetaInfo& metaInfo, |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
371 const char* path) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
372 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
373 // cf. "DicomDirInterface::buildImageRecord()" |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
374 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
375 /* copy attribute values from dataset to image record */ |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
376 CopyStringType1(record, dicom, encoding, hasCodeExtensions, DCM_InstanceNumber); |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
377 //CopyElementType1C(record, dicom, encoding, hasCodeExtensions, DCM_ImageType); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
378 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
379 // REMOVED since 0.9.7: copyElementType1C(dicom, DCM_ReferencedImageSequence, record); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
380 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
381 std::string sopClassUid, sopInstanceUid, transferSyntaxUid; |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
382 if (!GetUtf8TagValue(sopClassUid, dicom, encoding, hasCodeExtensions, DCM_SOPClassUID) || |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
383 !GetUtf8TagValue(sopInstanceUid, dicom, encoding, hasCodeExtensions, DCM_SOPInstanceUID) || |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
384 !GetUtf8TagValue(transferSyntaxUid, metaInfo, encoding, hasCodeExtensions, DCM_TransferSyntaxUID)) |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
385 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
386 throw OrthancException(ErrorCode_BadFileFormat); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
387 } |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
388 |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
389 SetTagValue(record, DCM_ReferencedFileID, path); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
390 SetTagValue(record, DCM_ReferencedSOPClassUIDInFile, sopClassUid); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
391 SetTagValue(record, DCM_ReferencedSOPInstanceUIDInFile, sopInstanceUid); |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
392 SetTagValue(record, DCM_ReferencedTransferSyntaxUIDInFile, transferSyntaxUid); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
393 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
394 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
395 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
396 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
397 bool CreateResource(DcmDirectoryRecord*& target, |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
398 ResourceType level, |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4200
diff
changeset
|
399 ParsedDicomFile& dicom, |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
400 const char* filename, |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
401 const char* path) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
402 { |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
403 DcmDataset& dataset = *dicom.GetDcmtkObject().getDataset(); |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
404 |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
405 bool hasCodeExtensions; |
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
406 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
407 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
408 bool found; |
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
409 std::string id; |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
410 E_DirRecType type; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
411 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
412 switch (level) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
413 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
414 case ResourceType_Patient: |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
415 if (!GetUtf8TagValue(id, dataset, encoding, hasCodeExtensions, DCM_PatientID)) |
3107
554832246eaa
Fix issue #124 (GET /studies/ID/media fails for certain dicom file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
416 { |
554832246eaa
Fix issue #124 (GET /studies/ID/media fails for certain dicom file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
417 // Be tolerant about missing patient ID. Fixes issue #124 |
554832246eaa
Fix issue #124 (GET /studies/ID/media fails for certain dicom file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
418 // (GET /studies/ID/media fails for certain dicom file). |
554832246eaa
Fix issue #124 (GET /studies/ID/media fails for certain dicom file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
419 id = ""; |
554832246eaa
Fix issue #124 (GET /studies/ID/media fails for certain dicom file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
420 } |
554832246eaa
Fix issue #124 (GET /studies/ID/media fails for certain dicom file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
421 |
554832246eaa
Fix issue #124 (GET /studies/ID/media fails for certain dicom file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
422 found = true; |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
423 type = ERT_Patient; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
424 break; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
425 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
426 case ResourceType_Study: |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
427 found = GetUtf8TagValue(id, dataset, encoding, hasCodeExtensions, DCM_StudyInstanceUID); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
428 type = ERT_Study; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
429 break; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
430 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
431 case ResourceType_Series: |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
432 found = GetUtf8TagValue(id, dataset, encoding, hasCodeExtensions, DCM_SeriesInstanceUID); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
433 type = ERT_Series; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
434 break; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
435 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
436 case ResourceType_Instance: |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
437 found = GetUtf8TagValue(id, dataset, encoding, hasCodeExtensions, DCM_SOPInstanceUID); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
438 type = ERT_Image; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
439 break; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
440 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
441 default: |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
442 throw OrthancException(ErrorCode_InternalError); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
443 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
444 |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
445 if (!found) |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
446 { |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
447 throw OrthancException(ErrorCode_BadFileFormat); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
448 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
449 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
450 IndexKey key = std::make_pair(level, std::string(id.c_str())); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
451 Index::iterator it = index_.find(key); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
452 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
453 if (it != index_.end()) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
454 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
455 target = it->second; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
456 return false; // Already existing |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
457 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
458 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
459 std::unique_ptr<DcmDirectoryRecord> record(new DcmDirectoryRecord(type, NULL, filename)); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
460 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
461 switch (level) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
462 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
463 case ResourceType_Patient: |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
464 FillPatient(*record, dataset, encoding, hasCodeExtensions); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
465 break; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
466 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
467 case ResourceType_Study: |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
468 FillStudy(*record, dataset, encoding, hasCodeExtensions); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
469 break; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
470 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
471 case ResourceType_Series: |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
472 FillSeries(*record, dataset, encoding, hasCodeExtensions); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
473 break; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
474 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
475 case ResourceType_Instance: |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
476 FillInstance(*record, dataset, encoding, hasCodeExtensions, *dicom.GetDcmtkObject().getMetaInfo(), path); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
477 break; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
478 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
479 default: |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
480 throw OrthancException(ErrorCode_InternalError); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
481 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
482 |
3217
cf8cbeb35f33
preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3107
diff
changeset
|
483 CopyStringType1C(*record, dataset, encoding, hasCodeExtensions, DCM_SpecificCharacterSet); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
484 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
485 target = record.get(); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
486 GetRoot().insertSub(record.release()); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
487 index_[key] = target; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
488 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
489 return true; // Newly created |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
490 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
491 |
4471
b6818bbef7b8
patch of DCMTK 3.6.6 to fix value of "MediaStorageSOPClassUID" if writing DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
492 void Write(std::string& s) |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
493 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
494 if (!GetDicomDir().write(DICOMDIR_DEFAULT_TRANSFERSYNTAX, |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
495 EET_UndefinedLength /*encodingType*/, |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
496 EGL_withoutGL /*groupLength*/).good()) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
497 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
498 throw OrthancException(ErrorCode_InternalError); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
499 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
500 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
501 file_.Read(s); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
502 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
503 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
504 void SetFileSetId(const std::string& id) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
505 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
506 dir_.reset(NULL); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
507 fileSetId_ = id; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
508 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
509 }; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
510 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
511 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
512 DicomDirWriter::DicomDirWriter() : pimpl_(new PImpl) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
513 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
514 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
515 |
2475
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
516 void DicomDirWriter::SetUtcUsed(bool utc) |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
517 { |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
518 pimpl_->SetUtcUsed(utc); |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
519 } |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
520 |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
521 bool DicomDirWriter::IsUtcUsed() const |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
522 { |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
523 return pimpl_->IsUtcUsed(); |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
524 } |
8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
525 |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
526 void DicomDirWriter::SetFileSetId(const std::string& id) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
527 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
528 pimpl_->SetFileSetId(id); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
529 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
530 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
531 void DicomDirWriter::Add(const std::string& directory, |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
532 const std::string& filename, |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
533 ParsedDicomFile& dicom) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
534 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
535 std::string path; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
536 if (directory.empty()) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
537 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
538 path = filename; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
539 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
540 else |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
541 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
542 if (directory[directory.length() - 1] == '/' || |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
543 directory[directory.length() - 1] == '\\') |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
544 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
545 throw OrthancException(ErrorCode_ParameterOutOfRange); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
546 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
547 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
548 path = directory + '\\' + filename; |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
549 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
550 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
551 DcmDirectoryRecord* instance; |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
552 bool isNewInstance = pimpl_->CreateResource(instance, ResourceType_Instance, dicom, filename.c_str(), path.c_str()); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
553 if (isNewInstance) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
554 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
555 DcmDirectoryRecord* series; |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
556 bool isNewSeries = pimpl_->CreateResource(series, ResourceType_Series, dicom, filename.c_str(), NULL); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
557 series->insertSub(instance); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
558 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
559 if (isNewSeries) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
560 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
561 DcmDirectoryRecord* study; |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
562 bool isNewStudy = pimpl_->CreateResource(study, ResourceType_Study, dicom, filename.c_str(), NULL); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
563 study->insertSub(series); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
564 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
565 if (isNewStudy) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
566 { |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
567 DcmDirectoryRecord* patient; |
1885
5be57564ffc4
refactoring dicomdir generation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1788
diff
changeset
|
568 pimpl_->CreateResource(patient, ResourceType_Patient, dicom, filename.c_str(), NULL); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
569 patient->insertSub(study); |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
570 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
571 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
572 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
573 } |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
574 |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
575 void DicomDirWriter::Encode(std::string& target) |
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
576 { |
4471
b6818bbef7b8
patch of DCMTK 3.6.6 to fix value of "MediaStorageSOPClassUID" if writing DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
577 pimpl_->Write(target); |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
578 } |
2422
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
579 |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
580 |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
581 void DicomDirWriter::EnableExtendedSopClass(bool enable) |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
582 { |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
583 pimpl_->EnableExtendedSopClass(enable); |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
584 } |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
585 |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
586 |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
587 bool DicomDirWriter::IsExtendedSopClass() const |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
588 { |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
589 return pimpl_->IsExtendedSopClass(); |
b340f0a9022c
New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2421
diff
changeset
|
590 } |
1121
82567bac5e25
Creation of ZIP archives for media storage, with DICOMDIR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
591 } |