Skip to Content
Technical Articles
Author's profile photo Abdelmajid BEKHTI

Manage health data with SAP Data Hub

For a recent healthcare prospect, we have build a prototype for integrating different data sources, such as internet data using APIs and information from websites as well as from on premise databases. One of the requirement was to exchange data with a FHIR system.

FHIR (Fast Healthcare Interoperability Resources, pronounced “fire”) supports data exchange between software systems in the healthcare sector. For more details, please visit the FHIR website: https://www.hl7.org/fhir/

We used SAP Data Hub as a platform for integrating all those different sources. For the FHIR integration, we use a public server that we can use for GET and POST methods. The server is available here: http://hapi.fhir.org/.

The goal of the pipeline is to get data from a FHIR resource, change values on the fly and push back the result into the FHIR server. For this example, we are going to use the following patient hapi.fhir.org/baseR4/Patient/30 and change his name (dummy data).

The overall pipeline is as follow. I will explain the different steps over the post.

To get the data (GET method) we simply used the OpenAPI Client operator with the following parameters:

Then on the fly, the data is changed via the Message Operator using javascript.

$.setPortCallback("input",onInput);

function isByteArray(data) {
    switch (Object.prototype.toString.call(data)) {
        case "[object Int8Array]":
        case "[object Uint8Array]":
            return true;
        case "[object Array]":
        case "[object GoArray]":
            return data.length > 0 && typeof data[0] === 'number';
    }
    return false;
}

function onInput(ctx,s) {
    var msg = {};

    var inbody = s.Body;
    var inattributes = s.Attributes;

    // convert the body into string if it is bytes
    if (isByteArray(inbody)) {
        inbody = String.fromCharCode.apply(null, inbody);
    }

    msg.Attributes = {};
    for (var key in inattributes) {
        msg.Attributes[key] = inattributes[key];
    }
   
   console.log("remove [] in body ")
       
   var patient = JSON.parse(inbody);
   
   //change the familiy name here
   patient.name[0].family="Doe"
   patient.name[0].given="John"
   msg.Body = JSON.stringify(patient)
   msg.Attributes["js.action"] = "JSON";
   

   $.output(msg);
}

As you can see, the change occurs at the end of the script:

   //change the familiy name here
   patient.name[0].family="Doe"
   patient.name[0].given="John"
   msg.Body = JSON.stringify(patient)
   msg.Attributes["js.action"] = "JSON";

The output data are transferred as JSON format to the output port of the Message Operator in order to be pushed back to the FHIR server. We use as well the standard OpenAPI Client operator with the POST method to “update” the existing values.

Now we just have to run the pipeline and check on the FHIR server if the change happened. Once the pipeline finished successfully, we can use Postman to check the changes.

Great it worked 🙂

 

These is only a simple example and there are of course many more possibilities with SAP Data Hub or SAP Data Intelligence. To learn more, please have a look into our SAP website https://www.sap.com/products/data-hub.html and also into the SAP Developer website https://developers.sap.com/topics/data-hub.html.

 

 

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.