-
Notifications
You must be signed in to change notification settings - Fork 20
1. Introduction
The basic components of the fhir-bridge are explained in this chapter. As an example the mapping of an fhir observation is used.
Channel to which a system can receive or send a message. Apache camel supports different types of endpoints. Another specific endpoint that is important here are the Fhir endpoints. They provide specific endpoints for Fhir resource that are to be processed, in our case e.g. mapped to openEHR.
A camel component is a factory for the endpoints of the Fhir bridge. In our case we use the Fhir custom component provided by ipf for Fhir endpoints. A component is auto discovered by camel when starting the spring server and instantiates a Fhir Transaction e.g. CreateObservationComponent.
A Transaction initializes the endpoint by setting its parameters e.g. CreateObservationTransaction. Such parameters are as an example the FHIR version, the Audit Strategy and the Provider etc. .
Defines the audit logging for the endpoint.
The provider provides the URL endpoint where the resource is submitted to by the user e.g. POST {server_url}/fhir/Observation.
The Message contains the data that is transferred to a route, it has a header and a body. The exchange is the container of the message, it supports different types of messages e.g. one-way, request-response etc.
Routes contain the flow of logic and interaction between the components and systems. To understand how routing works we will take a look at the following method of the Observation Routing.
from("fhir-create-observation:fhirConsumer?fhirContext=#fhirContext")
This defines from what endpoint data is to be processed, in our case the one we already shown above CreateObservationTransaction (has the name fhir-create-observation). The fhirContext=#fhirContext
defines the fhirContext, in our case the global HAPI Fhir context of the fhir-bridge (defined by IPF).
.onException(Exception.class)
.process(defaultExceptionHandler)
.end()
When an exception appears (onException) it is to be processed (defaultExceptionHandler) and the route ended (no futher processing of the message).
.process(requestValidator)
The process requestValidator, validates the profile if it is e.g. supported, if not an error message is returned.
The method also sets the header FhirBridgeConstants.PROFILE
of the message, with the profile enum (e.g. Profile.BODY_HEIGHT).
.bean(observationDao, "create(${body})")
Sends a message to a bean endpoint, where the method create of the observationDao is called. The create takes the body of the message as parameter, so in this case our Fhir json. This provides an easier access for the resource json.
.setHeader(FhirBridgeConstants.METHOD_OUTCOME, body())
Sets the header name of the message with the constantFhirBridgeConstants.METHOD_OUTCOME
and the value of the header with the current body of the message, so the Fhir json.
.setBody(simple("${body.resource}"))
Sets the body of the message with the Fhir json (access via the former bean DAO). The body is a DaoMethodOutcome of Fhir, to access the resource directly. .resource
is called.
.process(patientIdProcessor) // check if patient id exists
In this process the PatientID is verified. This includes checking if the patient id exists within the FHIR json and that this id is also contained in the ehrbase instance. If not a error message is returned.
.setHeader(CompositionConstants.COMPOSITION_CONVERTER, method(compositionConverterResolver, "resolve(${header.CamelFhirBridgeProfile})"))
Sets the header with the name CompositionConstants.COMPOSITION_CONVERTER
, calls the resolve method of the bean compositionConverterResolver
. As parameters of this method the Profile enum is used (was set within the requestValidator). For each Profile there is a specific mapping, using the Profile enum this mapping is identified.
.to("ehr-composition:compositionProducer?operation=mergeCompositionEntity")
Sends an exchange to the composition endpoint. Here the mergeComposition Entity method is called. This method executes the CompositionConverter (mapping of the fhir resource to an ehrbase composition) and sends the result to ehrbase.
.setBody(header(FhirBridgeConstants.METHOD_OUTCOME));
At last the body of the message is set with the initially submitted Fhir resource, which was saved under the header in step 5. This json is returned to the user, if the mapping was successful.
Class that contains the mapping from a fhir resource to an openehr composition and vice versa.