28 lines
920 B
Python
28 lines
920 B
Python
"""Import schema for `core.tea.models.EvaluacionNeuropediatrica`: the note and its ICD-10 diagnosis."""
|
|
from typing import Annotated, Optional
|
|
|
|
from pydantic import BeforeValidator, StringConstraints
|
|
|
|
from webapi.imports.schemas.base import ImportSchema
|
|
from webapi.imports.schemas.coercion import FlexDate, OptionalStr, SourceId, optional_str
|
|
|
|
|
|
def _upper(v):
|
|
v = optional_str(v)
|
|
return v.strip().upper() if isinstance(v, str) else v
|
|
|
|
|
|
# A letter, two digits and optionally a dot with one or two more (F84.0); the dot may be missing (F840).
|
|
_CIE10 = Annotated[
|
|
Optional[Annotated[str, StringConstraints(pattern=r"^[A-Z][0-9]{2}(\.?[0-9]{1,2})?$")]],
|
|
BeforeValidator(_upper),
|
|
]
|
|
|
|
|
|
class EvaluacionNeuropediatricaImportSchema(ImportSchema):
|
|
neu_id: SourceId = None
|
|
neu_pac_id: Optional[int] = None
|
|
neu_ord_id: OptionalStr = None
|
|
neu_fecha: FlexDate = None
|
|
neu_cie_codigo: _CIE10 = None
|