{"openapi":"3.0.3","info":{"title":"API Sistema de Gestión de Cuidados — Vitalia","description":"API REST para la gestión de internos, medicamentos, mediciones, alertas e incidencias en centros de cuidado. Todas las respuestas siguen un formato estandarizado: un objeto `result` con `code` (código HTTP: 200/400/401/500), `ref` (referencia interna del diccionario de errores, p. ej. `AUTH-0001`) y `msg` (mensaje para el usuario), y un objeto `data` con el contenido específico de cada operación.\n\n**Nota de cobertura:** las referencias `XXX-0xxx`/`XXX-1xxx`/`SYS-9xxx` provienen del diccionario de errores original del proyecto. Las marcadas con \uD83C\uDD95 en su `summary` son extensiones añadidas para cubrir operaciones necesarias (actualizar, desvincular, refrescar token, listar catálogos, perfil del usuario autenticado, ingesta de alertas desde dispositivos IoT) que el diccionario original no contemplaba explícitamente, siguiendo la misma convención de nomenclatura.\n\n**Decisiones de diseño verificadas en esta revisión:** - Todo listado devuelve `data: { items: [...], meta: {...} }` — forma\n  consistente sin excepciones, incluidos catálogos pequeños (roles,\n  familiares).\n- Toda operación protegida documenta explícitamente su respuesta `401`. - `POST /alertas` acepta dos métodos de autenticación (`bearerAuth` o\n  `deviceApiKey`) para admitir tanto al personal como a sensores ESP32.\n- Cada referencia del diccionario de errores (original y extendida) está\n  efectivamente enlazada a al menos un endpoint — ninguna quedó huérfana.\n","version":"1.2.0","contact":{"name":"Equipo Vitalia"}},"servers":[{"url":"https://ambar.cards/api","description":"Producción"},{"url":"https://staging.ambar.cards/api","description":"Staging"}],"tags":[{"name":"Auth"},{"name":"Usuarios"},{"name":"Roles"},{"name":"Internos"},{"name":"Medicamentos"},{"name":"Mediciones"},{"name":"Notificaciones"},{"name":"Alertas"},{"name":"Incidencias"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Token JWT obtenido en /auth/login. Enviar como `Authorization: Bearer {token}`. Usado por el personal (staff web/app).\n"},"deviceApiKey":{"type":"apiKey","in":"header","name":"X-Device-Key","description":"\uD83C\uDD95 Clave estática asignada por dispositivo IoT (ESP32/Blynk). Alternativa a `bearerAuth` para reportar alertas automáticas sin flujo de login interactivo, ya que el firmware embebido no puede sostener sesiones JWT.\n"}},"schemas":{"Result":{"type":"object","description":"Metadatos de resultado de la operación.","required":["code","ref","msg"],"properties":{"code":{"type":"integer","description":"Código de respuesta HTTP.","enum":[200,400,401,500],"example":200},"ref":{"type":"string","description":"Referencia interna del diccionario de errores (ver convención).","example":"USR-0001"},"msg":{"type":"string","description":"Mensaje orientado al usuario final.","example":"Usuario registrado exitosamente"}}},"ErrorResponse":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","nullable":true,"example":null}}},"PaginatedMeta":{"type":"object","description":"Metadatos de paginación, presentes en toda respuesta de listado.","properties":{"page":{"type":"integer","example":1},"per_page":{"type":"integer","example":20},"total":{"type":"integer","example":87,"description":"Total de registros que cumplen el filtro"},"total_pages":{"type":"integer","example":5}}},"Rol":{"type":"object","properties":{"id_rol":{"type":"integer","example":2},"nombre":{"type":"string","example":"cuidador"},"descripcion":{"type":"string","example":"Personal encargado de atención directa a internos"}}},"Usuario":{"type":"object","properties":{"id_usuario":{"type":"integer","example":12},"nombre":{"type":"string","example":"María López"},"correo":{"type":"string","format":"email","example":"maria@vitalia.com"},"id_rol":{"type":"integer","example":2},"estado":{"type":"string","enum":["activo","inactivo"],"example":"activo"}}},"UsuarioInput":{"type":"object","required":["nombre","correo","contrasena","id_rol"],"properties":{"nombre":{"type":"string"},"correo":{"type":"string","format":"email"},"contrasena":{"type":"string","format":"password"},"id_rol":{"type":"integer"}}},"Interno":{"type":"object","properties":{"id_interno":{"type":"integer","example":34},"nombre":{"type":"string","example":"Juan Pérez"},"fecha_nacimiento":{"type":"string","format":"date","example":"1945-03-12"},"sexo":{"type":"string","enum":["M","F"],"example":"M"},"estado":{"type":"string","enum":["activo","baja"],"example":"activo"}}},"InternoInput":{"type":"object","required":["nombre","fecha_nacimiento","sexo"],"properties":{"nombre":{"type":"string"},"fecha_nacimiento":{"type":"string","format":"date"},"sexo":{"type":"string","enum":["M","F"]}}},"HistorialClinicoInput":{"type":"object","required":["contenido"],"properties":{"contenido":{"type":"string","example":"Diagnóstico: hipertensión controlada"}}},"HistorialClinico":{"type":"object","properties":{"id_historial":{"type":"integer"},"id_interno":{"type":"integer"},"contenido":{"type":"string"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time","nullable":true}}},"FamiliarVinculoInput":{"type":"object","required":["id_usuario"],"properties":{"id_usuario":{"type":"integer","description":"Usuario con rol familiar a vincular"}}},"FamiliarVinculo":{"type":"object","properties":{"id_usuario":{"type":"integer"},"id_interno":{"type":"integer"},"nombre":{"type":"string","example":"Carla Pérez"},"parentesco":{"type":"string","nullable":true,"example":"hija"}}},"Medicamento":{"type":"object","properties":{"id_medicamento":{"type":"integer"},"nombre":{"type":"string","example":"Losartán 50mg"},"presentacion":{"type":"string","example":"Tableta"}}},"MedicamentoInput":{"type":"object","required":["nombre","presentacion"],"properties":{"nombre":{"type":"string"},"presentacion":{"type":"string"}}},"PrescripcionInput":{"type":"object","required":["id_medicamento","dosis","frecuencia"],"properties":{"id_medicamento":{"type":"integer"},"dosis":{"type":"string","example":"50mg"},"frecuencia":{"type":"string","example":"cada 12 horas"}}},"PrescripcionUpdateInput":{"type":"object","description":"Actualización parcial de dosis/frecuencia de una prescripción activa.","properties":{"dosis":{"type":"string","example":"75mg"},"frecuencia":{"type":"string","example":"cada 8 horas"}}},"Prescripcion":{"type":"object","properties":{"id_interno_medicamento":{"type":"integer"},"id_interno":{"type":"integer"},"id_medicamento":{"type":"integer"},"dosis":{"type":"string"},"frecuencia":{"type":"string"},"estado":{"type":"string","enum":["activo","cancelado","finalizado"]}}},"AdministracionInput":{"type":"object","required":["dosis_administrada"],"properties":{"dosis_administrada":{"type":"string","example":"50mg"},"observaciones":{"type":"string","nullable":true}}},"AdministracionMedicamento":{"type":"object","properties":{"id_administracion":{"type":"integer"},"id_interno_medicamento":{"type":"integer"},"id_cuidador":{"type":"integer"},"timestamp":{"type":"string","format":"date-time"}}},"MedicionInput":{"type":"object","description":"Debe llegar al menos un signo vital.","properties":{"presion_arterial":{"type":"string","nullable":true,"example":"120/80"},"frecuencia_cardiaca":{"type":"integer","nullable":true,"example":72},"temperatura":{"type":"number","nullable":true,"example":36.5},"saturacion_oxigeno":{"type":"integer","nullable":true,"example":97},"glucosa":{"type":"number","nullable":true,"example":95}}},"Medicion":{"allOf":[{"$ref":"#/components/schemas/MedicionInput"},{"type":"object","properties":{"id_medicion":{"type":"integer"},"id_interno":{"type":"integer"},"created_by":{"type":"integer"},"created_at":{"type":"string","format":"date-time"}}}]},"Notificacion":{"type":"object","properties":{"id_notificacion":{"type":"integer"},"mensaje":{"type":"string"},"estado_lectura":{"type":"string","enum":["no_leida","leida"]},"created_at":{"type":"string","format":"date-time"}}},"AlertaInput":{"type":"object","required":["tipo_alerta","descripcion","origen"],"properties":{"tipo_alerta":{"type":"string","example":"caida"},"descripcion":{"type":"string"},"origen":{"type":"string","example":"sensor_esp32"}}},"AlertaEstadoInput":{"type":"object","required":["estado"],"properties":{"estado":{"type":"string","enum":["atendida","descartada"],"example":"atendida"}}},"Alerta":{"allOf":[{"$ref":"#/components/schemas/AlertaInput"},{"type":"object","properties":{"id_alerta":{"type":"integer"},"estado":{"type":"string","enum":["activa","atendida","descartada"]}}}]},"IncidenciaInput":{"type":"object","required":["descripcion","prioridad"],"properties":{"descripcion":{"type":"string"},"prioridad":{"type":"string","enum":["baja","media","alta"]}}},"Incidencia":{"allOf":[{"$ref":"#/components/schemas/IncidenciaInput"},{"type":"object","properties":{"id_incidencia":{"type":"integer"},"estado":{"type":"string","enum":["abierta","cerrada"]}}}]},"LoginInput":{"type":"object","required":["correo","contrasena"],"properties":{"correo":{"type":"string","format":"email"},"contrasena":{"type":"string","format":"password"}}},"LoginData":{"type":"object","properties":{"token":{"type":"string","example":"eyJhbGciOiJIUzI1NiIs..."},"usuario":{"$ref":"#/components/schemas/Usuario"}}},"RefreshInput":{"type":"object","required":["refresh_token"],"properties":{"refresh_token":{"type":"string","example":"df34a1c2-9e21-4b7a-9c3e-..."}}},"RefreshData":{"type":"object","properties":{"token":{"type":"string","example":"eyJhbGciOiJIUzI1NiIs..."}}}},"examples":{"AUTH-0001":{"summary":"AUTH-0001 · Sesión iniciada","value":{"result":{"code":200,"ref":"AUTH-0001","msg":"Sesión iniciada correctamente"},"data":{"token":"eyJhbGciOi...","usuario":{"id_usuario":1,"nombre":"María López","correo":"maria@vitalia.com","id_rol":2,"estado":"activo"}}}},"AUTH-0002":{"summary":"AUTH-0002 · Sesión cerrada","value":{"result":{"code":200,"ref":"AUTH-0002","msg":"Sesión cerrada correctamente"},"data":null}},"USR-0001":{"summary":"USR-0001 · Usuario creado","value":{"result":{"code":200,"ref":"USR-0001","msg":"Usuario registrado exitosamente"},"data":{"id_usuario":12}}},"USR-0002":{"summary":"USR-0002 · Usuario actualizado","value":{"result":{"code":200,"ref":"USR-0002","msg":"Datos del usuario actualizados"},"data":{"id_usuario":12}}},"USR-0003":{"summary":"USR-0003 · Usuario desactivado","value":{"result":{"code":200,"ref":"USR-0003","msg":"El usuario fue desactivado del sistema"},"data":null}},"INT-0001":{"summary":"INT-0001 · Interno creado","value":{"result":{"code":200,"ref":"INT-0001","msg":"Interno registrado correctamente"},"data":{"id_interno":34}}},"INT-0002":{"summary":"INT-0002 · Interno dado de baja","value":{"result":{"code":200,"ref":"INT-0002","msg":"El interno fue dado de baja"},"data":null}},"INT-0003":{"summary":"INT-0003 · Historial clínico guardado","value":{"result":{"code":200,"ref":"INT-0003","msg":"Historial clínico guardado"},"data":{"id_historial":5}}},"INT-0004":{"summary":"INT-0004 · Familiar vinculado","value":{"result":{"code":200,"ref":"INT-0004","msg":"Familiar vinculado al interno"},"data":null}},"MED-0001":{"summary":"MED-0001 · Medicamento en catálogo","value":{"result":{"code":200,"ref":"MED-0001","msg":"Medicamento registrado en el catálogo"},"data":{"id_medicamento":7}}},"MED-0002":{"summary":"MED-0002 · Medicamento prescrito","value":{"result":{"code":200,"ref":"MED-0002","msg":"Medicamento prescrito al interno"},"data":{"id_interno_medicamento":21}}},"MED-0003":{"summary":"MED-0003 · Dosis registrada","value":{"result":{"code":200,"ref":"MED-0003","msg":"Dosis registrada correctamente"},"data":{"id_administracion":88}}},"MED-0004":{"summary":"MED-0004 · Prescripción cancelada","value":{"result":{"code":200,"ref":"MED-0004","msg":"Prescripción cancelada"},"data":null}},"MDC-0001":{"summary":"MDC-0001 · Signos vitales guardados","value":{"result":{"code":200,"ref":"MDC-0001","msg":"Signos vitales guardados"},"data":{"id_medicion":150}}},"NTF-0001":{"summary":"NTF-0001 · Notificación leída","value":{"result":{"code":200,"ref":"NTF-0001","msg":"Notificación marcada como leída"},"data":null}},"ALT-0001":{"summary":"ALT-0001 · Alerta registrada","value":{"result":{"code":200,"ref":"ALT-0001","msg":"Alerta registrada en el sistema"},"data":{"id_alerta":9}}},"INC-0001":{"summary":"INC-0001 · Incidencia registrada","value":{"result":{"code":200,"ref":"INC-0001","msg":"Incidencia registrada correctamente"},"data":{"id_incidencia":3}}},"INC-0002":{"summary":"INC-0002 · Incidencia actualizada","value":{"result":{"code":200,"ref":"INC-0002","msg":"Incidencia actualizada"},"data":{"id_incidencia":3}}},"AUTH-0003":{"summary":"\uD83C\uDD95 AUTH-0003 · Token renovado","value":{"result":{"code":200,"ref":"AUTH-0003","msg":"Sesión renovada correctamente"},"data":{"token":"eyJhbGciOi..."}}},"AUTH-0004":{"summary":"\uD83C\uDD95 AUTH-0004 · Perfil obtenido","value":{"result":{"code":200,"ref":"AUTH-0004","msg":"Perfil obtenido correctamente"},"data":{"id_usuario":1,"nombre":"María López","correo":"maria@vitalia.com","id_rol":2,"estado":"activo"}}},"INT-0005":{"summary":"\uD83C\uDD95 INT-0005 · Familiar desvinculado","value":{"result":{"code":200,"ref":"INT-0005","msg":"Familiar desvinculado del interno"},"data":null}},"MED-0005":{"summary":"\uD83C\uDD95 MED-0005 · Medicamento actualizado","value":{"result":{"code":200,"ref":"MED-0005","msg":"Medicamento actualizado en el catálogo"},"data":{"id_medicamento":7}}},"MED-0006":{"summary":"\uD83C\uDD95 MED-0006 · Prescripción actualizada","value":{"result":{"code":200,"ref":"MED-0006","msg":"Prescripción actualizada correctamente"},"data":{"id_interno_medicamento":21}}},"ALT-0002":{"summary":"\uD83C\uDD95 ALT-0002 · Alerta actualizada","value":{"result":{"code":200,"ref":"ALT-0002","msg":"La alerta fue actualizada"},"data":{"id_alerta":9}}},"AUTH-1001":{"summary":"AUTH-1001 · Credenciales incorrectas","value":{"result":{"code":400,"ref":"AUTH-1001","msg":"Usuario o contraseña incorrectos"},"data":null}},"AUTH-1002":{"summary":"AUTH-1002 · Sesión expirada","value":{"result":{"code":400,"ref":"AUTH-1002","msg":"Tu sesión expiró, inicia sesión de nuevo"},"data":null}},"AUTH-1003":{"summary":"AUTH-1003 · Sin permiso","value":{"result":{"code":400,"ref":"AUTH-1003","msg":"No tienes permiso para realizar esta acción"},"data":null}},"USR-1001":{"summary":"USR-1001 · Campos obligatorios","value":{"result":{"code":400,"ref":"USR-1001","msg":"Completa todos los campos obligatorios"},"data":null}},"USR-1002":{"summary":"USR-1002 · Correo ya registrado","value":{"result":{"code":400,"ref":"USR-1002","msg":"Este correo ya está registrado"},"data":null}},"USR-1003":{"summary":"USR-1003 · Usuario no existe","value":{"result":{"code":400,"ref":"USR-1003","msg":"El usuario no existe"},"data":null}},"USR-1004":{"summary":"USR-1004 · Rol no válido","value":{"result":{"code":400,"ref":"USR-1004","msg":"El rol seleccionado no es válido"},"data":null}},"INT-1001":{"summary":"INT-1001 · Interno no existe","value":{"result":{"code":400,"ref":"INT-1001","msg":"El interno no existe en el sistema"},"data":null}},"INT-1002":{"summary":"INT-1002 · Datos incompletos","value":{"result":{"code":400,"ref":"INT-1002","msg":"Completa los datos del interno"},"data":null}},"INT-1003":{"summary":"INT-1003 · Historial ya existe","value":{"result":{"code":400,"ref":"INT-1003","msg":"Este interno ya tiene historial clínico creado"},"data":null}},"INT-1004":{"summary":"INT-1004 · Familiar ya vinculado","value":{"result":{"code":400,"ref":"INT-1004","msg":"Este familiar ya está vinculado al interno"},"data":null}},"MED-1001":{"summary":"MED-1001 · Medicamento no existe","value":{"result":{"code":400,"ref":"MED-1001","msg":"El medicamento no existe en el catálogo"},"data":null}},"MED-1002":{"summary":"MED-1002 · Prescripción no existe","value":{"result":{"code":400,"ref":"MED-1002","msg":"La prescripción no existe"},"data":null}},"MED-1003":{"summary":"MED-1003 · Dosis inválida","value":{"result":{"code":400,"ref":"MED-1003","msg":"El formato de la dosis no es válido"},"data":null}},"MED-1004":{"summary":"MED-1004 · Prescripción ya cancelada","value":{"result":{"code":400,"ref":"MED-1004","msg":"Esta prescripción ya fue cancelada o finalizada"},"data":null}},"MDC-1001":{"summary":"MDC-1001 · Sin signos vitales","value":{"result":{"code":400,"ref":"MDC-1001","msg":"Ingresa al menos un signo vital"},"data":null}},"MDC-1002":{"summary":"MDC-1002 · Medición no existe","value":{"result":{"code":400,"ref":"MDC-1002","msg":"El registro de medición no existe"},"data":null}},"ALT-1001":{"summary":"ALT-1001 · Alerta no existe","value":{"result":{"code":400,"ref":"ALT-1001","msg":"La alerta no existe"},"data":null}},"ALT-1002":{"summary":"ALT-1002 · Datos de alerta incompletos","value":{"result":{"code":400,"ref":"ALT-1002","msg":"Completa el tipo de alerta y descripción"},"data":null}},"INC-1001":{"summary":"INC-1001 · Incidencia no existe","value":{"result":{"code":400,"ref":"INC-1001","msg":"La incidencia no existe"},"data":null}},"INC-1002":{"summary":"INC-1002 · Prioridad no válida","value":{"result":{"code":400,"ref":"INC-1002","msg":"La prioridad seleccionada no es válida"},"data":null}},"INC-1003":{"summary":"INC-1003 · Incidencia ya cerrada","value":{"result":{"code":400,"ref":"INC-1003","msg":"Esta incidencia ya fue cerrada"},"data":null}},"AUTH-1004":{"summary":"\uD83C\uDD95 AUTH-1004 · No autenticado","value":{"result":{"code":401,"ref":"AUTH-1004","msg":"Debes iniciar sesión para continuar"},"data":null}},"AUTH-1005":{"summary":"\uD83C\uDD95 AUTH-1005 · Refresh token inválido","value":{"result":{"code":400,"ref":"AUTH-1005","msg":"Tu sesión expiró, inicia sesión de nuevo"},"data":null}},"ROL-1001":{"summary":"\uD83C\uDD95 ROL-1001 · Rol no existe","value":{"result":{"code":400,"ref":"ROL-1001","msg":"El rol no existe"},"data":null}},"INT-1005":{"summary":"\uD83C\uDD95 INT-1005 · Familiar no vinculado","value":{"result":{"code":400,"ref":"INT-1005","msg":"Este familiar no está vinculado al interno"},"data":null}},"MED-1005":{"summary":"\uD83C\uDD95 MED-1005 · Datos de medicamento inválidos","value":{"result":{"code":400,"ref":"MED-1005","msg":"Completa el nombre y la presentación del medicamento"},"data":null}},"SYS-9001":{"summary":"SYS-9001 · Error no controlado","value":{"result":{"code":500,"ref":"SYS-9001","msg":"Ocurrió un error. Recarga la página e intenta de nuevo"},"data":null}},"SYS-9002":{"summary":"SYS-9002 · Timeout de base de datos","value":{"result":{"code":500,"ref":"SYS-9002","msg":"El sistema tardó demasiado en responder. Intenta en unos segundos"},"data":null}},"SYS-9003":{"summary":"SYS-9003 · Error al guardar","value":{"result":{"code":500,"ref":"SYS-9003","msg":"No pudimos guardar la información. Intenta de nuevo"},"data":null}},"SYS-9004":{"summary":"SYS-9004 · Falla de JWT","value":{"result":{"code":500,"ref":"SYS-9004","msg":"No pudimos iniciar tu sesión. Intenta de nuevo"},"data":null}},"SYS-9005":{"summary":"SYS-9005 · Servicio no disponible","value":{"result":{"code":500,"ref":"SYS-9005","msg":"El servicio no está disponible en este momento. Regresa pronto"},"data":null}},"SYS-9006":{"summary":"SYS-9006 · Fallo interno de logs/storage","value":{"result":{"code":500,"ref":"SYS-9006","msg":"Ocurrió un problema interno. Nuestro equipo ya fue notificado"},"data":null}}},"parameters":{"PageParam":{"name":"page","in":"query","description":"Número de página (paginación).","required":false,"schema":{"type":"integer","minimum":1,"default":1}},"PerPageParam":{"name":"per_page","in":"query","description":"Cantidad de resultados por página.","required":false,"schema":{"type":"integer","minimum":1,"maximum":100,"default":20}},"UsuarioEstadoParam":{"name":"estado","in":"query","description":"Filtra usuarios por estado.","required":false,"schema":{"type":"string","enum":["activo","inactivo"]}},"InternoEstadoParam":{"name":"estado","in":"query","description":"Filtra internos por estado.","required":false,"schema":{"type":"string","enum":["activo","baja"]}},"MedicamentoNombreParam":{"name":"nombre","in":"query","description":"Búsqueda parcial por nombre de medicamento.","required":false,"schema":{"type":"string"}},"PrescripcionEstadoParam":{"name":"estado","in":"query","description":"Filtra prescripciones por estado.","required":false,"schema":{"type":"string","enum":["activo","cancelado","finalizado"]}},"MedicionDesdeParam":{"name":"desde","in":"query","description":"Fecha/hora mínima (ISO 8601) para filtrar mediciones.","required":false,"schema":{"type":"string","format":"date-time"}},"MedicionHastaParam":{"name":"hasta","in":"query","description":"Fecha/hora máxima (ISO 8601) para filtrar mediciones.","required":false,"schema":{"type":"string","format":"date-time"}},"AlertaTipoParam":{"name":"tipo_alerta","in":"query","description":"Filtra alertas por tipo (p. ej. caida, sensor_esp32).","required":false,"schema":{"type":"string"}},"AlertaEstadoParam":{"name":"estado","in":"query","description":"Filtra alertas por estado.","required":false,"schema":{"type":"string","enum":["activa","atendida","descartada"]}},"IncidenciaEstadoParam":{"name":"estado","in":"query","description":"Filtra incidencias por estado.","required":false,"schema":{"type":"string","enum":["abierta","cerrada"]}},"IncidenciaPrioridadParam":{"name":"prioridad","in":"query","description":"Filtra incidencias por prioridad.","required":false,"schema":{"type":"string","enum":["baja","media","alta"]}},"NotificacionEstadoParam":{"name":"estado_lectura","in":"query","description":"Filtra notificaciones por estado de lectura.","required":false,"schema":{"type":"string","enum":["no_leida","leida"]}}},"responses":{"Unauthorized":{"description":"No autenticado (token ausente o con formato inválido)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"AUTH-1004":{"$ref":"#/components/examples/AUTH-1004"}}}}},"ServerError":{"description":"Error interno del servidor","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"SYS-9001":{"$ref":"#/components/examples/SYS-9001"},"SYS-9002":{"$ref":"#/components/examples/SYS-9002"},"SYS-9003":{"$ref":"#/components/examples/SYS-9003"},"SYS-9005":{"$ref":"#/components/examples/SYS-9005"},"SYS-9006":{"$ref":"#/components/examples/SYS-9006"}}}}}}},"paths":{"/auth/login":{"post":{"tags":["Auth"],"summary":"Iniciar sesión","operationId":"iniciarSesion","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginInput"}}}},"responses":{"200":{"description":"Sesión iniciada","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"$ref":"#/components/schemas/LoginData"}}},"examples":{"AUTH-0001":{"$ref":"#/components/examples/AUTH-0001"}}}}},"400":{"description":"Credenciales inválidas","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"AUTH-1001":{"$ref":"#/components/examples/AUTH-1001"}}}}},"500":{"description":"Falla al generar sesión","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"SYS-9004":{"$ref":"#/components/examples/SYS-9004"},"SYS-9001":{"$ref":"#/components/examples/SYS-9001"}}}}}}}},"/auth/refresh":{"post":{"tags":["Auth"],"summary":"\uD83C\uDD95 Renovar token de sesión","operationId":"renovarTokenDeSesion","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RefreshInput"}}}},"responses":{"200":{"description":"Token renovado","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"$ref":"#/components/schemas/RefreshData"}}},"examples":{"AUTH-0003":{"$ref":"#/components/examples/AUTH-0003"}}}}},"400":{"description":"Refresh token inválido o expirado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"AUTH-1005":{"$ref":"#/components/examples/AUTH-1005"}}}}},"500":{"description":"Falla al firmar el nuevo token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"SYS-9004":{"$ref":"#/components/examples/SYS-9004"}}}}}}}},"/auth/logout":{"post":{"tags":["Auth"],"summary":"Cerrar sesión","operationId":"cerrarSesion","responses":{"200":{"description":"Sesión cerrada","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","nullable":true,"example":null}}},"examples":{"AUTH-0002":{"$ref":"#/components/examples/AUTH-0002"}}}}},"400":{"description":"Token expirado o inválido","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"AUTH-1002":{"$ref":"#/components/examples/AUTH-1002"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/auth/me":{"get":{"tags":["Auth"],"summary":"\uD83C\uDD95 Obtener perfil del usuario autenticado","operationId":"obtenerPerfilDelUsuarioAutenticado","description":"Permite al frontend recuperar el usuario asociado al token sin decodificar el JWT localmente.","responses":{"200":{"description":"Perfil obtenido","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"$ref":"#/components/schemas/Usuario"}}},"examples":{"AUTH-0004":{"$ref":"#/components/examples/AUTH-0004"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/roles":{"get":{"tags":["Roles"],"summary":"\uD83C\uDD95 Listar catálogo de roles","operationId":"listarCatalogoDeRoles","description":"Catálogo de referencia usado para validar `id_rol` al crear/actualizar usuarios.","parameters":[{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PerPageParam"}],"responses":{"200":{"description":"Lista de roles","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Rol"}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/roles/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"get":{"tags":["Roles"],"summary":"\uD83C\uDD95 Obtener rol","operationId":"obtenerRol","responses":{"200":{"description":"Rol encontrado","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"$ref":"#/components/schemas/Rol"}}}}}},"400":{"description":"Rol no existe","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"ROL-1001":{"$ref":"#/components/examples/ROL-1001"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/usuarios":{"post":{"tags":["Usuarios"],"summary":"Registrar usuario","operationId":"registrarUsuario","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UsuarioInput"}}}},"responses":{"200":{"description":"Usuario creado","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"id_usuario":{"type":"integer"}}}}},"examples":{"USR-0001":{"$ref":"#/components/examples/USR-0001"}}}}},"400":{"description":"Validación fallida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"USR-1001":{"$ref":"#/components/examples/USR-1001"},"USR-1002":{"$ref":"#/components/examples/USR-1002"},"USR-1004":{"$ref":"#/components/examples/USR-1004"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"get":{"tags":["Usuarios"],"summary":"Listar usuarios","operationId":"listarUsuarios","parameters":[{"$ref":"#/components/parameters/UsuarioEstadoParam"},{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PerPageParam"}],"responses":{"200":{"description":"Lista de usuarios","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Usuario"}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}}}}}}}},"400":{"description":"Sin permiso para listar usuarios","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"AUTH-1003":{"$ref":"#/components/examples/AUTH-1003"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/usuarios/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"get":{"tags":["Usuarios"],"summary":"Obtener usuario","operationId":"obtenerUsuario","responses":{"200":{"description":"Usuario encontrado","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"$ref":"#/components/schemas/Usuario"}}}}}},"400":{"description":"Usuario no existe","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"USR-1003":{"$ref":"#/components/examples/USR-1003"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"put":{"tags":["Usuarios"],"summary":"Actualizar usuario","operationId":"actualizarUsuario","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UsuarioInput"}}}},"responses":{"200":{"description":"Usuario actualizado","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"id_usuario":{"type":"integer"}}}}},"examples":{"USR-0002":{"$ref":"#/components/examples/USR-0002"}}}}},"400":{"description":"Datos inválidos o usuario no existe","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"USR-1001":{"$ref":"#/components/examples/USR-1001"},"USR-1003":{"$ref":"#/components/examples/USR-1003"},"USR-1004":{"$ref":"#/components/examples/USR-1004"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"delete":{"tags":["Usuarios"],"summary":"Desactivar usuario","operationId":"desactivarUsuario","responses":{"200":{"description":"Usuario desactivado","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","nullable":true,"example":null}}},"examples":{"USR-0003":{"$ref":"#/components/examples/USR-0003"}}}}},"400":{"description":"Usuario no existe","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"USR-1003":{"$ref":"#/components/examples/USR-1003"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/internos":{"post":{"tags":["Internos"],"summary":"Registrar interno","operationId":"registrarInterno","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternoInput"}}}},"responses":{"200":{"description":"Interno creado","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"id_interno":{"type":"integer"}}}}},"examples":{"INT-0001":{"$ref":"#/components/examples/INT-0001"}}}}},"400":{"description":"Datos incompletos","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"INT-1002":{"$ref":"#/components/examples/INT-1002"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"get":{"tags":["Internos"],"summary":"Listar internos","operationId":"listarInternos","parameters":[{"$ref":"#/components/parameters/InternoEstadoParam"},{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PerPageParam"}],"responses":{"200":{"description":"Lista de internos","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Interno"}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/internos/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"get":{"tags":["Internos"],"summary":"Obtener interno","operationId":"obtenerInterno","responses":{"200":{"description":"Interno encontrado","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"$ref":"#/components/schemas/Interno"}}}}}},"400":{"description":"Interno no existe","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"INT-1001":{"$ref":"#/components/examples/INT-1001"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"put":{"tags":["Internos"],"summary":"Actualizar interno","operationId":"actualizarInterno","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InternoInput"}}}},"responses":{"200":{"description":"Interno actualizado","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"id_interno":{"type":"integer"}}}}}}}},"400":{"description":"Datos inválidos o interno no existe","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"INT-1001":{"$ref":"#/components/examples/INT-1001"},"INT-1002":{"$ref":"#/components/examples/INT-1002"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"delete":{"tags":["Internos"],"summary":"Dar de baja al interno","operationId":"darDeBajaAlInterno","responses":{"200":{"description":"Interno dado de baja","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","nullable":true,"example":null}}},"examples":{"INT-0002":{"$ref":"#/components/examples/INT-0002"}}}}},"400":{"description":"Interno no existe","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"INT-1001":{"$ref":"#/components/examples/INT-1001"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/internos/{id}/historial-clinico":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"post":{"tags":["Internos"],"summary":"Crear historial clínico del interno","operationId":"crearHistorialClinicoDelInterno","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HistorialClinicoInput"}}}},"responses":{"200":{"description":"Historial guardado","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"id_historial":{"type":"integer"}}}}},"examples":{"INT-0003":{"$ref":"#/components/examples/INT-0003"}}}}},"400":{"description":"Interno no existe o historial ya creado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"INT-1001":{"$ref":"#/components/examples/INT-1001"},"INT-1003":{"$ref":"#/components/examples/INT-1003"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"get":{"tags":["Internos"],"summary":"Obtener historial clínico del interno","operationId":"obtenerHistorialClinicoDelInterno","responses":{"200":{"description":"Historial encontrado","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"$ref":"#/components/schemas/HistorialClinico"}}}}}},"400":{"description":"Interno no existe","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"INT-1001":{"$ref":"#/components/examples/INT-1001"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"put":{"tags":["Internos"],"summary":"\uD83C\uDD95 Actualizar historial clínico del interno","operationId":"actualizarHistorialClinicoDelInterno","description":"Reutiliza INT-0003 (el diccionario original documenta este código como INSERT/UPDATE).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HistorialClinicoInput"}}}},"responses":{"200":{"description":"Historial actualizado","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"id_historial":{"type":"integer"}}}}},"examples":{"INT-0003":{"$ref":"#/components/examples/INT-0003"}}}}},"400":{"description":"Interno o historial no existen","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"INT-1001":{"$ref":"#/components/examples/INT-1001"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/internos/{id}/familiares":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"post":{"tags":["Internos"],"summary":"Vincular familiar al interno","operationId":"vincularFamiliarAlInterno","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FamiliarVinculoInput"}}}},"responses":{"200":{"description":"Familiar vinculado","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","nullable":true,"example":null}}},"examples":{"INT-0004":{"$ref":"#/components/examples/INT-0004"}}}}},"400":{"description":"Interno no existe o vínculo duplicado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"INT-1001":{"$ref":"#/components/examples/INT-1001"},"INT-1004":{"$ref":"#/components/examples/INT-1004"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"get":{"tags":["Internos"],"summary":"\uD83C\uDD95 Listar familiares vinculados al interno","operationId":"listarFamiliaresVinculadosAlInterno","parameters":[{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PerPageParam"}],"responses":{"200":{"description":"Lista de familiares","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/FamiliarVinculo"}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}}}}}}}},"400":{"description":"Interno no existe","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"INT-1001":{"$ref":"#/components/examples/INT-1001"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/internos/{id}/familiares/{usuarioId}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}},{"name":"usuarioId","in":"path","required":true,"schema":{"type":"integer"}}],"delete":{"tags":["Internos"],"summary":"\uD83C\uDD95 Desvincular familiar del interno","operationId":"desvincularFamiliarDelInterno","responses":{"200":{"description":"Familiar desvinculado","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","nullable":true,"example":null}}},"examples":{"INT-0005":{"$ref":"#/components/examples/INT-0005"}}}}},"400":{"description":"Interno no existe o vínculo no encontrado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"INT-1001":{"$ref":"#/components/examples/INT-1001"},"INT-1005":{"$ref":"#/components/examples/INT-1005"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/medicamentos":{"post":{"tags":["Medicamentos"],"summary":"Registrar medicamento en el catálogo","operationId":"registrarMedicamentoEnElCatalogo","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MedicamentoInput"}}}},"responses":{"200":{"description":"Medicamento registrado","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"id_medicamento":{"type":"integer"}}}}},"examples":{"MED-0001":{"$ref":"#/components/examples/MED-0001"}}}}},"400":{"description":"Datos inválidos","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"MED-1005":{"$ref":"#/components/examples/MED-1005"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"get":{"tags":["Medicamentos"],"summary":"Listar catálogo de medicamentos","operationId":"listarCatalogoDeMedicamentos","parameters":[{"$ref":"#/components/parameters/MedicamentoNombreParam"},{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PerPageParam"}],"responses":{"200":{"description":"Lista de medicamentos","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Medicamento"}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/medicamentos/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"get":{"tags":["Medicamentos"],"summary":"\uD83C\uDD95 Obtener medicamento del catálogo","operationId":"obtenerMedicamentoDelCatalogo","responses":{"200":{"description":"Medicamento encontrado","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"$ref":"#/components/schemas/Medicamento"}}}}}},"400":{"description":"Medicamento no existe","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"MED-1001":{"$ref":"#/components/examples/MED-1001"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"put":{"tags":["Medicamentos"],"summary":"\uD83C\uDD95 Actualizar medicamento del catálogo","operationId":"actualizarMedicamentoDelCatalogo","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MedicamentoInput"}}}},"responses":{"200":{"description":"Medicamento actualizado","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"id_medicamento":{"type":"integer"}}}}},"examples":{"MED-0005":{"$ref":"#/components/examples/MED-0005"}}}}},"400":{"description":"Medicamento no existe o datos inválidos","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"MED-1001":{"$ref":"#/components/examples/MED-1001"},"MED-1005":{"$ref":"#/components/examples/MED-1005"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/internos/{id}/medicamentos":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"post":{"tags":["Medicamentos"],"summary":"Prescribir medicamento al interno","operationId":"prescribirMedicamentoAlInterno","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PrescripcionInput"}}}},"responses":{"200":{"description":"Medicamento prescrito","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"id_interno_medicamento":{"type":"integer"}}}}},"examples":{"MED-0002":{"$ref":"#/components/examples/MED-0002"}}}}},"400":{"description":"Medicamento no existe, interno no existe o dosis inválida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"MED-1001":{"$ref":"#/components/examples/MED-1001"},"MED-1003":{"$ref":"#/components/examples/MED-1003"},"INT-1001":{"$ref":"#/components/examples/INT-1001"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"get":{"tags":["Medicamentos"],"summary":"Listar prescripciones del interno","operationId":"listarPrescripcionesDelInterno","parameters":[{"$ref":"#/components/parameters/PrescripcionEstadoParam"},{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PerPageParam"}],"responses":{"200":{"description":"Lista de prescripciones","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Prescripcion"}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}}}}}}}},"400":{"description":"Interno no existe","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"INT-1001":{"$ref":"#/components/examples/INT-1001"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/internos/{id}/medicamentos/{prescripcionId}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}},{"name":"prescripcionId","in":"path","required":true,"schema":{"type":"integer"}}],"put":{"tags":["Medicamentos"],"summary":"\uD83C\uDD95 Actualizar dosis o frecuencia de una prescripción activa","operationId":"actualizarDosisOFrecuenciaDeUnaPrescripcionActiva","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PrescripcionUpdateInput"}}}},"responses":{"200":{"description":"Prescripción actualizada","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"id_interno_medicamento":{"type":"integer"}}}}},"examples":{"MED-0006":{"$ref":"#/components/examples/MED-0006"}}}}},"400":{"description":"Prescripción no existe, ya cancelada o dosis inválida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"MED-1002":{"$ref":"#/components/examples/MED-1002"},"MED-1003":{"$ref":"#/components/examples/MED-1003"},"MED-1004":{"$ref":"#/components/examples/MED-1004"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"delete":{"tags":["Medicamentos"],"summary":"Cancelar prescripción","operationId":"cancelarPrescripcion","responses":{"200":{"description":"Prescripción cancelada","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","nullable":true,"example":null}}},"examples":{"MED-0004":{"$ref":"#/components/examples/MED-0004"}}}}},"400":{"description":"Prescripción no existe o ya cancelada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"MED-1002":{"$ref":"#/components/examples/MED-1002"},"MED-1004":{"$ref":"#/components/examples/MED-1004"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/internos/{id}/medicamentos/{prescripcionId}/administraciones":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}},{"name":"prescripcionId","in":"path","required":true,"schema":{"type":"integer"}}],"post":{"tags":["Medicamentos"],"summary":"Registrar dosis administrada","operationId":"registrarDosisAdministrada","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdministracionInput"}}}},"responses":{"200":{"description":"Dosis registrada","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"id_administracion":{"type":"integer"}}}}},"examples":{"MED-0003":{"$ref":"#/components/examples/MED-0003"}}}}},"400":{"description":"Prescripción no existe o ya finalizada","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"MED-1002":{"$ref":"#/components/examples/MED-1002"},"MED-1004":{"$ref":"#/components/examples/MED-1004"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"get":{"tags":["Medicamentos"],"summary":"\uD83C\uDD95 Listar dosis administradas de una prescripción","operationId":"listarDosisAdministradasDeUnaPrescripcion","parameters":[{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PerPageParam"}],"responses":{"200":{"description":"Historial de administraciones","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/AdministracionMedicamento"}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}}}}}}}},"400":{"description":"Prescripción no existe","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"MED-1002":{"$ref":"#/components/examples/MED-1002"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/internos/{id}/mediciones":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"post":{"tags":["Mediciones"],"summary":"Registrar signos vitales","operationId":"registrarSignosVitales","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MedicionInput"}}}},"responses":{"200":{"description":"Signos vitales guardados","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"id_medicion":{"type":"integer"}}}}},"examples":{"MDC-0001":{"$ref":"#/components/examples/MDC-0001"}}}}},"400":{"description":"Ningún signo vital enviado o interno no existe","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"MDC-1001":{"$ref":"#/components/examples/MDC-1001"},"INT-1001":{"$ref":"#/components/examples/INT-1001"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"get":{"tags":["Mediciones"],"summary":"Listar mediciones del interno","operationId":"listarMedicionesDelInterno","parameters":[{"$ref":"#/components/parameters/MedicionDesdeParam"},{"$ref":"#/components/parameters/MedicionHastaParam"},{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PerPageParam"}],"responses":{"200":{"description":"Lista de mediciones","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Medicion"}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}}}}}}}},"400":{"description":"Interno no existe","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"INT-1001":{"$ref":"#/components/examples/INT-1001"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/mediciones/{medicionId}":{"parameters":[{"name":"medicionId","in":"path","required":true,"schema":{"type":"integer"}}],"get":{"tags":["Mediciones"],"summary":"Obtener medición","operationId":"obtenerMedicion","responses":{"200":{"description":"Medición encontrada","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"$ref":"#/components/schemas/Medicion"}}}}}},"400":{"description":"Medición no existe","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"MDC-1002":{"$ref":"#/components/examples/MDC-1002"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/notificaciones":{"get":{"tags":["Notificaciones"],"summary":"\uD83C\uDD95 Listar notificaciones del usuario autenticado","operationId":"listarNotificacionesDelUsuarioAutenticado","parameters":[{"$ref":"#/components/parameters/NotificacionEstadoParam"},{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PerPageParam"}],"responses":{"200":{"description":"Lista de notificaciones","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Notificacion"}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/notificaciones/{id}/leida":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"patch":{"tags":["Notificaciones"],"summary":"Marcar notificación como leída","operationId":"marcarNotificacionComoLeida","responses":{"200":{"description":"Notificación marcada como leída","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","nullable":true,"example":null}}},"examples":{"NTF-0001":{"$ref":"#/components/examples/NTF-0001"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/alertas":{"post":{"tags":["Alertas"],"summary":"Registrar alerta","operationId":"registrarAlerta","description":"\uD83C\uDD95 Acepta tanto personal autenticado (`bearerAuth`) como dispositivos IoT que reportan alertas automáticas (`deviceApiKey`), p. ej. un sensor de caídas ESP32 con `origen: sensor_esp32`.\n","security":[{"bearerAuth":[]},{"deviceApiKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertaInput"}}}},"responses":{"200":{"description":"Alerta registrada","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"id_alerta":{"type":"integer"}}}}},"examples":{"ALT-0001":{"$ref":"#/components/examples/ALT-0001"}}}}},"400":{"description":"Datos de alerta incompletos","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"ALT-1002":{"$ref":"#/components/examples/ALT-1002"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"get":{"tags":["Alertas"],"summary":"Listar alertas","operationId":"listarAlertas","parameters":[{"$ref":"#/components/parameters/AlertaTipoParam"},{"$ref":"#/components/parameters/AlertaEstadoParam"},{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PerPageParam"}],"responses":{"200":{"description":"Lista de alertas","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Alerta"}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/alertas/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"get":{"tags":["Alertas"],"summary":"Obtener alerta","operationId":"obtenerAlerta","responses":{"200":{"description":"Alerta encontrada","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"$ref":"#/components/schemas/Alerta"}}}}}},"400":{"description":"Alerta no existe","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"ALT-1001":{"$ref":"#/components/examples/ALT-1001"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"patch":{"tags":["Alertas"],"summary":"\uD83C\uDD95 Atender o descartar alerta","operationId":"atenderODescartarAlerta","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertaEstadoInput"}}}},"responses":{"200":{"description":"Alerta actualizada","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"id_alerta":{"type":"integer"}}}}},"examples":{"ALT-0002":{"$ref":"#/components/examples/ALT-0002"}}}}},"400":{"description":"Alerta no existe","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"ALT-1001":{"$ref":"#/components/examples/ALT-1001"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/incidencias":{"post":{"tags":["Incidencias"],"summary":"Registrar incidencia","operationId":"registrarIncidencia","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IncidenciaInput"}}}},"responses":{"200":{"description":"Incidencia registrada","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"id_incidencia":{"type":"integer"}}}}},"examples":{"INC-0001":{"$ref":"#/components/examples/INC-0001"}}}}},"400":{"description":"Prioridad no válida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"INC-1002":{"$ref":"#/components/examples/INC-1002"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"get":{"tags":["Incidencias"],"summary":"Listar incidencias","operationId":"listarIncidencias","parameters":[{"$ref":"#/components/parameters/IncidenciaEstadoParam"},{"$ref":"#/components/parameters/IncidenciaPrioridadParam"},{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PerPageParam"}],"responses":{"200":{"description":"Lista de incidencias","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Incidencia"}},"meta":{"$ref":"#/components/schemas/PaginatedMeta"}}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}},"/incidencias/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"integer"}}],"get":{"tags":["Incidencias"],"summary":"Obtener incidencia","operationId":"obtenerIncidencia","responses":{"200":{"description":"Incidencia encontrada","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"$ref":"#/components/schemas/Incidencia"}}}}}},"400":{"description":"Incidencia no existe","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"INC-1001":{"$ref":"#/components/examples/INC-1001"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}},"put":{"tags":["Incidencias"],"summary":"Actualizar incidencia","operationId":"actualizarIncidencia","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IncidenciaInput"}}}},"responses":{"200":{"description":"Incidencia actualizada","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"$ref":"#/components/schemas/Result"},"data":{"type":"object","properties":{"id_incidencia":{"type":"integer"}}}}},"examples":{"INC-0002":{"$ref":"#/components/examples/INC-0002"}}}}},"400":{"description":"Incidencia no existe, cerrada o prioridad inválida","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"INC-1001":{"$ref":"#/components/examples/INC-1001"},"INC-1002":{"$ref":"#/components/examples/INC-1002"},"INC-1003":{"$ref":"#/components/examples/INC-1003"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/ServerError"}}}}}}