# Vet Modules Roadmap — Gap Closure vs ezyVet / SmartFlow

> **Owner:** Hossam
> **Last updated:** 2026-05-28
> **Status:** Living document — tick boxes as tasks complete.

This roadmap converts the VetClinic / VetAdmission gap-analysis vs ezyVet (and the SmartFlow whiteboard) into a phased, task-level execution plan. It has been **rebaselined against an audit of the ERP** so that work which can be wired into existing core/CRM/Connector capabilities is not rebuilt.

---

## ERP capabilities we already have (and will reuse)

| # | Capability | Where it lives | Implication for vet |
|---|---|---|---|
| 1 | Quotations (`transactions.sub_status='quotation'`, PDF, copy, send) | core `SellController` | Vet "estimates" = quotation wrapper |
| 2 | Recurring invoices (`is_recurring`, `recur_interval*`, `pos:generateSubscriptionInvoices` cron) | core | Wellness plans ride on this |
| 3 | SMS + WhatsApp + Email notifications, per-business `sms_settings`, auto-send flags | core `NotificationUtil` | No SMS gateway to build; add vet `template_for` keys |
| 4 | Notification templates with subject / body / SMS body / WhatsApp text | core `NotificationTemplate` | Reuse for vet reminders |
| 5 | REST API + OAuth2 + WooCommerce integrations | `Modules/Connector` | Lab adapters can be exposed here for symmetry |
| 6 | Internal messaging + To-Do (comments, docs) | `Modules/Essentials` | Reference pattern only — owner messaging is going via the new dedicated portal (see deferred items) |
| 7 | HR / shifts / schedules / leave / payroll | `Modules/Essentials` | Doctors can later be linked to HR users |
| 8 | Batch + lot + expiry (`purchase_lines.lot_number / mfg_date / exp_date`, `enable_product_expiry`, `stop_selling_n_days_before_expiry`) | core | Pharmacy dispense FEFO uses this |
| 9 | Purchase requisitions w/ supplier sharing + approval | `Modules/PurchaseRequisition` | Pharmacy reorder uses this |
| 10 | Inter-location transfers | `Modules/TpsTransfer` + core `StockTransferController` | Pharmacy redistribution |
| 11 | Generic audit log | `Modules/ActivityLog` | Vet already integrates via `LogsVcActivity` trait |

---

## Deferred items (handled by the planned dedicated client portal)

The customer portal is being built as a **separate vet-specific project** with its own data model and UI. These items therefore drop out of the vet-module roadmap and will be picked up there:

- **VC-P3.3 Online booking portal** — deferred to dedicated vet client portal project
- **VC-P3.2 Owner inbox / message thread** — deferred to dedicated vet client portal project
- **VC-P6.1 Referral portal** — deferred to a separate referral portal project (CRM contact portal is not a fit; referrers need vet-specific views)

Within the vet modules we still need to **emit** the data those portals will consume — notification templates with appropriate tags and PDF links remain in scope.

---

## Phase 1 — Finish in-flight features

Goal: close out the half-built consent, controlled-drug, and vaccine-certificate features.
Effort: M (3-5 days).

### 1.1 Consent module hardening

- [ ] **VC-P1-T1** — Add HTML5-canvas signature pad to consent print view (`S`)
  - New view: `Modules/VetClinic/Resources/views/consents/sign.blade.php`
  - Modify `VcConsentController`: add `sign(id)`, `storeSignature(id)`
  - Routes: `GET /consents/{id}/sign`, `POST /consents/{id}/sign`
- [ ] **VC-P1-T2** — Migration: `vc_consent_signatures` table with SHA-256 hash, IP, UA, signed_by (`S`)
- [ ] **VC-P1-T3** — Lock signed consents from edit/delete; archive only (`S`)
- [ ] **VC-P1-T4** — Public signature verification page (`S`)

### 1.2 Controlled register Phase 3

- [ ] **VC-P1-T5** — Add `is_controlled` + `controlled_schedule` columns to `vc_medicines` (`S`)
- [ ] **VC-P1-T6** — Auto-create OUT log on prescription finalise (`M`)
- [ ] **VC-P1-T7** — Statutory per-medicine register print (`M`)
- [ ] **VC-P1-T8** — Reconciliation / variance flag with `vc_controlled_reconciliations` (`M`)

### 1.3 Vaccination certificate upgrade

