CaCu indicators: times along the screening route, proportion intervals and survival notebooks #16

Merged
edgar merged 5 commits from integration/cacu-indicadores into dev 2026-11-22 01:01:08 -06:00
Showing only changes of commit 8e5a7e3b81 - Show all commits
+8 -6
View File
@@ -15,7 +15,9 @@ from pathlib import Path
import pytest
CORTE = date(2025, 12, 31)
INFERRED = {"colposcopia", "tratamiento", "citologia_de_vigilancia", "diagnostico", "antecedente", "orden_biopsia"}
# What dbt adds to the kit's timeline: the procedures it infers and the patient's birth and death, from `persona`.
ADDED = {"colposcopia", "tratamiento", "citologia_de_vigilancia", "diagnostico", "antecedente", "orden_biopsia",
"nacimiento", "defuncion"}
KIT_ROWS = Path(__file__).parent / "fixtures" / "kit_cacu_timeline.json"
@@ -38,18 +40,18 @@ def kit_rows():
def as_kit(rows) -> list[dict]:
"""Rows as the snapshot keeps them: text values, no load time, without the inferred procedures."""
"""Rows as the snapshot keeps them: text values, no load time, without the rows dbt adds."""
return [{k: None if v is None else str(v) for k, v in row.items() if k != "conocida_en"}
for row in rows if row["tipo"] not in INFERRED]
for row in rows if row["tipo"] not in ADDED]
def test_the_timeline_is_the_kit_s_plus_the_inferred_procedures(loaded, kit_rows):
"""Pins down: the wired repository reads dbt's view, which holds every row the kit's timeline held, in its
order and with a date as `fecha`, plus inferred procedures. Fails if the orchestration binds another query, or
the view stops giving one of the kit's rows."""
order and with a date as `fecha`, plus the inferred procedures and the patient's birth and death. Fails if the
orchestration binds another query, or the view stops giving one of the kit's rows."""
rows = loaded.ctx.repos.silver.timeline.read(until=CORTE)
assert as_kit(rows) == kit_rows
assert {row["tipo"] for row in rows} & INFERRED
assert {row["tipo"] for row in rows} & ADDED
assert all(isinstance(row["fecha"], date) for row in rows)