Hello Community,
I'm a beginner and currently working on a project to convert CCDA files to FHIR using InterSystems IRIS. I have developed a web form to upload CCDA files, and I'm attempting to convert the uploaded CCDA files to FHIR. However, I am encountering an issue where the conversion process results in an empty entry.
Here's the Output it displays on HTML page:
Size of CCDA Stream: 74152
vR4
{"resourceType":"Bundle","type":"transaction","entry":[]}
Here is my code: CCDtoFHIR.csp
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CCDA to FHIR Converter</title>
</head>
<body>
<section>
<div>
<p>CCDA to FHIR Converter</p>
<div>
<div>
<h1>Upload CCDA File</h1>
<form id="fileUploadForm" enctype="multipart/form-data" method="post" action="CCDtoFHIR.csp">
<div>
<label for="file">Upload CCDA File</label>
<input type="file" name="file" id="file" required>
</div>
<div>
<button type="submit">Upload</button>
</div>
</form>
<csp:if condition='($data(%request.MimeData("file",1)))'>
<hr><br>
<b>FHIR Conversion Result:</b><br>
<ul>
<script language="cache" runat="server">
try {
// Read the uploaded file stream
set ccdaStream = ##class(%Stream.TmpBinary).%New()
do ccdaStream.CopyFrom(%request.MimeData("file",1))
// Ensure the stream is an object
if ('$isobject(ccdaStream)) {
write "Failed to read uploaded file stream"
quit
}
// Debug: Output the size of the CCDA stream
write "Size of CCDA Stream: ", ccdaStream.Size, "<br>"
// Read some content from the stream for debugging
do ccdaStream.Rewind()
// Determine the appropriate XSLT transform based on the document type
set xsltTransform = "SDA3/CCDA-to-SDA.xsl" // Default to CCDA-to-SDA
// Convert CCDA to SDA3 using HealthShare's built-in methods
set tTransformer = ##class(HS.Util.XSLTTransformer).%New()
set tSC = tTransformer.Transform(ccdaStream, xsltTransform, .tSDA3Stream)
if $$$ISERR(tSC) {
write "Transformation to SDA3 failed", "<br>"
quit
}
set sdaStream = ##class(%Stream.TmpBinary).%New()
do tSDA3Stream.Rewind()
do sdaStream.CopyFrom(tSDA3Stream)
// Convert SDA3 to FHIR using HealthShare's built-in methods
set fhirStream = ##class(%Stream.TmpBinary).%New()
set SDA3ToFHIRObject = ##class(HS.FHIR.DTL.Util.API.Transform.SDA3ToFHIR).TransformStream(tSDA3Stream, "HS.SDA3.Container", "R4")
// Check if the transformation returned a valid bundle
if '$isobject(SDA3ToFHIRObject.bundle) {
write "Failed to transform SDA3 to FHIR", "<br>"
quit
}
// Serialize the FHIR bundle to JSON
do SDA3ToFHIRObject.bundle.%ToJSON(fhirStream)
do fhirStream.Rewind()
// Write the FHIR data to the response
while ('fhirStream.AtEnd) {
write fhirStream.ReadLine(), "<br>"
}
} catch (ex) {
// Handle exceptions
write "Error during conversion: ", ex.DisplayString(), "<br>"
}
</script>
</ul>
</csp:if>
</div>
</div>
</div>
</section>
</body>
</html>
Problem Description:
- The CCDA file uploads successfully, and I can see the size of the uploaded stream.
- The transformation to SDA3 seems to work fine without errors.
- The conversion from SDA3 to FHIR appears to be successful, but the resulting FHIR bundle is empty.
Debugging Steps:
- I've ensured that the CCDA stream is read correctly.
- I confirmed that the transformation to SDA3 does not produce any errors.
- I attempted to output some content from the SDA3 stream, which seems fine.
- The FHIR transformation does not produce any errors, but the resulting FHIR bundle is empty.
Questions:
- What could be the reason for obtaining an empty FHIR bundle after the transformation?
- Are there any additional debugging steps or checks I can perform to identify the issue?
- Is there a specific configuration or additional steps required for the
HS.FHIR.DTL.Util.API.Transform.SDA3ToFHIR
transformation process?