Skip to content

Commit

Permalink
Merge pull request #30 from katilingban/v0.1.3
Browse files Browse the repository at this point in the history
V0.1.3
  • Loading branch information
ernestguevarra authored Nov 11, 2020
2 parents 4a6fbb8 + b83d3e5 commit fb47e78
Show file tree
Hide file tree
Showing 3 changed files with 239 additions and 4 deletions.
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# sudanCMAM v0.1.4

In this version:

* added visualisation of MUAC at admission, average weight gain and
length-of-stay

# sudanCMAM v0.1.3

In this version:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!--- start badges -->
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
![version](https://img.shields.io/badge/version-0.1.3-blue.svg)
![version](https://img.shields.io/badge/version-0.1.4-blue.svg)
![license](https://img.shields.io/badge/license-GPL3-blue.svg)
[![DOI](https://zenodo.org/badge/290984010.svg)](https://zenodo.org/badge/latestdoi/290984010)
<!--- end badges -->
Expand Down
234 changes: 231 additions & 3 deletions sudanCMAMdashboard.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2484,10 +2484,238 @@ output$locality_defaulters <- renderPlotly({
plotlyOutput(outputId = "locality_defaulters")
```

<!---

Case-finding
================================================================================
--->

```{r muac1}
## Tidy the list
x1 <- muac_admission[[1]] %>%
pivot_longer(cols = `Tahdi Osisi`:Baryay,
names_to = "health_facilities",
values_to = "n")
x2 <- muac_admission[[2]] %>%
pivot_longer(cols = `Alhara alula`:Omrahaw,
names_to = "health_facilities",
values_to = "n")
x3 <- muac_admission[[3]] %>%
pivot_longer(cols = `Mukram`:`Al Kuaty hospital`,
names_to = "health_facilities",
values_to = "n")
x4 <- muac_admission[[4]] %>%
pivot_longer(cols = `8 - Arab`:`Reara`,
names_to = "health_facilities",
values_to = "n")
## Concatenate
xx <- rbind(x1, x2, x3, x4)
```

Row <!--- {.tabset .tabset-fade} --->
--------------------------------------------------------------------------------

### By state

```{r muac2, fig.height = 6}
muac_state <- aggregate(n ~ state + muac, data = xx, FUN = sum)
median_muac <- muac_state %>%
split(f = muac_state$state) %>%
lapply(FUN = function(x) median(rep(x$muac, x$n), na.rm = TRUE)) %>%
unlist()
median_muac <- names(median_muac) %>%
data.frame(median_muac)
names(median_muac) <- c("state", "median muac")
row.names(median_muac) <- 1:nrow(median_muac)
output$state_muac <- renderPlotly({
z <- muac_state %>%
ggplot(mapping = aes(x = muac, y = n)) +
geom_col(fill = unicef_blue, alpha = 0.7) +
geom_vline(data = median_muac,
mapping = aes(xintercept = `median muac`),
colour = unicef_darkblue,
linetype = 2, size = 0.5) +
scale_x_reverse(breaks = seq(from = 115, to = 60, by = -5)) +
labs(title = "MUAC at Admission by State", x = "MUAC (mm)") +
facet_wrap(. ~ state, ncol = 3) +
unicef_theme
ggplotly(p = z)
})
plotlyOutput(outputId = "state_muac")
```

Row
--------------------------------------------------------------------------------

### By locality

```{r muac3, fig.height = 8}
muac_locality <- aggregate(n ~ state + locality + muac, data = xx, FUN = sum)
median_muac_locality <- muac_locality %>%
split(f = list(muac_locality$state, muac_locality$locality)) %>%
lapply(FUN = function(x) median(rep(x$muac, x$n), na.rm = TRUE)) %>%
unlist()
median_muac_locality <- stringr::str_split(string = names(median_muac_locality),
pattern = "\\.",
simplify = TRUE) %>%
data.frame(median_muac_locality) %>%
rename(state = X1, locality = X2, `median muac` = median_muac_locality)
row.names(median_muac_locality) <- 1:nrow(median_muac_locality)
output$locality_muac <- renderPlotly({
z <- muac_locality %>%
ggplot(mapping = aes(x = muac, y = n)) +
geom_col(fill = unicef_blue, alpha = 0.7) +
geom_vline(data = median_muac_locality,
mapping = aes(xintercept = `median muac`),
colour = unicef_darkblue,
linetype = 2, size = 0.5) +
scale_x_reverse(breaks = seq(from = 115, to = 60, by = -5)) +
labs(title = "MUAC at Admission by Locality", x = "MUAC (mm)") +
facet_grid(locality ~ state) +
unicef_theme
ggplotly(p = z)
})
plotlyOutput(outputId = "locality_muac")
```

Effectiveness
================================================================================

Row {.tabset .tabset-fade}
--------------------------------------------------------------------------------

```{r los1}
length_of_stay <- otp_beneficiaries %>%
calculate_los_df(admission_date = "admDate", discharge_date = "disDate") %>%
mutate(state = "Kassala") %>%
dplyr::relocate(state, .before = locality)
median_los_state <- length_of_stay %>%
split(f = length_of_stay$state) %>%
lapply(FUN = function(x) median(x$los, na.rm = TRUE)) %>%
unlist()
median_los_state <- names(median_los_state) %>%
data.frame(median_los_state)
names(median_los_state) <- c("state", "median length-of-stay")
row.names(median_los_state) <- 1:nrow(median_los_state)
median_los_locality <- length_of_stay %>%
split(f = list(length_of_stay$state, length_of_stay$locality)) %>%
lapply(FUN = function(x) median(x$los, na.rm = TRUE)) %>%
unlist()
median_los_locality <- stringr::str_split(string = names(median_los_locality),
pattern = "\\.",
simplify = TRUE) %>%
data.frame(median_los_locality) %>%
rename(state = X1, locality = X2, `median length-of-stay` = median_los_locality)
row.names(median_los_locality) <- 1:nrow(median_los_locality)
```

### By state

```{r los2, fig.height = 8}
output$los_state <- renderPlotly({
los_state_plot <- length_of_stay %>%
ggplot(mapping = aes(x = state, y = los)) +
geom_boxplot(colour = unicef_blue, width = 0.5) +
labs(title = "Median length-of-stay by state",
x = "",
y = "Length-of-stay (days)") +
unicef_theme
ggplotly(p = los_state_plot)
})
plotlyOutput(outputId = "los_state")
```

### By locality

```{r los3, fig.height = 8}
output$los_locality <- renderPlotly({
los_locality_plot <- length_of_stay %>%
ggplot(mapping = aes(x = locality, y = los)) +
geom_boxplot(colour = unicef_blue, width = 0.5) +
labs(title = "Median length-of-stay by locality",
x = "",
y = "Length-of-stay (days)") +
facet_wrap(state ~ .) +
unicef_theme
ggplotly(p = los_locality_plot)
})
plotlyOutput(outputId = "los_locality")
```

Row {.tabset .tabset-fade}
--------------------------------------------------------------------------------

```{r wtGain1}
wt_gain <- otp_beneficiaries %>%
mutate(state = "Kassala") %>%
dplyr::relocate(state, .before = locality) %>%
calculate_los_df(admission_date = "admDate", discharge_date = "disDate") %>%
mutate(wtGain = ((diswt - wt) * 1000) / (wt * los)) %>%
filter(wtGain >= 0)
```

### By state

```{r wtGain2, fig.height = 8}
output$wt_gain_state <- renderPlotly({
z <- wt_gain %>%
ggplot(mapping = aes(x = state, y = wtGain)) +
geom_boxplot(colour = unicef_blue, width = 0.5) +
labs(title = "Average weight gain by state",
x = "",
y = "Average weight gain (g/kg/day)") +
unicef_theme
ggplotly(p = z)
})
plotlyOutput(outputId = "wt_gain_state")
```

### By locality

```{r wtGain3, fig.height = 8}
output$wt_gain_locality <- renderPlotly({
z <- wt_gain %>%
ggplot(mapping = aes(x = locality, y = wtGain)) +
geom_boxplot(colour = unicef_blue, width = 0.5) +
labs(title = "Average weight gain by locality",
x = "",
y = "Average weight gain (g/kg/day)") +
facet_wrap(state ~ .) +
unicef_theme
ggplotly(p = z)
})
plotlyOutput(outputId = "wt_gain_locality")
```


About
================================================================================
Expand All @@ -2500,7 +2728,7 @@ This dashboard has been developed in support of the evaluation of the **Sudan Co

**How to use the dashboard**

This dashboard has two main sections - *Performance* and *Responsiveness* - which can be accessed via the header tabs. The *Performance* section (shown on dashboard startup) presents analysis and visualisation of CMAM performance indicators at national, state and locality level across various time periods. The *Responsiveness* section presents analysis and visualisation of CMAM responsiveness indicators at national, state and locality level across various time periods. The dashboard has a fixed sidebar that contains various user interfaces for selecting appropriate settings for respective sections. The various settings groups include an info button which when clicked shows a modal dialog box providing information and guidance on how to choose appropriate settings.
This dashboard has four main sections - *Performance*, *Responsiveness*, *Case-finding*, and *Effectiveness* - which can be accessed via the header tabs. The *Performance* section (shown on dashboard startup) presents analysis and visualisation of CMAM performance indicators at national, state and locality level across various time periods. The *Responsiveness* section presents analysis and visualisation of CMAM responsiveness indicators at national, state and locality level across various time periods. The *Case-finding* section shows MUAC-at-admission which is an indicator of how good the case-finding mechanism of the programme is - the closer the MUAC-at-admissions are to the admitting MUAC threshold (i.e. 115 mm) the earlier that they are found in the community and the earlier the cases are found the better their treatment outcomes are. The *Effectiveness* section presents indicators of length-of-stay in the programme and average weight gain. These indicators assess clinical effectiveness. The dashboard has a fixed sidebar that contains various user interfaces for selecting appropriate settings for respective sections. The various settings groups include an info button which when clicked shows a modal dialog box providing information and guidance on how to choose appropriate settings.

<br>

Expand Down

0 comments on commit fb47e78

Please sign in to comment.