Run the KSA HMS as the full site or as an HMS-only edition on a hospital's own servers or any cloud, and choose its AI, storage, video, realtime, mail and SMS providers with environment variables.

Installation and Configuration

One codebase runs every install. Everything below is chosen in the server's .env file, never by changing code, so a hospital's IT team can run the HMS on its own servers (on-premise) or on any cloud provider. Leave a setting out and you get today's hosted behaviour.

A complete commented template is in .env.hms.example at the root of the application.

After changing .env, run php artisan config:cache and php artisan route:cache again, restart the application (Octane) and the queue workers (Horizon), then check the install:

php artisan hms:about     # edition, tenancy mode and the drivers in use (no secrets)
php artisan hms:doctor    # PASS / FAIL per item; add --with-ai for one tiny AI call

hms:doctor checks the database connections, Redis, the queue, a write/read/delete on the upload and report storage (a read-only check for Firebase), the AI and transcription settings, video, mail and SMS. It exits with code 1 when anything fails, so it can run in deployment scripts and monitoring.

Editions

Setting Values Default
APP_EDITION full (KSA HMS and the Pakistan site) or hms (KSA HMS only) full
SA_PUBLIC_SITE true / false: serve the KSA marketing pages (landing /sa and /ar, about, contact, hub and the guided demo) true for full, false for hms

In the hms edition only the hospital system is registered:

The tenancy mode (one hospital or several on one install) is shown by hms:about and is configured separately.

AI (chat)

Used by AIDO, AI pre-screening, SOAP note drafts, lab summaries and explanations, the risk alert note and the AI status health check. Every call is logged in the AI call log without its text.

