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
00035 #ifndef DVIFACE_H
00036 #define DVIFACE_H
00037
00038 #include "osconfig.h"
00039
00040
00041 #include "ofstream.h"
00042 #include "dctk.h"
00043 #include "dvpscf.h"
00044 #include "dvpstat.h"
00045 #include "dbpriv.h"
00046 #include "dbstore.h"
00047 #include "ofstring.h"
00048 #include "imagedb.h"
00049 #include "dvcache.h"
00050
00051
00052 class OFLogFile;
00053 class DicomImage;
00054 class DiDisplayFunction;
00055 class DVPSStoredPrint;
00056 class DVPSPrintMessageHandler;
00057 class DSRDocument;
00058 class DVSignatureHandler;
00059
00064 class DVInterface: public DVConfiguration
00065 {
00066
00067 public:
00068
00078 DVInterface(const char *config_file = NULL, OFBool useLog = OFFalse);
00079
00082 virtual ~DVInterface();
00083
00084
00085
00095 OFCondition loadImage(const char *studyUID, const char *seriesUID, const char *instanceUID, OFBool changeStatus = OFFalse);
00096
00103 OFCondition loadImage(const char *filename);
00104
00112 OFCondition loadReferencedImage(size_t idx, OFBool changeStatus = OFFalse);
00113
00124 OFCondition loadPState(const char *studyUID, const char *seriesUID, const char *instanceUID, OFBool changeStatus = OFFalse);
00125
00134 OFCondition loadPState(const char *pstName, const char *imgName = NULL);
00135
00144 OFCondition loadStructuredReport(const char *studyUID, const char *seriesUID, const char *instanceUID, OFBool changeStatus = OFFalse);
00145
00151 OFCondition loadStructuredReport(const char *filename);
00152
00165 OFCondition loadSRTemplate(const char *reportID);
00166
00179 OFCondition savePState(OFBool replaceSOPInstanceUID);
00180
00194 OFCondition savePState(const char *filename, OFBool replaceSOPInstanceUID, OFBool explicitVR=OFTrue);
00195
00205 OFCondition saveCurrentImage(const char *filename, OFBool explicitVR=OFTrue);
00206
00218 OFCondition saveStructuredReport();
00219
00232 OFCondition saveStructuredReport(const char *filename, OFBool explicitVR=OFTrue);
00233
00242 OFCondition addImageReferenceToPState(const char *studyUID, const char *seriesUID, const char *instanceUID);
00243
00247 size_t getNumberOfImageReferences();
00248
00255 DVPresentationState& getCurrentPState()
00256 {
00257 return *pState;
00258 }
00259
00265 DSRDocument& getCurrentReport()
00266 {
00267 return *pReport;
00268 }
00269
00274 DVPSStoredPrint& getPrintHandler()
00275 {
00276 return *pPrint;
00277 }
00278
00286 OFCondition resetPresentationState();
00287
00293 OFCondition saveCurrentPStateForReset();
00294
00303 OFCondition releaseDatabase();
00304
00314 const char *getFilename(const char *studyUID, const char *seriesUID, const char *instanceUID);
00315
00324 Uint32 getNumberOfStudies();
00325
00334 OFCondition selectStudy(Uint32 idx);
00335
00344 OFCondition selectStudy(const char *studyUID);
00345
00352 DVIFhierarchyStatus getStudyStatus() ;
00353
00359 const char *getStudyUID();
00360
00366 const char *getStudyDescription();
00367
00373 const char *getStudyDate();
00374
00380 const char *getStudyTime();
00381
00387 const char *getReferringPhysiciansName();
00388
00394 const char *getAccessionNumber();
00395
00401 const char *getNameOfPhysiciansReadingStudy();
00402
00410 const char *getPatientName();
00411
00419 const char *getPatientID();
00420
00428 const char *getPatientBirthDate();
00429
00437 const char *getPatientSex();
00438
00446 const char *getPatientBirthTime();
00447
00455 const char *getOtherPatientNames();
00456
00464 const char *getOtherPatientID();
00465
00473 const char *getEthnicGroup();
00474
00482 Uint32 getNumberOfSeries();
00483
00491 OFCondition selectSeries(Uint32 idx);
00492
00500 OFCondition selectSeries(const char *seriesUID);
00501
00507 const char *getSeriesUID();
00508
00514 DVIFhierarchyStatus getSeriesStatus();
00515
00523 DVPSInstanceType getSeriesType();
00524
00530 DVPSInstanceType getInstanceType();
00531
00537 const char *getSeriesNumber();
00538
00544 const char *getSeriesDate();
00545
00551 const char *getSeriesTime();
00552
00558 const char *getSeriesDescription();
00559
00565 const char *getSeriesPerformingPhysiciansName();
00566
00572 const char *getSeriesProtocolName();
00573
00579 const char *getSeriesOperatorsName();
00580
00586 const char *getModality();
00587
00595 Uint32 getNumberOfInstances();
00596
00604 OFCondition selectInstance(Uint32 idx);
00605
00613 OFCondition selectInstance(const char *instanceUID);
00614
00624 OFCondition selectInstance(const char *instanceUID, const char *sopClassUID);
00625
00635 OFCondition selectInstance(const char *studyUID, const char *seriesUID, const char *instanceUID);
00636
00642 const char *getSOPClassUID();
00643
00649 const char *getInstanceUID();
00650
00656 const char *getImageNumber();
00657
00663 const char *getFilename();
00664
00670 DVIFhierarchyStatus getInstanceStatus() ;
00671
00677 const char *getInstanceDescription();
00678
00684 const char *getPresentationLabel();
00685
00686
00687
00688
00701 OFCondition instanceReviewed(const char *studyUID, const char *seriesUID, const char *instanceUID);
00702
00714 OFCondition deleteInstance(const char *studyUID, const char *seriesUID, const char *instanceUID);
00715
00726 OFCondition deleteSeries(const char *studyUID, const char *seriesUID);
00727
00737 OFCondition deleteStudy(const char *studyUID);
00738
00739
00740
00752 OFCondition startReceiver();
00753
00761 OFCondition terminateReceiver();
00762
00778 OFCondition startQueryRetrieveServer();
00779
00789 OFCondition terminateQueryRetrieveServer();
00790
00801 OFBool newInstancesReceived();
00802
00815 OFCondition sendStudy(const char *targetID, const char *studyUID)
00816 {
00817 return sendIOD(targetID, studyUID, NULL, NULL);
00818 }
00819
00834 OFCondition sendSeries(const char *targetID, const char *studyUID, const char *seriesUID)
00835 {
00836 return sendIOD(targetID, studyUID, seriesUID, NULL);
00837 }
00838
00856 OFCondition sendIOD(const char *targetID, const char *studyUID, const char *seriesUID, const char *instanceUID);
00857
00868 OFCondition dumpIOD(const char *filename);
00869
00885 OFCondition dumpIOD(const char *studyUID, const char *seriesUID, const char *instanceUID);
00886
00897 OFCondition checkIOD(const char *filename);
00898
00914 OFCondition checkIOD(const char *studyUID, const char *seriesUID, const char *instanceUID);
00915
00933 OFCondition saveDICOMImage(
00934 const char *filename,
00935 const void *pixelData,
00936 unsigned long width,
00937 unsigned long height,
00938 double aspectRatio=1.0,
00939 OFBool explicitVR=OFTrue,
00940 const char *instanceUID=NULL);
00941
00956 OFCondition saveDICOMImage(
00957 const void *pixelData,
00958 unsigned long width,
00959 unsigned long height,
00960 double aspectRatio=1.0);
00961
00979 OFCondition saveHardcopyGrayscaleImage(
00980 const char *filename,
00981 const void *pixelData,
00982 unsigned long width,
00983 unsigned long height,
00984 double aspectRatio=1.0,
00985 OFBool explicitVR=OFTrue,
00986 const char *instanceUID=NULL);
00987
01002 OFCondition saveHardcopyGrayscaleImage(
01003 const void *pixelData,
01004 unsigned long width,
01005 unsigned long height,
01006 double aspectRatio=1.0);
01007
01017 OFCondition saveFileFormatToDB(DcmFileFormat &fileformat);
01018
01028 OFCondition loadStoredPrint(const char *studyUID, const char *seriesUID, const char *instanceUID, OFBool changeStatus = OFFalse);
01029
01036 OFCondition loadStoredPrint(const char *filename);
01037
01049 OFCondition saveStoredPrint(
01050 const char *filename,
01051 OFBool writeRequestedImageSize,
01052 OFBool explicitVR=OFTrue,
01053 const char *instanceUID=NULL);
01054
01065 OFCondition saveStoredPrint(OFBool writeRequestedImageSize);
01066
01070 size_t getNumberOfPrintPreviews();
01071
01083 OFCondition loadPrintPreview(size_t idx, OFBool printLUT = OFTrue, OFBool changeStatus = OFFalse);
01084
01087 void unloadPrintPreview();
01088
01093 unsigned long getPrintPreviewSize();
01094
01103 void setMaxPrintPreviewWidthHeight(unsigned long width, unsigned long height);
01104
01111 OFCondition getPrintPreviewWidthHeight(unsigned long &width, unsigned long &height);
01112
01119 OFCondition getPrintPreviewBitmap(void *bitmap, unsigned long size);
01120
01127 OFCondition disablePState();
01128
01134 OFCondition enablePState();
01135
01141 Uint32 getNumberOfPStates();
01142
01149 OFCondition selectPState(Uint32 idx, OFBool changeStatus = OFFalse);
01150
01156 const char *getPStateDescription(Uint32 idx);
01157
01163 const char *getPStateLabel(Uint32 idx);
01164
01172 OFBool isDisplayTransformPossible(DVPSDisplayTransform transform = DVPSD_GSDF);
01173
01178 OFCondition setAmbientLightValue(double value);
01179
01184 OFCondition getAmbientLightValue(double &value);
01185
01186
01187
01193 OFCondition setCurrentPrinter(const char *targetID);
01194
01199 const char *getCurrentPrinter();
01200
01207 OFCondition setPrinterMediumType(const char *value);
01208
01212 const char *getPrinterMediumType();
01213
01220 OFCondition setPrinterFilmDestination(const char *value);
01221
01225 const char *getPrinterFilmDestination();
01226
01233 OFCondition setPrinterFilmSessionLabel(const char *value);
01234
01238 const char *getPrinterFilmSessionLabel();
01239
01246 OFCondition setPrinterPriority(const char *value);
01247
01251 const char *getPrinterPriority();
01252
01259 OFCondition setPrinterOwnerID(const char *value);
01260
01264 const char *getPrinterOwnerID();
01265
01272 OFCondition setPrinterNumberOfCopies(unsigned long value);
01273
01277 unsigned long getPrinterNumberOfCopies();
01278
01284 void clearFilmSessionSettings();
01285
01291 OFCondition selectDisplayPresentationLUT(const char *lutID);
01292
01298 const char *getDisplayPresentationLUTID();
01299
01307 OFCondition selectPrintPresentationLUT(const char *lutID);
01308
01314 const char *getPrintPresentationLUTID();
01315
01320 OFCondition spoolPrintJob(OFBool deletePrintedImages=OFTrue);
01321
01333 OFCondition startPrintSpooler();
01334
01341 OFCondition terminatePrintSpooler();
01342
01355 OFCondition startPrintServer();
01356
01364 OFCondition terminatePrintServer();
01365
01376 OFCondition addToPrintHardcopyFromDB(const char *studyUID, const char *seriesUID, const char *instanceUID);
01377
01388 OFCondition spoolStoredPrintFromDB(const char *studyUID, const char *seriesUID, const char *instanceUID);
01389
01399 OFCondition printSCUcreateBasicFilmSession(DVPSPrintMessageHandler& printHandler, OFBool plutInSession);
01400
01401
01402
01406 OFBool isActiveAnnotation() { return activateAnnotation; }
01407
01411 OFBool getPrependDateTime() { return prependDateTime; }
01412
01416 OFBool getPrependPrinterName() { return prependPrinterName; }
01417
01421 OFBool getPrependLighting() { return prependLighting; }
01422
01426 const char *getAnnotationText() { return annotationText.c_str(); }
01427
01431 void setActiveAnnotation(OFBool value) { activateAnnotation=value; }
01432
01436 void setPrependDateTime(OFBool value) { prependDateTime=value; }
01437
01441 void setPrependPrinterName(OFBool value) { prependPrinterName=value; }
01442
01446 void setPrependLighting(OFBool value) { prependLighting=value; }
01447
01451 void setAnnotationText(const char *value);
01452
01453
01454
01466 OFBool verifyUserPassword(const char *userID, const char *passwd);
01467
01491 OFCondition verifyAndSignStructuredReport(const char *userID, const char *passwd, DVPSVerifyAndSignMode mode);
01492
01493
01494
01495
01501 virtual void setLog(OFConsole *stream, OFBool verbMode, OFBool dbgMode);
01502
01510 void setLogFilter(DVPSLogMessageLevel level);
01511
01520 OFCondition writeLogMessage(
01521 DVPSLogMessageLevel level,
01522 const char *module,
01523 const char *message);
01524
01525
01526
01533 const char *getCurrentSignatureValidationHTML(DVPSObjectType objtype) const;
01534
01539 const char *getCurrentSignatureValidationOverview() const;
01540
01545 DVPSSignatureStatus getCurrentSignatureStatus(DVPSObjectType objtype) const;
01546
01550 DVPSSignatureStatus getCombinedImagePStateSignatureStatus() const;
01551
01556 unsigned long getNumberOfCorrectSignatures(DVPSObjectType objtype) const;
01557
01562 unsigned long getNumberOfUntrustworthySignatures(DVPSObjectType objtype) const;
01563
01568 unsigned long getNumberOfCorruptSignatures(DVPSObjectType objtype) const;
01569
01574 void disableImageAndPState();
01575
01576 private:
01577
01580 DVInterface(const DVInterface&);
01581
01584 DVInterface& operator=(const DVInterface&);
01585
01593 OFCondition exchangeImageAndPState(DVPresentationState *newState, DcmFileFormat *image, DcmFileFormat *state=NULL);
01594
01601 OFCondition lockDatabase();
01602
01609 OFCondition lockExclusive();
01610
01614 OFCondition unlockExclusive();
01615
01622 OFCondition createPrintJobFilenames(const char *printer, OFString& tempname, OFString& jobname);
01623
01628 OFCondition createQueryRetrieveServerConfigFile(const char *filename);
01629
01636 OFCondition startExternalApplication(const char *application, const char *filename);
01637
01638
01639
01642 DVPSStoredPrint *pPrint;
01643
01646 DVPresentationState *pState;
01647
01650 DSRDocument *pReport;
01651
01654 DVSignatureHandler *pSignatureHandler;
01655
01658 DVPresentationState *pStoredPState;
01659
01662 DcmFileFormat *pDicomImage;
01663
01667 DcmFileFormat *pDicomPState;
01668
01671 DicomImage *pHardcopyImage;
01672
01676 OFString printJobIdentifier;
01677
01680 unsigned long printJobCounter;
01681
01684 OFString configPath;
01685
01689 OFString databaseIndexFile;
01690
01694 unsigned long referenceTime;
01695
01698 DiDisplayFunction *displayFunction[DVPSD_max];
01699
01702 DB_Private_Handle *pHandle;
01703
01706 OFBool lockingMode;
01707
01710 DVStudyCache idxCache;
01711
01714 IdxRecord idxRec;
01715
01718 int idxRecPos;
01719
01722 OFBool imageInDatabase;
01723
01724
01725
01728 OFBool createIndexCache();
01729
01732 OFBool createPStateCache();
01733
01736 void clearIndexCache();
01737
01740 void clearIndexRecord(IdxRecord &record,
01741 int &recpos);
01742
01746 OFBool readIndexRecord(const int pos,
01747 IdxRecord &record,
01748 int *oldpos = NULL);
01749
01753 void updateStatusCache();
01754
01757 DVStudyCache::ItemStruct *getStudyStruct(const char *studyUID = NULL,
01758 const char *seriesUID = NULL);
01759
01762 DVSeriesCache::ItemStruct *getSeriesStruct(const char *studyUID = NULL,
01763 const char *seriesUID = NULL,
01764 const char *instanceUID = NULL);
01765
01768 DVInstanceCache::ItemStruct *getInstanceStruct(const char *studyUID = NULL,
01769 const char *seriesUID = NULL,
01770 const char *instanceUID = NULL);
01771
01774 int findStudyIdx(StudyDescRecord *study,
01775 const char *uid);
01776
01779 int deleteImageFile(const char *filename);
01780
01783 void resetDatabaseReferenceTime();
01784
01785
01789 OFCondition instanceReviewed(int pos);
01790
01793 unsigned long minimumPrintBitmapWidth;
01794
01797 unsigned long minimumPrintBitmapHeight;
01798
01801 unsigned long maximumPrintBitmapWidth;
01802
01805 unsigned long maximumPrintBitmapHeight;
01806
01809 unsigned long maximumPrintPreviewWidth;
01810
01813 unsigned long maximumPrintPreviewHeight;
01814
01817 unsigned long maximumPreviewImageWidth;
01818
01821 unsigned long maximumPreviewImageHeight;
01822
01825 OFString currentPrinter;
01826
01829 OFString displayCurrentLUTID;
01830
01833 OFString printCurrentLUTID;
01834
01837 OFString printerMediumType;
01838
01841 OFString printerFilmDestination;
01842
01845 OFString printerFilmSessionLabel;
01846
01849 unsigned long printerNumberOfCopies;
01850
01854 OFString printerPriority;
01855
01858 OFString printerOwnerID;
01859
01862 OFBool activateAnnotation;
01863
01866 OFBool prependDateTime;
01867
01870 OFBool prependPrinterName;
01871
01874 OFBool prependLighting;
01875
01878 OFString annotationText;
01879
01882 OFLogFile *logFile;
01883 };
01884
01885
01886 #endif
01887
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902
01903
01904
01905
01906
01907
01908
01909
01910
01911
01912
01913
01914
01915
01916
01917
01918
01919
01920
01921
01922
01923
01924
01925
01926
01927
01928
01929
01930
01931
01932
01933
01934
01935
01936
01937
01938
01939
01940
01941
01942
01943
01944
01945
01946
01947
01948
01949
01950
01951
01952
01953
01954
01955
01956
01957
01958
01959
01960
01961
01962
01963
01964
01965
01966
01967
01968
01969
01970
01971
01972
01973
01974
01975
01976
01977
01978
01979
01980
01981
01982
01983
01984
01985
01986
01987
01988
01989
01990
01991
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001
02002
02003
02004
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021
02022
02023
02024
02025
02026
02027
02028
02029
02030
02031
02032
02033
02034
02035
02036
02037
02038
02039
02040
02041
02042
02043
02044
02045
02046
02047
02048
02049
02050
02051
02052
02053
02054
02055
02056
02057
02058
02059
02060
02061
02062
02063
02064
02065
02066
02067
02068
02069
02070
02071
02072
02073
02074
02075
02076
02077
02078
02079
02080
02081
02082
02083
02084
02085
02086
02087
02088
02089
02090
02091
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112
02113
02114
02115
02116
02117
02118
02119
02120
02121
02122
02123
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144
02145
02146
02147
02148
02149
02150
02151
02152
02153
02154
02155
02156
02157
02158
02159
02160
02161
02162
02163
02164
02165
02166
02167
02168
02169
02170
02171
02172
02173
02174
02175
02176
02177
02178
02179
02180
02181
02182
02183
02184
02185
02186
02187
02188
02189
02190
02191
02192
02193
02194
02195
02196
02197
02198
02199
02200
02201
02202
02203
02204
02205
02206
02207
02208
02209
02210
02211
02212
02213
02214
02215
02216
02217
02218
02219
02220
02221
02222
02223
02224
02225
02226
02227
02228
02229
02230
02231
02232