- [ ] **VC-P1-T9** — Replace `printVaccinations` output with WHO-style certificate (`S`)
- [ ] **VC-P1-T10** — Public certificate verification via QR (`S`)

---

## Phase 2 — Vet quotations (estimates wrapper)

Goal: multi-line costed plans clients approve before treatment, **on top of the existing quotation engine**.
Effort: M (3-4 days).

- [ ] **VC-P2-T1** — "Create Quotation" CTA on appointment show — pre-fills `transactions` with `sub_status='quotation'`, vet context, SOAP-plan-meds as draft lines (`S`)
- [ ] **VC-P2-T2** — Extend the existing `new_quotation` notification so the email/SMS/WhatsApp carries an owner-approval link (`S`)
- [ ] **VC-P2-T3** — Public approve/reject actions on the existing quotation public view, owner email-token + signature capture (`M`)
- [ ] **VC-P2-T4** — "Convert Quotation → Invoice" button — reuses `SellController` conversion, links resulting `sells.id` to `vc_appointments.erp_sell_id` (`S`)

---

## Phase 3 — Notification template keys for vet events

Goal: vet workflows fire via the existing SMS + WhatsApp + Email notification engine.
Effort: S-M (1-2 days).

- [ ] **VC-P3-T1** — Add vet keys to `NotificationTemplate::customerNotifications()`: `vc_appointment_reminder`, `vc_vaccine_due`, `vc_appointment_confirmation`, `vc_consent_request`, `vc_quotation_sent` (`S`)
- [ ] **VC-P3-T2** — Route `VcSendVaccineReminders` and reminder cron through `NotificationUtil` (SMS + WhatsApp + Email) (`S`)

> ⏸ **Deferred to dedicated vet client portal project:** booking portal, owner inbox, my-pets page.

---

## Phase 4 — Pharmacy dispense → ERP stock

Goal: reconnect prescription dispensing to core ERP batch/lot/expiry stock.
Effort: S-M (2-3 days).

**Note:** The `vc_medicine_batches` table was already dropped by the 2026-05-02 redesign migration in favour of ERP `purchase_lines`. The `vc_medicines` table is the **medicine catalogue / library** used by prescriptions and (upcoming) VetAdmission treatment plans — leave its design alone.

- [ ] **VC-P4-T1** — Backfill `vc_medicines.product_id` for all dispensable items + add admin re-link tool (`S`)
- [ ] **VC-P4-T2** — On prescription finalise: post a sell via `SellController` with `lot_no_line_id` selected FEFO from `purchase_lines` matching `vc_medicines.product_id` (`M`)
- [ ] **VC-P4-T3** — Surface the existing core stock-expiry report as a widget in the vet dashboard; vet-specific filter view (`S`)

---

## Phase 5 — Diagnostics expansion

Goal: support more lab analyzers + imaging requests.
Effort: L (8-12 days).

### 5.1 Lab adapter pattern

- [ ] **VC-P5-T1** — Extract `LabAdapterInterface` from current NX600 logic (`M`)
- [ ] **VC-P5-T2** — IDEXX VetConnect adapter (HL7 v2 / HTTPS) (`L`)
- [ ] **VC-P5-T3** — Antech adapter (skip until customer demand) (`M`)
- [ ] **VC-P5-T4** — Per-business lab-provider config UI (`S`)

### 5.2 Imaging requests

- [ ] **VC-P5-T5** — Schema: `vc_imaging_modalities`, `vc_imaging_requests`, `vc_imaging_studies` (`S`)
- [ ] **VC-P5-T6** — Request CRUD + worklist mirroring lab UX (`M`)
- [ ] **VC-P5-T7** — OHIF viewer integration for DICOM + inline preview for JPG/PNG/PDF (`M`)

---

## Phase 6 — Wellness plans (subscriptions)

Goal: recurring health-plan subscriptions, billed via the existing recurring invoice engine.
Effort: M (4-5 days).

> ⏸ **VC-P6.1 Referral portal deferred** to a separate referral-portal project.

- [ ] **VC-P6-T1** — Schema: `vc_wellness_plans`, `vc_wellness_plan_benefits`, `vc_wellness_subscriptions`, `vc_wellness_benefit_usage` (`S`)
- [ ] **VC-P6-T2** — CRUD + subscribe UI; subscribing creates a `transactions` row with `is_recurring=1` (`M`)
- [ ] **VC-P6-T3** — Benefit redemption hook: on prescription/vaccination, check active subscription and discount the resulting sell line (`M`)
- [ ] **VC-P6-T4** — Reports: active subscribers, MRR, benefit utilisation (`S`)