Setting Meaning
SA_AI_DRIVER azure (default), openai_compatible or none
AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_KEY, AZURE_OPENAI_API_VERSION, AZURE_OPENAI_DEPLOYMENT_NAME Azure OpenAI resource and chat deployment (azure driver)
SA_AI_BASE_URL OpenAI-compatible API base, ending in /v1 (for example http://ollama:11434/v1, http://vllm:8000/v1, http://lmstudio:1234/v1, https://api.openai.com/v1)
SA_AI_API_KEY Bearer key, blank for local servers without one
SA_AI_CHAT_MODEL Default model name, for example llama3.1:8b or qwen2.5:14b
SA_AI_TIMEOUT Seconds per request (default 60)
SA_AI_JSON_MODE true sends response_format: json_object; set false for servers without JSON mode
SA_AI_MAX_TOKENS_FIELD max_tokens (default) or max_completion_tokens
SA_AI_MODEL_AIDO, SA_AI_MODEL_PRESCREENING, SA_AI_MODEL_SOAP, SA_AI_MODEL_LAB, SA_AI_MODEL_RISK, SA_AI_MODEL_HEALTH_CHECK Optional model (or Azure deployment) per feature

With none, AI is turned off for the hospital: every feature uses its rule-based fallback (AIDO's guided booking, the form pre-screening, manual SOAP notes and lab summaries, rule-only risk alerts) and screens show AI is turned off for this hospital. Continue manually. No data leaves the server.

Transcription (speech to text)

Used by consultation transcription and dictation.

Setting Meaning
SA_STT_DRIVER azure (default), openai_compatible or none
AZURE_OPENAI_WHISPER_ENDPOINT, AZURE_OPENAI_WHISPER_API_KEY, AZURE_OPENAI_WHISPER_DEPLOYMENT Azure speech deployment (azure driver)
SA_STT_BASE_URL, SA_STT_API_KEY Whisper-style endpoint (POST {base}/audio/transcriptions); default to the AI values
SA_STT_MODEL Model name (default whisper-1; for example large-v3 on faster-whisper servers)
SA_STT_TIMEOUT Seconds per request (default 120)

With none, transcription and dictation are off and doctors type their notes.

File storage

Setting Meaning
SA_STORAGE_DISK Where patient uploads and visit attachments go: firebase (default) or any disk in config/filesystems.php: local (private storage/app on the application server) or s3
SA_REPORTS_DISK Lab and imaging reports and remote follow-up audio (default local; s3 to keep them in the bucket)
SA_STORAGE_URL_TTL_MINUTES Lifetime of download links (default 30)
SA_FIREBASE_SIGNED_URLS Firebase only: signed, short-lived links (default true, as the bucket is private); false only for a public bucket
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGION, AWS_BUCKET S3 credentials and bucket
AWS_ENDPOINT, AWS_USE_PATH_STYLE_ENDPOINT Any S3-compatible store: MinIO, Ceph, Wasabi, OCI Object Storage, a Saudi cloud region. MinIO and Ceph usually need AWS_USE_PATH_STYLE_ENDPOINT=true

Files are never public. With local, the application hands out a short-lived signed link (/sa/files/download?...&signature=...) that works only for that file and only until it expires; with s3, the store's own temporary URL is used. Keep the bucket private.

The S3 disk needs the league/flysystem-aws-s3-v3 package (composer require league/flysystem-aws-s3-v3); hms:doctor says so when it is missing. Switching storage does not move existing files: copy them across first, keeping their paths.

Video visits

Setting Meaning
SA_VIDEO_DRIVER livekit (default) or none
LIVEKIT_URL, LIVEKIT_API_KEY, LIVEKIT_API_SECRET LiveKit Cloud or a self-hosted LiveKit server (wss://livekit.hospital.example)
SA_VIDEO_ENABLED false also turns video visits off

With none, booking (manual and AIDO) does not offer Video, and the API refuses visit_mode=video with Video visits are turned off for this hospital. Choose In clinic.

Realtime

The KSA screens refresh by polling the API (queue boards, slot availability, video presence), so the HMS needs no websocket server. BROADCAST_DRIVER can stay log or null. When the full edition broadcasts for the Pakistan site, it uses Laravel broadcasting: Pusher cloud, or a self-hosted Soketi with PUSHER_HOST, PUSHER_PORT and PUSHER_SCHEME.

Mail

Mail uses Laravel mailers: set MAIL_MAILER=smtp with MAIL_HOST, MAIL_PORT, MAIL_USERNAME, MAIL_PASSWORD, MAIL_ENCRYPTION and MAIL_FROM_ADDRESS for the hospital's own mail server or any provider. MAIL_MAILER=log writes messages to the log instead.

SMS

Used for the registration verification code and the file number issued message. Every message is kept in the notification log with its delivery status.

Setting Meaning
SA_SMS_DRIVER log (default: nothing is sent, the message is kept as stubbed), none (no SMS) or http
SA_SMS_HTTP_URL Gateway address
SA_SMS_HTTP_METHOD POST (default), PUT, PATCH or GET
SA_SMS_HTTP_AUTH_HEADER, SA_SMS_HTTP_AUTH_VALUE One header, for example Authorization and Bearer <token>
SA_SMS_HTTP_BODY JSON body where {to}, {message} and {sender} are filled in
SA_SMS_HTTP_FORMAT json (default) or form
SA_SMS_SENDER Sender name registered with the provider
SA_SMS_HTTP_TIMEOUT Seconds (default 15)

A 2xx answer counts as sent; anything else is logged as failed with the HTTP status. Any Saudi provider with an HTTP API (Unifonic, Taqnyat, Msegat and others) can be configured this way; take the URL, header and body fields from the provider's API guide. Example:

SA_SMS_DRIVER=http
SA_SMS_HTTP_URL=https://sms-provider.example.sa/v1/messages
SA_SMS_HTTP_AUTH_HEADER=Authorization
SA_SMS_HTTP_AUTH_VALUE="Bearer your-token"
SA_SMS_HTTP_BODY='{"recipient":"{to}","body":"{message}","sender":"{sender}"}'
SA_SMS_SENDER=Hospital

PDPL vendor registry

The PDPL Governance page lists the providers that really receive data, and the KSA-only endpoints setting blocks any that process data outside Saudi Arabia. The drivers keep it truthful:

Driver Vendor key Inside KSA when
SA_AI_DRIVER=azure azure_openai never (East US 2)
SA_AI_DRIVER=openai_compatible SA_AI_VENDOR_KEY (default openai_compatible) SA_AI_INSIDE_KSA=true
SA_AI_DRIVER=none and SA_STT_DRIVER=none none: AI is off
SA_STORAGE_DISK=firebase firebase_storage never (US multi-region)
SA_STORAGE_DISK=local app_hosting (the application server) SA_HOSTING_INSIDE_KSA=true
SA_STORAGE_DISK=s3 SA_STORAGE_VENDOR_KEY (default object_storage) SA_STORAGE_INSIDE_KSA=true
SA_SMS_DRIVER=http SA_SMS_VENDOR_KEY (default sms_gateway) SA_SMS_INSIDE_KSA (default true)

Name and location come from SA_AI_VENDOR_NAME / SA_AI_VENDOR_LOCATION, SA_STORAGE_VENDOR_NAME / SA_STORAGE_LOCATION, SA_SMS_VENDOR_NAME / SA_SMS_VENDOR_LOCATION and SA_HOSTING_LOCATION. Set inside KSA only when the data is really processed in Saudi Arabia. A hospital whose registry was created before a driver change gets the new provider added automatically; the org admin can still edit or disable it on the governance page. When the chat driver is on, the AI gate follows the chat provider (transcription is covered by the same entry).

Example setups

Fully on-premise, AI on the hospital's own servers

APP_EDITION=hms
SA_HOSTING_LOCATION="Hospital data centre, Riyadh"
SA_HOSTING_INSIDE_KSA=true

SA_AI_DRIVER=openai_compatible
SA_AI_BASE_URL=http://ollama.hospital.local:11434/v1
SA_AI_CHAT_MODEL=qwen2.5:14b
SA_AI_JSON_MODE=true
SA_AI_VENDOR_NAME="On-premise AI server"
SA_AI_VENDOR_LOCATION="Hospital data centre, Riyadh"
SA_AI_INSIDE_KSA=true

SA_STT_DRIVER=openai_compatible
SA_STT_BASE_URL=http://whisper.hospital.local:8000/v1
SA_STT_MODEL=large-v3

SA_STORAGE_DISK=local
SA_REPORTS_DISK=local

SA_VIDEO_DRIVER=livekit
LIVEKIT_URL=wss://video.hospital.local
LIVEKIT_API_KEY=...
LIVEKIT_API_SECRET=...

BROADCAST_DRIVER=log
MAIL_MAILER=smtp
MAIL_HOST=mail.hospital.local
SA_SMS_DRIVER=http

No AI at all? Use SA_AI_DRIVER=none and SA_STT_DRIVER=none. No video server? Use SA_VIDEO_DRIVER=none.

On-premise with the hospital's own Azure

APP_EDITION=hms
SA_AI_DRIVER=azure
SA_STT_DRIVER=azure
AZURE_OPENAI_ENDPOINT=https://hospital-openai.openai.azure.com/
AZURE_OPENAI_API_KEY=...
AZURE_OPENAI_DEPLOYMENT_NAME=gpt-4o-mini
AZURE_OPENAI_WHISPER_DEPLOYMENT=whisper

SA_STORAGE_DISK=s3
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=hms-files
AWS_ENDPOINT=https://minio.hospital.local
AWS_USE_PATH_STYLE_ENDPOINT=true
SA_STORAGE_INSIDE_KSA=true

Correct the Azure vendor's location on the governance page if the hospital's Azure region differs.

Hosted SaaS (today's production)

Leave every SA_*_DRIVER unset, or set them to the defaults: APP_EDITION=full, Azure OpenAI, Firebase storage, LiveKit Cloud, Pusher and the current mailers, with SMS kept in the log.