Mercurial > hg > orthanc
annotate Core/DicomNetworking/Internals/FindScp.cpp @ 3539:f25e84cc5f87
fix ordered-slices
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Tue, 15 Oct 2019 12:57:16 +0200 |
parents | 1bcc35e4615a |
children | 94f4a18a79cc |
rev | line source |
---|---|
0 | 1 /** |
62 | 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:
941
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
3060
4e43e67f8ecf
preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2954
diff
changeset
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
136 | 11 * |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
0 | 23 * |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
766
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
34 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
35 /*========================================================================= |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
36 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
37 This file is based on portions of the following project: |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
38 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
39 Program: DCMTK 3.6.0 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
40 Module: http://dicom.offis.de/dcmtk.php.en |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
41 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
42 Copyright (C) 1994-2011, OFFIS e.V. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
43 All rights reserved. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
44 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
45 This software and supporting documentation were developed by |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
46 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
47 OFFIS e.V. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
48 R&D Division Health |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
49 Escherweg 2 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
50 26121 Oldenburg, Germany |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
51 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
52 Redistribution and use in source and binary forms, with or without |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
53 modification, are permitted provided that the following conditions |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
54 are met: |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
55 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
56 - Redistributions of source code must retain the above copyright |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
57 notice, this list of conditions and the following disclaimer. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
58 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
59 - Redistributions in binary form must reproduce the above copyright |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
60 notice, this list of conditions and the following disclaimer in the |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
61 documentation and/or other materials provided with the distribution. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
62 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
63 - Neither the name of OFFIS nor the names of its contributors may be |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
64 used to endorse or promote products derived from this software |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
65 without specific prior written permission. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
66 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
67 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
68 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
69 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
70 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
71 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
72 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
73 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
74 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
75 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
76 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
77 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
78 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
79 =========================================================================*/ |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
80 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
81 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
722
diff
changeset
|
82 |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
83 #include "../../PrecompiledHeaders.h" |
0 | 84 #include "FindScp.h" |
85 | |
3451 | 86 #include "../../DicomFormat/DicomArray.h" |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
87 #include "../../DicomParsing/FromDcmtkBridge.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
88 #include "../../DicomParsing/ToDcmtkBridge.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
89 #include "../../Logging.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
90 #include "../../OrthancException.h" |
0 | 91 |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1786
diff
changeset
|
92 #include <dcmtk/dcmdata/dcfilefo.h> |
2204
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
93 #include <dcmtk/dcmdata/dcdeftag.h> |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
94 |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
95 |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
96 |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
97 /** |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
98 * The function below is extracted from DCMTK 3.6.0, cf. file |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
99 * "dcmtk-3.6.0/dcmwlm/libsrc/wldsfs.cc". |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
100 **/ |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
101 |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
102 static void HandleExistentButEmptyReferencedStudyOrPatientSequenceAttributes(DcmDataset *dataset, |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
103 const DcmTagKey &sequenceTagKey) |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
104 // Date : May 3, 2005 |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
105 // Author : Thomas Wilkens |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
106 // Task : This function performs a check on a sequence attribute in the given dataset. At two different places |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
107 // in the definition of the DICOM worklist management service, a sequence attribute with a return type |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
108 // of 2 is mentioned containing two 1C attributes in its item; the condition of the two 1C attributes |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
109 // specifies that in case a sequence item is present, then these two attributes must be existent and |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
110 // must contain a value. (I am talking about ReferencedStudySequence and ReferencedPatientSequence.) |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
111 // In cases where the sequence attribute contains exactly one item with an empty ReferencedSOPClass |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
112 // and an empty ReferencedSOPInstance, we want to remove the item from the sequence. This is what |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
113 // this function does. |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
114 // Parameters : dataset - [in] Dataset in which the consistency of the sequence attribute shall be checked. |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
115 // sequenceTagKey - [in] DcmTagKey of the sequence attribute which shall be checked. |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
116 // Return Value : none. |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
117 { |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
118 DcmElement *sequenceAttribute = NULL, *referencedSOPClassUIDAttribute = NULL, *referencedSOPInstanceUIDAttribute = NULL; |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
119 |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
120 // in case the sequence attribute contains exactly one item with an empty |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
121 // ReferencedSOPClassUID and an empty ReferencedSOPInstanceUID, remove the item |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
122 if( dataset->findAndGetElement( sequenceTagKey, sequenceAttribute ).good() && |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
123 ( (DcmSequenceOfItems*)sequenceAttribute )->card() == 1 && |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
124 ( (DcmSequenceOfItems*)sequenceAttribute )->getItem(0)->findAndGetElement( DCM_ReferencedSOPClassUID, referencedSOPClassUIDAttribute ).good() && |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
125 referencedSOPClassUIDAttribute->getLength() == 0 && |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
126 ( (DcmSequenceOfItems*)sequenceAttribute )->getItem(0)->findAndGetElement( DCM_ReferencedSOPInstanceUID, referencedSOPInstanceUIDAttribute, OFFalse ).good() && |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
127 referencedSOPInstanceUIDAttribute->getLength() == 0 ) |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
128 { |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
129 DcmItem *item = ((DcmSequenceOfItems*)sequenceAttribute)->remove( ((DcmSequenceOfItems*)sequenceAttribute)->getItem(0) ); |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
130 delete item; |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
131 } |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
132 } |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
133 |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
134 |
0 | 135 |
62 | 136 namespace Orthanc |
0 | 137 { |
138 namespace | |
139 { | |
140 struct FindScpData | |
141 { | |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2256
diff
changeset
|
142 DicomServer::IRemoteModalities* modalities_; |
1786
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
143 IFindRequestHandler* findHandler_; |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
144 IWorklistRequestHandler* worklistHandler_; |
0 | 145 DicomFindAnswers answers_; |
146 DcmDataset* lastRequest_; | |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
147 const std::string* remoteIp_; |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
148 const std::string* remoteAet_; |
1799
4f01c9d73f02
calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
149 const std::string* calledAet_; |
2059 | 150 |
151 FindScpData() : answers_(false) | |
152 { | |
153 } | |
0 | 154 }; |
155 | |
156 | |
2204
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
157 |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
158 static void FixWorklistQuery(ParsedDicomFile& query) |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
159 { |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
160 // TODO: Check out |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
161 // WlmDataSourceFileSystem::HandleExistentButEmptyDescriptionAndCodeSequenceAttributes()" |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
162 // in DCMTK 3.6.0 |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
163 |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
164 DcmDataset* dataset = query.GetDcmtkObject().getDataset(); |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
165 HandleExistentButEmptyReferencedStudyOrPatientSequenceAttributes(dataset, DCM_ReferencedStudySequence); |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
166 HandleExistentButEmptyReferencedStudyOrPatientSequenceAttributes(dataset, DCM_ReferencedPatientSequence); |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
167 } |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
168 |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
169 |
3108
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
170 static void FixFindQuery(DicomMap& target, |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
171 const DicomMap& source) |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
172 { |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
173 // "The definition of a Data Set in PS3.5 specifically excludes |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
174 // the range of groups below group 0008, and this includes in |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
175 // particular Meta Information Header elements such as Transfer |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
176 // Syntax UID (0002,0010)." |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
177 // http://dicom.nema.org/medical/dicom/current/output/chtml/part04/sect_C.4.html#sect_C.4.1.1.3 |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
178 // https://groups.google.com/d/msg/orthanc-users/D3kpPuX8yV0/_zgHOzkMEQAJ |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
179 |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
180 DicomArray a(source); |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
181 |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
182 for (size_t i = 0; i < a.GetSize(); i++) |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
183 { |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
184 if (a.GetElement(i).GetTag().GetGroup() >= 0x0008) |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
185 { |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
186 target.SetValue(a.GetElement(i).GetTag(), a.GetElement(i).GetValue()); |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
187 } |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
188 } |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
189 } |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
190 |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
191 |
2204
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
192 |
0 | 193 void FindScpCallback( |
194 /* in */ | |
195 void *callbackData, | |
196 OFBool cancelled, | |
197 T_DIMSE_C_FindRQ *request, | |
198 DcmDataset *requestIdentifiers, | |
199 int responseCount, | |
200 /* out */ | |
201 T_DIMSE_C_FindRSP *response, | |
202 DcmDataset **responseIdentifiers, | |
203 DcmDataset **statusDetail) | |
204 { | |
205 bzero(response, sizeof(T_DIMSE_C_FindRSP)); | |
206 *statusDetail = NULL; | |
207 | |
1786
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
208 std::string sopClassUid(request->AffectedSOPClassUID); |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
209 |
656 | 210 FindScpData& data = *reinterpret_cast<FindScpData*>(callbackData); |
0 | 211 if (data.lastRequest_ == NULL) |
212 { | |
1786
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
213 bool ok = false; |
0 | 214 |
215 try | |
216 { | |
2256
de1ba22fd28a
simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
217 RemoteModalityParameters modality; |
de1ba22fd28a
simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
218 |
de1ba22fd28a
simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
219 /** |
de1ba22fd28a
simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
220 * Ensure that the remote modality is known to Orthanc for C-FIND requests. |
de1ba22fd28a
simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
221 **/ |
de1ba22fd28a
simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
222 |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2256
diff
changeset
|
223 assert(data.modalities_ != NULL); |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2256
diff
changeset
|
224 if (!data.modalities_->LookupAETitle(modality, *data.remoteAet_)) |
2256
de1ba22fd28a
simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
225 { |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
226 throw OrthancException(ErrorCode_UnknownModality, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
227 "Modality with AET \"" + (*data.remoteAet_) + |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
228 "\" is not defined in the \"DicomModalities\" configuration option"); |
2256
de1ba22fd28a
simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
229 } |
de1ba22fd28a
simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
230 |
de1ba22fd28a
simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
231 |
1786
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
232 if (sopClassUid == UID_FINDModalityWorklistInformationModel) |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
233 { |
2059 | 234 data.answers_.SetWorklist(true); |
235 | |
1786
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
236 if (data.worklistHandler_ != NULL) |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
237 { |
1788
6a2d507ef064
getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
238 ParsedDicomFile query(*requestIdentifiers); |
2204
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
239 FixWorklistQuery(query); |
0158f2de8cad
Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
240 |
1800
30e97a1f4093
callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1799
diff
changeset
|
241 data.worklistHandler_->Handle(data.answers_, query, |
30e97a1f4093
callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1799
diff
changeset
|
242 *data.remoteIp_, *data.remoteAet_, |
2256
de1ba22fd28a
simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
243 *data.calledAet_, modality.GetManufacturer()); |
1786
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
244 ok = true; |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
245 } |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
246 else |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
247 { |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
248 LOG(ERROR) << "No worklist handler is installed, cannot handle this C-FIND request"; |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
249 } |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
250 } |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
251 else |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
252 { |
2059 | 253 data.answers_.SetWorklist(false); |
254 | |
1786
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
255 if (data.findHandler_ != NULL) |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
256 { |
1859
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
257 std::list<DicomTag> sequencesToReturn; |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
258 |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
259 for (unsigned long i = 0; i < requestIdentifiers->card(); i++) |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
260 { |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
261 DcmElement* element = requestIdentifiers->getElement(i); |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
262 if (element && !element->isLeaf()) |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
263 { |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
264 const DicomTag tag(FromDcmtkBridge::Convert(element->getTag())); |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
265 |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
266 DcmSequenceOfItems& sequence = dynamic_cast<DcmSequenceOfItems&>(*element); |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
267 if (sequence.card() != 0) |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
268 { |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
269 LOG(WARNING) << "Orthanc only supports sequence matching on worklists, " |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
270 << "ignoring C-FIND SCU constraint on tag (" << tag.Format() |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2059
diff
changeset
|
271 << ") " << FromDcmtkBridge::GetTagName(*element); |
1859
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
272 } |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
273 |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
274 sequencesToReturn.push_back(tag); |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
275 } |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
276 } |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
277 |
1786
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
278 DicomMap input; |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2256
diff
changeset
|
279 FromDcmtkBridge::ExtractDicomSummary(input, *requestIdentifiers); |
2125 | 280 |
3108
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
281 DicomMap filtered; |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
282 FixFindQuery(filtered, input); |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
283 |
55dacaf139ed
Don't consider tags whose group is below 0x0008 in C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
284 data.findHandler_->Handle(data.answers_, filtered, sequencesToReturn, |
1800
30e97a1f4093
callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1799
diff
changeset
|
285 *data.remoteIp_, *data.remoteAet_, |
2256
de1ba22fd28a
simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
286 *data.calledAet_, modality.GetManufacturer()); |
1786
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
287 ok = true; |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
288 } |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
289 else |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
290 { |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
291 LOG(ERROR) << "No C-Find handler is installed, cannot handle this request"; |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
292 } |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
293 } |
0 | 294 } |
62 | 295 catch (OrthancException& e) |
0 | 296 { |
297 // Internal error! | |
941
83489fddd8c5
Options to limit the number of results for an incoming C-FIND query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
298 LOG(ERROR) << "C-FIND request handler has failed: " << e.What(); |
1786
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
299 } |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
300 |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
301 if (!ok) |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
302 { |
0 | 303 response->DimseStatus = STATUS_FIND_Failed_UnableToProcess; |
304 *responseIdentifiers = NULL; | |
305 return; | |
306 } | |
307 | |
308 data.lastRequest_ = requestIdentifiers; | |
309 } | |
310 else if (data.lastRequest_ != requestIdentifiers) | |
311 { | |
312 // Internal error! | |
313 response->DimseStatus = STATUS_FIND_Failed_UnableToProcess; | |
314 *responseIdentifiers = NULL; | |
315 return; | |
316 } | |
722 | 317 |
0 | 318 if (responseCount <= static_cast<int>(data.answers_.GetSize())) |
319 { | |
941
83489fddd8c5
Options to limit the number of results for an incoming C-FIND query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
320 // There are pending results that are still to be sent |
0 | 321 response->DimseStatus = STATUS_Pending; |
1789 | 322 *responseIdentifiers = data.answers_.ExtractDcmDataset(responseCount - 1); |
0 | 323 } |
1800
30e97a1f4093
callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1799
diff
changeset
|
324 else if (data.answers_.IsComplete()) |
941
83489fddd8c5
Options to limit the number of results for an incoming C-FIND query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
325 { |
83489fddd8c5
Options to limit the number of results for an incoming C-FIND query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
326 // Success: All the results have been sent |
83489fddd8c5
Options to limit the number of results for an incoming C-FIND query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
327 response->DimseStatus = STATUS_Success; |
83489fddd8c5
Options to limit the number of results for an incoming C-FIND query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
328 *responseIdentifiers = NULL; |
83489fddd8c5
Options to limit the number of results for an incoming C-FIND query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
329 } |
0 | 330 else |
331 { | |
941
83489fddd8c5
Options to limit the number of results for an incoming C-FIND query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
332 // Success, but the results were too numerous and had to be cropped |
83489fddd8c5
Options to limit the number of results for an incoming C-FIND query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
333 LOG(WARNING) << "Too many results for an incoming C-FIND query"; |
83489fddd8c5
Options to limit the number of results for an incoming C-FIND query
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
334 response->DimseStatus = STATUS_FIND_Cancel_MatchingTerminatedDueToCancelRequest; |
0 | 335 *responseIdentifiers = NULL; |
336 } | |
337 } | |
338 } | |
339 | |
340 | |
341 OFCondition Internals::findScp(T_ASC_Association * assoc, | |
342 T_DIMSE_Message * msg, | |
343 T_ASC_PresentationContextID presID, | |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2256
diff
changeset
|
344 DicomServer::IRemoteModalities& modalities, |
1786
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
345 IFindRequestHandler* findHandler, |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
346 IWorklistRequestHandler* worklistHandler, |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
347 const std::string& remoteIp, |
1799
4f01c9d73f02
calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
348 const std::string& remoteAet, |
4f01c9d73f02
calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
349 const std::string& calledAet) |
0 | 350 { |
351 FindScpData data; | |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2256
diff
changeset
|
352 data.modalities_ = &modalities; |
1786
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
353 data.findHandler_ = findHandler; |
164d78911382
primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
354 data.worklistHandler_ = worklistHandler; |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2256
diff
changeset
|
355 data.lastRequest_ = NULL; |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
356 data.remoteIp_ = &remoteIp; |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
357 data.remoteAet_ = &remoteAet; |
1799
4f01c9d73f02
calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
358 data.calledAet_ = &calledAet; |
0 | 359 |
360 OFCondition cond = DIMSE_findProvider(assoc, presID, &msg->msg.CFindRQ, | |
361 FindScpCallback, &data, | |
362 /*opt_blockMode*/ DIMSE_BLOCKING, | |
363 /*opt_dimse_timeout*/ 0); | |
364 | |
365 // if some error occured, dump corresponding information and remove the outfile if necessary | |
366 if (cond.bad()) | |
367 { | |
368 OFString temp_str; | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
369 LOG(ERROR) << "Find SCP Failed: " << cond.text(); |
0 | 370 } |
371 | |
372 return cond; | |
373 } | |
374 } |