4.8 KiB
Breast cohort: synthetic integration contract
This contract is for a synthetic source. Set CAMA_COHORT_ACCESS_TOKEN in
the server environment. 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. 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,
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
patient identifiers. 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/<pac_id>; 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.
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
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_ACCESS_TOKEN of at least 32 characters. Send it 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.
examples/serve_cama_integration.py runs normal application configuration
against an existing disposable SQLite copy, with a temporary token injected by
its loopback-only test proxy. It is suitable only
for local synthetic integration and does not provide production authentication.