Skip to content

How to attach and reference a PDF in Event Summary -> Event Details section #5

@utsavik

Description

@utsavik

Hello,
I am attempting to create an Event Summary CDA Document using this java library. As per the ADHA Event Summary specification I could find ways to attach a pdf for Diagnostic Imaging or Pathology Report under Diagnostic Investigations.

My use case requires me to attach and link a PDF clinical report as part of the Event Summary. I am trying to add the link to PDF under the Event Details Section in the Narrative. I managed to add a link but I am unable to figure out how to attach the PDF so that it can be reference by the link tag.

Has anyone tried the above before? Any assistance or nudge in the right direction will be very much appreciated!

I tried the following but it did not work,

   // Prepare Event Summary Content
    EventSummaryContent eventSummaryContent = new EventSummaryContentImpl();
    //Attach PDF as Structured FIle to Event Summary content
    String base64Pdf = "base64 for the pdf goes here";

    // File path to save the PDF
    String filePath = "EventSummary.pdf";

    // Decode the base64 string
    byte[] decodedPdf = java.util.Base64.getDecoder().decode(base64Pdf);

    // Create a new file
    File file = new File(filePath);

    // Write the decoded content to the file
    try (FileOutputStream fos = new FileOutputStream(file)) {
         fos.write(decodedPdf);
    }

    AttachedMedia attachedMedia = new AttachedMedia(file);
    attachedMedia.setFileName("EventSummary.pdf");
    attachedMedia.setMediaType("application/pdf"); // Set the content type of the attachment

    // Add the attachment to the Event Summary
    eventSummaryContent.setStructuredBodyFiles(attachedMedia);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions