9a62ddcdaf
The patient takes the menopausal state, molecular and clinical subtype, integrative cluster, cellularity, mutation load, Ki-67 category and source of the record; a new import entity carries the recurrence and the last contact; hormone and anti-HER2 therapy are treatments. The route serves each cohort's scenarios, a scenario's figure and a patient's scenarios over the live cohort build, computing the models and the bootstrap in the background and caching them per build. Includes the survival import work this builds on. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
"""`/cama/supervivencia`: the survival figure of a clinical scenario and the scenarios of a patient."""
|
|
|
|
from flask import Blueprint, jsonify, request
|
|
from werkzeug.exceptions import BadRequest, NotFound
|
|
|
|
from webapi.cama_survival import service
|
|
|
|
cama_survival_bp = Blueprint("cama_survival", __name__)
|
|
|
|
|
|
@cama_survival_bp.errorhandler(service.NotAvailable)
|
|
def _not_available(error):
|
|
return jsonify({"error": str(error)}), 404
|
|
|
|
|
|
@cama_survival_bp.get("/escenarios")
|
|
def scenarios():
|
|
return jsonify(service.scenarios())
|
|
|
|
|
|
@cama_survival_bp.get("/figura")
|
|
def figure():
|
|
scenario = request.args.get("escenario", "").strip()
|
|
if not scenario:
|
|
raise BadRequest("falta el parámetro «escenario»")
|
|
try:
|
|
return jsonify(service.figure(scenario))
|
|
except KeyError:
|
|
raise NotFound(f"el modelo no define el escenario «{scenario}»")
|
|
|
|
|
|
@cama_survival_bp.get("/pacientes/<int:pac_id>")
|
|
def patient(pac_id: int):
|
|
try:
|
|
return jsonify(service.patient_scenarios(pac_id))
|
|
except KeyError:
|
|
raise NotFound("la paciente no está en la cohorte")
|