Import data from DHIS2
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
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]
#>