fw4spl
StructuredReport.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2016.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWGDCMIO_HELPER_STRUCTUREDREPORT_HPP__
8 #define __FWGDCMIO_HELPER_STRUCTUREDREPORT_HPP__
9 
10 #include "fwGdcmIO/container/sr/DicomSRContainerNode.hpp"
11 #include "fwGdcmIO/container/sr/DicomSRNode.hpp"
12 #include "fwGdcmIO/helper/DicomDataReader.hxx"
13 
14 #include <gdcmDataSet.h>
15 #include <gdcmSequenceOfItems.h>
16 
17 namespace fwGdcmIO
18 {
19 
20 namespace helper
21 {
22 
26 class FWGDCMIO_CLASS_API StructuredReport
27 {
28 public:
29 
35  readSR(const ::gdcm::DataSet& dataset);
36 
42  FWGDCMIO_API static void dumpSR(const SPTR(::fwGdcmIO::container::sr::DicomSRNode)& root,
43  std::ostream& out = std::cout);
44 
45 protected:
46 
52  static void readSubNodeContainer(const ::gdcm::DataSet& dataset,
54 
60  static void readSubNode(const ::gdcm::DataSet& dataset,
62 
69  FWGDCMIO_API static void dumpSRNode(const SPTR(::fwGdcmIO::container::sr::DicomSRNode)& node,
70  std::ostream& out, int& index);
71 
79  template <uint16_t GROUP, uint16_t ELEMENT>
80  static ::fwGdcmIO::container::DicomCodedAttribute readCodeSequence(const ::gdcm::DataSet& dataset)
81  {
83 
84  if ( !dataset.FindDataElement(::gdcm::Tag(GROUP,ELEMENT)))
85  {
86  // Return empty coded attributes
87  return codedAttributes;
88  }
89 
90  ::gdcm::SmartPointer< ::gdcm::SequenceOfItems > sequence =
91  dataset.GetDataElement(::gdcm::Tag(GROUP,ELEMENT)).GetValueAsSQ();
92  if (sequence->GetNumberOfItems() == 0) // One Item shall be permitted
93  {
94  // Return empty coded attributes
95  return codedAttributes;
96  }
97 
98  const ::gdcm::DataSet& itemDataset = sequence->GetItem(1).GetNestedDataSet();
99 
100  // Code value - Type 1
101  auto codeValue = ::fwGdcmIO::helper::DicomDataReader::getTagValue<0x0008,0x0100>(itemDataset);
102 
103  // Coding Scheme Designator - Type 1
104  auto codingSchemeDesignator = ::fwGdcmIO::helper::DicomDataReader::getTagValue<0x0008,0x0102>(itemDataset);
105 
106  // Coding Scheme Version - Type 1C
107  auto codingSchemeVersion = ::fwGdcmIO::helper::DicomDataReader::getTagValue<0x0008,0x0103>(itemDataset);
108 
109  // Code Meaning - Type 1
110  auto codeMeaning = ::fwGdcmIO::helper::DicomDataReader::getTagValue<0x0008,0x0104>(itemDataset);
111 
112  return ::fwGdcmIO::container::DicomCodedAttribute(codeValue,
113  codingSchemeDesignator,
114  codeMeaning,
115  codingSchemeVersion);
116  }
117 };
118 
119 } // namespace helper
120 } // namespace fwGdcmIO
121 
122 #endif /*__FWGDCMIO_HELPER_STRUCTUREDREPORT_HPP__*/
#define SPTR(_cls_)
The namespace fwGdcmIO contains reader, writer and helper for dicom data.
This class defines a node in a SR document.
Definition: DicomSRNode.hpp:27
This class represents a DICOM basic coded entry. It stores the four mains attributes : Code Value...
::fwGdcmIO::container::DicomCodedAttribute readCodeSequence(const ::gdcm::DataSet &dataset)
Read content of a code sequence (eg : Concept Name Code Sequence, ...)
This class defines a CONTAINER node in a SR document.
This class contains helpers for DICOM Structured Reporting (SR).