healthdatalayer 1.4.2__py3-none-any.whl → 1.4.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.

@@ -24,6 +24,8 @@ from .client.pathological_history import PathologicalHistory
24
24
  from .client.pet import Pet
25
25
  from .client.profession import Profession
26
26
  from .client.px import Px
27
+ from .client.state import State
28
+ from .client.city import City
27
29
 
28
30
  from .collaborator.collaborator_speciality import CollaboratorSpeciality
29
31
  from .collaborator.collaborator import Collaborator
@@ -0,0 +1,11 @@
1
+ import uuid
2
+ from sqlmodel import SQLModel,Field
3
+ from typing import Optional
4
+
5
+ class City(SQLModel,table=True):
6
+ __tablename__ = "city"
7
+
8
+ city_id:uuid.UUID=Field(default_factory=uuid.uuid4,primary_key=True)
9
+ name:str
10
+ state_id: Optional[uuid.UUID] = Field(default=None, foreign_key="state.state_id")
11
+ is_active: bool = Field(default=True)
@@ -20,9 +20,11 @@ class Px(Client, table=True):
20
20
  profession_id: Optional[uuid.UUID] = Field(default=None, foreign_key="profession.profession_id")
21
21
  education_id: Optional[uuid.UUID] = Field(default=None, foreign_key="education.education_id")
22
22
  user_id: Optional[uuid.UUID] = Field(default=None, foreign_key="user.user_id")
23
+ nationality_id: Optional[uuid.UUID] = Field(default=None, foreign_key="nationality.nationality_id")
23
24
 
24
25
  Px.marriage_status = Relationship()
25
26
  Px.profession = Relationship()
26
27
  Px.education = Relationship()
27
28
  Px.user = Relationship()
29
+ Px.nationality = Relationship()
28
30
  Px.medical_labs = Relationship(back_populates="pxs", link_model="ClientLab")
@@ -0,0 +1,9 @@
1
+ import uuid
2
+ from sqlmodel import SQLModel,Field
3
+
4
+ class State(SQLModel,table=True):
5
+ __tablename__ = "state"
6
+
7
+ state_id:uuid.UUID=Field(default_factory=uuid.uuid4,primary_key=True)
8
+ name:str
9
+ is_active: bool = Field(default=True)
@@ -2,7 +2,7 @@ from typing import Optional, List
2
2
  from uuid import UUID
3
3
  from sqlmodel import select
4
4
 
5
- from healthdatalayer.models import Address
5
+ from healthdatalayer.models import Address, City, State
6
6
  from healthdatalayer.config.db import engines, get_session
7
7
 
8
8
  class AddressRepository:
@@ -61,4 +61,34 @@ class AddressRepository:
61
61
  session.delete(db_address)
62
62
 
63
63
  session.commit()
64
- return True
64
+ return True
65
+
66
+ def list_all_state_command(self, active_only: bool = True) -> List[Address]:
67
+ with get_session(self.tenant) as session:
68
+ statement = select(State)
69
+
70
+ if active_only:
71
+ statement = statement.where(State.is_active == True)
72
+
73
+ results = session.exec(statement)
74
+ return results.all()
75
+
76
+ def list_all_city_command(self, active_only: bool = True) -> List[Address]:
77
+ with get_session(self.tenant) as session:
78
+ statement = select(City)
79
+
80
+ if active_only:
81
+ statement = statement.where(City.is_active == True)
82
+
83
+ results = session.exec(statement)
84
+ return results.all()
85
+
86
+ def list_city_by_state_id_command(self,state_id: UUID, active_only: bool = True) -> List[Address]:
87
+ with get_session(self.tenant) as session:
88
+ statement = select(City).where(City.state_id == state_id)
89
+
90
+ if active_only:
91
+ statement = statement.where(State.is_active == True)
92
+
93
+ results = session.exec(statement)
94
+ return results.all()
@@ -23,20 +23,11 @@ class CollaboratorRepository:
23
23
  with get_session(self.tenant) as session:
24
24
  if load_relations:
