TEA on its new staging: silver load, ten measures answered on request with the status at the period's end, several groups and column strata, and FHIR R4 endpoints for measures, follow-up and patient summary

This commit is contained in:
2026-11-12 15:21:25 -06:00
parent c430a5bd11
commit a0407e41d6
55 changed files with 2609 additions and 790 deletions
+11 -3
View File
@@ -25,8 +25,9 @@ def event_views(manifest: Path, project: str) -> list:
"""`drop view if exists` and `create view … as <compiled SQL>` for every model the project's measures read,
parents first.
Those are the project's models semantic models count over (`models/<project>/…`) and the timelines its strata
read (`meta.estratos.*.linea`), with the non-ephemeral models they're built on; an ephemeral one is already inlined
Those are the project's models semantic models count over (`models/<project>/…`), the timelines its strata
read (`meta.estratos.*.linea`) and the views the WebApi reads (`meta.lee_la_webapi`), with the non-ephemeral
models they're built on; an ephemeral one is already inlined
in its child's compiled SQL. Another domain's models aren't created: their tables may not exist here.
"""
m = json.loads(manifest.read_text(encoding="utf-8"))
@@ -37,6 +38,9 @@ def event_views(manifest: Path, project: str) -> list:
roots |= {by_name[spec["linea"]] for metric in m["metrics"].values()
if metric["config"].get("meta", {}).get("measure_url", "").startswith(f"{project}/")
for spec in metric["config"]["meta"].get("estratos", {}).values() if "linea" in spec}
# The views the WebApi reads directly (a follow-up list, a patient summary).
roots |= {uid for uid, n in nodes.items() if n["resource_type"] == "model" and n["fqn"][1] == project
and n["config"].get("meta", {}).get("lee_la_webapi")}
ordered: list[str] = []
def visit(uid: str) -> None:
@@ -69,10 +73,14 @@ def catalog_layers(project: str, manifest: Path) -> list[list]:
contract = CONTRACTS[scoring_of(d)]
measures.append(t.CatMeasure(measure_id=d.measure_id, url=d.url, version=d.version, titulo=labels[d.metric],
contrato=contract, unidad=d.basis))
codes = dict.fromkeys((*d.denominator.codes, *d.numerator.codes, *((OBSERVATION,) if contract == "C3r" else ())))
exclusion = getattr(d, "exclusion", None)
codes = dict.fromkeys((*d.denominator.codes, *d.numerator.codes, *((OBSERVATION,) if contract == "C3r" else ()),
*(exclusion.codes if exclusion else ())))
children += [t.CatMeasureResultado(resultado_id=f"{d.measure_id}.{c}", measure_id=d.measure_id, poblacion=c,
etiqueta=c) for c in codes]
children.append(t.CatMeasureGrupo(measure_id=d.measure_id, grupo=d.group, etiqueta=d.group, orden=0))
children += [t.CatMeasureGrupo(measure_id=d.measure_id, grupo=g.name, etiqueta=g.label, orden=i)
for i, g in enumerate(getattr(d, "groups", ()), 1)]
children += [t.CatMeasureEstrato(measure_id=d.measure_id, estrato_id=s.name) for s in d.strata]
stratum_rows = [t.CatEstrato(estrato_id=s, etiqueta=labels_of[s], unidad="paciente") for s in strata]
return [stratum_rows + measures, children]