healthdatalayer 1.5.2__py3-none-any.whl → 1.5.4__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
@@ -120,7 +120,67 @@ class MedicalVisitRepository:
120
120
 
121
121
  medical_visits = session.exec(statement).all()
122
122
  return medical_visits
123
+
124
+ def get_by_daterange_command(self, 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.visit_date >= start_date
128
+ )
129
+
130
+ if end_date is not None:
131
+ statement = statement.where(MedicalVisit.visit_date <= end_date)
132
+ if active_only:
133
+ statement = statement.where(MedicalVisit.is_active == True)
134
+ if load_relations:
135
+ statement = statement.options(
136
+ joinedload(MedicalVisit.client),
137
+ joinedload(MedicalVisit.collaborator),
138
+ joinedload(MedicalVisit.speciality),
139
+ selectinload(MedicalVisit.medical_diagnosis_visits),
140
+ selectinload(MedicalVisit.medical_recipe_visits),
141
+ selectinload(MedicalVisit.organ_system_reviews),
142
+ selectinload(MedicalVisit.physical_exams)
143
+ )
144
+
145
+ medical_visits = session.exec(statement).all()
146
+ return medical_visits
123
147
 
148
+ def get_by_targetdate_command(self, target_date: datetime, active_only: bool = True, load_relations: bool = False) -> List[MedicalVisit]:
149
+ with get_session(self.tenant) as session:
150
+
151
+ if isinstance(target_date, str):
152
+ try:
153
+ target_date = datetime.strptime(target_date, "%Y-%m-%d")
154
+ except ValueError:
155
+ raise ValueError("Invalid date format")
156
+
157
+ elif isinstance(target_date, date) and not isinstance(target_date, datetime):
158
+ target_date = datetime.combine(target_date, time.min)
159
+
160
+ start_of_day = datetime.combine(target_date.date(), datetime.min.time())
161
+ end_of_day = datetime.combine(target_date.date(), datetime.max.time())
162
+
163
+ statement = select(MedicalVisit).where(
164
+ MedicalVisit.visit_date >= start_of_day,
165
+ MedicalVisit.visit_date <= end_of_day
166
+ )
167
+
168
+ if active_only:
169
+ statement = statement.where(MedicalVisit.is_active == True)
170
+ if load_relations:
171
+ statement = statement.options(
172
+ joinedload(MedicalVisit.client),
173
+ joinedload(MedicalVisit.collaborator),
174
+ joinedload(MedicalVisit.speciality),
175
+ selectinload(MedicalVisit.medical_diagnosis_visits),
176
+ selectinload(MedicalVisit.medical_recipe_visits),
177
+ selectinload(MedicalVisit.organ_system_reviews),
178
+ selectinload(MedicalVisit.physical_exams)
179
+ )
180
+
181
+ medical_visits = session.exec(statement).all()
182
+ return medical_visits
183
+
124
184
  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
185
  with get_session(self.tenant) as session:
126
186
  statement = select(MedicalVisit).where(
@@ -149,6 +209,15 @@ class MedicalVisitRepository:
149
209
  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
210
  with get_session(self.tenant) as session:
151
211
 
212
+ if isinstance(target_date, str):
213
+ try:
214
+ target_date = datetime.strptime(target_date, "%Y-%m-%d")
215
+ except ValueError:
216
+ raise ValueError("Invalid date format")
217
+
218
+ elif isinstance(target_date, date) and not isinstance(target_date, datetime):
219
+ target_date = datetime.combine(target_date, time.min)
220
+
152
221
  start_of_day = datetime.combine(target_date.date(), datetime.min.time())
153
222
  end_of_day = datetime.combine(target_date.date(), datetime.max.time())
154
223
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: healthdatalayer
3
- Version: 1.5.2
3
+ Version: 1.5.4
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=EcnFzcj0wyZN3AVpqNc8SGYJVCG_OUHvajQt3b2a9H4,13853
92
+ healthdatalayer/repositories/medical_visit_repositories/medical_visit_repository.py,sha256=vATKxoBimx_-VYtqnxx-6u4sdU7u8sjtE2y6Kr2uepM,17186
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.2.dist-info/METADATA,sha256=ZMt-9bN5bYCyFoch-0_KY6QObIEfsPfB8HSkSLJfwC4,827
101
- healthdatalayer-1.5.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
102
- healthdatalayer-1.5.2.dist-info/top_level.txt,sha256=6f1-gvpg533UEVuYsRJCDhdSDQUBwijyAHylyS4nG_4,16
103
- healthdatalayer-1.5.2.dist-info/RECORD,,
100
+ healthdatalayer-1.5.4.dist-info/METADATA,sha256=bqu_siXQB-Xn2dwFXeurSFOXdCZT5SqIrZRA57b7Yxc,827
101
+ healthdatalayer-1.5.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
102
+ healthdatalayer-1.5.4.dist-info/top_level.txt,sha256=6f1-gvpg533UEVuYsRJCDhdSDQUBwijyAHylyS4nG_4,16
103
+ healthdatalayer-1.5.4.dist-info/RECORD,,