# HG changeset patch # User Sebastien Jodogne # Date 1507456016 -7200 # Node ID b340f0a9022c635425753eb48742574705e0454c # Parent d0fe5ec7eb051b67d79f3e6007efb1311cb9381f New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR diff -r d0fe5ec7eb05 -r b340f0a9022c Core/DicomParsing/DicomDirWriter.cpp --- a/Core/DicomParsing/DicomDirWriter.cpp Sun Oct 08 11:13:56 2017 +0200 +++ b/Core/DicomParsing/DicomDirWriter.cpp Sun Oct 08 11:46:56 2017 +0200 @@ -128,8 +128,9 @@ class DicomDirWriter::PImpl { private: - std::string fileSetId_; - TemporaryFile file_; + std::string fileSetId_; + bool extendedSopClass_; + TemporaryFile file_; std::auto_ptr dir_; typedef std::pair IndexKey; @@ -257,8 +258,26 @@ public: - PImpl() : fileSetId_("ORTHANC_MEDIA") + PImpl() : + fileSetId_("ORTHANC_MEDIA"), + extendedSopClass_(false) + { + } + + void EnableExtendedSopClass(bool enable) { + if (enable) + { + LOG(WARNING) << "Generating a DICOMDIR with type 3 attributes, " + << "which leads to an Extended SOP Class"; + } + + extendedSopClass_ = enable; + } + + bool IsExtendedSopClass() const + { + return extendedSopClass_; } void FillPatient(DcmDirectoryRecord& record, @@ -319,6 +338,14 @@ CopyStringType1(record, dicom, encoding, DCM_SeriesInstanceUID); /* use type 1C instead of 1 in order to avoid unwanted overwriting */ CopyStringType1C(record, dicom, encoding, DCM_SeriesNumber); + + // Add extended (non-standard) type 3 tags, those are not generated by DCMTK + // http://dicom.nema.org/medical/Dicom/2016a/output/chtml/part02/sect_7.3.html + // https://groups.google.com/d/msg/orthanc-users/Y7LOvZMDeoc/9cp3kDgxAwAJ + if (extendedSopClass_) + { + CopyStringType3(record, dicom, encoding, DCM_SeriesDescription); + } } void FillInstance(DcmDirectoryRecord& record, @@ -522,4 +549,16 @@ { pimpl_->Read(target); } + + + void DicomDirWriter::EnableExtendedSopClass(bool enable) + { + pimpl_->EnableExtendedSopClass(enable); + } + + + bool DicomDirWriter::IsExtendedSopClass() const + { + return pimpl_->IsExtendedSopClass(); + } } diff -r d0fe5ec7eb05 -r b340f0a9022c Core/DicomParsing/DicomDirWriter.h --- a/Core/DicomParsing/DicomDirWriter.h Sun Oct 08 11:13:56 2017 +0200 +++ b/Core/DicomParsing/DicomDirWriter.h Sun Oct 08 11:46:56 2017 +0200 @@ -57,6 +57,10 @@ ParsedDicomFile& dicom); void Encode(std::string& target); + + void EnableExtendedSopClass(bool enable); + + bool IsExtendedSopClass() const; }; } diff -r d0fe5ec7eb05 -r b340f0a9022c NEWS --- a/NEWS Sun Oct 08 11:13:56 2017 +0200 +++ b/NEWS Sun Oct 08 11:46:56 2017 +0200 @@ -6,6 +6,7 @@ * New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip * New argument "ignore-length" to force the inclusion of too long tags in JSON +* New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR Maintenance ----------- diff -r d0fe5ec7eb05 -r b340f0a9022c OrthancServer/OrthancRestApi/OrthancRestArchive.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestArchive.cpp Sun Oct 08 11:13:56 2017 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestArchive.cpp Sun Oct 08 11:46:56 2017 +0200 @@ -625,7 +625,8 @@ static void Apply(RestApiOutput& output, ServerContext& context, ArchiveIndex& archive, - const std::string& filename) + const std::string& filename, + bool enableExtendedSopClass) { archive.Expand(context.GetIndex()); @@ -643,10 +644,12 @@ writer.SetZip64(isZip64); writer.OpenDirectory("IMAGES"); - // Create the DICOMDIR writer - DicomDirWriter dicomDir; + // Create a DICOMDIR writer + MediaWriterVisitor v(writer, context); - MediaWriterVisitor v(writer, context); + // Request type-3 arguments to be added to the DICOMDIR + v.dicomDir_.EnableExtendedSopClass(enableExtendedSopClass); + archive.Apply(v); // Add the DICOMDIR @@ -723,7 +726,8 @@ MediaWriterVisitor::Apply(call.GetOutput(), OrthancRestApi::GetContext(call), archive, - "Archive.zip"); + "Archive.zip", + false); } } @@ -758,7 +762,8 @@ MediaWriterVisitor::Apply(call.GetOutput(), OrthancRestApi::GetContext(call), archive, - id + ".zip"); + id + ".zip", + call.HasArgument("extended")); }