Coalesces the four scattered POLIS diagnosis fields into one canonical
diagnosis_harmonised and derives the analytic variables that separate true
non-AFP illness from the acute-flaccid-paralysis differentials. The four
sources are read in priority order – a confirmed-polio override from
classification, then coded diagnosis_final, then the ICD-10
diagnosis_other, then the free-text diagnosis_other_specified, then the
free-text provisional_diagnosis – and the first that resolves to a
specific diagnosis wins. Free text is normalised (accent-stripped,
lower-cased, punctuation collapsed) and matched against
polis_afp_diagnosis_lookup(); ICD-10 codes against polis_afp_icd10();
the resulting label is classified via polis_afp_diagnosis_class().
Value
data with the harmonised diagnosis columns added:
diagnosis_harmonised– the single canonical diagnosis label;diagnosis_source– which field supplied it (classification (polio),diagnosis_final,diagnosis_other (ICD),diagnosis_other_specified,provisional_diagnosis,non-specific text,recorded unknownornone);diagnosis_class– the coarse class frompolis_afp_diagnosis_class();is_non_afp–TRUEfor reported illness that is not acute flaccid paralysis (malaria, sepsis, malnutrition, ...);residual_paralysis– the 60-day outcome fromfollowup_findings(residual/recovered/died/pending), when present;febrile_asymmetric_onset–TRUEwhen paralysis was asymmetric with fever at onset, when both source columns are present.
The raw diagnosis_* and provisional_diagnosis columns are left
untouched.
Details
Cases that carry text but resolve to nothing specific are labelled
"Other (non-specific)", an explicit "Unknown" is preserved, and a case
with no diagnostic information at all becomes "Not recorded", so every row
receives a definite label and a diagnosis_source provenance.
Examples
clean_afp_diagnosis(data.frame(
classification = c("Confirmed (wild)", "Discarded", "Discarded"),
diagnosis_final = c(NA, "Guillain Barre Syndrom", "Other"),
diagnosis_other = c(NA, NA, "B54"),
diagnosis_other_specified = c(NA, NA, "malaria"),
provisional_diagnosis = c(NA, NA, NA)
))
#> classification diagnosis_final diagnosis_other
#> 1 Confirmed (wild) <NA> <NA>
#> 2 Discarded Guillain Barre Syndrom <NA>
#> 3 Discarded Other B54
#> diagnosis_other_specified provisional_diagnosis diagnosis_harmonised
#> 1 <NA> NA Poliomyelitis
#> 2 <NA> NA Guillain-Barre syndrome
#> 3 malaria NA Malaria
#> diagnosis_source diagnosis_class is_non_afp
#> 1 classification (polio) polio FALSE
#> 2 diagnosis_final afp_compatible FALSE
#> 3 diagnosis_other (ICD) non_afp TRUE
