CaMa recurrence: every scenario the patient's covariates place her in

This commit is contained in:
Roberto Treviño Cervantes
2026-11-22 18:04:57 -06:00
parent cc54c1dc86
commit 1fbeabb872
2 changed files with 13 additions and 7 deletions
+6 -4
View File
@@ -154,7 +154,8 @@ def recurrence_blueprint() -> Blueprint:
"""CaMa's recurrence analysis, to register with `url_prefix="/cama"`: `GET /modelo/recurrencia` answers the figures of every clinical
scenario of both external cohorts (METABRIC and SCAN-B) that has a row in the summary the production version published, those rows
(one per cohort, scenario and horizon) for the risk-factor label, and, given `?paciente=<pac_id>`, the scenario her own age, tumor
size, grade and receptors place her in first as the default. The figures describe the cohorts' patients, not her."""
size, grade and receptors place her in first as the default, and every scenario they place her in (`de_la_paciente`, the larger
first within each cohort). The figures describe the cohorts' patients, not her."""
blueprint = Blueprint("model_analysis_cama_recurrence", __name__)
@blueprint.get("/modelo/recurrencia")
@@ -171,7 +172,7 @@ def recurrence_blueprint() -> Blueprint:
summary = _summary("cama", "recurrence", resolved.version, "analisis/recurrencia_desarrollo.json")
present = {(r["cohorte"], r["escenario"]) for r in summary}
figures = [f for f in record["escenarios"] if (f["cohorte"], f["escenario"]) in present]
default = None
default, hers = None, []
paciente = request.args.get("paciente", "")
if paciente.isdigit():
try:
@@ -181,8 +182,9 @@ def recurrence_blueprint() -> Blueprint:
rows = labelled[labelled["pac_id"] == int(paciente)] if labelled is not None else None
if rows is not None and not rows.empty:
mine = patient.matching(figures, patient.covariates_of(rows.iloc[0]))
default = {"cohorte": mine[0]["cohorte"], "escenario": mine[0]["escenario"]} if mine else None
hers = [{"cohorte": f["cohorte"], "escenario": f["escenario"]} for f in mine]
default = hers[0] if hers else None
return jsonify({"modelo": {"nombre": "cama-recurrence", "version": str(resolved.version)}, "horizontes": record["horizons_months"],
"escenarios": figures, "resumen": summary, "predeterminado": default})
"escenarios": figures, "resumen": summary, "predeterminado": default, "de_la_paciente": hers})
return blueprint