File size: 1,396 Bytes
5f12c93 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | """
M1 HCE — contraindicaciones y movimientos de pacientes.
"""
from datetime import datetime, timezone
from app.config import settings
from app.integrations._base import _get, _post
def get_contraindicaciones(paciente_id: int) -> list[str]:
"""
Retorna lista de contraindicaciones del paciente.
Consulta informativa — no bloquea el flujo si el servicio no está disponible.
"""
if settings.mock_external_services:
return []
data = _get(f"{settings.m1_hce_url}/api/v1/hce/pacientes/{paciente_id}/contraindicaciones")
if not data:
return []
return [d.get("descripcion", "") for d in data.get("detalle", [])]
def notify_movimiento(
tipo_movimiento: str,
paciente_id: int,
cama_id: int | None = None,
cama_origen_id: int | None = None,
resultado: str | None = None,
motivo: str | None = None,
) -> bool:
"""Notifica a M1 (HCE) un movimiento de paciente. Retorna True si OK."""
if settings.mock_external_services:
return True
payload = {
"tipo_movimiento": tipo_movimiento,
"paciente_id": paciente_id,
"cama_id": cama_id,
"cama_origen_id": cama_origen_id,
"resultado": resultado,
"motivo": motivo,
"timestamp": datetime.now(timezone.utc).isoformat(),
}
return _post(f"{settings.m1_hce_url}/api/v1/hce/movimientos", payload) is not None
|