25
25
  statement = select(Collaborator).where(Collaborator.collaborator_id == collaborator_id).options(
26
- selectinload(Collaborator.specialties)
26
+ selectinload(Collaborator.collaborator_type),
27
+ joinedload(Collaborator.user),
28
+ selectinload(Collaborator.specialties)
27
29
  )
28
30
  collaborator = session.exec(statement).first()
29
- if load_relations:
30
-
31
- if collaborator.collaborator_type_id:
32
- from healthdatalayer.models.collaborator.collaborator_type import CollaboratorType
33
- collab_type_obj = session.get(CollaboratorType, collaborator.collaborator_type_id)
34
- object.__setattr__(collaborator,'collaborator_type', collab_type_obj)
35
-
36
- if collaborator.user_id:
37
- from healthdatalayer.models.user.user import User
38
- user_obj = session.get(User, collaborator.user_id)
39
- object.__setattr__(collaborator,'user',user_obj)
40
31
 
41
32
  return collaborator
42
33
  else:
@@ -47,11 +38,15 @@ class CollaboratorRepository:
47
38
  statement = (
48
39
  select(Collaborator)
49
40
  .join(CollaboratorSpeciality)
50
- .where(CollaboratorSpeciality.speciality_id == speciality_id)
41
+ .where(CollaboratorSpeciality.speciality_id == speciality_id, Collaborator.is_active == True)
51
42
  )
52
43
 
53
44
  if load_relations:
54
- statement = statement.options(selectinload(Collaborator.specialties))
45
+ statement = statement.options(
46
+ selectinload(Collaborator.collaborator_type),
47
+ joinedload(Collaborator.user),
48
+ selectinload(Collaborator.specialties)
49
+ )
55
50
 
56
51
  collaborators = session.exec(statement).all()
57
52
 
@@ -92,29 +87,19 @@ class CollaboratorRepository:
92
87
  def get_all_command(self, active_only: bool = True,load_related: bool = False) -> List[Collaborator]:
93
88
  with get_session(self.tenant) as session:
94
89
 
90
+ statement = select(Collaborator)
95
91
 
96
92
  if load_related:
97
93
 
98
- statement = select(Collaborator).options(
99
- selectinload(Collaborator.specialties)
100
- )
101
- if active_only:
102
- statement = statement.where(Collaborator.is_active == True)
103
- collaborators = session.exec(statement).all()
104
-
105
- for collaborator in collaborators:
106
- if collaborator.collaborator_type_id:
107
- from healthdatalayer.models.collaborator.collaborator_type import CollaboratorType
108
- collab_type_obj = session.get(CollaboratorType, collaborator.collaborator_type_id)
109
- object.__setattr__(collaborator,'collaborator_type', collab_type_obj)
110
-
111
- if collaborator.user_id:
112
- from healthdatalayer.models.user.user import User
113
- user_obj = session.get(User, collaborator.user_id)
114
- object.__setattr__(collaborator,'user',user_obj)
115
- return collaborators
94
+ statement = statement.options(
95
+ selectinload(Collaborator.collaborator_type),
96
+ joinedload(Collaborator.user),
97
+ selectinload(Collaborator.specialties)
98
+ )
116
99
 
117
- statement = select(Collaborator)
100
+ if active_only:
101
+ statement = statement.where(Collaborator.is_active == True)
102
+
118
103
  return session.exec(statement).all()
119
104
 
120
105
  def update_command(self, collaborator: Collaborator) -> Collaborator:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: healthdatalayer
3
- Version: 1.4.2
3
+ Version: 1.4.4
4
4
  Summary: Health Datalayer to access data from different sources
5
5
  Author: Jesus Martinez
6
6
  Author-email: jesusmartinez@noosds.com
@@ -3,7 +3,7 @@ healthdatalayer/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
3
3
  healthdatalayer/config/config.py,sha256=vyqrlHDgCGpYX7V9fDn4g671lUU1RuWlSYCIazI-SqQ,689
4
4
  healthdatalayer/config/db.py,sha256=b_SWTINJSVUhR0uyD4h93jPLKUzRm6Ky0tmALWbjM18,342
