From 7ddb3df4d986f749cd47d68357029fc1b608f4a8 Mon Sep 17 00:00:00 2001 From: edgar Date: Fri, 4 Dec 2026 12:47:07 -0600 Subject: [PATCH] No servir los riesgos ni listar los modelos ocultos --- tests/test_cacu.py | 5 ++++- webapi/fhir.py | 4 ++-- webapi/models.py | 7 ++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/test_cacu.py b/tests/test_cacu.py index 6350bb9..d88d1a6 100644 --- a/tests/test_cacu.py +++ b/tests/test_cacu.py @@ -32,12 +32,14 @@ from fhir_checks import follow_up, pages, served, unscored, validate from test_conectar import ok, wait_for from conftest import put_concept_map +from core.cacu import visibility ROOT = Path(__file__).parents[2] HOSPITAL = ROOT / "tests" / "fixtures" / "hospital" REFERENCE = ROOT / "tests" / "fixtures" / "reference" / "cacu" PIPELINE = ROOT / "tests" / "fixtures" / "pipelines" / "hospital_cacu.json" REFERENCE_CUTOFF = "2026-11-23" # the current platform's cohort cut-off (follow-up ends) + CAPTURED_ON = "2026-11-25" # the day the indicators were captured: durations counted to it PERIODS = [f"{y}-S{s}" for y in range(2021, 2027) for s in (1, 2)] COHORTS = { @@ -189,7 +191,8 @@ def test_cacu_from_the_hospital_to_indicators_and_risks(api, platform, tmp_path) # none is promoted without the clinical validation. wait_for(api, ok(api.post("/models/cacu/train", json={"as_of": REFERENCE_CUTOFF}))["run_id"]) names = [m["name"] for m in ok(api.get("/models/cacu"))] - assert set(names) == set(current) + # the hidden models (core.models.HIDDEN) are neither trained nor listed + assert set(names) == {n for n in current if visibility.model(f"cacu.{n}")} for name in names: (version,) = ok(api.get(f"/models/cacu/{name}/versions")) assert version["reports"] == ["interpretability", "technical_validation"] diff --git a/webapi/fhir.py b/webapi/fhir.py index f59d15c..2b4440c 100644 --- a/webapi/fhir.py +++ b/webapi/fhir.py @@ -20,7 +20,7 @@ from fhir.resources.R4B.resource import Resource from core import catalog, models from core import fhir as f from core import measures as m -from core.cacu import currency, risk_series +from core.cacu import currency, risk_series, visibility from core.cacu import reference_risk as reference from core.domains import Domain, measures, part from core.follow_up import window_start @@ -83,7 +83,7 @@ def _risks(domain: Domain, persons: list[str], cutoff: date) -> list[dict]: rows = [ r for r in reads.rows(domain.value, "risk", persons=persons) - if r["model"] not in models.DEVELOPMENT + if r["model"] not in models.DEVELOPMENT and visibility.model(r["model"]) ] history = _history(domain, persons) gone = {person: currency.withheld(found, cutoff) for person, found in history.items()} diff --git a/webapi/models.py b/webapi/models.py index 058b92c..dc91213 100644 --- a/webapi/models.py +++ b/webapi/models.py @@ -9,6 +9,7 @@ from fastapi import APIRouter, Depends, HTTPException, UploadFile from fastapi.responses import Response from pydantic import BaseModel +from core.cacu import visibility from core.domains import Domain from core.models import title from persistance import registry @@ -35,7 +36,11 @@ class Model(BaseModel): def models(domain: Domain) -> list[Model]: """The domain's registered models, with their names on screen.""" prefix = f"{domain.value}." - return [Model(name=n.removeprefix(prefix), title=title(n)) for n in registry.names(prefix)] + return [ + Model(name=n.removeprefix(prefix), title=title(n)) + for n in registry.names(prefix) + if visibility.model(n) + ] @router.get("/{domain}/{name}/versions")