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
Practitionerresource, create a correspondingGroupresource with thePractitioner.idreferenced in theGroup.memberattribute.- This
Groupresource links thePractitionerto aCarePlanresource when thePractitioneris theCarePlan.subject.
- This
-
When creating a
Practitionerresource, create aPractitionerRoleresource.- This resource links the
Practitionerto anOrganizationresource when thePractitioneris anOrganizationmember. - The
PractitionerRoleresource defines the role of thePractitionerin theOrganization, e.g. a Community Health Worker or Supervisor role.
- This resource links the
-
Assign the
PractitioneraCareTeamby adding aPractitionerreference to theCareTeam.participant.memberattribute.- Assign the
CareTeamanOrganizationby adding anOrganizationreference to theCareTeam.managingOrganizationattribute. - Add an
Organizationreference to theCareTeam.participant.memberattribute of theCareTeamresource for easy search.
- Assign the
-
Assign the
OrganizationaLocationvia theOrganizationAffiliationresource.- The
Organizationis referenced on theOrganizationAffiliation.organizationattribute. - The
Locationis referenced on theOrganizationAffiliation.locationattribute.
- The
-
The
Locationchild parent relationship is defined by theLocation.partOfattribute.- The parent
Locationis referenced on the child'sLocation.partOfattribute.
- The parent
Android application
-
Update
local.propertiesfile- Update
FHIR_BASE_URLvalue to theurlof the FHIR Gateway Host
- Update
-
Data Filtering - configure sync strategy
- Update the
application_configuration.jsonwith 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.valueabove should correspond tofhir_core_app_idmentioned in the user management Keycloak section below.
- Update the
sync_config.jsonto 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.
-
POSTthe 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_FILEwith 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
Compositionresource ID andBinaryresources 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,GETfor Binary should exist, Client Mapper for thefhir_core_app_idand corresponding user attribute should not be missing -
The
TOKEN_ISSUERspecified 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.jsonfile 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