Hello everyone, welcome to the AI Prompt Contest!
For your inspiration here we share the first two Promts we experimented with at Meditecs (source)
Question: Can you create a sample transformation converting HL7 v2.4 to FHIR R4 in Mirth integration engine?
ChatGPT answer in 2024
Creating a transformation to convert HL7 v2.4 to FHIR R4 in the Mirth integration engine requires mapping each relevant HL7 segment to its corresponding FHIR resource format. Below is a sample JavaScript transformation script for Mirth Connect, focusing on patient demographics from an HL7 ADT (Admit, Discharge, Transfer) message to a FHIR Patient resource.
// Initialize FHIR Patient Resource
var patientResource = {
resourceType: "Patient",
identifier: [],
name: [],
telecom: [],
gender: "",
birthDate: ""
};
// Map HL7 PID Segment to FHIR Patient Resource
var pid = msg['PID'];
// Patient Identifier (from PID-3)
if (pid['PID.3']['PID.3.1'].toString()) {
patientResource.identifier.push({
use: "usual",
system: "urn:oid:1.2.36.146.595.7.3.1.1",
value: pid['PID.3']['PID.3.1'].toString()
});
}
// Patient Name (from PID-5)
if (pid['PID.5']['PID.5.1'].toString()) {
patientResource.name.push({
use: "official",
family: pid['PID.5']['PID.5.1'].toString(),
given: [pid['PID.5']['PID.5.2'].toString()]
});
}
// Telecom - Phone Number (from PID-13)
if (pid['PID.13']['PID.13.1'].toString()) {
patientResource.telecom.push({
system: "phone",
value: pid['PID.13']['PID.13.1'].toString(),
use: "home"
});
}
// Gender (from PID-8)
switch (pid['PID.8'].toString()) {
case 'M':
patientResource.gender = "male";
break;
case 'F':
patientResource.gender = "female";
break;
default:
patientResource.gender = "unknown";
}
// Output FHIR Patient Resource as JSON
return JSON.stringify(patientResource, null, 2);
Explanation of Key Transformations
- Identifier (PID-3): Maps the patient identifier from HL7 to the identifier array in the FHIR Patient resource.
- Name (PID-5): Constructs the name array with family and given names.
- Telecom (PID-13): Adds the patient’s phone number to the telecom array.
- Gender (PID-8): Translates gender values (M/F) from HL7 to FHIR-compliant terms.
- Birth Date (PID-7): Reformats the birth date from HL7 to the FHIR YYYY-MM-DD format.
Additional Notes
- Ensure that the Destination Connector is configured to send or store the JSON output.
- You may need to modify or expand the script to cover other segments (e.g., visit information) depending on your integration requirements.
Would you like an example covering additional HL7 segments or a different FHIR resource?
Feel free to comment and upvote, and of course upload your own Prompt to win!
