add import audit trail, live indicator recompute, reportes endpoints; production hardening

This commit is contained in:
Roberto Treviño Cervantes
2026-10-30 11:19:30 -06:00
parent 168edb30f5
commit 2b2c290f58
74 changed files with 4095 additions and 1782 deletions
+6 -19
View File
@@ -3,14 +3,11 @@ Core; system-managed `pac_created_at`/`pac_updated_at`/`pac_fuente_sistema` are
`pac_id` is importable: every other TEA table references the patient by the
source system's integer id, so it has to be kept, not renumbered."""
from datetime import date
from typing import Optional
from pydantic import field_validator
from core.tea.enums import Parentesco, SexoBiologico
from webapi.imports.schemas.base import ImportSchema
from webapi.imports.schemas.coercion import Catalog, CatalogValue, coerce_date, optional_str
from webapi.imports.schemas.coercion import Catalog, CatalogValue, FlexDate, OptionalStr
_SEXO_CATALOG = Catalog(SexoBiologico)
_PARENTESCO_CATALOG = Catalog(Parentesco)
@@ -18,20 +15,10 @@ _PARENTESCO_CATALOG = Catalog(Parentesco)
class PacientesImportSchema(ImportSchema):
pac_id: Optional[int] = None
pac_id_hospital: Optional[str] = None
pac_id_titular: Optional[str] = None
pac_id_hospital: OptionalStr = None
pac_id_titular: OptionalStr = None
pac_parentesco: CatalogValue(_PARENTESCO_CATALOG) = None
pac_fecha_nacimiento: Optional[date] = None
pac_fecha_nacimiento: FlexDate = None
pac_sexo: CatalogValue(_SEXO_CATALOG) = None
pac_codigo_postal_vigente: Optional[str] = None
pac_dependencia: Optional[str] = None
@field_validator("pac_id_hospital", "pac_id_titular", "pac_codigo_postal_vigente", "pac_dependencia", mode="before")
@classmethod
def _optional_str_fields(cls, v):
return optional_str(v)
@field_validator("pac_fecha_nacimiento", mode="before")
@classmethod
def _coerce_fecha_nacimiento(cls, v):
return coerce_date(v)
pac_codigo_postal_vigente: OptionalStr = None
pac_dependencia: OptionalStr = None