Sidebar

Is there a detailed document covering wrapping a PDF in DICOM and sending is via HL7

0 votes
132 views
asked Feb 20 by eric-b-9094 (140 points)
My solution generates a PDF and sends it via HL7 today, but we want to send to more PACS systems and need to add DICOM support.

1 Answer

0 votes

The DICOM standard allows for an Encapsulated PDF in a DICOM file.  Given your question, I created a sample channel that receives an HL7 MDM message with a base64 encoded PDF.

The result is a DICOM file with the demographics and other tags populated based on the MDM message.

message = qie.createDICOMMessage();

/*
The tags required for a DICOM Encapsulated PDF was taken from here:
https://github.com/dcm4che/dcm4che/blob/master/dcm4che-assembly/src/etc/pdf2dcm/encapsulatedPDFMetadata.xml
*/

// Patient Name
message.setNode("10,10", source.getNode("PID-5"));
// Patient ID
message.setNode("10,20", source.getNode("PID-3"));
// Patient DOB
message.setNode("10,30", source.getNode("PID-7"));
// Patient Sex
message.setNode("10,40", source.getNode("PID-8"));

// Date and time
var studyDatetime = source.getNode("TXA-6");
if (StringUtils.isBlank(studyDatetime)) {
   studyDatetime = source.getNode("TXA-4");
}
message.setNode("8,20", qie.formatDate('yyyyMMdd', studyDatetime));
message.setNode("8,30", qie.formatDate('HHmmss', studyDatetime));

// Provider
message.setNode("8,90", source.getNode("PV1-8.2") + "^" + source.getNode("PV1-8.3"));
// Study ID
message.setNode("20,10", source.getNode("TXA-12.1"));
// Accession
message.setNode("8,50", source.getNode("TXA-12.1"));
// Modality
message.setNode("8,60", "DOC");
// Manufacturer
message.setNode("8,70", "QIE");
// Conversion Type
message.setNode("8,64", "SD");
// MIME Type
message.setNode("42,12", "application/pdf");
// SOPClassUID
message.setNode("8,16", "1.2.840.10008.5.1.4.1.1.104.1");
// SOP Instance UID
message.setNode("8,18", qie.generateDICOMInstanceUID());
// Instance Number
message.setNode("20,13", "1");
// Document Title
message.setNode("42,10", source.getNode("OBX-3.2"));
// ConceptNameCodeSequence
// message.setDICOMSequence("40,A043", "");
// Burned In Annotation
message.setNode("28,0301", "YES");

/*
The following shows, we can add the PDF bytes to the Encapsulated Data tag.
https://github.com/dcm4che/dcm4che/blob/master/dcm4che-tool/dcm4che-tool-pdf2dcm/src/main/java/org/dcm4che3/tool/pdf2dcm/Pdf2Dcm.java
*/

// OBX-5.5 is Base64 Encoded
var pdfBytes = qie.base64DecodeToBytes(source.getNode("OBX-5.5"));
message.setDICOMBytes('0042,0011', pdfBytes);

// If using the test window, you could write the DICOM to a file without starting the channel.
// qie.writeFile('/Users/Shared/dicom/EncapsulatedPDF/' + qie.getUUID(false), message.getDICOMBytesForFile(), true);

Here is an importable QIE channel with some sample messages.

answered Feb 23 by mike-r-7535 (13,830 points)
...