diff --git a/webapi/fhir.py b/webapi/fhir.py index f371025..495b03f 100644 --- a/webapi/fhir.py +++ b/webapi/fhir.py @@ -209,40 +209,11 @@ def reference_risk( cutoff: date | None = Query(None, description="Only what was reported by this day"), sample: date | None = Query(None, description="The cytology's sample day"), ) -> Response: - """EXPERIMENTAL, off unless CACU_NCI_REFERENCE=1. The NCI/ASCCP CIN3+ reference risk of one - patient's cytology by a cut-off, how it was resolved and, beside it, the institutional models' - risks when they measure the same thing. Research only: not validated, not a recommendation.""" - facts, day = _reference_facts(domain, id, cutoff) - resolution = reference.resolve(facts, day, sample) - latest: dict[str, dict] = {} # each model's latest assessment by the cut-off - for r in _risks(domain, [id], day): - index = str(r["index_date"])[:10] - if index > day.isoformat(): - continue - found = latest.setdefault( - r["model"], - { - "model": r["model"], - "index_date": index, - "title": models.title(r["model"]), - "predictions": [], - }, - ) - if index > found["index_date"]: - found.update(index_date=index, predictions=[]) - if index == found["index_date"]: - found["predictions"].append( - { - "years": int(r["horizon_years"]), - "p": r["probability"], - "low": r["ci_low"], - "high": r["ci_high"], - } - ) - comparison = ( - reference.compare(resolution, list(latest.values())) if resolution["horizons"] else [] - ) - return fhir(f.reference_risk(resolution, comparison, reference.tables())) + """Disabled: the master table's provenance is not verified. The workbooks' series are in + `$risk-series`.""" + if domain != Domain.CACU or os.environ.get(NCI_REFERENCE) != "1": + raise HTTPException(404, "the NCI reference comparison is not enabled") + raise HTTPException(503, "NCI master table is unavailable: its provenance is unverified") @router.get("/Patient/{id}/$risk-series", responses=_OK, response_class=Response)