Follow-up list: a case's survival is 1 at 0 years, at the index date

This commit is contained in:
2026-11-22 18:40:53 -06:00
parent c51402510a
commit 377882edd0
2 changed files with 8 additions and 2 deletions
+5 -1
View File
@@ -256,7 +256,11 @@ def _probabilidades_por_paciente() -> dict[str, dict[int, list[dict]]]:
continue
destino = found.setdefault(clave, {})
for pac_id, horizontes in por_paciente.items():
destino.setdefault(pac_id, [_horizonte(h, complemento=clave == "supervivencia") for h in horizontes])
filas = [_horizonte(h, complemento=clave == "supervivencia") for h in horizontes]
if clave == "supervivencia" and filas and not any(f["horizonte_anios"] == 0 for f in filas):
# at the index date every patient is alive
filas.insert(0, {"horizonte_anios": 0.0, "probabilidad": 1.0, "ic_bajo": 1.0, "ic_alto": 1.0})
destino.setdefault(pac_id, filas)
return found