CaMa: the follow-up row carries a provisional status, priority and mammogram-to-diagnosis days; the survival menu names the patient's own scenarios

This commit is contained in:
Roberto Treviño Cervantes
2026-11-22 21:38:43 -06:00
parent 88c9694a46
commit f7f8af8b4c
4 changed files with 62 additions and 9 deletions
+9 -5
View File
@@ -99,8 +99,9 @@ def model_analysis_blueprint(domain: str, scenario: str) -> Blueprint:
@blueprint.get("/modelo/escenarios")
def scenarios_menu():
"""The clinical scenarios the menu offers: those with a row in the version's summary and enough patients over the data
ingested so far to draw, in the pipeline's order, with their patients; `?paciente=<pac_id>` also names the one she
belongs to first as the default. 404 while there is no version in production."""
ingested so far to draw, in the pipeline's order, with their patients; `?paciente=<pac_id>` also gives the ones she belongs to
(`de_la_paciente`, the whole cohort when she is in none) and the first of them as the default. 404 while there is no version
in production."""
from models.cama.survival import live
try:
@@ -110,15 +111,18 @@ def model_analysis_blueprint(domain: str, scenario: str) -> Blueprint:
in_summary = {row["escenario"] for row in _summary(domain, scenario, version)}
masks = live.scenario_masks(labelled)
menu = [{"nombre": name, "n": int(mask.sum())} for name, mask in masks.items() if name in in_summary and live.answerable(labelled, mask)]
default = menu[0]["nombre"] if menu else None
default, hers = (menu[0]["nombre"] if menu else None), []
paciente = request.args.get("paciente", "")
if paciente.isdigit():
try:
mine = live.patient_scenarios(labelled, int(paciente))
except live.QueryError as error:
return jsonify({"error": str(error)}), 422
default = next((m["nombre"] for m in menu if m["nombre"] in mine), default)
return jsonify({"modelo": {"nombre": f"{domain}-{scenario}", "version": str(version)}, "escenarios": menu, "predeterminado": default})
hers = [m for m in menu if m["nombre"] in mine] or (
[{"nombre": live.WHOLE, "n": len(labelled)}] if mine == [live.WHOLE] else [])
default = hers[0]["nombre"] if hers else default
return jsonify({"modelo": {"nombre": f"{domain}-{scenario}", "version": str(version)}, "escenarios": menu,
"de_la_paciente": hers, "predeterminado": default})
@blueprint.post("/modelo/curvas/consulta")
def live_curves():