Skip to contents

Import data from DHIS2

Usage

read_dhis2(login, org_unit, program)

Arguments

login

A httr2_response object returned by the dhis2_login() function

org_unit

A character with the organisation unit ID or name

program

A character with the program ID or name

Value

A data frame that contains both the tracked entity attributes and their event data.

Examples

# login to the DHIS2 instance
dhis2_login <- login(
  type = "dhis2",
  from = "https://smc.moh.gm/dhis",
  user_name = "test",
  password = "Gambia@123"
)
#>  Logged in successfully!
program = "E5IUQuHg3Mg"
org_unit = "GcLhRNAFppR"
data <- read_dhis2(
  login = dhis2_login,
  org_unit = org_unit,
  program = program
)
#>  Checking whether the API version is accounted for
#>  Checking whether the API version is accounted for [189ms]
#> 
#>  Getting the data elements
#>  Getting the data elements [208ms]
#> 
#>  Getting organisation units
#>  Getting organisation units [6.6s]
#> 
#>  Getting the programs
#>  Getting the programs [745ms]
#> 
#>  Getting the program stages
#>  Getting the program stages [440ms]
#> 
#>  Getting the tracked entity attributes
#>  Getting the tracked entity attributes [2.3s]
#> 
#>  Getting the event data
#>  Getting the event data [7.1s]
#> 

# fetch data from the test DHIS2 instance
dhis2_login <- login(
  type = "dhis2",
  from = "https://play.im.dhis2.org/stable-2-42-1",
  user_name = "admin",
  password = "district"
)
#>  Logged in successfully!
org_unit <- "DiszpKrYNg8"
program <- "IpHINAT79UW"

data <- read_dhis2(
  login = dhis2_login,
  org_unit = org_unit,
  program = program
)
#>  Checking whether the API version is accounted for
#>  Checking whether the API version is accounted for [196ms]
#> 
#>  Getting the data elements
#>  Getting the data elements [359ms]
#> 
#>  Getting organisation units
#>  Getting organisation units [6.7s]
#> 
#>  Getting the programs
#>  Getting the programs [774ms]
#> 
#>  Getting the program stages
#>  Getting the program stages [439ms]
#> 
#>  Getting the tracked entity attributes
#>  Getting the tracked entity attributes [968ms]
#> 
#>  Getting the event data
#>  Getting the event data [478ms]
#>