e2ecaa027c
webapi/fhir/risk.py builds a patient's RiskAssessment for CaCu and CaMa; GET /cama/modelo/curvas serves the production version's survival curves; the cycle's estimator is generic by scenario; silver persona carries the date of death for CaMa; the import schema accepts it; the CaMa risk batches can be confirmed and voided.
34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
"""Import schema for `core.cama.models.Paciente`."""
|
|
from typing import Optional
|
|
|
|
from core.cama.enums import DEPENDENCIA_ALIAS, Dependencia, PARENTESCO_ALIAS, Parentesco, SEXO_BIOLOGICO_ALIAS, SexoBiologico
|
|
from webapi.imports.schemas.base import ImportSchema
|
|
from webapi.imports.schemas.coercion import (
|
|
Catalog,
|
|
CatalogValue,
|
|
FlexDate,
|
|
PostalCode,
|
|
RequiredDate,
|
|
RequiredHospitalId,
|
|
)
|
|
|
|
# Dependencia/Parentesco: Core marks both catalogs as tentative.
|
|
_DEPENDENCIA_CATALOG = Catalog(Dependencia, DEPENDENCIA_ALIAS, strict=False)
|
|
_PARENTESCO_CATALOG = Catalog(Parentesco, PARENTESCO_ALIAS, strict=False)
|
|
_SEXO_BIOLOGICO_CATALOG = Catalog(SexoBiologico, SEXO_BIOLOGICO_ALIAS)
|
|
|
|
|
|
class PacienteImportSchema(ImportSchema):
|
|
# The source's own id, kept so rows that reference it by id (not by a
|
|
# natural key) still point at this record.
|
|
pac_id: Optional[int] = None
|
|
pac_id_hospital: RequiredHospitalId
|
|
pac_sexo: CatalogValue(_SEXO_BIOLOGICO_CATALOG) = None
|
|
# IND-01: required, since age at each event of interest is derived from it.
|
|
pac_fecha_nacimiento: RequiredDate
|
|
# Survival's outcome; empty while she is alive or the date is unknown.
|
|
pac_fecha_defuncion: FlexDate = None
|
|
pac_codigo_postal: PostalCode = None
|
|
pac_dependencia: CatalogValue(_DEPENDENCIA_CATALOG) = None
|
|
pac_parentesco: CatalogValue(_PARENTESCO_CATALOG) = None
|