Переработан эндпоинт getProfile на использование http клиента
All checks were successful
Build And Push / publish (push) Successful in 1m41s
All checks were successful
Build And Push / publish (push) Successful in 1m41s
This commit is contained in:
@ -6,6 +6,7 @@ from typing import Annotated, Any
|
||||
from fastapi import APIRouter, Body, Depends, status
|
||||
|
||||
from apps.users.auth import login
|
||||
from clients import clients as c
|
||||
from shared.redis import client as cache
|
||||
|
||||
from . import mock
|
||||
@ -95,8 +96,10 @@ async def find_pat(user: Annotated[str, Depends(login)]):
|
||||
|
||||
|
||||
@router.get('/getProfile')
|
||||
async def get_profile(user: Annotated[str, Depends(login)]):
|
||||
return mock.profile[0]
|
||||
async def get_profile():
|
||||
return await c.vitacore_api.getProfile(
|
||||
'3c963d68-14e5-4a43-ab15-1d2d19b76398'
|
||||
)
|
||||
|
||||
|
||||
@router.get('/getHosps')
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
from .esia.api import ESIA_API
|
||||
from .vitacore.api import VITACORE_API
|
||||
|
||||
|
||||
class ClientsObject:
|
||||
_esia_api = None
|
||||
_vitacore_api = None
|
||||
|
||||
@property
|
||||
def esia_api(self):
|
||||
@ -11,5 +13,12 @@ class ClientsObject:
|
||||
|
||||
return self._esia_api
|
||||
|
||||
@property
|
||||
def vitacore_api(self):
|
||||
if not self._vitacore_api:
|
||||
self._vitacore_api = VITACORE_API()
|
||||
|
||||
return self._vitacore_api
|
||||
|
||||
|
||||
clients = ClientsObject()
|
||||
|
||||
0
src/clients/vitacore/__init__.py
Normal file
0
src/clients/vitacore/__init__.py
Normal file
28
src/clients/vitacore/api.py
Normal file
28
src/clients/vitacore/api.py
Normal file
@ -0,0 +1,28 @@
|
||||
from logging import getLogger
|
||||
|
||||
from fastapi import status as st
|
||||
from httpx import AsyncClient
|
||||
|
||||
from core.config import settings
|
||||
from shared import exceptions as e
|
||||
|
||||
from . import schema as s
|
||||
|
||||
|
||||
class VITACORE_API(AsyncClient):
|
||||
def __init__(self):
|
||||
self.logger = getLogger(__name__)
|
||||
super().__init__(base_url=settings.VITACORE_BASE_URL)
|
||||
|
||||
async def findBySnils(self, snils: str):
|
||||
return
|
||||
|
||||
async def getProfile(self, patId: str):
|
||||
req = await self.get('/getProfile', params={'patId': patId})
|
||||
|
||||
match req.status_code:
|
||||
case st.HTTP_200_OK:
|
||||
return s.ProfileModel.model_validate(req.json())
|
||||
case _:
|
||||
self.logger.error(req.json())
|
||||
raise e.UnknownException
|
||||
64
src/clients/vitacore/schema.py
Normal file
64
src/clients/vitacore/schema.py
Normal file
@ -0,0 +1,64 @@
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class TrustedPersonModel(BaseModel):
|
||||
parentSnils: str = Field(
|
||||
title='СНИЛС представителя', examples=['156-125-394 57']
|
||||
)
|
||||
represType: str = Field(
|
||||
title='Вид родства (Мать/Отец/Иной родственник/Не родственник)',
|
||||
examples=['Мать'],
|
||||
)
|
||||
fullName: str = Field(
|
||||
title='ФИО представителя', examples=['Тестова Тест Тестовна']
|
||||
)
|
||||
phone: str = Field(
|
||||
title='Мобильный телефон представителя',
|
||||
examples=['+7 (999) 112-33-21'],
|
||||
)
|
||||
IsGuardian: bool = Field(title='Флаг Опекун', examples=['true'])
|
||||
IsTrustee: bool = Field(title='Флаг Попечитель', examples=['true'])
|
||||
status: bool = Field(
|
||||
title='Флаг Текущий представитель',
|
||||
examples=['false'],
|
||||
)
|
||||
|
||||
|
||||
class ProfileModel(BaseModel):
|
||||
id: str = Field(
|
||||
title='Идентификатор пациента',
|
||||
examples=['b62e9f22-a871-4c52-96d6-559c707a716d'],
|
||||
)
|
||||
SNILS: str = Field(title='СНИЛС', examples=['000-000-600 18'])
|
||||
lastName: str = Field(title='Фамилия', examples=['Тестовый'])
|
||||
firstName: str = Field(title='Имя', examples=['Пациент'])
|
||||
middleName: str = Field(title='Отчество', examples=['Ребенок'])
|
||||
birthDate: str = Field(title='Дата рождения', examples=['2024-10-16'])
|
||||
gender: str = Field(title='Пол', examples=['М'])
|
||||
docType: str = Field(
|
||||
title='Тип документа',
|
||||
examples=['Свидетельство о рождении, выданное в РФ'],
|
||||
)
|
||||
docSer: str = Field(title='Серия документа', examples=['III-КБ'])
|
||||
docNum: str = Field(title='Номер документа', examples=['999999'])
|
||||
ENP: str = Field(
|
||||
title='Единый номер полиса ОМС (16-ти значный)',
|
||||
examples=['?'],
|
||||
)
|
||||
addressReal: str = Field(
|
||||
title='Адрес проживания',
|
||||
examples=[
|
||||
'420000, Татарстан Респ, г.Казань, ул.Магистральная (Большие Клыки), д.1, кв.1' # noqa: E501
|
||||
],
|
||||
)
|
||||
attachBranchId: str = Field(
|
||||
title='Идентификатор СТП прикреплния',
|
||||
examples=['string'],
|
||||
)
|
||||
attachState: str = Field(
|
||||
title='Номер участка',
|
||||
examples=['99'],
|
||||
)
|
||||
trustedPersons: list[TrustedPersonModel] = Field(
|
||||
title='Информация о представителе',
|
||||
)
|
||||
@ -51,6 +51,11 @@ class Settings(BaseSettings):
|
||||
ESIA_CONTAINER_PASSWORD: str = Field(default='')
|
||||
ESIA_CONTAINER_THUMBPRINT: str = Field(default='')
|
||||
|
||||
# Vitacore
|
||||
VITACORE_BASE_URL: str = Field(
|
||||
default='https://gist-cws.ezdrav.ru:8899/MP_API'
|
||||
)
|
||||
|
||||
@model_validator(mode='after')
|
||||
def celery_env(self):
|
||||
environ['CELERY_BROKER_URL'] = self.REDIS_URL
|
||||
|
||||
Reference in New Issue
Block a user