00001 /* 00002 * 00003 * Copyright (C) 1993-2005, OFFIS 00004 * 00005 * This software and supporting documentation were developed by 00006 * 00007 * Kuratorium OFFIS e.V. 00008 * Healthcare Information and Communication Systems 00009 * Escherweg 2 00010 * D-26121 Oldenburg, Germany 00011 * 00012 * THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND OFFIS MAKES NO WARRANTY 00013 * REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR 00014 * FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR 00015 * ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND 00016 * PERFORMANCE OF THE SOFTWARE IS WITH THE USER. 00017 * 00018 * Module: dcmqrdb 00019 * 00020 * Author: Andrew Hewett, Marco Eichelberg 00021 * 00022 * Purpose: class DcmQueryRetrieveIndexDatabaseHandle 00023 * 00024 * Last Update: $Author: meichel $ 00025 * Update Date: $Date: 2005/12/08 16:04:22 $ 00026 * Source File: $Source: /share/dicom/cvs-depot/dcmtk/dcmqrdb/include/dcmtk/dcmqrdb/dcmqrdbi.h,v $ 00027 * CVS/RCS Revision: $Revision: 1.4 $ 00028 * Status: $State: Exp $ 00029 * 00030 * CVS/RCS Log at end of file 00031 * 00032 */ 00033 00034 #ifndef DCMQRDBI_H 00035 #define DCMQRDBI_H 00036 00037 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00038 #include "dcmtk/dcmqrdb/dcmqrdba.h" /* for class DcmQueryRetrieveDatabaseHandle */ 00039 00040 #include "dcmtk/dcmnet/dicom.h" 00041 #include "dcmtk/dcmnet/dimse.h" 00042 #include "dcmtk/ofstd/offname.h" 00043 00044 struct StudyDescRecord; 00045 struct DB_Private_Handle; 00046 struct DB_SmallDcmElmt; 00047 struct IdxRecord; 00048 struct DB_ElementList; 00049 class DcmQueryRetrieveConfig; 00050 00051 #define DBINDEXFILE "index.dat" 00052 00053 #ifndef _WIN32 00054 /* we lock image files on all platforms except Win32 where it does not work 00055 * due to the different semantics of LockFile/LockFileEx compared to flock. 00056 */ 00057 #define LOCK_IMAGE_FILES 00058 #endif 00059 00062 enum DB_LEVEL 00063 { 00065 PATIENT_LEVEL, 00067 STUDY_LEVEL, 00069 SERIE_LEVEL, 00071 IMAGE_LEVEL 00072 }; 00073 00081 enum DVIFhierarchyStatus 00082 { 00084 DVIF_objectIsNotNew, 00086 DVIF_objectIsNew, 00088 DVIF_objectContainsNewSubobjects 00089 }; 00090 00092 #define DB_UpperMaxStudies 500 00093 00095 #define DB_UpperMaxBytesPerStudy 0x40000000L 00096 00097 00102 class DcmQueryRetrieveIndexDatabaseHandle: public DcmQueryRetrieveDatabaseHandle 00103 { 00104 public: 00105 00115 DcmQueryRetrieveIndexDatabaseHandle( 00116 const char *storageArea, 00117 long maxStudiesPerStorageArea, 00118 long maxBytesPerStudy, 00119 OFCondition& result); 00120 00125 ~DcmQueryRetrieveIndexDatabaseHandle(); 00126 00130 void setDebugLevel(int debugLevel); 00131 00137 void setIdentifierChecking(OFBool checkFind, OFBool checkMove); 00138 00148 OFCondition makeNewStoreFileName( 00149 const char *SOPClassUID, 00150 const char *SOPInstanceUID, 00151 char *newImageFileName); 00152 00164 OFCondition storeRequest( 00165 const char *SOPClassUID, 00166 const char *SOPInstanceUID, 00167 const char *imageFileName, 00168 DcmQueryRetrieveDatabaseStatus *status, 00169 OFBool isNew = OFTrue ); 00170 00184 OFCondition startFindRequest( 00185 const char *SOPClassUID, 00186 DcmDataset *findRequestIdentifiers, 00187 DcmQueryRetrieveDatabaseStatus *status); 00188 00200 OFCondition nextFindResponse( 00201 DcmDataset **findResponseIdentifiers, 00202 DcmQueryRetrieveDatabaseStatus *status); 00203 00210 OFCondition cancelFindRequest(DcmQueryRetrieveDatabaseStatus *status); 00211 00225 OFCondition startMoveRequest( 00226 const char *SOPClassUID, 00227 DcmDataset *moveRequestIdentifiers, 00228 DcmQueryRetrieveDatabaseStatus *status); 00229 00249 OFCondition nextMoveResponse( 00250 char *SOPClassUID, 00251 char *SOPInstanceUID, 00252 char *imageFileName, 00253 unsigned short *numberOfRemainingSubOperations, 00254 DcmQueryRetrieveDatabaseStatus *status); 00255 00262 OFCondition cancelMoveRequest(DcmQueryRetrieveDatabaseStatus *status); 00263 00267 OFCondition pruneInvalidRecords(); 00268 00269 // methods not inherited from the base class 00270 00273 int getDebugLevel() const; 00274 00278 void enableQuotaSystem(OFBool enable); 00279 00283 static void printIndexFile (char *storeArea); 00284 00290 OFCondition deleteImageFile(char* imgFile); 00291 00296 OFCondition DB_lock(OFBool exclusive); 00297 00300 OFCondition DB_unlock(); 00301 00307 OFCondition DB_IdxGetNext(int *idx, IdxRecord *idxRec); 00308 00313 OFCondition DB_IdxInitLoop(int *idx); 00314 00320 OFCondition DB_IdxRead(int idx, IdxRecord *idxRec); 00321 00326 OFCondition DB_GetStudyDesc(StudyDescRecord *pStudyDesc); 00327 00332 OFCondition DB_StudyDescChange(StudyDescRecord *pStudyDesc); 00333 00338 OFCondition DB_IdxRemove(int idx); 00339 00344 OFCondition instanceReviewed(int idx); 00345 00347 const char *getStorageArea() const; 00348 00350 const char *getIndexFilename() const; 00351 00352 00353 private: 00354 00355 OFCondition removeDuplicateImage( 00356 const char *SOPInstanceUID, const char *StudyInstanceUID, 00357 StudyDescRecord *pStudyDesc, const char *newImageFileName); 00358 int deleteOldestStudy(StudyDescRecord *pStudyDesc); 00359 OFCondition deleteOldestImages(StudyDescRecord *pStudyDesc, int StudyNum, char *StudyUID, long RequiredSize); 00360 int matchDate (DB_SmallDcmElmt *mod, DB_SmallDcmElmt *elt); 00361 int matchTime (DB_SmallDcmElmt *mod, DB_SmallDcmElmt *elt); 00362 int matchUID (DB_SmallDcmElmt *mod, DB_SmallDcmElmt *elt); 00363 int matchStrings (DB_SmallDcmElmt *mod, DB_SmallDcmElmt *elt); 00364 int matchOther (DB_SmallDcmElmt *mod, DB_SmallDcmElmt *elt); 00365 int dbmatch (DB_SmallDcmElmt *mod, DB_SmallDcmElmt *elt); 00366 void makeResponseList(DB_Private_Handle *phandle, IdxRecord *idxRec); 00367 int matchStudyUIDInStudyDesc (StudyDescRecord *pStudyDesc, char *StudyUID, int maxStudiesAllowed); 00368 OFCondition checkupinStudyDesc(StudyDescRecord *pStudyDesc, char *StudyUID, long imageSize); 00369 void dbdebug(int level, const char* format, ...) const; 00370 00371 OFCondition hierarchicalCompare ( 00372 DB_Private_Handle *phandle, 00373 IdxRecord *idxRec, 00374 DB_LEVEL level, 00375 DB_LEVEL infLevel, 00376 int *match); 00377 00378 OFCondition testFindRequestList ( 00379 DB_ElementList *findRequestList, 00380 DB_LEVEL queryLevel, 00381 DB_LEVEL infLevel, 00382 DB_LEVEL lowestLevel); 00383 00384 OFCondition testMoveRequestList ( 00385 DB_ElementList *findRequestList, 00386 DB_LEVEL queryLevel, 00387 DB_LEVEL infLevel, 00388 DB_LEVEL lowestLevel); 00389 00391 DB_Private_Handle *handle; 00392 00394 OFBool quotaSystemEnabled; 00395 00397 OFBool doCheckFindIdentifier; 00398 00400 OFBool doCheckMoveIdentifier; 00401 00403 OFFilenameCreator fnamecreator; 00404 00406 int debugLevel; 00407 00408 }; 00409 00410 00414 class DcmQueryRetrieveIndexDatabaseHandleFactory: public DcmQueryRetrieveDatabaseHandleFactory 00415 { 00416 public: 00417 00421 DcmQueryRetrieveIndexDatabaseHandleFactory(const DcmQueryRetrieveConfig *config); 00422 00424 virtual ~DcmQueryRetrieveIndexDatabaseHandleFactory(); 00425 00434 virtual DcmQueryRetrieveDatabaseHandle *createDBHandle( 00435 const char *callingAETitle, 00436 const char *calledAETitle, 00437 OFCondition& result) const; 00438 00439 private: 00440 00442 const DcmQueryRetrieveConfig *config_; 00443 }; 00444 00445 #endif 00446 00447 /* 00448 * CVS Log 00449 * $Log: dcmqrdbi.h,v $ 00450 * Revision 1.4 2005/12/08 16:04:22 meichel 00451 * Changed include path schema for all DCMTK header files 00452 * 00453 * Revision 1.3 2005/04/22 15:36:34 meichel 00454 * Passing calling aetitle to DcmQueryRetrieveDatabaseHandleFactory::createDBHandle 00455 * to allow configuration retrieval based on calling aetitle. 00456 * 00457 * Revision 1.2 2005/04/04 10:04:45 meichel 00458 * Added public declarations for index file functions that are 00459 * used from module dcmpstat 00460 * 00461 * Revision 1.1 2005/03/30 13:34:50 meichel 00462 * Initial release of module dcmqrdb that will replace module imagectn. 00463 * It provides a clear interface between the Q/R DICOM front-end and the 00464 * database back-end. The imagectn code has been re-factored into a minimal 00465 * class structure. 00466 * 00467 * 00468 */