Connect breast follow-up to the configured cohort

This commit is contained in:
Angel Capetillo Zavala
2026-11-13 15:16:14 -06:00
parent 7bc214b50c
commit 8b47f1522d
9 changed files with 220 additions and 305 deletions
+25 -7
View File
@@ -1,12 +1,17 @@
# Breast cohort: synthetic integration contract
This contract is opt-in and only for a synthetic source. The server must set
`CAMA_COHORT_SYNTHETIC` to `True`, provide `CAMA_COHORT_READER(cutoff)` and
provide `CAMA_COHORT_ACCESS(request)`. Without a reader the aggregate returns
503. Without an access callback or when it returns false, all cohort patient
list, detail and export requests return 403. The existing fixture endpoints
remain available when `cohorte` is absent. This is not a production access
policy; authorization for real patient data has not been implemented.
This contract is opt-in and only for a synthetic source. Set
`CAMA_COHORT_SYNTHETIC=1`, `CAMA_COHORT_SECRET` and
`CAMA_COHORT_ACCESS_TOKEN` in the server environment. The pseudonym secret
must have at least 32 UTF-8 bytes; the token must be at least 32 ASCII
letters, digits, underscores or hyphens. The application reads the configured CaMa database
and checks the `X-Cama-Cohort-Token` request header on patient routes. Store
the pseudonym secret persistently: changing it changes every pseudonym. The
header must be supplied by a trusted server-side access boundary, never
embedded in browser code. Without an enabled reader the aggregate returns
503; without authorized access the patient routes return 403. This is not a
production access policy; authorization for real patient data has not been
implemented.
`GET /cama/analisis/indicadores?corte=2026-10-20` returns a descriptive count
by BI-RADS. It includes `cohorte`, `revision`, `escenario`, `corte`,
@@ -37,6 +42,14 @@ accepts `page` and `page_size` (maximum 200). Export is limited to 5,000.
cohort is empty it is the cutoff. `hasta` is the inclusive cutoff. Windows 1,
3, 6 and 12 retain their calendar-month semantics.
Regular follow-up accepts the same window and filters without cohort context;
it reads the same source, checks access and returns its cohort context and
revision. When omitted, cutoff is the server's current date and the window is
three months. Quote the returned context in subsequent page, detail and export
requests to pin them to that revision. The old independent fixture, status and
priority filters are no longer served; these values cannot be derived safely
from the available records.
BI-RADS codes are `BIRADS_4`, `BIRADS_4A`, `BIRADS_4B`, `BIRADS_4C`,
`BIRADS_5`, `BIRADS_6`. Age options are `MENOR_40`, `40-49`, `50-59`,
`60-69`, `70+`, `SIN_DATO`. Filters combine with AND. Unknown, duplicated or
@@ -64,3 +77,8 @@ and requires `CAMA_COHORT_SECRET` and `CAMA_COHORT_ACCESS_TOKEN` of at least
Other domain database URLs are set to isolated in-memory SQLite by the example.
The Windows-only `fcntl` shim raises if locking is attempted: this example does
not validate file-locking functionality.
`examples/serve_cama_integration.py` runs normal application configuration
against an existing disposable SQLite copy, with a stable secret file and a
temporary token injected by its loopback-only test proxy. It is suitable only
for local synthetic integration and does not provide production authentication.