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

@@ -6,6 +6,9 @@ from .client_repositories.marriage_status_repository import MarriageStatusReposi
6
6
  from .client_repositories.pet_repository import PetRepository
7
7
  from .client_repositories.profession_repository import ProfessionRepository
8
8
  from .client_repositories.px_repository import PxRepository
9
+ from .client_repositories.emergency_contact_repository import EmergencyContactRepository
10
+ from .client_repositories.nationality_repository import NationalityRepository
11
+ from .client_repositories.pathological_history_repository import PathologicalHistoryRepository
9
12
 
10
13
  from .collaborator_repositories.collaborator_repository import CollaboratorRepository
11
14
  from .collaborator_repositories.collaborator_type_repository import CollaboratorTypeRepository
@@ -0,0 +1,78 @@
1
+ from typing import Optional, List
2
+ from uuid import UUID
3
+ from sqlmodel import select
4
+
5
+ from healthdatalayer.models import EmergencyContact
6
+ from healthdatalayer.config.db import engines, get_session
7
+
8
+ class EmergencyContactRepository:
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, emergency_contact: EmergencyContact) -> EmergencyContact:
15
+ with get_session(self.tenant) as session:
16
+ session.add(emergency_contact)
17
+ session.commit()
18
+ session.refresh(emergency_contact)
19
+ return emergency_contact
20
+
21
+ def get_by_id_command(self, emergency_contact_id: UUID) -> Optional[EmergencyContact]:
22
+ with get_session(self.tenant) as session:
23
+ return session.get(EmergencyContact, emergency_contact_id)
24
+
25
+ def get_by_client_id_command(self, client_id: UUID) -> List[EmergencyContact]:
26
+ with get_session(self.tenant) as session:
27
+ statement = select(EmergencyContact).where(
28
+ EmergencyContact.client_id == client_id,
29
+ EmergencyContact.is_active == True
30
+ )
31
+ results = session.exec(statement)
32
+ return results.all()
33
+
34
+ def get_by_name_command(self, name: str) -> Optional[EmergencyContact]:
35
+ with get_session(self.tenant) as session:
36
+ statement = select(EmergencyContact).where(EmergencyContact.name == name)
37
+ result = session.exec(statement).first()
38
+ return result
39
+
40
+ def list_all_command(self, active_only: bool = True) -> List[EmergencyContact]:
41
+ with get_session(self.tenant) as session:
42
+ statement = select(EmergencyContact)
43
+
44
+ if active_only:
45
+ statement = statement.where(EmergencyContact.is_active == True)
46
+
47
+ results = session.exec(statement)
48
+ return results.all()
49
+
50
+ def update_command(self, emergency_contact_id: UUID, **kwargs) -> Optional[EmergencyContact]:
51
+ with get_session(self.tenant) as session:
52
+ db_emergency_contact = session.get(EmergencyContact, emergency_contact_id)
53
+ if not db_emergency_contact:
54
+ return None
55
+
56
+ for key, value in kwargs.items():
57
+ if hasattr(db_emergency_contact, key):
58
+ setattr(db_emergency_contact, key, value)
59
+
60
+ session.add(db_emergency_contact)
61
+ session.commit()
62
+ session.refresh(db_emergency_contact)
63
+ return db_emergency_contact
64
+
65
+ def delete_command(self, emergency_contact_id: UUID, soft_delete: bool = True) -> bool:
66
+ with get_session(self.tenant) as session:
67
+ db_emergency_contact = session.get(EmergencyContact, emergency_contact_id)
68
+ if not db_emergency_contact:
69
+ return False
70
+
71
+ if soft_delete:
72
+ db_emergency_contact.is_active = False
73
+ session.add(db_emergency_contact)
74
+ else:
75
+ session.delete(db_emergency_contact)
76
+
77
+ session.commit()
78
+ return True
@@ -0,0 +1,69 @@
1
+ from typing import Optional, List
2
+ from uuid import UUID
3
+ from sqlmodel import select
4
+
5
+ from healthdatalayer.models import Nationality
6
+ from healthdatalayer.config.db import engines, get_session
7
+
8
+ class NationalityRepository:
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, nationality: Nationality) -> Nationality:
15
+ with get_session(self.tenant) as session:
16
+ session.add(nationality)
17
+ session.commit()
18
+ session.refresh(nationality)
19
+ return nationality
20
+
21
+ def get_by_id_command(self, nationality_id: UUID) -> Optional[Nationality]:
22
+ with get_session(self.tenant) as session:
23
+ return session.get(Nationality, nationality_id)
24
+
25
+ def get_by_name_command(self, name: str) -> Optional[Nationality]:
26
+ with get_session(self.tenant) as session:
27
+ statement = select(Nationality).where(Nationality.name.ilike(f"%{name}%"), Nationality.is_active == True)
28
+ result = session.exec(statement).first()
29
+ return result
30
+
31
+ def list_all_command(self, active_only: bool = True) -> List[Nationality]:
32
+ with get_session(self.tenant) as session:
33
+ statement = select(Nationality)
34
+
35
+ if active_only:
36
+ statement = statement.where(Nationality.is_active == True)
37
+
38
+ results = session.exec(statement)
39
+ return results.all()
40
+
41
+ def update_command(self, nationality_id: UUID, **kwargs) -> Optional[Nationality]:
42
+ with get_session(self.tenant) as session:
43
+ db_nationality = session.get(Nationality, nationality_id)
44
+ if not db_nationality:
45
+ return None
46
+
47
+ for key, value in kwargs.items():
48
+ if hasattr(db_nationality, key):
49
+ setattr(db_nationality, key, value)
50
+
51
+ session.add(db_nationality)
52
+ session.commit()
53
+ session.refresh(db_nationality)
54
+ return db_nationality
55
+
56
+ def delete_command(self, nationality_id: UUID, soft_delete: bool = True) -> bool:
57
+ with get_session(self.tenant) as session:
58
+ db_nationality = session.get(Nationality, nationality_id)
59
+ if not db_nationality:
60
+ return False
61
+
62
+ if soft_delete:
63
+ db_nationality.is_active = False
64
+ session.add(db_nationality)
65
+ else:
66
+ session.delete(db_nationality)
67
+
68
+ session.commit()
69
+ return True
@@ -0,0 +1,73 @@
1
+ from typing import Optional, List
2
+ from uuid import UUID
3
+ from sqlmodel import select
4
+
5
+ from healthdatalayer.models import PathologicalHistory
6
+ from healthdatalayer.config.db import engines, get_session
7
+
8
+ class PathologicalHistoryRepository:
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, pathological_history: PathologicalHistory) -> PathologicalHistory:
15
+ with get_session(self.tenant) as session:
16
+ session.add(pathological_history)
17
+ session.commit()
18
+ session.refresh(pathological_history)
19
+ return pathological_history
20
+
21
+ def get_by_id_command(self, pathological_history_id: UUID) -> Optional[PathologicalHistory]:
22
+ with get_session(self.tenant) as session:
23
+ return session.get(PathologicalHistory, pathological_history_id)
24
+
25
+ def get_by_client_id_command(self, client_id: UUID) -> List[PathologicalHistory]:
26
+ with get_session(self.tenant) as session:
27
+ statement = select(PathologicalHistory).where(
28
+ PathologicalHistory.client_id == client_id,
29
+ PathologicalHistory.is_active == True
30
+ )
31
+ results = session.exec(statement)
32
+ return results.all()
33
+
34
+
35
+ def list_all_command(self, active_only: bool = True) -> List[PathologicalHistory]:
36
+ with get_session(self.tenant) as session:
37
+ statement = select(PathologicalHistory)
38
+
39
+ if active_only:
40
+ statement = statement.where(PathologicalHistory.is_active == True)
41
+
42
+ results = session.exec(statement)
43
+ return results.all()
44
+
45
+ def update_command(self, pathological_history_id: UUID, **kwargs) -> Optional[PathologicalHistory]:
46
+ with get_session(self.tenant) as session:
47
+ db_pathological_history = session.get(PathologicalHistory, pathological_history_id)
48
+ if not db_pathological_history:
49
+ return None
50
+
51
+ for key, value in kwargs.items():
52
+ if hasattr(db_pathological_history, key):
53
+ setattr(db_pathological_history, key, value)
54
+
55
+ session.add(db_pathological_history)
56
+ session.commit()
57
+ session.refresh(db_pathological_history)
58
+ return db_pathological_history
59
+
60
+ def delete_command(self, pathological_history_id: UUID, soft_delete: bool = True) -> bool:
61
+ with get_session(self.tenant) as session:
62
+ db_pathological_history = session.get(PathologicalHistory, pathological_history_id)
63
+ if not db_pathological_history:
64
+ return False
65
+
66
+ if soft_delete:
67
+ db_pathological_history.is_active = False
68
+ session.add(db_pathological_history)
69
+ else:
70
+ session.delete(db_pathological_history)
71
+
72
+ session.commit()
73
+ return True
@@ -97,7 +97,8 @@ class PxRepository:
97
97
  with get_session(self.tenant) as session:
