This commit is contained in:
2025-10-16 16:43:18 +03:00
parent cb3b138241
commit a4239a0c52
21 changed files with 524 additions and 140 deletions

View File

@ -6,6 +6,7 @@ from typing import Annotated
from fastapi import APIRouter, Body, Depends, status
from apps.users.auth import login
from apps.users.models import User
from clients import clients as c
from clients.vitacore import schema as s
from shared.redis import client as cache
@ -20,16 +21,16 @@ router = APIRouter(
@router.get('/getProfile', response_model=s.ProfileModel)
async def get_profile():
async def get_profile(user: Annotated[User, Depends(login)]):
"""
Get profile of user by id.
Get profile of user.
"""
return await c.vitacore_api.getProfile(
'b62e9f22-a871-4c52-96d6-559c707a716d'
)
return await c.vitacore_api.getProfile(user.vita_id)
@router.get('/getDepartments', response_model=list[s.DepartmentModel])
@router.get('/getDepartments',
# response_model=list[s.DepartmentModel]
)
async def get_departments():
"""
Get list of departments.
@ -38,7 +39,9 @@ async def get_departments():
@router.get('/getWorkers', response_model=s.WorkersModel)
async def get_workers(departmentId: str):
async def get_workers(
user: Annotated[User, Depends(login)], departmentId: str
):
"""
Get list of workers by department id.
"""
@ -46,7 +49,7 @@ async def get_workers(departmentId: str):
@router.get('/getSpecs', response_model=s.SpecsV021Model)
async def get_specs():
async def get_specs(user: Annotated[User, Depends(login)]):
"""
Get list of specialties.
"""
@ -54,27 +57,23 @@ async def get_specs():
@router.get('/getEntries', response_model=s.EntriesModel)
async def get_entries():
async def get_entries(user: Annotated[User, Depends(login)]):
"""
Get list of entries for user by id.
"""
return await c.vitacore_api.getEntries(
'6c7978f0-c573-4ccf-8c6e-f0cd9aceb1e1'
)
return await c.vitacore_api.getEntries(user.vita_id)
@router.get('/getVaccsReport')
async def get_vaccs_report():
async def get_vaccs_report(user: Annotated[User, Depends(login)]):
"""
Get report of vaccinations for user by id.
"""
return await c.vitacore_api.getVaccsReport(
'6fe66cae-409a-4f56-8ae9-d55d3c38569b'
)
return await c.vitacore_api.getVaccsReport(user.vita_id)
@router.get('/getMedExamDict')
async def get_med_exam_dict():
async def get_med_exam_dict(user: Annotated[User, Depends(login)]):
"""
Get medical examination dictionary.
"""
@ -82,92 +81,80 @@ async def get_med_exam_dict():
@router.get('/getRoutesList')
async def get_routes_list():
async def get_routes_list(user: Annotated[User, Depends(login)]):
"""
Get list of routes.
"""
return await c.vitacore_api.getRoutesList(
'4e6de5f7-4dc9-451b-bf0d-7a64a9b8c279'
)
return await c.vitacore_api.getRoutesList(user.vita_id)
@router.get('/getHospExaminations')
async def get_hosp_examinations():
async def get_hosp_examinations(
user: Annotated[User, Depends(login)], examId: str
):
"""
Get list of hospital examinations.
"""
return await c.vitacore_api.getHospExaminations(
'7bbdac30-9a33-4f13-9458-2c229c0c20f5',
'f22be2c9-8e68-42d6-851e-fbf4a5e8f657',
user.vita_id,
examId,
)
@router.get('/getCurrHosp')
async def get_curr_hosp():
async def get_curr_hosp(user: Annotated[User, Depends(login)]):
"""
Get current hospitalization.
"""
return await c.vitacore_api.getCurrHosp(
'b708e782-4f83-4f3b-8639-512c0c9637bf'
)
return await c.vitacore_api.getCurrHosp(user.vita_id)
@router.get('/getHosps')
async def get_hosps():
async def get_hosps(user: Annotated[User, Depends(login)]):
"""
Get list of hospitals.
"""
return await c.vitacore_api.getHosps(
'b708e782-4f83-4f3b-8639-512c0c9637bf'
)
return await c.vitacore_api.getHosps(user.vita_id)
@router.get('/getHospRecommendations')
async def get_hosp_recommendations():
async def get_hosp_recommendations(user: Annotated[User, Depends(login)]):
"""
Get list of recommended hospitals.
"""
return await c.vitacore_api.getHospRecommendations(
'b708e782-4f83-4f3b-8639-512c0c9637bf'
)
return await c.vitacore_api.getHospRecommendations(user.vita_id)
@router.get('/getHospRoutes')
async def get_hosp_routes():
async def get_hosp_routes(user: Annotated[User, Depends(login)]):
"""
Get list of recommended hospitals.
"""
return await c.vitacore_api.getHospRoutes(
'3092e1c5-e08b-4654-a027-82be90fe8a49'
)
return await c.vitacore_api.getHospRoutes(user.vita_id)
@router.get('/getDiagnosticResults')
async def get_diagnostic_results():
async def get_diagnostic_results(user: Annotated[User, Depends(login)]):
"""
Get list of diagnostic results.
"""
return await c.vitacore_api.getDiagnosticResults(
'4867cc79-9805-4ae2-98d3-2f822848635e'
)
return await c.vitacore_api.getDiagnosticResults(user.vita_id)
@router.get('/getELNs')
async def get_eln():
async def get_eln(user: Annotated[User, Depends(login)]):
"""
Get list of ELNs.
"""
return await c.vitacore_api.getELNs('d4493f1c-fcbb-4242-99e6-32328bed53b9')
return await c.vitacore_api.getELNs(user.vita_id)
@router.get('/getPatFLG')
async def get_pat_flg():
async def get_pat_flg(user: Annotated[User, Depends(login)]):
"""
Get list of ELNs.
"""
return await c.vitacore_api.getPatFLG(
'0bf2e271-e565-42a8-924e-0017bcdedecd'
)
return await c.vitacore_api.getPatFLG(user.vita_id)
# @router.post('/measurement', status_code=status.HTTP_202_ACCEPTED)
@ -191,7 +178,7 @@ async def get_pat_flg():
@router.post('/measurement', status_code=status.HTTP_202_ACCEPTED)
async def measurement(
user: Annotated[str, Depends(login)],
user: Annotated[User, Depends(login)],
ad: Annotated[int, Body()],
sd: Annotated[int, Body()],
pulse: Annotated[int, Body()],
@ -208,7 +195,7 @@ async def measurement(
'comment': comment,
'status': status,
}
cache_key = f'tdn:measurement:{user}:{created}'
cache_key = f'tdn:measurement:{user.id}:{created}'
cache.set(cache_key, dumps(data))
return
@ -221,28 +208,35 @@ async def measurements(
return data
@router.get('/test')
async def test_route():
return await c.aemd_api.searchRegistryItem('16247900267')
@router.get('/queue')
async def queue(user: Annotated[bool, Depends(login)]):
return {
'id': 60,
'guid': '92b3343d-1cb2-47b2-8497-a37e38b6ba24',
'tmk_date': None,
'created_at': '2025-04-02 15:21:19.890343',
'code_mo': '166502',
'mo_name': 'ГАУЗ "ГКБ№7 ИМ. М.Н.САДЫКОВА"',
'doctor_spec': '109',
'doctor_snils': None,
'patient_name': 'Иванов Петр Федорович',
'patient_birthday': '1997-03-01',
'patient_snils': '099-678-666 12',
'patient_policy': None,
'patient_phone': '+79123456789',
'patient_email': None,
'tmk_status': 1,
'tmk_status_name': 'Создана',
'tmk_cancel_reason': None,
'tmk_cancel_reason_name': None,
'vks_doctor_link': None,
'vks_patient_link': None,
'doctor_spec_name': 'врач-терапевт',
}
return [
{
'id': 60,
'guid': '92b3343d-1cb2-47b2-8497-a37e38b6ba24',
'tmk_date': None,
'created_at': '2025-04-02 15:21:19.890343',
'code_mo': '166502',
'mo_name': 'ГАУЗ "ГКБ№7 ИМ. М.Н.САДЫКОВА"',
'doctor_spec': '109',
'doctor_snils': None,
'patient_name': 'Иванов Петр Федорович',
'patient_birthday': '1997-03-01',
'patient_snils': '099-678-666 12',
'patient_policy': None,
'patient_phone': '+79123456789',
'patient_email': None,
'tmk_status': 1,
'tmk_status_name': 'Создана',
'tmk_cancel_reason': None,
'tmk_cancel_reason_name': None,
'vks_doctor_link': None,
'vks_patient_link': None,
'doctor_spec_name': 'врач-терапевт',
}
]