Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

1. Introduction

Severin Kohler edited this page Dec 9, 2020 · 1 revision

Basic components

The basic components of the fhir-bridge are explained in this chapter. As an example the mapping of an fhir observation is used.

Endpoint

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.

Component

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.

Transaction

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. .

Audit Strategy

Defines the audit logging for the endpoint.

Provider

The provider provides the URL endpoint where the resource is submitted to by the user e.g. POST {server_url}/fhir/Observation.

Exchange and Message

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

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.

1. From

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).

2. Exception

      .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).

3. Validate Resource

      .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).

4. Providing a data access object

      .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.

5. Set header for method outcome

      .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.

6. Set Body

      .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.

7. Check Patient ids

      .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.

8. Set header Composition converter

    .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.

9. Execute mapping and send result to ehrbase

   .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.

10. Set return Body

   .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.

Converter

Class that contains the mapping from a fhir resource to an openehr composition and vice versa.

Clone this wiki locally