00001 /* 00002 * 00003 * Copyright (C) 1993-2010, OFFIS e.V. 00004 * All rights reserved. See COPYRIGHT file for details. 00005 * 00006 * This software and supporting documentation were developed by 00007 * 00008 * OFFIS e.V. 00009 * R&D Division Health 00010 * Escherweg 2 00011 * D-26121 Oldenburg, Germany 00012 * 00013 * 00014 * Module: dcmqrdb 00015 * 00016 * Author: Andrew Hewett 00017 * 00018 * Purpose: TI Common Constants, Types, Globals and Functions 00019 * 00020 * Last Update: $Author: joergr $ 00021 * Update Date: $Date: 2010-10-14 13:16:41 $ 00022 * CVS/RCS Revision: $Revision: 1.8 $ 00023 * Status: $State: Exp $ 00024 * 00025 * CVS/RCS Log at end of file 00026 * 00027 */ 00028 00029 #ifndef DCMQRTIS_H 00030 #define DCMQRTIS_H 00031 00032 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00033 00034 #include "dcmtk/dcmnet/dicom.h" 00035 #include "dcmtk/dcmnet/cond.h" 00036 #include "dcmtk/dcmnet/assoc.h" 00037 #include "dcmtk/dcmnet/dimse.h" 00038 #include "dcmtk/ofstd/ofcmdln.h" 00039 #include "dcmtk/dcmqrdb/dcmqrcnf.h" 00040 00041 class DcmQueryRetrieveDatabaseHandle; 00042 00043 /* 00044 * Constants 00045 */ 00046 00047 #define TI_MAXPEERS 100 00048 #define TI_MAXDATABASES 100 00049 #define TI_MAXSTUDIES 1000 00050 #define TI_MAXSERIES 500 00051 #define TI_MAXIMAGES 1000 00052 00053 /* 00054 * Type definitions 00055 */ 00056 00057 struct TI_ImageEntry 00058 { 00059 DIC_UI sopInstanceUID; 00060 DIC_IS imageNumber; 00061 int intImageNumber; 00062 } ; 00063 00064 struct TI_SeriesEntry 00065 { 00066 DIC_UI seriesInstanceUID; 00067 DIC_IS seriesNumber; 00068 int intSeriesNumber; 00069 DIC_CS modality; 00070 TI_ImageEntry *images[TI_MAXIMAGES]; /* array of image pointers */ 00071 int imageCount; 00072 00073 time_t lastQueryTime; /* time we last queried db */ 00074 }; 00075 00076 struct TI_StudyEntry 00077 { 00078 DIC_UI studyInstanceUID; 00079 DIC_CS studyID; 00080 DIC_PN patientName; 00081 DIC_LO patientID; 00082 TI_SeriesEntry *series[TI_MAXSERIES]; /* array of series pointers */ 00083 int seriesCount; 00084 time_t lastQueryTime; /* time we last queried db */ 00085 }; 00086 00087 00088 struct TI_DBEntry 00089 { 00090 const char *title; /* the CTN AE Title associated with this DB */ 00091 00092 const char **peerTitles; /* peer titles which can read this database 00093 * and thus we can comminicate with */ 00094 int peerTitleCount; /* number of peer titles */ 00095 00096 DcmQueryRetrieveDatabaseHandle *dbHandle; /* handle to current db */ 00097 00098 TI_StudyEntry *studies[TI_MAXSTUDIES]; /* array of study pointers */ 00099 int studyCount; 00100 00101 int currentStudy; /* index of current study */ 00102 int currentSeries; /* index of current series in current study */ 00103 int currentImage; /* index of current image in current study */ 00104 00105 time_t lastQueryTime; /* time we last queried db */ 00106 00107 OFBool isRemoteDB; /* true if DB is remote */ 00108 }; 00109 00110 struct TI_GenericCallbackStruct 00111 { 00112 TI_DBEntry *db; 00113 TI_StudyEntry *study; 00114 TI_SeriesEntry *series; 00115 }; 00116 00117 typedef OFBool (*TI_GenericEntryCallbackFunction)(TI_GenericCallbackStruct *cbstruct, DcmDataset *reply); 00118 00121 class DcmQueryRetrieveTelnetInitiator 00122 { 00123 public: 00124 00128 DcmQueryRetrieveTelnetInitiator(DcmQueryRetrieveConfig &cfg); 00129 00132 void TI_userInput(); 00133 00138 OFBool addPeerName(const char *peerName, const char *configFileName); 00139 00142 void printConfig(); 00143 00147 OFBool TI_detachAssociation(OFBool abortFlag); 00148 00152 void setAETitle(const char *ae) 00153 { 00154 myAETitle = ae; 00155 } 00156 00160 void setMaxPDU(OFCmdUnsignedInt pdu) 00161 { 00162 maxReceivePDULength = pdu; 00163 } 00164 00167 void activateFirstPeer() 00168 { 00169 peerHostName = peerNames[0]; 00170 } 00171 00176 T_ASC_Network **accessNet() 00177 { 00178 return &net; 00179 } 00180 00182 int getdbCount() const 00183 { 00184 return dbCount; 00185 } 00186 00192 void createConfigEntries( 00193 const char *configFileName, 00194 int remoteDBTitlesCount, 00195 const char **remoteDBTitles); 00196 00200 void setXferSyntax(E_TransferSyntax xfer) { networkTransferSyntax = xfer; } 00201 00206 void setBlockMode(T_DIMSE_BlockingMode blockMode, int timeout) 00207 { 00208 blockMode_ = blockMode; 00209 dimse_timeout_ = timeout; 00210 } 00211 00212 private: 00213 00214 OFBool TI_attachAssociation(); 00215 OFBool TI_changeAssociation(); 00216 OFBool TI_sendEcho(); 00217 OFBool TI_storeImage(char *sopClass, char *sopInstance, char * imgFile); 00218 OFBool TI_remoteFindQuery( 00219 TI_DBEntry *db, DcmDataset *query, 00220 TI_GenericEntryCallbackFunction callbackFunction, 00221 TI_GenericCallbackStruct *callbackData); 00222 OFBool TI_title(int arg, const char * /*cmdbuf*/ ); 00223 OFBool TI_attachDB(TI_DBEntry *db); 00224 OFBool TI_database(int arg, const char * /*cmdbuf*/ ); 00225 OFBool TI_echo(int arg, const char * /*cmdbuf*/ ); 00226 OFBool TI_quit(int arg, const char * /*cmdbuf*/ ); 00227 OFBool TI_actualizeStudies(); 00228 OFBool TI_study(int arg, const char * /*cmdbuf*/ ); 00229 OFBool TI_actualizeSeries(); 00230 OFBool TI_series(int arg, const char * /*cmdbuf*/ ); 00231 OFBool TI_actualizeImages(); 00232 OFBool TI_image(int arg, const char * /*cmdbuf*/ ); 00233 OFBool TI_buildStudies(TI_DBEntry *db); 00234 OFBool TI_buildSeries(TI_DBEntry *db, TI_StudyEntry *study); 00235 OFBool TI_buildRemoteImages(TI_DBEntry *db, TI_StudyEntry *study, TI_SeriesEntry *series); 00236 OFBool TI_buildImages(TI_DBEntry *db, TI_StudyEntry *study, TI_SeriesEntry *series); 00237 OFBool TI_sendStudy(int arg, const char * /*cmdbuf*/ ); 00238 OFBool TI_sendSeries(int arg, const char * /*cmdbuf*/ ); 00239 OFBool TI_sendImage(int arg, const char * /*cmdbuf*/ ); 00240 OFBool TI_send(int /*arg*/, const char *cmdbuf); 00241 OFBool TI_shortHelp(int /*arg*/ , const char * /*cmdbuf*/ ); 00242 OFBool TI_help(int arg, const char * /*cmdbuf*/ ); 00243 OFBool TI_buildRemoteStudies(TI_DBEntry *db); 00244 OFBool TI_buildRemoteSeries(TI_DBEntry *db, TI_StudyEntry *study); 00245 OFBool TI_dbReadable(const char *dbTitle); 00246 time_t TI_dbModifyTime(const char *dbTitle); 00247 OFCondition addPresentationContexts(T_ASC_Parameters *params); 00248 00249 OFBool findDBPeerTitles( 00250 const char *configFileName, 00251 TI_DBEntry *dbEntry, 00252 const char *peer); 00253 00255 TI_DBEntry **dbEntries; 00256 00258 int dbCount; 00259 00261 const char *peerHostName; 00262 00264 const char *peerNames[TI_MAXPEERS]; 00265 00267 int peerNamesCount; 00268 00270 const char *myAETitle; 00271 00273 T_ASC_Network *net; 00274 00276 T_ASC_Association *assoc; 00277 00279 OFCmdUnsignedInt maxReceivePDULength; 00280 00282 int currentdb; 00283 00285 const char *currentPeerTitle; 00286 00288 DcmQueryRetrieveConfig& config; 00289 00291 E_TransferSyntax networkTransferSyntax; 00292 00294 T_DIMSE_BlockingMode blockMode_; 00295 00297 int dimse_timeout_; 00298 00299 }; 00300 00301 00302 #endif 00303 00304 /* 00305 * CVS Log 00306 * $Log: dcmqrtis.h,v $ 00307 * Revision 1.8 2010-10-14 13:16:41 joergr 00308 * Updated copyright header. Added reference to COPYRIGHT file. 00309 * 00310 * Revision 1.7 2010-08-09 13:23:00 joergr 00311 * Updated data dictionary to 2009 edition of the DICOM standard. From now on, 00312 * the official "keyword" is used for the attribute name which results in a 00313 * number of minor changes (e.g. "PatientsName" is now called "PatientName"). 00314 * 00315 * Revision 1.6 2009-11-24 10:10:42 uli 00316 * Switched to logging mechanism provided by the "new" oflog module. 00317 * 00318 * Revision 1.5 2009-08-21 09:50:07 joergr 00319 * Replaced tabs by spaces and updated copyright date. 00320 * 00321 * Revision 1.4 2005/12/08 16:04:28 meichel 00322 * Changed include path schema for all DCMTK header files 00323 * 00324 * Revision 1.3 2005/11/17 13:44:37 meichel 00325 * Added command line options for DIMSE and ACSE timeouts 00326 * 00327 * Revision 1.2 2005/06/16 08:03:51 meichel 00328 * Fixed typo in method name 00329 * 00330 * Revision 1.1 2005/03/30 13:34:50 meichel 00331 * Initial release of module dcmqrdb that will replace module imagectn. 00332 * It provides a clear interface between the Q/R DICOM front-end and the 00333 * database back-end. The imagectn code has been re-factored into a minimal 00334 * class structure. 00335 * 00336 * 00337 */