in fhir-auth-tx/src/main/java/sample/camel/MyCamelRouter.java [37:62]
public void configure() throws Exception {
from("file:{{input}}").routeId("fhir-example")
.onException(ProtocolException.class)
.handled(true)
.log(LoggingLevel.ERROR, "Error connecting to FHIR server with URL:{{serverUrl}}, please check the application.properties file ${exception.message}")
.end()
.log("Converting ${file:name}")
.unmarshal().csv()
.process(exchange -> {
List<Patient> bundle = new ArrayList<>();
@SuppressWarnings("unchecked")
List<List<String>> patients = (List<List<String>>) exchange.getIn().getBody();
for (List<String> patient: patients) {
Patient fhirPatient = new Patient();
fhirPatient.setId(patient.get(0));
fhirPatient.addName().addGiven(patient.get(1));
fhirPatient.getNameFirstRep().setFamily(patient.get(2));
bundle.add(fhirPatient);
}
exchange.getIn().setBody(bundle);
})
// create Patient in our FHIR server
.to("fhir://transaction/withResources?inBody=resources&serverUrl={{serverUrl}}&username={{serverUser}}&password={{serverPassword}}&fhirVersion={{fhirVersion}}")
// log the outcome
.log("Patients created successfully: ${body}");
}