98
98
  statement = select(Px).where(
99
99
  (Px.first_name.ilike(f"%{name}%")) |
100
- (Px.last_name.ilike(f"%{name}%"))
100
+ (Px.last_name.ilike(f"%{name}%")) |
101
+ (Px.identification.ilike(f"%{name}%"))
101
102
  )
102
103
 
103
104
  results = session.exec(statement).all()
@@ -27,7 +27,8 @@ class BridgeAreaFloorBranchRepository:
27
27
  statement = statement.options(
28
28
  selectinload(BridgeAreaFloorBranch.branch).selectinload(Branch.system),
29
29
  selectinload(BridgeAreaFloorBranch.area),
30
- selectinload(BridgeAreaFloorBranch.floor)
30
+ selectinload(BridgeAreaFloorBranch.floor),
31
+ selectinload(BridgeAreaFloorBranch.room)
31
32
  )
32
33
  bridge = session.exec(statement).first()
33
34
 
@@ -45,7 +46,8 @@ class BridgeAreaFloorBranchRepository:
45
46
  statement = statement.options(
46
47
  selectinload(BridgeAreaFloorBranch.branch).selectinload(Branch.system),
47
48
  selectinload(BridgeAreaFloorBranch.area),
48
- selectinload(BridgeAreaFloorBranch.floor)
49
+ selectinload(BridgeAreaFloorBranch.floor),
50
+ selectinload(BridgeAreaFloorBranch.room)
49
51
  )
