maleo-identity 0.0.97__py3-none-any.whl → 0.0.100__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.

Potentially problematic release.


This version of maleo-identity might be problematic. Click here for more details.

Files changed (57) hide show
  1. maleo/identity/constants/api_key.py +13 -0
  2. maleo/identity/constants/organization.py +0 -14
  3. maleo/identity/constants/organization_registration_code.py +0 -15
  4. maleo/identity/constants/organization_relation.py +13 -0
  5. maleo/identity/constants/patient.py +7 -0
  6. maleo/identity/constants/user.py +0 -15
  7. maleo/identity/constants/user_medical_role.py +13 -0
  8. maleo/identity/constants/user_organization_role.py +13 -0
  9. maleo/identity/constants/user_profile.py +0 -15
  10. maleo/identity/constants/user_system_role.py +13 -0
  11. maleo/identity/dtos.py +295 -0
  12. maleo/identity/enums/api_key.py +13 -0
  13. maleo/identity/enums/organization.py +5 -6
  14. maleo/identity/enums/organization_relation.py +12 -0
  15. maleo/identity/enums/patient.py +22 -0
  16. maleo/identity/enums/user.py +10 -6
  17. maleo/identity/enums/user_medical_role.py +12 -0
  18. maleo/identity/enums/user_organization_role.py +12 -0
  19. maleo/identity/enums/user_profile.py +9 -0
  20. maleo/identity/enums/user_system_role.py +12 -0
  21. maleo/identity/mixins/api_key.py +6 -0
  22. maleo/identity/mixins/common.py +29 -0
  23. maleo/identity/mixins/organization_relation.py +14 -0
  24. maleo/identity/mixins/patient.py +8 -0
  25. maleo/identity/mixins/user_profile.py +4 -21
  26. maleo/identity/models.py +89 -95
  27. maleo/identity/schemas/api_key.py +128 -0
  28. maleo/identity/schemas/common.py +152 -120
  29. maleo/identity/schemas/organization.py +39 -6
  30. maleo/identity/schemas/organization_registration_code.py +14 -5
  31. maleo/identity/schemas/organization_relation.py +178 -0
  32. maleo/identity/schemas/patient.py +234 -0
  33. maleo/identity/schemas/user.py +19 -4
  34. maleo/identity/schemas/user_medical_role.py +181 -0
  35. maleo/identity/schemas/user_organization_role.py +181 -0
  36. maleo/identity/schemas/user_profile.py +68 -10
  37. maleo/identity/schemas/user_system_role.py +174 -0
  38. maleo/identity/types/api_key.py +7 -0
  39. maleo/identity/types/organization.py +1 -2
  40. maleo/identity/types/organization_registration_code.py +1 -2
  41. maleo/identity/types/organization_relation.py +7 -0
  42. maleo/identity/types/patient.py +4 -0
  43. maleo/identity/types/user.py +1 -2
  44. maleo/identity/types/user_medical_role.py +7 -0
  45. maleo/identity/types/user_organization_role.py +7 -0
  46. maleo/identity/types/user_profile.py +1 -2
  47. maleo/identity/types/user_system_role.py +7 -0
  48. maleo/identity/utils/organization.py +33 -27
  49. maleo/identity/utils/user.py +33 -27
  50. maleo/identity/validators/__init__.py +0 -0
  51. maleo/identity/validators/patient.py +6 -0
  52. {maleo_identity-0.0.97.dist-info → maleo_identity-0.0.100.dist-info}/METADATA +8 -7
  53. maleo_identity-0.0.100.dist-info/RECORD +67 -0
  54. maleo_identity-0.0.97.dist-info/RECORD +0 -36
  55. {maleo_identity-0.0.97.dist-info → maleo_identity-0.0.100.dist-info}/WHEEL +0 -0
  56. {maleo_identity-0.0.97.dist-info → maleo_identity-0.0.100.dist-info}/licenses/LICENSE +0 -0
  57. {maleo_identity-0.0.97.dist-info → maleo_identity-0.0.100.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,178 @@
1
+ from pydantic import BaseModel, Field
2
+ from typing import Annotated, Generic, Literal, Tuple, TypeVar, overload
3
+ from uuid import UUID
4
+ from maleo.enums.organization import (
5
+ OrganizationRelation,
6
+ SimpleOrganizationRelationMixin,
7
+ OptListOfOrganizationRelations,
8
+ SimpleOrganizationRelationsMixin,
9
+ )
10
+ from maleo.enums.status import (
11
+ ListOfDataStatuses,
12
+ FULL_DATA_STATUSES,
13
+ )
14
+ from maleo.schemas.mixins.filter import convert as convert_filter
15
+ from maleo.schemas.mixins.identity import (
16
+ IdentifierTypeValue,
17
+ Ids,
18
+ UUIDs,
19
+ IntSourceId,
20
+ IntSourceIds,
21
+ IntTargetId,
22
+ IntTargetIds,
23
+ )
24
+ from maleo.schemas.mixins.sort import convert as convert_sort
25
+ from maleo.schemas.parameter import (
26
+ ReadSingleParameter as BaseReadSingleParameter,
27
+ ReadPaginatedMultipleParameter,
28
+ StatusUpdateParameter as BaseStatusUpdateParameter,
29
+ DeleteSingleParameter as BaseDeleteSingleParameter,
30
+ )
31
+ from maleo.types.boolean import OptBool
32
+ from maleo.types.dict import StrToAnyDict
33
+ from maleo.types.integer import OptListOfInts
34
+ from maleo.types.uuid import OptListOfUUIDs
35
+ from ..enums.organization_relation import IdentifierType
36
+ from ..mixins.organization_relation import IsBidirectional, Metadata
37
+ from ..types.organization_relation import IdentifierValueType
38
+
39
+
40
+ class CreateParameter(
41
+ Metadata,
42
+ IsBidirectional[bool],
43
+ SimpleOrganizationRelationMixin[OrganizationRelation],
44
+ IntTargetId[int],
45
+ IntSourceId[int],
46
+ ):
47
+ is_bidirectional: Annotated[bool, Field(False, description="Is Bidirectional")] = (
48
+ False
49
+ )
50
+
51
+
52
+ class ReadMultipleParameter(
53
+ ReadPaginatedMultipleParameter,
54
+ SimpleOrganizationRelationsMixin[OptListOfOrganizationRelations],
55
+ IntTargetIds[OptListOfInts],
56
+ IntSourceIds[OptListOfInts],
57
+ UUIDs[OptListOfUUIDs],
58
+ Ids[OptListOfInts],
59
+ ):
60
+ @property
61
+ def _query_param_fields(self) -> set[str]:
62
+ return {
63
+ "ids",
64
+ "uuids",
65
+ "statuses",
66
+ "source_ids",
67
+ "target_ids",
68
+ "relations",
69
+ "search",
70
+ "page",
71
+ "limit",
72
+ "use_cache",
73
+ }
74
+
75
+ def to_query_params(self) -> StrToAnyDict:
76
+ params = self.model_dump(
77
+ mode="json", include=self._query_param_fields, exclude_none=True
78
+ )
79
+ params["filters"] = convert_filter(self.date_filters)
80
+ params["sorts"] = convert_sort(self.sort_columns)
81
+ params = {k: v for k, v in params.items()}
82
+ return params
83
+
84
+
85
+ class ReadSingleParameter(BaseReadSingleParameter[IdentifierType, IdentifierValueType]):
86
+ @overload
87
+ @classmethod
88
+ def new(
89
+ cls,
90
+ identifier_type: Literal[IdentifierType.ID],
91
+ identifier_value: int,
92
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
93
+ use_cache: bool = True,
94
+ ) -> "ReadSingleParameter": ...
95
+ @overload
96
+ @classmethod
97
+ def new(
98
+ cls,
99
+ identifier_type: Literal[IdentifierType.UUID],
100
+ identifier_value: UUID,
101
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
102
+ use_cache: bool = True,
103
+ ) -> "ReadSingleParameter": ...
104
+ @overload
105
+ @classmethod
106
+ def new(
107
+ cls,
108
+ identifier_type: Literal[IdentifierType.COMPOSITE],
109
+ identifier_value: Tuple[int, int, OrganizationRelation],
110
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
111
+ use_cache: bool = True,
112
+ ) -> "ReadSingleParameter": ...
113
+ @overload
114
+ @classmethod
115
+ def new(
116
+ cls,
117
+ identifier_type: IdentifierType,
118
+ identifier_value: IdentifierValueType,
119
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
120
+ use_cache: bool = True,
121
+ ) -> "ReadSingleParameter": ...
122
+ @classmethod
123
+ def new(
124
+ cls,
125
+ identifier_type: IdentifierType,
126
+ identifier_value: IdentifierValueType,
127
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
128
+ use_cache: bool = True,
129
+ ) -> "ReadSingleParameter":
130
+ return cls(
131
+ identifier_type=identifier_type,
132
+ identifier_value=identifier_value,
133
+ statuses=statuses,
134
+ use_cache=use_cache,
135
+ )
136
+
137
+ def to_query_params(self) -> StrToAnyDict:
138
+ return self.model_dump(
139
+ mode="json", include={"statuses", "use_cache"}, exclude_none=True
140
+ )
141
+
142
+
143
+ class FullUpdateData(Metadata, IsBidirectional[bool]):
144
+ pass
145
+
146
+
147
+ class PartialUpdateData(Metadata, IsBidirectional[OptBool]):
148
+ pass
149
+
150
+
151
+ UpdateDataT = TypeVar("UpdateDataT", FullUpdateData, PartialUpdateData)
152
+
153
+
154
+ class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
155
+ data: UpdateDataT = Field(..., description="Update data")
156
+
157
+
158
+ class UpdateParameter(
159
+ UpdateDataMixin[UpdateDataT],
160
+ IdentifierTypeValue[
161
+ IdentifierType,
162
+ IdentifierValueType,
163
+ ],
164
+ Generic[UpdateDataT],
165
+ ):
166
+ pass
167
+
168
+
169
+ class StatusUpdateParameter(
170
+ BaseStatusUpdateParameter[IdentifierType, IdentifierValueType],
171
+ ):
172
+ pass
173
+
174
+
175
+ class DeleteSingleParameter(
176
+ BaseDeleteSingleParameter[IdentifierType, IdentifierValueType]
177
+ ):
178
+ pass
@@ -0,0 +1,234 @@
1
+ from datetime import date
2
+ from pydantic import BaseModel, Field, model_validator
3
+ from typing import Annotated, Generic, Literal, Self, TypeVar, overload
4
+ from uuid import UUID
5
+ from maleo.enums.identity import (
6
+ OptBloodType,
7
+ BloodTypeMixin,
8
+ OptListOfBloodTypes,
9
+ BloodTypesMixin,
10
+ OptRhesus,
11
+ RhesusMixin,
12
+ OptListOfRhesuses,
13
+ RhesusesMixin,
14
+ Gender,
15
+ OptGender,
16
+ GenderMixin,
17
+ OptListOfGenders,
18
+ GendersMixin,
19
+ )
20
+ from maleo.enums.status import (
21
+ ListOfDataStatuses,
22
+ FULL_DATA_STATUSES,
23
+ )
24
+ from maleo.schemas.mixins.filter import convert as convert_filter
25
+ from maleo.schemas.mixins.identity import (
26
+ IdentifierTypeValue,
27
+ Ids,
28
+ UUIDs,
29
+ FullNames,
30
+ DateOfBirth,
31
+ IntOrganizationId,
32
+ IntOrganizationIds,
33
+ )
34
+ from maleo.schemas.mixins.sort import convert as convert_sort
35
+ from maleo.schemas.parameter import (
36
+ ReadSingleParameter as BaseReadSingleParameter,
37
+ ReadPaginatedMultipleParameter,
38
+ StatusUpdateParameter as BaseStatusUpdateParameter,
39
+ DeleteSingleParameter as BaseDeleteSingleParameter,
40
+ )
41
+ from maleo.types.datetime import OptDate
42
+ from maleo.types.dict import StrToAnyDict
43
+ from maleo.types.integer import OptListOfInts
44
+ from maleo.types.string import OptStr, OptListOfStrs
45
+ from maleo.types.uuid import OptListOfUUIDs
46
+ from ..enums.patient import IdentifierType, OptListOfExpandableFields
47
+ from ..mixins.common import IdCard, FullName, PlaceOfBirth
48
+ from ..mixins.patient import Passport
49
+ from ..types.patient import IdentifierValueType
50
+ from ..validators.patient import validate_id_card_or_passport
51
+
52
+
53
+ class Expand(BaseModel):
54
+ expand: Annotated[
55
+ OptListOfExpandableFields, Field(None, description="Expand", min_length=1)
56
+ ] = None
57
+
58
+
59
+ class CreateQuery(Expand):
60
+ pass
61
+
62
+
63
+ class CreateData(
64
+ RhesusMixin[OptRhesus],
65
+ BloodTypeMixin[OptBloodType],
66
+ GenderMixin[Gender],
67
+ DateOfBirth[date],
68
+ PlaceOfBirth[OptStr],
69
+ FullName[str],
70
+ Passport[OptStr],
71
+ IdCard[OptStr],
72
+ IntOrganizationId[int],
73
+ ):
74
+ @model_validator(mode="after")
75
+ def chk_id_card_or_passport(self) -> Self:
76
+ validate_id_card_or_passport(self.id_card, self.passport)
77
+ return self
78
+
79
+
80
+ class CreateParameter(CreateQuery, CreateData):
81
+ pass
82
+
83
+
84
+ class ReadMultipleParameter(
85
+ Expand,
86
+ ReadPaginatedMultipleParameter,
87
+ RhesusesMixin[OptListOfRhesuses],
88
+ BloodTypesMixin[OptListOfBloodTypes],
89
+ GendersMixin[OptListOfGenders],
90
+ FullNames[OptListOfStrs],
91
+ IntOrganizationIds[OptListOfInts],
92
+ UUIDs[OptListOfUUIDs],
93
+ Ids[OptListOfInts],
94
+ ):
95
+ @property
96
+ def _query_param_fields(self) -> set[str]:
97
+ return {
98
+ "ids",
99
+ "uuids",
100
+ "statuses",
101
+ "organization_ids",
102
+ "full_names",
103
+ "genders",
104
+ "blood_types",
105
+ "rhesuses",
106
+ "search",
107
+ "page",
108
+ "limit",
109
+ "use_cache",
110
+ "expand",
111
+ }
112
+
113
+ def to_query_params(self) -> StrToAnyDict:
114
+ params = self.model_dump(
115
+ mode="json", include=self._query_param_fields, exclude_none=True
116
+ )
117
+ params["filters"] = convert_filter(self.date_filters)
118
+ params["sorts"] = convert_sort(self.sort_columns)
119
+ params = {k: v for k, v in params.items()}
120
+ return params
121
+
122
+
123
+ class ReadSingleParameter(
124
+ Expand, BaseReadSingleParameter[IdentifierType, IdentifierValueType]
125
+ ):
126
+ @overload
127
+ @classmethod
128
+ def new(
129
+ cls,
130
+ identifier_type: Literal[IdentifierType.ID],
131
+ identifier_value: int,
132
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
133
+ use_cache: bool = True,
134
+ expand: OptListOfExpandableFields = None,
135
+ ) -> "ReadSingleParameter": ...
136
+ @overload
137
+ @classmethod
138
+ def new(
139
+ cls,
140
+ identifier_type: Literal[IdentifierType.UUID],
141
+ identifier_value: UUID,
142
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
143
+ use_cache: bool = True,
144
+ expand: OptListOfExpandableFields = None,
145
+ ) -> "ReadSingleParameter": ...
146
+ @overload
147
+ @classmethod
148
+ def new(
149
+ cls,
150
+ identifier_type: Literal[IdentifierType.ID_CARD, IdentifierType.PASSPORT],
151
+ identifier_value: str,
152
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
153
+ use_cache: bool = True,
154
+ expand: OptListOfExpandableFields = None,
155
+ ) -> "ReadSingleParameter": ...
156
+ @classmethod
157
+ def new(
158
+ cls,
159
+ identifier_type: IdentifierType,
160
+ identifier_value: IdentifierValueType,
161
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
162
+ use_cache: bool = True,
163
+ expand: OptListOfExpandableFields = None,
164
+ ) -> "ReadSingleParameter":
165
+ return cls(
166
+ identifier_type=identifier_type,
167
+ identifier_value=identifier_value,
168
+ statuses=statuses,
169
+ use_cache=use_cache,
170
+ expand=expand,
171
+ )
172
+
173
+ def to_query_params(self) -> StrToAnyDict:
174
+ return self.model_dump(
175
+ mode="json", include={"statuses", "use_cache", "expand"}, exclude_none=True
176
+ )
177
+
178
+
179
+ class FullUpdateData(
180
+ RhesusMixin[OptRhesus],
181
+ BloodTypeMixin[OptBloodType],
182
+ GenderMixin[Gender],
183
+ DateOfBirth[date],
184
+ PlaceOfBirth[OptStr],
185
+ FullName[str],
186
+ Passport[OptStr],
187
+ IdCard[OptStr],
188
+ ):
189
+ pass
190
+
191
+
192
+ class PartialUpdateData(
193
+ RhesusMixin[OptRhesus],
194
+ BloodTypeMixin[OptBloodType],
195
+ GenderMixin[OptGender],
196
+ DateOfBirth[OptDate],
197
+ PlaceOfBirth[OptStr],
198
+ FullName[OptStr],
199
+ Passport[OptStr],
200
+ IdCard[OptStr],
201
+ ):
202
+ pass
203
+
204
+
205
+ UpdateDataT = TypeVar("UpdateDataT", FullUpdateData, PartialUpdateData)
206
+
207
+
208
+ class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
209
+ data: UpdateDataT = Field(..., description="Update data")
210
+
211
+
212
+ class UpdateParameter(
213
+ Expand,
214
+ UpdateDataMixin[UpdateDataT],
215
+ IdentifierTypeValue[
216
+ IdentifierType,
217
+ IdentifierValueType,
218
+ ],
219
+ Generic[UpdateDataT],
220
+ ):
221
+ pass
222
+
223
+
224
+ class StatusUpdateParameter(
225
+ Expand,
226
+ BaseStatusUpdateParameter[IdentifierType, IdentifierValueType],
227
+ ):
228
+ pass
229
+
230
+
231
+ class DeleteSingleParameter(
232
+ BaseDeleteSingleParameter[IdentifierType, IdentifierValueType]
233
+ ):
234
+ pass
@@ -17,6 +17,7 @@ from maleo.schemas.mixins.identity import (
17
17
  IdentifierTypeValue,
18
18
  Ids,
19
19
  UUIDs,
20
+ IntOrganizationIds,
20
21
  )
21
22
  from maleo.schemas.mixins.sort import convert as convert_sort
22
23
  from maleo.schemas.parameter import (
@@ -29,7 +30,7 @@ from maleo.types.dict import StrToAnyDict
29
30
  from maleo.types.integer import OptListOfInts
30
31
  from maleo.types.string import OptStr, OptListOfStrs
31
32
  from maleo.types.uuid import OptListOfUUIDs
32
- from ..enums.user import IdentifierType
33
+ from ..enums.user import IdentifierType, OptListOfExpandableFields
33
34
  from ..mixins.user import (
34
35
  Username,
35
36
  Usernames,
@@ -41,6 +42,12 @@ from ..mixins.user import (
41
42
  from ..types.user import IdentifierValueType
42
43
 
43
44
 
45
+ class Expand(BaseModel):
46
+ expand: Annotated[
47
+ OptListOfExpandableFields, Field(None, description="Expand", min_length=1)
48
+ ] = None
49
+
50
+
44
51
  class CreateParameter(
45
52
  Phone[str], Email[str], Username[str], FullUserTypeMixin[UserType]
46
53
  ):
@@ -48,6 +55,7 @@ class CreateParameter(
48
55
 
49
56
 
50
57
  class ReadMultipleParameter(
58
+ Expand,
51
59
  ReadPaginatedMultipleParameter,
52
60
  Phones[OptListOfStrs],
53
61
  Emails[OptListOfStrs],
@@ -55,10 +63,12 @@ class ReadMultipleParameter(
55
63
  FullUserTypesMixin[OptListOfUserTypes],
56
64
  UUIDs[OptListOfUUIDs],
57
65
  Ids[OptListOfInts],
66
+ IntOrganizationIds[OptListOfInts],
58
67
  ):
59
68
  @property
60
69
  def _query_param_fields(self) -> set[str]:
61
70
  return {
71
+ "organization_ids",
62
72
  "ids",
63
73
  "uuids",
64
74
  "statuses",
@@ -70,6 +80,7 @@ class ReadMultipleParameter(
70
80
  "page",
71
81
  "limit",
72
82
  "use_cache",
83
+ "expand",
73
84
  }
74
85
 
75
86
  def to_query_params(self) -> StrToAnyDict:
@@ -82,7 +93,9 @@ class ReadMultipleParameter(
82
93
  return params
83
94
 
84
95
 
85
- class ReadSingleParameter(BaseReadSingleParameter[IdentifierType, IdentifierValueType]):
96
+ class ReadSingleParameter(
97
+ Expand, BaseReadSingleParameter[IdentifierType, IdentifierValueType]
98
+ ):
86
99
  @overload
87
100
  @classmethod
88
101
  def new(
@@ -127,11 +140,11 @@ class ReadSingleParameter(BaseReadSingleParameter[IdentifierType, IdentifierValu
127
140
 
128
141
  def to_query_params(self) -> StrToAnyDict:
129
142
  return self.model_dump(
130
- mode="json", include={"statuses", "use_cache"}, exclude_none=True
143
+ mode="json", include={"statuses", "use_cache", "expand"}, exclude_none=True
131
144
  )
132
145
 
133
146
 
134
- class ChangePasswordData(BaseModel):
147
+ class PasswordUpdateData(BaseModel):
135
148
  old: Annotated[str, Field(..., description="Old Password", max_length=255)]
136
149
  old_confirmation: Annotated[
137
150
  str, Field(..., description="Old Password Confirmation", max_length=255)
@@ -159,6 +172,7 @@ class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
159
172
 
160
173
 
161
174
  class UpdateParameter(
175
+ Expand,
162
176
  UpdateDataMixin[UpdateDataT],
163
177
  IdentifierTypeValue[
164
178
  IdentifierType,
@@ -170,6 +184,7 @@ class UpdateParameter(
170
184
 
171
185
 
172
186
  class StatusUpdateParameter(
187
+ Expand,
173
188
  BaseStatusUpdateParameter[IdentifierType, IdentifierValueType],
174
189
  ):
175
190
  pass
@@ -0,0 +1,181 @@
1
+ from pydantic import BaseModel, Field
2
+ from typing import Generic, Literal, Tuple, TypeVar, overload
3
+ from uuid import UUID
4
+ from maleo.enums.medical import (
5
+ MedicalRole,
6
+ OptMedicalRole,
7
+ FullMedicalRoleMixin,
8
+ OptListOfMedicalRoles,
9
+ FullMedicalRolesMixin,
10
+ )
11
+ from maleo.enums.status import (
12
+ ListOfDataStatuses,
13
+ FULL_DATA_STATUSES,
14
+ )
15
+ from maleo.schemas.mixins.filter import convert as convert_filter
16
+ from maleo.schemas.mixins.identity import (
17
+ IdentifierTypeValue,
18
+ Ids,
19
+ UUIDs,
20
+ IntUserId,
21
+ IntUserIds,
22
+ IntOrganizationId,
23
+ IntOrganizationIds,
24
+ )
25
+ from maleo.schemas.mixins.sort import convert as convert_sort
26
+ from maleo.schemas.parameter import (
27
+ ReadSingleParameter as BaseReadSingleParameter,
28
+ ReadPaginatedMultipleParameter,
29
+ StatusUpdateParameter as BaseStatusUpdateParameter,
30
+ DeleteSingleParameter as BaseDeleteSingleParameter,
31
+ )
32
+ from maleo.types.dict import StrToAnyDict
33
+ from maleo.types.integer import OptInt, OptListOfInts
34
+ from maleo.types.uuid import OptListOfUUIDs
35
+ from ..enums.user_medical_role import IdentifierType
36
+ from ..types.user_medical_role import IdentifierValueType
37
+
38
+
39
+ class CreateParameter(
40
+ FullMedicalRoleMixin[MedicalRole],
41
+ IntOrganizationId[int],
42
+ IntUserId[int],
43
+ ):
44
+ pass
45
+
46
+
47
+ class ReadMultipleParameter(
48
+ ReadPaginatedMultipleParameter,
49
+ FullMedicalRolesMixin[OptListOfMedicalRoles],
50
+ IntOrganizationIds[OptListOfInts],
51
+ IntUserIds[OptListOfInts],
52
+ UUIDs[OptListOfUUIDs],
53
+ Ids[OptListOfInts],
54
+ ):
55
+ @property
56
+ def _query_param_fields(self) -> set[str]:
57
+ return {
58
+ "ids",
59
+ "uuids",
60
+ "statuses",
61
+ "user_ids",
62
+ "organization_ids",
63
+ "medical_roles",
64
+ "search",
65
+ "page",
66
+ "limit",
67
+ "use_cache",
68
+ }
69
+
70
+ def to_query_params(self) -> StrToAnyDict:
71
+ params = self.model_dump(
72
+ mode="json", include=self._query_param_fields, exclude_none=True
73
+ )
74
+ params["filters"] = convert_filter(self.date_filters)
75
+ params["sorts"] = convert_sort(self.sort_columns)
76
+ params = {k: v for k, v in params.items()}
77
+ return params
78
+
79
+
80
+ class ReadSingleParameter(BaseReadSingleParameter[IdentifierType, IdentifierValueType]):
81
+ @overload
82
+ @classmethod
83
+ def new(
84
+ cls,
85
+ identifier_type: Literal[IdentifierType.ID],
86
+ identifier_value: int,
87
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
88
+ use_cache: bool = True,
89
+ ) -> "ReadSingleParameter": ...
90
+ @overload
91
+ @classmethod
92
+ def new(
93
+ cls,
94
+ identifier_type: Literal[IdentifierType.UUID],
95
+ identifier_value: UUID,
96
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
97
+ use_cache: bool = True,
98
+ ) -> "ReadSingleParameter": ...
99
+ @overload
100
+ @classmethod
101
+ def new(
102
+ cls,
103
+ identifier_type: Literal[IdentifierType.COMPOSITE],
104
+ identifier_value: Tuple[int, int, MedicalRole],
105
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
106
+ use_cache: bool = True,
107
+ ) -> "ReadSingleParameter": ...
108
+ @overload
109
+ @classmethod
110
+ def new(
111
+ cls,
112
+ identifier_type: IdentifierType,
113
+ identifier_value: IdentifierValueType,
114
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
115
+ use_cache: bool = True,
116
+ ) -> "ReadSingleParameter": ...
117
+ @classmethod
118
+ def new(
119
+ cls,
120
+ identifier_type: IdentifierType,
121
+ identifier_value: IdentifierValueType,
122
+ statuses: ListOfDataStatuses = list(FULL_DATA_STATUSES),
123
+ use_cache: bool = True,
124
+ ) -> "ReadSingleParameter":
125
+ return cls(
126
+ identifier_type=identifier_type,
127
+ identifier_value=identifier_value,
128
+ statuses=statuses,
129
+ use_cache=use_cache,
130
+ )
131
+
132
+ def to_query_params(self) -> StrToAnyDict:
133
+ return self.model_dump(
134
+ mode="json", include={"statuses", "use_cache"}, exclude_none=True
135
+ )
136
+
137
+
138
+ class FullUpdateData(
139
+ FullMedicalRoleMixin[MedicalRole],
140
+ IntOrganizationId[int],
141
+ IntUserId[int],
142
+ ):
143
+ pass
144
+
145
+
146
+ class PartialUpdateData(
147
+ FullMedicalRoleMixin[OptMedicalRole],
148
+ IntOrganizationId[OptInt],
149
+ IntUserId[OptInt],
150
+ ):
151
+ pass
152
+
153
+
154
+ UpdateDataT = TypeVar("UpdateDataT", FullUpdateData, PartialUpdateData)
155
+
156
+
157
+ class UpdateDataMixin(BaseModel, Generic[UpdateDataT]):
158
+ data: UpdateDataT = Field(..., description="Update data")
159
+
160
+
161
+ class UpdateParameter(
162
+ UpdateDataMixin[UpdateDataT],
163
+ IdentifierTypeValue[
164
+ IdentifierType,
165
+ IdentifierValueType,
166
+ ],
167
+ Generic[UpdateDataT],
168
+ ):
169
+ pass
170
+
171
+
172
+ class StatusUpdateParameter(
173
+ BaseStatusUpdateParameter[IdentifierType, IdentifierValueType],
174
+ ):
175
+ pass
176
+
177
+
178
+ class DeleteSingleParameter(
179
+ BaseDeleteSingleParameter[IdentifierType, IdentifierValueType]
180
+ ):
181
+ pass