Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Oracle/ParseDicomFromWadoCommand.cpp @ 1650:af312e145980
more tests for CoordinateSystem3D
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 13 Nov 2020 10:44:11 +0100 |
parents | 59f95b9ea858 |
children | 0257339b0884 |
rev | line source |
---|---|
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
1271
0ca50d275b9a
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1151
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
16 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 **/ |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 #include "ParseDicomFromWadoCommand.h" |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1271
diff
changeset
|
25 #include <OrthancException.h> |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
1624 | 27 #include <cassert> |
28 | |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 namespace OrthancStone |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 { |
1484
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
31 ParseDicomFromWadoCommand::ParseDicomFromWadoCommand(const DicomSource& source, |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
32 const std::string& sopInstanceUid, |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 IOracleCommand* restCommand) : |
1484
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
34 source_(source), |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 sopInstanceUid_(sopInstanceUid), |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 restCommand_(restCommand) |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 { |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 if (restCommand == NULL) |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 { |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 } |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 if (restCommand_->GetType() != Type_Http && |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 restCommand_->GetType() != Type_OrthancRestApi) |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 { |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadParameterType); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 } |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 } |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 IOracleCommand* ParseDicomFromWadoCommand::Clone() const |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 { |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 assert(restCommand_.get() != NULL); |
1484
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
54 return new ParseDicomFromWadoCommand(source_, sopInstanceUid_, restCommand_->Clone()); |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 } |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 const IOracleCommand& ParseDicomFromWadoCommand::GetRestCommand() const |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 { |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 assert(restCommand_.get() != NULL); |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 return *restCommand_; |
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 } |
1484
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
63 |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
64 |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
65 ParseDicomFromWadoCommand* ParseDicomFromWadoCommand::Create( |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
66 const DicomSource& source, |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
67 const std::string& studyInstanceUid, |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
68 const std::string& seriesInstanceUid, |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
69 const std::string& sopInstanceUid, |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
70 bool transcode, |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
71 Orthanc::DicomTransferSyntax transferSyntax, |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
72 Orthanc::IDynamicObject* payload) |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
73 { |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
74 std::unique_ptr<Orthanc::IDynamicObject> protection(payload); |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
75 |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
76 const std::string uri = ("/studies/" + studyInstanceUid + |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
77 "/series/" + seriesInstanceUid + |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
78 "/instances/" + sopInstanceUid); |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
79 |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
80 std::string s; |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
81 if (transcode) |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
82 { |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
83 s = Orthanc::GetTransferSyntaxUid(transferSyntax); |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
84 } |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
85 else |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
86 { |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
87 s = "*"; // No transcoding, keep source transfer syntax |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
88 } |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
89 |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
90 std::map<std::string, std::string> arguments, headers; |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
91 headers["Accept"] = ("multipart/related; type=\"application/dicom\"; transfer-syntax=" + s); |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
92 |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
93 std::unique_ptr<IOracleCommand> rest( |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
94 source.CreateDicomWebCommand(uri, arguments, headers, NULL)); |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
95 |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
96 std::unique_ptr<ParseDicomFromWadoCommand> command( |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
97 new ParseDicomFromWadoCommand(source, sopInstanceUid, rest.release())); |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
98 |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
99 if (protection.get() != NULL) |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
100 { |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
101 command->AcquirePayload(protection.release()); |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
102 } |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
103 |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
104 return command.release(); |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
105 } |
1151
48befc2bf66d
ParseDicomFromWadoCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 } |