This Apache Camel application shows how DHIS2 resources can be turned into their FHIR counterparts and pushed as bundles to a FHIR server. Concretely, the Camel DHIS2 component is used to fetch organisation units, tracked entities, and option sets from DHIS2. Thanks to Camel's type converters, the fetched resources are transformed as follows:
- Organisation units into organizations and locations
- Tracked entities into patients
- Option sets into code systems and value sets
-
Open
dhis2-to-fhir-bundle/src/main/resources/application.yml
and set:dhis2-to-fhir.dhis2.base-url
to the DHIS2 server's addressdhis2-to-fhir.dhis2.username
to the DHIS2 account usernamedhis2-to-fhir.dhis2.password
to the DHIS2 account passworddhis2-to-fhir.fhir.server-url
to the FHIR server's address
-
From your terminal, change the current directory to
dhis2-to-fhir-bundle
and runmvn spring-boot:run
OrgUnitToFhirBundleRoute
┌─────┐ ┌─────┐ ┌───────────┐
│Camel│ │DHIS2│ │FHIR server│
└──┬──┘ └──┬──┘ └─────┬─────┘
│𝟏 /api/organisationUnits.json?fields=id,code,name,description,parent[id]&paging=false │ │
│─────────────────────────────────────────────────────────────────────────────────────>│ │
│ │ │
│ 𝟐 Organisation units │ │
│<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─│ │
│ │ │
│ │ │
╔═══════╤════╪═════════════════════════════════════════════════════════════════╗ │ │
║ LOOP │ organisation units ║ │ │
╟───────┘ │ ║ │ │
║ ────┐ ║ │ │
║ │ 𝟑 Transform organisation unit resource into organization ║ │ │
║ <───┘ ║ │ │
║ │ ║ │ │
║ ────┐ ║ │ │
║ │ 𝟒 Add organization resource to FHIR bundle ║ │ │
║ <───┘ ║ │ │
╚════════════╪═════════════════════════════════════════════════════════════════╝ │ │
│ │ │
│ 𝟓 Create organizations │ │
│─────────────────────────────────────────────────────────────────────────────────────────────────────────>│
│ │ │
│ 𝟔 │ │
│<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─│
┌──┴──┐ ┌──┴──┐ ┌─────┴─────┐
│Camel│ │DHIS2│ │FHIR server│
└─────┘ └─────┘ └───────────┘
TrackedEntityToFhirBundleRoute
┌─────┐ ┌─────┐ ┌───────────┐
│Camel│ │DHIS2│ │FHIR server│
└──┬──┘ └──┬──┘ └─────┬─────┘
│𝟏 /api/trackedEntityInstances.json?ou=DiszpKrYNg8&program=IpHINAT79UW │ │
│─────────────────────────────────────────────────────────────────────>│ │
│ │ │
│ 𝟐 Tracked entities │ │
│<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─│ │
│ │ │
│ │ │
╔═══════╤════╪═════════════════════════════════════════════════════════╗ │ │
║ LOOP │ tracked entities ║ │ │
╟───────┘ │ ║ │ │
║ ────┐ ║ │ │
║ │ 𝟑 Transform tracked entity resource into patient ║ │ │
║ <───┘ ║ │ │
║ │ ║ │ │
║ ────┐ ║ │ │
║ │ 𝟒 Add patient resource to FHIR bundle ║ │ │
║ <───┘ ║ │ │
╚════════════╪═════════════════════════════════════════════════════════╝ │ │
│ │ │
│ 𝟓 Create patients │ │
│─────────────────────────────────────────────────────────────────────────────────────────>│
│ │ │
│ 𝟔 │ │
│<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─│
┌──┴──┐ ┌──┴──┐ ┌─────┴─────┐
│Camel│ │DHIS2│ │FHIR server│
└─────┘ └─────┘ └───────────┘
OptionSetToFhirBundleRoute
┌─────┐ ┌─────┐ ┌───────────┐
│Camel│ │DHIS2│ │FHIR server│
└──┬──┘ └──┬──┘ └─────┬─────┘
│𝟏 /api/optionSets.json?fields=id,code,name,description,version,options[id,code,name]&paging=false&filter=id:eq:HB33RvLvVZe │ │
│──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────>│ │
│ │ │
│ 𝟐 Option sets │ │
│<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │ │
│ │ │
│ │ │
╔═══════╤════╪═════════════════════════════════════════════════════════╗ │ │
║ LOOP │ option sets ║ │ │
╟───────┘ │ ║ │ │
║ ────┐ ║ │ │
║ │ 𝟑 Transform option set resource into code system ║ │ │
║ <───┘ ║ │ │
║ │ ║ │ │
║ ────┐ ║ │ │
║ │ 𝟒 Transform option set resource into value set ║ │ │
║ <───┘ ║ │ │
║ │ ║ │ │
║ ────┐ ║ │ │
║ │ 𝟓 Add code system resource to FHIR bundle ║ │ │
║ <───┘ ║ │ │
║ │ ║ │ │
║ ────┐ ║ │ │
║ │ 𝟔 Add value set resource to FHIR bundle ║ │ │
║ <───┘ ║ │ │
╚════════════╪═════════════════════════════════════════════════════════╝ │ │
│ │ │
│ 𝟕 Create code systems & value sets │ │
│──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────>│
│ │ │
│ 𝟖 │ │
│<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │
┌──┴──┐ ┌──┴──┐ ┌─────┴─────┐
│Camel│ │DHIS2│ │FHIR server│
└─────┘ └─────┘ └───────────┘
@startuml
title OrgUnitToFhirBundleRoute
autonumber
Camel -> DHIS2 : /api/organisationUnits.json?fields=id,code,name,description,parent[id]&paging=false
Camel <-- DHIS2: Organisation units
loop organisation units
Camel -> Camel: Transform organisation unit resource into organization
Camel -> Camel: Add organization resource to FHIR bundle
end
Camel -> "FHIR server": Create organizations
Camel <-- "FHIR server"
@enduml
@startuml
title TrackedEntityToFhirBundleRoute
autonumber
Camel -> DHIS2 : /api/trackedEntityInstances.json?ou=DiszpKrYNg8&program=IpHINAT79UW
Camel <-- DHIS2: Tracked entities
loop tracked entities
Camel -> Camel: Transform tracked entity resource into patient
Camel -> Camel: Add patient resource to FHIR bundle
end
Camel -> "FHIR server": Create patients
Camel <-- "FHIR server"
@enduml
@startuml
title OptionSetToFhirBundleRoute
autonumber
Camel -> DHIS2 : /api/optionSets.json?fields=id,code,name,description,version,options[id,code,name]&paging=false&filter=id:eq:HB33RvLvVZe
Camel <-- DHIS2: Option sets
loop option sets
Camel -> Camel: Transform option set resource into code system
Camel -> Camel: Transform option set resource into value set
Camel -> Camel: Add code system resource to FHIR bundle
Camel -> Camel: Add value set resource to FHIR bundle
end
Camel -> "FHIR server": Create code systems & value sets
Camel <-- "FHIR server"
@enduml