-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_model.py
More file actions
63 lines (40 loc) · 1.52 KB
/
Copy pathapi_model.py
File metadata and controls
63 lines (40 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""API models for API server."""
from uuid import UUID
from pydantic import BaseModel
from api_server.models.base_model import AddressBase, PatientBase
from api_server.utils.model_builder import create_model
# Patient API response model - create base version first
PatientResponseBase = create_model(base_model=PatientBase, name="PatientResponseBase", all_fields=True)
# Add the age computed field to PatientResponse
class PatientResponse(PatientResponseBase):
# Include the age computed field from PatientBase
age: int | None = None
# Address API response model
AddressResponse = create_model(base_model=AddressBase, name="AddressResponse", all_fields=True)
# Patient input model (excludes id field)
PatientInput = create_model(
base_model=PatientBase,
name="PatientInput",
excluded_fields=["id"],
api_model=True,
)
# Address input model (excludes id field)
AddressInput = create_model(
base_model=AddressBase,
name="AddressInput",
excluded_fields=["id"],
api_model=True,
)
# Patient create input (includes address)
class PatientCreateInput(PatientInput):
addresses: list[AddressInput]
# Patient create response (includes address)
class PatientCreateResponse(PatientResponse):
addresses: list[AddressResponse] = []
# Address create input model
AddressCreateInput = AddressInput
# Address create response model
AddressCreateResponse = AddressResponse
class PrimaryAddressUpdate(BaseModel):
"""Request body for updating a patient's primary address."""
address_id: UUID | None = None