Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

FHIR REST Interfaces (1.1)

Volker Schmidt edited this page Mar 21, 2019 · 8 revisions

Overview

The adapter provides synchronous FHIR REST Interfaces. They offer in general the same features like the import and export of data, but they use technical IDs that are based on the technical IDs of DHIS 2 resources instead of the technical IDs of connected systems.

Setup

In the default configuration file of the Adapter FHIR REST Interfaces for DSTU3 and R4 are enabled.

dhis2.fhir-adapter:
  # Specifies if the FHIR interfaces should be enabled.
  fhir-rest-interfaces:
    # Specifies if DSTU3 FHIR interfaces should be enabled.
    dstu3-enabled: true
    # Specifies if R4 FHIR interfaces should be enabled.
    r4-enabled: true

Without configuring the Adapter, FHIR Location and FHIR Organization resources can be accessed. After performing the initial setup with the setup user interface, also the FHIR Patient resource can be accessed.

FHIR REST Interface Endpoints

The FHIR REST Interface endpoints are accessible below the following context relative URIs.

FHIR Version Endpoint
DSTU3 /fhir/dstu3/default
R4 /fhir/r4/default

The FHIR REST Interfaces support DHIS 2 Basic and OAuth2 Authentication. The permissions of the corresponding DHIS 2 user is applied when performing any request on DHIS 2.

FHIR Identifiers

The Adapter provides FHIR identifiers for FHIR Resources that are mapped to DHIS 2 Organization Units and DHIS 2 Tracked Entity Types. The following tables contains the system URIs that are used by these identifiers.

FHIR Resource System URI
Condition http://www.dhis2.org/dhis2-fhir-adapter/systems/condition-identifier
Diagnostic Report http://www.dhis2.org/dhis2-fhir-adapter/systems/diagnostic-report-identifier
Encounter http://www.dhis2.org/dhis2-fhir-adapter/systems/encounter-identifier
Immunization http://www.dhis2.org/dhis2-fhir-adapter/systems/immunization-identifier
Location http://www.dhis2.org/dhis2-fhir-adapter/systems/location-identifier
Medication Request http://www.dhis2.org/dhis2-fhir-adapter/systems/medication-request-identifier
Observation http://www.dhis2.org/dhis2-fhir-adapter/systems/observation-identifier
Organization http://www.dhis2.org/dhis2-fhir-adapter/systems/organization-identifier
Patient http://www.dhis2.org/dhis2-fhir-adapter/systems/patient-identifier
Practitioner http://www.dhis2.org/dhis2-fhir-adapter/systems/practitioner-identifier
Related Person http://www.dhis2.org/dhis2-fhir-adapter/systems/related-person-identifier

Example

The following example assumes that DHIS 2 uses Sierra Leone demo database and the DHIS 2 Tracked Entity Type named Person has been setup with all DHIS 2 Tracked Entity Attributes that are offered in the initial setup user interface of the Adapter for Sierra Leone demo database.

$ curl -u admin:district 'http://localhost:8081/fhir/dstu3/default/Organization?identifier=http%3A%2F%2Fwww.dhis2.org%2Fdhis2-fhir-adapter%2Fsystems%2Forganization-identifier%7COU_278320&_format=json&_pretty=true'
  
{
  "resourceType": "Bundle",
  "id": "bbf4fa01-e944-4112-9f47-e78d7c7e9a4e",
  "meta": {
    "lastUpdated": "2019-03-04T12:40:23.806+01:00"
  },
  "type": "searchset",
  "total": 1,
  "link": [
    {
      "relation": "self",
      "url": "http://localhost:8081/fhir/dstu3/default/Organization?_format=json&_pretty=true&identifier=http%3A%2F%2Fwww.dhis2.org%2Fdhis2-fhir-adapter%2Fsystems%2Forganization-identifier%7COU_278320"
    }
  ],
  "entry": [
    {
      "fullUrl": "http://localhost:8081/fhir/dstu3/default/Organization/ou-ldXIdLNUNEn-d0e1472a05e647c9b36bff1f06fec352",
      "resource": {
        "resourceType": "Organization",
        "id": "ou-ldXIdLNUNEn-d0e1472a05e647c9b36bff1f06fec352",
        "meta": {
          "lastUpdated": "2017-05-22T15:21:48.511+02:00"
        },
        "identifier": [
          {
            "system": "http://www.dhis2.org/dhis2-fhir-adapter/systems/organization-identifier",
            "value": "OU_278320"
          }
        ],
        "active": true,
        "type": [
          {
            "coding": [
              {
                "system": "http://hl7.org/fhir/organization-type",
                "code": "prov"
              }
            ],
            "text": "Facility"
          }
        ],
        "name": "Connaught Hospital"
      }
    }
  ]
}

The following command line snippet can be used to create a FHIR patient. It contains the technical ID of the FHIR Organization that has been retrieved above.

curl -u admin:district -XPOST -H 'Content-Type: application/fhir+json' http://localhost:8081/fhir/dstu3/default/Patient -d '{
  "resourceType": "Patient",
  "identifier": [
      {
          "system": "http://www.dhis2.org/dhis2-fhir-adapter/systems/patient-identifier",
          "value": "826371"
      }
  ],
  "name": [
      {
          "family": "West",
          "given": [
              "Joe",
              "Alan",
              "Scott"
          ]
      }
  ],
  "gender": "male",
  "birthDate": "2019-02-17",
  "address": [
      {
          "text": "Water Road 675 / Apartment 62 / Freetown"
      }
  ],
  "managingOrganization": {
      "reference": "Organization/ou-ldXIdLNUNEn-d0e1472a05e647c9b36bff1f06fec352"
  }
}'
Clone this wiki locally