5
5
  healthdatalayer/config/vault.py,sha256=9yUMXjaTYSnqr0npcQXDsg6Z7G3DityqpmHl1x42zS0,748
6
- healthdatalayer/models/__init__.py,sha256=aHts_4fmmSgAGlKe-qZ9aCXjeYPBVaB-VM4LqH-y4_4,1994
6
+ healthdatalayer/models/__init__.py,sha256=ZBY7CL172P68TWRWVTpzHO0_cnFzDRGz7aTy85Z8HPI,2056
7
7
  healthdatalayer/models/bridge_area_floor_branch/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  healthdatalayer/models/bridge_area_floor_branch/area.py,sha256=g_u6RoorLJ7XUx7qcqXLavrHxpflHGi0p77f-3RPbVU,201
9
9
  healthdatalayer/models/bridge_area_floor_branch/branch.py,sha256=lW2pbZVKkQeEWuShOLKFiNJAKt01mBswczk1hRELInw,515
@@ -13,6 +13,7 @@ healthdatalayer/models/bridge_area_floor_branch/room.py,sha256=nub6QIFyl6ZxGENru
13
13
  healthdatalayer/models/bridge_area_floor_branch/system.py,sha256=10r59kLMsLEv9cKa4hEZJoFAicVPS0rw4UNiN5nhsnI,212
14
14
  healthdatalayer/models/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  healthdatalayer/models/client/address.py,sha256=rc_Vw9qWECmGcf0GGTChZZj8m6whWSFFGA3xIcsYaBk,343
16
+ healthdatalayer/models/client/city.py,sha256=TYSthPrhdb9iTzDSUC9ZGmx7ZZ0PacxNS2S3ajMhnJU,355
16
17
  healthdatalayer/models/client/client.py,sha256=DjW64iOeGKPluKLqyWTTHVste0Y3pF0VL_FvHNLtvyM,786
17
18
  healthdatalayer/models/client/client_type.py,sha256=ElTYCXLkVItIhEIj2ZhXqHV872kY4A7gUuhwpm-BKjQ,261
18
19
  healthdatalayer/models/client/education.py,sha256=MQN-7Oh1PdneytDmm1DZuZ7wrXzXSTeu08SeKhZ0fi8,256
@@ -23,7 +24,8 @@ healthdatalayer/models/client/nationality.py,sha256=k1CKQTQIJAJP_qmeYB-AkRQ1Q5x9
23
24
  healthdatalayer/models/client/pathological_history.py,sha256=8jsOAaSGqk1M-60sLhoJuuz9MeUKbk693dARXgBriTY,1029
24
25
  healthdatalayer/models/client/pet.py,sha256=y7jiNF_9Jri0_55geo2hweEj4zdsHKu9ZCelBwfVWeA,516
25
26
  healthdatalayer/models/client/profession.py,sha256=eKX6Gf93qwQg2NyJsXKKbmEwQTxHvJCnOwQ5pxCpM0I,259
26
- healthdatalayer/models/client/px.py,sha256=R1RsEwLx3fQ8fPX5Mq7FrWtoexgL-RddDMs_D2PYs5Y,959
27
+ healthdatalayer/models/client/px.py,sha256=4HgPzbm_OdaQvOHC5-QLQA35VTK83QkaqX-rUF2kVYk,1095
28
+ healthdatalayer/models/client/state.py,sha256=G_AJOKKfkufZw_axfwSrcL3ZVtKY1FOm0AmCcHfn9Ao,244
27
29
  healthdatalayer/models/collaborator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
30
  healthdatalayer/models/collaborator/collaborator.py,sha256=Hju_VTUEgA22KJ5-lr-8dl8UsgeSEj2c5OxuGjU71oM,1064
29
31
  healthdatalayer/models/collaborator/collaborator_speciality.py,sha256=TQK8dbbM7LE14MpEpWjTmcYRJCOLlBGxQwrs7zkR5ao,346
@@ -52,7 +54,7 @@ healthdatalayer/models/user/role_user.py,sha256=HBLzwY5712DISqBTxrVOrNjnUOAHSYUf
52
54
  healthdatalayer/models/user/user.py,sha256=Fc1m5xluZMZPHe_TIsRu43dOXdjk3TNU4drrMLcfb9g,975
