QtDcmFindCallback.cpp
Go to the documentation of this file.
1 /*
2  QtDcm is a C++ Qt based library for communication and conversion of Dicom images.
3  Copyright (C) 2011 Alexandre Abadie <Alexandre.Abadie@univ-rennes1.fr>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
20 // Dcmtk includes
21 #include <dcmtk/dcmdata/dcelem.h>
22 #include <dcmtk/dcmdata/dcdeftag.h>
23 #include <dcmtk/dcmnet/dfindscu.h>
24 
25 #ifdef WITH_OPENSSL
26 #include "dcmtk/dcmtls/tlstrans.h"
27 #include "dcmtk/dcmtls/tlslayer.h"
28 #endif
29 
30 // QtDcm includes
31 #include <QtDcmPatient.h>
32 #include <QtDcmStudy.h>
33 #include <QtDcmSerie.h>
34 #include <QtDcmImage.h>
35 #include <QtDcmManager.h>
36 
37 #include <QtDcmFindCallback.h>
38 
40 {
41 public:
42  int type;
43 };
44 
46  d ( new QtDcmFindCallbackPrivate )
47 {
48  d->type = type;
49 }
50 
52 {
53  delete d;
54  d = NULL;
55 }
56 
57 void QtDcmFindCallback::callback ( T_DIMSE_C_FindRQ *request, int responseCount, T_DIMSE_C_FindRSP *rsp, DcmDataset *responseIdentifiers )
58 {
59  Q_UNUSED(request)
60  Q_UNUSED(responseCount)
61  Q_UNUSED(rsp)
62 
63  QMap<QString, QString> infosMap;
64 
65  OFString info;
66 
67  switch ( d->type )
68  {
69 
70  case PATIENT:
71  responseIdentifiers->findAndGetOFString ( DCM_PatientName, info );
72  infosMap.insert ( "Name", QString ( info.c_str() ) );
73  responseIdentifiers->findAndGetOFString ( DCM_PatientID, info );
74  infosMap.insert ( "ID", QString ( info.c_str() ) );
75  responseIdentifiers->findAndGetOFString ( DCM_PatientSex, info );
76  infosMap.insert ( "Sex", QString ( info.c_str() ) );
77  responseIdentifiers->findAndGetOFString ( DCM_PatientBirthDate, info );
78  infosMap.insert ( "Birthdate", QString ( info.c_str() ) );
79 
80  QtDcmManager::instance()->foundPatient ( infosMap );
81 
82  break;
83 
84  case STUDY:
85  responseIdentifiers->findAndGetOFString ( DCM_StudyDescription, info );
86  infosMap.insert ( "Description", QString ( info.c_str() ) );
87  responseIdentifiers->findAndGetOFString ( DCM_StudyDate, info );
88  infosMap.insert ( "Date", QString ( info.c_str() ) );
89  responseIdentifiers->findAndGetOFString ( DCM_StudyID, info );
90  infosMap.insert ( "ID", QString ( info.c_str() ) );
91  responseIdentifiers->findAndGetOFString ( DCM_StudyInstanceUID, info );
92  infosMap.insert ( "UID", QString ( info.c_str() ) );
93 
94  QtDcmManager::instance()->foundStudy ( infosMap );
95 
96  break;
97 
98  case SERIE:
99  responseIdentifiers->findAndGetOFString ( DCM_SeriesDescription, info );
100  infosMap.insert ( "Description", QString ( info.c_str() ) );
101  responseIdentifiers->findAndGetOFString ( DCM_StudyDate, info );
102  infosMap.insert ( "Date", QString ( info.c_str() ) );
103  responseIdentifiers->findAndGetOFString ( DCM_Modality, info );
104  infosMap.insert ( "Modality", QString ( info.c_str() ) );
105  responseIdentifiers->findAndGetOFString ( DCM_SeriesInstanceUID, info );
106  infosMap.insert ( "ID", QString ( info.c_str() ) );
107  responseIdentifiers->findAndGetOFString ( DCM_InstitutionName, info );
108  infosMap.insert ( "Institution", QString ( info.c_str() ) );
109  responseIdentifiers->findAndGetOFString ( DCM_PerformingPhysicianName, info );
110  infosMap.insert ( "Operator", QString ( info.c_str() ) );
111  responseIdentifiers->findAndGetOFString ( DCM_NumberOfSeriesRelatedInstances, info );
112  infosMap.insert ( "InstanceCount", QString ( info.c_str() ) );
113 
114  QtDcmManager::instance()->foundSerie ( infosMap );
115  break;
116 
117  case IMAGE:
118  responseIdentifiers->findAndGetOFString ( DCM_SOPInstanceUID, info );
119 
120 // QtDcmManager::instance()->setPreviewImageUID ( QString ( info.c_str() ) );
121  break;
122 
123  case IMAGES:
124  OFString number;
125  responseIdentifiers->findAndGetOFString ( DCM_SOPInstanceUID, info );
126  responseIdentifiers->findAndGetOFString ( DCM_InstanceNumber, number );
127 
128  if ( !number.length() )
129  number = "0";
130 
131  QtDcmManager::instance()->foundImage ( QString ( info.c_str() ), QString ( number.c_str() ).toInt() );
132 
133 // responseIdentifiers->print ( std::cout );
134 
135  break;
136  }
137 }
static QtDcmManager * instance()
void foundSerie(const QMap< QString, QString > &infosMap)
void foundPatient(const QMap< QString, QString > &infosMap)
QtDcmFindCallback(int type=PATIENT)
void foundStudy(const QMap< QString, QString > &infosMap)
virtual void callback(T_DIMSE_C_FindRQ *request, int responseCount, T_DIMSE_C_FindRSP *rsp, DcmDataset *responseIdentifiers)
void foundImage(const QString &image, int number)