CaCu's and CaMa's measures answered on request from dbt's semantic layer as FHIR MeasureReports, with the period and both cut-offs in the question; the route is /<domain>/indicadores

This commit is contained in:
2026-11-08 17:28:24 -06:00
committed by rockdrigo
parent 8f84253205
commit ea228da7b4
42 changed files with 18123 additions and 1338 deletions
+18 -25
View File
@@ -57,19 +57,21 @@ class Base:
return Session(self.motor)
def base_de(proyecto: str, carpeta) -> Base:
def base_de(proyecto: str, carpeta, datos=None) -> Base:
"""A migrated domain database in `carpeta`, with the kit's synthetic staging or, with `datos`, what it inserts."""
url = f"sqlite:///{carpeta / f'{proyecto}.db'}"
apuntar(proyecto, url)
ctx = Contexto(proyecto, ANIO, ANIO, repos=repositorios_de(proyecto))
manifest = os.environ.get("DBT_MANIFEST")
ctx = Contexto(proyecto, ANIO, ANIO, dbt_manifest=Path(manifest) if manifest else None, repos=repositorios_de(proyecto))
correr(ctx, solo=["migrar"])
motor = create_engine(url)
with Session(motor) as sesion:
import_module(f"indicadores_kit.{proyecto}.fixtures").insertar(sesion)
(datos or import_module(f"indicadores_kit.{proyecto}.fixtures").insertar)(sesion)
sesion.commit()
return Base(proyecto, ctx, import_module(f"persistance.{proyecto}"), motor)
@pytest.fixture(params=["cacu", "cama", "tea"])
@pytest.fixture(params=["cacu", "cama"])
def proyecto(request):
return request.param
@@ -136,25 +138,16 @@ MESES = ["2025-01", "2025-02", "2025-03"]
def cliente_de(proyecto: str, tmp_path_factory):
"""Yields a client over a temporary SQLite database seeded with the kit's demonstration data."""
from indicadores_kit.demostracion import base_de_prueba
from persistance import db
from persistance.settings import settings
"""Yields a client over a temporary SQLite database the cycle loaded from the kit's synthetic staging."""
carpeta = tmp_path_factory.mktemp(proyecto)
base = base_de(proyecto, carpeta)
base.correr("catalogos", "cargar", "vistas", "registro", "definiciones", "modelos", permitir_sin_definir=True)
try:
from webapi import create_app
ruta = tmp_path_factory.mktemp(proyecto) / f"{proyecto}.db"
obtener_motor = getattr(db, f"get_{proyecto}_engine")
with pytest.MonkeyPatch.context() as mp:
mp.setattr(settings, f"{proyecto}_database_url", f"sqlite:///{ruta}")
obtener_motor.cache_clear()
try:
base_de_prueba(obtener_motor(), proyecto)
from webapi import create_app
app = create_app()
app.config.update(TESTING=True)
with app.test_client() as cliente:
yield cliente
finally:
obtener_motor().dispose()
obtener_motor.cache_clear()
app = create_app()
app.config.update(TESTING=True)
with app.test_client() as cliente:
yield cliente
finally:
base.motor.dispose()