50
52
 
51
53
  results = session.exec(statement).all()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: healthdatalayer
3
- Version: 1.3.0
3
+ Version: 1.4.1
4
4
  Summary: Health Datalayer to access data from different sources
5
5
  Author: Jesus Martinez
6
6
  Author-email: jesusmartinez@noosds.com
@@ -50,16 +50,19 @@ healthdatalayer/models/user/role.py,sha256=A67jOXEcDMki_bibZMk3IKsLX8JptcP1tjuHx
50
50
  healthdatalayer/models/user/role_permission.py,sha256=mRMXItgI97Zqu0q9JkhjEPbn6mJQjdosibeZtRBtmMA,306
51
51
  healthdatalayer/models/user/role_user.py,sha256=HBLzwY5712DISqBTxrVOrNjnUOAHSYUfX4qcABinb2M,276
52
52
  healthdatalayer/models/user/user.py,sha256=Fc1m5xluZMZPHe_TIsRu43dOXdjk3TNU4drrMLcfb9g,975
53
- healthdatalayer/repositories/__init__.py,sha256=b8ya7gJkFq0yzF3h8G0vIiakv_uOB9u859sdBLhEZHI,2504
53
+ healthdatalayer/repositories/__init__.py,sha256=mu3VrCXi7GBJqwjsJHWDuyFFTX0wqBZzmJ7CyAypP6U,2766
54
54
  healthdatalayer/repositories/client_repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
55
  healthdatalayer/repositories/client_repositories/address_repository.py,sha256=CPU4jayxAZVPCQaezINxQM3f87ls-Y8xfxlAfZaj8Hc,2240
56
56
  healthdatalayer/repositories/client_repositories/client_type_repository.py,sha256=RddxYRoBpktXqbLZy2JC2MDWaXCq9_Auhk1peqe9hSw,2637
57
57
  healthdatalayer/repositories/client_repositories/education_repository.py,sha256=T-coaux5h35nkvOr9VPi7Ri_ETtlPdziJAhF2pCFNDo,2583
58
+ healthdatalayer/repositories/client_repositories/emergency_contact_repository.py,sha256=kCPrVY1thMJ1tcybaRupw9L8RB4GhnYbYPincH8bRFI,3259
58
59
  healthdatalayer/repositories/client_repositories/gender_repository.py,sha256=KCDg8uiHmpF8L6nNt1OhwZWvQ527ccU3G1ntSP9lYK0,2472
59
60
  healthdatalayer/repositories/client_repositories/marriage_status_repository.py,sha256=0GN-nijvB0GDbCYV4KC2SUt0G442UNngbndfA2wRcTo,2790
61
+ healthdatalayer/repositories/client_repositories/nationality_repository.py,sha256=tFrxodxhJgY-f6esq9gGZr7sr5l7qFwgRwnVQ6DOdrw,2694
62
+ healthdatalayer/repositories/client_repositories/pathological_history_repository.py,sha256=RabXI8VCWHUHlHwtrYm2vQE_eyep2wrzOsemgYa5NPY,3082
60
63
  healthdatalayer/repositories/client_repositories/pet_repository.py,sha256=aUjti4bUniQbbUz5-bjgvUgDrSpPyggy9k5e-RAoYgc,4802
