Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
utsavik opened this issue Mar 11, 2024 · 0 comments

Comments

@utsavik
Copy link

utsavik commented Mar 11, 2024

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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant