=== KennelFlow Vet ===
Contributors: brelandr
Tags: pets, veterinary, clinic, bookings
Requires at least: 6.2
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 0.1.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Veterinary foundation: patients, rooms, locations, and bookings with availability checks and REST API. Requires KennelFlow Core.

== Description ==

KennelFlow Vet provides clinical scheduling and record-keeping building blocks that integrate with KennelFlow shared pets and locations. Install **KennelFlow Core** first, then activate this add-on.

Primary development and listings use the WordPress.org profile **[@brelandr](https://profiles.wordpress.org/brelandr/).** Optional commercial services are available via **LandTech Web Designs**.

**Human-readable JavaScript/CSS source (Guideline 4):** Every release includes the unminified sources under **assets/src/** (see **assets/src/README.txt** for the dist-to-source map). Built files under **assets/dist/** are generated via **npm run build** (esbuild + Vite). The DICOM viewer bundles **Cornerstone3D** into **assets/dist/dicom-viewer.js**. Public source: https://github.com/brelandr/kennelflow-vet — see Developer notes for rebuild steps.

== Try It Live - Preview This Plugin Instantly ==

Preview KennelFlow Vet in WordPress Playground: the blueprint installs **KennelFlow Core** and **KennelFlow Vet** from WordPress.org, seeds demo pets and an owner portal, adds a **Book a Vet Visit** page with `[kennelflow_vet_booking]`, and opens the **Vet calendar** in wp-admin. Log in as **admin** / **password** (demo owner: **demoowner** / **password**).

[Preview on WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/brelandr/kennelflow-vet/main/blueprint.json)

The blueprint ships as `blueprint.json` and `assets/blueprints/blueprint.json`. WordPress.org also serves a copy from plugin SVN for directory live preview.

== Installation ==

1. Install and activate **KennelFlow Core** from WordPress.org.
2. Install KennelFlow Vet (upload zip or install from the Plugins screen). The folder name should match the plugin slug `/wp-content/plugins/kennelflow-vet/`.
3. Activate KennelFlow Vet from the Plugins screen.
4. Configure rooms, locations, and roles for your clinic.

== Frequently Asked Questions ==

= Does this require another KennelFlow plugin besides Core? =

KennelFlow Vet requires KennelFlow Core. Other KennelFlow add-ons are optional.

= Does this send data to external services? =

Clinical and booking data ordinarily stay on your WordPress site. **SMTP** mail and other unrelated plugins remain outside KennelFlow Vet’s scope. **Laboratory ingest** integrations do not transmit data externally unless clinic staff explicitly configure webhook or ingest flows that invoke other APIs.

**AI SOAP dictation uses the WordPress AI Client (WordPress 7.0+).** KennelFlow Vet does not store provider API keys. Site administrators configure AI connectors under **Settings → Connectors**; only then may permitted clinicians trigger dictation, which sends in-browser audio and derived text through the configured provider for transcription and SOAP structuring (see **External Services**). If no connector is configured, dictation is unavailable.

The **in-browser DICOM viewer** uses bundled JavaScript shipped with the plugin; it does **not** upload medical images to a third‑party viewing service by default.

= Where is the non-minified JavaScript and CSS source? =

Human-readable sources live under **assets/src/** alongside **assets/src/README.txt** (dist-to-entry mapping). The same trees ship in every release alongside **assets/dist/**. Browse or fork from https://github.com/brelandr/kennelflow-vet. Run **npm ci** then **npm run build** from the plugin root after edits; see Developer notes for esbuild vs Vite entrypoints and bundled dependencies.

== Developer notes ==

= Frontend bundles (readable source and rebuild) =

**Public source repository:** https://github.com/brelandr/kennelflow-vet — clone with `git clone https://github.com/brelandr/kennelflow-vet.git`, then run **npm ci** and **npm run build** to regenerate all bundles from the readable sources in **assets/src/**.

**WordPress.org release package:** each **trunk** or **tag** revision shipped to WordPress.org should include **assets/src/**, **vite.*.config.js**, **scripts/build-assets.mjs**, **package.json**, **package-lock.json**, **tsconfig.json**, and **assets/dist/** (including the Cornerstone3D-powered **dicom-viewer.js** bundle and **kennelflow-vet-decode-worker.js**).

**Maintainer zip builds:** From a git checkout you can run **scripts/build-wordpress-org-zip.sh** locally (repo-only tooling); it stages **release/*.zip** and verifies **`assets/dist/`** artefacts and core source entries. Install **Plugin Check** from https://wordpress.org/plugins/plugin-check/ and validate the staged directory before uploading to WordPress.org.

**esbuild bundles** (**scripts/build-assets.mjs**) produce **booking-wizard**, **admin-calendar**, **facility-settings** into **assets/dist/**.

**Vite bundles** rebuild **assets/dist/ai-dictation.*** from **vite.ai-dictation.config.js** and **assets/dist/dicom-viewer.*** from **vite.dicom.config.js** against the JSX sources listed in **assets/src/README.txt**. Run **`npm run build:vite`** to rebuild only the Vite targets, or **`npm run build`** / **`npm run build:all`** for the full pipeline (esbuild + both Vite configs).

**DICOM / Cornerstone3D:** **npm run build** compiles npm packages **@cornerstonejs/core** and **@cornerstonejs/dicom-image-loader** (upstream https://github.com/cornerstonejs/cornerstone3D) into **assets/dist/dicom-viewer.js** and **assets/dist/kennelflow-vet-decode-worker.js** via Vite — no **assets/vendor/** copies and no remote CDNs load imaging libraries at runtime.

Shipped readable sources map to shipped bundles as follows (see **assets/src/README.txt** for the definitive table):

* **assets/dist/booking-wizard.js** / **booking-wizard.css** — TypeScript/React in **assets/src/booking-wizard/** (entry **main.tsx**), plus **booking-wizard.css**
* **assets/dist/admin-calendar.js** / **admin-calendar.css** — **assets/src/admin-calendar/** (**main.tsx**), plus **admin-calendar.css**
* **assets/dist/facility-settings.js** / **facility-settings.css** — **assets/src/facility-settings/** (**main.tsx**), plus **facility-settings.css**
* **assets/dist/ai-dictation.js** / **ai-dictation.css** — **assets/src/ai-dictation.js** + JSX modules (including **AIDictation.jsx**) via **Vite**
* **assets/dist/dicom-viewer.js** / **dicom-viewer.css** — **assets/src/dicom-viewer-entry.jsx**, **assets/src/DICOMViewer.jsx**, **assets/src/cornerstone3d-bootstrap.js**, and **assets/src/dicom-viewer.css**, via **Vite** (bundles Cornerstone3D)
* **assets/dist/kennelflow-vet-decode-worker.js** — DICOM decode Web Worker emitted by the same Vite build (URL passed from PHP; ships beside **dicom-viewer.js**)

Fully regenerate bundles and the DICOM worker from the plugin root (**Node.js current LTS** recommended):

1. npm ci
2. npm run build   (alias: **npm run build:all** — esbuild, then AI dictation Vite, then DICOM Vite)

Incremental development:

* **npm run watch** — esbuild only (booking-wizard, admin-calendar, facility-settings)
* **npm run watch:vite:ai** — Vite watch for **ai-dictation**
* **npm run watch:vite:dicom** — Vite watch for **dicom-viewer** and **kennelflow-vet-decode-worker.js**

Dependency versions remain pinned via **package.json** / **package-lock.json**.

= Third-party libraries included in the bundled JS/CSS =

The bundled UI loads these runtime OSS libraries straight from the emitted JavaScript payloads (matching **package.json** majors):

* React and React DOM — https://react.dev/
* FullCalendar (core, React adapters, calendars) — https://fullcalendar.io/
* Cornerstone3D (**@cornerstonejs/core**, **@cornerstonejs/dicom-image-loader**) — https://github.com/cornerstonejs/cornerstone3D — https://www.cornerstonejs.org/
* dicom-parser (transitive dependency of the DICOM image loader) — https://github.com/cornerstonejs/dicomParser/

esbuild, Vite, TypeScript, and **@vitejs/plugin-react** are build-time-only developer dependencies.

= Admin JavaScript (plain, non-compiled) =

The following scripts under **assets/js/** are plain, human-readable JavaScript — no build step required:

* **assets/js/admin-ajax.js** — AJAX helpers used across the admin EMR interface
* **assets/js/admin-emr-confirm.js** — Confirmation dialog for destructive EMR actions
* **assets/js/admin-emr-pet-search.js** — Pet search autocomplete for EMR admin pages

== External Services ==

This plugin avoids silent network calls beyond what WordPress administrators explicitly configure.

= WordPress AI Client (optional SOAP dictation) =

Purpose: Clinicians may dictate optional SOAP scaffolding on pet encounter forms. Audio captured in-browser is processed through the **WordPress AI Client** (`wp_ai_client_prompt()`) built into WordPress 7.0+ — KennelFlow Vet does **not** call third-party AI HTTP APIs directly.

Administrator opt-in: **Default-off until a connector is configured.** Site administrators (typically under **Settings → Connectors**) choose and authorize an AI provider once at the site level. KennelFlow Vet stores **no** provider API keys. The plugin screen **KennelFlow Vet → AI dictation** links to Connectors and shows availability status.

When transmissions occur: **Only after** WordPress reports AI support (`wp_supports_ai()`) **and** a permitted user (EMR edit capability) triggers dictation via the REST route. The configured connector/provider handles outbound requests; if AI is unavailable, the route returns an error and no dictation runs.

Data sent: (1) **Audio** — browser-captured dictation uploaded to your WordPress site, then passed to the AI Client with `with_file()` for transcription; (2) **Transcripts and prompt snippets** — plain text plus a fixed SOAP-structuring prompt sent through the same client. No patient identifiers are added by the plugin beyond what clinicians speak; follow clinic policy when dictating.

Third-party providers: Which external service receives data depends entirely on the connector the site owner configures in WordPress (for example OpenAI, Anthropic, or Google). Review that provider’s terms and privacy policy in Connectors documentation alongside your facility’s HIPAA/state privacy workflows.

= DICOM imaging viewer =

The bundled DICOM tooling uses self-hosted **Cornerstone3D** JavaScript compiled into **assets/dist/dicom-viewer.js** (with **assets/dist/kennelflow-vet-decode-worker.js** for decoding) and does **not**, by itself, relay patient imaging to third-party viewing platforms.

= Laboratory webhook ingest (optional, inbound) =

Purpose: Clinic staff may configure diagnostic/lab vendors to POST result JSON to a KennelFlow Vet REST webhook when a shared secret is stored for that provider.

When transmissions occur: **Inbound only** — external lab systems initiate HTTPS POST requests to your WordPress site at **`/wp-json/kennelflow-vet/v1/lab-integration/webhook/{provider}`** when an administrator or integration filter configures a webhook secret for the provider slug. No outbound calls are made to lab vendors by this feature.

Authentication: Requests must present the configured shared secret via **`X-KF-Vet-Lab-Secret`**, **`X-KF-Vet-Lab-Token`**, or **`Authorization: Bearer`** header. Requests without a matching secret are rejected (401). If no secret is configured, the endpoint does not accept data.

Data received: JSON lab result payloads (patient identifiers and result rows as supplied by the vendor/integration). Parsed rows are stored in your WordPress database as EMR lab results for the matched pet. Review vendor agreements and your facility privacy policy before enabling inbound feeds.

== Privacy ==

The plugin stores clinical and booking data in your WordPress database and media library per your configuration. Review your site privacy policy and any other active plugins for how data is shared.

== Changelog ==

= 0.1.2 =
* Fix Vet calendar and Facility rules admin screens not mounting (React mount element and localized config names now match PHP).

= 0.1.0 =
* Initial release on WordPress.org.

== Developer Resources ==

The uncompiled source code, along with build tools and instructions for this plugin, is publicly available for review, study, and contribution on GitHub: https://github.com/brelandr/kennelflow-vet . Clone the repo, install dependencies with **npm ci**, then run **npm run build** so **esbuild** and **Vite** (including the Cornerstone3D DICOM bundle) all execute (matching the WordPress.org upload layout).