---

## VetAdmission M1 — Treatment grid (flowsheet)

Goal: per-admission treatment matrix replacing the occupancy-only board as the primary clinical view.
Effort: L (8-10 days).

- [ ] **VA-M1-T1** — `CarePlanSlotService` — expand care-plan `schedule_times` into expected slots, overlay `va_care_logs` (`M`)
- [ ] **VA-M1-T2** — Flowsheet endpoint + JSON data API on `VaAdmissionController` (`S`)
- [ ] **VA-M1-T3** — `admissions/flowsheet.blade.php` — sticky-left treatments × hourly columns, status colors, click-to-log (`L`)
- [ ] **VA-M1-T4** — Quick-log AJAX endpoint (`S`)
- [ ] **VA-M1-T5** — Update ward-board tiles to deep-link to flowsheet (`S`)
- [ ] **VA-M1-T6** — Permission `vet_admission.use_flowsheet` + activity audit per cell (`S`)

---

## VetAdmission M2 — Medications + fluid therapy

Goal: weight-based dose calc + IV fluid tracking, integrated into the flowsheet.
Effort: L (10-12 days). Depends on M1.

- [ ] **VA-M2-T1** — Schema: `va_admission_medications`, `va_medication_administrations` (`S`)
  - References `vc_medicines.id` (the medicine catalogue / library)
- [ ] **VA-M2-T2** — Schema: `va_admission_fluids`, `va_fluid_bag_changes` (`S`)
- [ ] **VA-M2-T3** — Dose calculator widget — `(dose_mg_per_kg × weight) ÷ concentration = volume_per_dose_ml`, pulled from latest vitals (`M`)
- [ ] **VA-M2-T4** — Medication CRUD UI under admission show (`M`)
- [ ] **VA-M2-T5** — Fluid CRUD UI with bag-change quick action and end-time alerts (`M`)
- [ ] **VA-M2-T6** — Extend `CarePlanSlotService` to render meds + fluids as flowsheet rows (`M`)

---

## VetAdmission M3 — Vital trends + range alerts

Goal: out-of-range alerts, charts, missed-task escalation.
Effort: M (5-7 days). Depends on M1.

- [ ] **VA-M3-T1** — Schema: `vc_vital_ranges` (species × life stage); seed canine + feline defaults (`S`)
- [ ] **VA-M3-T2** — Annotate vitals API with normal/low/high/critical per metric (`S`)
- [ ] **VA-M3-T3** — Chart.js trend graphs on admission show, range bands (`M`)
- [ ] **VA-M3-T4** — `vetadmission:check-overdue` cron every 15 min → polymorphic `va_alerts` table (`S`)
- [ ] **VA-M3-T5** — Dashboard alert tile "Critical alerts (in-patient)" → deep-link to flowsheet (`S`)

---

## VetAdmission M4 — Treatment protocols (presets)

Goal: one-click apply standard protocols.
Effort: M (4-5 days). Depends on M2.

- [ ] **VA-M4-T1** — Schema: `va_protocols`, `va_protocol_items` (`S`)
- [ ] **VA-M4-T2** — Protocol CRUD UI (`M`)
- [ ] **VA-M4-T3** — "Apply protocol" action expanding into care plan + meds + fluids in one transaction, logged to `va_protocol_applications` (`M`)
- [ ] **VA-M4-T4** — Seed Canine Parvo / Feline URI / Post-op orthopedic / DKA protocols (`S`)

---

## VetAdmission M5 — Billing roll-up + discharge pack

Goal: each task is potentially billable; discharge produces final invoice + take-home pack.
Effort: M (5-7 days). Depends on M1.

- [ ] **VA-M5-T1** — Add `product_id` to `va_care_task_types`, `va_admission_fluids`; `daily_rate_product_id` to `va_admissions` (`S`)
- [ ] **VA-M5-T2** — `AdmissionBillingService` — appends sell lines to existing ERP sell (reuses `SellController` flow) (`M`)
- [ ] **VA-M5-T3** — `vetadmission:post-daily-stay` nightly cron (`S`)
- [ ] **VA-M5-T4** — `va_discharge_templates` + merge-tag rendering (`M`)
- [ ] **VA-M5-T5** — Discharge wizard: review charges → pick template → meds-to-go (creates prescription) → follow-up appointment → generate invoice + PDF pack (`M`)

