00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef DATAPRIV_H
00035 #define DATAPRIV_H
00036
00037 #include "osconfig.h"
00038
00039 #include "imagedb.h"
00040 #include "dicom.h"
00041 #include "dcdatset.h"
00042 #include "dcuid.h"
00043 #include "dcdeftag.h"
00044 BEGIN_EXTERN_C
00045 #ifdef HAVE_IO_H
00046 #define access my_access // Workaround to make Visual C++ Compiler happy!
00047 #include <io.h>
00048 #undef access
00049 #endif
00050 END_EXTERN_C
00051
00052 #define STORE_SERVICE 1
00053 #define FIND_SERVICE 2
00054 #define MOVE_SERVICE 3
00055
00056
00057
00058
00059
00060
00061 #define AE_MAX_LENGTH 128
00062 #define AS_MAX_LENGTH 32
00063 #define AT_MAX_LENGTH 32
00064 #define CS_MAX_LENGTH 128
00065 #define DA_MAX_LENGTH 80
00066 #define DS_MAX_LENGTH 128
00067 #define DT_MAX_LENGTH 208
00068 #define FL_MAX_LENGTH 32
00069 #define FD_MAX_LENGTH 64
00070 #define IS_MAX_LENGTH 96
00071 #define LO_MAX_LENGTH 64
00072 #define LT_MAX_LENGTH 10240
00073 #define PN_MAX_LENGTH 64
00074 #define SH_MAX_LENGTH 16
00075 #define SL_MAX_LENGTH 32
00076 #define SS_MAX_LENGTH 16
00077 #define ST_MAX_LENGTH 1024
00078 #define TM_MAX_LENGTH 128
00079 #define UI_MAX_LENGTH 64
00080 #define UL_MAX_LENGTH 32
00081 #define US_MAX_LENGTH 16
00082 #define CS_LABEL_MAX_LENGTH 16
00083 #define DESCRIPTION_MAX_LENGTH 128
00084
00085 #define DBC_MAXSTRING 256
00086
00087 #define MAX_MAX_STUDIES DB_UpperMaxStudies
00088 #define MAX_NUMBER_OF_IMAGES 10000
00089 #define SIZEOF_IDXRECORD (sizeof (IdxRecord))
00090 #define SIZEOF_STUDYDESC (sizeof (StudyDescRecord) * MAX_MAX_STUDIES)
00091
00092
00093 typedef struct DB_SSmallDcmElmt {
00094 char* PValueField ;
00095 Uint32 ValueLength ;
00096 DcmTagKey XTag ;
00097 DB_SSmallDcmElmt();
00098
00099 private:
00100 DB_SSmallDcmElmt(const DB_SSmallDcmElmt& copy);
00101 DB_SSmallDcmElmt& operator=(const DB_SSmallDcmElmt& copy);
00102 } DB_SmallDcmElmt ;
00103
00104
00105 typedef enum {
00106 UNIQUE_KEY,
00107 REQUIRED_KEY,
00108 OPTIONAL_KEY
00109 } DB_KEY_TYPE ;
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 typedef enum {
00124 PATIENT_LEVEL,
00125 STUDY_LEVEL,
00126 SERIE_LEVEL,
00127 IMAGE_LEVEL
00128 } DB_LEVEL ;
00129
00130 typedef enum {
00131 PATIENT_ROOT,
00132 STUDY_ROOT,
00133 PATIENT_STUDY
00134 } DB_QUERY_CLASS ;
00135
00136 struct db_ElementList {
00137 DB_SmallDcmElmt elem ;
00138 struct db_ElementList *next ;
00139
00140 db_ElementList(): elem(), next(NULL) {}
00141 private:
00142 db_ElementList(const db_ElementList& copy);
00143 db_ElementList& operator=(const db_ElementList& copy);
00144 };
00145
00146 typedef struct db_ElementList DB_ElementList;
00147
00148 struct db_UidList {
00149 char *patient ;
00150 char *study ;
00151 char *serie ;
00152 char *image ;
00153 struct db_UidList *next ;
00154 };
00155
00156 typedef struct db_UidList DB_UidList ;
00157
00158
00159 struct db_IntegerList {
00160 int idxCounter ;
00161 struct db_IntegerList *next ;
00162 };
00163 typedef struct db_IntegerList DB_CounterList ;
00164
00165
00166 typedef enum {
00167 DATE_CLASS,
00168 TIME_CLASS,
00169 UID_CLASS,
00170 STRING_CLASS,
00171 OTHER_CLASS
00172 } DB_KEY_CLASS ;
00173
00174 struct DB_FindAttr {
00175 DcmTagKey tag ;
00176 DB_LEVEL level ;
00177 DB_KEY_TYPE keyAttr ;
00178 DB_KEY_CLASS keyClass ;
00179
00180
00181 DB_FindAttr(const DcmTagKey& t, DB_LEVEL l, DB_KEY_TYPE kt, DB_KEY_CLASS kc)
00182 : tag(t), level(l), keyAttr(kt), keyClass(kc) { }
00183 };
00184
00185
00186
00187 typedef struct {
00188 int pidx ;
00189 DB_ElementList *findRequestList ;
00190 DB_ElementList *findResponseList ;
00191 DB_LEVEL queryLevel ;
00192 char indexFilename[DBC_MAXSTRING+1] ;
00193 char storageArea[DBC_MAXSTRING+1] ;
00194 long maxBytesPerStudy ;
00195 long maxStudiesAllowed ;
00196 int idxCounter ;
00197 DB_CounterList *moveCounterList ;
00198 int NumberRemainOperations ;
00199 DB_QUERY_CLASS rootLevel ;
00200 DB_UidList *uidList ;
00201 } DB_Private_Handle ;
00202
00203
00204 typedef struct {
00205 char StudyInstanceUID [UI_MAX_LENGTH] ;
00206 long StudySize ;
00207 double LastRecordedDate ;
00208 int NumberofRegistratedImages ;
00209 } StudyDescRecord ;
00210
00211
00212 typedef struct {
00213 int idxCounter ;
00214 double RecordedDate ;
00215 long ImageSize ;
00216 } ImagesofStudyArray ;
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229 #define RECORDIDX_PatientsBirthDate 0
00230 #define RECORDIDX_PatientsSex 1
00231 #define RECORDIDX_PatientsName 2
00232 #define RECORDIDX_PatientID 3
00233 #define RECORDIDX_PatientsBirthTime 4
00234 #define RECORDIDX_OtherPatientIDs 5
00235 #define RECORDIDX_OtherPatientNames 6
00236 #define RECORDIDX_EthnicGroup 7
00237 #define RECORDIDX_NumberofPatientRelatedStudies 8
00238 #define RECORDIDX_NumberofPatientRelatedSeries 9
00239 #define RECORDIDX_NumberofPatientRelatedInstances 10
00240 #define RECORDIDX_StudyDate 11
00241 #define RECORDIDX_StudyTime 12
00242 #define RECORDIDX_StudyID 13
00243 #define RECORDIDX_StudyDescription 14
00244 #define RECORDIDX_NameOfPhysiciansReadingStudy 15
00245 #define RECORDIDX_AccessionNumber 16
00246 #define RECORDIDX_ReferringPhysiciansName 17
00247 #define RECORDIDX_ProcedureDescription 18
00248 #define RECORDIDX_AttendingPhysiciansName 19
00249 #define RECORDIDX_StudyInstanceUID 20
00250 #define RECORDIDX_OtherStudyNumbers 21
00251 #define RECORDIDX_AdmittingDiagnosesDescription 22
00252 #define RECORDIDX_PatientsAge 23
00253 #define RECORDIDX_PatientsSize 24
00254 #define RECORDIDX_PatientsWeight 25
00255 #define RECORDIDX_Occupation 26
00256 #define RECORDIDX_NumberofStudyRelatedSeries 27
00257 #define RECORDIDX_NumberofStudyRelatedInstances 28
00258 #define RECORDIDX_SeriesNumber 29
00259 #define RECORDIDX_SeriesInstanceUID 30
00260 #define RECORDIDX_Modality 31
00261 #define RECORDIDX_ImageNumber 32
00262 #define RECORDIDX_SOPInstanceUID 33
00263 #define RECORDIDX_SeriesDate 34
00264 #define RECORDIDX_SeriesTime 35
00265 #define RECORDIDX_SeriesDescription 36
00266 #define RECORDIDX_ProtocolName 37
00267 #define RECORDIDX_OperatorsName 38
00268 #define RECORDIDX_PerformingPhysiciansName 39
00269 #define RECORDIDX_PresentationLabel 40
00270
00271 #define NBPARAMETERS 41
00272
00273
00274 struct IdxRecord {
00275
00276 char filename [DBC_MAXSTRING+1] ;
00277 char SOPClassUID [UI_MAX_LENGTH+1] ;
00278 double RecordedDate ;
00279 int ImageSize ;
00280
00281 DB_SmallDcmElmt param [NBPARAMETERS] ;
00282
00283 char PatientsBirthDate [DA_MAX_LENGTH+1] ;
00284 char PatientsSex [CS_MAX_LENGTH+1] ;
00285 char PatientsName [PN_MAX_LENGTH+1] ;
00286 char PatientID [LO_MAX_LENGTH+1] ;
00287 char PatientsBirthTime [TM_MAX_LENGTH+1] ;
00288 char OtherPatientIDs [LO_MAX_LENGTH+1] ;
00289 char OtherPatientNames [PN_MAX_LENGTH+1] ;
00290 char EthnicGroup [SH_MAX_LENGTH+1] ;
00291 char NumberofPatientRelatedStudies [IS_MAX_LENGTH+1] ;
00292 char NumberofPatientRelatedSeries [IS_MAX_LENGTH+1] ;
00293 char NumberofPatientRelatedInstances [IS_MAX_LENGTH+1] ;
00294
00295 char StudyDate [DA_MAX_LENGTH+1] ;
00296 char StudyTime [TM_MAX_LENGTH+1] ;
00297 char StudyID [CS_MAX_LENGTH+1] ;
00298 char StudyDescription [LO_MAX_LENGTH+1] ;
00299 char NameOfPhysiciansReadingStudy [PN_MAX_LENGTH+1] ;
00300
00301 char AccessionNumber [CS_MAX_LENGTH+1] ;
00302 char ReferringPhysiciansName [PN_MAX_LENGTH+1] ;
00303 char ProcedureDescription [LO_MAX_LENGTH+1] ;
00304 char AttendingPhysiciansName [PN_MAX_LENGTH+1] ;
00305 char StudyInstanceUID [UI_MAX_LENGTH+1] ;
00306 char OtherStudyNumbers [IS_MAX_LENGTH+1] ;
00307 char AdmittingDiagnosesDescription [LO_MAX_LENGTH+1] ;
00308 char PatientsAge [AS_MAX_LENGTH+1] ;
00309 char PatientsSize [DS_MAX_LENGTH+1] ;
00310 char PatientsWeight [DS_MAX_LENGTH+1] ;
00311 char Occupation [SH_MAX_LENGTH+1] ;
00312 char NumberofStudyRelatedSeries [IS_MAX_LENGTH+1] ;
00313 char NumberofStudyRelatedInstances [IS_MAX_LENGTH+1] ;
00314
00315 char SeriesNumber [IS_MAX_LENGTH+1] ;
00316 char SeriesInstanceUID [UI_MAX_LENGTH+1] ;
00317 char Modality [CS_MAX_LENGTH+1] ;
00318
00319 char ImageNumber [IS_MAX_LENGTH+1] ;
00320 char SOPInstanceUID [UI_MAX_LENGTH+1] ;
00321
00322 char SeriesDate [DA_MAX_LENGTH+1] ;
00323 char SeriesTime [TM_MAX_LENGTH+1] ;
00324 char SeriesDescription [LO_MAX_LENGTH+1] ;
00325 char ProtocolName [LO_MAX_LENGTH+1] ;
00326 char OperatorsName [PN_MAX_LENGTH+1] ;
00327 char PerformingPhysiciansName [PN_MAX_LENGTH+1] ;
00328 char PresentationLabel [CS_LABEL_MAX_LENGTH+1] ;
00329
00330 DVIFhierarchyStatus hstat;
00331
00332
00333 char InstanceDescription [DESCRIPTION_MAX_LENGTH+1] ;
00334
00335 IdxRecord();
00336
00337 private:
00338 IdxRecord(const IdxRecord& copy);
00339 IdxRecord& operator=(const IdxRecord& copy);
00340 };
00341
00342
00346 #define PATIENT_LEVEL_STRING "PATIENT"
00347 #define STUDY_LEVEL_STRING "STUDY"
00348 #define SERIE_LEVEL_STRING "SERIES"
00349 #define IMAGE_LEVEL_STRING "IMAGE"
00350
00354 extern void DB_IdxInitRecord (IdxRecord *, int linksOnly) ;
00355
00356 extern OFCondition DB_IdxRead (DB_Private_Handle *phandle, int idx, IdxRecord *idxRec) ;
00357 extern OFCondition DB_IdxAdd (DB_Private_Handle *phandle, int *idx, IdxRecord *idxRec) ;
00358 extern OFCondition DB_IdxRemove (DB_Private_Handle *phandle, int idx);
00359 extern OFCondition DB_StudyDescChange (DB_Private_Handle *phandle, StudyDescRecord *pStudyDesc) ;
00360 extern OFCondition DB_IdxInitLoop (DB_Private_Handle *phandle, int *idx) ;
00361 extern OFCondition DB_IdxGetNext (DB_Private_Handle *phandle, int *idx, IdxRecord *idxRec) ;
00362
00366 extern int DB_debugLevel;
00367 extern void DB_debug(int level, const char* format, ...);
00368
00369 extern int DB_StringUnify(char *, char *) ;
00370 extern OFCondition DB_FreeElementList (DB_ElementList *) ;
00371 extern OFCondition DB_FreeUidList (DB_UidList *) ;
00372 extern int DB_TagSupported (DcmTagKey) ;
00373 extern OFCondition DB_GetUIDTag (DB_LEVEL, DcmTagKey *) ;
00374 extern OFCondition DB_GetTagLevel (DcmTagKey, DB_LEVEL *) ;
00375 extern OFCondition DB_GetTagKeyAttr (DcmTagKey, DB_KEY_TYPE *) ;
00376 extern OFCondition DB_GetTagKeyClass (DcmTagKey, DB_KEY_CLASS *) ;
00377 extern int DB_CharsetInElement (char *charset, DB_SmallDcmElmt *elt) ;
00378 extern void DB_RemoveSpaces (char *string) ;
00379 extern void DB_RemoveEnclosingSpaces (char *string) ;
00380 extern long DB_DateToLong (char *date) ;
00381 extern double DB_TimeToDouble (char *time) ;
00382 extern void DB_DuplicateElement (DB_SmallDcmElmt *src, DB_SmallDcmElmt *dst) ;
00383 extern int DB_MatchDate (DB_SmallDcmElmt *mod, DB_SmallDcmElmt *elt) ;
00384 extern int DB_MatchTime (DB_SmallDcmElmt *mod, DB_SmallDcmElmt *elt) ;
00385 extern int DB_MatchUID (DB_SmallDcmElmt *mod, DB_SmallDcmElmt *elt) ;
00386 extern int DB_MatchStrings (DB_SmallDcmElmt *mod, DB_SmallDcmElmt *elt) ;
00387 extern int DB_Match (DB_SmallDcmElmt *mod, DB_SmallDcmElmt *elt) ;
00388 extern void DB_MakeResponseList (DB_Private_Handle *phandle, IdxRecord *idxRec) ;
00389 extern OFCondition DB_HierarchicalCompare (DB_Private_Handle *phandle, IdxRecord *idxRec,
00390 DB_LEVEL level, DB_LEVEL infLevel, int *match) ;
00391 extern OFCondition DB_CheckupinStudyDesc(DB_Private_Handle *phandle, StudyDescRecord *pStudyDesc, char *StudyUID, long imageSize) ;
00392 extern int DB_MatchStudyUIDInStudyDesc(StudyDescRecord *pStudyDesc, char *StudyUID, int maxStudiesAllowed) ;
00393 extern OFCondition DB_GetStudyDesc(DB_Private_Handle *phandle, StudyDescRecord *pStudyDesc) ;
00394 extern OFCondition DB_DeleteOldestImages(DB_Private_Handle *phandle, StudyDescRecord *pStudyDesc, int StudyNum, char *StudyUID, long RequiredSize) ;
00395 extern int DB_DeleteOldestStudy(DB_Private_Handle *phandle, StudyDescRecord *pStudyDesc) ;
00396 extern "C" int DB_Compare(const void *e1, const void *e2) ;
00397
00398 extern OFCondition DB_lock(DB_Private_Handle *phandle, OFBool exclusive);
00399 extern OFCondition DB_unlock(DB_Private_Handle *phandle);
00400
00401 extern OFBool DB_doCheckFindIdentifier();
00402 extern OFBool DB_doCheckMoveIdentifier();
00403
00404 extern void DB_printDataset(DcmDataset *ds);
00405
00406 #endif
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502