67 lines
4.0 KiB
Markdown
67 lines
4.0 KiB
Markdown
# 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.
|
|
|
|
`GET /cama/analisis/indicadores?corte=2026-10-20` returns a descriptive count
|
|
by BI-RADS. It includes `cohorte`, `revision`, `escenario`, `corte`,
|
|
`umbral_supresion`, `unidad`, `denominador` and `grupos`. A sample group is
|
|
`{"codigo":"BIRADS_5","n":6,"suprimido":false}`. A suppressed group's `n`
|
|
is null. The prototype's required `indicadores` array is empty: the new
|
|
`grupos` is a count distribution, not an incidence or survival estimate.
|
|
No survival, recurrence, subgroup grid or other analysis endpoints are supplied.
|
|
|
|
One patient contributes once: choose the latest mammogram with a BI-RADS report
|
|
available by cutoff; then include it if BI-RADS is 4, 4A, 4B, 4C, 5 or 6.
|
|
`revision` is a digest of the materialized cohort, including its data and stable
|
|
pseudonyms. It is an integrity marker, not an authorization credential.
|
|
|
|
For each patient request send `cohorte=cama_birads_v1`, `escenario=diagnostico`,
|
|
the exact `revision` and `corte` from the aggregate, `meses`, and any selected
|
|
`birads` or `grupo_edad`. For example:
|
|
|
|
```
|
|
GET /cama/seguimiento?cohorte=cama_birads_v1&escenario=diagnostico&revision=<revision>&corte=2026-10-20&meses=0&birads=BIRADS_5
|
|
```
|
|
|
|
For the same selected population use the same query on
|
|
`/cama/seguimiento/exportacion` or `/cama/pacientes/<id_seudonimo>`; list
|
|
accepts `page` and `page_size` (maximum 200). Export is limited to 5,000.
|
|
`meses=0` means the whole eligible cohort through cutoff. Its inclusive
|
|
`desde` is the earliest eligible mammography date before filtering; when the
|
|
cohort is empty it is the cutoff. `hasta` is the inclusive cutoff. Windows 1,
|
|
3, 6 and 12 retain their calendar-month semantics.
|
|
|
|
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
|
|
invalid parameters return 400. A filtered group with fewer than five patients,
|
|
or a nonempty whole cohort smaller than five, returns 403; empty unfiltered
|
|
cohorts return an empty page. A revision mismatch returns 409; absent detail
|
|
returns 404, an unavailable reader returns 503 and oversized exports return 413.
|
|
Authorization is checked independently of suppression. Responses containing
|
|
patient data carry `Cache-Control: no-store`.
|
|
|
|
The source uses the kit's silver mammography and biopsy queries. A biopsy must
|
|
be linked through its order to the selected mammogram and patient. Clinical
|
|
dates and load start timestamps are distinct fields. Procedure and observation
|
|
load timestamps must be no later than the UTC cutoff day. Silver stores only
|
|
the current row: a historical value overwritten later cannot be reconstructed,
|
|
and the person table does not version date of birth. Therefore this contract
|
|
does not certify a historical snapshot. Revision detects changes between
|
|
requests but does not persist the previous cohort. The current implementation
|
|
materializes the full cohort in memory and has not been sized for production.
|
|
|
|
The local example `examples/serve_cama_cohort.py` accepts an existing synthetic
|
|
SQLite file in `CAMA_SYNTHETIC_SQLITE`, opens it read-only, binds to loopback,
|
|
and requires `CAMA_COHORT_SECRET` and `CAMA_COHORT_ACCESS_TOKEN` of at least
|
|
32 characters. Send the latter in `X-Cama-Cohort-Token` for patient requests.
|
|
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.
|