dcmsr/include/dcmtk/dcmsr/dsrdoctn.h

00001 /*
00002  *
00003  *  Copyright (C) 2000-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: dcmsr
00015  *
00016  *  Author: Joerg Riesmeier
00017  *
00018  *  Purpose:
00019  *    classes: DSRDocumentTreeNode
00020  *
00021  *  Last Update:      $Author: joergr $
00022  *  Update Date:      $Date: 2010-10-14 13:16:32 $
00023  *  CVS/RCS Revision: $Revision: 1.27 $
00024  *  Status:           $State: Exp $
00025  *
00026  *  CVS/RCS Log at end of file
00027  *
00028  */
00029 
00030 
00031 #ifndef DSRDOCTN_H
00032 #define DSRDOCTN_H
00033 
00034 #include "dcmtk/config/osconfig.h"   /* make sure OS specific configuration is included first */
00035 
00036 #include "dcmtk/dcmsr/dsrtree.h"
00037 #include "dcmtk/dcmsr/dsrcodvl.h"
00038 #include "dcmtk/dcmdata/dcitem.h"
00039 
00040 
00041 /*-----------------------*
00042  *  forward declaration  *
00043  *-----------------------*/
00044 
00045 class DSRIODConstraintChecker;
00046 
00047 
00048 /*---------------------*
00049  *  class declaration  *
00050  *---------------------*/
00051 
00054 class DSRDocumentTreeNode
00055   : public DSRTreeNode
00056 {
00057     // allow access to getConceptNamePtr()
00058     friend class DSRContentItem;
00059 
00060   public:
00061 
00072     DSRDocumentTreeNode(const E_RelationshipType relationshipType,
00073                         const E_ValueType valueType);
00074 
00077     virtual ~DSRDocumentTreeNode();
00078 
00082     virtual void clear();
00083 
00089     virtual OFBool isValid() const;
00090 
00097     virtual OFBool isShort(const size_t flags) const;
00098 
00108     virtual OFCondition print(STD_NAMESPACE ostream &stream,
00109                               const size_t flags) const;
00110 
00119     virtual OFCondition read(DcmItem &dataset,
00120                              const DSRIODConstraintChecker *constraintChecker,
00121                              const size_t flags);
00122 
00132     virtual OFCondition write(DcmItem &dataset,
00133                               DcmStack *markedItems = NULL);
00134 
00143     virtual OFCondition readXML(const DSRXMLDocument &doc,
00144                                 DSRXMLCursor cursor,
00145                                 const E_DocumentType documentType,
00146                                 const size_t flags);
00147 
00153     virtual OFCondition writeXML(STD_NAMESPACE ostream &stream,
00154                                  const size_t flags) const;
00155 
00167     virtual OFCondition renderHTML(STD_NAMESPACE ostream &docStream,
00168                                    STD_NAMESPACE ostream &annexStream,
00169                                    const size_t nestingLevel,
00170                                    size_t &annexNumber,
00171                                    const size_t flags) const;
00172 
00178     inline OFBool isSigned()
00179     {
00180         return (DigitalSignatures.card() > 0);
00181     }
00182 
00190     inline OFBool isMarked() const
00191     {
00192         return MarkFlag;
00193     }
00194 
00199     inline void setMark(const OFBool flag)
00200     {
00201         MarkFlag = flag;
00202     }
00203 
00207     inline OFBool isReferenceTarget() const
00208     {
00209         return ReferenceTarget;
00210     }
00211 
00215     inline void setReferenceTarget(const OFBool isTarget = OFTrue)
00216     {
00217         ReferenceTarget = isTarget;
00218     }
00219 
00223     inline OFBool hasChildNodes() const
00224     {
00225         return (Down != NULL);
00226     }
00227 
00231     inline OFBool hasSiblingNodes() const
00232     {
00233         return (Prev != NULL) || (Next != NULL);
00234     }
00235 
00239     inline size_t getNodeID() const
00240     {
00241         return Ident;
00242     }
00243 
00247     inline E_RelationshipType getRelationshipType() const
00248     {
00249         return RelationshipType;
00250     }
00251 
00255     inline E_ValueType getValueType() const
00256     {
00257         return ValueType;
00258     }
00259 
00263     inline const DSRCodedEntryValue &getConceptName() const
00264     {
00265         return ConceptName;
00266     }
00267 
00274     OFCondition getConceptName(DSRCodedEntryValue &conceptName) const;
00275 
00284     virtual OFCondition setConceptName(const DSRCodedEntryValue &conceptName);
00285 
00291     inline const OFString &getObservationDateTime() const
00292     {
00293         return ObservationDateTime;
00294     }
00295 
00304     virtual OFCondition setObservationDateTime(const OFString &observationDateTime);
00305 
00318     OFCondition getTemplateIdentification(OFString &templateIdentifier,
00319                                           OFString &mappingResource) const;
00320 
00328     virtual OFCondition setTemplateIdentification(const OFString &templateIdentifier,
00329                                                   const OFString &mappingResource);
00330 
00335     void removeSignatures();
00336 
00337 
00338   protected:
00339 
00343     inline DSRCodedEntryValue *getConceptNamePtr()
00344     {
00345         return &ConceptName;
00346     }
00347 
00359     OFCondition createAndAppendNewNode(DSRDocumentTreeNode *&previousNode,
00360                                        const E_RelationshipType relationshipType,
00361                                        const E_ValueType valueType,
00362                                        const DSRIODConstraintChecker *constraintChecker = NULL);
00363 
00370     virtual OFCondition readContentItem(DcmItem &dataset);
00371 
00378     virtual OFCondition writeContentItem(DcmItem &dataset) const;
00379 
00387     virtual OFCondition readXMLContentItem(const DSRXMLDocument &doc,
00388                                            DSRXMLCursor cursor);
00389 
00401     virtual OFCondition renderHTMLContentItem(STD_NAMESPACE ostream &docStream,
00402                                               STD_NAMESPACE ostream &annexStream,
00403                                               const size_t nestingLevel,
00404                                               size_t &annexNumber,
00405                                               const size_t flags) const;
00406 
00413     void writeXMLItemStart(STD_NAMESPACE ostream &stream,
00414                            const size_t flags,
00415                            const OFBool closingBracket = OFTrue) const;
00416 
00421     void writeXMLItemEnd(STD_NAMESPACE ostream &stream,
00422                          const size_t flags) const;
00423 
00430     OFCondition readSRDocumentContentModule(DcmItem &dataset,
00431                                             const DSRIODConstraintChecker *constraintChecker,
00432                                             const size_t flags);
00433 
00440     OFCondition writeSRDocumentContentModule(DcmItem &dataset,
00441                                              DcmStack *markedItems);
00442 
00450     OFCondition readDocumentRelationshipMacro(DcmItem &dataset,
00451                                               const DSRIODConstraintChecker *constraintChecker,
00452                                               const OFString &posString,
00453                                               const size_t flags);
00454 
00461     OFCondition writeDocumentRelationshipMacro(DcmItem &dataset,
00462                                                DcmStack *markedItems);
00463 
00470     OFCondition readDocumentContentMacro(DcmItem &dataset,
00471                                          const OFString &posString,
00472                                          const size_t flags);
00473 
00478     OFCondition writeDocumentContentMacro(DcmItem &dataset) const;
00479 
00487     OFCondition readContentSequence(DcmItem &dataset,
00488                                     const DSRIODConstraintChecker *constraintChecker,
00489                                     const OFString &posString,
00490                                     const size_t flags);
00491 
00498     OFCondition writeContentSequence(DcmItem &dataset,
00499                                      DcmStack *markedItems) const;
00500 
00507     OFCondition renderHTMLConceptName(STD_NAMESPACE ostream &docStream,
00508                                       const size_t flags) const;
00509 
00519     OFCondition renderHTMLChildNodes(STD_NAMESPACE ostream &docStream,
00520                                      STD_NAMESPACE ostream &annexStream,
00521                                      const size_t nestingLevel,
00522                                      size_t &annexNumber,
00523                                      const size_t flags) const;
00524 
00525   // --- static function ---
00526 
00535     static const OFString &getRelationshipText(const E_RelationshipType relationshipType,
00536                                                OFString &relationshipText,
00537                                                const size_t flags);
00538 
00539 
00540   private:
00541 
00543     OFBool                   MarkFlag;
00545     OFBool                   ReferenceTarget;
00546 
00548     const E_RelationshipType RelationshipType;
00550     const E_ValueType        ValueType;
00551 
00553     DSRCodedEntryValue       ConceptName;
00555     OFString                 ObservationDateTime;
00556 
00558     OFString                 TemplateIdentifier;
00560     OFString                 MappingResource;
00561 
00563     DcmSequenceOfItems       MACParameters;
00565     DcmSequenceOfItems       DigitalSignatures;
00566 
00567 
00568  // --- declaration of default/copy constructor and assignment operator
00569 
00570     DSRDocumentTreeNode();
00571     DSRDocumentTreeNode(const DSRDocumentTreeNode &);
00572     DSRDocumentTreeNode &operator=(const DSRDocumentTreeNode &);
00573 };
00574 
00575 
00576 #endif
00577 
00578 
00579 /*
00580  *  CVS/RCS Log:
00581  *  $Log: dsrdoctn.h,v $
00582  *  Revision 1.27  2010-10-14 13:16:32  joergr
00583  *  Updated copyright header. Added reference to COPYRIGHT file.
00584  *
00585  *  Revision 1.26  2009-10-13 14:57:50  uli
00586  *  Switched to logging mechanism provided by the "new" oflog module.
00587  *
00588  *  Revision 1.25  2008-05-19 09:48:32  joergr
00589  *  Fixed typo.
00590  *
00591  *  Revision 1.24  2007-11-15 16:33:30  joergr
00592  *  Added support for output in XHTML 1.1 format.
00593  *
00594  *  Revision 1.23  2006/08/15 16:40:03  meichel
00595  *  Updated the code in module dcmsr to correctly compile when
00596  *    all standard C++ classes remain in namespace std.
00597  *
00598  *  Revision 1.22  2006/05/11 09:18:21  joergr
00599  *  Moved containsExtendedCharacters() from dcmsr to dcmdata module.
00600  *
00601  *  Revision 1.21  2005/12/08 16:05:00  meichel
00602  *  Changed include path schema for all DCMTK header files
00603  *
00604  *  Revision 1.20  2004/11/22 16:39:09  meichel
00605  *  Added method that checks if the SR document contains non-ASCII characters
00606  *    in any of the strings affected by SpecificCharacterSet.
00607  *
00608  *  Revision 1.19  2003/12/16 15:57:51  joergr
00609  *  Added note that the condition for the Content Template Sequence is currently
00610  *  not checked.
00611  *
00612  *  Revision 1.18  2003/10/30 17:53:02  joergr
00613  *  Added full support for the ContentTemplateSequence (read/write, get/set
00614  *  template identification). Template constraints are not checked yet.
00615  *
00616  *  Revision 1.17  2003/10/06 09:52:58  joergr
00617  *  Added new flag which allows to ignore content item errors when reading an SR
00618  *  document (e.g. missing value type specific attributes).
00619  *
00620  *  Revision 1.16  2003/09/15 14:18:54  joergr
00621  *  Introduced new class to facilitate checking of SR IOD relationship content
00622  *  constraints. Replaced old implementation distributed over numerous classes.
00623  *
00624  *  Revision 1.15  2003/08/07 17:31:00  joergr
00625  *  Removed libxml dependency from header files. Simplifies linking (MSVC).
00626  *
00627  *  Revision 1.14  2003/08/07 12:34:06  joergr
00628  *  Added readXML functionality.
00629  *  Updated documentation to get rid of doxygen warnings.
00630  *
00631  *  Revision 1.13  2002/08/02 12:38:31  joergr
00632  *  Enhanced debug output of dcmsr::read() routines (e.g. add position string
00633  *  of invalid content items to error messages).
00634  *
00635  *  Revision 1.12  2001/11/09 16:10:49  joergr
00636  *  Added preliminary support for Mammography CAD SR.
00637  *
00638  *  Revision 1.11  2001/09/26 13:04:07  meichel
00639  *  Adapted dcmsr to class OFCondition
00640  *
00641  *  Revision 1.10  2001/04/03 08:24:01  joergr
00642  *  Added new command line option: ignore relationship content constraints
00643  *  specified for each SR document class.
00644  *
00645  *  Revision 1.9  2001/02/02 14:37:33  joergr
00646  *  Added new option to dsr2xml allowing to specify whether value and/or
00647  *  relationship type are to be encoded as XML attributes or elements.
00648  *
00649  *  Revision 1.8  2001/01/18 15:53:34  joergr
00650  *  Added support for digital signatures.
00651  *
00652  *  Revision 1.7  2000/11/13 10:26:21  joergr
00653  *  Added output of optional observation datetime to rendered HTML page.
00654  *
00655  *  Revision 1.6  2000/11/07 18:14:28  joergr
00656  *  Enhanced support for by-reference relationships.
00657  *
00658  *  Revision 1.5  2000/11/01 16:23:19  joergr
00659  *  Added support for conversion to XML.
00660  *
00661  *  Revision 1.4  2000/10/26 14:17:38  joergr
00662  *  Added support for "Comprehensive SR".
00663  *
00664  *  Revision 1.3  2000/10/23 15:10:29  joergr
00665  *  Added/updated doc++ comments.
00666  *
00667  *  Revision 1.2  2000/10/18 17:02:27  joergr
00668  *  Added methods allowing direct access to certain content item values.
00669  *  Made some functions inline.
00670  *
00671  *  Revision 1.1  2000/10/13 07:49:26  joergr
00672  *  Added new module 'dcmsr' providing access to DICOM structured reporting
00673  *  documents (supplement 23).  Doc++ documentation not yet completed.
00674  *
00675  *
00676  */


Generated on 6 Jan 2011 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.5.1