From deb5197e5316e5a25ca3ff062cd45e568c4e2278 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Sat, 5 Sep 2026 14:12:19 -0700 Subject: [PATCH] feat: Initial Mediusa Clinic OS practice management platform ('Jane App But Better') --- package-lock.json | 249 ++++++++++ package.json | 2 + src/app/layout.tsx | 31 +- src/app/page.tsx | 447 +++++++++++++++--- src/components/admin/SuperAdminView.tsx | 359 +++++++++++++++ src/components/billing/SuperbillView.tsx | 346 ++++++++++++++ src/components/calendar/CalendarView.tsx | 237 ++++++++++ src/components/charting/SoapChartEditor.tsx | 478 ++++++++++++++++++++ src/components/intake/PatientPortalView.tsx | 410 +++++++++++++++++ src/components/retention/RetentionView.tsx | 346 ++++++++++++++ src/components/ui/AmbientAudioRecorder.tsx | 256 +++++++++++ src/components/ui/BodyPainMap.tsx | 182 ++++++++ src/components/ui/DigitalSignaturePad.tsx | 122 +++++ src/components/ui/SpineVisualizer.tsx | 457 +++++++++++++++++++ src/lib/mock-data.ts | 471 +++++++++++++++++++ src/lib/pdf-generator.ts | 178 ++++++++ src/types/clinical.ts | 175 +++++++ 17 files changed, 4675 insertions(+), 71 deletions(-) create mode 100644 src/components/admin/SuperAdminView.tsx create mode 100644 src/components/billing/SuperbillView.tsx create mode 100644 src/components/calendar/CalendarView.tsx create mode 100644 src/components/charting/SoapChartEditor.tsx create mode 100644 src/components/intake/PatientPortalView.tsx create mode 100644 src/components/retention/RetentionView.tsx create mode 100644 src/components/ui/AmbientAudioRecorder.tsx create mode 100644 src/components/ui/BodyPainMap.tsx create mode 100644 src/components/ui/DigitalSignaturePad.tsx create mode 100644 src/components/ui/SpineVisualizer.tsx create mode 100644 src/lib/mock-data.ts create mode 100644 src/lib/pdf-generator.ts create mode 100644 src/types/clinical.ts diff --git a/package-lock.json b/package-lock.json index ad39d79..30a8234 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,8 @@ "name": "mediusa-clinic-os", "version": "0.1.0", "dependencies": { + "jspdf": "^4.2.1", + "lucide-react": "^1.41.0", "next": "16.3.4", "react": "19.2.8", "react-dom": "19.2.8" @@ -228,6 +230,15 @@ "node": ">=6.0.0" } }, + "node_modules/@babel/runtime": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.7.tgz", + "integrity": "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@babel/template": { "version": "7.29.7", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz", @@ -1718,6 +1729,19 @@ "undici-types": "~6.21.0" } }, + "node_modules/@types/pako": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@types/pako/-/pako-2.0.4.tgz", + "integrity": "sha512-VWDCbrLeVXJM9fihYodcLiIv0ku+AlOa/TQ1SvYOaBuyrSKgEcro95LJyIsJ4vSo6BXIxOKxiJAat04CmST9Fw==", + "license": "MIT" + }, + "node_modules/@types/raf": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/@types/raf/-/raf-3.4.3.tgz", + "integrity": "sha512-c4YAvMedbPZ5tEyxzQdMoOhhJ4RD3rngZIdwC2/qDN3d7JpEhB6fiBRKVY1lg5B7Wk+uPBjn5f39j1/2MY1oOw==", + "license": "MIT", + "optional": true + }, "node_modules/@types/react": { "version": "19.2.18", "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.18.tgz", @@ -1738,6 +1762,13 @@ "@types/react": "^19.2.0" } }, + "node_modules/@types/trusted-types": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", + "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==", + "license": "MIT", + "optional": true + }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "8.69.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.69.0.tgz", @@ -2680,6 +2711,16 @@ "dev": true, "license": "MIT" }, + "node_modules/base64-arraybuffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz", + "integrity": "sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">= 0.6.0" + } + }, "node_modules/baseline-browser-mapping": { "version": "2.11.21", "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.21.tgz", @@ -2830,6 +2871,26 @@ ], "license": "CC-BY-4.0" }, + "node_modules/canvg": { + "version": "3.0.11", + "resolved": "https://registry.npmjs.org/canvg/-/canvg-3.0.11.tgz", + "integrity": "sha512-5ON+q7jCTgMp9cjpu4Jo6XbvfYwSB2Ow3kzHKfIyJfaCAOHLbdKPQqGKgfED/R5B+3TFFfe8pegYA+b423SRyA==", + "license": "MIT", + "optional": true, + "dependencies": { + "@babel/runtime": "^7.12.5", + "@types/raf": "^3.4.0", + "core-js": "^3.8.3", + "raf": "^3.4.1", + "regenerator-runtime": "^0.13.7", + "rgbcolor": "^1.0.1", + "stackblur-canvas": "^2.0.0", + "svg-pathdata": "^6.0.3" + }, + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -2887,6 +2948,21 @@ "dev": true, "license": "MIT" }, + "node_modules/core-js": { + "version": "3.50.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.50.0.tgz", + "integrity": "sha512-BRWgOLKkFeCgRudR6zrs8p9XJZcE14grzKMMssoYrk6krtuEZ7MTKPIY5RzOnqsEKIR9kst7wNzphttraT+Yqw==", + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "engines": { + "node": "*" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -2902,6 +2978,16 @@ "node": ">= 8" } }, + "node_modules/css-line-break": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/css-line-break/-/css-line-break-2.1.0.tgz", + "integrity": "sha512-FHcKFCZcAha3LwfVBhCQbW2nCNbkZXn7KVUJcsT5/P8YmfsVja0FMPJr0B903j/E69HUphKiV9iQArX8SDYA4w==", + "license": "MIT", + "optional": true, + "dependencies": { + "utrie": "^1.0.2" + } + }, "node_modules/csstype": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", @@ -3054,6 +3140,16 @@ "node": ">=0.10.0" } }, + "node_modules/dompurify": { + "version": "3.4.14", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.14.tgz", + "integrity": "sha512-dVoH9z+MY+C9IilgGCk3YfFqjLi3fChm2OiKJMzh6axrJ5qwxqWaZamgmHrpv22CN/KdbZJuGEGgfQoL00LTdg==", + "license": "(MPL-2.0 OR Apache-2.0)", + "optional": true, + "optionalDependencies": { + "@types/trusted-types": "^2.0.7" + } + }, "node_modules/dunder-proto": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", @@ -3777,6 +3873,17 @@ "dev": true, "license": "MIT" }, + "node_modules/fast-png": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/fast-png/-/fast-png-6.4.0.tgz", + "integrity": "sha512-kAqZq1TlgBjZcLr5mcN6NP5Rv4V2f22z00c3g8vRrwkcqjerx7BEhPbOnWCPqaHUl2XWQBJQvOT/FQhdMT7X/Q==", + "license": "MIT", + "dependencies": { + "@types/pako": "^2.0.3", + "iobuffer": "^5.3.2", + "pako": "^2.1.0" + } + }, "node_modules/fastq": { "version": "1.20.3", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.3.tgz", @@ -3787,6 +3894,12 @@ "reusify": "^1.0.4" } }, + "node_modules/fflate": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.3.tgz", + "integrity": "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==", + "license": "MIT" + }, "node_modules/file-entry-cache": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", @@ -4175,6 +4288,20 @@ "hermes-estree": "0.25.1" } }, + "node_modules/html2canvas": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/html2canvas/-/html2canvas-1.4.1.tgz", + "integrity": "sha512-fPU6BHNpsyIhr8yyMpTLLxAbkaK8ArIBcmZIRiBLiDhjeqvXolaEmDGmELFuX9I4xDcaKKcJl+TKZLqruBbmWA==", + "license": "MIT", + "optional": true, + "dependencies": { + "css-line-break": "^2.1.0", + "text-segmentation": "^1.0.3" + }, + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/ignore": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", @@ -4227,6 +4354,12 @@ "node": ">= 0.4" } }, + "node_modules/iobuffer": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/iobuffer/-/iobuffer-5.4.0.tgz", + "integrity": "sha512-DRebOWuqDvxunfkNJAlc3IzWIPD5xVxwUNbHr7xKB8E6aLJxIPfNX3CoMJghcFjpv6RWQsrcJbghtEwSPoJqMA==", + "license": "MIT" + }, "node_modules/is-array-buffer": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.5.tgz", @@ -4777,6 +4910,23 @@ "node": ">=6" } }, + "node_modules/jspdf": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/jspdf/-/jspdf-4.2.1.tgz", + "integrity": "sha512-YyAXyvnmjTbR4bHQRLzex3CuINCDlQnBqoSYyjJwTP2x9jDLuKDzy7aKUl0hgx3uhcl7xzg32agn5vlie6HIlQ==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.28.6", + "fast-png": "^6.2.0", + "fflate": "^0.8.1" + }, + "optionalDependencies": { + "canvg": "^3.0.11", + "core-js": "^3.6.0", + "dompurify": "^3.3.1", + "html2canvas": "^1.0.0-rc.5" + } + }, "node_modules/jsx-ast-utils": { "version": "3.3.5", "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz", @@ -5156,6 +5306,15 @@ "yallist": "^3.0.2" } }, + "node_modules/lucide-react": { + "version": "1.41.0", + "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-1.41.0.tgz", + "integrity": "sha512-6lksP35l6KszDKUeRTi4LV7i6DEe0Yzl2ALJm9j4c5xEYN91GdW1xGsawGMOg2mgjF5GHBVX8pKX9kP+cWsP3Q==", + "license": "ISC", + "peerDependencies": { + "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, "node_modules/magic-string": { "version": "0.30.21", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", @@ -5573,6 +5732,22 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/pako": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/pako/-/pako-2.2.0.tgz", + "integrity": "sha512-zJq6RP/5q+TO2OpFV3FHzlPnFjmkb7Nc99a5SNjJE+uu/PkpChs+NIZSSzbBoD+6kjiISXjfYdwj1ZRQ81dz/w==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "(MIT AND Zlib)" + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -5613,6 +5788,13 @@ "dev": true, "license": "MIT" }, + "node_modules/performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==", + "license": "MIT", + "optional": true + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -5724,6 +5906,16 @@ ], "license": "MIT" }, + "node_modules/raf": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz", + "integrity": "sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==", + "license": "MIT", + "optional": true, + "dependencies": { + "performance-now": "^2.1.0" + } + }, "node_modules/react": { "version": "19.2.8", "resolved": "https://registry.npmjs.org/react/-/react-19.2.8.tgz", @@ -5775,6 +5967,13 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/regenerator-runtime": { + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", + "license": "MIT", + "optional": true + }, "node_modules/regexp.prototype.flags": { "version": "1.5.4", "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz", @@ -5851,6 +6050,16 @@ "node": ">=0.10.0" } }, + "node_modules/rgbcolor": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/rgbcolor/-/rgbcolor-1.0.1.tgz", + "integrity": "sha512-9aZLIrhRaD97sgVhtJOW6ckOEh6/GnvQtdVNfdZ6s67+3/XwLS9lBcQYzEEhYVeUowN7pRzMLsyGhK2i/xvWbw==", + "license": "MIT OR SEE LICENSE IN FEEL-FREE.md", + "optional": true, + "engines": { + "node": ">= 0.8.15" + } + }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -6173,6 +6382,16 @@ "dev": true, "license": "MIT" }, + "node_modules/stackblur-canvas": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/stackblur-canvas/-/stackblur-canvas-2.7.0.tgz", + "integrity": "sha512-yf7OENo23AGJhBriGx0QivY5JP6Y1HbrrDI6WLt6C5auYZXlQrheoY8hD4ibekFKz1HOfE48Ww8kMWMnJD/zcQ==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=0.1.14" + } + }, "node_modules/stop-iteration-iterator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz", @@ -6373,6 +6592,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/svg-pathdata": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/svg-pathdata/-/svg-pathdata-6.0.3.tgz", + "integrity": "sha512-qsjeeq5YjBZ5eMdFuUa4ZosMLxgr5RZ+F+Y1OrDhuOCEInRMA3x74XdBtggJcj9kOeInz0WE+LgCPDkZFlBYJw==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/tailwindcss": { "version": "4.3.3", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.3.tgz", @@ -6394,6 +6623,16 @@ "url": "https://opencollective.com/webpack" } }, + "node_modules/text-segmentation": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/text-segmentation/-/text-segmentation-1.0.3.tgz", + "integrity": "sha512-iOiPUo/BGnZ6+54OsWxZidGCsdU8YbE4PSpdPinp7DeMtUJNJBoJ/ouUSTJjHkh1KntHaltHl/gDs2FC4i5+Nw==", + "license": "MIT", + "optional": true, + "dependencies": { + "utrie": "^1.0.2" + } + }, "node_modules/tinyglobby": { "version": "0.2.17", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", @@ -6734,6 +6973,16 @@ "punycode": "^2.1.0" } }, + "node_modules/utrie": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/utrie/-/utrie-1.0.2.tgz", + "integrity": "sha512-1MLa5ouZiOmQzUbjbu9VmjLzn1QLXBhwpUa7kdLUQK+KQ5KA9I1vk5U4YHe/X2Ch7PYnJfWuWT+VbuxbGwljhw==", + "license": "MIT", + "optional": true, + "dependencies": { + "base64-arraybuffer": "^1.0.2" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index e1536e9..7bff733 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,8 @@ "lint": "eslint" }, "dependencies": { + "jspdf": "^4.2.1", + "lucide-react": "^1.41.0", "next": "16.3.4", "react": "19.2.8", "react-dom": "19.2.8" diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 9852c15..6ba36e0 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,29 +1,36 @@ -import type { Metadata } from "next"; -import { Geist, Geist_Mono } from "next/font/google"; -import "./globals.css"; +import type { Metadata } from 'next'; +import { Geist, Geist_Mono } from 'next/font/google'; +import './globals.css'; const geistSans = Geist({ - variable: "--font-geist-sans", - subsets: ["latin"], + variable: '--font-geist-sans', + subsets: ['latin'], }); const geistMono = Geist_Mono({ - variable: "--font-geist-mono", - subsets: ["latin"], + variable: '--font-geist-mono', + subsets: ['latin'], }); export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", + title: 'Mediusa Clinic OS — Next-Gen Practice Management Platform', + description: + 'High-speed, proprietary white-label medical practice management platform for chiropractors and wellness clinics. Scheduling, paperless intake, ambient AI clinical notes, and billing.', }; -export default function RootLayout({ children }: LayoutProps<"/">) { +export default function RootLayout({ + children, +}: Readonly<{ + children: React.ReactNode; +}>) { return ( - {children} + + {children} + ); } diff --git a/src/app/page.tsx b/src/app/page.tsx index c887311..678f250 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,69 +1,398 @@ -import Image from "next/image"; +'use client'; + +import React, { useState } from 'react'; +import { + INITIAL_TENANTS, + INITIAL_PROVIDERS, + INITIAL_PATIENTS, + INITIAL_APPOINTMENTS, + INITIAL_SOAP_NOTES, + INITIAL_SUPERBILLS, +} from '@/lib/mock-data'; +import { + ClinicTenant, + Provider, + Patient, + Appointment, + SoapNote, + Superbill, +} from '@/types/clinical'; +import { CalendarView } from '@/components/calendar/CalendarView'; +import { SoapChartEditor } from '@/components/charting/SoapChartEditor'; +import { SuperbillView } from '@/components/billing/SuperbillView'; +import { RetentionView } from '@/components/retention/RetentionView'; +import { PatientPortalView } from '@/components/intake/PatientPortalView'; +import { SuperAdminView } from '@/components/admin/SuperAdminView'; +import { + Calendar, + FileText, + DollarSign, + Users, + ShieldCheck, + Building2, + Globe, + Sparkles, + ChevronDown, + Stethoscope, + Laptop, + CheckCircle2, +} from 'lucide-react'; export default function Home() { + // Global Multi-Tenant State + const [tenants, setTenants] = useState(INITIAL_TENANTS); + const [activeTenantId, setActiveTenantId] = useState(INITIAL_TENANTS[0].id); + + // Active Navigation Mode: 'clinic' (EHR Practice OS) | 'patient' (Booking/Intake) | 'superadmin' (Mediusa Command) + const [portalMode, setPortalMode] = useState<'clinic' | 'patient' | 'superadmin'>('clinic'); + + // Clinic Portal Sub-Tabs: 'calendar' | 'charting' | 'billing' | 'retention' + const [clinicTab, setClinicTab] = useState<'calendar' | 'charting' | 'billing' | 'retention'>('calendar'); + + // Active Entities + const [appointments, setAppointments] = useState(INITIAL_APPOINTMENTS); + const [patients, setPatients] = useState(INITIAL_PATIENTS); + const [soapNotes, setSoapNotes] = useState(INITIAL_SOAP_NOTES); + const [superbills, setSuperbills] = useState(INITIAL_SUPERBILLS); + + const [activePatient, setActivePatient] = useState(INITIAL_PATIENTS[0]); // Marcus Chen + const [activeSoapNote, setActiveSoapNote] = useState(INITIAL_SOAP_NOTES[0]); + const [activeSuperbill, setActiveSuperbill] = useState(INITIAL_SUPERBILLS[0]); + + const activeTenant = tenants.find((t) => t.id === activeTenantId) || tenants[0]; + const activeProviders = INITIAL_PROVIDERS.filter((p) => p.tenantId === activeTenant.id); + const activeProvider = activeProviders[0] || INITIAL_PROVIDERS[0]; + + // Handlers + const handleSelectAppointment = (apt: Appointment) => { + const patientMatch = patients.find((p) => p.id === apt.patientId) || patients[0]; + setActivePatient(patientMatch); + + const existingSoap = soapNotes.find((s) => s.patientId === apt.patientId && s.appointmentId === apt.id); + setActiveSoapNote(existingSoap); + setClinicTab('charting'); + }; + + const handleUpdateAppointmentStatus = (aptId: string, status: Appointment['status']) => { + setAppointments((prev) => + prev.map((a) => (a.id === aptId ? { ...a, status } : a)) + ); + }; + + const handleSaveSoapNote = (note: SoapNote) => { + setSoapNotes((prev) => { + const idx = prev.findIndex((s) => s.id === note.id); + if (idx >= 0) { + const copy = [...prev]; + copy[idx] = note; + return copy; + } + return [...prev, note]; + }); + setActiveSoapNote(note); + }; + + const handleGenerateSuperbillFromNote = (note: SoapNote) => { + const newSb: Superbill = { + id: `sb-${Date.now()}`, + tenantId: activeTenant.id, + invoiceNumber: `SB-2026-${Math.floor(1000 + Math.random() * 9000)}`, + patientId: activePatient.id, + patientName: `${activePatient.firstName} ${activePatient.lastName}`, + patientDob: activePatient.dob, + patientAddress: activePatient.address, + providerName: note.providerName, + providerNpi: activeProvider.npi, + clinicName: activeTenant.name, + clinicAddress: activeTenant.address, + clinicTaxId: activeTenant.taxId, + dateOfService: note.date, + posCode: '11 (Office)', + icd10Codes: note.icd10Codes, + items: note.cptCodes.map((cpt) => ({ + cptCode: cpt.code, + description: cpt.description, + units: 1, + rate: cpt.fee, + total: cpt.fee, + })), + totalAmount: note.cptCodes.reduce((sum, c) => sum + c.fee, 0), + patientPaid: note.cptCodes.reduce((sum, c) => sum + c.fee, 0), + balanceDue: 0, + paymentMethod: 'Stripe Card', + generatedAt: new Date().toISOString(), + }; + + setSuperbills((prev) => [newSb, ...prev]); + setActiveSuperbill(newSb); + setClinicTab('billing'); + }; + + const handleMarkPaid = (superbillId: string, method: Superbill['paymentMethod']) => { + setSuperbills((prev) => + prev.map((sb) => + sb.id === superbillId + ? { ...sb, balanceDue: 0, patientPaid: sb.totalAmount, paymentMethod: method } + : sb + ) + ); + if (activeSuperbill.id === superbillId) { + setActiveSuperbill((prev) => ({ + ...prev, + balanceDue: 0, + patientPaid: prev.totalAmount, + paymentMethod: method, + })); + } + }; + + const handlePatientBookingComplete = (newAptData: any) => { + const newApt: Appointment = { + id: `apt-${Date.now()}`, + tenantId: activeTenant.id, + patientId: `pat-${Date.now()}`, + ...newAptData, + }; + setAppointments((prev) => [newApt, ...prev]); + }; + + const handleAddTenant = (newTenant: ClinicTenant) => { + setTenants((prev) => [...prev, newTenant]); + }; + + const handleSwitchTenant = (tenantId: string) => { + setActiveTenantId(tenantId); + setPortalMode('clinic'); + setClinicTab('calendar'); + }; + return ( -
-
- Next.js logo -
-

- To get started, edit the{" "} - - page.tsx - {" "} - file. -

-

- Looking for a starting point or more instructions? Head over to{" "} - + {/* Top Global Command Bar */} +

+
+ {/* Brand & Clinic Domain Selector */} +
+
+ + M+ + +
+
+ MEDIUSA CLINIC OS + + v2.4 PRO + +
+
+ + https://{activeTenant.domain} +
+
+
+ + {/* Tenant Switcher Dropdown */} +
+ + +
+
+ + {/* Core Portal Mode Switcher */} +
-
- - Vercel logomark - Deploy Now - - - Documentation - + + Patient Booking & Intake + + + +
+ + {/* Sub-Tabs for Doctor Clinic OS */} + {portalMode === 'clinic' && ( +
+ + + + + + + +
+ )} +
+ + {/* Main App Container */} +
+ {/* PORTAL MODE 1: Clinic Practice OS */} + {portalMode === 'clinic' && ( +
+ {clinicTab === 'calendar' && ( + setPortalMode('patient')} + /> + )} + + {clinicTab === 'charting' && ( + setClinicTab('calendar')} + /> + )} + + {clinicTab === 'billing' && ( + setClinicTab('charting')} + onMarkPaid={handleMarkPaid} + /> + )} + + {clinicTab === 'retention' && ( + { + setActivePatient(patient); + const existing = soapNotes.find((s) => s.patientId === patient.id); + setActiveSoapNote(existing); + setClinicTab('charting'); + }} + /> + )} +
+ )} + + {/* PORTAL MODE 2: White-Labeled Patient Booking & Intake */} + {portalMode === 'patient' && ( + + )} + + {/* PORTAL MODE 3: Mediusa Super-Admin Command Center */} + {portalMode === 'superadmin' && ( + + )}
+ + {/* Footer Branding (Mediusa / AI Pilots Ecosystem) */} +
+
+ + Mediusa Clinic OS • Proprietary Practice Management Engine for AI Pilots / Mediusa + + + hello@aipilots.site • HIPAA Certified • Sub-30s Clinical Charting Standard + +
+
); } diff --git a/src/components/admin/SuperAdminView.tsx b/src/components/admin/SuperAdminView.tsx new file mode 100644 index 0000000..ef50a0a --- /dev/null +++ b/src/components/admin/SuperAdminView.tsx @@ -0,0 +1,359 @@ +'use client'; + +import React, { useState } from 'react'; +import { ClinicTenant } from '@/types/clinical'; +import { + Building2, + TrendingUp, + DollarSign, + Users, + Plus, + ExternalLink, + ShieldCheck, + CheckCircle2, + Sparkles, + Zap, + Globe, + Settings, +} from 'lucide-react'; + +interface SuperAdminViewProps { + tenants: ClinicTenant[]; + onAddTenant: (tenant: ClinicTenant) => void; + onSwitchTenant: (tenantId: string) => void; +} + +export const SuperAdminView: React.FC = ({ + tenants, + onAddTenant, + onSwitchTenant, +}) => { + const [showProvisionModal, setShowProvisionModal] = useState(false); + const [newClinicName, setNewClinicName] = useState(''); + const [newSlug, setNewSlug] = useState(''); + const [newDoctorName, setNewDoctorName] = useState(''); + const [newNpi, setNewNpi] = useState(''); + const [newPlan, setNewPlan] = useState<'Starter' | 'Pro Clinic' | 'Multi-Doc Enterprise'>('Pro Clinic'); + const [isProvisioning, setIsProvisioning] = useState(false); + const [provisionSuccess, setProvisionSuccess] = useState(false); + + const totalMRR = tenants.reduce((sum, t) => sum + t.mrr, 0) + 3120; // 24 clinics total simulated + const totalClinics = tenants.length + 21; // 24 active clinics + + const handleNameChange = (val: string) => { + setNewClinicName(val); + setNewSlug( + val + .toLowerCase() + .replace(/[^a-z0-9]/g, '-') + .replace(/-+/g, '-') + .replace(/^-|-$/g, '') + ); + }; + + const handleProvisionSubmit = (e: React.FormEvent) => { + e.preventDefault(); + setIsProvisioning(true); + + setTimeout(() => { + const created: ClinicTenant = { + id: `tenant-${Date.now()}`, + name: newClinicName, + slug: newSlug, + domain: `${newSlug}.mediusa.app`, + phone: '(555) 839-2041', + email: `contact@${newSlug}.com`, + address: '100 Wellness Way, Suite 10', + cityStateZip: 'Irvine, CA 92618', + npi: newNpi || '1992019481', + taxId: '82-9481920', + logoText: newClinicName.slice(0, 10).toUpperCase(), + brandColor: '#0d9488', + accentColor: '#14b8a6', + plan: newPlan, + mrr: newPlan === 'Starter' ? 99 : newPlan === 'Pro Clinic' ? 149 : 199, + stripeConnected: true, + createdAt: new Date().toISOString().split('T')[0], + }; + + onAddTenant(created); + setIsProvisioning(false); + setProvisionSuccess(true); + + setTimeout(() => { + setProvisionSuccess(false); + setShowProvisionModal(false); + onSwitchTenant(created.id); + }, 1200); + }, 1500); + }; + + return ( +
+ {/* Super-Admin Agency Banner */} +
+
+
+ + + + + AI PILOTS / MEDIUSA AGENCY ENGINE + +
+

+ Clinic OS Multi-Tenant Command Center +

+

+ Autonomous Practice Management SaaS Platform. Onboard 20–100+ chiropractic & wellness clinics with zero developer overhead. +

+
+ + +
+ + {/* High-Level SaaS Metrics */} +
+
+
+ Current SaaS MRR + +
+
+ ${totalMRR.toLocaleString()}.00 +
+

+ +$596.00 added this month +

+
+ +
+
+ Target MRR @ 100 Clinics + +
+
$17,900.00
+

Based on $179 avg clinic subscription

+
+ +
+
+ Active Clinic Tenants + +
+
{totalClinics} Clinics
+

100% white-label retention

+
+ +
+
+ Active Patients Managed + +
+
3,842
+

Across California & US clinics

+
+
+ + {/* Active Clinic Tenant Registry */} +
+
+
+

Client Tenant Registry

+

+ Each clinic operates on its isolated schema with custom branding and domain routing. +

+
+ + {tenants.length} Primary Demo Instances Loaded + +
+ +
+ {tenants.map((t) => ( +
+
+
+ +

{t.name}

+ + {t.plan} (${t.mrr}/mo) + + + Stripe Active + +
+ +
+ + + https://{t.domain} + + + NPI: {t.npi} + + EIN: {t.taxId} + + Created: {t.createdAt} +
+
+ +
+ +
+
+ ))} +
+
+ + {/* 60-Second Instant Clinic Provisioning Modal */} + {showProvisionModal && ( +
+
+
+
+ + + +
+

+ 60-Second Instant Clinic Provisioning +

+

+ Creates database tenant, seed templates & custom domain +

+
+
+
+ + {provisionSuccess ? ( +
+ +

Clinic Provisioned Successfully!

+

+ Tenant schema generated. Redirecting to newly created white-labeled instance... +

+
+ ) : ( +
+
+ + handleNameChange(e.target.value)} + className="w-full bg-slate-950 border border-slate-800 rounded-xl p-3 text-slate-200 focus:outline-none focus:border-teal-500" + /> +
+ +
+
+ + setNewSlug(e.target.value)} + className="w-full bg-slate-950 border border-slate-800 rounded-xl p-3 text-slate-200 font-mono focus:outline-none focus:border-teal-500" + /> + + https://{newSlug || 'slug'}.mediusa.app + +
+ +
+ + setNewDoctorName(e.target.value)} + className="w-full bg-slate-950 border border-slate-800 rounded-xl p-3 text-slate-200 focus:outline-none focus:border-teal-500" + /> +
+
+ +
+
+ + setNewNpi(e.target.value)} + className="w-full bg-slate-950 border border-slate-800 rounded-xl p-3 text-slate-200 font-mono focus:outline-none focus:border-teal-500" + /> +
+ +
+ + +
+
+ +
+ + + +
+
+ )} +
+
+ )} +
+ ); +}; diff --git a/src/components/billing/SuperbillView.tsx b/src/components/billing/SuperbillView.tsx new file mode 100644 index 0000000..1471a33 --- /dev/null +++ b/src/components/billing/SuperbillView.tsx @@ -0,0 +1,346 @@ +'use client'; + +import React, { useState } from 'react'; +import { Superbill, ClinicTenant } from '@/types/clinical'; +import { generateSuperbillPdf } from '@/lib/pdf-generator'; +import { + FileText, + Download, + CreditCard, + CheckCircle2, + ShieldAlert, + ArrowLeft, + DollarSign, + Printer, + Sparkles, + ExternalLink, +} from 'lucide-react'; + +interface SuperbillViewProps { + superbill: Superbill; + activeTenant: ClinicTenant; + onBack: () => void; + onMarkPaid: (superbillId: string, method: Superbill['paymentMethod']) => void; +} + +export const SuperbillView: React.FC = ({ + superbill, + activeTenant, + onBack, + onMarkPaid, +}) => { + const [showPaymentModal, setShowPaymentModal] = useState(false); + const [isProcessingStripe, setIsProcessingStripe] = useState(false); + const [paymentSuccess, setPaymentSuccess] = useState(false); + + const handleDownloadPdf = () => { + generateSuperbillPdf(superbill); + }; + + const handleStripePay = (method: Superbill['paymentMethod']) => { + setIsProcessingStripe(true); + setTimeout(() => { + setIsProcessingStripe(false); + setPaymentSuccess(true); + onMarkPaid(superbill.id, method); + setTimeout(() => { + setShowPaymentModal(false); + setPaymentSuccess(false); + }, 1500); + }, 1200); + }; + + return ( +
+ {/* Top Header Bar */} +
+
+ +
+
+

+ Superbill {superbill.invoiceNumber} +

+ + {superbill.balanceDue === 0 ? 'Paid in Full' : 'Balance Due'} + +
+

+ Clean Medical Claim Standard (CMS-1500 / 837P Ready) for {superbill.patientName} +

+
+
+ +
+ + + {superbill.balanceDue > 0 && ( + + )} +
+
+ + {/* Main Printed Superbill Card Simulation */} +
+ {/* Clinic & Statement Header */} +
+
+ + PRACTICE MANAGEMENT SUPERBILL + +

{superbill.clinicName}

+

{superbill.clinicAddress}

+

+ Tax ID / EIN: {superbill.clinicTaxId} • POS:{' '} + {superbill.posCode} +

+
+ +
+
Invoice Number
+
{superbill.invoiceNumber}
+
Date of Service
+
{superbill.dateOfService}
+
+
+ + {/* Provider & Patient 2-Col Info */} +
+ {/* Provider */} +
+

+ Rendering Provider +

+
{superbill.providerName}
+
+ National Provider Identifier (NPI):{' '} + {superbill.providerNpi} +
+
Specialty: Chiropractic Clinical Biomechanics
+
+ + {/* Patient */} +
+

+ Patient Demographics +

+
{superbill.patientName}
+
DOB: {superbill.patientDob}
+
Address: {superbill.patientAddress}
+
+
+ + {/* Diagnosis ICD-10 Section */} +
+

+ Primary Diagnosis Codes (ICD-10-CM) +

+
+ {superbill.icd10Codes.map((icd, index) => ( +
+ + {index + 1} + + {icd.code} + {icd.description} +
+ ))} +
+
+ + {/* Procedures Table */} +
+

+ Rendered Procedures (CPT Codes) +

+
+ + + + + + + + + + + + {superbill.items.map((item) => ( + + + + + + + + ))} + +
CPT CodeService DescriptionUnitsFeeTotal
{item.cptCode}{item.description}{item.units}${item.rate.toFixed(2)} + ${item.total.toFixed(2)} +
+
+
+ + {/* Financial Summary */} +
+
+

+ This Superbill contains all required claim elements (CMS-1500 Boxes 21, 24, 25, 31, 33) + for direct patient submission to their private health insurance or FSA/HSA reimbursement plan. +

+

+ Payment Method: {superbill.paymentMethod} +

+
+ +
+
+ Total Charges: + ${superbill.totalAmount.toFixed(2)} +
+
+ Patient Paid: + -${superbill.patientPaid.toFixed(2)} +
+
+ Balance Due: + ${superbill.balanceDue.toFixed(2)} +
+
+
+
+ + {/* Stripe Payment Modal */} + {showPaymentModal && ( +
+
+
+
+ + + +
+

Stripe Connect Checkout

+

Direct to {activeTenant.name}

+
+
+
+ +
+
+ Amount Due: + + ${superbill.balanceDue.toFixed(2)} + +
+ + {paymentSuccess ? ( +
+ +
Payment Processed Successfully!
+
+ Stripe Charge ID: ch_3P18f92Ksk921 +
+
+ ) : ( + <> + +
+ + + + + +
+ + )} +
+ + {!paymentSuccess && ( +
+ +
+ )} +
+
+ )} +
+ ); +}; diff --git a/src/components/calendar/CalendarView.tsx b/src/components/calendar/CalendarView.tsx new file mode 100644 index 0000000..251525a --- /dev/null +++ b/src/components/calendar/CalendarView.tsx @@ -0,0 +1,237 @@ +'use client'; + +import React, { useState } from 'react'; +import { Appointment, ClinicTenant, Provider } from '@/types/clinical'; +import { + Calendar as CalendarIcon, + Clock, + User, + Plus, + CheckCircle, + AlertCircle, + PlayCircle, + XCircle, + ChevronLeft, + ChevronRight, + Filter, +} from 'lucide-react'; + +interface CalendarViewProps { + appointments: Appointment[]; + providers: Provider[]; + activeTenant: ClinicTenant; + onSelectAppointment: (apt: Appointment) => void; + onUpdateStatus: (aptId: string, status: Appointment['status']) => void; + onNewAppointmentClick: () => void; +} + +export const CalendarView: React.FC = ({ + appointments, + providers, + activeTenant, + onSelectAppointment, + onUpdateStatus, + onNewAppointmentClick, +}) => { + const [selectedProviderId, setSelectedProviderId] = useState('all'); + const [activeDateStr, setActiveDateStr] = useState('2026-09-05'); + + const filteredAppointments = appointments.filter( + (a) => selectedProviderId === 'all' || a.providerId === selectedProviderId + ); + + const getStatusBadge = (status: Appointment['status']) => { + switch (status) { + case 'completed': + return ( + + Completed + + ); + case 'in_room': + return ( + + In Operatory + + ); + case 'arrived': + return ( + + Arrived / Waiting + + ); + case 'confirmed': + return ( + + Confirmed + + ); + case 'booked': + return ( + + Booked + + ); + case 'no_show': + return ( + + No Show + + ); + } + }; + + return ( +
+ {/* Action Header */} +
+
+
+ + + Saturday, September 5, 2026 + + +
+ + {/* Provider Filter */} +
+ + {providers.map((p) => ( + + ))} +
+
+ + +
+ + {/* Grid of Appointments */} +
+ {filteredAppointments.map((apt) => ( +
+
+ {/* Top Row: Time & Status */} +
+
+ + + {apt.time} + + + {apt.durationMinutes} min + +
+ {getStatusBadge(apt.status)} +
+ + {/* Patient & Service Details */} +
+

+ {apt.patientName} +

+

+ {apt.serviceType} +

+
+ Provider: {apt.providerName} + + {apt.room} +
+ + {apt.notes && ( +
+ "{apt.notes}" +
+ )} +
+
+ + {/* Action Bar */} +
+ + +
+ {apt.status === 'booked' && ( + + )} + {apt.status === 'arrived' && ( + + )} + {apt.status === 'in_room' && ( + + )} +
+
+
+ ))} +
+
+ ); +}; diff --git a/src/components/charting/SoapChartEditor.tsx b/src/components/charting/SoapChartEditor.tsx new file mode 100644 index 0000000..1b39d78 --- /dev/null +++ b/src/components/charting/SoapChartEditor.tsx @@ -0,0 +1,478 @@ +'use client'; + +import React, { useState } from 'react'; +import { SoapNote, Patient, Provider, SpinalAdjustmentEntry, CptCodeItem, Icd10CodeItem } from '@/types/clinical'; +import { SpineVisualizer } from '@/components/ui/SpineVisualizer'; +import { AmbientAudioRecorder } from '@/components/ui/AmbientAudioRecorder'; +import { STANDARD_CPT_CODES, STANDARD_ICD10_CODES } from '@/lib/mock-data'; +import { + FileText, + Sparkles, + CheckCircle, + Copy, + PenTool, + Save, + DollarSign, + ChevronLeft, + Tag, + ShieldCheck, + AlertCircle, +} from 'lucide-react'; + +interface SoapChartEditorProps { + patient: Patient; + provider: Provider; + initialSoapNote?: SoapNote; + onSaveSoapNote: (note: SoapNote) => void; + onGenerateSuperbill: (note: SoapNote) => void; + onBackToCalendar: () => void; +} + +export const SoapChartEditor: React.FC = ({ + patient, + provider, + initialSoapNote, + onSaveSoapNote, + onGenerateSuperbill, + onBackToCalendar, +}) => { + const [subjective, setSubjective] = useState( + initialSoapNote?.subjective || + `Patient presents for scheduled visit ${patient.carePlan.completedVisits + 1} of ${ + patient.carePlan.totalVisits + }. Chief complaint: ${patient.chiefComplaint}. VAS pain reported at 4/10.` + ); + const [objective, setObjective] = useState( + initialSoapNote?.objective || + 'Postural examination reveals mild anterior head carriage and unleveling of right iliac crest. Motion palpation identifies segmental hypomobility with paraspinal guarding.' + ); + const [assessment, setAssessment] = useState( + initialSoapNote?.assessment || + 'Segmental and somatic dysfunction of lumbar and cervical spine. Patient progressing steadily toward functional goals outlined in care plan.' + ); + const [plan, setPlan] = useState( + initialSoapNote?.plan || + '1. High velocity low amplitude (HVLA) manipulative therapy delivered to listed subluxations.\n2. Prescribed postural home stabilization exercises.\n3. Return in 3 days for scheduled care plan visit.' + ); + const [adjustments, setAdjustments] = useState( + initialSoapNote?.spinalAdjustments || [ + { vertebra: 'L4', region: 'Lumbar', listing: 'Right Posterior (RP)', technique: 'Diversified' }, + { vertebra: 'Sacrum', region: 'Pelvis/Sacrum', listing: 'Right Sacral Base Anterior', technique: 'Thompson Drop' }, + ] + ); + const [selectedIcd10, setSelectedIcd10] = useState( + initialSoapNote?.icd10Codes || [STANDARD_ICD10_CODES[2], STANDARD_ICD10_CODES[5]] // M99.03 & M54.50 + ); + const [selectedCpt, setSelectedCpt] = useState( + initialSoapNote?.cptCodes || [STANDARD_CPT_CODES[0], STANDARD_CPT_CODES[3]] // 98940 & 97140 + ); + const [vasScore, setVasScore] = useState(initialSoapNote?.vasScore || 3); + const [isSigned, setIsSigned] = useState(initialSoapNote?.status === 'signed'); + const [signedTimestamp, setSignedTimestamp] = useState(initialSoapNote?.signedAt); + + // Ambient AI Scribe callback + const handleApplyExtractedSoap = (data: { + vasScore: number; + subjective: string; + objective: string; + assessment: string; + plan: string; + spinalAdjustments: SpinalAdjustmentEntry[]; + icd10: string[]; + cpt: string[]; + }) => { + setVasScore(data.vasScore); + setSubjective(data.subjective); + setObjective(data.objective); + setAssessment(data.assessment); + setPlan(data.plan); + + if (data.spinalAdjustments && data.spinalAdjustments.length > 0) { + setAdjustments(data.spinalAdjustments); + } + + // Auto map ICD10 + const matchedIcds = STANDARD_ICD10_CODES.filter((icd) => data.icd10.includes(icd.code)); + if (matchedIcds.length > 0) setSelectedIcd10(matchedIcds); + + // Auto map CPT + const matchedCpts = STANDARD_CPT_CODES.filter((cpt) => data.cpt.includes(cpt.code)); + if (matchedCpts.length > 0) setSelectedCpt(matchedCpts); + }; + + const handleToggleAdjustment = (entry: SpinalAdjustmentEntry) => { + setAdjustments((prev) => { + const exists = prev.some((a) => a.vertebra === entry.vertebra); + if (exists) { + return prev.filter((a) => a.vertebra !== entry.vertebra); + } else { + return [...prev, entry]; + } + }); + }; + + const handleCloneLastNote = () => { + setSubjective('Patient reports continued symptom improvement following last spinal adjustment. Morning stiffness resolved within 10 minutes. Current pain rated 3/10.'); + setObjective('Palpation reveals decreased tone in lumbar paraspinals. Persistent fixation noted at L4-L5 with right sacral torsion.'); + setAssessment('Care plan compliance high. Significant restoration of active range of motion noted.'); + setPlan('1. Diversified adjustment delivered to indicated segments.\n2. Manual myofascial release 10 minutes.\n3. Continue active home rehabilitation.'); + }; + + const handleSignChart = () => { + const now = new Date().toISOString(); + setIsSigned(true); + setSignedTimestamp(now); + + const savedNote: SoapNote = { + id: initialSoapNote?.id || `soap-${Date.now()}`, + tenantId: patient.tenantId, + patientId: patient.id, + patientName: `${patient.firstName} ${patient.lastName}`, + providerId: provider.id, + providerName: provider.name, + date: '2026-09-05', + status: 'signed', + vasScore, + subjective, + objective, + assessment, + plan, + spinalAdjustments: adjustments, + icd10Codes: selectedIcd10, + cptCodes: selectedCpt, + signedAt: now, + signedBy: `${provider.name}, ${provider.credentials} (NPI ${provider.npi})`, + }; + + onSaveSoapNote(savedNote); + }; + + const handleCreateSuperbillClick = () => { + const savedNote: SoapNote = { + id: initialSoapNote?.id || `soap-${Date.now()}`, + tenantId: patient.tenantId, + patientId: patient.id, + patientName: `${patient.firstName} ${patient.lastName}`, + providerId: provider.id, + providerName: provider.name, + date: '2026-09-05', + status: isSigned ? 'signed' : 'draft', + vasScore, + subjective, + objective, + assessment, + plan, + spinalAdjustments: adjustments, + icd10Codes: selectedIcd10, + cptCodes: selectedCpt, + signedAt: signedTimestamp, + signedBy: `${provider.name}, ${provider.credentials}`, + }; + + onGenerateSuperbill(savedNote); + }; + + return ( +
+ {/* Top Breadcrumb & Patient Header */} +
+
+ + +
+
+

+ {patient.firstName} {patient.lastName} +

+ + Care Plan: Visit {patient.carePlan.completedVisits + 1} of {patient.carePlan.totalVisits} + + {isSigned ? ( + + Signed & Locked + + ) : ( + + In Progress (Draft) + + )} +
+ +
+ DOB: {patient.dob} + + Insurance: {patient.insuranceName} + + Attending: {provider.name} +
+
+
+ + {/* Action buttons */} +
+ + + + + +
+
+ + {/* Ambient AI Clinical Scribe Section */} + + + {/* 2D Spine Visualizer Subluxation Clicker */} + + + {/* Structured SOAP Fields Grid */} +
+ {/* Subjective */} +
+
+
+ + + S + + Subjective Complaint & History + + VAS: {vasScore}/10 +
+