Created
July 11, 2018 10:21
-
-
Save johnpoth/dc70a307dc8a75fb03cf1217d19c5623 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from("file:{{input}}").routeId("fhir-example") // (1) | |
.onException(ProtocolException.class) // (2) | |
.handled(true) | |
.log(LoggingLevel.ERROR, "Error connecting to FHIR server with URL:{{serverUrl}}, please check the application.properties file ${exception.message}") | |
.end() | |
.onException(HL7Exception.class) | |
.handled(true) | |
.log(LoggingLevel.ERROR, "Error unmarshalling ${file:name} ${exception.message}") | |
.end() | |
.log("Converting ${file:name}") | |
// unmarshall file to hl7 message | |
.unmarshal().hl7() // (3) | |
// very simple mapping from a HLV2 patient to dstu3 patient | |
.process(exchange -> { // (4) | |
ORU_R01 msg = exchange.getIn().getBody(ORU_R01.class); | |
final PID pid = msg.getPATIENT_RESULT().getPATIENT().getPID(); | |
String surname = pid.getPatientName()[0].getFamilyName().getFn1_Surname().getValue(); | |
String name = pid.getPatientName()[0].getGivenName().getValue(); | |
String patientId = msg.getPATIENT_RESULT().getPATIENT().getPID().getPatientID().getCx1_ID().getValue(); | |
Patient patient = new Patient(); | |
patient.addName().addGiven(name); | |
patient.getNameFirstRep().setFamily(surname); | |
patient.setId(patientId); | |
exchange.getIn().setBody(patient); | |
}) | |
// marshall to JSON for logging | |
.marshal().fhirJson("{{fhirVersion}}") // (5) | |
.log("Inserting Patient: ${body}") | |
// create Patient in our FHIR server | |
.to("fhir://create/resource?inBody=resourceAsString&serverUrl={{serverUrl}}&fhirVersion={{fhirVersion}}") // (6) | |
// log the outcome | |
.log("Patient created successfully: ${body.getCreated}"); // (7) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment