A timeline stratum read by the event cut-off, and labels for a timeline stratum's values
How: `linea_de_tiempo_al_corte` is `linea_de_tiempo_al_inicio_del_periodo` with what the timeline held by the question's event cut-off (all of it without one) instead of before the period's start. FHIR's `_label` reads a timeline stratum's labels from its `valores` entries and `resto_etiqueta`. Tests cover CaMa's tumour stratifiers: the facts dbt derives, the surrogate subtype's rules, CAMA_BIRADS_CANCER_INVASOR broken down by them, and the cut-off. Implications: a patient's characteristic learned after the fact that put her in the period (a cancer's stage or subtype, written after its biopsy) can stratify a measure, and stays reproducible through the cut-offs. CaMa publishes eight measures and five strata.
This commit is contained in:
@@ -120,9 +120,15 @@ def _proportion_cells(definition, counts: Counts, excluded: int | None = None) -
|
||||
|
||||
|
||||
def _label(spec: dict, value: str) -> str | None:
|
||||
"""A stratum value's label, when the stratum's `valores` maps values to labels."""
|
||||
"""A stratum value's label: from `valores` as a map of values to labels, or as a list of entries with `etiqueta`
|
||||
(a timeline stratum's), or `resto_etiqueta` for its `resto`."""
|
||||
labels_of = spec.get("valores")
|
||||
return labels_of.get(value) if isinstance(labels_of, dict) else None
|
||||
if isinstance(labels_of, dict):
|
||||
return labels_of.get(value)
|
||||
if isinstance(labels_of, list):
|
||||
found = [v.get("etiqueta") for v in labels_of if isinstance(v, dict) and v.get("valor") == value]
|
||||
return found[0] if found else (spec.get("resto_etiqueta") if value == spec.get("resto") else None)
|
||||
return None
|
||||
|
||||
|
||||
def _stratum_value(stratifier: str, value: str, display: str | None = None) -> dict:
|
||||
|
||||
Reference in New Issue
Block a user