=== Doctor Prescription Manager ===
Contributors: aryanchoubey
Tags: prescription, woocommerce, doctor, clinic, dermatology, pharmacy, whatsapp, medical
Requires at least: 6.4
Tested up to: 6.7
Requires PHP: 8.1
Stable tag: 2.6.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Professional prescription management for WooCommerce. Doctors create prescriptions, patients receive a link, medicines are auto-added to cart.

== Description ==

Doctor Prescription Manager transforms your WooCommerce store into a professional clinic prescription system. Built for dermatology clinics and medical practices that sell medicines through WooCommerce.

**How it works:**

1. Doctor creates a prescription by selecting WooCommerce products
2. Sets dosage, frequency, and duration for each medicine
3. A secure prescription link is generated
4. Doctor sends the link to the patient via WhatsApp
5. Patient clicks the link — medicines are automatically added to their WooCommerce cart
6. Patient completes checkout through WooCommerce

**Features:**

* Professional doctor dashboard (frontend pages, not wp-admin)
* Patient management with search and CRUD
* Prescription creation with WooCommerce product search
* Dosage presets for dermatology (Apply twice daily, etc.)
* Secure 256-bit prescription links
* WhatsApp message preview and deep linking
* Auto add-to-cart functionality
* Stock checking and out-of-stock handling
* Reports dashboard with analytics
* Audit trail for every prescription action
* Rate limiting on prescription links
* WordPress Settings API for configuration
* Mobile-responsive design

**Requirements:**

* WordPress 6.4 or higher
* WooCommerce 8.0 or higher
* PHP 8.1 or higher

== Installation ==

1. Upload the `doctor-prescription-manager` folder to `/wp-content/plugins/`
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Go to Settings > Permalinks and click "Save Changes" (flushes rewrite rules)
4. Configure your clinic details under Rx Manager in the admin menu
5. Visit /doctor-dashboard/ on your site to access the doctor dashboard

== Frequently Asked Questions ==

= Do patients need to create an account? =

No. The prescription landing page is public. Patients can add medicines to their cart and checkout as guests (if WooCommerce guest checkout is enabled).

= Is patient data secure? =

Yes. Patient data is stored in custom database tables with WordPress capability checks on every API endpoint. Prescription links use 256-bit cryptographic tokens — they cannot be guessed or brute-forced.

= Can I customise the WhatsApp message? =

Yes. Go to Rx Manager settings in wp-admin and edit the WhatsApp message template. You can use placeholders like {patient_name}, {doctor_name}, {prescription_url}, etc.

= What happens if a product is out of stock? =

The system checks stock before adding to cart. Out-of-stock items are skipped with a notice to the patient. Available items are still added.

== Changelog ==

= 2.6.3 =
* Extended the button/input theme-isolation to every remaining control — sidebar sign-out, dashboard activity rows, and all patient landing-page buttons (Add to Cart, Chat on WhatsApp, Go to Website) — so no button anywhere picks up the WordPress theme's colours in any state


= 2.6.2 =
* Fixed button and input styling on the doctor pages where the WordPress theme was bleeding its hover/active/focus colours in — buttons now keep the plugin theme in every state (Save as Draft, Back, Copy Message, Add Patient, New Prescription, remove icons)
* Fixed the quantity field showing blank — typed values are now always visible


= 2.6.1 =
* Declared WooCommerce HPOS (High-Performance Order Storage) compatibility — clears the "incompatible with WooCommerce features" notice (the plugin already used HPOS-safe order APIs)


= 2.6.0 =
* Self-hosted automatic updates — licensed sites now see the normal "Update available -> Update now" flow, served from the licence server (only active licences receive updates)
* Author link now points to the portfolio site


= 2.5.2 =
* Default licence server URL is now a single constant (DPM_License::DEFAULT_API_URL), set to the production licence host — rebranding the host is a one-line change


= 2.5.1 =
* Medicine search now shows a browsable list of available medicines on click — a short, scrollable, alphabetical dropdown — while typing still performs the normal keyword search


