healthdatalayer 1.4.4__tar.gz → 1.4.5__tar.gz
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 healthdatalayer might be problematic. Click here for more details.
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/PKG-INFO +1 -1
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/medical_visit/medical_visit.py +3 -2
- healthdatalayer-1.4.5/healthdatalayer/models/medical_visit/status_visit_enum.py +8 -0
- healthdatalayer-1.4.5/healthdatalayer/repositories/medical_visit_repositories/medical_visit_repository.py +234 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer.egg-info/PKG-INFO +1 -1
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer.egg-info/SOURCES.txt +1 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/setup.py +1 -1
- healthdatalayer-1.4.4/healthdatalayer/repositories/medical_visit_repositories/medical_visit_repository.py +0 -110
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/README.md +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/__init__.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/config/__init__.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/config/config.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/config/db.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/config/vault.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/__init__.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/bridge_area_floor_branch/__init__.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/bridge_area_floor_branch/area.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/bridge_area_floor_branch/branch.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/bridge_area_floor_branch/bridge_area_floor_branch.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/bridge_area_floor_branch/floor.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/bridge_area_floor_branch/room.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/bridge_area_floor_branch/system.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/client/__init__.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/client/address.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/client/city.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/client/client.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/client/client_type.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/client/education.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/client/emergency_contact.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/client/gender.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/client/marriage_status.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/client/nationality.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/client/pathological_history.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/client/pet.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/client/profession.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/client/px.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/client/state.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/collaborator/__init__.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/collaborator/collaborator.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/collaborator/collaborator_speciality.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/collaborator/collaborator_type.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/collaborator/speciality.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/lab/__init__.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/lab/client_lab.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/lab/measure_lab.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/lab/medical_lab.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/medical_visit/__init__.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/medical_visit/medical_diagnosis.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/medical_visit/medical_diagnosis_visit.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/medical_visit/medical_drug.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/medical_visit/medical_drug_recipe.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/medical_visit/medical_recipe_visit.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/medical_visit/organ_system_review.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/medical_visit/physical_exam.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/medical_visit/visit_triage.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/user/__init__.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/user/permission.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/user/permission_user.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/user/role.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/user/role_permission.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/user/role_user.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/user/user.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/__init__.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/client_repositories/__init__.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/client_repositories/address_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/client_repositories/client_type_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/client_repositories/education_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/client_repositories/emergency_contact_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/client_repositories/gender_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/client_repositories/marriage_status_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/client_repositories/nationality_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/client_repositories/pathological_history_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/client_repositories/pet_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/client_repositories/profession_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/client_repositories/px_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/collaborator_repositories/__init__.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/collaborator_repositories/collaborator_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/collaborator_repositories/collaborator_type_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/collaborator_repositories/speciality_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/infraestructure_repositories/__init__.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/infraestructure_repositories/area_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/infraestructure_repositories/branch_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/infraestructure_repositories/bridge_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/infraestructure_repositories/floor_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/infraestructure_repositories/room_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/infraestructure_repositories/system_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/lab_repositories/__init__.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/lab_repositories/measure_lab_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/lab_repositories/medical_lab_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/medical_visit_repositories/__init__.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/medical_visit_repositories/medical_diagnosis_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/medical_visit_repositories/medical_diagnosis_visit_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/medical_visit_repositories/medical_drug_recipe_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/medical_visit_repositories/medical_drug_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/medical_visit_repositories/medical_recipe_visit_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/medical_visit_repositories/organ_system_review_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/medical_visit_repositories/physical_exam_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/medical_visit_repositories/visit_triage_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/user_repositories/__init__.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/user_repositories/permission_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/user_repositories/role_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/repositories/user_repositories/user_repository.py +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer.egg-info/dependency_links.txt +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer.egg-info/requires.txt +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer.egg-info/top_level.txt +0 -0
- {healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/setup.cfg +0 -0
|
@@ -2,9 +2,10 @@ import uuid
|
|
|
2
2
|
from datetime import datetime
|
|
3
3
|
from typing import Optional, List, TYPE_CHECKING
|
|
4
4
|
from sqlmodel import SQLModel, Field, Relationship
|
|
5
|
+
from sqlalchemy import Column, Enum as SqlEnum
|
|
5
6
|
|
|
6
7
|
from healthdatalayer.models import Collaborator
|
|
7
|
-
|
|
8
|
+
from healthdatalayer.models.medical_visit.status_visit_enum import StatusVisitEnum
|
|
8
9
|
from healthdatalayer.models import Speciality
|
|
9
10
|
from healthdatalayer.models import BridgeAreaFloorBranch
|
|
10
11
|
if TYPE_CHECKING:
|
|
@@ -28,7 +29,7 @@ class MedicalVisit(SQLModel, table=True):
|
|
|
28
29
|
speciality_id:Optional[uuid.UUID]=Field(default=None,foreign_key="speciality.speciality_id")
|
|
29
30
|
speciality: Optional[Speciality] = Relationship()
|
|
30
31
|
|
|
31
|
-
status_visit:
|
|
32
|
+
status_visit: StatusVisitEnum = Field(sa_column=Column(SqlEnum(StatusVisitEnum, native_enum=False), nullable=False))
|
|
32
33
|
|
|
33
34
|
next_followup_visit_id:Optional[uuid.UUID]=Field(default=None,foreign_key="medical_visit.medical_visit_id")
|
|
34
35
|
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
from typing import Optional, List
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
from uuid import UUID
|
|
4
|
+
from sqlmodel import select
|
|
5
|
+
from sqlalchemy.orm import selectinload,joinedload
|
|
6
|
+
from healthdatalayer.models import MedicalVisit
|
|
7
|
+
from healthdatalayer.config.db import engines, get_session
|
|
8
|
+
|
|
9
|
+
class MedicalVisitRepository:
|
|
10
|
+
def __init__(self, tenant: str):
|
|
11
|
+
self.tenant = tenant
|
|
12
|
+
if tenant not in engines:
|
|
13
|
+
raise ValueError(f"Tenant {tenant} is not configured")
|
|
14
|
+
|
|
15
|
+
def create_command(self, medical_visit: MedicalVisit) -> MedicalVisit:
|
|
16
|
+
with get_session(self.tenant) as session:
|
|
17
|
+
session.add(medical_visit)
|
|
18
|
+
session.commit()
|
|
19
|
+
session.refresh(medical_visit)
|
|
20
|
+
return medical_visit
|
|
21
|
+
|
|
22
|
+
def get_by_id_command(self, medical_visit_id: UUID, load_relations: bool = False) -> Optional[MedicalVisit]:
|
|
23
|
+
with get_session(self.tenant) as session:
|
|
24
|
+
|
|
25
|
+
if load_relations:
|
|
26
|
+
statement = select(MedicalVisit).where(MedicalVisit.medical_visit_id == medical_visit_id).options(
|
|
27
|
+
joinedload(MedicalVisit.client),
|
|
28
|
+
joinedload(MedicalVisit.collaborator),
|
|
29
|
+
joinedload(MedicalVisit.speciality),
|
|
30
|
+
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
31
|
+
selectinload(MedicalVisit.medical_recipe_visits),
|
|
32
|
+
selectinload(MedicalVisit.organ_system_reviews),
|
|
33
|
+
selectinload(MedicalVisit.physical_exams)
|
|
34
|
+
)
|
|
35
|
+
medical_visit = session.exec(statement).first()
|
|
36
|
+
|
|
37
|
+
return medical_visit
|
|
38
|
+
else:
|
|
39
|
+
return session.get(MedicalVisit, medical_visit_id)
|
|
40
|
+
|
|
41
|
+
def list_all_command(self, active_only: bool = True, load_relations: bool = False)->List[MedicalVisit]:
|
|
42
|
+
with get_session(self.tenant) as session:
|
|
43
|
+
statement = select(MedicalVisit)
|
|
44
|
+
|
|
45
|
+
if load_relations:
|
|
46
|
+
|
|
47
|
+
statement = select(MedicalVisit).options(
|
|
48
|
+
joinedload(MedicalVisit.client),
|
|
49
|
+
joinedload(MedicalVisit.collaborator),
|
|
50
|
+
joinedload(MedicalVisit.speciality),
|
|
51
|
+
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
52
|
+
selectinload(MedicalVisit.medical_recipe_visits),
|
|
53
|
+
selectinload(MedicalVisit.organ_system_reviews),
|
|
54
|
+
selectinload(MedicalVisit.physical_exams)
|
|
55
|
+
)
|
|
56
|
+
if active_only:
|
|
57
|
+
statement = statement.where(MedicalVisit.is_active == True)
|
|
58
|
+
medical_visits = session.exec(statement).all()
|
|
59
|
+
|
|
60
|
+
return medical_visits
|
|
61
|
+
|
|
62
|
+
statement = select(MedicalVisit)
|
|
63
|
+
return session.exec(statement).all()
|
|
64
|
+
|
|
65
|
+
def get_by_client_id_command(self, client_id: UUID, active_only: bool = True, load_relations: bool = False) -> List[MedicalVisit]:
|
|
66
|
+
with get_session(self.tenant) as session:
|
|
67
|
+
statement = select(MedicalVisit).where(MedicalVisit.client_id == client_id)
|
|
68
|
+
if active_only:
|
|
69
|
+
statement = statement.where(MedicalVisit.is_active == True)
|
|
70
|
+
if load_relations:
|
|
71
|
+
statement = statement.options(
|
|
72
|
+
joinedload(MedicalVisit.client),
|
|
73
|
+
joinedload(MedicalVisit.collaborator),
|
|
74
|
+
joinedload(MedicalVisit.speciality),
|
|
75
|
+
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
76
|
+
selectinload(MedicalVisit.medical_recipe_visits),
|
|
77
|
+
selectinload(MedicalVisit.organ_system_reviews),
|
|
78
|
+
selectinload(MedicalVisit.physical_exams)
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
medical_visits = session.exec(statement).all()
|
|
82
|
+
return medical_visits
|
|
83
|
+
|
|
84
|
+
def get_by_collaborator_id_command(self, collaborator_id: UUID, active_only: bool = True, load_relations: bool = False) -> List[MedicalVisit]:
|
|
85
|
+
with get_session(self.tenant) as session:
|
|
86
|
+
statement = select(MedicalVisit).where(MedicalVisit.collaborator_id == collaborator_id)
|
|
87
|
+
|
|
88
|
+
if active_only:
|
|
89
|
+
statement = statement.where(MedicalVisit.is_active == True)
|
|
90
|
+
if load_relations:
|
|
91
|
+
statement = statement.options(
|
|
92
|
+
joinedload(MedicalVisit.client),
|
|
93
|
+
joinedload(MedicalVisit.collaborator),
|
|
94
|
+
joinedload(MedicalVisit.speciality),
|
|
95
|
+
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
96
|
+
selectinload(MedicalVisit.medical_recipe_visits),
|
|
97
|
+
selectinload(MedicalVisit.organ_system_reviews),
|
|
98
|
+
selectinload(MedicalVisit.physical_exams)
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
medical_visits = session.exec(statement).all()
|
|
102
|
+
return medical_visits
|
|
103
|
+
|
|
104
|
+
def get_by_next_followup_id_command(self, next_followup_id: UUID, active_only: bool = True, load_relations: bool = False) -> List[MedicalVisit]:
|
|
105
|
+
with get_session(self.tenant) as session:
|
|
106
|
+
statement = select(MedicalVisit).where(MedicalVisit.next_followup_visit_id == next_followup_id)
|
|
107
|
+
|
|
108
|
+
if active_only:
|
|
109
|
+
statement = statement.where(MedicalVisit.is_active == True)
|
|
110
|
+
if load_relations:
|
|
111
|
+
statement = statement.options(
|
|
112
|
+
joinedload(MedicalVisit.client),
|
|
113
|
+
joinedload(MedicalVisit.collaborator),
|
|
114
|
+
joinedload(MedicalVisit.speciality),
|
|
115
|
+
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
116
|
+
selectinload(MedicalVisit.medical_recipe_visits),
|
|
117
|
+
selectinload(MedicalVisit.organ_system_reviews),
|
|
118
|
+
selectinload(MedicalVisit.physical_exams)
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
medical_visits = session.exec(statement).all()
|
|
122
|
+
return medical_visits
|
|
123
|
+
|
|
124
|
+
def get_by_collaboratorid_and_daterange_command(self, collaborator_id: UUID, start_date: datetime, end_date: datetime, active_only: bool = True, load_relations: bool = False) -> List[MedicalVisit]:
|
|
125
|
+
with get_session(self.tenant) as session:
|
|
126
|
+
statement = select(MedicalVisit).where(
|
|
127
|
+
MedicalVisit.collaborator_id == collaborator_id,
|
|
128
|
+
MedicalVisit.visit_date >= start_date
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
if end_date is not None:
|
|
132
|
+
statement = statement.where(MedicalVisit.visit_date <= end_date)
|
|
133
|
+
if active_only:
|
|
134
|
+
statement = statement.where(MedicalVisit.is_active == True)
|
|
135
|
+
if load_relations:
|
|
136
|
+
statement = statement.options(
|
|
137
|
+
joinedload(MedicalVisit.client),
|
|
138
|
+
joinedload(MedicalVisit.collaborator),
|
|
139
|
+
joinedload(MedicalVisit.speciality),
|
|
140
|
+
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
141
|
+
selectinload(MedicalVisit.medical_recipe_visits),
|
|
142
|
+
selectinload(MedicalVisit.organ_system_reviews),
|
|
143
|
+
selectinload(MedicalVisit.physical_exams)
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
medical_visits = session.exec(statement).all()
|
|
147
|
+
return medical_visits
|
|
148
|
+
|
|
149
|
+
def get_by_collaboratorid_and_targetdate_command(self, collaborator_id: UUID, target_date: datetime, active_only: bool = True, load_relations: bool = False) -> List[MedicalVisit]:
|
|
150
|
+
with get_session(self.tenant) as session:
|
|
151
|
+
|
|
152
|
+
start_of_day = datetime.combine(target_date.date(), datetime.min.time())
|
|
153
|
+
end_of_day = datetime.combine(target_date.date(), datetime.max.time())
|
|
154
|
+
|
|
155
|
+
statement = select(MedicalVisit).where(
|
|
156
|
+
MedicalVisit.collaborator_id == collaborator_id,
|
|
157
|
+
MedicalVisit.visit_date >= start_of_day,
|
|
158
|
+
MedicalVisit.visit_date <= end_of_day
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
if active_only:
|
|
162
|
+
statement = statement.where(MedicalVisit.is_active == True)
|
|
163
|
+
if load_relations:
|
|
164
|
+
statement = statement.options(
|
|
165
|
+
joinedload(MedicalVisit.client),
|
|
166
|
+
joinedload(MedicalVisit.collaborator),
|
|
167
|
+
joinedload(MedicalVisit.speciality),
|
|
168
|
+
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
169
|
+
selectinload(MedicalVisit.medical_recipe_visits),
|
|
170
|
+
selectinload(MedicalVisit.organ_system_reviews),
|
|
171
|
+
selectinload(MedicalVisit.physical_exams)
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
medical_visits = session.exec(statement).all()
|
|
175
|
+
return medical_visits
|
|
176
|
+
|
|
177
|
+
def get_by_collaboratorid_and_specificdatetime_command(self, collaborator_id: UUID, specific_datetime: datetime, active_only: bool = True, load_relations: bool = False) -> Optional[MedicalVisit]:
|
|
178
|
+
with get_session(self.tenant) as session:
|
|
179
|
+
|
|
180
|
+
statement = select(MedicalVisit).where(
|
|
181
|
+
MedicalVisit.collaborator_id == collaborator_id,
|
|
182
|
+
MedicalVisit.visit_date == specific_datetime
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
if active_only:
|
|
186
|
+
statement = statement.where(MedicalVisit.is_active == True)
|
|
187
|
+
if load_relations:
|
|
188
|
+
statement = statement.options(
|
|
189
|
+
joinedload(MedicalVisit.client),
|
|
190
|
+
joinedload(MedicalVisit.collaborator),
|
|
191
|
+
joinedload(MedicalVisit.speciality),
|
|
192
|
+
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
193
|
+
selectinload(MedicalVisit.medical_recipe_visits),
|
|
194
|
+
selectinload(MedicalVisit.organ_system_reviews),
|
|
195
|
+
selectinload(MedicalVisit.physical_exams)
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
medical_visit = session.exec(statement).first()
|
|
199
|
+
return medical_visit
|
|
200
|
+
|
|
201
|
+
def update_command(self, medical_visit: MedicalVisit) -> MedicalVisit:
|
|
202
|
+
with get_session(self.tenant) as session:
|
|
203
|
+
existing_medical_visit = session.get(MedicalVisit, medical_visit.medical_visit_id)
|
|
204
|
+
if not existing_medical_visit:
|
|
205
|
+
raise ValueError(f"medical_visit with id {medical_visit.medical_visit_id} does not exist")
|
|
206
|
+
|
|
207
|
+
for key, value in medical_visit.dict(exclude_unset=True).items():
|
|
208
|
+
setattr(existing_medical_visit, key, value)
|
|
209
|
+
|
|
210
|
+
bd_medical_visit = session.merge(existing_medical_visit)
|
|
211
|
+
session.commit()
|
|
212
|
+
session.refresh(bd_medical_visit)
|
|
213
|
+
return bd_medical_visit
|
|
214
|
+
|
|
215
|
+
def delete_command(self, medical_visit_id: UUID, soft_delete: bool = False)->None:
|
|
216
|
+
with get_session(self.tenant) as session:
|
|
217
|
+
existing_bridge = session.get(MedicalVisit, medical_visit_id)
|
|
218
|
+
if not existing_bridge:
|
|
219
|
+
raise ValueError(f"MedicalVisit with id {medical_visit_id} does not exist")
|
|
220
|
+
|
|
221
|
+
if soft_delete:
|
|
222
|
+
existing_bridge.is_active = False
|
|
223
|
+
session.add(existing_bridge)
|
|
224
|
+
else:
|
|
225
|
+
session.delete(existing_bridge)
|
|
226
|
+
|
|
227
|
+
session.commit()
|
|
228
|
+
|
|
229
|
+
def exists_by_collaboratoid_and_targetdate_command(self, collaborator_id: UUID, target_date: datetime) -> bool:
|
|
230
|
+
with get_session(self.tenant) as session:
|
|
231
|
+
statement = select(MedicalVisit).where(MedicalVisit.collaborator_id == collaborator_id, MedicalVisit.visit_date == target_date)
|
|
232
|
+
result = session.exec(statement).first()
|
|
233
|
+
return result is not None
|
|
234
|
+
|
|
@@ -51,6 +51,7 @@ healthdatalayer/models/medical_visit/medical_recipe_visit.py
|
|
|
51
51
|
healthdatalayer/models/medical_visit/medical_visit.py
|
|
52
52
|
healthdatalayer/models/medical_visit/organ_system_review.py
|
|
53
53
|
healthdatalayer/models/medical_visit/physical_exam.py
|
|
54
|
+
healthdatalayer/models/medical_visit/status_visit_enum.py
|
|
54
55
|
healthdatalayer/models/medical_visit/visit_triage.py
|
|
55
56
|
healthdatalayer/models/user/__init__.py
|
|
56
57
|
healthdatalayer/models/user/permission.py
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
from typing import Optional, List
|
|
2
|
-
from uuid import UUID
|
|
3
|
-
from sqlmodel import select, or_
|
|
4
|
-
from sqlalchemy.orm import selectinload,joinedload
|
|
5
|
-
from healthdatalayer.models import MedicalVisit
|
|
6
|
-
from healthdatalayer.config.db import engines, get_session
|
|
7
|
-
|
|
8
|
-
class MedicalVisitRepository:
|
|
9
|
-
def __init__(self, tenant: str):
|
|
10
|
-
self.tenant = tenant
|
|
11
|
-
if tenant not in engines:
|
|
12
|
-
raise ValueError(f"Tenant {tenant} is not configured")
|
|
13
|
-
|
|
14
|
-
def create_command(self, medical_visit: MedicalVisit) -> MedicalVisit:
|
|
15
|
-
with get_session(self.tenant) as session:
|
|
16
|
-
session.add(medical_visit)
|
|
17
|
-
session.commit()
|
|
18
|
-
session.refresh(medical_visit)
|
|
19
|
-
return medical_visit
|
|
20
|
-
|
|
21
|
-
def get_by_id_command(self, medical_visit_id: UUID, load_relations: bool = False) -> Optional[MedicalVisit]:
|
|
22
|
-
with get_session(self.tenant) as session:
|
|
23
|
-
|
|
24
|
-
if load_relations:
|
|
25
|
-
statement = select(MedicalVisit).where(MedicalVisit.medical_visit_id == medical_visit_id).options(
|
|
26
|
-
joinedload(MedicalVisit.client),
|
|
27
|
-
joinedload(MedicalVisit.collaborator),
|
|
28
|
-
joinedload(MedicalVisit.speciality),
|
|
29
|
-
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
30
|
-
selectinload(MedicalVisit.medical_recipe_visits),
|
|
31
|
-
selectinload(MedicalVisit.organ_system_reviews),
|
|
32
|
-
selectinload(MedicalVisit.physical_exams)
|
|
33
|
-
)
|
|
34
|
-
medical_visit = session.exec(statement).first()
|
|
35
|
-
|
|
36
|
-
return medical_visit
|
|
37
|
-
else:
|
|
38
|
-
return session.get(MedicalVisit, medical_visit_id)
|
|
39
|
-
|
|
40
|
-
def list_all_command(self, active_only: bool = True, load_relations: bool = False)->List[MedicalVisit]:
|
|
41
|
-
with get_session(self.tenant) as session:
|
|
42
|
-
statement = select(MedicalVisit)
|
|
43
|
-
|
|
44
|
-
if load_relations:
|
|
45
|
-
|
|
46
|
-
statement = select(MedicalVisit).options(
|
|
47
|
-
joinedload(MedicalVisit.client),
|
|
48
|
-
joinedload(MedicalVisit.collaborator),
|
|
49
|
-
joinedload(MedicalVisit.speciality),
|
|
50
|
-
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
51
|
-
selectinload(MedicalVisit.medical_recipe_visits),
|
|
52
|
-
selectinload(MedicalVisit.organ_system_reviews),
|
|
53
|
-
selectinload(MedicalVisit.physical_exams)
|
|
54
|
-
)
|
|
55
|
-
if active_only:
|
|
56
|
-
statement = statement.where(MedicalVisit.is_active == True)
|
|
57
|
-
medical_visits = session.exec(statement).all()
|
|
58
|
-
|
|
59
|
-
return medical_visits
|
|
60
|
-
|
|
61
|
-
statement = select(MedicalVisit)
|
|
62
|
-
return session.exec(statement).all()
|
|
63
|
-
|
|
64
|
-
def get_by_client_id_command(self, client_id: UUID, active_only: bool = True, load_relations: bool = False) -> List[MedicalVisit]:
|
|
65
|
-
with get_session(self.tenant) as session:
|
|
66
|
-
statement = select(MedicalVisit).where(MedicalVisit.client_id == client_id)
|
|
67
|
-
if active_only:
|
|
68
|
-
statement = statement.where(MedicalVisit.is_active == True)
|
|
69
|
-
if load_relations:
|
|
70
|
-
statement = statement.options(
|
|
71
|
-
joinedload(MedicalVisit.client),
|
|
72
|
-
joinedload(MedicalVisit.collaborator),
|
|
73
|
-
joinedload(MedicalVisit.speciality),
|
|
74
|
-
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
75
|
-
selectinload(MedicalVisit.medical_recipe_visits),
|
|
76
|
-
selectinload(MedicalVisit.organ_system_reviews),
|
|
77
|
-
selectinload(MedicalVisit.physical_exams)
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
medical_visits = session.exec(statement).all()
|
|
81
|
-
return medical_visits
|
|
82
|
-
|
|
83
|
-
def update_command(self, medical_visit: MedicalVisit) -> MedicalVisit:
|
|
84
|
-
with get_session(self.tenant) as session:
|
|
85
|
-
existing_medical_visit = session.get(MedicalVisit, medical_visit.medical_visit_id)
|
|
86
|
-
if not existing_medical_visit:
|
|
87
|
-
raise ValueError(f"medical_visit with id {medical_visit.medical_visit_id} does not exist")
|
|
88
|
-
|
|
89
|
-
for key, value in medical_visit.dict(exclude_unset=True).items():
|
|
90
|
-
setattr(existing_medical_visit, key, value)
|
|
91
|
-
|
|
92
|
-
bd_medical_visit = session.merge(existing_medical_visit)
|
|
93
|
-
session.commit()
|
|
94
|
-
session.refresh(bd_medical_visit)
|
|
95
|
-
return bd_medical_visit
|
|
96
|
-
|
|
97
|
-
def delete_command(self, medical_visit_id: UUID, soft_delete: bool = False)->None:
|
|
98
|
-
with get_session(self.tenant) as session:
|
|
99
|
-
existing_bridge = session.get(MedicalVisit, medical_visit_id)
|
|
100
|
-
if not existing_bridge:
|
|
101
|
-
raise ValueError(f"MedicalVisit with id {medical_visit_id} does not exist")
|
|
102
|
-
|
|
103
|
-
if soft_delete:
|
|
104
|
-
existing_bridge.is_active = False
|
|
105
|
-
session.add(existing_bridge)
|
|
106
|
-
else:
|
|
107
|
-
session.delete(existing_bridge)
|
|
108
|
-
|
|
109
|
-
session.commit()
|
|
110
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/client/client_type.py
RENAMED
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/client/emergency_contact.py
RENAMED
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/client/marriage_status.py
RENAMED
|
File without changes
|
{healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/client/nationality.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/collaborator/__init__.py
RENAMED
|
File without changes
|
{healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/collaborator/collaborator.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/collaborator/speciality.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/medical_visit/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/medical_visit/medical_drug.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/medical_visit/visit_triage.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/user/permission_user.py
RENAMED
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer/models/user/role_permission.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.4.4 → healthdatalayer-1.4.5}/healthdatalayer.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|