healthdatalayer 1.5.8__tar.gz → 1.7.0__tar.gz
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.
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/PKG-INFO +1 -1
- healthdatalayer-1.7.0/healthdatalayer/dtos/__init__.py +3 -0
- healthdatalayer-1.7.0/healthdatalayer/dtos/medical_visit/medical_certificate.py +62 -0
- healthdatalayer-1.7.0/healthdatalayer/dtos/medical_visit/recipe_dto.py +16 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/client/px.py +7 -2
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/medical_visit/medical_drug.py +2 -6
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/medical_visit/medical_drug_recipe.py +10 -3
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/medical_visit/medical_recipe_visit.py +3 -3
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/client_repositories/px_repository.py +48 -1
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/collaborator_repositories/collaborator_repository.py +1 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/medical_visit_repositories/medical_drug_recipe_repository.py +4 -3
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/medical_visit_repositories/medical_drug_repository.py +17 -2
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/medical_visit_repositories/medical_recipe_visit_repository.py +58 -6
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/medical_visit_repositories/medical_visit_repository.py +177 -13
- healthdatalayer-1.7.0/healthdatalayer/repositories/user_repositories/__init__.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer.egg-info/PKG-INFO +1 -1
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer.egg-info/SOURCES.txt +3 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/setup.py +1 -1
- healthdatalayer-1.5.8/healthdatalayer/dtos/__init__.py +0 -1
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/README.md +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/__init__.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/config/__init__.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/config/config.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/config/db.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/config/vault.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/dtos/collaborator/__init__.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/dtos/collaborator/schedule_collaborator.py +0 -0
- {healthdatalayer-1.5.8/healthdatalayer/models/bridge_area_floor_branch → healthdatalayer-1.7.0/healthdatalayer/dtos/medical_visit}/__init__.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/__init__.py +0 -0
- {healthdatalayer-1.5.8/healthdatalayer/models/client → healthdatalayer-1.7.0/healthdatalayer/models/bridge_area_floor_branch}/__init__.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/bridge_area_floor_branch/area.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/bridge_area_floor_branch/branch.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/bridge_area_floor_branch/bridge_area_floor_branch.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/bridge_area_floor_branch/floor.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/bridge_area_floor_branch/room.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/bridge_area_floor_branch/system.py +0 -0
- {healthdatalayer-1.5.8/healthdatalayer/models/collaborator → healthdatalayer-1.7.0/healthdatalayer/models/client}/__init__.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/client/address.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/client/city.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/client/client.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/client/client_type.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/client/education.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/client/emergency_contact.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/client/gender.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/client/marriage_status.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/client/nationality.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/client/pathological_history.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/client/pet.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/client/profession.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/client/state.py +0 -0
- {healthdatalayer-1.5.8/healthdatalayer/models/lab → healthdatalayer-1.7.0/healthdatalayer/models/collaborator}/__init__.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/collaborator/collaborator.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/collaborator/collaborator_speciality.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/collaborator/collaborator_type.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/collaborator/speciality.py +0 -0
- {healthdatalayer-1.5.8/healthdatalayer/models/medical_visit → healthdatalayer-1.7.0/healthdatalayer/models/lab}/__init__.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/lab/client_lab.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/lab/measure_lab.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/lab/medical_lab.py +0 -0
- {healthdatalayer-1.5.8/healthdatalayer/models/user → healthdatalayer-1.7.0/healthdatalayer/models/medical_visit}/__init__.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/medical_visit/medical_diagnosis.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/medical_visit/medical_diagnosis_visit.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/medical_visit/medical_visit.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/medical_visit/organ_system_review.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/medical_visit/physical_exam.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/medical_visit/status_visit_enum.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/medical_visit/visit_triage.py +0 -0
- {healthdatalayer-1.5.8/healthdatalayer/repositories/client_repositories → healthdatalayer-1.7.0/healthdatalayer/models/user}/__init__.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/user/permission.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/user/permission_user.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/user/role.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/user/role_permission.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/user/role_user.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/user/user.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/__init__.py +0 -0
- {healthdatalayer-1.5.8/healthdatalayer/repositories/collaborator_repositories → healthdatalayer-1.7.0/healthdatalayer/repositories/client_repositories}/__init__.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/client_repositories/address_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/client_repositories/client_type_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/client_repositories/education_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/client_repositories/emergency_contact_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/client_repositories/gender_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/client_repositories/marriage_status_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/client_repositories/nationality_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/client_repositories/pathological_history_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/client_repositories/pet_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/client_repositories/profession_repository.py +0 -0
- {healthdatalayer-1.5.8/healthdatalayer/repositories/infraestructure_repositories → healthdatalayer-1.7.0/healthdatalayer/repositories/collaborator_repositories}/__init__.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/collaborator_repositories/collaborator_type_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/collaborator_repositories/speciality_repository.py +0 -0
- {healthdatalayer-1.5.8/healthdatalayer/repositories/lab_repositories → healthdatalayer-1.7.0/healthdatalayer/repositories/infraestructure_repositories}/__init__.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/infraestructure_repositories/area_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/infraestructure_repositories/branch_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/infraestructure_repositories/bridge_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/infraestructure_repositories/floor_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/infraestructure_repositories/room_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/infraestructure_repositories/system_repository.py +0 -0
- {healthdatalayer-1.5.8/healthdatalayer/repositories/medical_visit_repositories → healthdatalayer-1.7.0/healthdatalayer/repositories/lab_repositories}/__init__.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/lab_repositories/measure_lab_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/lab_repositories/medical_lab_repository.py +0 -0
- {healthdatalayer-1.5.8/healthdatalayer/repositories/user_repositories → healthdatalayer-1.7.0/healthdatalayer/repositories/medical_visit_repositories}/__init__.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/medical_visit_repositories/medical_diagnosis_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/medical_visit_repositories/medical_diagnosis_visit_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/medical_visit_repositories/organ_system_review_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/medical_visit_repositories/physical_exam_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/medical_visit_repositories/visit_triage_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/user_repositories/permission_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/user_repositories/role_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/repositories/user_repositories/user_repository.py +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer.egg-info/dependency_links.txt +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer.egg-info/requires.txt +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer.egg-info/top_level.txt +0 -0
- {healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/setup.cfg +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import List, Optional
|
|
3
|
+
from datetime import date, datetime, time
|
|
4
|
+
|
|
5
|
+
class MedicalCertificateDTO(BaseModel):
|
|
6
|
+
sys: Optional[str] = None
|
|
7
|
+
stablishment: Optional[str] = None
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
medical_record_number: Optional[str] = None
|
|
11
|
+
number_his: Optional[str] = None
|
|
12
|
+
last_name: Optional[str] = None
|
|
13
|
+
first_name: Optional[str] = None
|
|
14
|
+
sex: Optional[str] = None
|
|
15
|
+
age: Optional[int] = None
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
service: Optional[str] = None
|
|
19
|
+
speciality: Optional[str] = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
year_visit: Optional[int] = None
|
|
23
|
+
month_visit: Optional[int] = None
|
|
24
|
+
day_visit: Optional[int] = None
|
|
25
|
+
hour_start: Optional[time] = None
|
|
26
|
+
hour_end: Optional[time] = None
|
|
27
|
+
visit_date_spanish: Optional[str] = None
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
rest: Optional[bool] = None
|
|
31
|
+
rest_hours: Optional[float] = None
|
|
32
|
+
rest_date_start: Optional[datetime] = None
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
year_rest_start: Optional[int] = None
|
|
36
|
+
month_rest_start: Optional[int] = None
|
|
37
|
+
day_rest_start: Optional[int] = None
|
|
38
|
+
rest_date_start_spanish: Optional[str] = None
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
rest_date_end: Optional[datetime] = None
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
year_rest_end: Optional[int] = None
|
|
45
|
+
month_rest_end: Optional[int] = None
|
|
46
|
+
day_rest_end: Optional[int] = None
|
|
47
|
+
rest_date_end_spanish: Optional[str] = None
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
doctor_name: Optional[str] = None
|
|
51
|
+
doctor_ruc: Optional[str] = None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class DiagnosisDTO(BaseModel):
|
|
55
|
+
name_diagnosis: str
|
|
56
|
+
cie_10_code: Optional[str] = None
|
|
57
|
+
|
|
58
|
+
class MedicalDiagnosesDTO(BaseModel):
|
|
59
|
+
diagnoses: List[DiagnosisDTO]
|
|
60
|
+
|
|
61
|
+
class Config:
|
|
62
|
+
from_attributes = True
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from typing import List, Optional
|
|
3
|
+
from datetime import date, datetime, time
|
|
4
|
+
|
|
5
|
+
class HeaderRecipe(BaseModel):
|
|
6
|
+
visit_date : Optional[datetime] = None
|
|
7
|
+
name_doctor : Optional[str] = None
|
|
8
|
+
ruc : Optional[str] = None
|
|
9
|
+
code : Optional[str] = None
|
|
10
|
+
first_name_px : Optional[str] = None
|
|
11
|
+
last_name_px : Optional[str] = None
|
|
12
|
+
|
|
13
|
+
class RecipeMedicalDrugData(BaseModel):
|
|
14
|
+
drug_name : Optional[str] = None
|
|
15
|
+
comment: Optional[str] = None
|
|
16
|
+
quantity :Optional[int] = None
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Optional, TYPE_CHECKING
|
|
1
|
+
from typing import Optional, TYPE_CHECKING, List
|
|
2
2
|
from sqlmodel import Field, Relationship
|
|
3
3
|
import uuid
|
|
4
4
|
|
|
@@ -7,6 +7,7 @@ from healthdatalayer.models import Client
|
|
|
7
7
|
|
|
8
8
|
if TYPE_CHECKING:
|
|
9
9
|
from healthdatalayer.models import ClientLab
|
|
10
|
+
from healthdatalayer.models import PathologicalHistory
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class Px(Client, table=True):
|
|
@@ -21,10 +22,14 @@ class Px(Client, table=True):
|
|
|
21
22
|
education_id: Optional[uuid.UUID] = Field(default=None, foreign_key="education.education_id")
|
|
22
23
|
user_id: Optional[uuid.UUID] = Field(default=None, foreign_key="user.user_id")
|
|
23
24
|
nationality_id: Optional[uuid.UUID] = Field(default=None, foreign_key="nationality.nationality_id")
|
|
25
|
+
pathological_histories: List["PathologicalHistory"] = Relationship(
|
|
26
|
+
back_populates="client",
|
|
27
|
+
sa_relationship_kwargs={"lazy": "selectin"}
|
|
28
|
+
)
|
|
24
29
|
|
|
25
30
|
Px.marriage_status = Relationship()
|
|
26
31
|
Px.profession = Relationship()
|
|
27
32
|
Px.education = Relationship()
|
|
28
33
|
Px.user = Relationship()
|
|
29
34
|
Px.nationality = Relationship()
|
|
30
|
-
Px.medical_labs = Relationship(back_populates="pxs", link_model="ClientLab")
|
|
35
|
+
Px.medical_labs = Relationship(back_populates="pxs", link_model="ClientLab")
|
{healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/medical_visit/medical_drug.py
RENAMED
|
@@ -5,8 +5,7 @@ from sqlmodel import SQLModel, Field, Relationship
|
|
|
5
5
|
|
|
6
6
|
from healthdatalayer.models.medical_visit.medical_drug_recipe import MedicalDrugRecipe
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
from healthdatalayer.models.medical_visit.medical_recipe_visit import MedicalRecipeVisit
|
|
8
|
+
|
|
10
9
|
|
|
11
10
|
class MedicalDrug(SQLModel, table=True):
|
|
12
11
|
__tablename__ = "medical_drug"
|
|
@@ -21,7 +20,4 @@ class MedicalDrug(SQLModel, table=True):
|
|
|
21
20
|
|
|
22
21
|
is_active: bool = Field(default=True)
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
back_populates="medical_drugs",
|
|
26
|
-
link_model=MedicalDrugRecipe
|
|
27
|
-
)
|
|
23
|
+
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import uuid
|
|
2
2
|
from datetime import datetime
|
|
3
|
-
from typing import Optional
|
|
4
|
-
from sqlmodel import SQLModel, Field
|
|
3
|
+
from typing import Optional, TYPE_CHECKING
|
|
4
|
+
from sqlmodel import SQLModel, Field, Relationship
|
|
5
|
+
|
|
6
|
+
#from healthdatalayer.models import MedicalDrug
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from healthdatalayer.models import MedicalRecipeVisit,MedicalDrug
|
|
5
9
|
|
|
6
10
|
class MedicalDrugRecipe(SQLModel, table=True):
|
|
7
11
|
__tablename__ = "medical_drug_recipe"
|
|
@@ -9,10 +13,13 @@ class MedicalDrugRecipe(SQLModel, table=True):
|
|
|
9
13
|
medical_drug_recipe_id:uuid.UUID=Field(default_factory=uuid.uuid4,primary_key=True)
|
|
10
14
|
|
|
11
15
|
medical_drug_id: uuid.UUID = Field(foreign_key="medical_drug.medical_drug_id", primary_key=True)
|
|
16
|
+
medical_drug: Optional["MedicalDrug"] = Relationship()
|
|
12
17
|
medical_recipe_visit_id: uuid.UUID = Field(foreign_key="medical_recipe_visit.medical_recipe_visit_id", primary_key=True)
|
|
18
|
+
medical_recipe_visit: Optional["MedicalRecipeVisit"] = Relationship()
|
|
13
19
|
|
|
14
20
|
quantity:int
|
|
15
21
|
suplied:bool
|
|
22
|
+
comment:Optional[str] = Field(default=None)
|
|
16
23
|
suplied_date: Optional[datetime] = Field(default=None)
|
|
17
|
-
|
|
24
|
+
|
|
18
25
|
is_active: bool = Field(default=True)
|
|
@@ -22,7 +22,7 @@ class MedicalRecipeVisit(SQLModel, table=True):
|
|
|
22
22
|
|
|
23
23
|
is_active: bool = Field(default=True)
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
back_populates="
|
|
27
|
-
|
|
25
|
+
medical_drug_recipes: List["MedicalDrugRecipe"] = Relationship(
|
|
26
|
+
back_populates="medical_recipe_visit",
|
|
27
|
+
sa_relationship_kwargs={"lazy": "selectin"}
|
|
28
28
|
)
|
|
@@ -52,6 +52,17 @@ class PxRepository:
|
|
|
52
52
|
from healthdatalayer.models.user.user import User
|
|
53
53
|
user_obj = session.get(User, px.user_id)
|
|
54
54
|
object.__setattr__(px, 'user', user_obj)
|
|
55
|
+
|
|
56
|
+
if px.nationality_id:
|
|
57
|
+
from healthdatalayer.models.client.nationality import Nationality
|
|
58
|
+
user_obj = session.get(Nationality, px.nationality_id)
|
|
59
|
+
object.__setattr__(px, 'nationality', user_obj)
|
|
60
|
+
|
|
61
|
+
from healthdatalayer.models.client.pathological_history import PathologicalHistory
|
|
62
|
+
statement = select(PathologicalHistory).where(PathologicalHistory.client_id == px_id)
|
|
63
|
+
pathological_his = session.exec(statement).all()
|
|
64
|
+
if pathological_his:
|
|
65
|
+
object.__setattr__(px, 'pathological_histories',pathological_his)
|
|
55
66
|
|
|
56
67
|
return px
|
|
57
68
|
|
|
@@ -90,6 +101,19 @@ class PxRepository:
|
|
|
90
101
|
from healthdatalayer.models.user.user import User
|
|
91
102
|
user_obj = session.get(User, px.user_id)
|
|
92
103
|
object.__setattr__(px, 'user', user_obj)
|
|
104
|
+
|
|
105
|
+
if px.nationality_id:
|
|
106
|
+
from healthdatalayer.models.client.nationality import Nationality
|
|
107
|
+
user_obj = session.get(Nationality, px.nationality_id)
|
|
108
|
+
object.__setattr__(px, 'nationality', user_obj)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
from healthdatalayer.models.client.pathological_history import PathologicalHistory
|
|
112
|
+
statement = select(PathologicalHistory).where(PathologicalHistory.client_id == px.client_id)
|
|
113
|
+
pathological_his = session.exec(statement).all()
|
|
114
|
+
if pathological_his:
|
|
115
|
+
object.__setattr__(px, 'pathological_histories',pathological_his)
|
|
116
|
+
|
|
93
117
|
|
|
94
118
|
return px
|
|
95
119
|
|
|
@@ -134,7 +158,18 @@ class PxRepository:
|
|
|
134
158
|
from healthdatalayer.models.user.user import User
|
|
135
159
|
user_obj = session.get(User, px.user_id)
|
|
136
160
|
object.__setattr__(px, 'user', user_obj)
|
|
137
|
-
|
|
161
|
+
if px.nationality_id:
|
|
162
|
+
from healthdatalayer.models.client.nationality import Nationality
|
|
163
|
+
user_obj = session.get(Nationality, px.nationality_id)
|
|
164
|
+
object.__setattr__(px, 'nationality', user_obj)
|
|
165
|
+
|
|
166
|
+
from healthdatalayer.models.client.pathological_history import PathologicalHistory
|
|
167
|
+
statement = select(PathologicalHistory).where(PathologicalHistory.client_id == px.client_id)
|
|
168
|
+
pathological_his = session.exec(statement).all()
|
|
169
|
+
if pathological_his:
|
|
170
|
+
object.__setattr__(px, 'pathological_histories',pathological_his)
|
|
171
|
+
|
|
172
|
+
|
|
138
173
|
return results
|
|
139
174
|
|
|
140
175
|
def list_all_command(self, active_only: bool = True, load_relations: bool = False) -> List[Px]:
|
|
@@ -177,6 +212,18 @@ class PxRepository:
|
|
|
177
212
|
from healthdatalayer.models.user.user import User
|
|
178
213
|
user_obj = session.get(User, px.user_id)
|
|
179
214
|
object.__setattr__(px, 'user', user_obj)
|
|
215
|
+
|
|
216
|
+
if px.nationality_id:
|
|
217
|
+
from healthdatalayer.models.client.nationality import Nationality
|
|
218
|
+
user_obj = session.get(Nationality, px.nationality_id)
|
|
219
|
+
object.__setattr__(px, 'nationality', user_obj)
|
|
220
|
+
|
|
221
|
+
from healthdatalayer.models.client.pathological_history import PathologicalHistory
|
|
222
|
+
statement = select(PathologicalHistory).where(PathologicalHistory.client_id == px.client_id)
|
|
223
|
+
pathological_his = session.exec(statement).all()
|
|
224
|
+
if pathological_his:
|
|
225
|
+
object.__setattr__(px, 'pathological_histories',pathological_his)
|
|
226
|
+
|
|
180
227
|
|
|
181
228
|
return results
|
|
182
229
|
|
|
@@ -19,8 +19,8 @@ class MedicalDrugRecipeRepository:
|
|
|
19
19
|
|
|
20
20
|
def get_by_id_command(self, medical_drug_recipe_id: UUID) -> Optional[MedicalDrugRecipe]:
|
|
21
21
|
with get_session(self.tenant) as session:
|
|
22
|
-
|
|
23
|
-
return session.
|
|
22
|
+
statement = select(MedicalDrugRecipe).where(MedicalDrugRecipe.medical_drug_recipe_id == medical_drug_recipe_id)
|
|
23
|
+
return session.exec(statement).first()
|
|
24
24
|
|
|
25
25
|
def list_all_command(self, active_only: bool = True)->List[MedicalDrugRecipe]:
|
|
26
26
|
with get_session(self.tenant) as session:
|
|
@@ -56,7 +56,8 @@ class MedicalDrugRecipeRepository:
|
|
|
56
56
|
|
|
57
57
|
def delete_command(self, medical_drug_recipe_id: UUID, soft_delete: bool = True) -> bool:
|
|
58
58
|
with get_session(self.tenant) as session:
|
|
59
|
-
|
|
59
|
+
statement = select(MedicalDrugRecipe).where(MedicalDrugRecipe.medical_drug_recipe_id == medical_drug_recipe_id)
|
|
60
|
+
db_medical_drug_recipe = session.exec(statement).first()
|
|
60
61
|
if not db_medical_drug_recipe:
|
|
61
62
|
return False
|
|
62
63
|
|
|
@@ -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 MedicalDrug
|
|
6
6
|
from healthdatalayer.config.db import engines, get_session
|
|
@@ -60,4 +60,19 @@ class MedicalDrugRepository:
|
|
|
60
60
|
session.delete(db_medical_drug)
|
|
61
61
|
|
|
62
62
|
session.commit()
|
|
63
|
-
return True
|
|
63
|
+
return True
|
|
64
|
+
|
|
65
|
+
def get_by_name_code_ilike_command(self, name:str, active_only: bool = True) -> List[MedicalDrug]:
|
|
66
|
+
with get_session(self.tenant) as session:
|
|
67
|
+
statement = select(MedicalDrug).where(
|
|
68
|
+
or_(
|
|
69
|
+
MedicalDrug.drug_name.ilike(f"%{name}%"),
|
|
70
|
+
MedicalDrug.drug_code.ilike(f"%{name}%")
|
|
71
|
+
)
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
if active_only:
|
|
75
|
+
statement = statement.where(MedicalDrug.is_active == True)
|
|
76
|
+
|
|
77
|
+
medical_diagnosis = session.exec(statement).all()
|
|
78
|
+
return medical_diagnosis
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
from typing import Optional, List
|
|
2
2
|
from uuid import UUID
|
|
3
|
-
from sqlmodel import select, or_
|
|
3
|
+
from sqlmodel import select, or_, text
|
|
4
4
|
from sqlalchemy.orm import selectinload,joinedload
|
|
5
|
-
from healthdatalayer.models import MedicalRecipeVisit
|
|
5
|
+
from healthdatalayer.models import MedicalRecipeVisit, MedicalDrugRecipe, MedicalDrug
|
|
6
|
+
from healthdatalayer.dtos import HeaderRecipe, RecipeMedicalDrugData
|
|
6
7
|
from healthdatalayer.config.db import engines, get_session
|
|
7
8
|
|
|
8
9
|
class MedicalRecipeVisitRepository:
|
|
@@ -24,7 +25,7 @@ class MedicalRecipeVisitRepository:
|
|
|
24
25
|
if load_relations:
|
|
25
26
|
statement = select(MedicalRecipeVisit).where(MedicalRecipeVisit.medical_recipe_visit_id == medical_recipe_visit_id).options(
|
|
26
27
|
joinedload(MedicalRecipeVisit.medical_visit),
|
|
27
|
-
|
|
28
|
+
selectinload(MedicalRecipeVisit.medical_drug_recipes).selectinload(MedicalDrugRecipe.medical_drug)
|
|
28
29
|
)
|
|
29
30
|
medical_recipe_visit = session.exec(statement).first()
|
|
30
31
|
|
|
@@ -38,7 +39,7 @@ class MedicalRecipeVisitRepository:
|
|
|
38
39
|
if load_relations:
|
|
39
40
|
statement = statement.options(
|
|
40
41
|
selectinload(MedicalRecipeVisit.medical_visit),
|
|
41
|
-
selectinload(MedicalRecipeVisit.
|
|
42
|
+
selectinload(MedicalRecipeVisit.medical_drug_recipes).selectinload(MedicalDrugRecipe.medical_drug)
|
|
42
43
|
)
|
|
43
44
|
medical_recipe_visit = session.exec(statement).first()
|
|
44
45
|
|
|
@@ -52,7 +53,7 @@ class MedicalRecipeVisitRepository:
|
|
|
52
53
|
|
|
53
54
|
statement = select(MedicalRecipeVisit).options(
|
|
54
55
|
selectinload(MedicalRecipeVisit.medical_visit),
|
|
55
|
-
selectinload(MedicalRecipeVisit.
|
|
56
|
+
selectinload(MedicalRecipeVisit.medical_drug_recipes).selectinload(MedicalDrugRecipe.medical_drug)
|
|
56
57
|
)
|
|
57
58
|
if active_only:
|
|
58
59
|
statement = statement.where(MedicalRecipeVisit.is_active == True)
|
|
@@ -90,4 +91,55 @@ class MedicalRecipeVisitRepository:
|
|
|
90
91
|
session.delete(existing_medical_recipe_visit)
|
|
91
92
|
|
|
92
93
|
session.commit()
|
|
93
|
-
|
|
94
|
+
|
|
95
|
+
def get_header_recipe_data(self, med_recipe_visit_id : str) ->Optional[HeaderRecipe]:
|
|
96
|
+
with get_session(self.tenant) as session:
|
|
97
|
+
query= text("""
|
|
98
|
+
select mv.visit_date, c."name" as name_doctor,
|
|
99
|
+
c.ruc, c.code,
|
|
100
|
+
px.first_name as first_name_px , px.last_name as last_name_px
|
|
101
|
+
from medical_recipe_visit mrv
|
|
102
|
+
join medical_visit mv on mv.medical_visit_id = mrv.medical_visit_id
|
|
103
|
+
join collaborator c on c.collaborator_id = mv.collaborator_id
|
|
104
|
+
join px on px.client_id = mv.client_id
|
|
105
|
+
where mrv.medical_recipe_visit_id = :med_recipe_visit_id
|
|
106
|
+
""")
|
|
107
|
+
result = session.exec(query, params={"med_recipe_visit_id": med_recipe_visit_id})
|
|
108
|
+
|
|
109
|
+
row = result.fetchone()
|
|
110
|
+
|
|
111
|
+
if not row:
|
|
112
|
+
raise ValueError(f"No se encontró la visita médica con ID: {med_recipe_visit_id}")
|
|
113
|
+
|
|
114
|
+
return HeaderRecipe(
|
|
115
|
+
visit_date=row[0],
|
|
116
|
+
name_doctor=row[1],
|
|
117
|
+
ruc=row[2],
|
|
118
|
+
code=row[3],
|
|
119
|
+
first_name_px=row[4],
|
|
120
|
+
last_name_px=row[5]
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
def get_recipe_drugs_data(self, med_recipe_visit_id : str) ->List[RecipeMedicalDrugData]:
|
|
124
|
+
with get_session(self.tenant) as session:
|
|
125
|
+
query = text("""
|
|
126
|
+
select md.drug_name, mdr."comment", mdr.quantity from medical_recipe_visit mrv
|
|
127
|
+
left join medical_drug_recipe mdr on mrv.medical_recipe_visit_id = mdr.medical_recipe_visit_id
|
|
128
|
+
left join medical_drug md on md.medical_drug_id = mdr.medical_drug_id
|
|
129
|
+
where mrv.medical_recipe_visit_id = :med_recipe_visit_id
|
|
130
|
+
""")
|
|
131
|
+
|
|
132
|
+
result = session.exec(query, params={"med_recipe_visit_id": med_recipe_visit_id})
|
|
133
|
+
rows = result.fetchall()
|
|
134
|
+
|
|
135
|
+
# Convertir cada fila a DiagnosisDTO
|
|
136
|
+
recipe_list = []
|
|
137
|
+
for row in rows:
|
|
138
|
+
diagnosis = RecipeMedicalDrugData(
|
|
139
|
+
drug_name=row[0],
|
|
140
|
+
comment=row[1],
|
|
141
|
+
quantity=row[2]
|
|
142
|
+
)
|
|
143
|
+
recipe_list.append(diagnosis)
|
|
144
|
+
|
|
145
|
+
return recipe_list
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
from typing import Optional, List
|
|
2
2
|
from datetime import datetime, date, time
|
|
3
3
|
from uuid import UUID
|
|
4
|
-
from sqlmodel import select
|
|
4
|
+
from sqlmodel import select, text
|
|
5
5
|
from sqlalchemy.orm import selectinload,joinedload
|
|
6
|
-
from healthdatalayer.models import MedicalVisit
|
|
6
|
+
from healthdatalayer.models import MedicalVisit,MedicalDiagnosisVisit
|
|
7
|
+
from healthdatalayer.dtos import MedicalCertificateDTO, DiagnosisDTO, MedicalDiagnosesDTO
|
|
7
8
|
from healthdatalayer.config.db import engines, get_session
|
|
8
9
|
|
|
9
10
|
class MedicalVisitRepository:
|
|
@@ -27,7 +28,7 @@ class MedicalVisitRepository:
|
|
|
27
28
|
joinedload(MedicalVisit.client),
|
|
28
29
|
joinedload(MedicalVisit.collaborator),
|
|
29
30
|
joinedload(MedicalVisit.speciality),
|
|
30
|
-
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
31
|
+
selectinload(MedicalVisit.medical_diagnosis_visits).selectinload(MedicalDiagnosisVisit.medical_diagnosis),
|
|
31
32
|
selectinload(MedicalVisit.medical_recipe_visits),
|
|
32
33
|
selectinload(MedicalVisit.organ_system_reviews),
|
|
33
34
|
selectinload(MedicalVisit.physical_exams)
|
|
@@ -72,7 +73,7 @@ class MedicalVisitRepository:
|
|
|
72
73
|
joinedload(MedicalVisit.client),
|
|
73
74
|
joinedload(MedicalVisit.collaborator),
|
|
74
75
|
joinedload(MedicalVisit.speciality),
|
|
75
|
-
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
76
|
+
selectinload(MedicalVisit.medical_diagnosis_visits).selectinload(MedicalDiagnosisVisit.medical_diagnosis),
|
|
76
77
|
selectinload(MedicalVisit.medical_recipe_visits),
|
|
77
78
|
selectinload(MedicalVisit.organ_system_reviews),
|
|
78
79
|
selectinload(MedicalVisit.physical_exams)
|
|
@@ -92,7 +93,7 @@ class MedicalVisitRepository:
|
|
|
92
93
|
joinedload(MedicalVisit.client),
|
|
93
94
|
joinedload(MedicalVisit.collaborator),
|
|
94
95
|
joinedload(MedicalVisit.speciality),
|
|
95
|
-
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
96
|
+
selectinload(MedicalVisit.medical_diagnosis_visits).selectinload(MedicalDiagnosisVisit.medical_diagnosis),
|
|
96
97
|
selectinload(MedicalVisit.medical_recipe_visits),
|
|
97
98
|
selectinload(MedicalVisit.organ_system_reviews),
|
|
98
99
|
selectinload(MedicalVisit.physical_exams)
|
|
@@ -136,7 +137,7 @@ class MedicalVisitRepository:
|
|
|
136
137
|
joinedload(MedicalVisit.client),
|
|
137
138
|
joinedload(MedicalVisit.collaborator),
|
|
138
139
|
joinedload(MedicalVisit.speciality),
|
|
139
|
-
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
140
|
+
selectinload(MedicalVisit.medical_diagnosis_visits).selectinload(MedicalDiagnosisVisit.medical_diagnosis),
|
|
140
141
|
selectinload(MedicalVisit.medical_recipe_visits),
|
|
141
142
|
selectinload(MedicalVisit.organ_system_reviews),
|
|
142
143
|
selectinload(MedicalVisit.physical_exams)
|
|
@@ -172,7 +173,7 @@ class MedicalVisitRepository:
|
|
|
172
173
|
joinedload(MedicalVisit.client),
|
|
173
174
|
joinedload(MedicalVisit.collaborator),
|
|
174
175
|
joinedload(MedicalVisit.speciality),
|
|
175
|
-
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
176
|
+
selectinload(MedicalVisit.medical_diagnosis_visits).selectinload(MedicalDiagnosisVisit.medical_diagnosis),
|
|
176
177
|
selectinload(MedicalVisit.medical_recipe_visits),
|
|
177
178
|
selectinload(MedicalVisit.organ_system_reviews),
|
|
178
179
|
selectinload(MedicalVisit.physical_exams)
|
|
@@ -197,7 +198,7 @@ class MedicalVisitRepository:
|
|
|
197
198
|
joinedload(MedicalVisit.client),
|
|
198
199
|
joinedload(MedicalVisit.collaborator),
|
|
199
200
|
joinedload(MedicalVisit.speciality),
|
|
200
|
-
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
201
|
+
selectinload(MedicalVisit.medical_diagnosis_visits).selectinload(MedicalDiagnosisVisit.medical_diagnosis),
|
|
201
202
|
selectinload(MedicalVisit.medical_recipe_visits),
|
|
202
203
|
selectinload(MedicalVisit.organ_system_reviews),
|
|
203
204
|
selectinload(MedicalVisit.physical_exams)
|
|
@@ -234,7 +235,7 @@ class MedicalVisitRepository:
|
|
|
234
235
|
joinedload(MedicalVisit.client),
|
|
235
236
|
joinedload(MedicalVisit.collaborator),
|
|
236
237
|
joinedload(MedicalVisit.speciality),
|
|
237
|
-
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
238
|
+
selectinload(MedicalVisit.medical_diagnosis_visits).selectinload(MedicalDiagnosisVisit.medical_diagnosis),
|
|
238
239
|
selectinload(MedicalVisit.medical_recipe_visits),
|
|
239
240
|
selectinload(MedicalVisit.organ_system_reviews),
|
|
240
241
|
selectinload(MedicalVisit.physical_exams)
|
|
@@ -258,7 +259,7 @@ class MedicalVisitRepository:
|
|
|
258
259
|
joinedload(MedicalVisit.client),
|
|
259
260
|
joinedload(MedicalVisit.collaborator),
|
|
260
261
|
joinedload(MedicalVisit.speciality),
|
|
261
|
-
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
262
|
+
selectinload(MedicalVisit.medical_diagnosis_visits).selectinload(MedicalDiagnosisVisit.medical_diagnosis),
|
|
262
263
|
selectinload(MedicalVisit.medical_recipe_visits),
|
|
263
264
|
selectinload(MedicalVisit.organ_system_reviews),
|
|
264
265
|
selectinload(MedicalVisit.physical_exams)
|
|
@@ -279,7 +280,7 @@ class MedicalVisitRepository:
|
|
|
279
280
|
joinedload(MedicalVisit.client),
|
|
280
281
|
joinedload(MedicalVisit.collaborator),
|
|
281
282
|
joinedload(MedicalVisit.speciality),
|
|
282
|
-
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
283
|
+
selectinload(MedicalVisit.medical_diagnosis_visits).selectinload(MedicalDiagnosisVisit.medical_diagnosis),
|
|
283
284
|
selectinload(MedicalVisit.medical_recipe_visits),
|
|
284
285
|
selectinload(MedicalVisit.organ_system_reviews),
|
|
285
286
|
selectinload(MedicalVisit.physical_exams)
|
|
@@ -300,7 +301,7 @@ class MedicalVisitRepository:
|
|
|
300
301
|
joinedload(MedicalVisit.client),
|
|
301
302
|
joinedload(MedicalVisit.collaborator),
|
|
302
303
|
joinedload(MedicalVisit.speciality),
|
|
303
|
-
selectinload(MedicalVisit.medical_diagnosis_visits),
|
|
304
|
+
selectinload(MedicalVisit.medical_diagnosis_visits).selectinload(MedicalDiagnosisVisit.medical_diagnosis),
|
|
304
305
|
selectinload(MedicalVisit.medical_recipe_visits),
|
|
305
306
|
selectinload(MedicalVisit.organ_system_reviews),
|
|
306
307
|
selectinload(MedicalVisit.physical_exams)
|
|
@@ -342,4 +343,167 @@ class MedicalVisitRepository:
|
|
|
342
343
|
statement = select(MedicalVisit).where(MedicalVisit.collaborator_id == collaborator_id, MedicalVisit.visit_date == target_date)
|
|
343
344
|
result = session.exec(statement).first()
|
|
344
345
|
return result is not None
|
|
345
|
-
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
def get_data_medical_certificate_command(self, medical_visit_id: str) -> MedicalCertificateDTO:
|
|
349
|
+
|
|
350
|
+
with get_session(self.tenant) as session:
|
|
351
|
+
|
|
352
|
+
query = text("""
|
|
353
|
+
select
|
|
354
|
+
s."name" as "sys",
|
|
355
|
+
b2."name" as stablishment,
|
|
356
|
+
px.medical_record_number,
|
|
357
|
+
px.identification as number_his,
|
|
358
|
+
px.last_name ,
|
|
359
|
+
px.first_name,
|
|
360
|
+
case
|
|
361
|
+
when g.name ='Male' then 'M'
|
|
362
|
+
else 'F'
|
|
363
|
+
end as sex,
|
|
364
|
+
EXTRACT(YEAR FROM AGE(px.birth_date)) AS age,
|
|
365
|
+
sp.name as service,
|
|
366
|
+
sp.subspeciality as speciality,
|
|
367
|
+
EXTRACT(YEAR FROM mv.visit_date) AS year_visit,
|
|
368
|
+
EXTRACT(MONTH FROM mv.visit_date) AS month_visit,
|
|
369
|
+
EXTRACT(DAY FROM mv.visit_date) AS day_visit,
|
|
370
|
+
mv.visit_date::time AS hour_start,
|
|
371
|
+
(mv.visit_date + INTERVAL '30 minutes')::time AS hour_end,
|
|
372
|
+
TO_CHAR(mv.visit_date, 'DD') || ' de ' ||
|
|
373
|
+
CASE EXTRACT(MONTH FROM mv.visit_date)
|
|
374
|
+
WHEN 1 THEN 'enero'
|
|
375
|
+
WHEN 2 THEN 'febrero'
|
|
376
|
+
WHEN 3 THEN 'marzo'
|
|
377
|
+
WHEN 4 THEN 'abril'
|
|
378
|
+
WHEN 5 THEN 'mayo'
|
|
379
|
+
WHEN 6 THEN 'junio'
|
|
380
|
+
WHEN 7 THEN 'julio'
|
|
381
|
+
WHEN 8 THEN 'agosto'
|
|
382
|
+
WHEN 9 THEN 'septiembre'
|
|
383
|
+
WHEN 10 THEN 'octubre'
|
|
384
|
+
WHEN 11 THEN 'noviembre'
|
|
385
|
+
WHEN 12 THEN 'diciembre'
|
|
386
|
+
END || ' del ' || EXTRACT(YEAR FROM mv.visit_date) AS visit_date_spanish,
|
|
387
|
+
mv.rest,
|
|
388
|
+
mv.rest_hours,
|
|
389
|
+
mv.rest_date_start ,
|
|
390
|
+
EXTRACT(YEAR FROM mv.rest_date_start) AS year_rest_start,
|
|
391
|
+
EXTRACT(MONTH FROM mv.rest_date_start) AS month_rest_start,
|
|
392
|
+
EXTRACT(DAY FROM mv.rest_date_start) AS day_rest_start,
|
|
393
|
+
TO_CHAR(mv.rest_date_start, 'DD') || ' de ' ||
|
|
394
|
+
CASE EXTRACT(MONTH FROM mv.rest_date_start)
|
|
395
|
+
WHEN 1 THEN 'enero'
|
|
396
|
+
WHEN 2 THEN 'febrero'
|
|
397
|
+
WHEN 3 THEN 'marzo'
|
|
398
|
+
WHEN 4 THEN 'abril'
|
|
399
|
+
WHEN 5 THEN 'mayo'
|
|
400
|
+
WHEN 6 THEN 'junio'
|
|
401
|
+
WHEN 7 THEN 'julio'
|
|
402
|
+
WHEN 8 THEN 'agosto'
|
|
403
|
+
WHEN 9 THEN 'septiembre'
|
|
404
|
+
WHEN 10 THEN 'octubre'
|
|
405
|
+
WHEN 11 THEN 'noviembre'
|
|
406
|
+
WHEN 12 THEN 'diciembre'
|
|
407
|
+
END || ' del ' || EXTRACT(YEAR FROM mv.rest_date_start) AS rest_date_start_spanish,
|
|
408
|
+
mv.rest_date_end,
|
|
409
|
+
EXTRACT(YEAR FROM mv.rest_date_end) AS year_rest_end,
|
|
410
|
+
EXTRACT(MONTH FROM mv.rest_date_end) AS month_rest_end,
|
|
411
|
+
EXTRACT(DAY FROM mv.rest_date_end) AS day_rest_end,
|
|
412
|
+
TO_CHAR( mv.rest_date_end, 'DD') || ' de ' ||
|
|
413
|
+
CASE EXTRACT(MONTH FROM mv.rest_date_end)
|
|
414
|
+
WHEN 1 THEN 'enero'
|
|
415
|
+
WHEN 2 THEN 'febrero'
|
|
416
|
+
WHEN 3 THEN 'marzo'
|
|
417
|
+
WHEN 4 THEN 'abril'
|
|
418
|
+
WHEN 5 THEN 'mayo'
|
|
419
|
+
WHEN 6 THEN 'junio'
|
|
420
|
+
WHEN 7 THEN 'julio'
|
|
421
|
+
WHEN 8 THEN 'agosto'
|
|
422
|
+
WHEN 9 THEN 'septiembre'
|
|
423
|
+
WHEN 10 THEN 'octubre'
|
|
424
|
+
WHEN 11 THEN 'noviembre'
|
|
425
|
+
WHEN 12 THEN 'diciembre'
|
|
426
|
+
END || ' del ' || EXTRACT(YEAR FROM mv.rest_date_end) AS rest_date_end_spanish,
|
|
427
|
+
c.name as doctor_name,
|
|
428
|
+
c.ruc as doctor_ruc
|
|
429
|
+
from medical_visit mv
|
|
430
|
+
left join px on px.client_id = mv.client_id
|
|
431
|
+
left join gender g on g.gender_id = px.gender_id
|
|
432
|
+
left join collaborator c on c.collaborator_id = mv.collaborator_id
|
|
433
|
+
left join bridge_area_floor_branch b on b.bridge_area_floor_branch_id = mv.bridge_area_floor_branch_id
|
|
434
|
+
left join branch b2 on b.branch_id = b2.branch_id
|
|
435
|
+
left join "system" s on s.system_id = b2.system_id
|
|
436
|
+
left join speciality sp on sp.speciality_id = mv.speciality_id
|
|
437
|
+
where mv.medical_visit_id = :medical_visit_id
|
|
438
|
+
and mv.status_visit != 'CANCELADO'
|
|
439
|
+
""")
|
|
440
|
+
|
|
441
|
+
result = session.exec(query, params={"medical_visit_id": medical_visit_id})
|
|
442
|
+
|
|
443
|
+
row = result.fetchone()
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
if not row:
|
|
447
|
+
raise ValueError(f"No se encontró la visita médica con ID: {medical_visit_id}")
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
return MedicalCertificateDTO(
|
|
451
|
+
sys=row[0],
|
|
452
|
+
stablishment=row[1],
|
|
453
|
+
medical_record_number=row[2],
|
|
454
|
+
number_his=row[3],
|
|
455
|
+
last_name=row[4],
|
|
456
|
+
first_name=row[5],
|
|
457
|
+
sex=row[6],
|
|
458
|
+
age=row[7],
|
|
459
|
+
service=row[8],
|
|
460
|
+
speciality=row[9],
|
|
461
|
+
year_visit=row[10],
|
|
462
|
+
month_visit=row[11],
|
|
463
|
+
day_visit=row[12],
|
|
464
|
+
hour_start=row[13],
|
|
465
|
+
hour_end=row[14],
|
|
466
|
+
visit_date_spanish=row[15],
|
|
467
|
+
rest=row[16],
|
|
468
|
+
rest_hours=row[17],
|
|
469
|
+
rest_date_start=row[18],
|
|
470
|
+
year_rest_start=row[19],
|
|
471
|
+
month_rest_start=row[20],
|
|
472
|
+
day_rest_start=row[21],
|
|
473
|
+
rest_date_start_spanish=row[22],
|
|
474
|
+
rest_date_end=row[23],
|
|
475
|
+
year_rest_end=row[24],
|
|
476
|
+
month_rest_end=row[25],
|
|
477
|
+
day_rest_end=row[26],
|
|
478
|
+
rest_date_end_spanish=row[27],
|
|
479
|
+
doctor_name=row[28],
|
|
480
|
+
doctor_ruc=row[29]
|
|
481
|
+
)
|
|
482
|
+
|
|
483
|
+
def get_medical_diagnoses_command(self, medical_visit_id: str) -> MedicalDiagnosesDTO:
|
|
484
|
+
|
|
485
|
+
with get_session(self.tenant) as session:
|
|
486
|
+
|
|
487
|
+
query = text("""
|
|
488
|
+
select md."name" as name_diagnosis,
|
|
489
|
+
md.cie_10_code
|
|
490
|
+
from medical_diagnosis md
|
|
491
|
+
join medical_diagnosis_visit mdv on mdv.medical_diagnosis_id = md.medical_diagnosis_id
|
|
492
|
+
where md.is_active = true
|
|
493
|
+
and mdv.is_active = true
|
|
494
|
+
and mdv.medical_visit_id = :medical_visit_id
|
|
495
|
+
""")
|
|
496
|
+
|
|
497
|
+
result = session.exec(query, params={"medical_visit_id": medical_visit_id})
|
|
498
|
+
rows = result.fetchall()
|
|
499
|
+
|
|
500
|
+
# Convertir cada fila a DiagnosisDTO
|
|
501
|
+
diagnoses_list = []
|
|
502
|
+
for row in rows:
|
|
503
|
+
diagnosis = DiagnosisDTO(
|
|
504
|
+
name_diagnosis=row[0],
|
|
505
|
+
cie_10_code=row[1]
|
|
506
|
+
)
|
|
507
|
+
diagnoses_list.append(diagnosis)
|
|
508
|
+
|
|
509
|
+
return MedicalDiagnosesDTO(diagnoses=diagnoses_list)
|
|
File without changes
|
|
@@ -13,6 +13,9 @@ healthdatalayer/config/vault.py
|
|
|
13
13
|
healthdatalayer/dtos/__init__.py
|
|
14
14
|
healthdatalayer/dtos/collaborator/__init__.py
|
|
15
15
|
healthdatalayer/dtos/collaborator/schedule_collaborator.py
|
|
16
|
+
healthdatalayer/dtos/medical_visit/__init__.py
|
|
17
|
+
healthdatalayer/dtos/medical_visit/medical_certificate.py
|
|
18
|
+
healthdatalayer/dtos/medical_visit/recipe_dto.py
|
|
16
19
|
healthdatalayer/models/__init__.py
|
|
17
20
|
healthdatalayer/models/bridge_area_floor_branch/__init__.py
|
|
18
21
|
healthdatalayer/models/bridge_area_floor_branch/area.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .collaborator.schedule_collaborator import ScheduleCollaboratorDTO
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/dtos/collaborator/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/client/client_type.py
RENAMED
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/client/emergency_contact.py
RENAMED
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/client/marriage_status.py
RENAMED
|
File without changes
|
{healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/client/nationality.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/collaborator/collaborator.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/collaborator/speciality.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/medical_visit/visit_triage.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/user/permission_user.py
RENAMED
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer/models/user/role_permission.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{healthdatalayer-1.5.8 → healthdatalayer-1.7.0}/healthdatalayer.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|