= 2.5.0 =
* Custom dosage, frequency, and duration — pick "Custom" in any preset dropdown to type your own instructions (template values outside the presets open in custom mode automatically)
* WhatsApp links now go straight to the WooCommerce cart: medicines are added automatically and the patient lands in the cart, ready to checkout or keep shopping
* Auto-add page self-submits via JavaScript, so WhatsApp link-preview crawlers can never consume a redemption
* Reopening the link while the cart still holds the items returns to the cart instead of an "already redeemed" error
* Prescription instructions (dosage · frequency · duration) now appear under each item in the cart, at checkout, and on the order
* New setting: Patient Link Behaviour — auto-cart (default) or show the prescription page first; a "View prescription details" link is always available


= 2.4.0 =
* WhatsApp sending method selector: Free (wa.me from your phone) or WhatsApp Cloud API (paid Meta service)
* Free mode: add your clinic's WhatsApp number — patients get a "Chat with the clinic on WhatsApp" button on their prescription page
* Cloud API mode is Advanced-plan gated with clear per-message cost guidance and an incomplete-credentials warning
* Sending automatically falls back to wa.me links whenever the API is not fully configured


= 2.3.0 =
* Rebuilt wp-admin experience with dedicated pages: Overview, Settings, Licence & Plans, Features
* Overview: licence status hero, live stats, setup checklist with progress, how-it-works guide
* Licence & Plans: current plan card with countdown, plan comparison (Basic vs Advanced), contact-to-upgrade and renewal CTAs
* Features page: full catalogue with locked/unlocked states per plan and upgrade prompts
* Settings reorganised into tabs (Clinic, Prescriptions, WhatsApp, PDF); Advanced-only tabs show locked panels on Basic
* Right-hand info sidebar on every page: plugin version, licence state, quick links, support contact, system status
* Renewal flow: expiry countdown banner on plugin pages and a site-wide admin notice from 14 days before expiry
* Each settings tab saves independently (no more cross-tab option wipes)


= 2.2.0 =
* Commercial-grade UI redesign of the doctor dashboard
* Fixed broken collapsed sidebar — clean icon rail with tooltips, centred icons, and smooth transition
* Sidebar collapse state now persists across pages
* New header with sidebar toggle, page date, and refreshed actions
* Sidebar user card with role and sign-out; clinic name under the brand
* Dashboard greeting, skeleton loading states, activity rows with avatars, and a segmented status distribution chart
* Refined design system: typography, colour palette, shadows, badges with status dots, focus states


= 2.1.0 =
* Licensing system rebuilt — the plugin now requires an active licence key to operate
* Two tiers: Basic (dashboard, patients, prescriptions, WhatsApp → cart flow) and Advanced (everything: templates, reports, PDF, reminders, photos, WhatsApp API)
* Licence keys support monthly, quarterly, yearly, or custom expiry with site activation limits
* Licence activation panel in wp-admin with status, tier, expiry, and remote re-check
* Companion licence server with admin dashboard (issue, renew, suspend, revoke keys)
* WooCommerce orders are now linked back to the prescription (order shown on the prescription detail page)
* Fixed Alpine.js initialisation order — patients page and dashboard stats now load correctly
* Fixed patient creation rejecting an empty gender selection
* Fixed currency symbol rendering as an HTML entity in medicine search
* Fixed duplicated "Dr." prefix in WhatsApp messages, landing page, and PDF
* Advanced-tier controls hidden on Basic tier (templates, reports, PDF buttons)
* Admin bar hidden on the doctor app pages; visual refinement across the dashboard

= 2.0.0 =
* Prescription templates — save and reuse common prescriptions
* PDF prescription export — professional branded print-ready prescriptions
* Multi-doctor support — data isolation per doctor, admin sees all
* Patient timeline — chronological view of prescriptions, notes, and activity
* Follow-up reminders — automated WhatsApp/email reminders via WP-Cron
* Before/after photos — secure storage with EXIF stripping
* Licensing system — free tier + Pro features
* WhatsApp Cloud API integration — send messages directly from the plugin
* WordPress media uploader for clinic logo
* Dashboard enhancements — quick actions, status breakdown, live stats
* Security hardening — encrypted API tokens, cache-control headers, rate limiting
* 9 database tables, 50+ PHP files

= 1.0.0 =
* Initial release
* Doctor dashboard with live stats
* Patient management (CRUD)
* Prescription creation with WooCommerce product search
* Secure prescription links with token validation
* Auto add-to-cart functionality
* WhatsApp message preview
* Reports dashboard
* Audit trail logging
