4

Building healthcare applications with SAP Build Apps using FHIR REST Services on...

 1 year ago
source link: https://blogs.sap.com/2023/06/22/building-healthcare-applications-with-sap-build-apps-using-fhir-rest-services-on-sap-btp/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
June 22, 2023 7 minute read

Building healthcare applications with SAP Build Apps using FHIR REST Services on SAP BTP

Introduction

At the end of April 2023, SAP published the SAP Health Data Services for FHIR as Beta service on BTP Cloud Foundry Environment (see also Health Application Development using HL7 FHIR on the SAP Business Technology Platform).
In parallel, a learning mission was published on SAP Discovery Center (see Get on your healthcare mission – Hands-on experience with SAP Health Data Services for FHIR (Beta)).

Bettina Lieske asked me to implement a sample user interface for these services. Since I was just looking at SAP Build Apps, we came to the idea to implement a patient list from the FHIR REST API with SAP Build Apps.

Due to the REST character of FHIR, the following description is also a general example for using a REST service (based on a BTP destination) in SAP Build Apps.

Prerequisites

FHIR server on BTP

As mentioned in the blogs above SAP Health Data Services for FHIR provides you with a FHIR server. In order to set it up, just follow the first 3 phases of the Discovery Center Mission Build a healthcare app with SAP Health Data Services for FHIR

SAP Build Apps Account

In order to create an app in SAP Build Apps, you need an account in an SAP Build Apps instance on BTP. This might be the same account, where the FHIR server instance is running, but it might be also an additional, free account like described in SAP Build Apps Free Tier Individual Access.

Execution

FHIR service as BTP destination

In order to reference a REST destination with authentication in SAP Build Apps, it is necessary to reference this service as a Cloud Foundry destination – in opposite to a public REST service, where you can reference the URL directly.

Navigate to the subaccount where the FHIR service instance is running.

Click on “Services”, “Instances and Subscriptions” in the navigation bar.

Click on “Credentials” of the FHIR service instance.

Copy the values from “coreservice”, “clientid”, “clientsecret”, “url”.

Blog-SBA-FHIR-230619-010.png

Navigate to the subaccount, where SAP Build Apps is running.

Click on “Connectivity”, “Destinations” in the navigation bar.

Click on “New Destination”.

Name the new destination, e.g. “FHIRBTPCC” (for FHIR service on BTP client credentials).

Paste the previously copied values (“coreservice”, “clientid”, “clientsecret”, “url”) as “URL”, “Client ID”, “Client Secret”, “Token Service URL”.

Add /oauth/token to the Token Service URL.

Fill all other values according to the screenshot:

Blog-SBA-FHIR-230619-020.png

Don’t forget to set the additional properties:

AppgyverEnabled: true
HTML5.DynamicDestination: true
WebIDEEnabled: true

These are necessary so that the destination is handled correctly as an SAP Build Apps destination.

Click on “Check Connection”.

“Connection to “FHIRBTPCC” established. Response returned: “401: Unauthorized”” appears. (Unfortunately the logic behind “Check Connection” does not use the credentials; so it could not be authorized. This will not be the case when running the app later on)

Build the app

Create the app

Go to the lobby of SAP Build Apps (e.g. as described in SAP Build Apps Free Tier Individual Access)

Create a new application: Click on “Create”, click on “Build an application”, click on “Web & Mobile Application”, name it e.g. “Patient List 230606”, description “UI for FHIR Server”.

Blog-SBA-FHIR-230619-030.png

Open the newly created app.

Enable Authentication

Enable authentication by: Click on “Auth”, click on “Enable Authentication”, click on SAP BTP authentication:

Blog-SBA-FHIR-230619-040.png

Create the Data Model

Click on Data, Click on “SAP Build Apps classic data entities“ and choose “SAP BTP Destination REST API integration”:

Blog-SBA-FHIR-230619-050.png

Give it a name, a description, choose the destination as created before:

Blog-SBA-FHIR-230619-060.png

Click on “list”, fill the relative path with “Patient”:

Blog-SBA-FHIR-230619-070.png

Click on Test, click on “Run Test”:

Blog-SBA-FHIR-230619-080.png

You can see the typical FHIR response to a search which is a bundle instance. In this list, the patient instances can be found in the “entry” element:

