Skip to content

Compute a canonical disease display label in the ETL - #16

Merged
zuhdil merged 1 commit into
mainfrom
disease-label-display
Jun 16, 2026
Merged

Compute a canonical disease display label in the ETL#16
zuhdil merged 1 commit into
mainfrom
disease-label-display

Conversation

@zuhdil

@zuhdil zuhdil commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Compute a single canonical disease display label in the ETL and carry it
into Gold as a new dim_disease.disease_label column. This is the data-layer
half of the client's final disease-name rule; the dashboard reads this column
(separate PR in igh-dashboard).

The rule

With P = disease_filter and S = secondary_disease_name (the
"No secondary disease" sentinel and blanks are already normalised to NULL
upstream):

  • MalariaP + " – " + S (e.g. Malaria – P. falciparum) — its strains
    never stand alone, so the primary is prefixed with a spaced en dash.
  • secondary presentS (COVID-19, Lassa fever, Gonorrhea).
  • no secondaryP (Tuberculosis, Buruli ulcer).
  • both missing → NULL (the cross-cutting "R&D for all" rows).

STIs need no special branch: they arrive parent-collapsed with the specific
infection in secondary_disease_name, so the default branch prints it.

Why compute it here

Computing the label once in diseases.py, beside the existing secondary-sentinel
and STI normalisation (and unit-tested alongside them), keeps the rule in a single
tested place. The downstream GraphQL backend and React tables/slide-ins become
pure pass-throughs with no duplicated logic.

Changes

  • transformations/diseases.py — compute disease_label after the existing
    disease-filter normalisation.
  • silver_to_gold/config/schema_map.py — pass disease_label through to
    dim_disease.
  • tests/unit/test_diseases.py — cases for the default, no-secondary, Malaria,
    STI, and both-null branches.
  • tests/e2e/test_silver_to_gold_e2e.py — add disease_label to the expected
    dim_disease column set.

Verification

  • uv run pytest tests/unit/test_diseases.py — 22 pass.
  • Regenerated Gold and spot-checked: Malaria rows render Malaria – <strain>,
    secondary-bearing rows render the secondary, no-secondary rows render the
    primary group, 239 cross-cutting rows are NULL.

The portal needs to print one disease name consistently across the
Pipeline Explorer tables, the slide-ins, and the per-column table
filter. Compute that label once here, beside the existing secondary-
sentinel and STI-collapse normalisation, and carry it into Gold as a
new `dim_disease.disease_label` column. The rule:

    * default      -> the secondary disease (COVID-19, Lassa fever,
                      Gonorrhea);
    * no secondary -> the primary disease group (Tuberculosis, Buruli
                      ulcer);
    * Malaria      -> "<primary> – <secondary>" with a spaced en dash,
                      because its strains (P. falciparum, P. vivax)
                      never stand alone.

STIs need no special branch: they arrive parent-collapsed with the
specific infection already in `secondary_disease_name`, so the default
branch prints it. Computing the label in one tested place means the
downstream GraphQL backend and React tables/slide-ins are pure pass-
throughs with no duplicated rule.

The computation is guarded on both columns being present, matching the
existing STI-collapse guard: in production both always carry values, so
the column is always materialised.
@zuhdil
zuhdil merged commit 5c86a2d into main Jun 16, 2026
1 check passed
@zuhdil
zuhdil deleted the disease-label-display branch June 16, 2026 06:07
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.

1 participant