Implementacion GETs de M1 para front
Browse files- README.md +5 -0
- app/integrations/hce.py +42 -0
- app/main.py +2 -1
- app/routers/pacientes.py +65 -0
- app/schemas/enums.py +9 -0
- app/schemas/paciente.py +35 -0
- documentation/M6_DISEÑO.md +10 -0
- documentation/end_to_end_tests/flujo_internacion_completo.md +1 -0
- documentation/integrations/openapi_docs/M1_docs.html +0 -35
- documentation/integrations/openapi_docs/M1_openapi.json +0 -0
- documentation/roles.md +10 -0
- tests/test_pacientes.py +71 -0
README.md
CHANGED
|
@@ -15,6 +15,11 @@ Módulo 6 del sistema multi-módulo Health Grid. Gestiona camas hospitalarias, s
|
|
| 15 |
|
| 16 |
---
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
## Levantar el proyecto
|
| 19 |
|
| 20 |
**Prerequisitos:** tener Docker instalado y corriendo. Copiar `.env.example` a `.env` y completar `DATABASE_URL` y `JWT_SECRET` antes de arrancar.
|
|
|
|
| 15 |
|
| 16 |
---
|
| 17 |
|
| 18 |
+
## Deploy y links
|
| 19 |
+
|
| 20 |
+
URL APIs: https://modulo-6-api.hf.space/api/v1/
|
| 21 |
+
URL Documentación: https://modulo-6-api.hf.space/api/v1/docs
|
| 22 |
+
|
| 23 |
## Levantar el proyecto
|
| 24 |
|
| 25 |
**Prerequisitos:** tener Docker instalado y corriendo. Copiar `.env.example` a `.env` y completar `DATABASE_URL` y `JWT_SECRET` antes de arrancar.
|
app/integrations/hce.py
CHANGED
|
@@ -20,6 +20,48 @@ def get_contraindicaciones(paciente_id: int) -> list[str]:
|
|
| 20 |
return [d.get("descripcion", "") for d in data.get("detalle", [])]
|
| 21 |
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
def notify_evento_episodio(
|
| 24 |
episodio_id: int,
|
| 25 |
tipo_evento: str,
|
|
|
|
| 20 |
return [d.get("descripcion", "") for d in data.get("detalle", [])]
|
| 21 |
|
| 22 |
|
| 23 |
+
def get_ficha_medica(paciente_id: int) -> dict | None:
|
| 24 |
+
"""
|
| 25 |
+
Ficha médica del paciente (grupo sanguíneo, peso, altura, observaciones generales) —
|
| 26 |
+
para mostrar en la página de detalle de cama del front. A diferencia de
|
| 27 |
+
`get_contraindicaciones`, acá el dato ES la respuesta: `None` significa que no se pudo
|
| 28 |
+
obtener (paciente sin ficha registrada en M1, o M1 no respondió — `_get` no distingue
|
| 29 |
+
entre esos casos, ver `M6_INTEGRACION_M1_HCE.md`), y el router lo traduce a 404.
|
| 30 |
+
"""
|
| 31 |
+
if settings.mock_external_services:
|
| 32 |
+
return {
|
| 33 |
+
"id_paciente": paciente_id,
|
| 34 |
+
"grupo_sanguineo": "A+",
|
| 35 |
+
"peso_kg": 72.5,
|
| 36 |
+
"altura_cm": 175.0,
|
| 37 |
+
"observaciones_generales": "Paciente con antecedentes de hipertensión arterial. Diabético tipo 2.",
|
| 38 |
+
}
|
| 39 |
+
return _get(f"{settings.m1_hce_url}/api/v1/pacientes/{paciente_id}/ficha-medica")
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def get_antecedentes(paciente_id: int) -> list[dict] | None:
|
| 43 |
+
"""
|
| 44 |
+
Antecedentes clínicos del paciente (quirúrgicos, familiares, patológicos, hábitos) —
|
| 45 |
+
para la página de detalle de cama del front. `None` (no `[]`) significa que no se pudo
|
| 46 |
+
obtener el dato — un paciente sin antecedentes reales devuelve `[]`, que el router
|
| 47 |
+
distingue explícitamente de `None` (ver `app/routers/pacientes.py`).
|
| 48 |
+
"""
|
| 49 |
+
if settings.mock_external_services:
|
| 50 |
+
return [
|
| 51 |
+
{
|
| 52 |
+
"id": 1,
|
| 53 |
+
"id_paciente": paciente_id,
|
| 54 |
+
"tipo": "Patologico",
|
| 55 |
+
"descripcion": "Hipertensión arterial",
|
| 56 |
+
"fecha_suceso": "2020-03-15",
|
| 57 |
+
"observaciones": None,
|
| 58 |
+
"fecha_registro": datetime.now(timezone.utc).isoformat(),
|
| 59 |
+
"id_medico_registro": 10,
|
| 60 |
+
}
|
| 61 |
+
]
|
| 62 |
+
return _get(f"{settings.m1_hce_url}/api/v1/pacientes/{paciente_id}/antecedentes")
|
| 63 |
+
|
| 64 |
+
|
| 65 |
def notify_evento_episodio(
|
| 66 |
episodio_id: int,
|
| 67 |
tipo_evento: str,
|
app/main.py
CHANGED
|
@@ -18,7 +18,7 @@ from app.config import settings
|
|
| 18 |
from app.dependencies import create_access_token, require_roles
|
| 19 |
from app.integrations import rabbit_consumer
|
| 20 |
|
| 21 |
-
from app.routers import auth, camas, internal, quirofanos, solicitudes, webhooks, auditoria
|
| 22 |
from app.routers.webhooks import router_turnos
|
| 23 |
|
| 24 |
# ─── Request ID — trazabilidad por request ────────────────────────────────
|
|
@@ -123,6 +123,7 @@ PREFIX = "/api/v1"
|
|
| 123 |
app.include_router(auth.router, prefix=PREFIX)
|
| 124 |
app.include_router(camas.router, prefix=PREFIX)
|
| 125 |
app.include_router(internal.router, prefix=PREFIX)
|
|
|
|
| 126 |
app.include_router(quirofanos.router, prefix=PREFIX)
|
| 127 |
app.include_router(solicitudes.router, prefix=PREFIX)
|
| 128 |
app.include_router(webhooks.router, prefix=PREFIX)
|
|
|
|
| 18 |
from app.dependencies import create_access_token, require_roles
|
| 19 |
from app.integrations import rabbit_consumer
|
| 20 |
|
| 21 |
+
from app.routers import auth, camas, internal, pacientes, quirofanos, solicitudes, webhooks, auditoria
|
| 22 |
from app.routers.webhooks import router_turnos
|
| 23 |
|
| 24 |
# ─── Request ID — trazabilidad por request ────────────────────────────────
|
|
|
|
| 123 |
app.include_router(auth.router, prefix=PREFIX)
|
| 124 |
app.include_router(camas.router, prefix=PREFIX)
|
| 125 |
app.include_router(internal.router, prefix=PREFIX)
|
| 126 |
+
app.include_router(pacientes.router, prefix=PREFIX)
|
| 127 |
app.include_router(quirofanos.router, prefix=PREFIX)
|
| 128 |
app.include_router(solicitudes.router, prefix=PREFIX)
|
| 129 |
app.include_router(webhooks.router, prefix=PREFIX)
|
app/routers/pacientes.py
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Consultas de solo lectura a M1 (HCE) sobre datos clínicos del paciente — para la página
|
| 3 |
+
de detalle de cama del front (que ya tiene `paciente_id` disponible desde `CamaResponse`).
|
| 4 |
+
|
| 5 |
+
Proxies puros: no tocan Supabase ni auditoría (no cambian estado de M6), solo reenvían la
|
| 6 |
+
consulta a M1 y traducen su respuesta.
|
| 7 |
+
"""
|
| 8 |
+
import logging
|
| 9 |
+
|
| 10 |
+
from fastapi import APIRouter, Depends, HTTPException, status
|
| 11 |
+
|
| 12 |
+
from app.dependencies import require_roles
|
| 13 |
+
from app.integrations import hce
|
| 14 |
+
from app.schemas.paciente import AntecedenteResponse, FichaMedicaResponse
|
| 15 |
+
|
| 16 |
+
logger = logging.getLogger(__name__)
|
| 17 |
+
|
| 18 |
+
router = APIRouter(prefix="/pacientes", tags=["Pacientes (M1 HCE)"])
|
| 19 |
+
|
| 20 |
+
_ERR_404 = {
|
| 21 |
+
"codigo": "RECURSO_NO_ENCONTRADO",
|
| 22 |
+
"mensaje": "No se pudo obtener el dato clínico del paciente en M1 (HCE)",
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
@router.get(
|
| 27 |
+
"/{paciente_id}/ficha-medica",
|
| 28 |
+
response_model=FichaMedicaResponse,
|
| 29 |
+
summary="Obtener la ficha médica de un paciente (M1 HCE)",
|
| 30 |
+
responses={
|
| 31 |
+
401: {"description": "No autenticado"},
|
| 32 |
+
403: {"description": "Sin permisos"},
|
| 33 |
+
404: {"description": "Paciente sin ficha médica registrada en M1, o M1 no respondió"},
|
| 34 |
+
},
|
| 35 |
+
)
|
| 36 |
+
def get_ficha_medica(
|
| 37 |
+
paciente_id: int,
|
| 38 |
+
user: dict = Depends(require_roles("ADMINISTRATIVO", "MEDICO", "LIMPIEZA")),
|
| 39 |
+
):
|
| 40 |
+
data = hce.get_ficha_medica(paciente_id)
|
| 41 |
+
if data is None:
|
| 42 |
+
logger.warning("Ficha médica no disponible en M1 — paciente_id=%s", paciente_id)
|
| 43 |
+
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=_ERR_404)
|
| 44 |
+
return FichaMedicaResponse.model_validate(data)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
@router.get(
|
| 48 |
+
"/{paciente_id}/antecedentes",
|
| 49 |
+
response_model=list[AntecedenteResponse],
|
| 50 |
+
summary="Listar los antecedentes clínicos de un paciente (M1 HCE)",
|
| 51 |
+
responses={
|
| 52 |
+
401: {"description": "No autenticado"},
|
| 53 |
+
403: {"description": "Sin permisos"},
|
| 54 |
+
404: {"description": "Paciente no encontrado en M1, o M1 no respondió"},
|
| 55 |
+
},
|
| 56 |
+
)
|
| 57 |
+
def get_antecedentes(
|
| 58 |
+
paciente_id: int,
|
| 59 |
+
user: dict = Depends(require_roles("ADMINISTRATIVO", "MEDICO", "LIMPIEZA")),
|
| 60 |
+
):
|
| 61 |
+
data = hce.get_antecedentes(paciente_id)
|
| 62 |
+
if data is None:
|
| 63 |
+
logger.warning("Antecedentes no disponibles en M1 — paciente_id=%s", paciente_id)
|
| 64 |
+
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=_ERR_404)
|
| 65 |
+
return [AntecedenteResponse.model_validate(a) for a in data]
|
app/schemas/enums.py
CHANGED
|
@@ -103,6 +103,15 @@ class OrigenAuditoriaEnum(str, Enum):
|
|
| 103 |
SISTEMA = "SISTEMA"
|
| 104 |
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
class TipoEventoAuditoriaEnum(str, Enum):
|
| 107 |
SOLICITUD_RECIBIDA = "SOLICITUD_RECIBIDA"
|
| 108 |
SOLICITUD_APROBADA = "SOLICITUD_APROBADA"
|
|
|
|
| 103 |
SISTEMA = "SISTEMA"
|
| 104 |
|
| 105 |
|
| 106 |
+
class TipoAntecedenteEnum(str, Enum):
|
| 107 |
+
"""Tipo de antecedente clínico — mismos valores que `TipoAntecedente` en M1 (HCE),
|
| 108 |
+
ver documentation/integrations/openapi_docs/M1_openapi.json."""
|
| 109 |
+
QUIRURGICO = "Quirurgico"
|
| 110 |
+
FAMILIAR = "Familiar"
|
| 111 |
+
PATOLOGICO = "Patologico"
|
| 112 |
+
HABITO = "Habito"
|
| 113 |
+
|
| 114 |
+
|
| 115 |
class TipoEventoAuditoriaEnum(str, Enum):
|
| 116 |
SOLICITUD_RECIBIDA = "SOLICITUD_RECIBIDA"
|
| 117 |
SOLICITUD_APROBADA = "SOLICITUD_APROBADA"
|
app/schemas/paciente.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Respuestas de los endpoints de consulta a M1 (HCE) sobre el paciente — ficha médica y
|
| 3 |
+
antecedentes clínicos, para la página de detalle de cama del front (ver
|
| 4 |
+
`app/routers/pacientes.py`). Mismos nombres de campo que `FichaMedicaSchema`/
|
| 5 |
+
`AntecedenteSchema` en documentation/integrations/openapi_docs/M1_openapi.json, para que
|
| 6 |
+
el front no tenga que remapear nada.
|
| 7 |
+
"""
|
| 8 |
+
from __future__ import annotations
|
| 9 |
+
from datetime import date, datetime
|
| 10 |
+
from typing import Optional
|
| 11 |
+
from pydantic import BaseModel, ConfigDict
|
| 12 |
+
from app.schemas.enums import TipoAntecedenteEnum
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class FichaMedicaResponse(BaseModel):
|
| 16 |
+
model_config = ConfigDict(from_attributes=True)
|
| 17 |
+
|
| 18 |
+
id_paciente: int
|
| 19 |
+
grupo_sanguineo: Optional[str] = None
|
| 20 |
+
peso_kg: Optional[float] = None
|
| 21 |
+
altura_cm: Optional[float] = None
|
| 22 |
+
observaciones_generales: Optional[str] = None
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class AntecedenteResponse(BaseModel):
|
| 26 |
+
model_config = ConfigDict(from_attributes=True)
|
| 27 |
+
|
| 28 |
+
id: int
|
| 29 |
+
id_paciente: int
|
| 30 |
+
tipo: TipoAntecedenteEnum
|
| 31 |
+
descripcion: str
|
| 32 |
+
fecha_suceso: Optional[date] = None
|
| 33 |
+
observaciones: Optional[str] = None
|
| 34 |
+
fecha_registro: datetime
|
| 35 |
+
id_medico_registro: int
|
documentation/M6_DISEÑO.md
CHANGED
|
@@ -282,8 +282,18 @@ lado de ellos.
|
|
| 282 |
| M1 HCE | `POST /hce/movimientos` | Al asignar cama o trasladar (movimiento unificado) |
|
| 283 |
| M1 HCE | `POST /hce/solicitudes/{solicitudHceId}/resultado` | Al resolver una solicitud |
|
| 284 |
| M1 HCE | `POST /hce/episodios/{episodioId}/eventos` | Al recibir una alerta de emergencia de M9 |
|
|
|
|
|
|
|
| 285 |
| M2 Turnos | `GET /api/v1/appointments/{appointmentId}` | Al aprobar solicitud con `origen=CIRUGIA_PROGRAMADA` |
|
| 286 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
### 7.4 Estrategia de mock (2da entrega)
|
| 288 |
|
| 289 |
Todos los endpoints `[EXT]` (los que expone otro módulo) se mockean localmente para la 2da entrega. El mock vive en la capa de clientes HTTP: la misma interfaz que en producción, pero devolviendo respuestas canned. Esto permite que la 3ra entrega solo cambie la URL base del cliente, sin tocar la lógica de servicios.
|
|
|
|
| 282 |
| M1 HCE | `POST /hce/movimientos` | Al asignar cama o trasladar (movimiento unificado) |
|
| 283 |
| M1 HCE | `POST /hce/solicitudes/{solicitudHceId}/resultado` | Al resolver una solicitud |
|
| 284 |
| M1 HCE | `POST /hce/episodios/{episodioId}/eventos` | Al recibir una alerta de emergencia de M9 |
|
| 285 |
+
| M1 HCE | `GET /api/v1/pacientes/{pacienteId}/ficha-medica` | Consulta bajo demanda del front (2026-07) — página de detalle de cama |
|
| 286 |
+
| M1 HCE | `GET /api/v1/pacientes/{pacienteId}/antecedentes` | Consulta bajo demanda del front (2026-07) — página de detalle de cama |
|
| 287 |
| M2 Turnos | `GET /api/v1/appointments/{appointmentId}` | Al aprobar solicitud con `origen=CIRUGIA_PROGRAMADA` |
|
| 288 |
|
| 289 |
+
Los dos endpoints de M1 marcados "consulta bajo demanda" son proxies puros expuestos por
|
| 290 |
+
M6 (`GET /api/v1/pacientes/{id}/ficha-medica` y `/antecedentes`, ver
|
| 291 |
+
`app/routers/pacientes.py`) — a diferencia del resto de esta tabla, no se disparan desde
|
| 292 |
+
un flujo de negocio interno sino que el front los llama directamente cuando el usuario
|
| 293 |
+
abre el detalle de una cama. `hce.get_ficha_medica`/`get_antecedentes` no distinguen
|
| 294 |
+
"paciente sin ese dato" de "M1 no respondió": ambos casos devuelven `None` y el router
|
| 295 |
+
responde `404` — simplificación aceptada, documentada en el docstring de esas funciones.
|
| 296 |
+
|
| 297 |
### 7.4 Estrategia de mock (2da entrega)
|
| 298 |
|
| 299 |
Todos los endpoints `[EXT]` (los que expone otro módulo) se mockean localmente para la 2da entrega. El mock vive en la capa de clientes HTTP: la misma interfaz que en producción, pero devolviendo respuestas canned. Esto permite que la 3ra entrega solo cambie la URL base del cliente, sin tocar la lógica de servicios.
|
documentation/end_to_end_tests/flujo_internacion_completo.md
CHANGED
|
@@ -140,6 +140,7 @@ import json, sys
|
|
| 140 |
print(json.dumps({
|
| 141 |
"tipo": "INTERNACION",
|
| 142 |
"solicitud_hce_id": "HCE-SOL-001",
|
|
|
|
| 143 |
"paciente_id": int(sys.argv[1]),
|
| 144 |
"medico_solicitante_id": 10,
|
| 145 |
"cama_solicitada_id": int(sys.argv[2]),
|
|
|
|
| 140 |
print(json.dumps({
|
| 141 |
"tipo": "INTERNACION",
|
| 142 |
"solicitud_hce_id": "HCE-SOL-001",
|
| 143 |
+
"episodio_id": 46,
|
| 144 |
"paciente_id": int(sys.argv[1]),
|
| 145 |
"medico_solicitante_id": 10,
|
| 146 |
"cama_solicitada_id": int(sys.argv[2]),
|
documentation/integrations/openapi_docs/M1_docs.html
DELETED
|
@@ -1,35 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="es">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="utf-8" />
|
| 5 |
-
<title>API Módulo 1 - Historia Clínica Electrónica (HCE) - Swagger UI</title>
|
| 6 |
-
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5/swagger-ui.css" />
|
| 7 |
-
<style>
|
| 8 |
-
body {
|
| 9 |
-
margin: 0;
|
| 10 |
-
padding: 0;
|
| 11 |
-
background-color: #f7f9fc;
|
| 12 |
-
}
|
| 13 |
-
</style>
|
| 14 |
-
</head>
|
| 15 |
-
<body>
|
| 16 |
-
<div id="swagger-ui"></div>
|
| 17 |
-
<script src="https://unpkg.com/swagger-ui-dist@5/swagger-ui-bundle.js"></script>
|
| 18 |
-
<script src="https://unpkg.com/swagger-ui-dist@5/swagger-ui-standalone-preset.js"></script>
|
| 19 |
-
<script>
|
| 20 |
-
window.onload = () => {
|
| 21 |
-
window.ui = SwaggerUIBundle({
|
| 22 |
-
url: './openapi.json',
|
| 23 |
-
spec: {"openapi": "3.1.0", "info": {"title": "API Módulo 1 - Historia Clínica Electrónica (HCE)", "description": "Repositorio central de datos médicos del sistema Health Grid. Gestiona consultas, diagnósticos, tratamientos y fichas médicas.", "version": "1.0.0"}, "paths": {"/api/v1/dev/login": {"post": {"tags": ["🔧 Desarrollo"], "summary": "[DEV] Obtener token JWT de desarrollo", "description": "Genera un JWT firmado con la misma clave que Core (M10). El token funciona en todos los endpoints protegidos.\n\n**Sin body**: genera token con el usuario por defecto (dr.dev, rol médico, todos los permisos).\n\n**Con body**: permite personalizar sub, username, role, permissions y duración.", "operationId": "dev_login_api_v1_dev_login_post", "requestBody": {"content": {"application/json": {"schema": {"anyOf": [{"$ref": "#/components/schemas/DevLoginRequest"}, {"type": "null"}], "title": "Body"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/DevLoginResponse"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/api/v1/pacientes/{id_paciente}/ficha-medica": {"post": {"tags": ["Ficha Médica (HCE)"], "summary": "Crear ficha médica de un paciente", "description": "Crea la ficha médica permanente de un paciente en la Historia Clínica. Contiene datos clínicos estáticos como grupo sanguíneo, peso, altura y observaciones generales. Solo puede existir una ficha por paciente.", "operationId": "crear_ficha_medica_api_v1_pacientes__id_paciente__ficha_medica_post", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/FichaMedicaCreate"}}}}, "responses": {"201": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/FichaMedicaSchema"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "409": {"description": "Ya existe una ficha médica para este paciente.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "get": {"tags": ["Ficha Médica (HCE)"], "summary": "Obtener ficha médica de un paciente", "description": "Retorna los datos clínicos permanentes del paciente registrados en su ficha médica.", "operationId": "obtener_ficha_medica_api_v1_pacientes__id_paciente__ficha_medica_get", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/FichaMedicaSchema"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "patch": {"tags": ["Ficha Médica (HCE)"], "summary": "Actualizar ficha médica de un paciente", "description": "Actualiza parcialmente la ficha médica del paciente. Solo se modifican los campos enviados en el body.", "operationId": "actualizar_ficha_medica_api_v1_pacientes__id_paciente__ficha_medica_patch", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/FichaMedicaUpdate"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/FichaMedicaSchema"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/api/v1/pacientes/{id_paciente}/antecedentes": {"get": {"tags": ["Ficha Médica — Antecedentes"], "summary": "Listar antecedentes clínicos de un paciente", "description": "Retorna todos los antecedentes registrados del paciente.", "operationId": "listar_antecedentes_api_v1_pacientes__id_paciente__antecedentes_get", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"type": "array", "items": {"$ref": "#/components/schemas/AntecedenteSchema"}, "title": "Response Listar Antecedentes Api V1 Pacientes Id Paciente Antecedentes Get"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"description": "Paciente no encontrado.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "post": {"tags": ["Ficha Médica — Antecedentes"], "summary": "Registrar un antecedente clínico", "description": "Agrega un nuevo antecedente al historial clínico del paciente.", "operationId": "crear_antecedente_api_v1_pacientes__id_paciente__antecedentes_post", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AntecedenteCreate"}}}}, "responses": {"201": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AntecedenteSchema"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"description": "Paciente no encontrado.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/api/v1/pacientes/{id_paciente}/antecedentes/{id_antecedente}": {"patch": {"tags": ["Ficha Médica — Antecedentes"], "summary": "Actualizar un antecedente clínico", "description": "Actualización parcial de un antecedente. Solo se pisan los campos enviados.", "operationId": "actualizar_antecedente_api_v1_pacientes__id_paciente__antecedentes__id_antecedente__patch", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}, {"name": "id_antecedente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Antecedente"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AntecedenteUpdate"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AntecedenteSchema"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/api/v1/pacientes/{id_paciente}/alertas": {"get": {"tags": ["Ficha Médica — Alertas Clínicas"], "summary": "Listar alertas clínicas de un paciente", "description": "Retorna todas las alertas del paciente (Activas y Resueltas).", "operationId": "listar_alertas_api_v1_pacientes__id_paciente__alertas_get", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"type": "array", "items": {"$ref": "#/components/schemas/AlertaSchema"}, "title": "Response Listar Alertas Api V1 Pacientes Id Paciente Alertas Get"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"description": "Paciente no encontrado.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "post": {"tags": ["Ficha Médica — Alertas Clínicas"], "summary": "Registrar una alerta clínica", "description": "Crea una nueva consideración/alerta de seguridad para el paciente.", "operationId": "crear_alerta_api_v1_pacientes__id_paciente__alertas_post", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AlertaCreate"}}}}, "responses": {"201": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AlertaSchema"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"description": "Paciente no encontrado.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/api/v1/pacientes/{id_paciente}/alertas/{id_alerta}": {"patch": {"tags": ["Ficha Médica — Alertas Clínicas"], "summary": "Resolver una alerta clínica", "description": "Cambia el estado de la alerta a Resuelta y registra la resolución.", "operationId": "resolver_alerta_api_v1_pacientes__id_paciente__alertas__id_alerta__patch", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}, {"name": "id_alerta", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Alerta"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AlertaUpdate"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AlertaSchema"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/api/v1/patients/{id_paciente}/episodes": {"get": {"tags": ["Atención Clínica — Episodios"], "summary": "Listar episodios médicos de un paciente", "description": "Permite a Facturación obtener el listado de episodios de un paciente para recopilar todos los actos médicos a liquidar.", "operationId": "listar_episodios_api_v1_patients__id_paciente__episodes_get", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}, {"name": "estado", "in": "query", "required": false, "schema": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Estado"}}, {"name": "desde_fecha", "in": "query", "required": false, "schema": {"anyOf": [{"type": "string", "format": "date"}, {"type": "null"}], "title": "Desde Fecha"}}, {"name": "hasta_fecha", "in": "query", "required": false, "schema": {"anyOf": [{"type": "string", "format": "date"}, {"type": "null"}], "title": "Hasta Fecha"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EpisodioListResponse"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "post": {"tags": ["Atención Clínica — Episodios"], "summary": "Abrir un nuevo episodio médico", "description": "Permite registrar/abrir un nuevo episodio de atención (guardia, consulta externa, etc.) para el paciente.", "operationId": "crear_episodio_api_v1_patients__id_paciente__episodes_post", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EpisodioCreate"}}}}, "responses": {"201": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EpisodioDetalle"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/api/v1/patients/{id_paciente}/episodes/{id_episodio}": {"get": {"tags": ["Atención Clínica — Episodios"], "summary": "Obtener detalle completo de un episodio", "description": "Retorna el detalle de un episodio médico específico incluyendo todos los actos médicos registrados. Principal insumo para liquidación.", "operationId": "obtener_episodio_api_v1_patients__id_paciente__episodes__id_episodio__get", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}, {"name": "id_episodio", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Episodio"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EpisodioDetalle"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "patch": {"tags": ["Atención Clínica — Episodios"], "summary": "Actualizar parcialmente un episodio médico", "description": "Permite realizar modificaciones parciales en el episodio o cerrarlo enviando estado='closed'.", "operationId": "actualizar_episodio_api_v1_patients__id_paciente__episodes__id_episodio__patch", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}, {"name": "id_episodio", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Episodio"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EpisodioUpdate"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EpisodioDetalle"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/api/v1/patients/{id_paciente}/episodes/{id_episodio}/medical-acts": {"get": {"tags": ["Atención Clínica — Actos Médicos"], "summary": "Listar actos médicos de un episodio", "description": "Lista todos los actos médicos registrados dentro de un episodio. Cada acto incluye el codigo_nomenclador para facturación.", "operationId": "listar_actos_medicos_api_v1_patients__id_paciente__episodes__id_episodio__medical_acts_get", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}, {"name": "id_episodio", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Episodio"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ActoMedicoListResponse"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "post": {"tags": ["Atención Clínica — Actos Médicos"], "summary": "Registrar un acto médico en un episodio", "description": "Permite registrar prestaciones/actos médicos dentro de un episodio activo de atención.", "operationId": "crear_acto_medico_api_v1_patients__id_paciente__episodes__id_episodio__medical_acts_post", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}, {"name": "id_episodio", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Episodio"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ActoMedicoCreate"}}}}, "responses": {"201": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ActoMedicoSchema"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unprocessable Entity"}}}}, "/api/v1/patients/{id_paciente}/episodes/{id_episodio}/evoluciones": {"get": {"tags": ["Atención Clínica — Evoluciones"], "summary": "Listar evoluciones médicas de un episodio", "description": "Lista todas las notas de evolución registradas dentro de un episodio, ordenadas cronológicamente.", "operationId": "listar_evoluciones_api_v1_patients__id_paciente__episodes__id_episodio__evoluciones_get", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}, {"name": "id_episodio", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Episodio"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EvolucionListResponse"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "post": {"tags": ["Atención Clínica — Evoluciones"], "summary": "Registrar una evolución médica en un episodio", "description": "Permite registrar una nota de evolución clínica dentro de un episodio activo. El profesional autor se obtiene automáticamente del token JWT.", "operationId": "crear_evolucion_api_v1_patients__id_paciente__episodes__id_episodio__evoluciones_post", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}, {"name": "id_episodio", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Episodio"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EvolucionCreate"}}}}, "responses": {"201": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EvolucionSchema"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unprocessable Entity"}}}}, "/api/v1/patients/{id_paciente}/episodes/{id_episodio}/evoluciones/{id_evolucion}": {"get": {"tags": ["Atención Clínica — Evoluciones"], "summary": "Obtener detalle de una evolución médica", "description": "Retorna el contenido completo de una nota de evolución específica.", "operationId": "obtener_evolucion_api_v1_patients__id_paciente__episodes__id_episodio__evoluciones__id_evolucion__get", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}, {"name": "id_episodio", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Episodio"}}, {"name": "id_evolucion", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Evolucion"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EvolucionSchema"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}, "patch": {"tags": ["Atención Clínica — Evoluciones"], "summary": "Actualizar parcialmente una evolución médica", "description": "Permite corregir el contenido de una nota de evolución existente.", "operationId": "actualizar_evolucion_api_v1_patients__id_paciente__episodes__id_episodio__evoluciones__id_evolucion__patch", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}, {"name": "id_episodio", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Episodio"}}, {"name": "id_evolucion", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Evolucion"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EvolucionUpdate"}}}}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/EvolucionSchema"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/api/v1/recetas": {"get": {"tags": ["Atención Clínica — Recetas"], "summary": "Consultar listado de recetas (sincronización masiva)", "description": "Permite al Módulo 3 (Farmacia) obtener todas las recetas generadas. Útil para auditorías, cierres de lote o recuperación de datos tras caídas de Kafka.", "operationId": "listar_recetas_api_v1_recetas_get", "security": [{"JWT Bearer": []}], "parameters": [{"name": "estado", "in": "query", "required": false, "schema": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Estado"}}, {"name": "id_paciente", "in": "query", "required": false, "schema": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Id Paciente"}}, {"name": "desde_fecha", "in": "query", "required": false, "schema": {"anyOf": [{"type": "string", "format": "date"}, {"type": "null"}], "title": "Desde Fecha"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/RecetaListResponse"}}}}, "401": {"description": "Token JWT ausente, inválido o expirado.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}}, "403": {"description": "Sin permiso requerido.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/api/v1/recetas/{id_receta}": {"get": {"tags": ["Atención Clínica — Recetas"], "summary": "Obtener detalles de receta (con alertas farmacológicas)", "description": "Endpoint al que Farmacia llama tras recibir el evento Kafka clinica.farmacia.receta_creada para obtener la medicación recetada y cruzarla con las alergias del paciente.", "operationId": "obtener_receta_api_v1_recetas__id_receta__get", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_receta", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Receta"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/RecetaMedicaDetallada"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/api/v1/patients/{id_paciente}/episodes/{id_episodio}/evoluciones/{id_evolucion}/recetas": {"post": {"tags": ["Atención Clínica — Recetas"], "summary": "Registrar una receta médica", "description": "Permite al médico registrar una receta electrónica asociada a la nota de evolución. Admite múltiples medicamentos. Al guardarse, se notifica automáticamente a Farmacia.", "operationId": "crear_receta_api_v1_patients__id_paciente__episodes__id_episodio__evoluciones__id_evolucion__recetas_post", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}, {"name": "id_episodio", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Episodio"}}, {"name": "id_evolucion", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Evolucion"}}], "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/RecetaCreate"}}}}, "responses": {"201": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/RecetaMedicaDetallada"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unprocessable Entity"}}}}, "/api/v1/hce/health": {"get": {"tags": ["Integración M10 (Core)"], "summary": "Health check del módulo HCE", "description": "Endpoint de estado que Core puede usar para monitorear la disponibilidad del módulo HCE. No requiere autenticación.", "operationId": "health_check_api_v1_hce_health_get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HealthResponse"}}}}}}}, "/api/v1/hce/notify-permission-change": {"post": {"tags": ["Integración M10 (Core)"], "summary": "Notificar a Core un cambio de permisos originado en HCE", "description": "Proxy que reenvía la notificación al Módulo 10 (Core).", "operationId": "notify_permission_change_api_v1_hce_notify_permission_change_post", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/PermissionChangeNotification"}}}, "required": true}, "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/PermissionChangeResponse"}}}}, "401": {"description": "Unauthorized", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}}, "422": {"description": "Unprocessable Entity", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}}}, "security": [{"JWT Bearer": []}]}}, "/api/v1/ordenes": {"get": {"tags": ["Integración M4/M5 (Estudios)"], "summary": "Consultar órdenes pendientes (sincronización masiva)", "description": "Endpoint utilizado por M4 y M5 como red de seguridad para consultar lotes completos de estudios pendientes.", "operationId": "listar_ordenes_api_v1_ordenes_get", "security": [{"JWT Bearer": []}], "parameters": [{"name": "tipo_estudio", "in": "query", "required": true, "schema": {"type": "string", "title": "Tipo Estudio"}}, {"name": "estado", "in": "query", "required": false, "schema": {"anyOf": [{"type": "string"}, {"type": "null"}], "default": "Pendiente", "title": "Estado"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/OrdenListResponse"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/api/v1/ordenes/{id_orden}": {"get": {"tags": ["Integración M4/M5 (Estudios)"], "summary": "Obtener detalles de orden (Smart Payload con alertas clínicas)", "description": "Endpoint utilizado por M4 y M5 para descargar la información clínica de la orden y las alertas de seguridad.", "operationId": "obtener_orden_api_v1_ordenes__id_orden__get", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_orden", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Orden"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/OrdenMedicaCompleta"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/api/v1/resultados": {"post": {"tags": ["Integración M4/M5 (Estudios)"], "summary": "Registrar resultado de estudio", "description": "Endpoint utilizado por M4 (Laboratorio) y M5 (Imágenes) para enviar los resultados de un estudio médico finalizado a la HCE.", "operationId": "registrar_resultado_api_v1_resultados_post", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ResultadoEstudioRequest"}}}, "required": true}, "responses": {"201": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ResultadoCreatedResponse"}}}}, "401": {"description": "Unauthorized", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}}, "403": {"description": "Forbidden", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}}, "422": {"description": "Datos inválidos.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}}}, "security": [{"JWT Bearer": []}]}}, "/api/v1/internacion/ingreso": {"post": {"tags": ["Integración M6 (Camas)"], "summary": "Notificar ingreso de paciente (M6 → HCE)", "description": "Endpoint utilizado por el Módulo 6 para notificar a la HCE que un paciente fue ingresado físicamente a una cama. Esto dispara la creación del Episodio de Internación en la Historia Clínica.", "operationId": "notificar_ingreso_api_v1_internacion_ingreso_post", "requestBody": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/IngresoInternacionRequest"}}}, "required": true}, "responses": {"201": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/IngresoInternacionResponse"}}}}, "401": {"description": "Unauthorized", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}}, "403": {"description": "Forbidden", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}}, "422": {"description": "Datos de ingreso inválidos.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}}}, "security": [{"JWT Bearer": []}]}}, "/api/v1/patients/{id_paciente}/insurance": {"get": {"tags": ["Integración M7 (Facturación)"], "summary": "Obtener cobertura médica vigente del paciente", "description": "Retorna la obra social o prepaga vigente del paciente. Facturación necesita este dato para aplicar el nomenclador correcto.", "operationId": "obtener_cobertura_api_v1_patients__id_paciente__insurance_get", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/InsuranceResponse"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/api/v1/pacientes/{id_paciente}/historial/recetas": {"get": {"tags": ["Integración M8 (Portal del Paciente)"], "summary": "Consultar historial de recetas del paciente (Para M8)", "description": "Endpoint sincrónico consumido por el Portal del Paciente (M8) para renderizar la sección 'Mi Salud', listando todas las recetas.", "operationId": "historial_recetas_api_v1_pacientes__id_paciente__historial_recetas_get", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"type": "array", "items": {"$ref": "#/components/schemas/RecetaMedicaDetallada"}, "title": "Response Historial Recetas Api V1 Pacientes Id Paciente Historial Recetas Get"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}, "/api/v1/pacientes/{id_paciente}/historial/resultados": {"get": {"tags": ["Integración M8 (Portal del Paciente)"], "summary": "Consultar resultados de estudios del paciente (Para M8)", "description": "Endpoint sincrónico consumido por el Portal del Paciente (M8) para mostrar los resultados de estudios médicos finalizados.", "operationId": "historial_resultados_api_v1_pacientes__id_paciente__historial_resultados_get", "security": [{"JWT Bearer": []}], "parameters": [{"name": "id_paciente", "in": "path", "required": true, "schema": {"type": "integer", "title": "Id Paciente"}}], "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {"type": "array", "items": {"$ref": "#/components/schemas/ResultadoEstudioResumen"}, "title": "Response Historial Resultados Api V1 Pacientes Id Paciente Historial Resultados Get"}}}}, "401": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Unauthorized"}, "403": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Forbidden"}, "404": {"content": {"application/json": {"schema": {"$ref": "#/components/schemas/ErrorResponse"}}}, "description": "Not Found"}, "422": {"description": "Validation Error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/HTTPValidationError"}}}}}}}}, "components": {"schemas": {"ActoMedicoCreate": {"properties": {"codigo_nomenclador": {"anyOf": [{"type": "string", "maxLength": 20}, {"type": "null"}], "title": "Codigo Nomenclador", "examples": ["01.01.01"]}, "descripcion": {"anyOf": [{"type": "string", "maxLength": 500}, {"type": "null"}], "title": "Descripcion", "examples": ["Consulta médica ambulatoria"]}, "tipo": {"$ref": "#/components/schemas/TipoActoMedico", "examples": ["consulta"]}, "id_profesional": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Id Profesional", "examples": [42]}, "fecha_realizacion": {"anyOf": [{"type": "string", "format": "date-time"}, {"type": "null"}], "title": "Fecha Realizacion", "description": "Fecha de realización. Si no se envía, se usa la fecha/hora actual."}, "cantidad": {"type": "integer", "exclusiveMinimum": 0.0, "title": "Cantidad", "default": 1, "examples": [1]}, "observaciones": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Observaciones"}}, "type": "object", "required": ["tipo"], "title": "ActoMedicoCreate", "description": "Payload para registrar un nuevo acto médico en un episodio."}, "ActoMedicoListResponse": {"properties": {"id_episodio": {"type": "integer", "title": "Id Episodio", "examples": [700]}, "total": {"type": "integer", "title": "Total", "examples": [4]}, "actos_medicos": {"items": {"$ref": "#/components/schemas/ActoMedicoSchema"}, "type": "array", "title": "Actos Medicos"}}, "type": "object", "required": ["id_episodio", "total", "actos_medicos"], "title": "ActoMedicoListResponse", "description": "Lista de actos médicos de un episodio."}, "ActoMedicoSchema": {"properties": {"id_acto_medico": {"type": "integer", "title": "Id Acto Medico", "examples": [9001]}, "id_episodio": {"type": "integer", "title": "Id Episodio", "examples": [700]}, "codigo_nomenclador": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Codigo Nomenclador", "examples": ["01.01.01"]}, "descripcion": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Descripcion", "examples": ["Consulta médica ambulatoria - primera vez"]}, "tipo": {"$ref": "#/components/schemas/TipoActoMedico", "examples": ["consulta"]}, "id_profesional": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Id Profesional", "examples": [42]}, "fecha_realizacion": {"type": "string", "format": "date-time", "title": "Fecha Realizacion", "examples": ["2025-03-10T09:15:00Z"]}, "cantidad": {"type": "integer", "title": "Cantidad", "default": 1, "examples": [1]}, "observaciones": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Observaciones"}}, "type": "object", "required": ["id_acto_medico", "id_episodio", "tipo", "fecha_realizacion"], "title": "ActoMedicoSchema", "description": "Acto médico registrado dentro de un episodio."}, "AlertaCreate": {"properties": {"tipo": {"$ref": "#/components/schemas/TipoConsideracion", "examples": ["Alergia"]}, "severidad": {"$ref": "#/components/schemas/SeveridadAlerta", "examples": ["Severa"]}, "descripcion": {"type": "string", "title": "Descripcion", "examples": ["Alergia severa a penicilina y derivados."]}}, "type": "object", "required": ["tipo", "severidad", "descripcion"], "title": "AlertaCreate", "description": "Body para crear una nueva alerta clínica."}, "AlertaSchema": {"properties": {"id": {"type": "integer", "title": "Id"}, "id_paciente": {"type": "integer", "title": "Id Paciente"}, "tipo": {"$ref": "#/components/schemas/TipoConsideracion"}, "severidad": {"$ref": "#/components/schemas/SeveridadAlerta"}, "descripcion": {"type": "string", "title": "Descripcion"}, "estado": {"$ref": "#/components/schemas/EstadoAlerta"}, "fecha_registro": {"type": "string", "format": "date-time", "title": "Fecha Registro"}, "id_medico_registro": {"type": "integer", "title": "Id Medico Registro"}, "fecha_resolucion": {"anyOf": [{"type": "string", "format": "date-time"}, {"type": "null"}], "title": "Fecha Resolucion"}, "id_medico_resolucion": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Id Medico Resolucion"}, "motivo_resolucion": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Motivo Resolucion"}}, "type": "object", "required": ["id", "id_paciente", "tipo", "severidad", "descripcion", "estado", "fecha_registro", "id_medico_registro"], "title": "AlertaSchema", "description": "Respuesta completa de una alerta clínica."}, "AlertaSmartPayload": {"properties": {"tipo": {"$ref": "#/components/schemas/TipoConsideracion"}, "severidad": {"$ref": "#/components/schemas/SeveridadAlerta"}, "descripcion": {"type": "string", "title": "Descripcion"}}, "type": "object", "required": ["tipo", "severidad", "descripcion"], "title": "AlertaSmartPayload", "description": "Schema reducido para Smart Payload en órdenes y recetas.\nSolo incluye lo necesario para que M3/M4/M5 tomen decisiones clínicas."}, "AlertaUpdate": {"properties": {"estado": {"$ref": "#/components/schemas/EstadoAlerta", "examples": ["Resuelta"]}, "motivo_resolucion": {"type": "string", "title": "Motivo Resolucion", "examples": ["Alergia superada, confirmado por alergista."]}}, "type": "object", "required": ["estado", "motivo_resolucion"], "title": "AlertaUpdate", "description": "Body para resolver una alerta clínica (PATCH)."}, "AntecedenteCreate": {"properties": {"tipo": {"$ref": "#/components/schemas/TipoAntecedente", "examples": ["Quirurgico"]}, "descripcion": {"type": "string", "title": "Descripcion", "examples": ["Colecistectomía laparoscópica"]}, "fecha_suceso": {"anyOf": [{"type": "string", "format": "date"}, {"type": "null"}], "title": "Fecha Suceso", "examples": ["2018-04-15"]}, "observaciones": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Observaciones", "examples": ["Sin complicaciones postoperatorias."]}}, "type": "object", "required": ["tipo", "descripcion"], "title": "AntecedenteCreate", "description": "Body para registrar un nuevo antecedente."}, "AntecedenteSchema": {"properties": {"id": {"type": "integer", "title": "Id"}, "id_paciente": {"type": "integer", "title": "Id Paciente"}, "tipo": {"$ref": "#/components/schemas/TipoAntecedente"}, "descripcion": {"type": "string", "title": "Descripcion"}, "fecha_suceso": {"anyOf": [{"type": "string", "format": "date"}, {"type": "null"}], "title": "Fecha Suceso"}, "observaciones": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Observaciones"}, "fecha_registro": {"type": "string", "format": "date-time", "title": "Fecha Registro"}, "id_medico_registro": {"type": "integer", "title": "Id Medico Registro"}}, "type": "object", "required": ["id", "id_paciente", "tipo", "descripcion", "fecha_registro", "id_medico_registro"], "title": "AntecedenteSchema", "description": "Respuesta completa de un antecedente clínico."}, "AntecedenteUpdate": {"properties": {"descripcion": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Descripcion"}, "fecha_suceso": {"anyOf": [{"type": "string", "format": "date"}, {"type": "null"}], "title": "Fecha Suceso"}, "observaciones": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Observaciones"}}, "type": "object", "title": "AntecedenteUpdate", "description": "Body para actualización parcial de un antecedente (PATCH)."}, "DevLoginRequest": {"properties": {"sub": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Sub", "description": "ID del usuario (médico)", "examples": [1]}, "username": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Username", "description": "Nombre de usuario", "examples": ["dr.dev"]}, "role": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Role", "description": "Rol del usuario", "examples": ["medico"]}, "permissions": {"anyOf": [{"items": {"type": "string"}, "type": "array"}, {"type": "null"}], "title": "Permissions", "description": "Lista de permisos", "examples": [["hce:read", "hce:write", "hce:alertas:read", "hce:alertas:write", "hce:antecedentes:read", "hce:antecedentes:write", "hce:ficha-medica:read", "hce:ficha-medica:write", "hce:recetas:read", "hce:recetas:write", "hce:ordenes:read", "hce:resultados:write", "hce:internacion:write", "hce:episodes:read", "hce:medical-acts:read", "hce:insurance:read", "hce:evoluciones:read", "hce:evoluciones:write"]]}, "sede_id": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Sede Id", "description": "ID de la sede", "examples": [1]}, "expire_hours": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Expire Hours", "description": "Horas de validez del token (default: 24)", "examples": [24]}}, "type": "object", "title": "DevLoginRequest", "description": "Body opcional para personalizar el token de desarrollo.\nSi no se envía ningún campo, se usan los valores por defecto de settings."}, "DevLoginResponse": {"properties": {"access_token": {"type": "string", "title": "Access Token"}, "token_type": {"type": "string", "title": "Token Type", "default": "bearer"}, "expires_in_hours": {"type": "integer", "title": "Expires In Hours"}, "user": {"additionalProperties": true, "type": "object", "title": "User"}}, "type": "object", "required": ["access_token", "expires_in_hours", "user"], "title": "DevLoginResponse", "description": "Respuesta del endpoint de login de desarrollo."}, "EpisodioCreate": {"properties": {"tipo": {"$ref": "#/components/schemas/TipoEpisodio", "examples": ["internacion"]}, "estado": {"$ref": "#/components/schemas/EstadoEpisodio", "default": "open", "examples": ["open"]}, "id_sede": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Id Sede", "examples": [3]}, "diagnostico_principal": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Diagnostico Principal", "examples": ["J18.9 - Neumonía no especificada"]}}, "type": "object", "required": ["tipo"], "title": "EpisodioCreate", "description": "Creación de episodio médico."}, "EpisodioDetalle": {"properties": {"id_episodio": {"type": "integer", "title": "Id Episodio", "examples": [700]}, "id_paciente": {"type": "integer", "title": "Id Paciente", "examples": [10500]}, "tipo": {"$ref": "#/components/schemas/TipoEpisodio", "examples": ["internacion"]}, "estado": {"$ref": "#/components/schemas/EstadoEpisodio", "examples": ["closed"]}, "id_sede": {"type": "integer", "title": "Id Sede", "examples": [3]}, "id_medico_responsable": {"type": "integer", "title": "Id Medico Responsable", "examples": [42]}, "diagnostico_principal": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Diagnostico Principal", "examples": ["J18.9 - Neumonía no especificada"]}, "fecha_apertura": {"type": "string", "format": "date-time", "title": "Fecha Apertura", "examples": ["2025-03-10T09:00:00Z"]}, "fecha_cierre": {"anyOf": [{"type": "string", "format": "date-time"}, {"type": "null"}], "title": "Fecha Cierre", "examples": ["2025-03-15T11:00:00Z"]}, "actos_medicos": {"items": {"$ref": "#/components/schemas/ActoMedicoSchema"}, "type": "array", "title": "Actos Medicos"}}, "type": "object", "required": ["id_episodio", "id_paciente", "tipo", "estado", "id_sede", "id_medico_responsable", "fecha_apertura"], "title": "EpisodioDetalle", "description": "Detalle completo de un episodio con actos médicos."}, "EpisodioListResponse": {"properties": {"id_paciente": {"type": "integer", "title": "Id Paciente", "examples": [10500]}, "total": {"type": "integer", "title": "Total", "examples": [5]}, "episodios": {"items": {"$ref": "#/components/schemas/EpisodioResumen"}, "type": "array", "title": "Episodios"}}, "type": "object", "required": ["id_paciente", "total", "episodios"], "title": "EpisodioListResponse", "description": "Lista de episodios de un paciente."}, "EpisodioResumen": {"properties": {"id_episodio": {"type": "integer", "title": "Id Episodio", "examples": [700]}, "tipo": {"$ref": "#/components/schemas/TipoEpisodio", "examples": ["internacion"]}, "estado": {"$ref": "#/components/schemas/EstadoEpisodio", "examples": ["closed"]}, "id_sede": {"type": "integer", "title": "Id Sede", "examples": [3]}, "fecha_apertura": {"type": "string", "format": "date-time", "title": "Fecha Apertura", "examples": ["2025-03-10T09:00:00Z"]}, "fecha_cierre": {"anyOf": [{"type": "string", "format": "date-time"}, {"type": "null"}], "title": "Fecha Cierre", "examples": ["2025-03-15T11:00:00Z"]}, "id_medico_responsable": {"type": "integer", "title": "Id Medico Responsable", "examples": [42]}}, "type": "object", "required": ["id_episodio", "tipo", "estado", "id_sede", "fecha_apertura", "id_medico_responsable"], "title": "EpisodioResumen", "description": "Resumen de un episodio para listados."}, "EpisodioUpdate": {"properties": {"tipo": {"anyOf": [{"$ref": "#/components/schemas/TipoEpisodio"}, {"type": "null"}]}, "estado": {"anyOf": [{"$ref": "#/components/schemas/EstadoEpisodio"}, {"type": "null"}]}, "id_sede": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Id Sede"}, "id_medico_responsable": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Id Medico Responsable"}, "diagnostico_principal": {"anyOf": [{"type": "string", "maxLength": 500}, {"type": "null"}], "title": "Diagnostico Principal"}, "fecha_cierre": {"anyOf": [{"type": "string", "format": "date-time"}, {"type": "null"}], "title": "Fecha Cierre"}}, "type": "object", "title": "EpisodioUpdate", "description": "Payload para actualizar un episodio médico (ej. cerrar o cambiar médico)."}, "ErrorResponse": {"properties": {"error": {"type": "string", "title": "Error", "examples": ["NOT_FOUND"]}, "message": {"type": "string", "title": "Message", "examples": ["El recurso solicitado no fue encontrado."]}, "timestamp": {"anyOf": [{"type": "string", "format": "date-time"}, {"type": "null"}], "title": "Timestamp"}}, "type": "object", "required": ["error", "message"], "title": "ErrorResponse", "description": "Respuesta estándar de error del módulo HCE."}, "EstadoAlerta": {"type": "string", "enum": ["Activa", "Resuelta"], "title": "EstadoAlerta", "description": "Estado del ciclo de vida de la alerta."}, "EstadoEpisodio": {"type": "string", "enum": ["open", "closed"], "title": "EstadoEpisodio"}, "EstadoReceta": {"type": "string", "enum": ["Activa", "Suspendida", "Dispensada"], "title": "EstadoReceta"}, "EvolucionCreate": {"properties": {"contenido": {"type": "string", "title": "Contenido", "description": "Texto libre con la nota clínica del profesional.", "examples": ["Paciente refiere mejoría del cuadro respiratorio. Se auscultan campos pulmonares limpios. Se indica continuar tratamiento."]}, "fecha": {"anyOf": [{"type": "string", "format": "date-time"}, {"type": "null"}], "title": "Fecha", "description": "Fecha/hora de la evolución. Si no se envía, se usa la fecha/hora actual."}}, "type": "object", "required": ["contenido"], "title": "EvolucionCreate", "description": "Body para registrar una nueva evolución médica en un episodio."}, "EvolucionListResponse": {"properties": {"id_episodio": {"type": "integer", "title": "Id Episodio"}, "total": {"type": "integer", "title": "Total"}, "evoluciones": {"items": {"$ref": "#/components/schemas/EvolucionSchema"}, "type": "array", "title": "Evoluciones"}}, "type": "object", "required": ["id_episodio", "total", "evoluciones"], "title": "EvolucionListResponse", "description": "Respuesta de listado de evoluciones de un episodio."}, "EvolucionSchema": {"properties": {"id_evolucion": {"type": "integer", "title": "Id Evolucion"}, "id_episodio": {"type": "integer", "title": "Id Episodio"}, "id_profesional": {"type": "integer", "title": "Id Profesional"}, "contenido": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Contenido"}, "fecha": {"type": "string", "format": "date-time", "title": "Fecha"}}, "type": "object", "required": ["id_evolucion", "id_episodio", "id_profesional", "fecha"], "title": "EvolucionSchema", "description": "Schema de respuesta completo de una evolución médica."}, "EvolucionUpdate": {"properties": {"contenido": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Contenido", "description": "Texto libre con la nota clínica corregida."}}, "type": "object", "title": "EvolucionUpdate", "description": "Body para actualizar parcialmente una evolución médica (PATCH)."}, "FichaMedicaCreate": {"properties": {"grupo_sanguineo": {"anyOf": [{"type": "string", "maxLength": 10}, {"type": "null"}], "title": "Grupo Sanguineo", "description": "Grupo sanguíneo y factor Rh del paciente.", "examples": ["A+"]}, "peso_kg": {"anyOf": [{"type": "number"}, {"type": "null"}], "title": "Peso Kg", "description": "Peso del paciente en kilogramos.", "examples": [72.5]}, "altura_cm": {"anyOf": [{"type": "number"}, {"type": "null"}], "title": "Altura Cm", "description": "Altura del paciente en centímetros.", "examples": [175.0]}, "observaciones_generales": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Observaciones Generales", "description": "Notas generales y antecedentes del paciente visibles en la cabecera de la ficha.", "examples": ["Paciente con antecedentes de hipertensión arterial. Diabético tipo 2."]}}, "type": "object", "title": "FichaMedicaCreate", "description": "Payload para crear/registrar la ficha médica de un paciente."}, "FichaMedicaSchema": {"properties": {"grupo_sanguineo": {"anyOf": [{"type": "string", "maxLength": 10}, {"type": "null"}], "title": "Grupo Sanguineo", "description": "Grupo sanguíneo y factor Rh del paciente.", "examples": ["A+"]}, "peso_kg": {"anyOf": [{"type": "number"}, {"type": "null"}], "title": "Peso Kg", "description": "Peso del paciente en kilogramos.", "examples": [72.5]}, "altura_cm": {"anyOf": [{"type": "number"}, {"type": "null"}], "title": "Altura Cm", "description": "Altura del paciente en centímetros.", "examples": [175.0]}, "observaciones_generales": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Observaciones Generales", "description": "Notas generales y antecedentes del paciente visibles en la cabecera de la ficha.", "examples": ["Paciente con antecedentes de hipertensión arterial. Diabético tipo 2."]}, "id_paciente": {"type": "integer", "title": "Id Paciente", "examples": [10500]}}, "type": "object", "required": ["id_paciente"], "title": "FichaMedicaSchema", "description": "Schema de respuesta completo de la ficha médica."}, "FichaMedicaUpdate": {"properties": {"grupo_sanguineo": {"anyOf": [{"type": "string", "maxLength": 10}, {"type": "null"}], "title": "Grupo Sanguineo", "description": "Grupo sanguíneo y factor Rh del paciente.", "examples": ["A+"]}, "peso_kg": {"anyOf": [{"type": "number"}, {"type": "null"}], "title": "Peso Kg", "description": "Peso del paciente en kilogramos.", "examples": [72.5]}, "altura_cm": {"anyOf": [{"type": "number"}, {"type": "null"}], "title": "Altura Cm", "description": "Altura del paciente en centímetros.", "examples": [175.0]}, "observaciones_generales": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Observaciones Generales", "description": "Notas generales y antecedentes del paciente visibles en la cabecera de la ficha.", "examples": ["Paciente con antecedentes de hipertensión arterial. Diabético tipo 2."]}}, "type": "object", "title": "FichaMedicaUpdate", "description": "Payload para actualizar parcialmente la ficha médica. Todos los campos son opcionales."}, "HTTPValidationError": {"properties": {"detail": {"items": {"$ref": "#/components/schemas/ValidationError"}, "type": "array", "title": "Detail"}}, "type": "object", "title": "HTTPValidationError"}, "HealthResponse": {"properties": {"status": {"type": "string", "title": "Status", "examples": ["UP"]}, "module": {"type": "string", "title": "Module", "examples": ["hce"]}, "timestamp": {"type": "string", "format": "date-time", "title": "Timestamp"}}, "type": "object", "required": ["status", "module", "timestamp"], "title": "HealthResponse", "description": "Respuesta del health check."}, "IngresoInternacionRequest": {"properties": {"id_paciente": {"type": "integer", "title": "Id Paciente", "examples": [10500]}, "sector": {"type": "string", "title": "Sector", "examples": ["UTI"]}, "habitacion": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Habitacion", "examples": ["Terapia A"]}, "cama": {"type": "string", "title": "Cama", "examples": ["Cama 4"]}, "fecha_ingreso": {"type": "string", "format": "date-time", "title": "Fecha Ingreso", "examples": ["2026-04-17T14:30:00Z"]}, "medico_solicitante": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Medico Solicitante", "examples": ["Dr. Pérez"]}}, "type": "object", "required": ["id_paciente", "sector", "cama", "fecha_ingreso"], "title": "IngresoInternacionRequest", "description": "Payload enviado por M6 para notificar ingreso de paciente a cama."}, "IngresoInternacionResponse": {"properties": {"status": {"type": "string", "title": "Status", "default": "success", "examples": ["success"]}, "mensaje": {"type": "string", "title": "Mensaje", "default": "Episodio creado y cama asignada correctamente.", "examples": ["Episodio creado y cama asignada correctamente."]}, "data": {"anyOf": [{"additionalProperties": true, "type": "object"}, {"type": "null"}], "title": "Data", "examples": [{"id_episodio": 700, "id_movimiento": 1}]}}, "type": "object", "title": "IngresoInternacionResponse", "description": "Respuesta tras crear episodio de internación."}, "InsuranceResponse": {"properties": {"id_paciente": {"type": "integer", "title": "Id Paciente", "examples": [10500]}, "id_obra_social": {"type": "integer", "title": "Id Obra Social", "examples": [15]}, "nombre_obra_social": {"type": "string", "title": "Nombre Obra Social", "examples": ["OSDE"]}, "codigo_plan": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Codigo Plan", "examples": ["OSDE-210"]}, "numero_afiliado": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Numero Afiliado", "examples": ["1234567890"]}, "vigente_desde": {"anyOf": [{"type": "string", "format": "date"}, {"type": "null"}], "title": "Vigente Desde", "examples": ["2024-01-01"]}, "vigente_hasta": {"anyOf": [{"type": "string", "format": "date"}, {"type": "null"}], "title": "Vigente Hasta"}}, "type": "object", "required": ["id_paciente", "id_obra_social", "nombre_obra_social"], "title": "InsuranceResponse", "description": "Cobertura médica vigente del paciente."}, "ItemRecetaCreate": {"properties": {"medicamento": {"type": "string", "maxLength": 300, "title": "Medicamento", "examples": ["Amoxicilina 500mg"]}, "indicaciones": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Indicaciones", "examples": ["Tomar 1 comprimido cada 8 horas por 7 días."]}, "cantidad": {"type": "integer", "minimum": 1.0, "title": "Cantidad", "default": 1, "examples": [1]}}, "type": "object", "required": ["medicamento"], "title": "ItemRecetaCreate", "description": "Schema para crear un ítem de receta."}, "ItemRecetaSchema": {"properties": {"medicamento": {"type": "string", "maxLength": 300, "title": "Medicamento", "examples": ["Amoxicilina 500mg"]}, "indicaciones": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Indicaciones", "examples": ["Tomar 1 comprimido cada 8 horas por 7 días."]}, "cantidad": {"type": "integer", "minimum": 1.0, "title": "Cantidad", "default": 1, "examples": [1]}, "id_item": {"type": "integer", "title": "Id Item", "examples": [1]}, "id_receta": {"type": "integer", "title": "Id Receta", "examples": [8502]}}, "type": "object", "required": ["medicamento", "id_item", "id_receta"], "title": "ItemRecetaSchema", "description": "Schema para leer un ítem de receta."}, "OrdenListResponse": {"properties": {"status": {"type": "string", "title": "Status", "default": "success", "examples": ["success"]}, "cantidad": {"type": "integer", "title": "Cantidad", "examples": [1]}, "data": {"items": {"$ref": "#/components/schemas/OrdenMedicaCompleta"}, "type": "array", "title": "Data"}}, "type": "object", "required": ["cantidad", "data"], "title": "OrdenListResponse", "description": "Respuesta de listado de órdenes."}, "OrdenMedicaCompleta": {"properties": {"id_orden": {"type": "integer", "title": "Id Orden", "examples": [4050]}, "id_paciente": {"type": "integer", "title": "Id Paciente", "examples": [10500]}, "tipo_estudio": {"$ref": "#/components/schemas/TipoEstudio", "examples": ["Imagen"]}, "descripcion_pedido": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Descripcion Pedido", "examples": ["Resonancia Magnética de Cerebro"]}, "prioridad": {"$ref": "#/components/schemas/PrioridadOrden", "examples": ["Urgente"]}, "alertas_clinicas": {"items": {"$ref": "#/components/schemas/AlertaSmartPayload"}, "type": "array", "title": "Alertas Clinicas"}}, "type": "object", "required": ["id_orden", "id_paciente", "tipo_estudio", "prioridad"], "title": "OrdenMedicaCompleta", "description": "Orden médica con Smart Payload de alertas clínicas activas."}, "PermissionChangeNotification": {"properties": {"id_usuario_afectado": {"type": "integer", "title": "Id Usuario Afectado", "examples": [42]}, "tipo_cambio": {"$ref": "#/components/schemas/TipoCambioPermiso", "examples": ["revoke-access"]}, "recurso_afectado": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Recurso Afectado", "examples": ["hce:write"]}, "motivo": {"type": "string", "title": "Motivo", "examples": ["Profesional suspendido por auditoría interna."]}, "id_usuario_notificador": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Id Usuario Notificador", "examples": [10]}, "fecha_ocurrencia": {"anyOf": [{"type": "string", "format": "date-time"}, {"type": "null"}], "title": "Fecha Ocurrencia"}}, "type": "object", "required": ["id_usuario_afectado", "tipo_cambio", "motivo"], "title": "PermissionChangeNotification", "description": "Payload que HCE envía a Core para notificar cambio de permisos."}, "PermissionChangeResponse": {"properties": {"acknowledged": {"type": "boolean", "title": "Acknowledged", "examples": [true]}}, "type": "object", "required": ["acknowledged"], "title": "PermissionChangeResponse", "description": "Respuesta de Core tras recibir la notificación."}, "PrioridadOrden": {"type": "string", "enum": ["Normal", "Urgente", "Emergencia"], "title": "PrioridadOrden"}, "RecetaCreate": {"properties": {"items": {"items": {"$ref": "#/components/schemas/ItemRecetaCreate"}, "type": "array", "minItems": 1, "title": "Items"}}, "type": "object", "required": ["items"], "title": "RecetaCreate", "description": "Payload para que un médico cree una receta completa con múltiples medicamentos."}, "RecetaListResponse": {"properties": {"total": {"type": "integer", "title": "Total", "examples": [15]}, "data": {"items": {"$ref": "#/components/schemas/RecetaMedicaDetallada"}, "type": "array", "title": "Data"}}, "type": "object", "required": ["total", "data"], "title": "RecetaListResponse", "description": "Respuesta paginada de recetas."}, "RecetaMedicaDetallada": {"properties": {"id_receta": {"type": "integer", "title": "Id Receta", "examples": [8502]}, "id_paciente": {"type": "integer", "title": "Id Paciente", "examples": [10500]}, "id_evolucion": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Id Evolucion", "examples": [302]}, "estado": {"$ref": "#/components/schemas/EstadoReceta", "examples": ["Activa"]}, "items": {"items": {"$ref": "#/components/schemas/ItemRecetaSchema"}, "type": "array", "title": "Items"}, "alertas_clinicas": {"items": {"$ref": "#/components/schemas/AlertaSmartPayload"}, "type": "array", "title": "Alertas Clinicas"}}, "type": "object", "required": ["id_receta", "id_paciente", "estado"], "title": "RecetaMedicaDetallada", "description": "Receta electrónica con Smart Payload de alertas clínicas activas del paciente."}, "ResultadoCreatedResponse": {"properties": {"status": {"type": "string", "title": "Status", "default": "success", "examples": ["success"]}, "message": {"type": "string", "title": "Message", "default": "Resultado vinculado correctamente a la Historia Clínica.", "examples": ["Resultado vinculado correctamente a la Historia Clínica."]}}, "type": "object", "title": "ResultadoCreatedResponse", "description": "Respuesta tras registrar un resultado."}, "ResultadoEstudioRequest": {"properties": {"id_orden": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "Id Orden", "examples": [4050]}, "id_paciente": {"type": "integer", "title": "Id Paciente", "examples": [10500]}, "tipo_estudio": {"$ref": "#/components/schemas/TipoEstudio", "examples": ["Imagen"]}, "id_profesional_firmante": {"type": "string", "title": "Id Profesional Firmante", "examples": ["Dra. Gomez (Radiología)"]}, "fecha_resultado": {"type": "string", "format": "date-time", "title": "Fecha Resultado", "examples": ["2026-04-17T11:00:00Z"]}, "informe_resumen": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Informe Resumen", "examples": ["RM de Cerebro: Sin hallazgos patológicos."]}, "id_externo_estudio": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Id Externo Estudio", "examples": ["550e8400-e29b-41d4-a716-446655440000"]}}, "type": "object", "required": ["id_paciente", "tipo_estudio", "id_profesional_firmante", "fecha_resultado"], "title": "ResultadoEstudioRequest", "description": "Payload enviado por M4/M5 para registrar un resultado en la HCE."}, "ResultadoEstudioResumen": {"properties": {"id_resultado": {"type": "integer", "title": "Id Resultado", "examples": [9021]}, "tipo_estudio": {"type": "string", "title": "Tipo Estudio", "examples": ["Laboratorio"]}, "fecha_resultado": {"type": "string", "format": "date-time", "title": "Fecha Resultado", "examples": ["2026-04-20T10:00:00Z"]}, "titulo": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Titulo", "examples": ["Hemograma Completo"]}, "resumen": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Resumen", "examples": ["Valores dentro de los rangos normales. Sin observaciones."]}, "profesional_firmante": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Profesional Firmante", "examples": ["Dr. Bioq. Fernandez"]}}, "type": "object", "required": ["id_resultado", "tipo_estudio", "fecha_resultado"], "title": "ResultadoEstudioResumen", "description": "Resumen de resultado para el Portal del Paciente (M8)."}, "SeveridadAlerta": {"type": "string", "enum": ["Leve", "Moderada", "Severa", "Critica"], "title": "SeveridadAlerta", "description": "Nivel de severidad de la alerta."}, "TipoActoMedico": {"type": "string", "enum": ["consulta", "estudio-laboratorio", "estudio-imagen", "procedimiento", "cirugia", "medicacion", "descartable"], "title": "TipoActoMedico"}, "TipoAntecedente": {"type": "string", "enum": ["Quirurgico", "Familiar", "Patologico", "Habito"], "title": "TipoAntecedente", "description": "Tipo de antecedente clínico del paciente."}, "TipoCambioPermiso": {"type": "string", "enum": ["revoke-access", "role-change", "deactivate-user"], "title": "TipoCambioPermiso"}, "TipoConsideracion": {"type": "string", "enum": ["Alergia", "Dispositivo_Implantado", "Condicion_Critica", "Riesgo_Infeccioso", "Contraindicacion"], "title": "TipoConsideracion", "description": "Tipo de consideración/alerta clínica del paciente."}, "TipoEpisodio": {"type": "string", "enum": ["consulta-externa", "internacion", "guardia", "cirugia"], "title": "TipoEpisodio"}, "TipoEstudio": {"type": "string", "enum": ["Laboratorio", "Imagen", "Anatomia_Patologica"], "title": "TipoEstudio"}, "ValidationError": {"properties": {"loc": {"items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}, "type": "array", "title": "Location"}, "msg": {"type": "string", "title": "Message"}, "type": {"type": "string", "title": "Error Type"}, "input": {"title": "Input"}, "ctx": {"type": "object", "title": "Context"}}, "type": "object", "required": ["loc", "msg", "type"], "title": "ValidationError"}}, "securitySchemes": {"JWT Bearer": {"type": "http", "description": "JWT emitido por Módulo 10 (Core). Header: Authorization: Bearer <token>", "scheme": "bearer"}}}},
|
| 24 |
-
dom_id: '#swagger-ui',
|
| 25 |
-
deepLinking: true,
|
| 26 |
-
presets: [
|
| 27 |
-
SwaggerUIBundle.presets.apis,
|
| 28 |
-
SwaggerUIStandalonePreset
|
| 29 |
-
],
|
| 30 |
-
layout: "StandaloneLayout"
|
| 31 |
-
});
|
| 32 |
-
};
|
| 33 |
-
</script>
|
| 34 |
-
</body>
|
| 35 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
documentation/integrations/openapi_docs/M1_openapi.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
documentation/roles.md
CHANGED
|
@@ -86,6 +86,16 @@ Solo ADMINISTRATIVO resuelve solicitudes de internación/traslado, incluso si fu
|
|
| 86 |
|
| 87 |
LIMPIEZA no tiene acceso al historial de auditoría — no necesita visibilidad sobre el log completo de movimientos clínicos/administrativos para hacer su trabajo.
|
| 88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
### Webhooks entrantes
|
| 90 |
|
| 91 |
Los endpoints bajo `/webhooks/*` (recepción de eventos de M1 HCE, M9 Monitoreo, M2 Turnos) **no usan `require_roles`** — no hay un usuario humano autenticado por JWT en esas llamadas. La autenticación de webhooks entrantes es un punto pendiente de definir con el Bus de Eventos de Core (ver `M6_DISEÑO.md` §13).
|
|
|
|
| 86 |
|
| 87 |
LIMPIEZA no tiene acceso al historial de auditoría — no necesita visibilidad sobre el log completo de movimientos clínicos/administrativos para hacer su trabajo.
|
| 88 |
|
| 89 |
+
### Pacientes (consulta a M1 HCE)
|
| 90 |
+
|
| 91 |
+
| Endpoint | ADMINISTRATIVO | MEDICO | LIMPIEZA |
|
| 92 |
+
|---|:---:|:---:|:---:|
|
| 93 |
+
| `GET /pacientes/{pacienteId}/ficha-medica` | ✓ | ✓ | ✓ |
|
| 94 |
+
| `GET /pacientes/{pacienteId}/antecedentes` | ✓ | ✓ | ✓ |
|
| 95 |
+
|
| 96 |
+
Proxies de solo lectura hacia M1 (HCE), para la página de detalle de cama del front —
|
| 97 |
+
mismo criterio que `GET /camas` (mapa completo visible para los 3 roles).
|
| 98 |
+
|
| 99 |
### Webhooks entrantes
|
| 100 |
|
| 101 |
Los endpoints bajo `/webhooks/*` (recepción de eventos de M1 HCE, M9 Monitoreo, M2 Turnos) **no usan `require_roles`** — no hay un usuario humano autenticado por JWT en esas llamadas. La autenticación de webhooks entrantes es un punto pendiente de definir con el Bus de Eventos de Core (ver `M6_DISEÑO.md` §13).
|
tests/test_pacientes.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Tests del router de Pacientes (proxy de consulta a M1 HCE): ficha médica y antecedentes
|
| 3 |
+
clínicos, para la página de detalle de cama del front.
|
| 4 |
+
"""
|
| 5 |
+
from fastapi.testclient import TestClient
|
| 6 |
+
|
| 7 |
+
PREFIX = "/api/v1/pacientes"
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
# ─── Ficha médica ───────────────────────────────────────────────────────────
|
| 11 |
+
|
| 12 |
+
def test_get_ficha_medica_sin_token_401(client: TestClient):
|
| 13 |
+
resp = client.get(f"{PREFIX}/7/ficha-medica")
|
| 14 |
+
assert resp.status_code == 401
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def test_get_ficha_medica_ok_mock(client: TestClient, medico_headers):
|
| 18 |
+
"""Con MOCK_EXTERNAL_SERVICES=true (default de test), hce.get_ficha_medica devuelve
|
| 19 |
+
un dato canned sin llamar a M1."""
|
| 20 |
+
resp = client.get(f"{PREFIX}/7/ficha-medica", headers=medico_headers)
|
| 21 |
+
assert resp.status_code == 200
|
| 22 |
+
data = resp.json()
|
| 23 |
+
assert data["id_paciente"] == 7
|
| 24 |
+
assert data["grupo_sanguineo"] == "A+"
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def test_get_ficha_medica_no_disponible_404(client: TestClient, medico_headers, monkeypatch):
|
| 28 |
+
monkeypatch.setattr("app.integrations.hce.get_ficha_medica", lambda pid: None)
|
| 29 |
+
resp = client.get(f"{PREFIX}/7/ficha-medica", headers=medico_headers)
|
| 30 |
+
# El exception_handler(404) global de app/main.py sobreescribe el detail de
|
| 31 |
+
# cualquier HTTPException(404) con un body genérico — mismo criterio que el resto
|
| 32 |
+
# de los 404 del proyecto (ver tests/test_camas.py), solo se verifica el status.
|
| 33 |
+
assert resp.status_code == 404
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def test_get_ficha_medica_rol_limpieza_ok(client: TestClient, limpieza_headers):
|
| 37 |
+
"""Los 3 roles pueden consultar — mismo criterio que GET /camas."""
|
| 38 |
+
resp = client.get(f"{PREFIX}/7/ficha-medica", headers=limpieza_headers)
|
| 39 |
+
assert resp.status_code == 200
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
# ─── Antecedentes clínicos ──────────────────────────────────────────────────
|
| 43 |
+
|
| 44 |
+
def test_get_antecedentes_sin_token_401(client: TestClient):
|
| 45 |
+
resp = client.get(f"{PREFIX}/7/antecedentes")
|
| 46 |
+
assert resp.status_code == 401
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def test_get_antecedentes_ok_mock(client: TestClient, admin_headers):
|
| 50 |
+
resp = client.get(f"{PREFIX}/7/antecedentes", headers=admin_headers)
|
| 51 |
+
assert resp.status_code == 200
|
| 52 |
+
data = resp.json()
|
| 53 |
+
assert len(data) == 1
|
| 54 |
+
assert data[0]["tipo"] == "Patologico"
|
| 55 |
+
assert data[0]["id_paciente"] == 7
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def test_get_antecedentes_no_disponible_404(client: TestClient, admin_headers, monkeypatch):
|
| 59 |
+
"""None (falla de M1 o paciente sin registro) se traduce a 404 — distinto de una
|
| 60 |
+
lista vacía real (ver test siguiente)."""
|
| 61 |
+
monkeypatch.setattr("app.integrations.hce.get_antecedentes", lambda pid: None)
|
| 62 |
+
resp = client.get(f"{PREFIX}/7/antecedentes", headers=admin_headers)
|
| 63 |
+
assert resp.status_code == 404
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def test_get_antecedentes_lista_vacia_no_es_404(client: TestClient, admin_headers, monkeypatch):
|
| 67 |
+
"""Un paciente sin antecedentes reales devuelve 200 con [], no 404 — `[]` no es `None`."""
|
| 68 |
+
monkeypatch.setattr("app.integrations.hce.get_antecedentes", lambda pid: [])
|
| 69 |
+
resp = client.get(f"{PREFIX}/7/antecedentes", headers=admin_headers)
|
| 70 |
+
assert resp.status_code == 200
|
| 71 |
+
assert resp.json() == []
|