CaMa survival menu: a patient in no drawable scenario gets no default curve

This commit is contained in:
2026-11-21 15:42:15 -06:00
parent b7ce3e7ddd
commit 0e7cf0acbe
2 changed files with 12 additions and 2 deletions
+3 -2
View File
@@ -100,7 +100,7 @@ def model_analysis_blueprint(domain: str, scenario: str) -> Blueprint:
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."""
belongs to first as the default (`null` when she is in none). 404 while there is no version in production."""
from models.cama.survival import live
try:
@@ -117,7 +117,8 @@ def model_analysis_blueprint(domain: str, scenario: str) -> Blueprint:
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)
# Belonging to no drawable scenario leaves no default: showing another subgroup's curve would misdescribe her.
default = next((m["nombre"] for m in menu if m["nombre"] in mine), None)
return jsonify({"modelo": {"nombre": f"{domain}-{scenario}", "version": str(version)}, "escenarios": menu, "predeterminado": default})
@blueprint.post("/modelo/curvas/consulta")