Download app/routers/pacientes.py from Modulo-6/api: direct link, hf CLI and curl.
- Browser
- Download file 3.15 kB
-
https://huggingface.co/spaces/Modulo-6/api/resolve/main/app/routers/pacientes.py
- Command line
-
hf download hf://spaces/Modulo-6/api/app/routers/pacientes.py
-
curl -L -o pacientes.py https://huggingface.co/spaces/Modulo-6/api/resolve/main/app/routers/pacientes.py
3.15 kB
| """ | |
| Consultas de solo lectura a M1 (HCE) sobre datos clínicos del paciente — para la página | |
| de detalle de cama del front (que ya tiene `paciente_id` disponible desde `CamaResponse`). | |
| Proxies puros: no tocan Supabase ni auditoría (no cambian estado de M6), solo reenvían la | |
| consulta a M1 y traducen su respuesta. | |
| """ | |
| import logging | |
| from fastapi import APIRouter, Depends, HTTPException, status | |
| from app.dependencies import require_roles | |
| from app.integrations import hce | |
| from app.schemas.paciente import AntecedenteResponse, FichaMedicaResponse, PacienteResponse | |
| logger = logging.getLogger(__name__) | |
| router = APIRouter(prefix="/pacientes", tags=["Pacientes (M1 HCE)"]) | |
| _ERR_404 = { | |
| "codigo": "RECURSO_NO_ENCONTRADO", | |
| "mensaje": "No se pudo obtener el dato clínico del paciente en M1 (HCE)", | |
| } | |
| def get_paciente( | |
| paciente_id: int, | |
| user: dict = Depends(require_roles("ADMINISTRATIVO", "MEDICO", "LIMPIEZA")), | |
| ): | |
| data = hce.get_paciente(paciente_id) | |
| if data is None: | |
| logger.warning("Paciente no disponible en M1 — paciente_id=%s", paciente_id) | |
| raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=_ERR_404) | |
| return PacienteResponse.model_validate(data) | |
| def get_ficha_medica( | |
| paciente_id: int, | |
| user: dict = Depends(require_roles("ADMINISTRATIVO", "MEDICO", "LIMPIEZA")), | |
| ): | |
| data = hce.get_ficha_medica(paciente_id) | |
| if data is None: | |
| logger.warning("Ficha médica no disponible en M1 — paciente_id=%s", paciente_id) | |
| raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=_ERR_404) | |
| return FichaMedicaResponse.model_validate(data) | |
| def get_antecedentes( | |
| paciente_id: int, | |
| user: dict = Depends(require_roles("ADMINISTRATIVO", "MEDICO", "LIMPIEZA")), | |
| ): | |
| data = hce.get_antecedentes(paciente_id) | |
| if data is None: | |
| logger.warning("Antecedentes no disponibles en M1 — paciente_id=%s", paciente_id) | |
| raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=_ERR_404) | |
| return [AntecedenteResponse.model_validate(a) for a in data] | |