Compare commits

...

6 Commits

Author SHA1 Message Date
rockdrigo f296760c9b Ledgers: G-GEN-1, source terminology as catalog tables, and its implementation; migration heads of the branch (#163)
How: grooming.md gets G-GEN-1 (the proposal, its open questions and the commits that implement layers 1 to 3); AGENTS.md lists the source-terminology revisions on feature/163-source-terminology.

Implications: the issue can cite the branch's commits; the heads in dev are unchanged until it's merged.
2026-11-13 15:59:28 -06:00
angel 285575bfce Merge pull request 'Chore: Updating main with dev new deploy mechanism' (#173) from dev into main
Reviewed-on: #173
2026-11-11 20:57:03 -06:00
angel e7617dd8ea Merge branch 'main' into dev 2026-11-11 20:56:52 -06:00
angel ddbca8e1e2 Actualizar .gitea/workflows/deploy-dev.yml 2026-11-11 10:00:40 -06:00
angel 0da1bb6a8f Actualizar .gitea/workflows/deploy-dev.yml 2026-11-11 09:59:23 -06:00
angel 8ec9c86d10 Merge pull request 'Chore: Update main with dev.' (#170) from dev into main
Reviewed-on: #170
2026-11-10 20:15:40 -06:00
2 changed files with 46 additions and 0 deletions
+3
View File
@@ -144,6 +144,9 @@ 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,3 +293,46 @@ 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.