Blog-SBA-FHIR-230619-090a.png

So we have to set a path in the Response Mapper to the “entry” element.

Go back to tab Config, click on the x under Response Mapper:

Blog-SBA-FHIR-230619-100.png

Select Formula, Click on Create Formula, you will see:

Blog-SBA-FHIR-230619-110.png

Click on API response and click on response.data.entry. Now you see the list itself as result:

Blog-SBA-FHIR-230619-120.png

Click on Enter in order to set the value, click on Save, click on Save:

Blog-SBA-FHIR-230619-130.png

Go to test, Run test:

Blog-SBA-FHIR-230619-140.png

You see that the result is an empty json object, unexpected.

There is a bug in the response mapper, so go back to the config tab, click on the value under response mapper:

Substitute the value

response.data.entry
{driverCode: response.status , records: response.data.entry}

(The Response Mapper does not only expect the path itself, but a more complex object.)

Thanks to Marc Huber for the hack.

Click twice on Save:

Blog-SBA-FHIR-230619-150.png

Go to Test, run Test:

Blog-SBA-FHIR-230619-160.png

Now the response is OK.

To create the data model structure, click on “autodetect schema from response”, click on schema:

Blog-SBA-FHIR-230619-170.png

Now you can see the correct data structure.

Click on the switch beside list to activate the list operation:

Blog-SBA-FHIR-230619-180.png

Click on Save Data Entity:

Create the Data variable

Click on UI Canvas, click on Variables, click on Data Variables, click on Add Data Variable, click on Patients.

A new variable Patients1 is created:

Blog-SBA-FHIR-230619-190.png

Click on Save.

Create the UI

Click on UI Canvas and go from the “variables” mode to the “view” mode.

Drag the “List item” from the left hand side to the canvas:

Blog-SBA-FHIR-230619-200.png

Set Repeat with by clicking on the arrows under “Repeat with”, select Data and Variables, select Data variable, select Patients1:

Blog-SBA-FHIR-230619-210.png

Click on Save.

Now we would like to show <Last Name>, <First name> in the table on the left hand side and the birth date on the right hand side.

Let’s start with the birth date, because it is easier:

Click on ABC under Secondary Label:

Blog-SBA-FHIR-230619-220.png

Click Data item in repeat, click current, click birth date:

Blog-SBA-FHIR-230619-230.png

Click save.

Try to repeat this step with the primary label. We see, that the name is incompatible in this context as it is a complex data type:

Blog-SBA-FHIR-230619-240.png

So, we have to use the formula editor again. Go back to the “Select binding type” screen and select “Formula”.

Then, click on the line field below the “Formula” label.

In the menu field on the left, click on “Currently repeated data items”:

Blog-SBA-FHIR-230619-250.png

Select “repeated.current.resource.name[0].family” in the middle, press enter:

Blog-SBA-FHIR-230619-260.png

Type + ‘, ‘ + in the editor line to concatenate the 2 strings family and given.

Select “repeated.current.resource.name[0].given[0]”

So the complete editor line should be:

repeated.current.resource.name[0].family + ', ' + repeated.current.resource.name[0].given[0]
Blog-SBA-FHIR-230619-270.png

Click twice Save.

The canvas should show:

Blog-SBA-FHIR-230619-280.png

Click on Save.

Change the content above the table; change the content of the headline to patient list, remove the text field below:

Blog-SBA-FHIR-230619-290.png

Now it’s time to preview the results!

Preview the app

Click on Launch:

Blog-SBA-FHIR-230619-300.png

Click on “Open preview portal”:

Blog-SBA-FHIR-230619-310.png

Click on “Open web preview”, click on your app:

Blog-SBA-FHIR-230619-320.png

Voilà, the patients from the FHIR server will be shown!

Conclusion

SAP Build Apps is suited to show data from „SAP Health Data Services for FHIR“ on SAP BTP:

Both SAP Build apps and SAP Health Data Services for FHIR are compatible with the REST standard so that they can work together without any problems. With SAP Build Apps, there is an easy way to visualize the data from FHIR, the industry standard in Healthcare (see also https://blogs.sap.com/2023/05/30/benefits-of-the-hl7-fhir-industry-standard).


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK