maleo-identity 0.1.11__py3-none-any.whl → 0.1.24__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. maleo/identity/constants/api_key.py +2 -2
  2. maleo/identity/constants/organization.py +1 -1
  3. maleo/identity/constants/organization_registration_code.py +2 -2
  4. maleo/identity/constants/organization_relation.py +2 -2
  5. maleo/identity/constants/patient.py +1 -1
  6. maleo/identity/constants/user.py +1 -1
  7. maleo/identity/constants/user_medical_role.py +2 -2
  8. maleo/identity/constants/user_organization_role.py +2 -2
  9. maleo/identity/constants/user_profile.py +1 -1
  10. maleo/identity/constants/user_system_role.py +6 -2
  11. maleo/identity/enums/api_key.py +13 -1
  12. maleo/identity/enums/organization.py +4 -0
  13. maleo/identity/enums/organization_registration_code.py +4 -0
  14. maleo/identity/enums/organization_relation.py +11 -1
  15. maleo/identity/enums/patient.py +18 -2
  16. maleo/identity/enums/user.py +4 -0
  17. maleo/identity/enums/user_medical_role.py +11 -1
  18. maleo/identity/enums/user_organization_role.py +11 -1
  19. maleo/identity/enums/user_profile.py +4 -0
  20. maleo/identity/enums/user_system_role.py +24 -1
  21. maleo/identity/mixins/api_key.py +9 -4
  22. maleo/identity/mixins/organization.py +3 -1
  23. maleo/identity/mixins/organization_registration_code.py +40 -4
  24. maleo/identity/mixins/organization_relation.py +9 -4
  25. maleo/identity/mixins/patient.py +13 -44
  26. maleo/identity/mixins/user.py +3 -1
  27. maleo/identity/mixins/user_medical_role.py +9 -4
  28. maleo/identity/mixins/user_organization_role.py +9 -4
  29. maleo/identity/mixins/user_profile.py +3 -1
  30. maleo/identity/mixins/user_system_role.py +17 -6
  31. maleo/identity/schemas/api_key.py +21 -4
  32. maleo/identity/schemas/common.py +38 -24
  33. maleo/identity/schemas/organization.py +26 -0
  34. maleo/identity/schemas/organization_registration_code.py +19 -2
  35. maleo/identity/schemas/organization_relation.py +23 -5
  36. maleo/identity/schemas/patient.py +56 -31
  37. maleo/identity/schemas/user.py +23 -0
  38. maleo/identity/schemas/user_medical_role.py +25 -6
  39. maleo/identity/schemas/user_organization_role.py +25 -6
  40. maleo/identity/schemas/user_profile.py +33 -1
  41. maleo/identity/schemas/user_system_role.py +52 -11
  42. maleo/identity/types/api_key.py +2 -2
  43. maleo/identity/types/organization_relation.py +2 -2
  44. maleo/identity/types/patient.py +1 -1
  45. maleo/identity/types/user_medical_role.py +2 -2
  46. maleo/identity/types/user_organization_role.py +2 -2
  47. maleo/identity/types/user_system_role.py +3 -2
  48. {maleo_identity-0.1.11.dist-info → maleo_identity-0.1.24.dist-info}/METADATA +6 -5
  49. maleo_identity-0.1.24.dist-info/RECORD +66 -0
  50. maleo/identity/models.py +0 -337
  51. maleo_identity-0.1.11.dist-info/RECORD +0 -67
  52. {maleo_identity-0.1.11.dist-info → maleo_identity-0.1.24.dist-info}/WHEEL +0 -0
  53. {maleo_identity-0.1.11.dist-info → maleo_identity-0.1.24.dist-info}/licenses/LICENSE +0 -0
  54. {maleo_identity-0.1.11.dist-info → maleo_identity-0.1.24.dist-info}/top_level.txt +0 -0
@@ -1,13 +1,24 @@
1
- from pydantic import Field
1
+ from pydantic import BaseModel, Field
2
2
  from typing import Annotated, Literal, TypeGuard
3
3
  from uuid import UUID
4
4
  from maleo.schemas.mixins.identity import Identifier
5
- from ..enums.user_system_role import IdentifierType
6
- from ..types.user_system_role import CompositeIdentifier, IdentifierValueType
5
+ from maleo.types.any import ManyAny
6
+ from maleo.types.string import ManyStrs
7
+ from ..enums.user_system_role import IdentifierType, OptListOfExpandableFields
8
+ from ..types.user_system_role import CompositeIdentifierType, IdentifierValueType
9
+
10
+
11
+ class Expand(BaseModel):
12
+ expand: Annotated[
13
+ OptListOfExpandableFields, Field(None, description="Expanded field(s)")
14
+ ] = None
7
15
 
