# Ladill Care

Healthcare management for clinics and hospitals at **care.ladill.com** — patients,
appointments, queue, consultations, vitals, lab, prescriptions, pharmacy inventory,
encounter billing, and operational reports.

Authenticates via **Sign in with Ladill** (OIDC against `auth.ladill.com`). Every
clinical record is scoped to a platform account (`owner_ref`) and organization.

## Features

- **Patients** — registration, medical history, documents, visit timeline
- **Appointments & queue** — booking, walk-in, check-in, department queue
- **Consultations** — vitals, diagnoses, investigations, prescriptions
- **Laboratory** — test catalog, sample collection, results, approval
- **Pharmacy** — dispensing queue, drug inventory, batch stock tracking
- **Billing** — visit invoices, line items, payments, print view
- **Reports** — patients, appointments, lab, finance, clinical (CSV export)
- **Admin** — branches, departments, practitioners, members, audit log

## Platform integration

| Integration | Purpose |
|-------------|---------|
| OIDC SSO | User authentication (`LADILL_SSO_*`) |
| Billing API | Wallet top-up / purchases (`BILLING_API_KEY_CARE`) |
| Identity API | Platform user lookups (`IDENTITY_API_KEY_CARE`) |
| Service events | Inbound webhooks for `user.deleted`, `user.suspended`, `organization.updated` |

Registry entry lives in the monolith `config/ladill_apps.php` (`care` slug).

## Local development

```bash
composer install
cp .env.example .env && php artisan key:generate
touch database/database.sqlite   # sqlite is fine for local
php artisan migrate
npm install && npm run build     # or `npm run dev`
php artisan serve
php artisan test
```

For SSO locally, point `LADILL_SSO_*` at a Passport client on your Ladill platform
dev instance, or bypass `EnsurePlatformSession` in tests (see `CareWebTest`).

## Deployment

See [DEPLOY.md](DEPLOY.md) for production cutover (`/var/www/ladill-care`, Gitea CI,
nginx vhost, platform onboarding).

## API

REST API under `/api/v1` (Sanctum + organization setup middleware). Health check:
`GET /api/health`.
