Compare commits

..

14 Commits

Author SHA1 Message Date
Angel Capetillo Zavala e0e8d2671e Update breast analysis integration 2026-11-14 08:12:36 -06:00
Angel Capetillo Zavala a1d402ccb5 Record local dashboard environment recovery 2026-11-13 18:31:56 -06:00
Angel Capetillo Zavala 132b85053e Record patient identity integration 2026-11-13 18:24:39 -06:00
Angel Capetillo Zavala 92d3a65797 Clarify Linux validation before deployment 2026-11-13 15:47:10 -06:00
Angel Capetillo Zavala c39d20b0cd Pin the breast dashboard merge 2026-11-13 15:46:28 -06:00
Angel Capetillo Zavala f6b9896147 Record verified breast dashboard composition 2026-11-13 15:44:51 -06:00
Angel Capetillo Zavala 8d628417f3 Record breast dashboard integration candidate 2026-11-13 15:18:24 -06:00
Angel Capetillo Zavala 5e4ed74e99 Update ISSSTELEON for CaMa analysis 2026-11-13 14:36:52 -06:00
Angel Capetillo Zavala b550d18fb3 Update ISSSTELEON 2026-11-13 00:02:26 -06:00
Angel Capetillo Zavala 3669f4a298 Update breast cancer follow-up application 2026-11-12 22:40:59 -06:00
Angel Capetillo Zavala 62d41bcab4 Pin CaMa dashboard presentation 2026-11-12 13:21:07 -06:00
Angel Capetillo Zavala f9ff0d5927 Pin the integrated CaMa dashboard-test release 2026-11-12 12:17:34 -06:00
Angel Capetillo Zavala 829c548913 chore(submodules): update ISSSTELEON dashboard-test composition 2026-11-12 02:15:41 -06:00
Angel Capetillo Zavala 367e40a9fc Pin application composition for dashboard testing 2026-11-11 20:45:57 -06:00
5 changed files with 245 additions and 47 deletions
-3
View File
@@ -144,9 +144,6 @@ Databases: four independent ones (`CACU_`, `CAMA_`, `TEA_`,
on SQLite, MySQL 8, PostgreSQL 16 and SQL Server 2022; older revisions are
gone, so a database stamped with them must start fresh):
- tea `a3e1c7b90d12`, cacu `b4f2d8c01e23`, cama `c5a3e9d12f34`, governance `d6b4f0e23a45` -> `e7c5a1f34b56`
- on `feature/163-source-terminology` (not in `dev` yet): tea `a3e1c7b90d12` -> `f2b6d1e8c934` ->
`6d772e9a342f`, cacu -> `f89e1f081998`, cama -> `f82b64f43abd` (`cat_sistema_fuente`, `cat_mapeo`;
verified on SQLite only)
---
-43
View File
@@ -293,46 +293,3 @@ Proposals that come up while doing a task and aren't resolved inside it. Each on
from the indicator catalog and the gold YAML; one Hamilton node per indicator reads that declaration,
as a MetricFlow `ratio` metric would.
- **Issue:** #162
## G-GEN-1. Source terminology as catalog tables, editable from the UI
- **Where:** `Core/core/catalogos/<dominio>.toml` (`codigos_hospital`, `etiquetas_fuente`, `alias`), the silver
load's enum maps, `WebApi/webapi/orchestration/reference/source_mapping.py` (the mapping's rules) and
`observacion_clinica.valor_fuente`.
- **What happens:** how a lab provider or a medical-record header writes our codes lives in the catalog's TOML
and in code. A provider change (new captions, spellings or test codes) needs a commit, a release and a deploy,
and a deploy would overwrite any change made outside git.
- **What it conflicts with:** rule 4 (two new tables); rule 2 (versioning has to work on every engine, so SQL
Server's temporal tables can only be an add-on).
- **Proposal:**
1. Our codes (`cat_estudio`, `cat_resultado`, `cat_valor`) stay in the TOML, reviewed in git.
2. How each source writes them moves to two tables, the database being their system of record:
`cat_sistema_fuente` (who sends the data, by `fuente_tabla` and validity dates) and `cat_mapeo` (FHIR's
ConceptMap: `clase` estudio, etiqueta or valor; the form and its normalized form; target; validity;
`registrado_por`, `registrado_en`, `motivo`). Append-only; a deploy only inserts missing seed rows.
3. The mapping is a partial, non-injective function `(system, resultado_id, normalized form, date) -> valor_id`
into `cat_valor`. `source_mapping.check_function` already enforces it on the TOML; the UI and the API
apply it on every save. `source_mapping.resolve` is the remap's rule: no mapping or two disagreeing
mappings give no code, and the observation goes back to the out-of-catalog queue.
4. A remap step on every cycle and on demand rewrites only `valor_id` where the code changes, under a
`carga` of its own (`conocida_en` keeps reports cut before it reproducible). A new caption or study code
needs a re-extraction or a reload instead.
5. A queue screen (source text with no code), a mappings screen per system, a curator role, and a
`ConceptMap` endpoint.
6. Versioning: validity dates in the table (what the pipeline reads, every engine); in production SQL Server,
system-versioned temporal tables on both tables for the edit audit, a SQL Server-only revision that's a
no-op elsewhere.
- **Open questions:** where a report records the mappings it used (`toml_sha`, `huella` or `parametros`);
mappings per system only or also global; whether the temporal tables are in scope now.
- **Evidence:** draft and SQLite demo in `mock/borradores/catalogo-mapeo/` (`PROPUESTA.md`, `01_tablas.sql`,
`02_demo.py`): seeding from the TOML changes 0 stored observations; a new lab's 5 unmapped spellings land in
the queue and, once mapped and remapped, reach dbt's timeline, the stratifiers and the invasive-cancer event
unchanged.
- **Found in:** #163 (CaMa values read from reports), 2026-11-13.
- **Status:** approved by the owner on 2026-11-13 and implemented on `feature/163-source-terminology` (every
repository rebased on `dev`): ISSSTELEON `66c4ba5` (Core tables), `74eb5a4` (a revision per domain),
`14dff24` (`SourceMappingRepository`), `d6e2c68` (dbt's `vigencias_sin_traslape` on `cat_mapeo`),
`72d092d` (pointers); WebApi `64d3d72` (`source_mapping`: `check_function`, `resolve`), `73cbf0c` (seeding in
the `catalogs` step, `register` checking the function on write). Layers 1 (write check), 2 (`UNIQUE` and
check constraints) and 3 (dbt test) are in; pandera is left for a bulk import of mappings. Still open: loads
read the TOML's aliases, not `cat_mapeo`; the remap step; the UI screens; the `ConceptMap` endpoint;
migrations verified on SQLite only.
@@ -0,0 +1,198 @@
# CaMa dashboard integration coordination
## Patient identity follow-up — 2026-11-13 (proposal for Claude)
Remote tips were checked: WorkingNarrative `92d3a65797b1a07c0bd3bd737f9af967acc876ee`, ISSSTELEON `ec6d3e6cd7b8126423664b694ff40c479ceb1613`, WebApi `8b47f1522de0efd29f6c66c4b13df48f51bf8381`, WebApp `2e0938628c85fae76fc41384edfd887c808cf53b`, kit `f4be01b3127588e98c02ff96822098138bd5b1f5`. The `feature/seguimiento-pac-id` tips are kit `23957cc8d2ee9176e5800bc0ab3cd7ea31408a41`, WebApi `854720066fb4e14f171f0c4a0034be5fd96a5623`, WebApp `bfbd11beae578beb483c46ee5052f1efbc6b3ba1`; no such branch exists in the two parent repositories. The kit branch returns `str(pac_id)` under the legacy name `id_seudonimo`, WebApi removes the salt argument, and WebApp uses that value for CaCu risk. These are not ancestors of the dashboard tips. Their intent needs integration without reverting CaMa work.
`pac_id` is the staging patient primary key, copied to each domain's indicator `persona` and used by cohort/risk records. It is stable within the retained domain database; it is not proven globally unique across CaCu, CaMa and TEA databases or installations. `pac_id_hospital` is a separate source identifier; do not expose it or equate independently assigned domain IDs. TEA redesign has its own `pacientes.pac_id` and patient-linked records; an episode or order is not a patient identity. Preserve domain context and any episode identifier separately.
TEA redesign WebApi `461d651` currently emits a salted pseudonym as both FHIR `Patient.id` and `EpisodeOfCare.id`; the episode references that patient and the summary endpoint resolves the pseudonym against the cohort. That shared value reflects the current one-row-per-child projection, not proof that patient and episode are the same entity. A future migration must update references and lookup together, retain compatibility for existing FHIR clients, and avoid assuming one episode per patient forever.
The CaMa token is currently checked by `patient_access()` on list, detail and export; it is therefore an access gate as well as a proxy credential, not a pseudonym secret. No common authentication hook was found in the current WebApi tree. The nginx injection grants access to callers of that proxy rather than identifying a user. Removing it requires an explicit common boundary or a clearly scoped synthetic-only access decision; do not silently open patient endpoints while removing the secret. The normal installer retains `.env`; `deploy-dev` renders and persists a controlled Compose and overrides the WebApi entrypoint with gunicorn. A missing or invalid secret/token with the synthetic switch set raises in `create_app`, so it can prevent `/health`; this is a code-based failure mode, not a diagnosis of 18080 without its logs.
Proposed executable contract for review: in source-backed CaMa list rows use `pac_id: "42"` (decimal string), and advertise the same key in `columnas`; `GET /cama/pacientes/42` with the exact `cohorte`, `escenario`, `revision`, `corte`, `meses` and filters returns the selected row as `item`; export with the same context returns that row with the same `pac_id`. Do not derive identity from a row index, page, cutoff, filter or revision. A changed revision returns 409 before resolving the patient. For CaCu, reconcile the existing `id_seudonimo` compatibility field and the `GET /cacu/pacientes/42/riesgo` consumer with a source-backed `pac_id`; for TEA keep patient and episode separately scoped and do not invent IDs when its source cannot provide one. This is a proposal, not yet an agreed or implemented contract. Claude: please confirm field types, transition handling and UI ownership, and record the final WebApp SHA and tests here.
Codex isolated work in `C:/dev/patient-identity`: kit cherry-pick `7237e36` and WebApi cherry-pick `2ca8623` port the CaCu branch pair while retaining the old CaCu field name. WebApi draft `eeb55c4` emits CaMa `pac_id` as described, uses the shared database reader, and keeps the token gate fail-closed until access is resolved. These are drafts, not publishable gitlinks. Claude: please adapt and test the WebApp against this proposed CaMa field and the CaCu risk consumer, then record your final SHA. Keep TEA's FHIR Patient and EpisodeOfCare references internally consistent when that branch is integrated later.
Further local checks: 16 kit follow-up tests and 25 WebApi CaMa/CaCu tests passed (WebApi tests used the Windows-only lock shim). On a disposable synthetic SQLite copy via a loopback test proxy, `/health` succeeded; all 43 CaMa rows reconciled across seven-row pages, each patient detail and the full export, while an earlier cutoff was empty. The test proxy injects its own token and does not validate the image, nginx or the deploy-generated Compose. Port 18080 on `10.0.10.41` did not accept a connection from this machine; no host logs have been inspected.
An unsuppressed six-row BI-RADS filtered export was also a subset of the unfiltered export with identical rows; an obsolete revision returned 409.
The current isolated backend draft also passed 90 CaCu/TEA indicator regression tests with that same Windows-only shim. It does not establish browser, Linux container, authorization, deployment or retained-configuration acceptance.
If the Action rejects an already unhealthy installation before activation, it has not performed a deployment: inspect the installation record, service state and WebApi logs on the daemon host without printing environment values. Identify the last known healthy Compose, image IDs and matching configuration in the retained deployment or the relevant `.archive/<operation>/deploy`; verify its `/data` bind points to the existing instance data and recover those services with the operator's approved procedure. Do not reinstall, reseed or restore a database over live storage. Check `/health`, image identity, mounts and data integrity before retrying. If a previous update reached `update_failed` or `updating`, preserve its record and use the documented recovery/reconciliation procedure appropriate to its recorded phase; do not simply change the status to bypass the guard. A previously healthy Compose alone is insufficient if the candidate already modified persistent data: validate the backup and compatibility first.
The previous token/secret and host-acceptance instructions below describe the old candidate and are superseded for planning by the identity follow-up; they are not evidence of the new composition. Local Docker is unavailable and `127.0.0.1:18080` did not answer in the sandbox; host logs and image validation remain unverified.
Status: in progress. This is not a release or deployment approval.
The integrated WebApp is at `http://127.0.0.1:51850/indicadores/cama`, against the synthetic API at port 51849. Both ports answered on 2026-11-13. WebApp `2e0938628c85fae76fc41384edfd887c808cf53b` merges Claude's `0acee49de2098b2f9d06607f7d374091a5f4b764` with the integration containing proxy commit `c06cce20dfe2718f0a009a8c0af4a58d12b5671a` and the contract fixes; its tree is identical to tested commit `3783505dbdbbda340560f78d5b77d8707fd91bd4`. Use cutoff `2026-11-13` for data and `2026-10-20` for the pre-load empty cohort. The Linux image test remains outstanding.
Local commits: WebApi `7bc214b50c4b151f3e6cc818e2860971407943ac` (identity) and `8b47f1522de0efd29f6c66c4b13df48f51bf8381` (reader and follow-up); WebApp `2e0938628c85fae76fc41384edfd887c808cf53b`; ISSSTELEON `ec6d3e6cd7b8126423664b694ff40c479ceb1613` pins both. These are prepared for child-first publication. Run the isolated Linux image check below before updating 18080.
## Executable integration endpoint for Claude
The loopback-only synthetic test proxy is `http://127.0.0.1:51849`. It runs this checkout's WebApi against `C:/dev/CaMa-Lote1-dashboard/integration-data/cama.sqlite`, a separate SQLite backup. It supplies a temporary access token on the server side; Angular must not send or store that token. The pseudonym key is retained separately in `integration-data/pseudonym-secret`. Do not use this proxy as a production access boundary. Port 5059 belongs to a different server and must not be used for this test.
To restart in PowerShell, from `C:/dev/CaMa-Lote1-dashboard/WebApi`:
```powershell
$env:PYTHONPATH='C:\dev\CaMa-Lote1-dashboard\WebApi'
$env:PYTHONUTF8='1'
& C:\dev\ISSSTELEON-CaMa-TEA-DEV\ISSSTELEON\WebApi\.venv\Scripts\python.exe examples\serve_cama_integration.py --database C:\dev\CaMa-Lote1-dashboard\integration-data\cama.sqlite --secret-file C:\dev\CaMa-Lote1-dashboard\integration-data\pseudonym-secret --port 51849
```
Proxy `/cama`, `/cacu`, `/tea` and the other API routes from the Angular dev server to that endpoint. `GET /cama/analisis/indicadores?corte=2026-11-13` returns six visible BI-RADS groups; `GET /cama/seguimiento?corte=2026-11-13&meses=0` returns 43 rows. The original 37 historical rows have been supplemented in this disposable copy with six invented recent mammograms, so the ordinary three-month window returns six rows. Their load timestamp is synthetic, taken from the existing test load. The added rows do not alter the stored indicator reports; those reports must not be interpreted as recalculated from these added records. The local fixture script is `C:/dev/CaMa-Lote1-dashboard/integration-data/add_recent.py`. `corte=2026-10-20&meses=0` returns an empty unfiltered page because the load was later.
List replies include `cohorte`, `revision`, `escenario`, cutoff, window, filters, columns, pagination and rows. For detail and export quote the returned context with the same cutoff, window and filters: `/cama/pacientes/<id>?cohorte=cama_birads_v1&escenario=diagnostico&revision=<revision>&corte=2026-11-13&meses=0` and `/cama/seguimiento/exportacion` with the same query. The detail's `item` is exactly the selected list row; export has `total_items` and `items`. Every row includes the clinical report dates and separate `*_carga_inicio` provenance timestamps. No priority or follow-up status is inferred from an incomplete record.
The integrated WebApp is served at `http://127.0.0.1:51850` with its API paths proxied to 51849. To restart it from `C:/dev/CaMa-Lote1-dashboard/WebApp`, run `& C:\dev\tools\node-v24.21.0\node.exe node_modules\@angular\cli\bin\ng.js serve --host 127.0.0.1 --port 51850 --proxy-config C:\dev\CaMa-Lote1-dashboard\integration-data\proxy.json`. Run `python e2e/cama_followup_probe.py` from this repository to check HTTP reconciliation through that proxy. On this copy, the probe reconciles the regular six-row window, all pages, detail and export, then an unsuppressed Analysis group and an early empty cutoff. The nine CaMa measures returned data rows for `2025-S1`; the BI-RADS matrix returned 36 cells. These HTTP checks do not replace visual inspection or downloaded-file acceptance.
On the final integrated checkout the production Angular build passed and a focused run passed 145 tests for cohort, selection, labels, record and exports. A separate run passed 97 tests for domain switching, filters, catalogs and indicator panels. The current WebApi passed 13 focused cohort/runtime tests; the prior same-SHA CaCu/TEA regression passed 101 tests. The local installer simulation passed 49 tests. A static check confirms the Compose token wiring and nginx template paths, but does not prove nginx substitution or Linux container startup.
Browser result relayed by the user from Claude: the revised three-month habitual view showed six records and whole-cohort view 43. Table and XLSX identifiers matched in order, and the eight-page PDF preserved that order. All six Analysis groups opened the record and exported files matching the table, with focus returned to “Ver pacientes”. The pre-load empty state disabled exports. Resumen and Histórico loaded four values and eight figures. At 360 px the five views had no horizontal scrolling. CaCu and TEA opened their three sections, though this integration copy does not provide their data. Claude's validated working-tree changes were integrated locally; the 404 unavailable message was added afterwards and is covered by a focused automated test. Linux container validation remains outstanding.
## Composition
On 2026-11-13 the remote `dashboard-test` tips matched WebApi `1d5f1e0cc4c92d0184160191952afea07449bcc7`, WebApp `2b0f6dfbed3e4162a7c96c1a417897c7a1dc9bb5`, ISSSTELEON `8c9949ff3590d8407900281323d6224a6d2688c0`, and WorkingNarrative `5e4ed74e99b3f2f9762e9c1af9940b4c0773bff7`. The parent gitlinks match these child tips. Lote 1 is published on these branches; that does not establish what is deployed on port 18080. WebApp `features/cama-mock` was inspected at `c076e1e7a99c5937866560b0bb832578b4fa56b7`.
## Contract and ownership
- Backend owns the cohort, eligibility, cutoff, links, availability, revision, authorization, suppression and provenance. Angular owns presentation labels and exports from the server's selected rows; it must preserve codes for filters. The existing cohort endpoint returns raw BI-RADS and age codes, and Angular's `etiquetarCohorte` supplies display labels. `biopsia_fecha` in this contract is the report date, not a specimen date. `biopsia` is the source histopathology code, not a validated clinical diagnosis label.
- The existing CaMa catalog confirms display labels for `BENIGNO` → `Benigno`, `CARCINOMA_IN_SITU` → `Carcinoma in situ`, `CARCINOMA_INVASOR` → `Carcinoma invasor`, and `DESCONOCIDO` → `Desconocido`. The WebApp now applies them to cohort rows and retains the original as `biopsia_codigo`, so the table, patient card and files use the same display value. Unknown source values stay unchanged. Clinical and load dates retain distinct meanings.
- `GET /cama/analisis/indicadores` needs `corte` and returns a revision. Both regular follow-up and Analysis use the configured reader and the same selection logic. Regular follow-up returns a revision; for subsequent pages, detail and export send that context with the same cutoff, window and filters. A changed revision is 409; small filtered selections, including empty ones, are 403. An empty unfiltered cohort is 200. The threshold is five.
- The habitual CaMa view initially requests the three-month window without a revision; the server supplies the cutoff and cohort context, which the client retains for subsequent pages and exports. The user can select the whole cohort (`meses=0`). A 404 or 503 is displayed as unavailable and never triggers a switch to another source. A 409 on a habitual list retries the same query once without the old revision; a repeated 409 is shown. A selected group from Analysis retains its original revision and requires refreshing the analysis after 409. The patient card uses the selected list row and its announced column labels; it keeps that row, cutoff and selection while open and on return. It does not call the detail endpoint. Backend detail remains available and is checked independently against the same selection.
- The source is current silver procedures and observations, with clinical dates and load timestamps checked against the UTC cutoff. The order must link biopsy and selected mammogram and belong to the same patient. Silver does not preserve overwritten versions, so this is not a reproducible historical snapshot. A report can exist before its result is available. Provenance fields are load timestamps, not clinical event dates. Do not label them as clinical dates.
- On the read-only local synthetic fallback `C:/dev/ISSSTELEON-CaMa-TEA-DEV/F4D2-evidence/cama-local-fallback.sqlite`, the cutoff 2026-10-20 yields zero cohort rows: its three loads began on 2026-11-12 UTC. At 2026-12-31 the reader yields 37 rows. An empty page at an earlier cutoff is therefore not evidence of an empty database. This is a reader check, not an end-to-end dashboard test.
- Patient routes require a server-side access callback; a revision is not a credential. The configured reader is currently explicitly synthetic. The example's token is a test mechanism, not an authorization policy for real patients. Do not embed it in Angular or expose patient endpoints without an equivalent server-side access boundary.
## Remote mock inventory
| Capability | Source and rule needed | Status |
| --- | --- | --- |
| Resumen C2 breakdowns | Published `estrato`, category cells and labels; counts or percentage of each stratum only when its total is known. Suppressed and missing cells remain distinct. | Angular implementation exists in the remote mock; real capabilities and measures need reconciliation. |
| Curves | `/analisis`, `/analisis/resultados`; cohort membership, event, start, censoring, competing event, horizon and estimator, plus suppression at risk-set level. | Event and censoring definitions and adequate longitudinal source not verified; do not fabricate KM/CIF or intervals. |
| Heatmap | `/analisis/subgrupos`; two distinct variables, estimator, horizon, cell populations and events, suppression and crossed tests. | Same definitions and source unresolved; no supported endpoint yet. |
| Cohort diagnosis | Population/events, median follow-up, model checks, statistical validation and registered versus assumed variables from the same result. | Depends on the unresolved analysis and model definitions. |
| Individual Timeline View | No matching UI or proposal was found in WebApp remote `c076e1e` or Claude's `7971a49`; the generic patient detail has a medical history table. | `cama_linea_de_tiempo` is absent from the isolated synthetic database and its inspected backup, and WebApi's image does not build dbt. Its macro chooses an observation's load date without also checking its procedure's load and joins observations without a patient equality check. The view exposes source IDs. Verify the actual view on 18080, provide reproducible creation and cross-engine identity/knowledge tests, define which source identifiers are safe to expose, and identify Claude's UI proposal before implementing an endpoint. |
## Integration and acceptance still needed
- Backend: finish validation of both follow-up entry points, including unavailable results, provenance, identity, cutoff and links against the integration database. Verify whether complementary suppression is required before publishing intersecting breakdowns.
- Claude / Angular: exercise the final contract through regular follow-up and Analysis, including empty and suppressed selections, readable labels, biopsy report date, source vocabulary and provenance; verify detail, PDF and XLSX use the exact selected rows. Share the final WebApp SHA and tests with backend before parent gitlinks are updated.
- Startup: normal `create_app` now enables the synthetic reader only when `CAMA_COHORT_SYNTHETIC=1` and a stable pseudonym secret and a separate URL-safe access token are configured. The proposed nginx template overwrites the incoming token header with its own container environment value. This grants access to anyone who can reach the proxy and is intended exclusively for the isolated synthetic instance, not real clinical data. The Compose change supplies the token to nginx without putting it in Angular. This image configuration has not yet been built or tested with Docker here. The conservative update retains the prior `.env`; it does not provision these settings automatically. Before the Action, an operator with host access must verify the port identifies the intended synthetic instance, add the three values privately to its retained `.env` without changing the data path, and retain the same secret on future updates. Check file permissions and never print the values. Validate the actual image and proxy before declaring the update ready.
- Acceptance: the local API reconciliation and Claude's browser checks are recorded above. Verify the isolated Linux image and the existing 18080 installation record, backups and update guards on the host. Never replace or reseed its database as part of the update.
## Host acceptance after the composition is ready
1. On labserver, first build the candidate WebApi and WebApp images from the fully checked-out, pinned `ISSSTELEON` tree and run `dist/docker-compose.yml` under a separate Compose project and unused port, with an independently backed-up synthetic SQLite dataset and its own private `.env` and data directory. The `.env` must set `ISSSTELEON_VERSION`, `ISSSTELEON_DATOS`, `ISSSTELEON_PUERTO`, the four database URLs, `CAMA_COHORT_SYNTHETIC=1`, and independent stable `CAMA_COHORT_SECRET` and `CAMA_COHORT_ACCESS_TOKEN` values. Run `docker compose config -q`, start the isolated services, then perform the `nginx -t`, direct-403 and proxied-200 checks below using that isolated Compose project and port. Verify the same pseudonym before and after a restart and check CaMa measures. This is the missing Linux image and token-injection validation; do not use the 18080 data directory as the isolated target.
2. Verify that port 18080 maps to one `installed` record for the intended synthetic instance and retain its existing data and configuration. Back up and verify the current instance using the conservative update workflow; never install a fresh instance over its data. Check that no schema migration is pending.
3. Provision `CAMA_COHORT_SYNTHETIC=1`, `CAMA_COHORT_SECRET` and `CAMA_COHORT_ACCESS_TOKEN` privately in that instance's retained deployment `.env`. Generate two independent cryptographically random hex strings of at least 32 characters, retain the pseudonym secret for all later deployments, and do not print either value or commit them. The proxy token enables all clients that can reach that proxy, so this configuration is only for the synthetic environment. Confirm the file remains accessible only to the deployment account. The update copies retained configuration forward; it does not create the secrets itself.
4. After all candidate commits are validated and published child-first, dispatch `WorkingNarrative` → `deploy-dev` on ref `dashboard-test` with `puerto=18080` and `rama=dashboard-test`. Capture the resolved SHA and check it against the final outer gitlink. The update must complete its backup and integrity checks; investigate any failure instead of reinstalling or replacing the database.
5. Confirm `/health` through the WebApp proxy and check the actual nginx container uses the proposed template and the configured server-side token without displaying the token. Request `/cama/analisis/indicadores?corte=<current-date>` and `/cama/seguimiento?corte=<current-date>&meses=3`; the actual counts depend on the preserved instance. Exercise an earlier cutoff, an unsuppressed analysis group, its follow-up list, detail, PDF/XLSX and return navigation. Check Resumen and Histórico measures and CaCu/TEA. Do not assume the local six synthetic cases or local 43-row count exist on 18080.
In the verified instance's retained `deploy` directory, the operator can check the rendered container and direct API boundary without printing credentials:
```sh
docker compose --env-file .env -f docker-compose.yml ps
docker compose --env-file .env -f docker-compose.yml exec -T webapp nginx -t
docker compose --env-file .env -f docker-compose.yml exec -T webapp sh -c 'wget -S -O /dev/null "http://webapi:5000/cama/seguimiento?corte=2026-11-13&meses=3" 2>&1 | grep "HTTP/.* 403"'
curl -fsS http://127.0.0.1:18080/health
curl -fsS 'http://127.0.0.1:18080/cama/analisis/indicadores?corte=2026-11-13'
curl -fsS -o /dev/null -w 'Seguimiento HTTP %{http_code}\n' 'http://127.0.0.1:18080/cama/seguimiento?corte=2026-11-13&meses=3'
```
The direct request must return 403 and the proxied follow-up must return 200, or an explicitly explained suppression response for a small nonempty group. Use a cutoff that includes the actual instance's load timestamps, then one before them; do not infer either timestamp from the local fixture. Check pseudonym stability across a restart by comparing a selected ID privately, and do not print the ID or the secret. These are post-deployment checks, not evidence that the Linux image has already been validated.
## Patient and episode identity (Claude, WebApp)
Status: implemented in WebApp worktree `C:/dev/ISSSTELEON-WebApp-identity`, branch `feature/claude-identity-contract`, based on `dashboard-test` `2e09386`; final SHA at the end of this section. The audit below describes the sources as they were before the backend decision.
### What each domain sends today
| Domain | Key on the row that opens the card | Patient identity | Episode |
| --- | --- | --- | --- |
| CaMa (`dashboard-test`, WebApi `8b47f15`) | `id_seudonimo`: full HMAC-SHA256 hex, prefix `cama:`, secret from `CAMA_COHORT_SECRET`. 43 rows, 43 distinct ids on the integration API (`meses=0`). | same value | none. The cohort keeps one row per patient (latest mammogram with a BI-RADS report, then BI-RADS 4 to 6), so a patient never appears twice in one cohort. The selected mammogram is only implied by `mastografia_fecha` and `toma_carga_inicio`. A later cutoff can change which mammogram a given `id_seudonimo` stands for; only `revision` detects it. |
| CaCu (`dashboard-test` kit) | `id_seudonimo` = `"P-" + sha256(sal:pac_id)[:10]`, default salt `dev-simulado` (`SEGUIMIENTO_SAL`). | same value | none: the list groups by `pac_id`. |
| CaCu risk (`GET /cacu/pacientes/<int:pac_id>/riesgo`) | needs the integer `pac_id`, which the list never returns. | `pac_id` | none |
| TEA (branch `feature/163-tea-redesign` in WebApp and WebApi; not in `dashboard-test`) | `EpisodeOfCare.id`, shown as `id_seudonimo`; the card opens `Patient/<id>/$resumen-tea`. | `Patient.id` | `EpisodeOfCare.id`. The server sets both to the same pseudonym (one episode per child, keyed by `pac_id`). |
Verified on 2026-11-13 against `127.0.0.1:51849`: CaMa list, uniqueness above. `/cacu/seguimiento` answers 500 and `/tea/seguimiento` 404 on this copy (no CaCu data, no TEA routes), so those two cannot be exercised end to end here. `GET /cacu/pacientes/P-ABCDEF1234/riesgo` answers 404 because the route only accepts an integer.
### Findings
1. `id_seudonimo` means three different things: a secret-keyed HMAC (CaMa), a 40-bit salted hash with a public default salt (CaCu), and, on WebApi `feature/seguimiento-pac-id` (`8547200`, drops the salt from the CaCu list), apparently the raw `pac_id`. The WebApp commit `bfbd11b` on `feature/seguimiento-pac-id` sends the list's `id_seudonimo` to `/cacu/pacientes/<pac_id>/riesgo`. That works only if the list returns `pac_id`; with the pseudonym contract it silently shows "no disponible" because of the 404. I have not checked the kit side of `8547200`. Showing `pac_id` conflicts with the CaMa note "do not expose `str(pac_id)`" and with the label «Identificador seudónimo».
2. TEA's WebApp maps an episode row with `id_seudonimo = episode.id`, matches included resources by `subject.reference === episode.id`, and opens the patient card with the same value. This is correct only while episode id equals patient id. A patient with two episodes would open one card for both rows, collide on `data-patient` focus selectors, and match the wrong included resources.
3. No list row in any domain carries an episode key, and no endpoint returns two rows for one patient, so "one patient, several episodes" cannot be produced from the current data. Angular keys rows, selection, focus return and exports on `id_seudonimo` alone.
### Questions answered by the backend decision
See the backend decision below: patient key is `pac_id`, no client or server invents an episode key, CaCu risk uses `pac_id`, TEA is not part of this change.
### Backend decision for this integration (Codex)
The requested direction is to retire `id_seudonimo` from the new source-backed path. Use decimal-string `pac_id` for the patient, scoped by domain and retained database; it is the platform staging key copied into the indicator `persona`, not the hospital identifier and not a global identity. Do not create a new HMAC or require a pseudonym secret. In CaMa the list, announced columns, patient card and exports use `pac_id`; the detail route uses that same value and exact selection context. The draft implementation and test proxy are documented above. A cutoff can select a different mammogram for the same patient; `revision` detects cohort changes, and the card must retain the selected row and context.
For CaCu, the ported existing branch temporarily returns the decimal patient key in legacy `id_seudonimo`; the current `/cacu/pacientes/<int:pac_id>/riesgo` is the correct risk route. This changes the legacy field's value, so consumers must refresh their list and discard saved old hashes instead of interpreting them as IDs. For the new contract we will add `pac_id` with the same decimal string, keeping the legacy field only as a migration alias for existing consumers; WebApp should prefer `pac_id` and never route a hash to risk. Do not expose `pac_id_hospital`.
Do not synthesize `id_episodio` from a patient or from a date. CaMa currently publishes one selected mammogram per patient and has no supported episode API in this contract; retain the selected row and context. TEA is not being merged in this task: keep its existing FHIR pseudonym behavior until its own integration, while designing the client to distinguish `EpisodeOfCare.id` from the patient reference and not assuming equality. An actual source-backed episode identifier and its lifecycle need a separate contract when multiple episodes are supported. This answers questions 1–5: no invented episode key or CaMa HMAC; risk uses `pac_id`; TEA remains a later integration; no new CaCu salted hash.
Claude: please implement CaMa `pac_id` and the CaCu migration behavior, preserve TEA's current path, and record your final WebApp SHA and tests. Backend will add the CaCu `pac_id` field and retain the alias for transition.
The CaCu addition is now in kit `778088b` and its WebApi contract test in `06dd74c`; 16 kit and 11 WebApi follow-up tests passed (the latter with the Windows lock shim). The WebApi SHA includes the earlier CaMa draft `eeb55c4`. These remain isolated pending integration.
WebApi `6d32115` adds a passing full-app startup test with retained `CAMA_COHORT_SYNTHETIC=1`, absent obsolete secret and invalid token: `/health` succeeds and patient access remains denied. The three runtime tests pass with the Windows lock shim.
The current isolated WebApi tip is `9c0e03f` (removes an obsolete example-only switch); kit remains `778088b`. Core, Persistance and Extraction trees used by the local test environment match the candidate's pinned trees.
The isolated kit, WebApi, ISSSTELEON and WorkingNarrative worktrees use the local branch `feature/patient-identity-dashboard`; none has been pushed. The WebApp is Claude's separate worktree and branch.
For Claude's browser integration, the new backend is temporarily available at `http://127.0.0.1:51869` on the disposable CaMa data copy, without a token. Use cutoff `2026-11-13`, `meses=0` for 43 rows or the regular three-month window. This loopback server does not include CaCu or TEA data and is not a deployment boundary.
The models repository was also checked: it has no `feature/seguimiento-pac-id` or `dashboard-test` remote branch; TEA points to models `c50c3a081e9e592f710da5a87ccf31629cb03c8a`. The operator confirmed Docker is unavailable for now; proceed with local work and leave the real Compose/image update test outstanding.
The operator explicitly authorized the synthetic composition to use the same patient-route exposure as CaCu, without the CaMa-specific token. Codex is removing the token and Compose injection; no common authentication hook exists in the current WebApi. Claude: please remove the CaMa token nginx template/injection from your WebApp change as well. The optional access callback may still be supplied by a future common boundary. This changes the earlier fail-closed draft described above.
The loopback server on `51869` has been restarted with this updated no-token backend. Its sample data and identity contract are unchanged. CaCu list-to-risk identity was also exercised against a seeded patient: all four patient-risk tests passed with the Windows lock shim.
The no-token WebApi change is now committed at `46eb3df`; 14 focused CaMa tests passed with the Windows lock shim and the loopback server returned `/health` and 43 follow-up rows without a token. These checks do not validate Linux Compose or nginx. The optional callback remains usable when a common boundary is configured.
Review note for Claude: the current uncommitted `PAC_ID` validator permits at most 18 digits. SQLite integer primary keys can have 19 decimal digits; these identifiers are transported as strings, so please accept the source-supported 19-digit range and test it without converting to a JavaScript number.
The current WebApi tip is `1d8cd264b80cabaa7c2aa63e029a1e95a5db272f`; its last commit only clarifies the optional access callback documentation. ISSSTELEON's isolated index has the WebApi and kit gitlinks and Compose cleanup staged, pending Claude's WebApp SHA before committing the complete composition.
WebApi now ends at `10f0c59975647acc3d55c2d17dee6112ec6f9595`: a configured but non-callable optional access callback denies access instead of being ignored. Four focused follow-up tests passed with the Windows lock shim, and the staged ISSSTELEON gitlink has been updated.
The isolated WorkingNarrative `test_conservative.py` suite passed 49 mocked installer/update tests, including retained configuration handling. Its simulated messages about port 18080 are not a deployment or a Docker test. The actual Compose generated by `deploy-dev` and the retained-configuration update remain untested on Linux.
### WebApp implementation (Claude)
Final WebApp SHA: `3b246b4f1f94b4b4259816da5824d8a9a02f2d22` on `feature/claude-identity-contract` (local, not pushed). It is `dashboard-test` `2e09386` plus three commits: `edb868f` (the risk-by-`pac_id` commit of `feature/seguimiento-pac-id`, cherry-picked), `caf5f95` (the token and nginx template removed) and the identity change.
Contract the client implements:
- A row identifies its patient by `pac_id`, a decimal string (`0` or no leading zero, at most 18 digits), or by the legacy `id_seudonimo` (any non-empty string). `pac_id` wins when both are present, so the alias that CaCu rows carry during the migration is never used as the key. A `pac_id` that is not a decimal string (a JSON number, a padded value, a hash) makes the row invalid; the client does not fall back to `id_seudonimo`.
- A page whose rows repeat a patient, or identify patients by different fields, is not drawn, and a list read for a file that does so is refused. The same check runs over the concatenated pages of an export, so a patient on two pages stops the export.
- CaMa and every domain that uses the generic follow-up table: the link, the card, the PDF of the card and the columns of the table and the XLSX/PDF follow the announced `columnas`; the label comes from the server («Identificador de paciente»). The card keeps the clicked row, cut-off and selection; the client does not call the detail endpoint and does not infer a different mammogram for the same patient.
- CaCu: the table and card use `pac_id` when the row has it, labelled «Identificador de paciente», and the legacy «Identificador seudónimo» otherwise. The risk route `GET /cacu/pacientes/<pac_id>/riesgo` is requested only for a row with `pac_id`; a row with only `id_seudonimo` shows «Riesgo individual no disponible» and makes no request, because the value may be a hash. A 404 is "no risk data".
- No `id_episodio` and no episode key of any kind: the client has none and the backend decision defers it. TEA is untouched; its FHIR client still reads `EpisodeOfCare.id` and `Patient` as the same pseudonym and will need its own change before a patient can have several episodes.
- Transition: a response with only `id_seudonimo` renders exactly as before; verified against the integration API in legacy mode.
- Token: `Dockerfile` and `nginx.conf` are back to copying `nginx.conf` as the server config, with no `X-Cama-Cohort-Token` header and no environment substitution. The client never held a token.
- Demonstration records added in a CaCu record are kept per patient identifier. The legacy synthetic detail provider is looked up by `id_seudonimo`; a `pac_id` row has no synthetic detail and shows the unavailable state.
Validated:
- Against Codex's no-token backend at `127.0.0.1:51869` (dev server on 51851, cut-off `2026-11-13`): the regular three-month list returned 6 rows equal to the API in order; the whole cohort with 10 per page returned 43 rows on 5 pages, 43 distinct `pac_id`, equal to the API in order; the XLSX parsed from the downloaded blob had the header «Identificador de paciente» and the same 43 ids in the same order, and every row's cell text equalled the table's. The PDF generated with 4 pages; its text was not extracted, so the PDF order is covered by the document-definition tests and by being built from the same rows as the XLSX. From Analysis, the BI-RADS 5 group opened 12 rows over two pages equal to the API with the `birads` filter; the card for a row on page 2 showed that row's `pac_id`; focus returned to the control used; the XLSX had the 12 ids in the same order. Backend detail returned 200 and the export 43 rows with the same context; an earlier cut-off returned an empty cohort.
- Against the same API through a test-only forwarder that rewrites `pac_id` back to `id_seudonimo`: legacy rows rendered and opened with the legacy label.
- CaCu and TEA: the integration API has no data for either (`/cacu/seguimiento` answers 500, `/tea/seguimiento` 404), so the browser check only shows that both domains open their sections and report the unavailable data. The CaCu follow-up, record, risk and registration code paths are covered by their unit tests, which pass.
- `ng build` (production) passes. The full WebApp suite ran 1628 tests: 1624 passed and 4 failed. Three failures are the same at `2e09386`: the header title in `indicadores-cama-oportunidad.spec.ts`, and two 404-state tests in `indicadores-seguimiento-tabla.spec.ts` that still expect the pending message the unavailable-cohort message replaced. The fourth, `app.spec.ts` (`/conectar`), failed once under load and passed when run alone. New tests are in `paciente-identidad.spec.ts`; the older specs were adapted where they read `id_seudonimo`.
Still open: the Linux image and nginx, the PDF text order from a rendered file, CaCu with real data, and the two stale 404 specs.
### Integrated local composition
Codex integrated Claude's exact WebApp `3b246b4f1f94b4b4259816da5824d8a9a02f2d22` and added `01d6e71f07a4833248cabc4ee18be21da22f37e8`, which accepts 19-digit SQLite integer IDs as strings. The focused identity suite passed 15 tests. ISSSTELEON `3b442d89a2c1e5d924be5949c34d3c1b6a985af8` pins WebApp `01d6e71f07a4833248cabc4ee18be21da22f37e8`, WebApi `10f0c59975647acc3d55c2d17dee6112ec6f9595`, and kit `778088b91024e71380bc8fe696140cd45b3dacb5`, and removes the obsolete Compose token environment entries. These commits are local and not yet deployed. The WebApp findings and outstanding checks immediately above remain applicable.
Publish child-first only after review: kit, WebApi, WebApp, ISSSTELEON, then WorkingNarrative. The operator handles publication and deployment. Before 18080, validate the actual `deploy-dev` generated Compose and a retained-configuration update on an isolated Linux Docker host; retain the existing data and use the recovery guidance above if the current installation is unhealthy. The browser and mocked installer evidence here does not replace those checks.
The earlier `51850` development server held a file in the shared `node_modules` after an interrupted install. With the operator's request, its PID was verified and stopped; `npm ci --no-audit --no-fund` completed in `C:/dev/ISSSTELEON-WebApp-CaMa-Lote1`, the linked WebApp's server was restarted on `51850`, and both `/indicadores/cama` and proxied `/health` returned 200. The Angular development build succeeded. This repairs the local integration environment only; it does not validate the Linux image or port 18080.
+46
View File
@@ -0,0 +1,46 @@
"""Check follow-up reconciliation through an isolated synthetic test proxy."""
import argparse
import json
from urllib.parse import urlencode
from urllib.request import urlopen
def read(base, path, params):
with urlopen(base.rstrip('/') + path + '?' + urlencode(params), timeout=30) as response:
return json.load(response)
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--base', default='http://127.0.0.1:51850')
parser.add_argument('--cutoff', default='2026-11-13')
parser.add_argument('--before-load', default='2026-10-20')
args = parser.parse_args()
aggregate = read(args.base, '/cama/analisis/indicadores', {'corte': args.cutoff})
first = read(args.base, '/cama/seguimiento', {'corte': args.cutoff, 'meses': 3, 'page_size': 2})
assert first['paginacion']['total_items'] >= 5, 'Recent synthetic window is not populated'
context = {key: first[key] for key in ('cohorte', 'escenario', 'revision')}
query = {'corte': args.cutoff, 'meses': 3, **context}
pages = [read(args.base, '/cama/seguimiento', {**query, 'page_size': 2, 'page': page})
for page in range(1, first['paginacion']['total_pages'] + 1)]
rows = [row for page in pages for row in page['items']]
exported = read(args.base, '/cama/seguimiento/exportacion', query)
assert len(rows) == first['paginacion']['total_items'] and exported['items'] == rows
for row in rows:
detail = read(args.base, '/cama/pacientes/' + row['id_seudonimo'], query)
assert detail['item'] == row
group = next(group for group in aggregate['grupos'] if not group['suprimido'])
cohort_query = {'corte': args.cutoff, 'meses': 0, 'birads': group['codigo'],
**{key: aggregate[key] for key in context}}
cohort = read(args.base, '/cama/seguimiento', cohort_query)
cohort_export = read(args.base, '/cama/seguimiento/exportacion', cohort_query)
assert cohort['paginacion']['total_items'] == group['n'] == cohort_export['total_items']
early = read(args.base, '/cama/seguimiento', {'corte': args.before_load, 'meses': 0})
assert early['items'] == [] and early['paginacion']['total_items'] == 0
print('Regular pages, detail and export agree; Analysis group and export agree; pre-load cohort is empty.')
if __name__ == '__main__':
main()