8
16
 
9
17
  class UserSystemRoleIdentifier(Identifier[IdentifierType, IdentifierValueType]):
10
- pass
18
+ @property
19
+ def columns_and_values(self) -> tuple[ManyStrs, ManyAny]:
20
+ values = self.value if isinstance(self.value, tuple) else (self.value,)
21
+ return self.type.columns, values
11
22
 
12
23
 
13
24
  class IdUserSystemRoleIdentifier(Identifier[Literal[IdentifierType.ID], int]):
@@ -26,13 +37,13 @@ class UUIDUserSystemRoleIdentifier(Identifier[Literal[IdentifierType.UUID], UUID
26
37
 
27
38
 
28
39
  class CompositeUserSystemRoleIdentifier(
29
- Identifier[Literal[IdentifierType.COMPOSITE], CompositeIdentifier]
40
+ Identifier[Literal[IdentifierType.COMPOSITE], CompositeIdentifierType]
30
41
  ):
31
42
  type: Annotated[
32
43
  Literal[IdentifierType.COMPOSITE],
33
44
  Field(IdentifierType.COMPOSITE, description="Identifier's type"),
34
45
  ] = IdentifierType.COMPOSITE
35
- value: Annotated[CompositeIdentifier, Field(..., description="Identifier's value")]
46
+ value: Annotated[CompositeIdentifierType, Field(..., description="Identifier's value")]
36
47
 
37
48
 
38
49
  AnyUserSystemRoleIdentifier = (
@@ -1,4 +1,5 @@
1
- from typing import Literal, overload
1
+ from pydantic import Field
2
+ from typing import Annotated, Literal, overload
2
3
  from uuid import UUID
3
4
  from maleo.enums.status import (
4
5
  ListOfDataStatuses,
@@ -24,7 +25,7 @@ from maleo.types.integer import OptInt, OptListOfInts
24
25
  from maleo.types.uuid import OptListOfUUIDs
25
26
  from ..enums.api_key import IdentifierType
26
27
  from ..mixins.api_key import APIKeyIdentifier
27
- from ..types.api_key import CompositeIdentifier, IdentifierValueType
28
+ from ..types.api_key import CompositeIdentifierType, IdentifierValueType
28
29
 
29
30
 
30
31
  class CreateParameter(
@@ -41,6 +42,13 @@ class ReadMultipleParameter(
41
42
  UUIDs[OptListOfUUIDs],
42
43
  Ids[OptListOfInts],
43
44
  ):
45
+ ids: Annotated[OptListOfInts, Field(None, description="Ids")] = None
46
+ uuids: Annotated[OptListOfUUIDs, Field(None, description="UUIDs")] = None
47
+ user_ids: Annotated[OptListOfInts, Field(None, description="User's IDs")] = None
48
+ organization_ids: Annotated[
49
+ OptListOfInts, Field(None, description="Organization's IDs")
50
+ ] = None
51
+
44
52
  @property
45
53
  def _query_param_fields(self) -> set[str]:
46
54
  return {
@@ -66,6 +74,15 @@ class ReadMultipleParameter(
66
74
 
67
75
 
68
76
  class ReadSingleParameter(BaseReadSingleParameter[APIKeyIdentifier]):
77
+ @classmethod
78
+ def from_identifier(
79
+ cls,
80
+ identifier: APIKeyIdentifier,
81
+ statuses: ListOfDataStatuses = FULL_DATA_STATUSES,
82
+ use_cache: bool = True,
83
+ ) -> "ReadSingleParameter":
84
+ return cls(identifier=identifier, statuses=statuses, use_cache=use_cache)
85
+
69
86
  @overload
70
87
  @classmethod
71
88
  def new(
@@ -89,7 +106,7 @@ class ReadSingleParameter(BaseReadSingleParameter[APIKeyIdentifier]):
89
106
  def new(
90
107
  cls,
91
108
  identifier_type: Literal[IdentifierType.COMPOSITE],
92
- identifier_value: CompositeIdentifier,
109
+ identifier_value: CompositeIdentifierType,
93
110
  statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
94
111
  use_cache: bool = True,
95
112
  ) -> "ReadSingleParameter": ...
@@ -138,7 +155,7 @@ class DeleteSingleParameter(BaseDeleteSingleParameter[APIKeyIdentifier]):
138
155
  def new(
139
156
  cls,
140
157
  identifier_type: Literal[IdentifierType.COMPOSITE],
141
- identifier_value: CompositeIdentifier,
158
+ identifier_value: CompositeIdentifierType,
142
159
  ) -> "DeleteSingleParameter": ...
143
160
  @overload
144
161
  @classmethod
@@ -1,25 +1,37 @@
1
1
  from datetime import date
2
2
  from pydantic import BaseModel, Field
3
3
  from typing import Annotated, Generic, TypeVar, Type
4
- from maleo.enums.identity import (
5
- OptBloodType,
6
- BloodTypeMixin,
7
- OptRhesus,
8
- RhesusMixin,
9
- Gender,
10
- OptGender,
11
- GenderMixin,
4
+ from maleo.enums.identity import OptRhesus, RhesusMixin
5
+ from maleo.enums.status import DataStatus as DataStatusEnum, SimpleDataStatusMixin
6
+ from maleo.metadata.schemas.blood_type import (
7
+ OptKeyOrStandardSchema as BloodTypeOptKeyOrStandardSchema,
8
+ FullBloodTypeMixin,
9
+ )
10
+ from maleo.metadata.schemas.gender import (
11
+ OptKeyOrStandardSchema as GenderOptKeyOrStandardSchema,
12
+ KeyOrStandardSchema as GenderKeyOrStandardSchema,
13
+ FullGenderMixin,
14
+ )
15
+ from maleo.metadata.schemas.medical_role import (
16
+ KeyOrStandardSchema as MedicalRoleKeyOrStandardSchema,
17
+ FullMedicalRoleMixin,
12
18
  )
13
- from maleo.enums.medical import MedicalRole, FullMedicalRoleMixin
14
- from maleo.enums.organization import (
15
- OrganizationRole,
19
+ from maleo.metadata.schemas.organization_role import (
20
+ KeyOrStandardSchema as OrganizationRoleKeyOrStandardSchema,
16
21
  FullOrganizationRoleMixin,
17
- OrganizationType,
22
+ )
23
+ from maleo.metadata.schemas.organization_type import (
24
+ KeyOrStandardSchema as OrganizationTypeKeyOrStandardSchema,
18
25
  FullOrganizationTypeMixin,
19
26
  )
20
- from maleo.enums.status import DataStatus as DataStatusEnum, SimpleDataStatusMixin
21
- from maleo.enums.system import SystemRole, FullSystemRoleMixin
22
- from maleo.enums.user import UserType, FullUserTypeMixin
27
+ from maleo.metadata.schemas.system_role import (
28
+ KeyOrStandardSchema as SystemRoleKeyOrStandardSchema,
29
+ FullSystemRoleMixin,
30
+ )
31
+ from maleo.metadata.schemas.user_type import (
32
+ KeyOrStandardSchema as UserTypeKeyOrStandardSchema,
33
+ FullUserTypeMixin,
34
+ )
23
35
  from maleo.schemas.mixins.identity import (
24
36
  DataIdentifier,
25
37
  IntOrganizationId,
@@ -62,12 +74,14 @@ class APIKeySchema(
62
74
 
63
75
  class PatientSchema(
64
76
  RhesusMixin[OptRhesus],
65
- BloodTypeMixin[OptBloodType],
66
- GenderMixin[Gender],
77
+ FullBloodTypeMixin[BloodTypeOptKeyOrStandardSchema],
78
+ FullGenderMixin[GenderKeyOrStandardSchema],
67
79
  DateOfBirth[date],
68
80
  PlaceOfBirth[OptStr],
69
81
  FullName[str],
70
82
  PatientIdentity,
83
+ IntOrganizationId[int],
84
+ IntUserId[int],
71
85
  SimpleDataStatusMixin[DataStatusEnum],
72
86
  LifecycleTimestamp,
73
87
  DataIdentifier,
@@ -99,7 +113,7 @@ class OrganizationRegistrationCodeSchemaMixin(BaseModel):
99
113
  class StandardOrganizationSchema(
100
114
  OrganizationName[str],
101
115
  OrganizationKey[str],
102
- FullOrganizationTypeMixin[OrganizationType],
116
+ FullOrganizationTypeMixin[OrganizationTypeKeyOrStandardSchema],
103
117
  SimpleDataStatusMixin[DataStatusEnum],
104
118
  LifecycleTimestamp,
105
119
  DataIdentifier,
@@ -178,7 +192,7 @@ class OrganizationSchemaMixin(BaseModel, Generic[AnyOrganizationSchemaT]):
178
192
 
179
193
 
180
194
  class UserMedicalRoleSchema(
181
- FullMedicalRoleMixin[MedicalRole],
195
+ FullMedicalRoleMixin[MedicalRoleKeyOrStandardSchema],
182
196
  IntOrganizationId[int],
183
197
  IntUserId[int],
184
198
  SimpleDataStatusMixin[DataStatusEnum],
@@ -196,7 +210,7 @@ class UserMedicalRolesSchemaMixin(BaseModel):
196
210
 
197
211
 
198
212
  class UserOrganizationRoleSchema(
199
- FullOrganizationRoleMixin[OrganizationRole],
213
+ FullOrganizationRoleMixin[OrganizationRoleKeyOrStandardSchema],
200
214
  IntOrganizationId[int],
201
215
  IntUserId[int],
202
216
  SimpleDataStatusMixin[DataStatusEnum],
@@ -216,8 +230,8 @@ class UserOrganizationRolesSchemaMixin(BaseModel):
216
230
  class UserProfileSchema(
217
231
  AvatarUrl[OptStr],
218
232
  AvatarName[str],
219
- BloodTypeMixin[OptBloodType],
220
- GenderMixin[OptGender],
233
+ FullBloodTypeMixin[BloodTypeOptKeyOrStandardSchema],
234
+ FullGenderMixin[GenderOptKeyOrStandardSchema],
221
235
  BirthDate[OptDate],
222
236
  BirthPlace[OptStr],
223
237
  FullName[str],
@@ -245,7 +259,7 @@ class UserProfileSchemaMixin(BaseModel):
245
259
 
246
260
 
247
261
  class UserSystemRoleSchema(
248
- FullSystemRoleMixin[SystemRole],
262
+ FullSystemRoleMixin[SystemRoleKeyOrStandardSchema],
249
263
  IntUserId[int],
250
264
  SimpleDataStatusMixin[DataStatusEnum],
251
265
  LifecycleTimestamp,
@@ -270,7 +284,7 @@ class StandardUserSchema(
270
284
  Phone[str],
271
285
  Email[str],
272
286
  Username[str],
273
- FullUserTypeMixin[UserType],
287
+ FullUserTypeMixin[UserTypeKeyOrStandardSchema],
274
288
  SimpleDataStatusMixin[DataStatusEnum],
275
289
  LifecycleTimestamp,
276
290
  DataIdentifier,
@@ -57,6 +57,14 @@ class ReadMultipleParameter(
57
57
  UUIDs[OptListOfUUIDs],
58
58
  Ids[OptListOfInts],
59
59
  ):
60
+ ids: Annotated[OptListOfInts, Field(None, description="Ids")] = None
61
+ uuids: Annotated[OptListOfUUIDs, Field(None, description="UUIDs")] = None
62
+ organization_types: Annotated[
63
+ OptListOfOrganizationTypes, Field(None, description="Organization Types")
64
+ ] = None
65
+ keys: Annotated[OptListOfStrs, Field(None, description="Keys")] = None
66
+ names: Annotated[OptListOfStrs, Field(None, description="Names")] = None
67
+
60
68
  @property
61
69
  def _query_param_fields(self) -> set[str]:
62
70
  return {
@@ -83,6 +91,15 @@ class ReadMultipleParameter(
83
91
 
84
92
 
85
93
  class ReadSingleParameter(BaseReadSingleParameter[OrganizationIdentifier]):
94
+ @classmethod
95
+ def from_identifier(
96
+ cls,
97
+ identifier: OrganizationIdentifier,
98
+ statuses: ListOfDataStatuses = FULL_DATA_STATUSES,
99
+ use_cache: bool = True,
100
+ ) -> "ReadSingleParameter":
101
+ return cls(identifier=identifier, statuses=statuses, use_cache=use_cache)
102
+
86
103
  @overload
87
104
  @classmethod
88
105
  def new(
@@ -110,6 +127,15 @@ class ReadSingleParameter(BaseReadSingleParameter[OrganizationIdentifier]):
110
127
  statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
111
128
  use_cache: bool = True,
112
129
  ) -> "ReadSingleParameter": ...
130
+ @overload
131
+ @classmethod
132
+ def new(
133
+ cls,
134
+ identifier_type: IdentifierType,
135
+ identifier_value: IdentifierValueType,
136
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
137
+ use_cache: bool = True,
138
+ ) -> "ReadSingleParameter": ...
113
139
  @classmethod
114
140
  def new(
115
141
  cls,
@@ -1,5 +1,5 @@
1
1
  from pydantic import BaseModel, Field
2
- from typing import Generic, Literal, TypeVar, overload
2
+ from typing import Annotated, Generic, Literal, TypeVar, overload
3
3
  from uuid import UUID
4
4
  from maleo.enums.status import (
5
5
  ListOfDataStatuses,
@@ -28,6 +28,7 @@ from maleo.types.string import OptStr, OptListOfStrs
28
28
  from maleo.types.uuid import OptListOfUUIDs
29
29
  from ..enums.organization_registration_code import IdentifierType
30
30
  from ..mixins.organization_registration_code import (
31
+ CodeOrLength,
31
32
  Code,
32
33
  MaxUses,
33
34
  OrganizationRegistrationCodeIdentifier,
@@ -35,7 +36,7 @@ from ..mixins.organization_registration_code import (
35
36
  from ..types.organization_registration_code import IdentifierValueType
36
37
 
37
38
 
38
- class StandardCreateData(Code[OptStr]):
39
+ class StandardCreateData(CodeOrLength):
39
40
  pass
40
41
 
41
42
 
@@ -57,6 +58,13 @@ class ReadMultipleParameter(
57
58
  UUIDs[OptListOfUUIDs],
58
59
  Ids[OptListOfInts],
59
60
  ):
61
+ ids: Annotated[OptListOfInts, Field(None, description="Ids")] = None
62
+ uuids: Annotated[OptListOfUUIDs, Field(None, description="UUIDs")] = None
63
+ organization_ids: Annotated[
64
+ OptListOfInts, Field(None, description="Organization's IDs")
65
+ ] = None
66
+ codes: Annotated[OptListOfStrs, Field(None, description="Codes")] = None
67
+
60
68
  @property
61
69
  def _query_param_fields(self) -> set[str]:
62
70
  return {
@@ -84,6 +92,15 @@ class ReadMultipleParameter(
84
92
  class ReadSingleParameter(
85
93
  BaseReadSingleParameter[OrganizationRegistrationCodeIdentifier]
86
94
  ):
95
+ @classmethod
96
+ def from_identifier(
97
+ cls,
98
+ identifier: OrganizationRegistrationCodeIdentifier,
99
+ statuses: ListOfDataStatuses = FULL_DATA_STATUSES,
100
+ use_cache: bool = True,
101
+ ) -> "ReadSingleParameter":
102
+ return cls(identifier=identifier, statuses=statuses, use_cache=use_cache)
103
+
87
104
  @overload
88
105
  @classmethod
89
106
  def new(
@@ -39,7 +39,7 @@ from ..mixins.organization_relation import (
39
39
  Meta,
40
40
  OrganizationRelationIdentifier,
41
41
  )
42
- from ..types.organization_relation import CompositeIdentifier, IdentifierValueType
42
+ from ..types.organization_relation import CompositeIdentifierType, IdentifierValueType
43
43
 
44
44
 
45
45
  class CreateParameter(
@@ -62,6 +62,15 @@ class ReadMultipleParameter(
62
62
  UUIDs[OptListOfUUIDs],
63
63
  Ids[OptListOfInts],
64
64
  ):
65
+ ids: Annotated[OptListOfInts, Field(None, description="Ids")] = None
66
+ uuids: Annotated[OptListOfUUIDs, Field(None, description="UUIDs")] = None
67
+ source_ids: Annotated[OptListOfInts, Field(None, description="Source's IDs")] = None
68
+ target_ids: Annotated[OptListOfInts, Field(None, description="Target's IDs")] = None
69
+ relations: Annotated[
70
+ OptListOfOrganizationRelations,
71
+ Field(None, description="Organization Relations"),
72
+ ] = None
73
+
65
74
  @property
66
75
  def _query_param_fields(self) -> set[str]:
67
76
  return {
@@ -88,6 +97,15 @@ class ReadMultipleParameter(
88
97
 
89
98
 
90
99
  class ReadSingleParameter(BaseReadSingleParameter[OrganizationRelationIdentifier]):
100
+ @classmethod
101
+ def from_identifier(
102
+ cls,
103
+ identifier: OrganizationRelationIdentifier,
104
+ statuses: ListOfDataStatuses = FULL_DATA_STATUSES,
105
+ use_cache: bool = True,
106
+ ) -> "ReadSingleParameter":
107
+ return cls(identifier=identifier, statuses=statuses, use_cache=use_cache)
108
+
91
109
  @overload
92
110
  @classmethod
93
111
  def new(
@@ -111,7 +129,7 @@ class ReadSingleParameter(BaseReadSingleParameter[OrganizationRelationIdentifier
111
129
  def new(
112
130
  cls,
113
131
  identifier_type: Literal[IdentifierType.COMPOSITE],
114
- identifier_value: CompositeIdentifier,
132
+ identifier_value: CompositeIdentifierType,
115
133
  statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
116
134
  use_cache: bool = True,
117
135
  ) -> "ReadSingleParameter": ...
@@ -187,7 +205,7 @@ class UpdateParameter(
187
205
  def new(
188
206
  cls,
189
207
  identifier_type: Literal[IdentifierType.COMPOSITE],
190
- identifier_value: CompositeIdentifier,
208
+ identifier_value: CompositeIdentifierType,
191
209
  data: UpdateDataT,
192
210
  ) -> "UpdateParameter": ...
193
211
  @overload
@@ -237,7 +255,7 @@ class StatusUpdateParameter(
237
255
  def new(
238
256
  cls,
239
257
  identifier_type: Literal[IdentifierType.COMPOSITE],
240
- identifier_value: CompositeIdentifier,
258
+ identifier_value: CompositeIdentifierType,
241
259
  type: ResourceOperationStatusUpdateType,
242
260
  ) -> "StatusUpdateParameter": ...
243
261
  @overload
@@ -279,7 +297,7 @@ class DeleteSingleParameter(BaseDeleteSingleParameter[OrganizationRelationIdenti
279
297
  def new(
280
298
  cls,
281
299
  identifier_type: Literal[IdentifierType.COMPOSITE],
282
- identifier_value: CompositeIdentifier,
300
+ identifier_value: CompositeIdentifierType,
283
301
  ) -> "DeleteSingleParameter": ...
284
302
  @overload
285
303
  @classmethod
@@ -1,6 +1,6 @@
1
1
  from datetime import date
2
2
  from pydantic import BaseModel, Field
3
- from typing import Generic, Literal, TypeVar, overload
3
+ from typing import Annotated, Generic, Literal, TypeVar, overload
4
4
  from uuid import UUID
5
5
  from maleo.enums.identity import (
6
6
  OptBloodType,
@@ -28,6 +28,8 @@ from maleo.schemas.mixins.identity import (
28
28
  UUIDs,
29
29
  FullNames,
30
30
  DateOfBirth,
31
+ IntUserId,
32
+ IntUserIds,
31
33
  IntOrganizationId,
32
34
  IntOrganizationIds,
33
35
  )
@@ -44,9 +46,9 @@ from maleo.types.dict import StrToAnyDict
44
46
  from maleo.types.integer import OptListOfInts
45
47
  from maleo.types.string import OptStr, OptListOfStrs
46
48
  from maleo.types.uuid import OptListOfUUIDs
47
- from ..enums.patient import IdentifierType
49
+ from ..enums.patient import IdentifierType, OptListOfExpandableFields
48
50
  from ..mixins.common import IdCard, FullName, PlaceOfBirth
49
- from ..mixins.patient import PatientIdentity, PatientIdentifier
51
+ from ..mixins.patient import PatientIdentity, PatientIdentifier, Expand
50
52
  from ..types.patient import IdentifierValueType
51
53
 
52
54
 
@@ -69,26 +71,42 @@ class FullCreateData(
69
71
  pass
70
72
 
71
73
 
72
- class CreateParameter(FullCreateData):
74
+ class CreateParameter(Expand, FullCreateData, IntUserId[int]):
73
75
  pass
74
76
 
75
77
 
76
78
  class ReadMultipleParameter(
79
+ Expand,
77
80
  ReadPaginatedMultipleParameter,
78
81
  RhesusesMixin[OptListOfRhesuses],
79
82
  BloodTypesMixin[OptListOfBloodTypes],
80
83
  GendersMixin[OptListOfGenders],
81
84
  FullNames[OptListOfStrs],
82
85
  IntOrganizationIds[OptListOfInts],
86
+ IntUserIds[OptListOfInts],
83
87
  UUIDs[OptListOfUUIDs],
84
88
  Ids[OptListOfInts],
85
89
  ):
90
+ ids: Annotated[OptListOfInts, Field(None, description="Ids")] = None
91
+ uuids: Annotated[OptListOfUUIDs, Field(None, description="UUIDs")] = None
92
+ user_ids: Annotated[OptListOfInts, Field(None, description="User's IDs")] = None
93
+ organization_ids: Annotated[
94
+ OptListOfInts, Field(None, description="Organization's IDs")
95
+ ] = None
96
+ full_names: Annotated[OptListOfStrs, Field(None, description="Full Names")] = None
97
+ genders: Annotated[OptListOfGenders, Field(None, description="Genders")] = None
98
+ blood_types: Annotated[
99
+ OptListOfBloodTypes, Field(None, description="Blood Types")
100
+ ] = None
101
+ rhesuses: Annotated[OptListOfRhesuses, Field(None, description="Rhesuses")] = None
102
+
86
103
  @property
87
104
  def _query_param_fields(self) -> set[str]:
88
105
  return {
89
106
  "ids",
90
107
  "uuids",
91
108
  "statuses",
109
+ "user_ids",
92
110
  "organization_ids",
93
111
  "full_names",
94
112
  "genders",
@@ -98,6 +116,7 @@ class ReadMultipleParameter(
98
116
  "page",
99
117
  "limit",
100
118
  "use_cache",
119
+ "expand",
101
120
  }
102
121
 
103
122
  def to_query_params(self) -> StrToAnyDict:
@@ -110,7 +129,19 @@ class ReadMultipleParameter(
110
129
  return params
111
130
 
112
131
 
113
- class ReadSingleParameter(BaseReadSingleParameter[PatientIdentifier]):
132
+ class ReadSingleParameter(Expand, BaseReadSingleParameter[PatientIdentifier]):
133
+ @classmethod
134
+ def from_identifier(
135
+ cls,
136
+ identifier: PatientIdentifier,
137
+ statuses: ListOfDataStatuses = FULL_DATA_STATUSES,
138
+ use_cache: bool = True,
139
+ expand: OptListOfExpandableFields = None,
140
+ ) -> "ReadSingleParameter":
141
+ return cls(
142
+ identifier=identifier, statuses=statuses, use_cache=use_cache, expand=expand
143
+ )
144
+
114
145
  @overload
115
146
  @classmethod
116
147
  def new(
@@ -119,6 +150,7 @@ class ReadSingleParameter(BaseReadSingleParameter[PatientIdentifier]):
119
150
  identifier_value: int,
120
151
  statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
121
152
  use_cache: bool = True,
153
+ expand: OptListOfExpandableFields = None,
122
154
  ) -> "ReadSingleParameter": ...
123
155
  @overload
124
156
  @classmethod
@@ -128,15 +160,17 @@ class ReadSingleParameter(BaseReadSingleParameter[PatientIdentifier]):
128
160
  identifier_value: UUID,
129
161
  statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
130
162
  use_cache: bool = True,
163
+ expand: OptListOfExpandableFields = None,
131
164
  ) -> "ReadSingleParameter": ...
132
165
  @overload
133
166
  @classmethod
134
167
  def new(
135
168
  cls,
136
- identifier_type: Literal[IdentifierType.ID_CARD, IdentifierType.PASSPORT],
137
- identifier_value: str,
169
+ identifier_type: IdentifierType,
170
+ identifier_value: IdentifierValueType,
138
171
  statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
139
172
  use_cache: bool = True,
173
+ expand: OptListOfExpandableFields = None,
140
174
  ) -> "ReadSingleParameter": ...
141
175
  @classmethod
142
176
  def new(
@@ -145,6 +179,7 @@ class ReadSingleParameter(BaseReadSingleParameter[PatientIdentifier]):
145
179
  identifier_value: IdentifierValueType,
146
180
  statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
147
181
  use_cache: bool = True,
182
+ expand: OptListOfExpandableFields = None,
148
183
  ) -> "ReadSingleParameter":
149
184
  return cls(
150
185
  identifier=PatientIdentifier(
@@ -153,11 +188,12 @@ class ReadSingleParameter(BaseReadSingleParameter[PatientIdentifier]):
153
188
  ),
154
189
  statuses=statuses,
155
190
  use_cache=use_cache,
191
+ expand=expand,
156
192
  )
157
193
 
158
194
  def to_query_params(self) -> StrToAnyDict:
159
195
  return self.model_dump(
160
- mode="json", include={"statuses", "use_cache"}, exclude_none=True
196
+ mode="json", include={"statuses", "use_cache", "expand"}, exclude_none=True
161
197
  )
162
198
 
163
199
 
@@ -195,6 +231,7 @@ class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
195
231
 
196
232
 
197
233
  class UpdateParameter(
234
+ Expand,
198
235
  UpdateDataMixin[UpdateDataT],
199
236
  IdentifierMixin[PatientIdentifier],
200
237
  Generic[UpdateDataT],
@@ -206,6 +243,7 @@ class UpdateParameter(
206
243
  identifier_type: Literal[IdentifierType.ID],
207
244
  identifier_value: int,
208
245
  data: UpdateDataT,
246
+ expand: OptListOfExpandableFields = None,
209
247
  ) -> "UpdateParameter": ...
210
248
  @overload
211
249
  @classmethod
@@ -214,14 +252,7 @@ class UpdateParameter(
214
252
  identifier_type: Literal[IdentifierType.UUID],
215
253
  identifier_value: UUID,
216
254
  data: UpdateDataT,
217
- ) -> "UpdateParameter": ...
218
- @overload
219
- @classmethod
220
- def new(
221
- cls,
222
- identifier_type: Literal[IdentifierType.ID_CARD, IdentifierType.PASSPORT],
223
- identifier_value: str,
224
- data: UpdateDataT,
255
+ expand: OptListOfExpandableFields = None,
225
256
  ) -> "UpdateParameter": ...
226
257
  @overload
227
258
  @classmethod
@@ -230,6 +261,7 @@ class UpdateParameter(
230
261
  identifier_type: IdentifierType,
231
262
  identifier_value: IdentifierValueType,
232
263
  data: UpdateDataT,
264
+ expand: OptListOfExpandableFields = None,
233
265
  ) -> "UpdateParameter": ...
234
266
  @classmethod
235
267
  def new(
@@ -237,14 +269,17 @@ class UpdateParameter(
237
269
  identifier_type: IdentifierType,
238
270
  identifier_value: IdentifierValueType,
239
271
  data: UpdateDataT,
272
+ expand: OptListOfExpandableFields = None,
240
273
  ) -> "UpdateParameter":
241
274
  return cls(
242
275
  identifier=PatientIdentifier(type=identifier_type, value=identifier_value),
243
276
  data=data,
277
+ expand=expand,
244
278
  )
245
279
 
246
280
 
247
281
  class StatusUpdateParameter(
282
+ Expand,
248
283
  BaseStatusUpdateParameter[PatientIdentifier],
249
284
  ):
250
285
  @overload
@@ -254,6 +289,7 @@ class StatusUpdateParameter(
254
289
  identifier_type: Literal[IdentifierType.ID],
255
290
  identifier_value: int,
256
291
  type: ResourceOperationStatusUpdateType,
292
+ expand: OptListOfExpandableFields = None,
257
293
  ) -> "StatusUpdateParameter": ...
258
294
  @overload
259
295
  @classmethod
@@ -262,14 +298,7 @@ class StatusUpdateParameter(
262
298
  identifier_type: Literal[IdentifierType.UUID],
263
299
  identifier_value: UUID,
264
300
  type: ResourceOperationStatusUpdateType,
265
- ) -> "StatusUpdateParameter": ...
266
- @overload
267
- @classmethod
268
- def new(
269
- cls,
270
- identifier_type: Literal[IdentifierType.ID_CARD, IdentifierType.PASSPORT],
271
- identifier_value: str,
272
- type: ResourceOperationStatusUpdateType,
301
+ expand: OptListOfExpandableFields = None,
273
302
  ) -> "StatusUpdateParameter": ...
274
303
  @overload
275
304
  @classmethod
@@ -278,6 +307,7 @@ class StatusUpdateParameter(
278
307
  identifier_type: IdentifierType,
279
308
  identifier_value: IdentifierValueType,
280
309
  type: ResourceOperationStatusUpdateType,
310
+ expand: OptListOfExpandableFields = None,
281
311
  ) -> "StatusUpdateParameter": ...
282
312
  @classmethod
283
313
  def new(
@@ -285,10 +315,12 @@ class StatusUpdateParameter(
285
315
  identifier_type: IdentifierType,
286
316
  identifier_value: IdentifierValueType,
287
317
  type: ResourceOperationStatusUpdateType,
318
+ expand: OptListOfExpandableFields = None,
288
319
  ) -> "StatusUpdateParameter":
289
320
  return cls(
290
321
  identifier=PatientIdentifier(type=identifier_type, value=identifier_value),
291
322
  type=type,
323
+ expand=expand,
292
324
  )
293
325
 
294
326
 
@@ -305,13 +337,6 @@ class DeleteSingleParameter(BaseDeleteSingleParameter[PatientIdentifier]):
305
337
  ) -> "DeleteSingleParameter": ...
306
338
  @overload
307
339
  @classmethod
308
- def new(
309
- cls,
310
- identifier_type: Literal[IdentifierType.ID_CARD, IdentifierType.PASSPORT],
311
- identifier_value: str,
312
- ) -> "DeleteSingleParameter": ...
313
- @overload
314
- @classmethod
315
340
  def new(
316
341
  cls, identifier_type: IdentifierType, identifier_value: IdentifierValueType
317
342
  ) -> "DeleteSingleParameter": ...