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:
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user