Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions episodes/clean-data.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@

:::::::::

::::::::::::::::: checkpoint

Check warning on line 356 in episodes/clean-data.Rmd

View workflow job for this annotation

GitHub Actions / Build markdown source files if valid

[unknown div] checkpoint

At this point, we removed a number of columns and rows. Compare the dimensions of `raw_ebola_data` and `sim_ebola_data`.

Expand Down Expand Up @@ -570,7 +570,8 @@
dplyr::select(
study_id,
date_of_birth,
age_in_years
age_in_years,
remainder_months
)
```

Expand Down Expand Up @@ -693,7 +694,6 @@
target_columns = "case_id",
range = c(1, 15000)
) %>%
cleanepi::convert_to_numeric(target_columns = "age") %>%
# epidemiological operations ------------------------------
cleanepi::standardize_dates(
target_columns = c("date_onset", "date_sample")
Expand All @@ -707,7 +707,8 @@
span_unit = "days",
span_column_name = "reporting_delay"
) %>%
cleanepi::clean_using_dictionary(dictionary = test_dict)
cleanepi::clean_using_dictionary(dictionary = test_dict) %>%
cleanepi::convert_to_numeric(target_columns = "age")
```

```{r, echo=FALSE, eval=TRUE}
Expand Down
73 changes: 50 additions & 23 deletions episodes/read-cases.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,33 @@ dhis2_login <- readepi::login(
user_name = "admin",
password = "district"
)
```

::::::: caution

Avoid publishing your USER NAME and PASSWORD. You could use `{rstudioapi}`:

```{r, eval = FALSE}
dhis2_login <- readepi::login(
type = "dhis2",
from = "https://play.im.dhis2.org/stable-2-41-8-1",
user_name = rstudioapi::askForPassword("Database username"),
password = rstudioapi::askForPassword("Database password")
)
```

Your can read further from this blogpost on [How to Avoid Publishing Credentials in Your Code](https://rviews.rstudio.com/2019/03/21/how-to-avoid-publishing-credentials-in-your-code/)

:::::::

```{r}
# get the names and IDs of the programs
programs <- readepi::get_programs(login = dhis2_login)

# print tables
tibble::as_tibble(programs)
```



```{r}
# get the names and IDs of the organisation units
org_units <- readepi::get_organisation_units(login = dhis2_login)
Expand All @@ -337,58 +354,68 @@ tibble::as_tibble(org_units)
After retrieving organization units and program names from the DHIS2 database, we can import data using either names or coded IDs, as demonstrated in the code chunk below

```{r,message=FALSE}
data <- readepi::read_dhis2(
# import data from DHIS2 using names
data_name <- readepi::read_dhis2(
login = dhis2_login,
org_unit = "Keneba",
program = "Child Registration & Treatment "
org_unit = "Bucksal Clinic",
program = "Child Programme"
)

tibble::as_tibble(data)
tibble::as_tibble(data_name)
```

```{r,eval=TRUE,message=FALSE}
# import data from DHIS2 using names
# import data from DHIS2 using IDs
data <- readepi::read_dhis2(
data_id <- readepi::read_dhis2(
login = dhis2_login,
org_unit = "GcLhRNAFppR",
program = "E5IUQuHg3Mg"
org_unit = "vRC0stJ5y9Q",
program = "IpHINAT79UW"
)

tibble::as_tibble(data)
identical(data_id, data_name)
```

Note that not all organization units are registered for a specific program. To find which organization units are running a particular program, use the `get_program_org_units()` function as shown below:

```{r}
# get the list of organisation units that run the program "E5IUQuHg3Mg"
# get the list of organisation units that run the program "IpHINAT79UW"
target_org_units <- readepi::get_program_org_units(
login = dhis2_login,
program = "E5IUQuHg3Mg",
program = "IpHINAT79UW",
org_units = org_units
)

tibble::as_tibble(target_org_units)
```

:::::::::::::::: callout
<!-- :::::::::::::::: callout

Note: This example uses a DHIS2 system provided by the Ministry of Health of The Gambia for testing and development purposes. In practice, you should customize the parameters for your own DHIS2 instance.

::::::::::::::::

:::::::::::::::: -->

:::::::::::::::::::::: challenge

### Reading from your DHIS2 sever
### Reading from a DHIS2 sever

<!-- The DHIS2 organization provides demo servers for development and testing. One of these is called **stable-2-41-8-1**, from many other available in a list of [DHIS2 Demo Instances](https://im.dhis2.org/public/instances), and accessible with username `"admin"` and password `"district"`. -->

Test `{readepi}` by accessing to a DHIS2 server with your credentials.

Do the following:

- Log into a different server,
- List all available programs and organization units,
- Read data from one of these programs,
- Optional: Reproduce one descriptive figure.

::::::::: hint

Try using `rstudioapi::askForPassword()` for `user_name` and `password`.

If you have your credentials, try accessing to a DHIS2 server.
If you get errors, please fill an issue in the [`readepi` GitHub repository](https://github.com/epiverse-trace/readepi/issues/).

<!--
The DHIS2 organization provides demo servers for development and testing. One of
these is called **stable-242-4**, available at the link
("https://play.im.dhis2.org/stable-2-41-8-1"), and accessible with username "admin" and password "district". Log into this server, list all available programs and organization units, and read data from one of these programs.
-->
:::::::::

::::::::::::::::::::::

Expand Down
Loading