This is an example application of the camel-fhir component. We’ll be using camel-spring-boot as well for an easy setup.
The Camel route is located in the MyCamelRouter class.
This example will read patients stored in csv files from a directory and convert them to FHIR dtsu3 patients and upload them to a configured FHIR server. Each file is uploaded in a new transaction.
The example assumes you have a running FHIR server at your disposal, which is configured for basic authentication.
You may use [hapi-fhir-jpa-server-example](https://github.com/rkorytkowski/hapi-fhir/tree/basic-auth/hapi-fhir-jpaserver-example). You can start it up by running mvn jetty:run.
By default, the example uses http://localhost:8080/hapi-fhir-jpaserver-example/baseDstu3 as the FHIR server URL, DSTU3 as the FHIR version, BASIC authentication (admin as username and Admin123 as password) and target/work/fhir/input
as the directory to look for csv patients.
However, you can edit the application.properties file to change the defaults and provide your own configuration.
There is an example of a test in the MyCamelApplicationTest class, which mocks out the FHIR server, thus can be run without the FHIR server.
You can run this example using:
$ mvn spring-boot:runWhen the Camel application runs, you should see a folder created under target/work/fhir/input. Copy the file hl7v2.patient
located in the src/main/data folder into it. You should see the following output:
2018-07-24 11:52:51.615 INFO 30666 --- [work/fhir/input] fhir-example: Converting hl7v2.patient
2018-07-24 11:52:52.700 INFO 30666 --- [work/fhir/input] fhir-example: Inserting Patient: {"resourceType":"Patient","id":"100005056","name":[{"family":"Freeman","given":["Vincent"]}]}
2018-07-24 11:52:56.995 INFO 30666 --- [ #2 - CamelFhir] fhir-example: Patient created successfully: ca.uhn.fhir.rest.api.MethodOutcome@270f03f1The Camel application can be stopped pressing kbd:[Ctrl+c] in the shell.
Let create a service account first with all required permissions, first:
oc new-project fhir-test
oc create sa fhir-sa
oc adm policy add-scc-to-user privileged -z fhir-sa -n fhitr-testDeploy a fhir server through this Deployment resource:
kind: Deployment
apiVersion: apps/v1
metadata:
name: fhir
namespace: fhir-test
labels:
app: fhir
spec:
replicas: 1
selector:
matchLabels:
app: fhir
template:
metadata:
creationTimestamp: null
labels:
app: fhir
spec:
containers:
- resources: {}
readinessProbe:
exec:
command:
- bash
- "-c"
- |
curl http://localhost:8080/hapi-fhir-jpaserver-example/baseDtu3/metadata --header "Authorization: Basic YWRtaW46QWRtaW4xMjMK"
initialDelaySeconds: 60
timeoutSeconds: 5
periodSeconds: 10
successThreshold: 1
failureThreshold: 10
terminationMessagePath: /dev/termination-log
name: fhir
livenessProbe:
exec:
command:
- bash
- "-c"
- |
curl http://localhost:8080/hapi-fhir-jpaserver-example/baseDtu3/metadata --header "Authorization: Basic YWRtaW46QWRtaW4xMjMK"
initialDelaySeconds: 60
timeoutSeconds: 5
periodSeconds: 10
successThreshold: 1
failureThreshold: 10
env:
- name: DISABLE_AUTH
value: 'false'
- name: FHIR_USER
value: admin
- name: FHIR_PWD
value: Admin123
- name: hapi.fhir.fhir_version
value: DSTU3
securityContext:
privileged: true
serviceAccountName: fhir-sa
ports:
- name: fhir
containerPort: 8080
protocol: TCP
imagePullPolicy: IfNotPresent
terminationMessagePolicy: File
image: 'quay.io/fuse_qe/hapi-fhir-auth:v3.0.1'
restartPolicy: Always
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
securityContext:
runAsUser: 100
serviceAccountName: fhir-sa
schedulerName: default-scheduler
strategy:
type: RollingUpdateReplace keys in src/main/jkube/configmap.yaml with desired content in application.properties and patients.csv file.
data:
application.properties: |
key1=value1
key2=value2
key3=value3
patients.csv: |
1a,Name1,SureName1
2a,Name2,SureName2You can run this example using:
$ mvn clean install -Popenshift -DskipTestsTo show a summary of spring boot health check
curl -XGET -s http://localhost:8080/actuator/health
If you hit any problem using Camel or have some feedback, then please let us know.
We also love contributors, so get involved :-)
The Camel riders!