# Native HMS telemedicine (pilot)

The remote consultation interface uses browser WebRTC with Laravel-authenticated physician signaling and an expiring patient invitation. No Zoom/Meet integration is required.

## Installation

1. Run `php artisan migrate`.
2. Serve HMS over HTTPS. Browsers require a secure context for camera and microphone access.
3. Set up a TURN relay for production (e.g., coturn). In `.env` set `TELEMEDICINE_STUN_URL`, `TELEMEDICINE_TURN_URL`, `TELEMEDICINE_TURN_USERNAME`, and `TELEMEDICINE_TURN_PASSWORD`. Protect credentials and prefer short-lived TURN credentials for production.
4. Open **Appointments**, book a telemedicine appointment, then open **Telemedicine**. The assigned physician generates an invitation and sends it privately to the patient.
5. The patient opens the link, explicitly consents, and enables camera/microphone. The physician verifies identity, admits the patient, and enables their camera.
6. Existing clinical notes, triage, prescriptions, laboratory requests and billing remain in the HMS screens.

## Security and limitations

- Invitation tokens are random, stored only as SHA-256 hashes, expire after 24 hours, and rotate on regeneration. An invitation is a bearer credential: possession grants patient access. Deliver privately; do not paste into public chats.
- Calls are not recorded. WebRTC encrypts media in transit.
- Signaling currently uses authenticated short polling and database persistence. **This is a prototype**, not production-grade high-volume signaling. Messages are not automatically purged. Schedule deletion of stale signals and implement session-specific TTL.
- One patient and one physician per session; no group calls, screen sharing, reconnection negotiation, network quality dashboard, or patient identity verification beyond invitation possession.
- TURN server availability, secure deployment, privacy impact assessment, clinical consent requirements, and a complete threat model must be verified before use with real patient information.
- This feature has not been runtime-tested in the deployment environment.
