healthdatalayer 1.5.1__py3-none-any.whl → 1.5.3__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.

@@ -1,5 +1,5 @@
1
1
  from typing import Optional, List
2
- from datetime import datetime
2
+ from datetime import datetime, date, time
3
3
  from uuid import UUID
4
4
  from sqlmodel import select
5
5
  from sqlalchemy.orm import selectinload,joinedload
@@ -149,6 +149,15 @@ class MedicalVisitRepository:
149
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
150
  with get_session(self.tenant) as session:
151
151
 
152
+ if isinstance(target_date, str):
153
+ try:
154
+ target_date = datetime.strptime(target_date, "%Y-%m-%d")
155
+ except ValueError:
156
+ raise ValueError("Invalid date format")
157
+
158
+ elif isinstance(target_date, date) and not isinstance(target_date, datetime):
159
+ target_date = datetime.combine(target_date, time.min)
160
+
152
161
  start_of_day = datetime.combine(target_date.date(), datetime.min.time())
153
162
  end_of_day = datetime.combine(target_date.date(), datetime.max.time())
154
163
 
@@ -197,6 +206,48 @@ class MedicalVisitRepository:
197
206
 
198
207
  medical_visit = session.exec(statement).first()
199
208
  return medical_visit
209
+
210
+ def get_first_by_clientid_command(self, client_id: UUID, active_only: bool = True, load_relations: bool = False) -> Optional[MedicalVisit]:
211
+ with get_session(self.tenant) as session:
212
+
213
+ statement = select(MedicalVisit).where(MedicalVisit.client_id == client_id).order_by(MedicalVisit.visit_date.asc())
214
+
215
+ if active_only:
216
+ statement = statement.where(MedicalVisit.is_active == True)
217
+ if load_relations:
218
+ statement = statement.options(
219
+ joinedload(MedicalVisit.client),
220
+ joinedload(MedicalVisit.collaborator),
221
+ joinedload(MedicalVisit.speciality),
222
+ selectinload(MedicalVisit.medical_diagnosis_visits),
223
+ selectinload(MedicalVisit.medical_recipe_visits),
224
+ selectinload(MedicalVisit.organ_system_reviews),
225
+ selectinload(MedicalVisit.physical_exams)
226
+ )
227
+
228
+ medical_visit = session.exec(statement).first()
229
+ return medical_visit
230
+
231
+ def get_last_by_clientid_command(self, client_id: UUID, active_only: bool = True, load_relations: bool = False) -> Optional[MedicalVisit]:
232
+ with get_session(self.tenant) as session:
233
+
234
+ statement = select(MedicalVisit).where(MedicalVisit.client_id == client_id).order_by(MedicalVisit.visit_date.desc())
235
+
236
+ if active_only:
237
+ statement = statement.where(MedicalVisit.is_active == True)
238
+ if load_relations:
239
+ statement = statement.options(
240
+ joinedload(MedicalVisit.client),
241
+ joinedload(MedicalVisit.collaborator),
242
+ joinedload(MedicalVisit.speciality),
243
+ selectinload(MedicalVisit.medical_diagnosis_visits),
244
+ selectinload(MedicalVisit.medical_recipe_visits),
245
+ selectinload(MedicalVisit.organ_system_reviews),
246
+ selectinload(MedicalVisit.physical_exams)
247
+ )
248
+
249
+ medical_visit = session.exec(statement).first()
250
+ return medical_visit
200
251
 
201
252
  def update_command(self, medical_visit: MedicalVisit) -> MedicalVisit:
202
253
  with get_session(self.tenant) as session:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: healthdatalayer
3
- Version: 1.5.1
3
+ Version: 1.5.3
4
4
  Summary: Health Datalayer to access data from different sources
5
5
  Author: Jesus Martinez
6
6
  Author-email: jesusmartinez@noosds.com
@@ -89,7 +89,7 @@ healthdatalayer/repositories/medical_visit_repositories/medical_diagnosis_visit_
89
89
  healthdatalayer/repositories/medical_visit_repositories/medical_drug_recipe_repository.py,sha256=6rubP_KtheyJSvLmpBJwYuPKNsjhSvKi-_HM2QoP1hM,3141
90
90
  healthdatalayer/repositories/medical_visit_repositories/medical_drug_repository.py,sha256=mJNN6_aAK3eY9IpFc16nT3IshObGcFE5fi27SK-Sjio,2401
91
91
  healthdatalayer/repositories/medical_visit_repositories/medical_recipe_visit_repository.py,sha256=j4cJ4zURKILN3lkqfpXya29MQYFIMiTmJukOADBj5_c,4551
92
- healthdatalayer/repositories/medical_visit_repositories/medical_visit_repository.py,sha256=BmPLxuB22QOPukAAduIKwWq5lQkhKdILF4AuCF7Bj-s,11693
92
+ healthdatalayer/repositories/medical_visit_repositories/medical_visit_repository.py,sha256=hhHXQZh5T9G5GJgkTqN0jqQ-qiwXejCYbmF7ycwwa_8,14265
93
93
  healthdatalayer/repositories/medical_visit_repositories/organ_system_review_repository.py,sha256=-BTfgzvt8VlE2FsBHX3snzRl2VDrRClqz-dJL3bLheE,4192
94
94
  healthdatalayer/repositories/medical_visit_repositories/physical_exam_repository.py,sha256=Q4R2-6fv57jqZrGUMFQw4YZgZGQbn8UmSRS3UhUSZQg,3877
95
95
  healthdatalayer/repositories/medical_visit_repositories/visit_triage_repository.py,sha256=9Up5M7wWo5GnaYdl6QvTamYaIG4dG_ALM0Su66rlj44,4140
@@ -97,7 +97,7 @@ healthdatalayer/repositories/user_repositories/__init__.py,sha256=47DEQpj8HBSa-_
97
97
  healthdatalayer/repositories/user_repositories/permission_repository.py,sha256=3L4y-zCkI2PIRo-L3FJRSk4g3nZnu6q35lEY4ACJyq4,9630
98
98
  healthdatalayer/repositories/user_repositories/role_repository.py,sha256=jIsbeAFFQQ_CZJqBMcOskuMXtT1Il6eiN0Y2BpVO1JE,6821
99
99
  healthdatalayer/repositories/user_repositories/user_repository.py,sha256=FUCNdRRGc12dq5XuwDT3btvDETt6HGXh_xQIPTLCAvk,9839
100
- healthdatalayer-1.5.1.dist-info/METADATA,sha256=qPMRS9Q3Pgc9-6d7X1zWCbvQNePhBPOmoAmr_olmZm0,827
101
- healthdatalayer-1.5.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
102
- healthdatalayer-1.5.1.dist-info/top_level.txt,sha256=6f1-gvpg533UEVuYsRJCDhdSDQUBwijyAHylyS4nG_4,16
103
- healthdatalayer-1.5.1.dist-info/RECORD,,
100
+ healthdatalayer-1.5.3.dist-info/METADATA,sha256=kgjLX_1bbO11W6ktpeuXw4zBBPacFg1nYuqpZcMHIUs,827
101
+ healthdatalayer-1.5.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
102
+ healthdatalayer-1.5.3.dist-info/top_level.txt,sha256=6f1-gvpg533UEVuYsRJCDhdSDQUBwijyAHylyS4nG_4,16
103
+ healthdatalayer-1.5.3.dist-info/RECORD,,