Backend application setup
The backend requires these pieces of software, with an optional fourth:
- FHIR Store, e.g HAPI FHIR - How to set up HAPI FHIR
- FHIR Information Gateway with OpenSRP plugins - How to set up OpenSRP FHIR Gateway
- Identity and Access Management server with Oauth2 support e.g. Keycloak - How to set up Keycloak
- [Optional] the fhir-web admin dashboard.
For deployment to production, see our Production configuration recommendations.
User management
You can manage users manually via the APIs and/or user interfaces for keycloak and your FHIR API, or via the fhir-web user interface. See Keycloak for details.
FHIR API user management
-
For each
Practitioner
resource, create a correspondingGroup
resource with thePractitioner.id
referenced in theGroup.member
attribute.- This
Group
resource links thePractitioner
to aCarePlan
resource when thePractitioner
is theCarePlan.subject
.
- This
-
When creating a
Practitioner
resource, create aPractitionerRole
resource.- This resource links the
Practitioner
to anOrganization
resource when thePractitioner
is anOrganization
member. - The
PractitionerRole
resource defines the role of thePractitioner
in theOrganization
, e.g. a Community Health Worker or Supervisor role.
- This resource links the
-
Assign the
Practitioner
aCareTeam
by adding aPractitioner
reference to theCareTeam.participant.member
attribute.- Assign the
CareTeam
anOrganization
by adding anOrganization
reference to theCareTeam.managingOrganization
attribute. - Add an
Organization
reference to theCareTeam.participant.member
attribute of theCareTeam
resource for easy search.
- Assign the
-
Assign the
Organization
aLocation
via theOrganizationAffiliation
resource.- The
Organization
is referenced on theOrganizationAffiliation.organization
attribute. - The
Location
is referenced on theOrganizationAffiliation.location
attribute.
- The
-
The
Location
child parent relationship is defined by theLocation.partOf
attribute.- The parent
Location
is referenced on the child'sLocation.partOf
attribute.
- The parent
Android application
-
Update
local.properties
file- Update
FHIR_BASE_URL
value to theurl
of the FHIR Gateway Host
- Update
-
Data Filtering - configure sync strategy
- Update the
application_configuration.json
with the sync strategy for the deployment, e.g. for sync by Location:
"syncStrategy": ["Location"]
- Update the
Note: Currently the configuration accepts an array but a subsequent update will enforce a single value. See application_config.json
-
Composition JSON
- Update the identifier to the value of the application id
"identifier": {
"use": "official",
"value": "<app id>"
}
Note:
identifier.value
above should correspond tofhir_core_app_id
mentioned in the user management Keycloak section below.
- Update the
sync_config.json
to remove all the non-patient data resources. These should be referenced from the Composition resource so they can be exempted from the Data filter. See sync_config.json
FHIR API and configuration resources
-
Deploy the FHIR Store, e.g HAPI
- The steps here depend on what FHIR Store your are using. To deploy the HAPI FHIR Server using JPA, follow these steps.
-
POST
the binary resources referenced in thecomposition_config.json
Note: As described in the FHIR Gateway section, the server should be in an internal network behind a DMZ and therefore not require authentication, which will be handled by the FHIR Information Gateway.
Deploy the FHIR Gateway
- Link to the Docker image
- The main documentation for deploying can be found in the Github READ MEFor configuration parameters, check out Read Me file for setting environment variables.
- For configuration parameters, check out Read Me file for setting environment variables.
- OpenSRP nuances: Provide/export the System variable
ALLOWED_QUERIES_FILE
with value"resources/hapi_page_url_allowed_queries.json"
HAPI Page URL Allowed Queries - For each deployment the configuration entries for resources here should match the specific
Composition
resource ID andBinary
resources IDs for the android clients - Refer to the FHIR Info Gateway extension documentation
- Gateway with the help of the plugins currently handle both andriod and web client requests
Deploy fhir-web
- The OpenSRP 2.0 web portal deployment docs can be found here
- This platform is now supported by the Gateway server through the FHIR Info Gateway extension.
Gotchas
-
Keycloak redirect - You need to disable keycloak authentication in HAPI FHIR
-
Binary resource base64 encoding - You need to make sure that you properly set the Binary resource for application configuration
-
Keycloak/Role configuration - Roles for all the different resources - including
PUT
,POST
,GET
for Binary should exist, Client Mapper for thefhir_core_app_id
and corresponding user attribute should not be missing -
The
TOKEN_ISSUER
specified in your backend deployment should be the same Realm used by the application to fetch an access token for authentication and authorization.
env:
- name: TOKEN_ISSUER
value: https://<yourkeycloak>.smartregister.org/auth/realms/FHIR_Android
-
Remove Resource entries from the
sync_confguration.json
file that should not be part of the normal data sync but rather part of the Composition file e.g. Questionnaire -
When testing the set up DO NOT use debug app ids e.g.
app/debug
. The Gateway’s implementation is tightly coupled with the server hosted application resources -
In the HAPI FHIR application.yaml disable validations by setting to
false*
. This is however not highly recommended.
Resources
- FHIR Gateway
- Permission Checker Spec
- Data Access Filter Spec
- Data Requesting Spec
- FHIR Gateway Tags
- FHIR Web Docker Deployment
- OpenSRP Web Issue 1094
- OpenSRP Web Issue 1095
- OpenSRP Web Issue 553
- OpenSRP Web Issue 842
- OpenSRP Web Issue 552
- OpenSRP Web Issue 665
- OpenSRP Web Issue 1080
- OpenSRP Web Issue 663
- OpenSRP Web Issue 1079
- OpenSRP V2 RBAC ROLES
- How to Migrate to the Gateway server for sync