---

## VetAdmission M6 — Real-time collaboration (optional)

Goal: multi-user live flowsheet updates.
Effort: M (5-7 days). Defer until pain felt. Depends on M1.

- [ ] **VA-M6-T1** — Broadcasting setup (Laravel Echo + Soketi or Pusher) (`S`)
- [ ] **VA-M6-T2** — Events: `CareLogged`, `VitalRecorded`, `MedicationAdministered`, `AlertRaised` (`S`)
- [ ] **VA-M6-T3** — Frontend listener patches flowsheet cells (`M`)
- [ ] **VA-M6-T4** — Presence "who's editing" avatars (`S`)

---

## Cross-cutting

- [ ] **X-T1** — This file (`docs/vet-roadmap.md`) is the source of truth — tick boxes as tasks complete
- [ ] **X-T2** — Feature tests for: EstimateConversion (Phase 2), MedicineDispense (Phase 4), AdmissionBillingService (VA-M5), CarePlanSlotService (VA-M1)
- [ ] **X-T3** — Per-phase permissions migration assigning new perms to business Admin role
- [ ] **X-T4** — Every new controller extends `LogsVcActivity` (or VetAdmission equivalent) for audit uniformity
- [ ] **X-T5** — `module_version` bump on each phase release; `InstallController::update` adds the new migrations

---

## Suggested sprint sequencing (2-week sprints)

| Sprint | Primary | Parallel | Ships |
|---|---|---|---|
| 1 | VC-P1.1 consent canvas (T1-T4) | X-T1 (this doc) | Signed consents in prod |
| 2 | VC-P1.2 controlled (T5-T8) + P1.3 cert (T9-T10) | | CD register + cert QR live |
| 3 | VC-P2 (T1-T4) | VA-M1 (T1-T2) starts | Vet quotations + flowsheet schema |
| 4 | VA-M1 (T3-T6) | VC-P3 (T1-T2) | Flowsheet beta + SMS templates |
| 5 | VA-M2 meds (T1-T4) | VC-P4 (T1-T2) | Meds tab + dispense skeleton |
| 6 | VA-M2 fluids + grid (T5-T6) | VC-P4 (T3) | Fluid tab + stock widget |
| 7 | VA-M3 trends + alerts (T1-T5) | VC-P5.1 lab adapter refactor (T1) | Vital alerts + lab refactor |
| 8 | VA-M4 protocols (T1-T4) | VC-P5.1 (T2-T4) | Protocols + IDEXX adapter |
| 9 | VA-M5 billing + discharge (T1-T5) | | Discharge wizard |
| 10 | VC-P6 wellness (T1-T4) | VC-P5.2 imaging (T5-T7) | Wellness + imaging |
| 11+ | VA-M6 real-time, integrations, polish | | Long-tail |

---

## Effort summary

| Phase / MS | Tasks | Effort | Status |
|---|---|---|---|
| VC P1 — Consent + CD + cert | 10 | M (3-5d) | In flight |
| VC P2 — Quotation wrapper | 4 | M (3-4d) | Planned |
| VC P3 — Vet notification templates | 2 | S (1-2d) | Planned |
| VC P4 — Pharmacy → ERP stock | 3 | S-M (2-3d) | Planned |
| VC P5 — Diagnostics | 7 | L (8-12d) | Planned |
| VC P6 — Wellness | 4 | M (4-5d) | Planned |
| VA M1 — Flowsheet | 6 | L (8-10d) | Planned |
| VA M2 — Meds + fluids | 6 | L (10-12d) | Planned |
| VA M3 — Vital trends | 5 | M (5-7d) | Planned |
| VA M4 — Protocols | 4 | M (4-5d) | Planned |
| VA M5 — Discharge | 5 | M (5-7d) | Planned |
| VA M6 — Real-time (optional) | 4 | M (5-7d) | Deferred |
| Cross-cutting | 5 | M (ongoing) | Ongoing |
| **Total** | **65** | **~50-70 dev-days** | |
| **Deferred (separate projects)** | | | Booking portal · Owner inbox · Referral portal |
