Skip to content

SNT25-488 (snt_dhis2_extract_report) - #106

Open
sPuntinG wants to merge 5 commits into
mainfrom
SNT25-488
Open

SNT25-488 (snt_dhis2_extract_report)#106
sPuntinG wants to merge 5 commits into
mainfrom
SNT25-488

Conversation

@sPuntinG

@sPuntinG sPuntinG commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

SNT25-488 --- Reporting nb + r utils of reporting of "A.1 DHIS2 Extract"

https://bluesquare.atlassian.net/browse/SNT25-488

Done

  • Cleaned code by replacing set up and config code with equivalent functions from ./code/snt_utils.r
  • changed the display of first table of "Liste des éléments de donnée extraits" (disaggregatedd indicators) to be also not kable() style (it was confusing to have 2 rendering styles, and kable outputs are truncated when too long)
  • changed color of missing values from "tomatoe" to "grey" in plots "Complétude de l'extraction des données de routine au niveau des formations sanitaires"
  • In "6. Disponibilité des données par formation sanitaire (sur la période analysée)" fixed some phrasing that was either wrong ("une valeur non manquante (c’est-à-dire, une donnée rapportée, qu’elle soit nulle ou positive)") or confusiong ("fenetre" for denominator, and phrasing of subtitle).
  • Made y axis start from 0 in all plots to be less dramatic/misleading ...

Yet to be addressed (not great but not breaking):

  • At point ### 6.: 🤌🏼 # GP (2026-08-06): why do we get "white" (or blank) tiles? Missing data should get a 0% ...
  • Double import of routine_data because at step ### 5. it is transformed and overwritten, so if used as is it breaks at point ### 7. (hence need to keep the second import from dataset). See comment: ⚠️ # GP: need to keep this import and transformation even if repeated from upstream) ...

Tested in:

  • 🇨🇩 COD ("SNT Testing")
  • 🇧🇮 BDI ("BDI SNT Process"). Note: current pipeline version is outdated, so I added the utils file manually so I could test the dev version of the reporting ipynb via VS Code (R reporting utils would be pulled if the pipeline was updated and re-run with "Pull scripts"). This way I don't mess up the ws in case they need to use that specific run.

☑️ Also checked: it renders in Orchestrator WebApp html embedded preview


Important: always merge branch with Rebase so changes are replayed on top (avoid re-surfacing of older code)

@irautu-bluesquare irautu-bluesquare left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, mentioned some minor changes, most of them can be added for a future rework if you don't have time now

" country_code = COUNTRY_CODE, \n",
" suffix = \"_dhis2_raw_analytics.parquet\" \n",
" )\n",
"printdim(routine_data)"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not crucial, but this might be a bit surprising/difficult to understand for someone who's less technical ("data dimensions" is jargon in our field). See my comment in the function, for more details.


# To move to ./code/snt_utils.r ... (see https://bluesquare.atlassian.net/browse/SNT25-591 )
printdim <- function(df, name = deparse(substitute(df))) {
cat("Dimensions of", name, ":", nrow(df), "rows x", ncol(df), "columns\n\n")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the "x" in "rows x"? Also, not crucial, but the term "data dimensions" isn't widely understood and it's redundant here, since you already mention 'rows' and 'columns' which is clearer.

"# caption = \"Liste des éléments de données extraits, classés par indicateur\",\n",
"# col.names = c(\"ID de l'élément\", \"Nom de l'élément de donnée\", \"Indicateur\")\n",
"# )\n",
"## GP: modified to match in style the table of next cell\n",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i think this is going to be clearer!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!
I think, both to keep in line with our approach in the reports and with best practices for testing in general, that the code and plots should become functions. Not sure if you have the time to do it now, so if you don't, you can disregard this and we'll add it for a future rework.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To go back to our discussions in and after a previous meeting, about rendering: so far the best method I've found when rendering a plot, to make sure it keeps the size I want, is to:

  • import IRdisplay
  • create the ggplot_object under a variable name (not displaying it)
  • set a variable with a dynamic width/height (optional, only if necessary and if yes, preferably set only one of the dimensions)
  • create the path_for_saving
  • save the ggplot_object in its path_for_saving (with the set width/height), removing the warning about the size, which is confusing to the user. for this, i use "suppressMessages(ggsave(filename = path_for_saving, plot = ggplot_object, ...))"
  • call the plot from path_for_saving with display_png(file = path_for_saving)
    This ensures the plots stay the size you want and that they're properly rendered in the report

}

make_point_geojson <- function(lat, lon) {
sprintf('{"type": "Point", "coordinates": [%f, %f]}', lon, lat)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe correct the order of the parameters, because in the function calling, it's first latitude and then longitude

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants