Download app/integrations/hce.py from Modulo-6/api: direct link, hf CLI and curl.
- Browser
- Download file 1.4 kB
-
https://huggingface.co/spaces/Modulo-6/api/resolve/31c8dd67e47a516206b4122c4da00a634486a247/app/integrations/hce.py
- Command line
-
hf download hf://spaces/Modulo-6/api@31c8dd67e47a516206b4122c4da00a634486a247/app/integrations/hce.py
-
curl -L -o hce.py https://huggingface.co/spaces/Modulo-6/api/resolve/31c8dd67e47a516206b4122c4da00a634486a247/app/integrations/hce.py
1.4 kB
| """ | |
| 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 | |