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.
- maleo/identity/constants/api_key.py +2 -2
- maleo/identity/constants/organization.py +1 -1
- maleo/identity/constants/organization_registration_code.py +2 -2
- maleo/identity/constants/organization_relation.py +2 -2
- maleo/identity/constants/patient.py +1 -1
- maleo/identity/constants/user.py +1 -1
- maleo/identity/constants/user_medical_role.py +2 -2
- maleo/identity/constants/user_organization_role.py +2 -2
- maleo/identity/constants/user_profile.py +1 -1
- maleo/identity/constants/user_system_role.py +6 -2
- maleo/identity/enums/api_key.py +13 -1
- maleo/identity/enums/organization.py +4 -0
- maleo/identity/enums/organization_registration_code.py +4 -0
- maleo/identity/enums/organization_relation.py +11 -1
- maleo/identity/enums/patient.py +18 -2
- maleo/identity/enums/user.py +4 -0
- maleo/identity/enums/user_medical_role.py +11 -1
- maleo/identity/enums/user_organization_role.py +11 -1
- maleo/identity/enums/user_profile.py +4 -0
- maleo/identity/enums/user_system_role.py +24 -1
- maleo/identity/mixins/api_key.py +9 -4
- maleo/identity/mixins/organization.py +3 -1
- maleo/identity/mixins/organization_registration_code.py +40 -4
- maleo/identity/mixins/organization_relation.py +9 -4
- maleo/identity/mixins/patient.py +13 -44
- maleo/identity/mixins/user.py +3 -1
- maleo/identity/mixins/user_medical_role.py +9 -4
- maleo/identity/mixins/user_organization_role.py +9 -4
- maleo/identity/mixins/user_profile.py +3 -1
- maleo/identity/mixins/user_system_role.py +17 -6
- maleo/identity/schemas/api_key.py +21 -4
- maleo/identity/schemas/common.py +38 -24
- maleo/identity/schemas/organization.py +26 -0
- maleo/identity/schemas/organization_registration_code.py +19 -2
- maleo/identity/schemas/organization_relation.py +23 -5
- maleo/identity/schemas/patient.py +56 -31
- maleo/identity/schemas/user.py +23 -0
- maleo/identity/schemas/user_medical_role.py +25 -6
- maleo/identity/schemas/user_organization_role.py +25 -6
- maleo/identity/schemas/user_profile.py +33 -1
- maleo/identity/schemas/user_system_role.py +52 -11
- maleo/identity/types/api_key.py +2 -2
- maleo/identity/types/organization_relation.py +2 -2
- maleo/identity/types/patient.py +1 -1
- maleo/identity/types/user_medical_role.py +2 -2
- maleo/identity/types/user_organization_role.py +2 -2
- maleo/identity/types/user_system_role.py +3 -2
- {maleo_identity-0.1.11.dist-info → maleo_identity-0.1.24.dist-info}/METADATA +6 -5
- maleo_identity-0.1.24.dist-info/RECORD +66 -0
- maleo/identity/models.py +0 -337
- maleo_identity-0.1.11.dist-info/RECORD +0 -67
- {maleo_identity-0.1.11.dist-info → maleo_identity-0.1.24.dist-info}/WHEEL +0 -0
- {maleo_identity-0.1.11.dist-info → maleo_identity-0.1.24.dist-info}/licenses/LICENSE +0 -0
- {maleo_identity-0.1.11.dist-info → maleo_identity-0.1.24.dist-info}/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
|
4
4
|
ORGANIZATION_RESOURCE = Resource(
|
|
5
5
|
identifiers=[
|
|
6
6
|
ResourceIdentifier(
|
|
7
|
-
key="
|
|
7
|
+
key="organization", name="Organization", slug="organizations"
|
|
8
8
|
)
|
|
9
9
|
],
|
|
10
10
|
details=None,
|
|
@@ -4,8 +4,8 @@ from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
|
4
4
|
ORGANIZATION_REGISTRATION_CODE_RESOURCE = Resource(
|
|
5
5
|
identifiers=[
|
|
6
6
|
ResourceIdentifier(
|
|
7
|
-
key="
|
|
8
|
-
name="Organization Registration
|
|
7
|
+
key="organization_registration_code",
|
|
8
|
+
name="Organization Registration Code",
|
|
9
9
|
slug="organization-registration-codes",
|
|
10
10
|
)
|
|
11
11
|
],
|
|
@@ -4,8 +4,8 @@ from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
|
4
4
|
ORGANIZATION_RELATION_RESOURCE = Resource(
|
|
5
5
|
identifiers=[
|
|
6
6
|
ResourceIdentifier(
|
|
7
|
-
key="
|
|
8
|
-
name="Organization
|
|
7
|
+
key="organization_relation",
|
|
8
|
+
name="Organization Relation",
|
|
9
9
|
slug="organization-relations",
|
|
10
10
|
)
|
|
11
11
|
],
|
|
@@ -2,6 +2,6 @@ from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
PATIENT_RESOURCE = Resource(
|
|
5
|
-
identifiers=[ResourceIdentifier(key="
|
|
5
|
+
identifiers=[ResourceIdentifier(key="patient", name="Patient", slug="patients")],
|
|
6
6
|
details=None,
|
|
7
7
|
)
|
maleo/identity/constants/user.py
CHANGED
|
@@ -4,8 +4,8 @@ from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
|
4
4
|
USER_MEDICAL_ROLE_RESOURCE = Resource(
|
|
5
5
|
identifiers=[
|
|
6
6
|
ResourceIdentifier(
|
|
7
|
-
key="
|
|
8
|
-
name="User Medical
|
|
7
|
+
key="user_medical_role",
|
|
8
|
+
name="User Medical Role",
|
|
9
9
|
slug="user-medical-roles",
|
|
10
10
|
)
|
|
11
11
|
],
|
|
@@ -4,8 +4,8 @@ from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
|
4
4
|
USER_ORGANIZATION_ROLE_RESOURCE = Resource(
|
|
5
5
|
identifiers=[
|
|
6
6
|
ResourceIdentifier(
|
|
7
|
-
key="
|
|
8
|
-
name="User Organization
|
|
7
|
+
key="user_organization_role",
|
|
8
|
+
name="User Organization Role",
|
|
9
9
|
slug="user-organization-roles",
|
|
10
10
|
)
|
|
11
11
|
],
|
|
@@ -4,7 +4,7 @@ from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
|
4
4
|
USER_PROFILE_RESOURCE = Resource(
|
|
5
5
|
identifiers=[
|
|
6
6
|
ResourceIdentifier(
|
|
7
|
-
key="
|
|
7
|
+
key="user_profile", name="User Profile", slug="user-profiles"
|
|
8
8
|
)
|
|
9
9
|
],
|
|
10
10
|
details=None,
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
from maleo.schemas.resource import Resource, ResourceIdentifier
|
|
2
|
+
from maleo.types.string import DoubleStrs
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
USER_SYSTEM_ROLE_RESOURCE = Resource(
|
|
5
6
|
identifiers=[
|
|
6
7
|
ResourceIdentifier(
|
|
7
|
-
key="
|
|
8
|
-
name="User System
|
|
8
|
+
key="user_system_role",
|
|
9
|
+
name="User System Role",
|
|
9
10
|
slug="user-system-roles",
|
|
10
11
|
)
|
|
11
12
|
],
|
|
12
13
|
details=None,
|
|
13
14
|
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
COMPOSITE_COLUMS: DoubleStrs = ("user_id", "system_role")
|
maleo/identity/enums/api_key.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from enum import StrEnum
|
|
2
|
-
from maleo.types.string import ListOfStrs
|
|
2
|
+
from maleo.types.string import ListOfStrs, ManyStrs
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class IdentifierType(StrEnum):
|
|
@@ -11,3 +11,15 @@ class IdentifierType(StrEnum):
|
|
|
11
11
|
@classmethod
|
|
12
12
|
def choices(cls) -> ListOfStrs:
|
|
13
13
|
return [e.value for e in cls]
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def columns(self) -> ManyStrs:
|
|
17
|
+
if self is IdentifierType.ID:
|
|
18
|
+
return ("id",)
|
|
19
|
+
elif self is IdentifierType.UUID:
|
|
20
|
+
return ("uuid",)
|
|
21
|
+
elif self is IdentifierType.API_KEY:
|
|
22
|
+
return ("api_key",)
|
|
23
|
+
elif self is IdentifierType.COMPOSITE:
|
|
24
|
+
return ("user_id", "organization_id")
|
|
25
|
+
raise ValueError(f"Unknown column(s) for identifier type: {self}")
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from enum import StrEnum
|
|
2
|
-
from maleo.types.string import ListOfStrs
|
|
2
|
+
from maleo.types.string import ListOfStrs, ManyStrs
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class IdentifierType(StrEnum):
|
|
@@ -10,3 +10,13 @@ class IdentifierType(StrEnum):
|
|
|
10
10
|
@classmethod
|
|
11
11
|
def choices(cls) -> ListOfStrs:
|
|
12
12
|
return [e.value for e in cls]
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def columns(self) -> ManyStrs:
|
|
16
|
+
if self is IdentifierType.ID:
|
|
17
|
+
return ("id",)
|
|
18
|
+
elif self is IdentifierType.UUID:
|
|
19
|
+
return ("uuid",)
|
|
20
|
+
elif self is IdentifierType.COMPOSITE:
|
|
21
|
+
return ("source_id", "target_id", "relation")
|
|
22
|
+
raise ValueError(f"Unknown column(s) for identifier type: {self}")
|
maleo/identity/enums/patient.py
CHANGED
|
@@ -5,9 +5,25 @@ from maleo.types.string import ListOfStrs
|
|
|
5
5
|
class IdentifierType(StrEnum):
|
|
6
6
|
ID = "id"
|
|
7
7
|
UUID = "uuid"
|
|
8
|
-
ID_CARD = "id_card"
|
|
9
|
-
PASSPORT = "passport"
|
|
10
8
|
|
|
11
9
|
@classmethod
|
|
12
10
|
def choices(cls) -> ListOfStrs:
|
|
13
11
|
return [e.value for e in cls]
|
|
12
|
+
|
|
13
|
+
@property
|
|
14
|
+
def column(self) -> str:
|
|
15
|
+
return self.value
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ExpandableField(StrEnum):
|
|
19
|
+
GENDER = "gender"
|
|
20
|
+
BLOOD_TYPE = "blood_type"
|
|
21
|
+
|
|
22
|
+
@classmethod
|
|
23
|
+
def choices(cls) -> ListOfStrs:
|
|
24
|
+
return [e.value for e in cls]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
OptExpandableField = ExpandableField | None
|
|
28
|
+
ListOfExpandableFields = list[ExpandableField]
|
|
29
|
+
OptListOfExpandableFields = ListOfExpandableFields | None
|
maleo/identity/enums/user.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from enum import StrEnum
|
|
2
|
-
from maleo.types.string import ListOfStrs
|
|
2
|
+
from maleo.types.string import ListOfStrs, ManyStrs
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class IdentifierType(StrEnum):
|
|
@@ -10,3 +10,13 @@ class IdentifierType(StrEnum):
|
|
|
10
10
|
@classmethod
|
|
11
11
|
def choices(cls) -> ListOfStrs:
|
|
12
12
|
return [e.value for e in cls]
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def columns(self) -> ManyStrs:
|
|
16
|
+
if self is IdentifierType.ID:
|
|
17
|
+
return ("id",)
|
|
18
|
+
elif self is IdentifierType.UUID:
|
|
19
|
+
return ("uuid",)
|
|
20
|
+
elif self is IdentifierType.COMPOSITE:
|
|
21
|
+
return ("user_id", "organization_id", "medical_role")
|
|
22
|
+
raise ValueError(f"Unknown column(s) for identifier type: {self}")
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from enum import StrEnum
|
|
2
|
-
from maleo.types.string import ListOfStrs
|
|
2
|
+
from maleo.types.string import ListOfStrs, ManyStrs
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class IdentifierType(StrEnum):
|
|
@@ -10,3 +10,13 @@ class IdentifierType(StrEnum):
|
|
|
10
10
|
@classmethod
|
|
11
11
|
def choices(cls) -> ListOfStrs:
|
|
12
12
|
return [e.value for e in cls]
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def columns(self) -> ManyStrs:
|
|
16
|
+
if self is IdentifierType.ID:
|
|
17
|
+
return ("id",)
|
|
18
|
+
elif self is IdentifierType.UUID:
|
|
19
|
+
return ("uuid",)
|
|
20
|
+
elif self is IdentifierType.COMPOSITE:
|
|
21
|
+
return ("user_id", "organization_id", "organization_role")
|
|
22
|
+
raise ValueError(f"Unknown column(s) for identifier type: {self}")
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from enum import StrEnum
|
|
2
|
-
from maleo.types.string import ListOfStrs
|
|
2
|
+
from maleo.types.string import ListOfStrs, ManyStrs
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class IdentifierType(StrEnum):
|
|
@@ -10,3 +10,26 @@ class IdentifierType(StrEnum):
|
|
|
10
10
|
@classmethod
|
|
11
11
|
def choices(cls) -> ListOfStrs:
|
|
12
12
|
return [e.value for e in cls]
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def columns(self) -> ManyStrs:
|
|
16
|
+
if self is IdentifierType.ID:
|
|
17
|
+
return ("id",)
|
|
18
|
+
elif self is IdentifierType.UUID:
|
|
19
|
+
return ("uuid",)
|
|
20
|
+
elif self is IdentifierType.COMPOSITE:
|
|
21
|
+
return ("user_id", "system_role")
|
|
22
|
+
raise ValueError(f"Unknown column(s) for identifier type: {self}")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ExpandableField(StrEnum):
|
|
26
|
+
SYSTEM_ROLE = "system_role"
|
|
27
|
+
|
|
28
|
+
@classmethod
|
|
29
|
+
def choices(cls) -> ListOfStrs:
|
|
30
|
+
return [e.value for e in cls]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
OptExpandableField = ExpandableField | None
|
|
34
|
+
ListOfExpandableFields = list[ExpandableField]
|
|
35
|
+
OptListOfExpandableFields = ListOfExpandableFields | None
|
maleo/identity/mixins/api_key.py
CHANGED
|
@@ -2,8 +2,10 @@ 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 maleo.types.any import ManyAny
|
|
6
|
+
from maleo.types.string import ManyStrs
|
|
5
7
|
from ..enums.api_key import IdentifierType
|
|
6
|
-
from ..types.api_key import
|
|
8
|
+
from ..types.api_key import CompositeIdentifierType, IdentifierValueType
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
class APIKey(BaseModel):
|
|
@@ -11,7 +13,10 @@ class APIKey(BaseModel):
|
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
class APIKeyIdentifier(Identifier[IdentifierType, IdentifierValueType]):
|
|
14
|
-
|
|
16
|
+
@property
|
|
17
|
+
def columns_and_values(self) -> tuple[ManyStrs, ManyAny]:
|
|
18
|
+
values = self.value if isinstance(self.value, tuple) else (self.value,)
|
|
19
|
+
return self.type.columns, values
|
|
15
20
|
|
|
16
21
|
|
|
17
22
|
class IdAPIKeyIdentifier(Identifier[Literal[IdentifierType.ID], int]):
|
|
@@ -30,13 +35,13 @@ class UUIDAPIKeyIdentifier(Identifier[Literal[IdentifierType.UUID], UUID]):
|
|
|
30
35
|
|
|
31
36
|
|
|
32
37
|
class CompositeAPIKeyIdentifier(
|
|
33
|
-
Identifier[Literal[IdentifierType.COMPOSITE],
|
|
38
|
+
Identifier[Literal[IdentifierType.COMPOSITE], CompositeIdentifierType]
|
|
34
39
|
):
|
|
35
40
|
type: Annotated[
|
|
36
41
|
Literal[IdentifierType.COMPOSITE],
|
|
37
42
|
Field(IdentifierType.COMPOSITE, description="Identifier's type"),
|
|
38
43
|
] = IdentifierType.COMPOSITE
|
|
39
|
-
value: Annotated[
|
|
44
|
+
value: Annotated[CompositeIdentifierType, Field(..., description="Identifier's value")]
|
|
40
45
|
|
|
41
46
|
|
|
42
47
|
AnyAPIKeyIdentifier = (
|
|
@@ -21,7 +21,9 @@ class Secret(BaseModel, Generic[OptUUIDT]):
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
class OrganizationIdentifier(Identifier[IdentifierType, IdentifierValueType]):
|
|
24
|
-
|
|
24
|
+
@property
|
|
25
|
+
def column_and_value(self) -> tuple[str, IdentifierValueType]:
|
|
26
|
+
return self.type.column, self.value
|
|
25
27
|
|
|
26
28
|
|
|
27
29
|
class IdOrganizationIdentifier(Identifier[Literal[IdentifierType.ID], int]):
|
|
@@ -1,15 +1,49 @@
|
|
|
1
|
-
from pydantic import BaseModel, Field
|
|
2
|
-
from typing import Annotated, Generic, Literal, TypeGuard
|
|
1
|
+
from pydantic import BaseModel, Field, model_validator
|
|
2
|
+
from typing import Annotated, Generic, Literal, Self, TypeGuard
|
|
3
3
|
from uuid import UUID
|
|
4
4
|
from maleo.schemas.mixins.identity import Identifier
|
|
5
5
|
from maleo.types.integer import OptIntT
|
|
6
|
+
from maleo.types.misc import OptIntOrStr
|
|
6
7
|
from maleo.types.string import OptStrT
|
|
7
8
|
from ..enums.organization_registration_code import IdentifierType
|
|
8
9
|
from ..types.organization_registration_code import IdentifierValueType
|
|
9
10
|
|
|
10
11
|
|
|
12
|
+
class CodeOrLength(BaseModel):
|
|
13
|
+
code_or_length: Annotated[
|
|
14
|
+
OptIntOrStr,
|
|
15
|
+
Field(
|
|
16
|
+
None,
|
|
17
|
+
description=(
|
|
18
|
+
"Code (str) or length (int). "
|
|
19
|
+
"If code is given, the length must be between 6 and 36 inclusive. "
|
|
20
|
+
"If length is given, the value must be between 6 and 36 inclusive. "
|
|
21
|
+
"Will generate random 6 char string if omitted"
|
|
22
|
+
),
|
|
23
|
+
),
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
@model_validator(mode="after")
|
|
27
|
+
def validate_code_or_length(self) -> Self:
|
|
28
|
+
code_or_length = self.code_or_length
|
|
29
|
+
if code_or_length is None:
|
|
30
|
+
return self
|
|
31
|
+
print(code_or_length)
|
|
32
|
+
if isinstance(code_or_length, int):
|
|
33
|
+
length = code_or_length
|
|
34
|
+
elif isinstance(code_or_length, str):
|
|
35
|
+
length = len(code_or_length)
|
|
36
|
+
else:
|
|
37
|
+
raise ValueError("Code or Length must be either int or str")
|
|
38
|
+
if length < 6 or length > 36:
|
|
39
|
+
raise ValueError("Code or Length must be between 6 and 36 inclusive")
|
|
40
|
+
return self
|
|
41
|
+
|
|
42
|
+
|
|
11
43
|
class Code(BaseModel, Generic[OptStrT]):
|
|
12
|
-
code: Annotated[
|
|
44
|
+
code: Annotated[
|
|
45
|
+
OptStrT, Field(..., description="Code", min_length=6, max_length=36)
|
|
46
|
+
]
|
|
13
47
|
|
|
14
48
|
|
|
15
49
|
class MaxUses(BaseModel, Generic[OptIntT]):
|
|
@@ -23,7 +57,9 @@ class CurrentUses(BaseModel):
|
|
|
23
57
|
class OrganizationRegistrationCodeIdentifier(
|
|
24
58
|
Identifier[IdentifierType, IdentifierValueType]
|
|
25
59
|
):
|
|
26
|
-
|
|
60
|
+
@property
|
|
61
|
+
def column_and_value(self) -> tuple[str, IdentifierValueType]:
|
|
62
|
+
return self.type.column, self.value
|
|
27
63
|
|
|
28
64
|
|
|
29
65
|
class IdOrganizationRegistrationCodeIdentifier(
|
|
@@ -2,10 +2,12 @@ from pydantic import BaseModel, Field
|
|
|
2
2
|
from typing import Annotated, Generic, Literal, TypeGuard
|
|
3
3
|
from uuid import UUID
|
|
4
4
|
from maleo.schemas.mixins.identity import Identifier
|
|
5
|
+
from maleo.types.any import ManyAny
|
|
5
6
|
from maleo.types.boolean import OptBoolT
|
|
6
7
|
from maleo.types.misc import OptListOfAnyOrStrToAnyDict
|
|
8
|
+
from maleo.types.string import ManyStrs
|
|
7
9
|
from ..enums.organization_relation import IdentifierType
|
|
8
|
-
from ..types.organization_relation import
|
|
10
|
+
from ..types.organization_relation import CompositeIdentifierType, IdentifierValueType
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
class IsBidirectional(BaseModel, Generic[OptBoolT]):
|
|
@@ -17,7 +19,10 @@ class Meta(BaseModel):
|
|
|
17
19
|
|
|
18
20
|
|
|
19
21
|
class OrganizationRelationIdentifier(Identifier[IdentifierType, IdentifierValueType]):
|
|
20
|
-
|
|
22
|
+
@property
|
|
23
|
+
def columns_and_values(self) -> tuple[ManyStrs, ManyAny]:
|
|
24
|
+
values = self.value if isinstance(self.value, tuple) else (self.value,)
|
|
25
|
+
return self.type.columns, values
|
|
21
26
|
|
|
22
27
|
|
|
23
28
|
class IdOrganizationRelationIdentifier(Identifier[Literal[IdentifierType.ID], int]):
|
|
@@ -38,13 +43,13 @@ class UUIDOrganizationRelationIdentifier(
|
|
|
38
43
|
|
|
39
44
|
|
|
40
45
|
class CompositeOrganizationRelationIdentifier(
|
|
41
|
-
Identifier[Literal[IdentifierType.COMPOSITE],
|
|
46
|
+
Identifier[Literal[IdentifierType.COMPOSITE], CompositeIdentifierType]
|
|
42
47
|
):
|
|
43
48
|
type: Annotated[
|
|
44
49
|
Literal[IdentifierType.COMPOSITE],
|
|
45
50
|
Field(IdentifierType.COMPOSITE, description="Identifier's type"),
|
|
46
51
|
] = IdentifierType.COMPOSITE
|
|
47
|
-
value: Annotated[
|
|
52
|
+
value: Annotated[CompositeIdentifierType, Field(..., description="Identifier's value")]
|
|
48
53
|
|
|
49
54
|
|
|
50
55
|
AnyOrganizationRelationIdentifier = (
|
maleo/identity/mixins/patient.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
from pydantic import Field, model_validator
|
|
1
|
+
from pydantic import BaseModel, Field, model_validator
|
|
2
2
|
from typing import Annotated, Generic, Literal, Self, TypeGuard
|
|
3
3
|
from uuid import UUID
|
|
4
|
-
from maleo.schemas.mixins.identity import Identifier
|
|
5
|
-
from maleo.schemas.mixins.identity import Passport as BasePassport
|
|
4
|
+
from maleo.schemas.mixins.identity import Identifier, Passport as BasePassport
|
|
6
5
|
from maleo.types.string import OptStr, OptStrT
|
|
7
|
-
from ..enums.patient import IdentifierType
|
|
6
|
+
from ..enums.patient import IdentifierType, OptListOfExpandableFields
|
|
8
7
|
from ..types.patient import IdentifierValueType
|
|
9
8
|
from .common import IdCard
|
|
10
9
|
|
|
@@ -24,8 +23,16 @@ class PatientIdentity(
|
|
|
24
23
|
return self
|
|
25
24
|
|
|
26
25
|
|
|
26
|
+
class Expand(BaseModel):
|
|
27
|
+
expand: Annotated[
|
|
28
|
+
OptListOfExpandableFields, Field(None, description="Expanded field(s)")
|
|
29
|
+
] = None
|
|
30
|
+
|
|
31
|
+
|
|
27
32
|
class PatientIdentifier(Identifier[IdentifierType, IdentifierValueType]):
|
|
28
|
-
|
|
33
|
+
@property
|
|
34
|
+
def column_and_value(self) -> tuple[str, IdentifierValueType]:
|
|
35
|
+
return self.type.column, self.value
|
|
29
36
|
|
|
30
37
|
|
|
31
38
|
class IdPatientIdentifier(Identifier[Literal[IdentifierType.ID], int]):
|
|
@@ -43,29 +50,7 @@ class UUIDPatientIdentifier(Identifier[Literal[IdentifierType.UUID], UUID]):
|
|
|
43
50
|
] = IdentifierType.UUID
|
|
44
51
|
|
|
45
52
|
|
|
46
|
-
|
|
47
|
-
type: Annotated[
|
|
48
|
-
Literal[IdentifierType.ID_CARD],
|
|
49
|
-
Field(IdentifierType.ID_CARD, description="Identifier's type"),
|
|
50
|
-
] = IdentifierType.ID_CARD
|
|
51
|
-
value: Annotated[str, Field(..., description="Identifier's value", max_length=16)]
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
class PassportPatientIdentifier(Identifier[Literal[IdentifierType.PASSPORT], str]):
|
|
55
|
-
type: Annotated[
|
|
56
|
-
Literal[IdentifierType.PASSPORT],
|
|
57
|
-
Field(IdentifierType.PASSPORT, description="Identifier's type"),
|
|
58
|
-
] = IdentifierType.PASSPORT
|
|
59
|
-
value: Annotated[str, Field(..., description="Identifier's value", max_length=9)]
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
AnyPatientIdentifier = (
|
|
63
|
-
PatientIdentifier
|
|
64
|
-
| IdPatientIdentifier
|
|
65
|
-
| UUIDPatientIdentifier
|
|
66
|
-
| IdCardPatientIdentifier
|
|
67
|
-
| PassportPatientIdentifier
|
|
68
|
-
)
|
|
53
|
+
AnyPatientIdentifier = PatientIdentifier | IdPatientIdentifier | UUIDPatientIdentifier
|
|
69
54
|
|
|
70
55
|
|
|
71
56
|
def is_id_identifier(
|
|
@@ -78,19 +63,3 @@ def is_uuid_identifier(
|
|
|
78
63
|
identifier: AnyPatientIdentifier,
|
|
79
64
|
) -> TypeGuard[UUIDPatientIdentifier]:
|
|
80
65
|
return identifier.type is IdentifierType.UUID and isinstance(identifier.value, UUID)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def is_id_card_identifier(
|
|
84
|
-
identifier: AnyPatientIdentifier,
|
|
85
|
-
) -> TypeGuard[IdCardPatientIdentifier]:
|
|
86
|
-
return identifier.type is IdentifierType.ID_CARD and isinstance(
|
|
87
|
-
identifier.value, str
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
def is_passport_identifier(
|
|
92
|
-
identifier: AnyPatientIdentifier,
|
|
93
|
-
) -> TypeGuard[PassportPatientIdentifier]:
|
|
94
|
-
return identifier.type is IdentifierType.PASSPORT and isinstance(
|
|
95
|
-
identifier.value, str
|
|
96
|
-
)
|
maleo/identity/mixins/user.py
CHANGED
|
@@ -38,7 +38,9 @@ class Password(BaseModel):
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
class UserIdentifier(Identifier[IdentifierType, IdentifierValueType]):
|
|
41
|
-
|
|
41
|
+
@property
|
|
42
|
+
def column_and_value(self) -> tuple[str, IdentifierValueType]:
|
|
43
|
+
return self.type.column, self.value
|
|
42
44
|
|
|
43
45
|
|
|
44
46
|
class IdUserIdentifier(Identifier[Literal[IdentifierType.ID], int]):
|
|
@@ -2,12 +2,17 @@ from pydantic import 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 maleo.types.any import ManyAny
|
|
6
|
+
from maleo.types.string import ManyStrs
|
|
5
7
|
from ..enums.user_medical_role import IdentifierType
|
|
6
|
-
from ..types.user_medical_role import
|
|
8
|
+
from ..types.user_medical_role import CompositeIdentifierType, IdentifierValueType
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
class UserMedicalRoleIdentifier(Identifier[IdentifierType, IdentifierValueType]):
|
|
10
|
-
|
|
12
|
+
@property
|
|
13
|
+
def columns_and_values(self) -> tuple[ManyStrs, ManyAny]:
|
|
14
|
+
values = self.value if isinstance(self.value, tuple) else (self.value,)
|
|
15
|
+
return self.type.columns, values
|
|
11
16
|
|
|
12
17
|
|
|
13
18
|
class IdUserMedicalRoleIdentifier(Identifier[Literal[IdentifierType.ID], int]):
|
|
@@ -26,13 +31,13 @@ class UUIDUserMedicalRoleIdentifier(Identifier[Literal[IdentifierType.UUID], UUI
|
|
|
26
31
|
|
|
27
32
|
|
|
28
33
|
class CompositeUserMedicalRoleIdentifier(
|
|
29
|
-
Identifier[Literal[IdentifierType.COMPOSITE],
|
|
34
|
+
Identifier[Literal[IdentifierType.COMPOSITE], CompositeIdentifierType]
|
|
30
35
|
):
|
|
31
36
|
type: Annotated[
|
|
32
37
|
Literal[IdentifierType.COMPOSITE],
|
|
33
38
|
Field(IdentifierType.COMPOSITE, description="Identifier's type"),
|
|
34
39
|
] = IdentifierType.COMPOSITE
|
|
35
|
-
value: Annotated[
|
|
40
|
+
value: Annotated[CompositeIdentifierType, Field(..., description="Identifier's value")]
|
|
36
41
|
|
|
37
42
|
|
|
38
43
|
AnyUserMedicalRoleIdentifier = (
|
|
@@ -2,12 +2,17 @@ from pydantic import 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 maleo.types.any import ManyAny
|
|
6
|
+
from maleo.types.string import ManyStrs
|
|
5
7
|
from ..enums.user_organization_role import IdentifierType
|
|
6
|
-
from ..types.user_organization_role import
|
|
8
|
+
from ..types.user_organization_role import CompositeIdentifierType, IdentifierValueType
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
class UserOrganizationRoleIdentifier(Identifier[IdentifierType, IdentifierValueType]):
|
|
10
|
-
|
|
12
|
+
@property
|
|
13
|
+
def columns_and_values(self) -> tuple[ManyStrs, ManyAny]:
|
|
14
|
+
values = self.value if isinstance(self.value, tuple) else (self.value,)
|
|
15
|
+
return self.type.columns, values
|
|
11
16
|
|
|
12
17
|
|
|
13
18
|
class IdUserOrganizationRoleIdentifier(Identifier[Literal[IdentifierType.ID], int]):
|
|
@@ -28,13 +33,13 @@ class UUIDUserOrganizationRoleIdentifier(
|
|
|
28
33
|
|
|
29
34
|
|
|
30
35
|
class CompositeUserOrganizationRoleIdentifier(
|
|
31
|
-
Identifier[Literal[IdentifierType.COMPOSITE],
|
|
36
|
+
Identifier[Literal[IdentifierType.COMPOSITE], CompositeIdentifierType]
|
|
32
37
|
):
|
|
33
38
|
type: Annotated[
|
|
34
39
|
Literal[IdentifierType.COMPOSITE],
|
|
35
40
|
Field(IdentifierType.COMPOSITE, description="Identifier's type"),
|
|
36
41
|
] = IdentifierType.COMPOSITE
|
|
37
|
-
value: Annotated[
|
|
42
|
+
value: Annotated[CompositeIdentifierType, Field(..., description="Identifier's value")]
|
|
38
43
|
|
|
39
44
|
|
|
40
45
|
AnyUserOrganizationRoleIdentifier = (
|
|
@@ -46,7 +46,9 @@ class AvatarUrl(BaseModel, Generic[OptStrT]):
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
class UserProfileIdentifier(Identifier[IdentifierType, IdentifierValueType]):
|
|
49
|
-
|
|
49
|
+
@property
|
|
50
|
+
def column_and_value(self) -> tuple[str, IdentifierValueType]:
|
|
51
|
+
return self.type.column, self.value
|
|
50
52
|
|
|
51
53
|
|
|
52
54
|
class IdUserProfileIdentifier(Identifier[Literal[IdentifierType.ID], int]):
|