healthdatalayer 1.5.3__py3-none-any.whl → 1.5.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.
@@ -1,6 +1,6 @@
1
1
  from typing import Optional, List
2
2
  from uuid import UUID
3
- from sqlmodel import select
3
+ from sqlmodel import select, or_
4
4
 
5
5
  from healthdatalayer.models import MedicalDiagnosis
6
6
  from healthdatalayer.config.db import engines, get_session
@@ -32,9 +32,14 @@ class MedicalDiagnosisRepository:
32
32
  medical_diagnosis = session.exec(statement).first()
33
33
  return medical_diagnosis
34
34
 
35
- def get_by_name_ilike_command(self, name:str, active_only: bool = True) -> List[MedicalDiagnosis]:
35
+ def get_by_name_code_ilike_command(self, name:str, active_only: bool = True) -> List[MedicalDiagnosis]:
36
36
  with get_session(self.tenant) as session:
37
- statement = select(MedicalDiagnosis).where(MedicalDiagnosis.name.ilike(f"%{name}%"))
37
+ statement = select(MedicalDiagnosis).where(
38
+ or_(
39
+ MedicalDiagnosis.name.ilike(f"%{name}%"),
40
+ MedicalDiagnosis.cie_10_code.ilike(f"%{name}%")
41
+ )
42
+ )
38
43
 
39
44
  if active_only:
40
45
  statement = statement.where(MedicalDiagnosis.is_active == True)
@@ -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(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: healthdatalayer
3
- Version: 1.5.3
3
+ Version: 1.5.5
4
4
  Summary: Health Datalayer to access data from different sources
5
5
  Author: Jesus Martinez
6
6
  Author-email: jesusmartinez@noosds.com
@@ -84,12 +84,12 @@ healthdatalayer/repositories/lab_repositories/__init__.py,sha256=47DEQpj8HBSa-_T
84
84
  healthdatalayer/repositories/lab_repositories/measure_lab_repository.py,sha256=AAwgGjaLWTqyH3YHTD_eisunn6I0E0GmYLEseuLgZ0Q,3174
85
85
  healthdatalayer/repositories/lab_repositories/medical_lab_repository.py,sha256=owZQe3cXKkXsRuGXpqPBXjZvA-DEb7yD1OKPMOCqF1o,10909
86
86
  healthdatalayer/repositories/medical_visit_repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
87
- healthdatalayer/repositories/medical_visit_repositories/medical_diagnosis_repository.py,sha256=dnVW3hMUqrVGctBSNKVU2_j0ITH46aXN31XduELO8wg,4012
87
+ healthdatalayer/repositories/medical_visit_repositories/medical_diagnosis_repository.py,sha256=hwb5vh64ze72tFMSIUPNitC5t6pUCcO6pnI0gk-7LZU,4157
88
88
  healthdatalayer/repositories/medical_visit_repositories/medical_diagnosis_visit_repository.py,sha256=BHhglV8CBw4xpcLsFjRJPglg2D0ASnYD2k4RmbP80tU,5499
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=hhHXQZh5T9G5GJgkTqN0jqQ-qiwXejCYbmF7ycwwa_8,14265
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.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,,
100
+ healthdatalayer-1.5.5.dist-info/METADATA,sha256=FI6jWXF1Buf7HqOFDKYHKVxaQ8iB5T_lgdkmsNR2VvE,827
101
+ healthdatalayer-1.5.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
102
+ healthdatalayer-1.5.5.dist-info/top_level.txt,sha256=6f1-gvpg533UEVuYsRJCDhdSDQUBwijyAHylyS4nG_4,16
103
+ healthdatalayer-1.5.5.dist-info/RECORD,,