The catalog step seeds each domain's mappings, and a mapping is written only if the function still holds

How: `catalog_rows` turns the TOML's study codes, captions and each value's code, label and aliases into the
`catalogo` system's rows; the `catalogs` step adds the system and the forms with no row yet
(`mapeos_nuevos`). `register` normalizes the form and adds the row through `SourceMappingRepository.add`
with `check_stored`, which runs `check_function` on the stored rows of the same form; captions aren't
checked, since one caption may introduce several results. `ctx.repos.silver.mappings` is the domain's
repository.

Implications: the database keeps every mapping across deploys; a person's change is never overwritten, and
a second code for a form in force is refused before it's written. Loads still read the TOML's aliases.
This commit is contained in:
rockdrigo
2026-11-13 15:31:21 -06:00
parent 64d3d721e3
commit 73cbf0cfb8
5 changed files with 138 additions and 11 deletions
+3
View File
@@ -21,6 +21,7 @@ from persistance.edges.silver import (
ObservationRepository,
TimelineRepository,
LinksRepository,
SourceMappingRepository,
ViewsRepository,
)
from persistance.materializer import Materializer
@@ -43,6 +44,7 @@ class Silver:
observation: ObservationRepository
links: LinksRepository
timeline: TimelineRepository | None = None # the patients' timeline: dbt's view, as the models and the strata read it
mappings: SourceMappingRepository | None = None # how each source writes the catalog's codes
@dataclass(frozen=True)
@@ -80,6 +82,7 @@ def repositories_of(proyecto: str) -> Repositories:
observation=dominio.observation_period_repository,
links=dominio.links_repository,
timeline=dominio.timeline_repository,
mappings=dominio.source_mapping_repository,
),
materializer=dominio.materializer,
gold=Gold(