# HG changeset patch # User Sebastien Jodogne # Date 1548249790 -3600 # Node ID b6e7714c3fe6c207fc48365900e97674886bf628 # Parent 8a9eb767280cd575ec4e3d9b0249b304956679c6 Don't return tags whose group is below 0x0008 in C-FIND SCP diff -r 8a9eb767280c -r b6e7714c3fe6 Core/DicomNetworking/DicomFindAnswers.cpp --- a/Core/DicomNetworking/DicomFindAnswers.cpp Wed Jan 23 09:32:59 2019 +0100 +++ b/Core/DicomNetworking/DicomFindAnswers.cpp Wed Jan 23 14:23:10 2019 +0100 @@ -150,7 +150,35 @@ DcmDataset* DicomFindAnswers::ExtractDcmDataset(size_t index) const { - return new DcmDataset(*GetAnswer(index).GetDcmtkObject().getDataset()); + // As "DicomFindAnswers" stores its content using class + // "ParsedDicomFile" (that internally uses "DcmFileFormat" from + // DCMTK), the dataset can contain tags that are reserved if + // storing the media on the disk, notably tag + // "MediaStorageSOPClassUID" (0002,0002). In this function, we + // remove all those tags whose group is below 0x0008. The + // resulting data set is clean for emission in the C-FIND SCP. + + // http://dicom.nema.org/medical/dicom/current/output/chtml/part04/sect_C.4.html#sect_C.4.1.1.3 + // https://groups.google.com/d/msg/orthanc-users/D3kpPuX8yV0/_zgHOzkMEQAJ + + DcmDataset& source = *GetAnswer(index).GetDcmtkObject().getDataset(); + + std::auto_ptr target(new DcmDataset); + + for (unsigned long i = 0; i < source.card(); i++) + { + const DcmElement* element = source.getElement(i); + assert(element != NULL); + + if (element != NULL && + element->getTag().getGroup() >= 0x0008 && + element->getTag().getElement() != 0x0000) + { + target->insert(dynamic_cast(element->clone())); + } + } + + return target.release(); } diff -r 8a9eb767280c -r b6e7714c3fe6 NEWS --- a/NEWS Wed Jan 23 09:32:59 2019 +0100 +++ b/NEWS Wed Jan 23 14:23:10 2019 +0100 @@ -3,6 +3,7 @@ * Fix compatibility with DICOMweb plugin (allow multipart answers over HTTP Keep-Alive) * Fix issue #128 (Asynchronous C-MOVE: invalid number of remaining sub-operations) +* Don't return tags whose group is below 0x0008 in C-FIND SCP Version 1.5.2 (2019-01-18)