7 #include "fwGdcmIO/writer/ie/Document.hpp" 9 #include "fwGdcmIO/helper/DicomDataWriter.hxx" 10 #include "fwGdcmIO/helper/StructuredReport.hpp" 11 #include "fwGdcmIO/writer/tid/MeasurementReport.hpp" 13 #include <fwData/PointList.hpp> 14 #include <fwData/String.hpp> 15 #include <fwData/Vector.hpp> 17 #include <fwMedData/Series.hpp> 18 #include <fwMedData/types.hpp> 20 #include <fwTools/dateAndTime.hpp> 22 #include <boost/algorithm/string/split.hpp> 24 #include <gdcmUIDGenerator.h> 39 const ::fwData::Image::csptr& image,
41 const ::fwLog::Logger::sptr& logger,
42 ProgressCallback progress,
43 CancelRequestedCallback cancel) :
60 ::gdcm::DataSet& dataset =
m_writer->GetFile().GetDataSet();
62 ::boost::posix_time::ptime ptime = boost::posix_time::second_clock::local_time();
65 ::fwGdcmIO::helper::DicomDataWriter::setTagValue< int, 0x0020, 0x0013 >(0, dataset);
68 const std::string date = ::fwTools::getDate(ptime);
69 ::fwGdcmIO::helper::DicomDataWriter::setTagValue< 0x0008, 0x0023 >(date, dataset);
72 const std::string time = ::fwTools::getTime(ptime);
73 ::fwGdcmIO::helper::DicomDataWriter::setTagValue< 0x0008, 0x0033 >(time, dataset);
76 ::fwGdcmIO::helper::DicomDataWriter::createAndSetSequenceTagValue< 0x0040, 0xa372 >(dataset);
79 ::fwGdcmIO::helper::DicomDataWriter::setTagValue< 0x0040, 0xa491 >(
"PARTIAL", dataset);
82 ::fwGdcmIO::helper::DicomDataWriter::setTagValue< 0x0040, 0xa493 >(
"UNVERIFIED", dataset);
94 ::gdcm::DataSet& dataset =
m_writer->GetFile().GetDataSet();
97 ::gdcm::SmartPointer< ::gdcm::SequenceOfItems > sequence = new ::gdcm::SequenceOfItems();
98 sequence->SetLengthToUndefined();
99 ::fwGdcmIO::helper::DicomDataWriter::createAndSetSequenceTagValue< 0x0040, 0xa385 >(dataset);
102 ::gdcm::Item studyItem;
103 studyItem.SetVLToUndefined();
104 ::gdcm::DataSet& studyItemDataset = studyItem.GetNestedDataSet();
105 ::fwGdcmIO::helper::DicomDataWriter::setTagValue< 0x0020, 0x000D >(
106 m_instance->getStudyInstanceUID(), studyItemDataset);
109 ::gdcm::SmartPointer< ::gdcm::SequenceOfItems > seriesSequence = new ::gdcm::SequenceOfItems();
110 seriesSequence->SetLengthToUndefined();
111 ::fwGdcmIO::helper::DicomDataWriter::setSequenceTagValue< 0x0008, 0x1115 >(seriesSequence, studyItemDataset);
114 ::gdcm::Item seriesItem;
115 seriesItem.SetVLToUndefined();
116 ::gdcm::DataSet& seriesItemDataset = seriesItem.GetNestedDataSet();
117 ::fwGdcmIO::helper::DicomDataWriter::setTagValue< 0x0020, 0x000E >(
118 m_instance->getSeriesInstanceUID(), seriesItemDataset);
121 ::gdcm::SmartPointer< ::gdcm::SequenceOfItems > sopSequence = new ::gdcm::SequenceOfItems();
122 sopSequence->SetLengthToUndefined();
123 ::fwGdcmIO::helper::DicomDataWriter::setSequenceTagValue< 0x0008, 0x1199 >(sopSequence, seriesItemDataset);
125 for(
const std::string& instanceUID :
m_instance->getSOPInstanceUIDContainer())
128 ::gdcm::Item instanceItem;
129 instanceItem.SetVLToUndefined();
130 ::gdcm::DataSet& instanceItemDataset = instanceItem.GetNestedDataSet();
133 ::fwGdcmIO::helper::DicomDataWriter::setTagValue< 0x0008, 0x1150 >(
134 m_instance->getSOPClassUID(), instanceItemDataset);
137 ::fwGdcmIO::helper::DicomDataWriter::setTagValue< 0x0008, 0x1155 >(instanceUID, instanceItemDataset);
139 sopSequence->AddItem(instanceItem);
142 seriesSequence->AddItem(seriesItem);
143 sequence->AddItem(studyItem);
151 ::gdcm::DataSet& dataset =
m_writer->GetFile().GetDataSet();
156 root->write(dataset);
167 ::gdcm::DataSet& dataset =
m_writer->GetFile().GetDataSet();
170 std::string sopClassUID;
173 sopClassUID = ::gdcm::MediaStorage::GetMSString(::gdcm::MediaStorage::ComprehensiveSR);
179 sopClassUID =
"1.2.840.10008.5.1.4.1.1.88.34";
181 ::fwGdcmIO::helper::DicomDataWriter::setTagValue< 0x0008, 0x0016 >(sopClassUID, dataset);
184 ::gdcm::UIDGenerator uidGenerator;
185 std::string sopInstanceUID = uidGenerator.Generate();
186 ::fwGdcmIO::helper::DicomDataWriter::setTagValue< 0x0008, 0x0018 >(sopInstanceUID, dataset);
FWGDCMIO_API Document(const std::shared_ptr< ::gdcm::Writer > &writer, const std::shared_ptr< ::fwGdcmIO::container::DicomInstance > &instance, const ::fwData::Image::csptr &image, bool use3DSR=false, const ::fwLog::Logger::sptr &logger=nullptr, ProgressCallback progress=nullptr, CancelRequestedCallback cancel=nullptr)
Constructor.
void writePertinentOtherEvidenceSequence()
Write Pertinent Other Evidence Sequence (0040,A385)
virtual FWGDCMIO_API std::shared_ptr< ::fwGdcmIO::container::sr::DicomSRNode > createRootNode(bool useSCoord3D=true)
Create Measurement Report template root node.
This class defines a DICOM SOP instance. It is useful during the whole writing process. This class allows to share data between module writers.
bool m_use3DSR
True if we must use 3DSR.
The namespace fwGdcmIO contains reader, writer and helper for dicom data.
This class defines a node in a SR document.
Image Information Entity class.
virtual FWGDCMIO_API void writeSRDocumentGeneralModule()
Write SR Document General Module tags.
Contains the representation of the data objects used in the framework.
virtual FWGDCMIO_API void writeSRDocumentContentModule()
Write SR Document Content Module tags.
FWGDCMIO_API void writeSOPCommonModule()
Write SOP Common Module tags.
Measurement Report TID - This a root template.
virtual FWGDCMIO_API ~Document()
Destructor.