CaMa: individual risk and population curves served, and the cycle estimates with any scenario in production

webapi/fhir/risk.py builds a patient's RiskAssessment for CaCu and CaMa; GET /cama/modelo/curvas serves the production
version's survival curves; the cycle's estimator is generic by scenario; silver persona carries the date of death for CaMa;
the import schema accepts it; the CaMa risk batches can be confirmed and voided.
This commit is contained in:
rockdrigo
2026-11-21 02:07:34 -06:00
parent 26f2b35338
commit e2ecaa027c
17 changed files with 446 additions and 85 deletions
+6 -4
View File
@@ -68,14 +68,16 @@ def test_volver_a_correr_no_agrega_reportes(bases):
def test_en_cacu_arma_cada_cohorte_de_dbt_una_vez(bases):
"""Pins down: the cycle builds every cohort of the project in dbt's manifest, once each, and each build stores
as many members as it counts. TEA and CaMa have no dbt cohorts, so no cohort step. Fails if a cohort comes from
anywhere else than dbt, or a build's count and members disagree."""
as many members as it counts. TEA has no dbt cohorts, so no cohort step; CaCu's include the surveillance cohort
and CaMa's the total cohort. Fails if a cohort comes from anywhere else than dbt, or a build's count and members
disagree."""
proyecto, ctx, motor, _, pasos = bases
if proyecto != "cacu":
if proyecto == "tea":
assert "cohorts" not in [p.name for p in pasos]
return
armados = [p.summary for p in pasos if p.name == "cohorts"][0]
assert set(armados) == set(cohort_urls(proyecto, ctx.dbt_manifest)) and "cacu/cohorte_vigilancia" in armados
principal = {"cacu": "cacu/cohorte_vigilancia", "cama": "cama/cohorte_total"}[proyecto]
assert set(armados) == set(cohort_urls(proyecto, ctx.dbt_manifest)) and principal in armados
with motor.connect() as con:
assert con.execute(text("SELECT COUNT(*) FROM cohorte_armado")).scalar_one() == len(armados)
for armado_id, _ in armados.values():