Follow-up status: CASO, a patient with a cancer biopsy

A biopsy reported with a grade of `cacu.seguimiento.caso.grados` (CARCINOMA, provisional) by the reference makes the
patient a case: the status wins over every other, and what is followed for her is survival. Only the follow-up list
reads this rule; the measures' stratum in dbt is unchanged.
This commit is contained in:
2026-11-22 15:03:31 -06:00
parent 4a61bd8d33
commit 7640486852
4 changed files with 51 additions and 6 deletions
+25
View File
@@ -68,3 +68,28 @@ def test_in_dev_esta_obsoleta():
with pytest.warns(DeprecationWarning):
in_dev()
def test_una_biopsia_de_un_grado_de_caso_hace_caso_a_la_paciente(client, monkeypatch):
"""Fija: quien tiene una biopsia reportada con un grado de `cacu.seguimiento.caso.grados` al corte es CASO, gane lo
que gane lo demás, y nadie sin una lo es; el filtro `estatus=CASO` las da. La base de demostración no tiene
carcinomas, así que la regla se toma aquí como CIN2. Falla si la precedencia deja de poner CASO primero o el
estatus deja de leer el grado de la biopsia de su regla."""
from sqlalchemy import select
from persistance.db import get_cacu_session
from webapi.follow_up import listing
from webapi.follow_up.silver import biopsias
original = listing.valor_de
monkeypatch.setattr(listing, "valor_de", lambda sesion, clave, **kw:
["CIN2"] if clave == "cacu.seguimiento.caso.grados" else original(sesion, clave, **kw))
b = biopsias()
with get_cacu_session() as session:
con_cin2 = {r.pac_id for r in session.execute(select(b.c.pac_id).where(b.c.grado == "CIN2"))}
filas = client.get("/cacu/seguimiento?corte=2025-12-31&meses=12&page_size=200").get_json()["items"]
casos = {int(i["pac_id"]) for i in filas if i["estatus"]["codigo"] == "CASO"}
assert casos and casos == con_cin2 & {int(i["pac_id"]) for i in filas}
solo = client.get("/cacu/seguimiento?corte=2025-12-31&meses=12&page_size=200&estatus=CASO").get_json()["items"]
assert {int(i["pac_id"]) for i in solo} == casos