00001 /* 00002 * 00003 * Copyright (C) 2000-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: dcmsr 00019 * 00020 * Author: Joerg Riesmeier 00021 * 00022 * Purpose: 00023 * classes: DSRDocument 00024 * 00025 * Last Update: $Author: meichel $ 00026 * Update Date: $Date: 2005/12/08 16:04:59 $ 00027 * CVS/RCS Revision: $Revision: 1.38 $ 00028 * Status: $State: Exp $ 00029 * 00030 * CVS/RCS Log at end of file 00031 * 00032 */ 00033 00034 00035 #ifndef DSRDOC_H 00036 #define DSRDOC_H 00037 00038 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00039 00040 #include "dcmtk/dcmsr/dsrdoctr.h" 00041 #include "dcmtk/dcmsr/dsrsoprf.h" 00042 #include "dcmtk/dcmsr/dsrcsidl.h" 00043 00044 #include "dcmtk/ofstd/ofstream.h" 00045 00046 00047 /*---------------------* 00048 * class declaration * 00049 *---------------------*/ 00050 00056 class DSRDocument 00057 : protected DSRTypes 00058 { 00059 00060 public: 00061 00062 // --- constructors and destructor --- 00063 00068 DSRDocument(const E_DocumentType documentType = DT_BasicTextSR); 00069 00072 virtual ~DSRDocument(); 00073 00074 00075 // --- misc routines --- 00076 00079 void clear(); 00080 00086 OFBool isValid(); 00087 00095 OFBool isFinalized() const; 00096 00103 void setLogStream(OFConsole *stream); 00104 00105 00106 // --- input and output --- 00107 00114 OFCondition print(ostream &stream, 00115 const size_t flags = 0); 00116 00135 OFCondition read(DcmItem &dataset, 00136 const size_t flags = 0); 00137 00151 OFCondition write(DcmItem &dataset, 00152 DcmStack *markedItems = NULL); 00153 00165 OFCondition readXML(const OFString &filename, 00166 const size_t flags = 0); 00167 00175 OFCondition writeXML(ostream &stream, 00176 const size_t flags = 0); 00177 00185 OFCondition renderHTML(ostream &stream, 00186 const size_t flags = 0, 00187 const char *styleSheet = NULL); 00188 00193 virtual OFBool containsExtendedCharacters(); 00194 00195 // --- get/set misc attributes --- 00196 00200 E_DocumentType getDocumentType() const; 00201 00205 inline DSRDocumentTree &getTree() 00206 { 00207 return DocumentTree; 00208 } 00209 00217 E_CharacterSet getSpecificCharacterSetType() const; 00218 00223 OFCondition setSpecificCharacterSetType(const E_CharacterSet characterSet); 00224 00229 E_CompletionFlag getCompletionFlag() const; 00230 00235 const char *getCompletionFlagDescription() const; 00236 00242 const OFString &getCompletionFlagDescription(OFString &description) const; 00243 00248 E_VerificationFlag getVerificationFlag() const; 00249 00257 size_t getNumberOfVerifyingObservers(); 00258 00273 OFCondition getVerifyingObserver(const size_t idx, 00274 OFString &dateTime, 00275 OFString &observerName, 00276 OFString &organization); 00277 00294 OFCondition getVerifyingObserver(const size_t idx, 00295 OFString &dateTime, 00296 OFString &observerName, 00297 DSRCodedEntryValue &observerCode, 00298 OFString &organization); 00299 00312 DSRSOPInstanceReferenceList &getPredecessorDocuments(); 00313 00327 DSRSOPInstanceReferenceList &getIdenticalDocuments(); 00328 00343 DSRSOPInstanceReferenceList &getCurrentRequestedProcedureEvidence(); 00344 00353 DSRSOPInstanceReferenceList &getPertinentOtherEvidence(); 00354 00360 DSRCodingSchemeIdentificationList &getCodingSchemeIdentification(); 00361 00362 // --- get DICOM string attributes (C string) --- 00363 // --- (these functions return the whole string value, 00364 // --- i.e. all components of multi-valued attributes) 00365 00369 const char *getModality() const; 00370 00374 const char *getSOPClassUID() const; 00375 00379 const char *getStudyInstanceUID() const; 00380 00384 const char *getSeriesInstanceUID() const; 00385 00389 const char *getSOPInstanceUID() const; 00390 00394 const char *getInstanceCreatorUID() const; 00395 00399 const char *getSpecificCharacterSet() const; 00400 00404 const char *getPatientsName() const; 00405 00409 const char *getPatientsBirthDate() const; 00410 00414 const char *getPatientsSex() const; 00415 00419 const char *getReferringPhysiciansName() const; 00420 00424 const char *getStudyDescription() const; 00425 00429 const char *getSeriesDescription() const; 00430 00434 const char *getManufacturer() const; 00435 00439 const char *getStudyDate() const; 00440 00444 const char *getStudyTime() const; 00445 00449 const char *getInstanceCreationDate() const; 00450 00454 const char *getInstanceCreationTime() const; 00455 00459 const char *getContentDate() const; 00460 00464 const char *getContentTime() const; 00465 00469 const char *getStudyID() const; 00470 00474 const char *getPatientID() const; 00475 00479 const char *getSeriesNumber() const; 00480 00484 const char *getInstanceNumber() const; 00485 00489 const char *getAccessionNumber() const; 00490 00491 00492 // --- get DICOM string attributes (C++ string) --- 00493 // --- (these functions return only the first 00494 // --- component of multi-valued attributes) 00495 00500 const OFString &getModality(OFString &value) const; 00501 00506 const OFString &getSOPClassUID(OFString &value) const; 00507 00512 const OFString &getStudyInstanceUID(OFString &value) const; 00513 00518 const OFString &getSeriesInstanceUID(OFString &value) const; 00519 00524 const OFString &getSOPInstanceUID(OFString &value) const; 00525 00530 const OFString &getInstanceCreatorUID(OFString &value) const; 00531 00536 const OFString &getSpecificCharacterSet(OFString &value) const; 00537 00542 const OFString &getPatientsName(OFString &value) const; 00543 00548 const OFString &getPatientsBirthDate(OFString &value) const; 00549 00554 const OFString &getPatientsSex(OFString &value) const; 00555 00560 const OFString &getReferringPhysiciansName(OFString &value) const; 00561 00566 const OFString &getStudyDescription(OFString &value) const; 00567 00572 const OFString &getSeriesDescription(OFString &value) const; 00573 00578 const OFString &getManufacturer(OFString &value) const; 00579 00584 const OFString &getStudyDate(OFString &value) const; 00585 00590 const OFString &getStudyTime(OFString &value) const; 00591 00596 const OFString &getInstanceCreationDate(OFString &value) const; 00597 00602 const OFString &getInstanceCreationTime(OFString &value) const; 00603 00608 const OFString &getContentDate(OFString &value) const; 00609 00614 const OFString &getContentTime(OFString &value) const; 00615 00620 const OFString &getStudyID(OFString &value) const; 00621 00626 const OFString &getPatientID(OFString &value) const; 00627 00632 const OFString &getSeriesNumber(OFString &value) const; 00633 00638 const OFString &getInstanceNumber(OFString &value) const; 00639 00644 const OFString &getAccessionNumber(OFString &value) const; 00645 00646 00647 // --- set DICOM string attributes --- 00648 00655 OFCondition setSpecificCharacterSet(const OFString &value); 00656 00663 OFCondition setCompletionFlagDescription(const OFString &value); 00664 00670 OFCondition setPatientsName(const OFString &value); 00671 00677 OFCondition setPatientsBirthDate(const OFString &value); 00678 00684 OFCondition setPatientsSex(const OFString &value); 00685 00691 OFCondition setReferringPhysiciansName(const OFString &value); 00692 00698 OFCondition setStudyDescription(const OFString &value); 00699 00705 OFCondition setSeriesDescription(const OFString &value); 00706 00712 OFCondition setManufacturer(const OFString &value); 00713 00721 OFCondition setContentDate(const OFString &value); 00722 00730 OFCondition setContentTime(const OFString &value); 00731 00737 OFCondition setStudyID(const OFString &value); 00738 00744 OFCondition setPatientID(const OFString &value); 00745 00753 OFCondition setSeriesNumber(const OFString &value); 00754 00762 OFCondition setInstanceNumber(const OFString &value); 00763 00769 OFCondition setAccessionNumber(const OFString &value); 00770 00771 00772 // --- document management functions --- 00773 00779 void createNewStudy(); 00780 00786 void createNewSeries(); 00787 00795 OFCondition createNewSeriesInStudy(const OFString &studyUID); 00796 00808 void createNewSOPInstance(); 00809 00815 OFCondition createNewDocument(); 00816 00823 OFCondition createNewDocument(const E_DocumentType documentType); 00824 00842 OFCondition createRevisedVersion(const OFBool clearList = OFTrue); 00843 00851 OFCondition completeDocument(); 00852 00862 OFCondition completeDocument(const OFString &description); 00863 00876 OFCondition verifyDocument(const OFString &observerName, 00877 const OFString &organization); 00878 00889 OFCondition verifyDocument(const OFString &observerName, 00890 const OFString &organization, 00891 const OFString &dateTime /*= ""*/); 00892 00906 OFCondition verifyDocument(const OFString &observerName, 00907 const DSRCodedEntryValue &observerCode, 00908 const OFString &organization); 00909 00921 OFCondition verifyDocument(const OFString &observerName, 00922 const DSRCodedEntryValue &observerCode, 00923 const OFString &organization, 00924 const OFString &dateTime /*= ""*/); 00925 00933 void removeVerification(); 00934 00947 OFCondition finalizeDocument(); 00948 00949 00950 protected: 00951 00958 OFCondition readXMLDocumentHeader(DSRXMLDocument &doc, 00959 DSRXMLCursor cursor, 00960 const size_t flags); 00961 00968 OFCondition readXMLPatientData(const DSRXMLDocument &doc, 00969 DSRXMLCursor cursor, 00970 const size_t flags); 00971 00978 OFCondition readXMLStudyData(const DSRXMLDocument &doc, 00979 DSRXMLCursor cursor, 00980 const size_t flags); 00981 00988 OFCondition readXMLSeriesData(const DSRXMLDocument &doc, 00989 DSRXMLCursor cursor, 00990 const size_t flags); 00991 00998 OFCondition readXMLInstanceData(const DSRXMLDocument &doc, 00999 DSRXMLCursor cursor, 01000 const size_t flags); 01001 01008 OFCondition readXMLDocumentData(const DSRXMLDocument &doc, 01009 DSRXMLCursor cursor, 01010 const size_t flags); 01011 01018 OFCondition readXMLVerifyingObserverData(const DSRXMLDocument &doc, 01019 DSRXMLCursor cursor, 01020 const size_t flags); 01021 01026 void renderHTMLPatientData(ostream &stream, 01027 const size_t flags); 01028 01034 void renderHTMLReferenceList(ostream &stream, 01035 DSRSOPInstanceReferenceList &refList, 01036 const size_t flags); 01037 01046 OFCondition checkDatasetForReading(DcmItem &dataset, 01047 E_DocumentType &documentType); 01048 01054 void updateAttributes(const OFBool updateAll = OFTrue); 01055 01056 01057 private: 01058 01060 DSRDocumentTree DocumentTree; 01061 01063 OFConsole *LogStream; 01064 01066 OFBool FinalizedFlag; 01068 E_CompletionFlag CompletionFlagEnum; 01070 E_VerificationFlag VerificationFlagEnum; 01072 E_CharacterSet SpecificCharacterSetEnum; 01073 01074 // DICOM attributes are listed ordered by module. 01075 // The comments for each attribute describe "Name: (VR, VM, Type)". 01076 // Please note that for particular SR documents (e.g. Key Object Selection) 01077 // other rules might apply. See DICOM standard for further reference. 01078 01079 // --- SOP Common Module (M) --- 01080 // (see SR Document General Module) 01081 01083 DcmUniqueIdentifier SOPClassUID; 01085 DcmUniqueIdentifier SOPInstanceUID; 01087 DcmCodeString SpecificCharacterSet; 01089 DcmDate InstanceCreationDate; 01091 DcmTime InstanceCreationTime; 01093 DcmUniqueIdentifier InstanceCreatorUID; 01095 DSRCodingSchemeIdentificationList CodingSchemeIdentification; 01096 01097 // --- General Study Module (M) --- 01098 01100 DcmUniqueIdentifier StudyInstanceUID; 01102 DcmDate StudyDate; 01104 DcmTime StudyTime; 01106 DcmPersonName ReferringPhysiciansName; 01108 DcmShortString StudyID; 01110 DcmShortString AccessionNumber; 01112 DcmLongString StudyDescription; 01113 01114 // --- General Series Module --- 01115 // (see SR Document Series Module) 01116 01118 DcmLongString SeriesDescription; 01119 01120 // --- Patient Module (M) --- 01121 01123 DcmPersonName PatientsName; 01125 DcmLongString PatientID; 01127 DcmDate PatientsBirthDate; 01129 DcmCodeString PatientsSex; 01130 01131 // --- General Equipment Module (M) --- 01132 01134 DcmLongString Manufacturer; 01135 01136 // --- Frame of Reference (C) --- 01137 01138 // tbd: conditional module for X-Ray Radiation Dose SR not yet supported 01139 01140 // --- SR Document Series Module (M) --- 01141 01143 DcmCodeString Modality; 01145 DcmUniqueIdentifier SeriesInstanceUID; 01147 DcmIntegerString SeriesNumber; 01149 DcmSequenceOfItems ReferencedPerformedProcedureStepSequence; 01150 01151 // --- SR Document General Module (M) --- 01152 01154 DcmIntegerString InstanceNumber; 01156 DcmCodeString CompletionFlag; 01158 DcmLongString CompletionFlagDescription; 01160 DcmCodeString VerificationFlag; 01162 DcmDate ContentDate; 01164 DcmTime ContentTime; 01166 DcmSequenceOfItems VerifyingObserver; 01168 DSRSOPInstanceReferenceList PredecessorDocuments; 01170 DSRSOPInstanceReferenceList IdenticalDocuments; 01171 // Referenced Request Sequence: (SQ, 1, 1C) 01172 // -- not yet supported -- 01174 DcmSequenceOfItems PerformedProcedureCode; 01176 DSRSOPInstanceReferenceList CurrentRequestedProcedureEvidence; 01178 DSRSOPInstanceReferenceList PertinentOtherEvidence; 01179 01180 // --- declaration copy constructor and assignment operator 01181 01182 DSRDocument(const DSRDocument &); 01183 DSRDocument &operator=(const DSRDocument &); 01184 }; 01185 01186 01187 #endif 01188 01189 01190 /* 01191 * CVS/RCS Log: 01192 * $Log: dsrdoc.h,v $ 01193 * Revision 1.38 2005/12/08 16:04:59 meichel 01194 * Changed include path schema for all DCMTK header files 01195 * 01196 * Revision 1.37 2005/11/30 12:00:24 joergr 01197 * Added support for X-Ray Radiation Dose SR documents. 01198 * 01199 * Revision 1.36 2005/07/27 16:41:55 joergr 01200 * Updated reference to DICOM standard edition. 01201 * 01202 * Revision 1.35 2004/11/22 16:39:09 meichel 01203 * Added method that checks if the SR document contains non-ASCII characters 01204 * in any of the strings affected by SpecificCharacterSet. 01205 * 01206 * Revision 1.34 2004/04/16 13:24:07 joergr 01207 * Restructured code to avoid default parameter values for "complex types" like 01208 * OFString. Required for Sun CC 2.0.1. 01209 * 01210 * Revision 1.33 2004/01/05 14:36:02 joergr 01211 * Removed acknowledgements with e-mail addresses from CVS log. 01212 * 01213 * Revision 1.32 2003/10/30 17:53:23 joergr 01214 * Added full support for the ContentTemplateSequence (read/write, get/set 01215 * template identification). Template constraints are not checked yet. 01216 * 01217 * Revision 1.31 2003/10/09 13:18:16 joergr 01218 * Added text from Supplement 66 to getCurrentRequestedProcedureEvidence() API 01219 * comment. 01220 * 01221 * Revision 1.30 2003/09/10 13:16:13 joergr 01222 * Replaced PrivateCodingSchemeUID by new CodingSchemeIdenticationSequence as 01223 * required by CP 324. 01224 * 01225 * Revision 1.29 2003/08/07 18:01:42 joergr 01226 * Removed libxml dependency from header files. 01227 * 01228 * Revision 1.28 2003/08/07 12:31:46 joergr 01229 * Added readXML functionality. 01230 * Updated documentation to get rid of doxygen warnings. 01231 * Made method isFinalized() const. 01232 * Added new option to createRevisedVersion() which allows to keep the current 01233 * list of predecessor documents. 01234 * Changed interface to access the list of predecessor documents. Now using the 01235 * existing class DSRSOPInstanceReferenceList. 01236 * Added preliminary support for the Identical Documents Sequence. 01237 * Renamed parameters/variables "string" to avoid name clash with STL class. 01238 * 01239 * Revision 1.27 2002/05/14 08:15:24 joergr 01240 * Updated comments. 01241 * 01242 * Revision 1.26 2002/05/07 12:49:31 joergr 01243 * Added support for the Current Requested Procedure Evidence Sequence and the 01244 * Pertinent Other Evidence Sequence to the dcmsr module. 01245 * 01246 * Revision 1.25 2002/04/16 13:50:52 joergr 01247 * Added configurable support for C++ ANSI standard includes (e.g. streams). 01248 * 01249 * Revision 1.24 2001/11/09 16:10:48 joergr 01250 * Added preliminary support for Mammography CAD SR. 01251 * 01252 * Revision 1.23 2001/09/26 13:04:06 meichel 01253 * Adapted dcmsr to class OFCondition 01254 * 01255 * Revision 1.22 2001/04/03 08:24:01 joergr 01256 * Added new command line option: ignore relationship content constraints 01257 * specified for each SR document class. 01258 * 01259 * Revision 1.21 2001/01/29 17:37:14 joergr 01260 * Added methods to support a new state of finalized and unfinalized documents. 01261 * 01262 * Revision 1.20 2001/01/25 11:48:43 joergr 01263 * Corrected typos / enhanced comments. 01264 * 01265 * Revision 1.19 2001/01/18 15:53:33 joergr 01266 * Added support for digital signatures. 01267 * 01268 * Revision 1.18 2000/12/08 13:42:40 joergr 01269 * Renamed createNewSeries(studyUID) to createNewSeriesInStudy(studyUID). 01270 * 01271 * Revision 1.17 2000/11/16 13:31:27 joergr 01272 * Corrected behaviour of updateDicomAttributes(). 01273 * 01274 * Revision 1.16 2000/11/14 17:27:25 joergr 01275 * Added method to remove verification information. 01276 * 01277 * Revision 1.15 2000/11/14 16:36:21 joergr 01278 * Added methods to set the content date/time. 01279 * 01280 * Revision 1.14 2000/11/14 11:45:50 joergr 01281 * Corrected behaviour of method createRevisedVersion(). 01282 * 01283 * Revision 1.13 2000/11/13 14:19:06 joergr 01284 * Updated comments. 01285 * 01286 * Revision 1.12 2000/11/13 10:26:21 joergr 01287 * Added output of optional observation datetime to rendered HTML page. 01288 * 01289 * Revision 1.11 2000/11/10 18:10:20 joergr 01290 * Corrected behaviour of createNewSOPInstance() and createRevisedDocument(). 01291 * 01292 * Revision 1.10 2000/11/10 17:44:49 joergr 01293 * Added new methods to set the completion flag description, create new study/ 01294 * series UIDs. Added missing type 2 sequence to dataset. Corrected wrong format 01295 * of predecessor documents sequence. Changed behaviour of completion/verification 01296 * flags. Improved HTML and print/dump output. 01297 * 01298 * Revision 1.9 2000/11/09 20:32:07 joergr 01299 * Added support for non-ASCII characters in HTML 3.2 (use numeric value). 01300 * 01301 * Revision 1.8 2000/11/07 18:12:25 joergr 01302 * Enhanced rendered HTML output of date, time, datetime and pname. 01303 * 01304 * Revision 1.7 2000/11/01 16:16:33 joergr 01305 * dded support for conversion to XML. 01306 * Added support for Cascading Style Sheet (CSS) used optionally for HTML 01307 * rendering. 01308 * Enhanced support for specific character sets. 01309 * 01310 * Revision 1.6 2000/10/26 14:17:06 joergr 01311 * Added support for "Comprehensive SR". 01312 * 01313 * Revision 1.5 2000/10/18 17:01:47 joergr 01314 * Made some functions inline. 01315 * 01316 * Revision 1.4 2000/10/17 12:35:05 joergr 01317 * Added methods to retrieve information on predecessor documents and 01318 * verifying observers. 01319 * 01320 * Revision 1.3 2000/10/16 16:30:23 joergr 01321 * Added missing get/setSeriesDescription() methods. 01322 * Updated comments. 01323 * 01324 * Revision 1.2 2000/10/16 11:59:04 joergr 01325 * Made method creating a new SOP instance public. Added check for correct SOP 01326 * instance UID and SOP class UID to validity check. 01327 * 01328 * Revision 1.1 2000/10/13 07:49:25 joergr 01329 * Added new module 'dcmsr' providing access to DICOM structured reporting 01330 * documents (supplement 23). Doc++ documentation not yet completed. 01331 * 01332 * 01333 */