annotate OrthancFramework/Sources/DicomNetworking/Internals/FindScp.cpp @ 4224:38d446c9ee1d

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 30 Sep 2020 17:59:09 +0200
parents 4d42408da117
children 756126cd2219
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
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
3640
94f4a18a79cc upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3451
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
3959d33612cc initial commit
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.
136
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 122
diff changeset
11 *
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
3959d33612cc initial commit
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.
0
3959d33612cc initial commit
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/>.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
766
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
23
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
24 /*=========================================================================
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
25
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
26 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
27
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
28 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
29 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
30
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
31 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
32 All rights reserved.
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
33
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
34 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
35
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
36 OFFIS e.V.
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
37 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
38 Escherweg 2
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
39 26121 Oldenburg, Germany
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
40
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
41 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
42 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
43 are met:
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 - 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
46 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
47
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
48 - 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
49 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
50 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
51
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
52 - 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
53 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
54 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
55
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
56 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
57 "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
58 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
59 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
60 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
61 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
62 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
63 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
64 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
65 (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
66 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
67
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
68 =========================================================================*/
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
69
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
70
0a2f8c707c78 Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
71
2382
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2381
diff changeset
72 #include "../../PrecompiledHeaders.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 #include "FindScp.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
3451
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3108
diff changeset
75 #include "../../DicomFormat/DicomArray.h"
2382
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2381
diff changeset
76 #include "../../DicomParsing/FromDcmtkBridge.h"
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2381
diff changeset
77 #include "../../DicomParsing/ToDcmtkBridge.h"
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2381
diff changeset
78 #include "../../Logging.h"
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2381
diff changeset
79 #include "../../OrthancException.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1786
diff changeset
81 #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
82 #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
83
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
84
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
85
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
86 /**
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
87 * 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
88 * "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
89 **/
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
90
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
91 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
92 const DcmTagKey &sequenceTagKey)
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
93 // Date : May 3, 2005
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
94 // Author : Thomas Wilkens
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
95 // 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
96 // 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
97 // 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
98 // 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
99 // 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
100 // 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
101 // 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
102 // this function does.
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
103 // 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
104 // 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
105 // Return Value : none.
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
106 {
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
107 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
108
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
109 // 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
110 // 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
111 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
112 ( (DcmSequenceOfItems*)sequenceAttribute )->card() == 1 &&
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
113 ( (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
114 referencedSOPClassUIDAttribute->getLength() == 0 &&
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
115 ( (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
116 referencedSOPInstanceUIDAttribute->getLength() == 0 )
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 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
119 delete item;
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
120 }
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
121 }
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
122
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
123
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
125 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 namespace
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 struct FindScpData
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 {
2381
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
131 DicomServer::IRemoteModalities* modalities_;
1786
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
132 IFindRequestHandler* findHandler_;
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
133 IWorklistRequestHandler* worklistHandler_;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 DicomFindAnswers answers_;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 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
136 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
137 const std::string* remoteAet_;
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
138 const std::string* calledAet_;
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1929
diff changeset
139
4200
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
140 FindScpData() :
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
141 modalities_(NULL),
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
142 findHandler_(NULL),
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
143 worklistHandler_(NULL),
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
144 answers_(false),
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
145 lastRequest_(NULL),
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
146 remoteIp_(NULL),
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
147 remoteAet_(NULL),
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4137
diff changeset
148 calledAet_(NULL)
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1929
diff changeset
149 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1929
diff changeset
150 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 };
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153
2204
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
154
4203
4d42408da117 improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4200
diff changeset
155 static void FixWorklistQuery(ParsedDicomFile& query)
2204
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
156 {
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
157 // TODO: Check out
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
158 // WlmDataSourceFileSystem::HandleExistentButEmptyDescriptionAndCodeSequenceAttributes()"
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
159 // 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
160
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
161 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
162 HandleExistentButEmptyReferencedStudyOrPatientSequenceAttributes(dataset, DCM_ReferencedStudySequence);
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
163 HandleExistentButEmptyReferencedStudyOrPatientSequenceAttributes(dataset, DCM_ReferencedPatientSequence);
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
164 }
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
165
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
166
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
167 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
168 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
169 {
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 // "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
171 // 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
172 // 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
173 // 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
174 // 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
175 // 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
176
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 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
178
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 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
180 {
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 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
182 {
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 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
184 }
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 }
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
2204
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
189
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 void FindScpCallback(
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 /* in */
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 void *callbackData,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 OFBool cancelled,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 T_DIMSE_C_FindRQ *request,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 DcmDataset *requestIdentifiers,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 int responseCount,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 /* out */
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 T_DIMSE_C_FindRSP *response,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 DcmDataset **responseIdentifiers,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 DcmDataset **statusDetail)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 bzero(response, sizeof(T_DIMSE_C_FindRSP));
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 *statusDetail = NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204
1786
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
205 std::string sopClassUid(request->AffectedSOPClassUID);
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
206
656
08eca5d86aad fixes to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 618
diff changeset
207 FindScpData& data = *reinterpret_cast<FindScpData*>(callbackData);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 if (data.lastRequest_ == NULL)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 {
1786
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
210 bool ok = false;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 try
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 {
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
214 RemoteModalityParameters modality;
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
215
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
216 /**
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
217 * 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
218 **/
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
219
2381
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
220 assert(data.modalities_ != NULL);
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
221 if (!data.modalities_->LookupAETitle(modality, *data.remoteAet_))
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
222 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
223 throw OrthancException(ErrorCode_UnknownModality,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
224 "Modality with AET \"" + (*data.remoteAet_) +
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
225 "\" is not defined in the \"DicomModalities\" configuration option");
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
226 }
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
227
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
228
1786
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
229 if (sopClassUid == UID_FINDModalityWorklistInformationModel)
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
230 {
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1929
diff changeset
231 data.answers_.SetWorklist(true);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1929
diff changeset
232
1786
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
233 if (data.worklistHandler_ != NULL)
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
234 {
1788
6a2d507ef064 getting rid of opaque data structures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
235 ParsedDicomFile query(*requestIdentifiers);
2204
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
236 FixWorklistQuery(query);
0158f2de8cad Fix handling of worklist SCP with ReferencedStudySequence and ReferencedPatientSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2131
diff changeset
237
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1799
diff changeset
238 data.worklistHandler_->Handle(data.answers_, query,
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1799
diff changeset
239 *data.remoteIp_, *data.remoteAet_,
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
240 *data.calledAet_, modality.GetManufacturer());
1786
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
241 ok = true;
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
242 }
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
243 else
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
244 {
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
245 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
246 }
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 else
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
249 {
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1929
diff changeset
250 data.answers_.SetWorklist(false);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1929
diff changeset
251
1786
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
252 if (data.findHandler_ != NULL)
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
253 {
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
254 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
255
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
256 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
257 {
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
258 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
259 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
260 {
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
261 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
262
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
263 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
264 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
265 {
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
266 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
267 << "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
268 << ") " << 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
269 }
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
270
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
271 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
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
1786
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
275 DicomMap input;
4137
6774605d4341 keep only one signature for FromDcmtkBridge::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4136
diff changeset
276 std::set<DicomTag> ignoreTagLength;
6774605d4341 keep only one signature for FromDcmtkBridge::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4136
diff changeset
277 FromDcmtkBridge::ExtractDicomSummary(input, *requestIdentifiers, 0 /* don't truncate tags */, ignoreTagLength);
2125
b9bd52c72ba2 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
278
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
279 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
280 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
281
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 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
283 *data.remoteIp_, *data.remoteAet_,
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
284 *data.calledAet_, modality.GetManufacturer());
1786
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
285 ok = true;
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
286 }
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
287 else
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 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
290 }
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
291 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 }
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
293 catch (OrthancException& e)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 // 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
296 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
297 }
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
298
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
299 if (!ok)
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
300 {
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 response->DimseStatus = STATUS_FIND_Failed_UnableToProcess;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 *responseIdentifiers = NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 return;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 data.lastRequest_ = requestIdentifiers;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 else if (data.lastRequest_ != requestIdentifiers)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 // Internal error!
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 response->DimseStatus = STATUS_FIND_Failed_UnableToProcess;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 *responseIdentifiers = NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 return;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 }
722
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
315
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 if (responseCount <= static_cast<int>(data.answers_.GetSize()))
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 {
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
318 // There are pending results that are still to be sent
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 response->DimseStatus = STATUS_Pending;
1789
bdcc1dba4a53 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1788
diff changeset
320 *responseIdentifiers = data.answers_.ExtractDcmDataset(responseCount - 1);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 }
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1799
diff changeset
322 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
323 {
83489fddd8c5 Options to limit the number of results for an incoming C-FIND query
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
324 // 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
325 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
326 *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
327 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 {
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
330 // 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
331 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
332 response->DimseStatus = STATUS_FIND_Cancel_MatchingTerminatedDueToCancelRequest;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 *responseIdentifiers = NULL;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339 OFCondition Internals::findScp(T_ASC_Association * assoc,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 T_DIMSE_Message * msg,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 T_ASC_PresentationContextID presID,
2381
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
342 DicomServer::IRemoteModalities& modalities,
1786
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
343 IFindRequestHandler* findHandler,
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
344 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
345 const std::string& remoteIp,
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
346 const std::string& remoteAet,
3704
58f92b1c8061 Fix issue #167 (Job can't be cancelled - Handling of timeouts after established association)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
347 const std::string& calledAet,
58f92b1c8061 Fix issue #167 (Job can't be cancelled - Handling of timeouts after established association)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
348 int timeout)
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 FindScpData data;
2381
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
351 data.modalities_ = &modalities;
1786
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
352 data.findHandler_ = findHandler;
164d78911382 primitives to handle dicom worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
353 data.worklistHandler_ = worklistHandler;
2381
b8969010b534 uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2256
diff changeset
354 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
355 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
356 data.remoteAet_ = &remoteAet;
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
357 data.calledAet_ = &calledAet;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359 OFCondition cond = DIMSE_findProvider(assoc, presID, &msg->msg.CFindRQ,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 FindScpCallback, &data,
3704
58f92b1c8061 Fix issue #167 (Job can't be cancelled - Handling of timeouts after established association)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
361 /*opt_blockMode*/ (timeout ? DIMSE_NONBLOCKING : DIMSE_BLOCKING),
58f92b1c8061 Fix issue #167 (Job can't be cancelled - Handling of timeouts after established association)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
362 /*opt_dimse_timeout*/ timeout);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 // if some error occured, dump corresponding information and remove the outfile if necessary
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365 if (cond.bad())
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 OFString temp_str;
102
7593b57dc1bf switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
368 LOG(ERROR) << "Find SCP Failed: " << cond.text();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 return cond;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 }