61
64
  healthdatalayer/repositories/client_repositories/profession_repository.py,sha256=ALnx_y_z9Jfx9rBDvOdnK1P1_lkqKmFBeR1GVXj3m3Q,2620
62
- healthdatalayer/repositories/client_repositories/px_repository.py,sha256=T1NdNBHy_kbd0n9tvFvglgjCpdlnIebBbxO3BBr1guI,10059
65
+ healthdatalayer/repositories/client_repositories/px_repository.py,sha256=cTXDfKolG5aLdlQzXV98_r4Y1Qm5jYW9cUtntdw7e0k,10116
63
66
  healthdatalayer/repositories/collaborator_repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
67
  healthdatalayer/repositories/collaborator_repositories/collaborator_repository.py,sha256=61c3xFzjRm0_XT8FDQ2hA6tD_ruRVQjWhAPn8JBci18,6898
65
68
  healthdatalayer/repositories/collaborator_repositories/collaborator_type_repository.py,sha256=7-bJqbxgsJtyRU7nV_YCZhKufYLlighWBWjglw70nUw,2858
@@ -67,7 +70,7 @@ healthdatalayer/repositories/collaborator_repositories/speciality_repository.py,
67
70
  healthdatalayer/repositories/infraestructure_repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
68
71
  healthdatalayer/repositories/infraestructure_repositories/area_repository.py,sha256=Ubnir4Vc-ViglmE1KclOnLb_4ZkYPhwALmgWJ76Tr0Y,2393
69
72
  healthdatalayer/repositories/infraestructure_repositories/branch_repository.py,sha256=iW0483qD0AXK0cSZ5qHvF-aFnkI8oYLUVfPdFyNBIOQ,2467
70
- healthdatalayer/repositories/infraestructure_repositories/bridge_repository.py,sha256=QON-qsmTPnHeRteXtnO01J6-AQEhXuZh41ilPyrDi9I,3534
73
+ healthdatalayer/repositories/infraestructure_repositories/bridge_repository.py,sha256=dHqWVTxOON3jF-4XZqLmb2unlIlAg-vkU9TPI4kChTo,3658
71
74
  healthdatalayer/repositories/infraestructure_repositories/floor_repository.py,sha256=03GuTBI9X1u2zdASEv7t9O2CO7fz6-86Qdj0s11SqhU,2430
72
75
  healthdatalayer/repositories/infraestructure_repositories/room_repository.py,sha256=QBN5xSKGj9I2Is1NE6eKpUBkSgTj0yB2Y8y_tZfWQVU,2393
73
76
  healthdatalayer/repositories/infraestructure_repositories/system_repository.py,sha256=msEN6VuoCJL2zBQ2FaB7mZjKZJcAcle4lGVy3Sn83QE,2467
@@ -88,7 +91,7 @@ healthdatalayer/repositories/user_repositories/__init__.py,sha256=47DEQpj8HBSa-_
88
91
  healthdatalayer/repositories/user_repositories/permission_repository.py,sha256=3L4y-zCkI2PIRo-L3FJRSk4g3nZnu6q35lEY4ACJyq4,9630
89
92
  healthdatalayer/repositories/user_repositories/role_repository.py,sha256=jIsbeAFFQQ_CZJqBMcOskuMXtT1Il6eiN0Y2BpVO1JE,6821
90
93
  healthdatalayer/repositories/user_repositories/user_repository.py,sha256=FUCNdRRGc12dq5XuwDT3btvDETt6HGXh_xQIPTLCAvk,9839
91
- healthdatalayer-1.3.0.dist-info/METADATA,sha256=318lQqXYgyTg69VwjVp_H35g-try0_DQ1IG6cD5Njj8,827
92
- healthdatalayer-1.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
93
- healthdatalayer-1.3.0.dist-info/top_level.txt,sha256=6f1-gvpg533UEVuYsRJCDhdSDQUBwijyAHylyS4nG_4,16
94
- healthdatalayer-1.3.0.dist-info/RECORD,,
94
+ healthdatalayer-1.4.1.dist-info/METADATA,sha256=InmZzgBbYBtU7mw7JWNu8Zv8wPS_ghswiZuTbIda_5w,827
95
+ healthdatalayer-1.4.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
96
+ healthdatalayer-1.4.1.dist-info/top_level.txt,sha256=6f1-gvpg533UEVuYsRJCDhdSDQUBwijyAHylyS4nG_4,16
97
+ healthdatalayer-1.4.1.dist-info/RECORD,,