CaCu import: a patient's date of death
`pac_fecha_defuncion` was dropped on import, so `persona.fecha_defuncion` and the timeline's `defuncion` fact were always empty in CaCu and the survival scenario trained with no deaths. CaMa's schema already carried it.
This commit is contained in:
@@ -43,6 +43,18 @@ def test_paciente_schema_coerces_date_from_datetime_object():
|
||||
assert schema.pac_fecha_nacimiento.isoformat() == "2020-01-15"
|
||||
|
||||
|
||||
def test_cacu_paciente_keeps_her_date_of_death():
|
||||
"""Pins down: a CaCu patient's `pac_fecha_defuncion` is imported (the survival scenario's outcome), and an alive
|
||||
patient has none. Fails if the schema drops the column again: every CaCu death would be lost on import and the
|
||||
survival model would train with no deaths."""
|
||||
from datetime import date
|
||||
|
||||
dead = PacienteImportSchema(pac_id_hospital="H-1", pac_fecha_nacimiento="1960-03-01", pac_fecha_defuncion="2025-07-09")
|
||||
alive = PacienteImportSchema(pac_id_hospital="H-2", pac_fecha_nacimiento="1960-03-01")
|
||||
|
||||
assert dead.pac_fecha_defuncion == date(2025, 7, 9) and alive.pac_fecha_defuncion is None
|
||||
|
||||
|
||||
def test_tea_pacientes_schema_is_fully_optional():
|
||||
schema = PacientesImportSchema()
|
||||
assert schema.pac_id_hospital is None
|
||||
|
||||
@@ -6,6 +6,7 @@ from webapi.imports.schemas.base import ImportSchema
|
||||
from webapi.imports.schemas.coercion import (
|
||||
Catalog,
|
||||
CatalogValue,
|
||||
FlexDate,
|
||||
PostalCode,
|
||||
RequiredDate,
|
||||
RequiredHospitalId,
|
||||
@@ -25,6 +26,8 @@ class PacienteImportSchema(ImportSchema):
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user