53
55
  healthdatalayer/repositories/__init__.py,sha256=mu3VrCXi7GBJqwjsJHWDuyFFTX0wqBZzmJ7CyAypP6U,2766
54
56
  healthdatalayer/repositories/client_repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
- healthdatalayer/repositories/client_repositories/address_repository.py,sha256=CPU4jayxAZVPCQaezINxQM3f87ls-Y8xfxlAfZaj8Hc,2240
57
+ healthdatalayer/repositories/client_repositories/address_repository.py,sha256=Ae2rHG0zXyqoovcfyGh1hMPBQKLoBVKR5SlytnPO5iA,3436
56
58
  healthdatalayer/repositories/client_repositories/client_type_repository.py,sha256=RddxYRoBpktXqbLZy2JC2MDWaXCq9_Auhk1peqe9hSw,2637
57
59
  healthdatalayer/repositories/client_repositories/education_repository.py,sha256=T-coaux5h35nkvOr9VPi7Ri_ETtlPdziJAhF2pCFNDo,2583
58
60
  healthdatalayer/repositories/client_repositories/emergency_contact_repository.py,sha256=kCPrVY1thMJ1tcybaRupw9L8RB4GhnYbYPincH8bRFI,3259
@@ -64,7 +66,7 @@ healthdatalayer/repositories/client_repositories/pet_repository.py,sha256=aUjti4
64
66
  healthdatalayer/repositories/client_repositories/profession_repository.py,sha256=ALnx_y_z9Jfx9rBDvOdnK1P1_lkqKmFBeR1GVXj3m3Q,2620
65
67
  healthdatalayer/repositories/client_repositories/px_repository.py,sha256=cTXDfKolG5aLdlQzXV98_r4Y1Qm5jYW9cUtntdw7e0k,10116
66
68
  healthdatalayer/repositories/collaborator_repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
67
- healthdatalayer/repositories/collaborator_repositories/collaborator_repository.py,sha256=JB0UdtUEJEY8y33EIT51wHNytroXw_4aVg1U4KmGmGw,7572
69
+ healthdatalayer/repositories/collaborator_repositories/collaborator_repository.py,sha256=aYew_0UMYRvng3DgP5vnKbSVmYe8ozYWUnLly6LxTcI,6467
68
70
  healthdatalayer/repositories/collaborator_repositories/collaborator_type_repository.py,sha256=7-bJqbxgsJtyRU7nV_YCZhKufYLlighWBWjglw70nUw,2858
69
71
  healthdatalayer/repositories/collaborator_repositories/speciality_repository.py,sha256=tcAjp2OzFAnHpRKNdmw2Zsqvs7XdsO51h7cIJHt105s,2940
70
72
  healthdatalayer/repositories/infraestructure_repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -91,7 +93,7 @@ healthdatalayer/repositories/user_repositories/__init__.py,sha256=47DEQpj8HBSa-_
91
93
  healthdatalayer/repositories/user_repositories/permission_repository.py,sha256=3L4y-zCkI2PIRo-L3FJRSk4g3nZnu6q35lEY4ACJyq4,9630
92
94
  healthdatalayer/repositories/user_repositories/role_repository.py,sha256=jIsbeAFFQQ_CZJqBMcOskuMXtT1Il6eiN0Y2BpVO1JE,6821
93
95
  healthdatalayer/repositories/user_repositories/user_repository.py,sha256=FUCNdRRGc12dq5XuwDT3btvDETt6HGXh_xQIPTLCAvk,9839
94
- healthdatalayer-1.4.2.dist-info/METADATA,sha256=gP7YXWYYDnmmDfIUJ3I1iwFwdZCitP_pK2z9rrSM6sA,827
95
- healthdatalayer-1.4.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
96
- healthdatalayer-1.4.2.dist-info/top_level.txt,sha256=6f1-gvpg533UEVuYsRJCDhdSDQUBwijyAHylyS4nG_4,16
97
- healthdatalayer-1.4.2.dist-info/RECORD,,
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,,