healthdatalayer 1.4.4__py3-none-any.whl → 1.4.5__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 healthdatalayer might be problematic. Click here for more details.

@@ -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:str
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,8 @@
1
+ from enum import Enum
2
+
3
+ class StatusVisitEnum(str, Enum):
4
+ AGENDADO = "AGENDADO"
5
+ REAGENDADO = "REAGENDADO"
6
+ CANCELADO = "CANCELADO"
7
+ ATENDIDO = "ATENDIDO"
8
+ NO_ATENDIDO = "NO_ATENDIDO"
@@ -1,6 +1,7 @@
1
1
  from typing import Optional, List
2
+ from datetime import datetime
2
3
  from uuid import UUID
3
- from sqlmodel import select, or_
4
+ from sqlmodel import select
4
5
  from sqlalchemy.orm import selectinload,joinedload
5
6
  from healthdatalayer.models import MedicalVisit
6
7
  from healthdatalayer.config.db import engines, get_session
@@ -79,6 +80,123 @@ class MedicalVisitRepository:
79
80
 
80
81
  medical_visits = session.exec(statement).all()
81
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
82
200
 
83
201
  def update_command(self, medical_visit: MedicalVisit) -> MedicalVisit:
84
202
  with get_session(self.tenant) as session:
@@ -107,4 +225,10 @@ class MedicalVisitRepository:
107
225
  session.delete(existing_bridge)
108
226
 
109
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
110
234
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: healthdatalayer
3
- Version: 1.4.4
3
+ Version: 1.4.5
4
4
  Summary: Health Datalayer to access data from different sources
5
5
  Author: Jesus Martinez
6
6
  Author-email: jesusmartinez@noosds.com
@@ -41,9 +41,10 @@ healthdatalayer/models/medical_visit/medical_diagnosis_visit.py,sha256=3ZoWxhqln
41
41
  healthdatalayer/models/medical_visit/medical_drug.py,sha256=zG3oqzq0fGZQNkY7AmFZQaHTG7BVQ3kGJ-tgLgfwNdc,829
42
42
  healthdatalayer/models/medical_visit/medical_drug_recipe.py,sha256=DiygpjyX72sc5jD-h9hue5kU0T4YgZyLxD_qVacnxV0,657
43
43
  healthdatalayer/models/medical_visit/medical_recipe_visit.py,sha256=W8E8RAOtow_-NbEr8SBHnoq_huJlx-6zDrJL98vzNQ4,1042
44
- healthdatalayer/models/medical_visit/medical_visit.py,sha256=ow5KTmRCaTj5RBKeQ-gfTms-L3kBgqZl90elSbImsVc,2338
44
+ healthdatalayer/models/medical_visit/medical_visit.py,sha256=3CtXkXiFasuYEXGGHVfAKYu4VSsv8Xj8tTcR-dzqqmI,2567
45
45
  healthdatalayer/models/medical_visit/organ_system_review.py,sha256=fXWbuDfdy6QBBl-c5X14XBHpyCqLqqZdPNbzdq5H58U,1168
46
46
  healthdatalayer/models/medical_visit/physical_exam.py,sha256=VaezGMp4eptJH-mco-SCumATkcpp2xSA6zBtw9LrMFM,1772
47
+ healthdatalayer/models/medical_visit/status_visit_enum.py,sha256=p4krEZXsXpeAtedCwlj1vcPMPM9y-LHWHfkOVEgZtBY,199
47
48
  healthdatalayer/models/medical_visit/visit_triage.py,sha256=RrTQ_ckAkOTdNfHXetqKt3a1VmvHSkMZ_5VkGvJQheE,1093
48
49
  healthdatalayer/models/user/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
50
  healthdatalayer/models/user/permission.py,sha256=U4sU_l68X7lMIooaxJN3aZ7eVJT-DDCTI_ApKyvPo-E,801
@@ -85,7 +86,7 @@ healthdatalayer/repositories/medical_visit_repositories/medical_diagnosis_visit_
85
86
  healthdatalayer/repositories/medical_visit_repositories/medical_drug_recipe_repository.py,sha256=6rubP_KtheyJSvLmpBJwYuPKNsjhSvKi-_HM2QoP1hM,3141
86
87
  healthdatalayer/repositories/medical_visit_repositories/medical_drug_repository.py,sha256=mJNN6_aAK3eY9IpFc16nT3IshObGcFE5fi27SK-Sjio,2401
87
88
  healthdatalayer/repositories/medical_visit_repositories/medical_recipe_visit_repository.py,sha256=j4cJ4zURKILN3lkqfpXya29MQYFIMiTmJukOADBj5_c,4551
88
- healthdatalayer/repositories/medical_visit_repositories/medical_visit_repository.py,sha256=r6l4L2AuStV_9NO208_GG8REJRnFtHBU2zx0BjnYuCI,5151
89
+ healthdatalayer/repositories/medical_visit_repositories/medical_visit_repository.py,sha256=BmPLxuB22QOPukAAduIKwWq5lQkhKdILF4AuCF7Bj-s,11693
89
90
  healthdatalayer/repositories/medical_visit_repositories/organ_system_review_repository.py,sha256=-BTfgzvt8VlE2FsBHX3snzRl2VDrRClqz-dJL3bLheE,4192
90
91
  healthdatalayer/repositories/medical_visit_repositories/physical_exam_repository.py,sha256=Q4R2-6fv57jqZrGUMFQw4YZgZGQbn8UmSRS3UhUSZQg,3877
91
92
  healthdatalayer/repositories/medical_visit_repositories/visit_triage_repository.py,sha256=0xVnhXV2CSNi2FcW2tG_BGsqlm_oA9jvXP5qz5Aqj_c,3821
@@ -93,7 +94,7 @@ healthdatalayer/repositories/user_repositories/__init__.py,sha256=47DEQpj8HBSa-_
93
94
  healthdatalayer/repositories/user_repositories/permission_repository.py,sha256=3L4y-zCkI2PIRo-L3FJRSk4g3nZnu6q35lEY4ACJyq4,9630
94
95
  healthdatalayer/repositories/user_repositories/role_repository.py,sha256=jIsbeAFFQQ_CZJqBMcOskuMXtT1Il6eiN0Y2BpVO1JE,6821
95
96
  healthdatalayer/repositories/user_repositories/user_repository.py,sha256=FUCNdRRGc12dq5XuwDT3btvDETt6HGXh_xQIPTLCAvk,9839
96
- healthdatalayer-1.4.4.dist-info/METADATA,sha256=Bve8ZfDL4fPSh3MDTlCtYY0HSC-t2mCTT2y2x1Iskx4,827
97
- healthdatalayer-1.4.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
98
- healthdatalayer-1.4.4.dist-info/top_level.txt,sha256=6f1-gvpg533UEVuYsRJCDhdSDQUBwijyAHylyS4nG_4,16
99
- healthdatalayer-1.4.4.dist-info/RECORD,,
97
+ healthdatalayer-1.4.5.dist-info/METADATA,sha256=8JRrMnan-t3mU9GK2JZ_dYAW2nUjvg3de0Mm04juGKY,827
98
+ healthdatalayer-1.4.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
99
+ healthdatalayer-1.4.5.dist-info/top_level.txt,sha256=6f1-gvpg533UEVuYsRJCDhdSDQUBwijyAHylyS4nG_4,16
100
+ healthdatalayer-1.4.5.dist-info/RECORD,,