2021-09-27 23:45:22 +08:00
|
|
|
from datetime import datetime
|
2021-02-27 19:24:39 +08:00
|
|
|
from typing import Optional
|
2021-01-06 19:52:14 +08:00
|
|
|
|
2023-04-10 20:23:31 +08:00
|
|
|
from apps.common.schemas import BaseAuditModel
|
|
|
|
from core.uid_gen import FelicityIDType
|
2022-01-23 07:15:53 +08:00
|
|
|
from pydantic import EmailStr
|
2021-01-06 19:52:14 +08:00
|
|
|
|
2022-01-10 00:00:14 +08:00
|
|
|
#
|
2021-01-06 19:52:14 +08:00
|
|
|
# Patient Schema
|
2022-01-10 00:00:14 +08:00
|
|
|
#
|
2021-01-06 19:52:14 +08:00
|
|
|
|
|
|
|
# Shared properties
|
2022-01-23 07:15:53 +08:00
|
|
|
|
|
|
|
|
|
|
|
class PatientBase(BaseAuditModel):
|
2021-01-06 19:52:14 +08:00
|
|
|
client_patient_id: Optional[str] = None
|
2023-03-19 23:21:32 +08:00
|
|
|
client_uid: Optional[FelicityIDType] = None
|
2021-01-06 19:52:14 +08:00
|
|
|
patient_id: Optional[str] = None
|
|
|
|
first_name: Optional[str] = None
|
|
|
|
middle_name: Optional[str] = None
|
2022-01-10 00:00:14 +08:00
|
|
|
last_name: Optional[str] = None
|
2022-04-24 14:05:10 +08:00
|
|
|
gender: Optional[str] = None
|
2021-01-06 19:52:14 +08:00
|
|
|
age: Optional[int] = None
|
2021-09-27 23:45:22 +08:00
|
|
|
date_of_birth: Optional[datetime] = None
|
2021-01-06 19:52:14 +08:00
|
|
|
age_dob_estimated: Optional[bool] = None
|
|
|
|
phone_mobile: Optional[str] = None
|
|
|
|
phone_home: Optional[str] = None
|
|
|
|
consent_sms: Optional[bool] = None
|
|
|
|
email: Optional[EmailStr] = None
|
2021-05-30 22:32:13 +08:00
|
|
|
internal_use: Optional[bool] = False
|
2022-01-10 00:00:14 +08:00
|
|
|
active: Optional[bool] = None
|
2023-04-09 21:13:46 +08:00
|
|
|
district_uid: Optional[FelicityIDType] = None
|
|
|
|
province_uid: Optional[FelicityIDType] = None
|
|
|
|
country_uid: Optional[FelicityIDType] = None
|
2021-01-06 19:52:14 +08:00
|
|
|
|
|
|
|
|
|
|
|
# Properties to receive via API on creation
|
|
|
|
class PatientCreate(PatientBase):
|
2021-01-25 01:23:08 +08:00
|
|
|
client_patient_id: str
|
|
|
|
first_name: str
|
|
|
|
last_name: str
|
2023-03-19 23:21:32 +08:00
|
|
|
client_uid: FelicityIDType
|
2021-01-06 19:52:14 +08:00
|
|
|
active: bool = True
|
|
|
|
|
|
|
|
|
|
|
|
# Properties to receive via API on update
|
|
|
|
class PatientUpdate(PatientBase):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class PatientInDBBase(PatientBase):
|
2023-03-19 23:21:32 +08:00
|
|
|
uid: Optional[FelicityIDType] = None
|
2021-01-06 19:52:14 +08:00
|
|
|
|
|
|
|
class Config:
|
|
|
|
orm_mode = True
|
|
|
|
|
|
|
|
|
|
|
|
# Additional properties to return via API
|
|
|
|
class Patient(PatientInDBBase):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
# Additional properties stored in DB
|
|
|
|
class PatientInDB(PatientInDBBase):
|
2022-01-10 00:00:14 +08:00
|
|
|
pass
|
2023-04-09 21:13:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Identification Schema
|
|
|
|
#
|
|
|
|
|
|
|
|
# Shared properties
|
|
|
|
|
|
|
|
|
|
|
|
class IdentificationBase(BaseAuditModel):
|
|
|
|
name: str
|
|
|
|
|
|
|
|
|
|
|
|
# Properties to receive via API on creation
|
|
|
|
class IdentificationCreate(IdentificationBase):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
# Properties to receive via API on update
|
|
|
|
class IdentificationUpdate(IdentificationBase):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class IdentificationInDBBase(IdentificationBase):
|
|
|
|
uid: Optional[FelicityIDType] = None
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
orm_mode = True
|
|
|
|
|
|
|
|
|
|
|
|
# Additional properties to return via API
|
|
|
|
class Identification(IdentificationInDBBase):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
# Additional properties stored in DB
|
|
|
|
class IdentificationInDB(IdentificationInDBBase):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# PatientIdentification Schema
|
|
|
|
#
|
|
|
|
|
|
|
|
# Shared properties
|
|
|
|
|
|
|
|
|
|
|
|
class PatientIdentificationBase(BaseAuditModel):
|
|
|
|
patient_uid: str
|
|
|
|
identification_uid: str
|
|
|
|
value: str
|
|
|
|
|
|
|
|
|
|
|
|
# Properties to receive via API on creation
|
|
|
|
class PatientIdentificationCreate(PatientIdentificationBase):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
# Properties to receive via API on update
|
|
|
|
class PatientIdentificationUpdate(PatientIdentificationBase):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class PatientIdentificationInDBBase(PatientIdentificationBase):
|
|
|
|
uid: Optional[FelicityIDType] = None
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
orm_mode = True
|
|
|
|
|
|
|
|
|
|
|
|
# Additional properties to return via API
|
|
|
|
class PatientIdentification(PatientIdentificationInDBBase):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
# Additional properties stored in DB
|
|
|
|
class PatientIdentificationInDB(PatientIdentificationInDBBase):
|
|
|
|
pass
|