diff --git a/app/assets/css/main.css b/app/assets/css/main.css
index 16bfeb1..ca8d126 100644
--- a/app/assets/css/main.css
+++ b/app/assets/css/main.css
@@ -222,4 +222,39 @@
.tiptap p.is-empty:not(:first-child)::before {
content: none;
+}
+
+/* Style tiptap task list checkboxes to match Nuxt UI */
+.tiptap ul[data-type="taskList"] {
+ list-style: none;
+ padding-left: 0;
+}
+
+.tiptap ul[data-type="taskList"] li {
+ display: flex;
+ align-items: flex-start;
+ gap: 0.5rem;
+}
+
+.tiptap ul[data-type="taskList"] li > label {
+ margin-top: 2px;
+ flex-shrink: 0;
+}
+
+.tiptap ul[data-type="taskList"] li > label input[type="checkbox"] {
+ width: 1rem;
+ height: 1rem;
+ border-radius: 4px;
+ border: 1.5px solid #d1d5db;
+ cursor: pointer;
+ accent-color: var(--color-primary-500);
+}
+
+.tiptap ul[data-type="taskList"] li > div {
+ flex: 1;
+}
+
+.tiptap ul[data-type="taskList"] li[data-checked="true"] > div {
+ text-decoration: line-through;
+ color: #9ca3af;
}
\ No newline at end of file
diff --git a/app/components/AttendanceDropdown.vue b/app/components/AttendanceDropdown.vue
new file mode 100644
index 0000000..960c05d
--- /dev/null
+++ b/app/components/AttendanceDropdown.vue
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
diff --git a/app/components/Notes.vue b/app/components/Notes.vue
index b0dc254..98d0586 100644
--- a/app/components/Notes.vue
+++ b/app/components/Notes.vue
@@ -1,5 +1,7 @@
@@ -71,24 +61,25 @@ const items: EditorToolbarItem[][] = [
v-model="localContent"
:content-type="contentType || 'markdown'"
placeholder="Start typing your clinical notes here..."
- class="flex min-h-0 flex-1 flex-col overflow-hidden prose prose-sm sm:prose text-left dark:prose-invert"
- :class="sizeClassMap[selectedSize]"
+ class="flex flex-col flex-1 min-h-0 prose prose-sm sm:prose text-left dark:prose-invert"
>
-
-
-
-
+
+
+
diff --git a/app/pages/notes-test.vue b/app/pages/notes-test.vue
index 83be2aa..2e2a7bf 100644
--- a/app/pages/notes-test.vue
+++ b/app/pages/notes-test.vue
@@ -31,6 +31,15 @@
return clientPickerOptions.value[0]?.id ?? ''
})
+ type NotesEditorData = {
+ client: { id: string; name: string }
+ currentNote: { id: number; date: string; content: string }
+ previousNotes: { id: number; date: string; preview: string; content: string }[]
+ sessionNotes: { id: string; content: string; createdAt: string }[]
+ forms: { label?: string; status: 'complete' | 'pending' }[]
+ appointments?: { id: string; sessionName: string; sessionNumber: number; startTime: string; status: string }[]
+ }
+
const { data, pending, error } = await useFetch(
() => `/api/clients/${clientId.value}/notes-editor-data`,
{
@@ -84,7 +93,7 @@
:previous-notes="data.previousNotes"
:session-notes="data.sessionNotes"
:appointments="data.appointments"
- :forms="data.forms"
+ :forms="(data.forms as { label: string; status: 'complete' | 'pending' }[]).filter(f => !!f.label)"
:client-picker-options="clientPickerOptions"
client-picker-mode="notes-test"
back-href="/"
diff --git a/nuxt.config.ts b/nuxt.config.ts
index 8f578a6..051867c 100644
--- a/nuxt.config.ts
+++ b/nuxt.config.ts
@@ -41,5 +41,13 @@ export default defineNuxtConfig({
'prosemirror-transform',
],
},
+ optimizeDeps: {
+ include: [
+ '@vue/devtools-core',
+ '@vue/devtools-kit',
+ 'better-auth/vue',
+ 'better-auth/client/plugins',
+ ]
+ },
},
})
diff --git a/prisma/migrations/20260127013856_init/migration.sql b/prisma/migrations/20260127013856_init/migration.sql
deleted file mode 100644
index b547781..0000000
--- a/prisma/migrations/20260127013856_init/migration.sql
+++ /dev/null
@@ -1,66 +0,0 @@
--- CreateTable
-CREATE TABLE "user" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "name" TEXT NOT NULL,
- "email" TEXT NOT NULL,
- "emailVerified" BOOLEAN NOT NULL DEFAULT false,
- "image" TEXT,
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "updatedAt" DATETIME NOT NULL
-);
-
--- CreateTable
-CREATE TABLE "session" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "expiresAt" DATETIME NOT NULL,
- "token" TEXT NOT NULL,
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "updatedAt" DATETIME NOT NULL,
- "ipAddress" TEXT,
- "userAgent" TEXT,
- "userId" TEXT NOT NULL,
- CONSTRAINT "session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "account" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "accountId" TEXT NOT NULL,
- "providerId" TEXT NOT NULL,
- "userId" TEXT NOT NULL,
- "accessToken" TEXT,
- "refreshToken" TEXT,
- "idToken" TEXT,
- "accessTokenExpiresAt" DATETIME,
- "refreshTokenExpiresAt" DATETIME,
- "scope" TEXT,
- "password" TEXT,
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "updatedAt" DATETIME NOT NULL,
- CONSTRAINT "account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "verification" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "identifier" TEXT NOT NULL,
- "value" TEXT NOT NULL,
- "expiresAt" DATETIME NOT NULL,
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "updatedAt" DATETIME NOT NULL
-);
-
--- CreateIndex
-CREATE UNIQUE INDEX "user_email_key" ON "user"("email");
-
--- CreateIndex
-CREATE INDEX "session_userId_idx" ON "session"("userId");
-
--- CreateIndex
-CREATE UNIQUE INDEX "session_token_key" ON "session"("token");
-
--- CreateIndex
-CREATE INDEX "account_userId_idx" ON "account"("userId");
-
--- CreateIndex
-CREATE INDEX "verification_identifier_idx" ON "verification"("identifier");
diff --git a/prisma/migrations/20260314154429/migration.sql b/prisma/migrations/20260314154429/migration.sql
deleted file mode 100644
index 57888dd..0000000
--- a/prisma/migrations/20260314154429/migration.sql
+++ /dev/null
@@ -1,374 +0,0 @@
--- CreateTable
-CREATE TABLE "client" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "userId" TEXT NOT NULL,
- "status" TEXT NOT NULL DEFAULT 'INCOMPLETE',
- "therapyWeek" INTEGER,
- "missedSessions" INTEGER NOT NULL DEFAULT 0,
- CONSTRAINT "client_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "client_permission" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "clientId" TEXT NOT NULL,
- "canViewScores" BOOLEAN NOT NULL DEFAULT false,
- "canViewNotes" BOOLEAN NOT NULL DEFAULT false,
- "canViewPlan" BOOLEAN NOT NULL DEFAULT false,
- CONSTRAINT "client_permission_clientId_fkey" FOREIGN KEY ("clientId") REFERENCES "client" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "session_note" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "clientId" TEXT NOT NULL,
- "content" TEXT NOT NULL,
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- CONSTRAINT "session_note_clientId_fkey" FOREIGN KEY ("clientId") REFERENCES "client" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "client_plan" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "clientId" TEXT NOT NULL,
- "content" TEXT NOT NULL DEFAULT '',
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "updatedAt" DATETIME NOT NULL,
- CONSTRAINT "client_plan_clientId_fkey" FOREIGN KEY ("clientId") REFERENCES "client" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "form" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "title" TEXT NOT NULL,
- "description" TEXT,
- "slug" TEXT NOT NULL,
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "updatedAt" DATETIME NOT NULL
-);
-
--- CreateTable
-CREATE TABLE "question" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "text" TEXT NOT NULL,
- "type" TEXT NOT NULL,
- "alias" TEXT NOT NULL,
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "updatedAt" DATETIME NOT NULL
-);
-
--- CreateTable
-CREATE TABLE "form_question" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "formId" TEXT NOT NULL,
- "questionId" TEXT NOT NULL,
- "order" INTEGER NOT NULL,
- CONSTRAINT "form_question_questionId_fkey" FOREIGN KEY ("questionId") REFERENCES "question" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "form_question_formId_fkey" FOREIGN KEY ("formId") REFERENCES "form" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "form_assignment" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "userId" TEXT NOT NULL,
- "formId" TEXT NOT NULL,
- "assignedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "completedAt" DATETIME,
- CONSTRAINT "form_assignment_formId_fkey" FOREIGN KEY ("formId") REFERENCES "form" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "form_assignment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "ace_response" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "userId" TEXT NOT NULL,
- "responses" TEXT NOT NULL,
- "completedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- CONSTRAINT "ace_response_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "AppForm" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "userId" TEXT NOT NULL,
- "status" TEXT NOT NULL DEFAULT 'IN_PROGRESS',
- "submittedAt" DATETIME,
- CONSTRAINT "AppForm_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "AppQuestion" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "formId" INTEGER NOT NULL,
- "userId" TEXT NOT NULL,
- "q01" TEXT,
- "q02" TEXT,
- "q03" TEXT,
- "q04" TEXT,
- "q05" TEXT,
- "q06" TEXT,
- "q07" TEXT,
- "q08" TEXT,
- "q09" TEXT,
- "q10" TEXT,
- "q11" TEXT,
- "q12" TEXT,
- "q13" TEXT,
- "q14" TEXT,
- "q15" TEXT,
- "q16" TEXT,
- "q17" TEXT,
- "q18" TEXT,
- "q19" TEXT,
- "q20" TEXT,
- "q21" TEXT,
- "q22" TEXT,
- "q23" TEXT,
- "q24" TEXT,
- "q25" TEXT,
- "q26" TEXT,
- "q27" TEXT,
- "q28" TEXT,
- "q29" TEXT,
- "q30" TEXT,
- "q31" TEXT,
- "q32" TEXT,
- "q33" TEXT,
- "q34" TEXT,
- "q35" TEXT,
- "q36" TEXT,
- "q37" TEXT,
- "q38" TEXT,
- "q39" TEXT,
- "q40" TEXT,
- "q41" TEXT,
- "q42" TEXT,
- "q43" TEXT,
- "q44" TEXT,
- "q45" TEXT,
- "q46" TEXT,
- "q47" TEXT,
- "q48" TEXT,
- "q49" TEXT,
- "q50" TEXT,
- CONSTRAINT "AppQuestion_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "AppQuestion_formId_fkey" FOREIGN KEY ("formId") REFERENCES "AppForm" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "GadForm" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "userId" TEXT NOT NULL,
- "status" TEXT NOT NULL DEFAULT 'IN_PROGRESS',
- "totalScore" INTEGER,
- "severity" TEXT,
- "submittedAt" DATETIME,
- CONSTRAINT "GadForm_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "GadQuestion" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "formId" INTEGER NOT NULL,
- "userId" TEXT NOT NULL,
- "g01" INTEGER,
- "g02" INTEGER,
- "g03" INTEGER,
- "g04" INTEGER,
- "g05" INTEGER,
- "g06" INTEGER,
- "g07" INTEGER,
- "g08" INTEGER,
- CONSTRAINT "GadQuestion_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "GadQuestion_formId_fkey" FOREIGN KEY ("formId") REFERENCES "GadForm" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "PhqForm" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "userId" TEXT NOT NULL,
- "status" TEXT NOT NULL DEFAULT 'IN_PROGRESS',
- "totalScore" INTEGER,
- "submittedAt" DATETIME,
- "severity" TEXT,
- CONSTRAINT "PhqForm_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "PhqQuestion" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "formId" INTEGER NOT NULL,
- "userId" TEXT NOT NULL,
- "q1" INTEGER,
- "q2" INTEGER,
- "q3" INTEGER,
- "q4" INTEGER,
- "q5" INTEGER,
- "q6" INTEGER,
- "q7" INTEGER,
- "q8" INTEGER,
- "q9" INTEGER,
- "q10" INTEGER,
- CONSTRAINT "PhqQuestion_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "PhqQuestion_formId_fkey" FOREIGN KEY ("formId") REFERENCES "PhqForm" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "PclForm" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "userId" TEXT NOT NULL,
- "status" TEXT NOT NULL DEFAULT 'IN_PROGRESS',
- "submittedAt" DATETIME,
- "severity" TEXT,
- "totalScore" INTEGER,
- CONSTRAINT "PclForm_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "PclQuestion" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "formId" INTEGER NOT NULL,
- "userId" TEXT NOT NULL,
- "q01" INTEGER,
- "q02" INTEGER,
- "q03" INTEGER,
- "q04" INTEGER,
- "q05" INTEGER,
- "q06" INTEGER,
- "q07" INTEGER,
- "q08" INTEGER,
- "q09" INTEGER,
- "q10" INTEGER,
- "q11" INTEGER,
- "q12" INTEGER,
- "q13" INTEGER,
- "q14" INTEGER,
- "q15" INTEGER,
- "q16" INTEGER,
- "q17" INTEGER,
- "q18" INTEGER,
- "q19" INTEGER,
- "q20" INTEGER,
- CONSTRAINT "PclQuestion_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "PclQuestion_formId_fkey" FOREIGN KEY ("formId") REFERENCES "PclForm" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "change_audit" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "entityType" TEXT NOT NULL,
- "entityId" TEXT NOT NULL,
- "oldValue" TEXT,
- "newValue" TEXT,
- "reasoning" TEXT,
- "documentationBase64" TEXT,
- "signatureData" TEXT NOT NULL,
- "signedById" TEXT NOT NULL,
- "signedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- CONSTRAINT "change_audit_signedById_fkey" FOREIGN KEY ("signedById") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- RedefineTables
-PRAGMA defer_foreign_keys=ON;
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_user" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "name" TEXT NOT NULL,
- "email" TEXT NOT NULL,
- "emailVerified" BOOLEAN NOT NULL DEFAULT false,
- "image" TEXT,
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "updatedAt" DATETIME NOT NULL,
- "role" TEXT NOT NULL DEFAULT 'CLIENT',
- "phoneNumber" INTEGER
-);
-INSERT INTO "new_user" ("createdAt", "email", "emailVerified", "id", "image", "name", "updatedAt") SELECT "createdAt", "email", "emailVerified", "id", "image", "name", "updatedAt" FROM "user";
-DROP TABLE "user";
-ALTER TABLE "new_user" RENAME TO "user";
-CREATE UNIQUE INDEX "user_email_key" ON "user"("email");
-PRAGMA foreign_keys=ON;
-PRAGMA defer_foreign_keys=OFF;
-
--- CreateIndex
-CREATE UNIQUE INDEX "client_userId_key" ON "client"("userId");
-
--- CreateIndex
-CREATE INDEX "client_status_idx" ON "client"("status");
-
--- CreateIndex
-CREATE UNIQUE INDEX "client_permission_clientId_key" ON "client_permission"("clientId");
-
--- CreateIndex
-CREATE INDEX "session_note_clientId_idx" ON "session_note"("clientId");
-
--- CreateIndex
-CREATE UNIQUE INDEX "client_plan_clientId_key" ON "client_plan"("clientId");
-
--- CreateIndex
-CREATE UNIQUE INDEX "form_slug_key" ON "form"("slug");
-
--- CreateIndex
-CREATE UNIQUE INDEX "question_alias_key" ON "question"("alias");
-
--- CreateIndex
-CREATE INDEX "form_question_formId_idx" ON "form_question"("formId");
-
--- CreateIndex
-CREATE INDEX "form_question_questionId_idx" ON "form_question"("questionId");
-
--- CreateIndex
-CREATE UNIQUE INDEX "form_question_formId_questionId_key" ON "form_question"("formId", "questionId");
-
--- CreateIndex
-CREATE INDEX "form_assignment_userId_idx" ON "form_assignment"("userId");
-
--- CreateIndex
-CREATE INDEX "form_assignment_formId_idx" ON "form_assignment"("formId");
-
--- CreateIndex
-CREATE UNIQUE INDEX "form_assignment_userId_formId_key" ON "form_assignment"("userId", "formId");
-
--- CreateIndex
-CREATE INDEX "ace_response_userId_idx" ON "ace_response"("userId");
-
--- CreateIndex
-CREATE UNIQUE INDEX "AppForm_userId_key" ON "AppForm"("userId");
-
--- CreateIndex
-CREATE UNIQUE INDEX "AppQuestion_formId_key" ON "AppQuestion"("formId");
-
--- CreateIndex
-CREATE INDEX "AppQuestion_userId_idx" ON "AppQuestion"("userId");
-
--- CreateIndex
-CREATE INDEX "GadForm_userId_idx" ON "GadForm"("userId");
-
--- CreateIndex
-CREATE UNIQUE INDEX "GadQuestion_formId_key" ON "GadQuestion"("formId");
-
--- CreateIndex
-CREATE INDEX "GadQuestion_userId_idx" ON "GadQuestion"("userId");
-
--- CreateIndex
-CREATE UNIQUE INDEX "PhqForm_userId_key" ON "PhqForm"("userId");
-
--- CreateIndex
-CREATE INDEX "PhqForm_userId_idx" ON "PhqForm"("userId");
-
--- CreateIndex
-CREATE UNIQUE INDEX "PhqQuestion_formId_key" ON "PhqQuestion"("formId");
-
--- CreateIndex
-CREATE INDEX "PhqQuestion_userId_idx" ON "PhqQuestion"("userId");
-
--- CreateIndex
-CREATE INDEX "PclForm_userId_idx" ON "PclForm"("userId");
-
--- CreateIndex
-CREATE UNIQUE INDEX "PclQuestion_formId_key" ON "PclQuestion"("formId");
-
--- CreateIndex
-CREATE INDEX "PclQuestion_userId_idx" ON "PclQuestion"("userId");
-
--- CreateIndex
-CREATE INDEX "change_audit_entityType_entityId_idx" ON "change_audit"("entityType", "entityId");
diff --git a/prisma/migrations/20260402034332_consolidate_notes_and_split_schemas/migration.sql b/prisma/migrations/20260402034332_consolidate_notes_and_split_schemas/migration.sql
deleted file mode 100644
index e59221e..0000000
--- a/prisma/migrations/20260402034332_consolidate_notes_and_split_schemas/migration.sql
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the column `documentationBase64` on the `change_audit` table. All the data in the column will be lost.
-
-*/
--- AlterTable
-ALTER TABLE "PclQuestion" ADD COLUMN "worstEvent" TEXT;
-
--- CreateTable
-CREATE TABLE "Appointment" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "clientId" TEXT NOT NULL,
- "adminId" TEXT NOT NULL,
- "title" TEXT NOT NULL,
- "description" TEXT,
- "startTime" DATETIME NOT NULL,
- "endTime" DATETIME NOT NULL,
- "status" TEXT NOT NULL DEFAULT 'SCHEDULED',
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "updatedAt" DATETIME NOT NULL,
- CONSTRAINT "Appointment_clientId_fkey" FOREIGN KEY ("clientId") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
- CONSTRAINT "Appointment_adminId_fkey" FOREIGN KEY ("adminId") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "PhysicianStatementForm" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "userId" TEXT NOT NULL,
- "status" TEXT NOT NULL DEFAULT 'NOT_SUBMITTED',
- "originalFileName" TEXT,
- "storedFileName" TEXT,
- "mimeType" TEXT,
- "uploadedAt" DATETIME,
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "updatedAt" DATETIME NOT NULL,
- CONSTRAINT "PhysicianStatementForm_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "ReleaseOfInformationAuthorizationForm" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "userId" TEXT NOT NULL,
- "status" TEXT NOT NULL DEFAULT 'NOT_SUBMITTED',
- "originalFileName" TEXT,
- "storedFileName" TEXT,
- "mimeType" TEXT,
- "uploadedAt" DATETIME,
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "updatedAt" DATETIME NOT NULL,
- CONSTRAINT "ReleaseOfInformationAuthorizationForm_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "session_note_edit" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "sessionNoteId" TEXT NOT NULL,
- "originalContent" TEXT,
- "reason" TEXT,
- "signature" TEXT,
- "editedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- CONSTRAINT "session_note_edit_sessionNoteId_fkey" FOREIGN KEY ("sessionNoteId") REFERENCES "session_note" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "declaration_template" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "requestKind" TEXT NOT NULL,
- "version" INTEGER NOT NULL,
- "content" TEXT NOT NULL,
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
-);
-
--- CreateTable
-CREATE TABLE "session_notes_request" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "clientId" TEXT NOT NULL,
- "requestKind" TEXT NOT NULL,
- "status" TEXT NOT NULL DEFAULT 'PENDING',
- "signatureData" TEXT NOT NULL,
- "declarationTemplateId" TEXT NOT NULL,
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "decidedAt" DATETIME,
- "decidedByUserId" TEXT,
- "rejectionReason" TEXT,
- "approvedSummaryText" TEXT,
- CONSTRAINT "session_notes_request_clientId_fkey" FOREIGN KEY ("clientId") REFERENCES "client" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "session_notes_request_declarationTemplateId_fkey" FOREIGN KEY ("declarationTemplateId") REFERENCES "declaration_template" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
- CONSTRAINT "session_notes_request_decidedByUserId_fkey" FOREIGN KEY ("decidedByUserId") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE
-);
-
--- RedefineTables
-PRAGMA defer_foreign_keys=ON;
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_change_audit" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "entityType" TEXT NOT NULL,
- "entityId" TEXT NOT NULL,
- "oldValue" TEXT,
- "newValue" TEXT,
- "reasoning" TEXT,
- "documentationPath" TEXT,
- "documentationName" TEXT,
- "signatureData" TEXT NOT NULL,
- "signedById" TEXT NOT NULL,
- "signedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- CONSTRAINT "change_audit_signedById_fkey" FOREIGN KEY ("signedById") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-INSERT INTO "new_change_audit" ("entityId", "entityType", "id", "newValue", "oldValue", "reasoning", "signatureData", "signedAt", "signedById") SELECT "entityId", "entityType", "id", "newValue", "oldValue", "reasoning", "signatureData", "signedAt", "signedById" FROM "change_audit";
-DROP TABLE "change_audit";
-ALTER TABLE "new_change_audit" RENAME TO "change_audit";
-CREATE INDEX "change_audit_entityType_entityId_idx" ON "change_audit"("entityType", "entityId");
-PRAGMA foreign_keys=ON;
-PRAGMA defer_foreign_keys=OFF;
-
--- CreateIndex
-CREATE INDEX "Appointment_clientId_idx" ON "Appointment"("clientId");
-
--- CreateIndex
-CREATE INDEX "Appointment_adminId_idx" ON "Appointment"("adminId");
-
--- CreateIndex
-CREATE UNIQUE INDEX "PhysicianStatementForm_userId_key" ON "PhysicianStatementForm"("userId");
-
--- CreateIndex
-CREATE INDEX "PhysicianStatementForm_status_idx" ON "PhysicianStatementForm"("status");
-
--- CreateIndex
-CREATE UNIQUE INDEX "ReleaseOfInformationAuthorizationForm_userId_key" ON "ReleaseOfInformationAuthorizationForm"("userId");
-
--- CreateIndex
-CREATE INDEX "ReleaseOfInformationAuthorizationForm_status_idx" ON "ReleaseOfInformationAuthorizationForm"("status");
-
--- CreateIndex
-CREATE INDEX "session_note_edit_sessionNoteId_idx" ON "session_note_edit"("sessionNoteId");
-
--- CreateIndex
-CREATE UNIQUE INDEX "declaration_template_requestKind_version_key" ON "declaration_template"("requestKind", "version");
-
--- CreateIndex
-CREATE INDEX "session_notes_request_clientId_idx" ON "session_notes_request"("clientId");
-
--- CreateIndex
-CREATE INDEX "session_notes_request_status_idx" ON "session_notes_request"("status");
-
--- CreateIndex
-CREATE INDEX "session_notes_request_declarationTemplateId_idx" ON "session_notes_request"("declarationTemplateId");
diff --git a/prisma/migrations/20260402035909_remove_dynamic_forms/migration.sql b/prisma/migrations/20260402035909_remove_dynamic_forms/migration.sql
deleted file mode 100644
index 21cc75c..0000000
--- a/prisma/migrations/20260402035909_remove_dynamic_forms/migration.sql
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the `form` table. If the table is not empty, all the data it contains will be lost.
- - You are about to drop the `form_assignment` table. If the table is not empty, all the data it contains will be lost.
- - You are about to drop the `form_question` table. If the table is not empty, all the data it contains will be lost.
- - You are about to drop the `question` table. If the table is not empty, all the data it contains will be lost.
-
-*/
--- DropTable
-PRAGMA foreign_keys=off;
-DROP TABLE "form";
-PRAGMA foreign_keys=on;
-
--- DropTable
-PRAGMA foreign_keys=off;
-DROP TABLE "form_assignment";
-PRAGMA foreign_keys=on;
-
--- DropTable
-PRAGMA foreign_keys=off;
-DROP TABLE "form_question";
-PRAGMA foreign_keys=on;
-
--- DropTable
-PRAGMA foreign_keys=off;
-DROP TABLE "question";
-PRAGMA foreign_keys=on;
diff --git a/prisma/migrations/20260402041509_hardcode_ace_form/migration.sql b/prisma/migrations/20260402041509_hardcode_ace_form/migration.sql
deleted file mode 100644
index 575593d..0000000
--- a/prisma/migrations/20260402041509_hardcode_ace_form/migration.sql
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the `ace_response` table. If the table is not empty, all the data it contains will be lost.
-
-*/
--- DropTable
-PRAGMA foreign_keys=off;
-DROP TABLE "ace_response";
-PRAGMA foreign_keys=on;
-
--- CreateTable
-CREATE TABLE "ace_form" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "userId" TEXT NOT NULL,
- "status" TEXT NOT NULL DEFAULT 'IN_PROGRESS',
- "totalScore" INTEGER,
- "severity" TEXT,
- "submittedAt" DATETIME,
- CONSTRAINT "ace_form_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "ace_question" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "formId" INTEGER NOT NULL,
- "userId" TEXT NOT NULL,
- "a01" TEXT,
- "a02" TEXT,
- "a03" TEXT,
- "a04" TEXT,
- "a05" TEXT,
- "a06" TEXT,
- "a07" TEXT,
- "a08" TEXT,
- "a09" TEXT,
- "a10" TEXT,
- CONSTRAINT "ace_question_formId_fkey" FOREIGN KEY ("formId") REFERENCES "ace_form" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "ace_question_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateIndex
-CREATE UNIQUE INDEX "ace_form_userId_key" ON "ace_form"("userId");
-
--- CreateIndex
-CREATE INDEX "ace_form_userId_idx" ON "ace_form"("userId");
-
--- CreateIndex
-CREATE UNIQUE INDEX "ace_question_formId_key" ON "ace_question"("formId");
-
--- CreateIndex
-CREATE INDEX "ace_question_userId_idx" ON "ace_question"("userId");
diff --git a/prisma/migrations/20260426215909_add_client_clinician_user_id/migration.sql b/prisma/migrations/20260426215909_add_client_clinician_user_id/migration.sql
deleted file mode 100644
index edb850a..0000000
--- a/prisma/migrations/20260426215909_add_client_clinician_user_id/migration.sql
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- Warnings:
-
- - You are about to drop the `ace_form` table. If the table is not empty, all the data it contains will be lost.
- - You are about to drop the `ace_question` table. If the table is not empty, all the data it contains will be lost.
- - Added the required column `sessionName` to the `Appointment` table without a default value. This is not possible if the table is not empty.
- - Added the required column `sessionNumber` to the `Appointment` table without a default value. This is not possible if the table is not empty.
- - Added the required column `sessionName` to the `session_note` table without a default value. This is not possible if the table is not empty.
- - Added the required column `sessionNumber` to the `session_note` table without a default value. This is not possible if the table is not empty.
-
-*/
--- DropIndex
-DROP INDEX "PhqForm_userId_key";
-
--- DropIndex
-DROP INDEX "ace_form_userId_idx";
-
--- DropIndex
-DROP INDEX "ace_form_userId_key";
-
--- DropIndex
-DROP INDEX "ace_question_userId_idx";
-
--- DropIndex
-DROP INDEX "ace_question_formId_key";
-
--- AlterTable
-ALTER TABLE "session_notes_request" ADD COLUMN "approvalReason" TEXT;
-ALTER TABLE "session_notes_request" ADD COLUMN "endDate" DATETIME;
-ALTER TABLE "session_notes_request" ADD COLUMN "startDate" DATETIME;
-
--- DropTable
-PRAGMA foreign_keys=off;
-DROP TABLE "ace_form";
-PRAGMA foreign_keys=on;
-
--- DropTable
-PRAGMA foreign_keys=off;
-DROP TABLE "ace_question";
-PRAGMA foreign_keys=on;
-
--- CreateTable
-CREATE TABLE "client_form_score_history" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "userId" TEXT NOT NULL,
- "formKey" TEXT NOT NULL,
- "score" INTEGER,
- "severity" TEXT,
- "recordedAt" DATETIME NOT NULL,
- "answersJson" TEXT,
- CONSTRAINT "client_form_score_history_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "AceForm" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "userId" TEXT NOT NULL,
- "status" TEXT NOT NULL DEFAULT 'IN_PROGRESS',
- "totalScore" INTEGER,
- "severity" TEXT,
- "submittedAt" DATETIME,
- CONSTRAINT "AceForm_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "AceQuestion" (
- "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- "formId" INTEGER NOT NULL,
- "userId" TEXT NOT NULL,
- "a01" TEXT,
- "a02" TEXT,
- "a03" TEXT,
- "a04" TEXT,
- "a05" TEXT,
- "a06" TEXT,
- "a07" TEXT,
- "a08" TEXT,
- "a09" TEXT,
- "a10" TEXT,
- CONSTRAINT "AceQuestion_formId_fkey" FOREIGN KEY ("formId") REFERENCES "AceForm" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "AceQuestion_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- CreateTable
-CREATE TABLE "notification" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "userId" TEXT NOT NULL,
- "type" TEXT NOT NULL,
- "title" TEXT NOT NULL,
- "message" TEXT NOT NULL,
- "sessionNoteId" TEXT,
- "readAt" DATETIME,
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- CONSTRAINT "notification_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "notification_sessionNoteId_fkey" FOREIGN KEY ("sessionNoteId") REFERENCES "session_note" ("id") ON DELETE CASCADE ON UPDATE CASCADE
-);
-
--- RedefineTables
-PRAGMA defer_foreign_keys=ON;
-PRAGMA foreign_keys=OFF;
-CREATE TABLE "new_Appointment" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "clientId" TEXT NOT NULL,
- "adminId" TEXT NOT NULL,
- "title" TEXT NOT NULL,
- "sessionName" TEXT NOT NULL,
- "sessionNumber" INTEGER NOT NULL,
- "description" TEXT,
- "startTime" DATETIME NOT NULL,
- "endTime" DATETIME NOT NULL,
- "status" TEXT NOT NULL DEFAULT 'SCHEDULED',
- "videoProvider" TEXT,
- "videoJoinUrl" TEXT,
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "updatedAt" DATETIME NOT NULL,
- CONSTRAINT "Appointment_clientId_fkey" FOREIGN KEY ("clientId") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
- CONSTRAINT "Appointment_adminId_fkey" FOREIGN KEY ("adminId") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
-);
-INSERT INTO "new_Appointment" ("adminId", "clientId", "createdAt", "description", "endTime", "id", "startTime", "status", "title", "updatedAt") SELECT "adminId", "clientId", "createdAt", "description", "endTime", "id", "startTime", "status", "title", "updatedAt" FROM "Appointment";
-DROP TABLE "Appointment";
-ALTER TABLE "new_Appointment" RENAME TO "Appointment";
-CREATE INDEX "Appointment_clientId_idx" ON "Appointment"("clientId");
-CREATE INDEX "Appointment_adminId_idx" ON "Appointment"("adminId");
-CREATE UNIQUE INDEX "Appointment_clientId_sessionNumber_key" ON "Appointment"("clientId", "sessionNumber");
-CREATE TABLE "new_client" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "userId" TEXT NOT NULL,
- "status" TEXT NOT NULL DEFAULT 'INCOMPLETE',
- "waitlistedAt" DATETIME,
- "archivedAt" DATETIME,
- "therapyWeek" INTEGER,
- "missedSessions" INTEGER NOT NULL DEFAULT 0,
- "clinicianUserId" TEXT,
- CONSTRAINT "client_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "client_clinicianUserId_fkey" FOREIGN KEY ("clinicianUserId") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE
-);
-INSERT INTO "new_client" ("id", "missedSessions", "status", "therapyWeek", "userId") SELECT "id", "missedSessions", "status", "therapyWeek", "userId" FROM "client";
-DROP TABLE "client";
-ALTER TABLE "new_client" RENAME TO "client";
-CREATE UNIQUE INDEX "client_userId_key" ON "client"("userId");
-CREATE INDEX "client_status_idx" ON "client"("status");
-CREATE INDEX "client_clinicianUserId_idx" ON "client"("clinicianUserId");
-CREATE TABLE "new_session_note" (
- "id" TEXT NOT NULL PRIMARY KEY,
- "clientId" TEXT NOT NULL,
- "sessionName" TEXT NOT NULL,
- "sessionNumber" INTEGER NOT NULL,
- "appointmentId" TEXT,
- "kind" TEXT NOT NULL DEFAULT 'PROGRESS',
- "status" TEXT NOT NULL DEFAULT 'DRAFT',
- "content" TEXT NOT NULL,
- "attended" BOOLEAN NOT NULL DEFAULT true,
- "signatureData" TEXT,
- "clinicianSignedAt" DATETIME,
- "clinicianSignedById" TEXT,
- "clinicianSignatureData" TEXT,
- "adminSignedAt" DATETIME,
- "adminSignedById" TEXT,
- "adminSignatureData" TEXT,
- "adminApprovalNote" TEXT,
- "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "updatedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- CONSTRAINT "session_note_clientId_fkey" FOREIGN KEY ("clientId") REFERENCES "client" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "session_note_appointmentId_fkey" FOREIGN KEY ("appointmentId") REFERENCES "Appointment" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
- CONSTRAINT "session_note_clinicianSignedById_fkey" FOREIGN KEY ("clinicianSignedById") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
- CONSTRAINT "session_note_adminSignedById_fkey" FOREIGN KEY ("adminSignedById") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE
-);
-INSERT INTO "new_session_note" ("clientId", "content", "createdAt", "id") SELECT "clientId", "content", "createdAt", "id" FROM "session_note";
-DROP TABLE "session_note";
-ALTER TABLE "new_session_note" RENAME TO "session_note";
-CREATE INDEX "session_note_clientId_idx" ON "session_note"("clientId");
-CREATE INDEX "session_note_appointmentId_idx" ON "session_note"("appointmentId");
-CREATE INDEX "session_note_status_idx" ON "session_note"("status");
-CREATE INDEX "session_note_kind_idx" ON "session_note"("kind");
-PRAGMA foreign_keys=ON;
-PRAGMA defer_foreign_keys=OFF;
-
--- CreateIndex
-CREATE INDEX "client_form_score_history_userId_recordedAt_idx" ON "client_form_score_history"("userId", "recordedAt");
-
--- CreateIndex
-CREATE INDEX "AceForm_userId_idx" ON "AceForm"("userId");
-
--- CreateIndex
-CREATE UNIQUE INDEX "AceQuestion_formId_key" ON "AceQuestion"("formId");
-
--- CreateIndex
-CREATE INDEX "AceQuestion_userId_idx" ON "AceQuestion"("userId");
-
--- CreateIndex
-CREATE INDEX "notification_userId_readAt_idx" ON "notification"("userId", "readAt");
-
--- CreateIndex
-CREATE INDEX "notification_userId_createdAt_idx" ON "notification"("userId", "createdAt");
diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml
deleted file mode 100644
index 2a5a444..0000000
--- a/prisma/migrations/migration_lock.toml
+++ /dev/null
@@ -1,3 +0,0 @@
-# Please do not edit this file manually
-# It should be added in your version-control system (e.g., Git)
-provider = "sqlite"
diff --git a/prisma/schema/notes.prisma b/prisma/schema/notes.prisma
index 3813022..a5a91e8 100644
--- a/prisma/schema/notes.prisma
+++ b/prisma/schema/notes.prisma
@@ -28,18 +28,18 @@ enum SessionNoteKind {
}
model SessionNote {
- id String @id @default(cuid())
- clientId String
- sessionName String
- sessionNumber Int
- appointmentId String?
- kind SessionNoteKind @default(PROGRESS)
- status SessionNoteStatus @default(DRAFT)
- content String
- attended Boolean @default(true)
+ id String @id @default(cuid())
+ clientId String
+ content String
+ attendanceStatus String? @default("show")
+ sessionName String
+ sessionNumber Int
+ appointmentId String?
+ kind SessionNoteKind @default(PROGRESS)
+ status SessionNoteStatus @default(DRAFT)
/// Deprecated: legacy single-signature field kept for back-compat with existing rows.
/// New flow uses `clinicianSignatureData` / `adminSignatureData` below.
- signatureData String?
+ signatureData String?
/// Tier 1 — signed by the clinician who wrote the note.
clinicianSignedAt DateTime?
@@ -70,11 +70,14 @@ model SessionNote {
}
model SessionNoteEdit {
- id String @id @default(cuid())
- sessionNoteId String
- originalContent String?
- reason String?
- signature String?
+ id String @id @default(cuid())
+ sessionNoteId String
+ originalContent String?
+ editedContent String?
+ oldAttendanceStatus String?
+ newAttendanceStatus String?
+ reason String?
+ signature String?
editedAt DateTime @default(now())
sessionNote SessionNote @relation(fields: [sessionNoteId], references: [id], onDelete: Cascade)
diff --git a/server/api/clients/[id]/notes.post.ts b/server/api/clients/[id]/notes.post.ts
index 80007ab..9feefc9 100644
--- a/server/api/clients/[id]/notes.post.ts
+++ b/server/api/clients/[id]/notes.post.ts
@@ -45,7 +45,7 @@ export default defineEventHandler(async (event) => {
const body = await readBody<{
content?: string
- attended?: boolean
+ attendanceStatus?: string
appointmentId?: string
kind?: SessionNoteKind
action?: SaveAction
@@ -60,6 +60,10 @@ export default defineEventHandler(async (event) => {
reason?: string
}>(event)
+ if (!body?.content || typeof body.content !== 'string') {
+ throw createError({ statusCode: 400, statusMessage: 'Content is required' })
+ }
+
const content = typeof body?.content === 'string' ? body.content.trim() : ''
if (!content) {
throw createError({ statusCode: 400, statusMessage: 'Content is required' })
@@ -99,7 +103,8 @@ export default defineEventHandler(async (event) => {
}
}
- const hasAttendance = typeof body.attended === 'boolean'
+ const attendanceStatus = body.attendanceStatus ?? 'show'
+ const hasAttendance = attendanceStatus === 'show'
const dbUser = await prisma.user.findFirst({
where: { id: clientUserId, role: 'CLIENT' },
@@ -144,7 +149,6 @@ export default defineEventHandler(async (event) => {
statusMessage: 'Attendance status is required when signing a session note.',
})
}
- const attended = hasAttendance ? body.attended : true
const existingNote = await prisma.sessionNote.findFirst({
where: { appointmentId: appointment.id, clientId: client.id },
@@ -197,7 +201,7 @@ export default defineEventHandler(async (event) => {
where: { id: existingNote.id },
data: {
content,
- attended,
+ attendanceStatus,
kind,
status: nextStatus,
...clinicianFields,
@@ -226,7 +230,7 @@ export default defineEventHandler(async (event) => {
data: {
clientId: client.id,
content,
- attended,
+ attendanceStatus,
kind,
status: nextStatus,
appointmentId: appointment.id,
diff --git a/server/api/clients/[id]/session-notes/[noteId].patch.ts b/server/api/clients/[id]/session-notes/[noteId].patch.ts
index e266001..354b897 100644
--- a/server/api/clients/[id]/session-notes/[noteId].patch.ts
+++ b/server/api/clients/[id]/session-notes/[noteId].patch.ts
@@ -26,6 +26,7 @@ export default defineEventHandler(async (event) => {
content?: string
reason?: string
signature?: string
+ attendanceStatus?: string
signatureData?: string
}>(event)
@@ -78,13 +79,18 @@ export default defineEventHandler(async (event) => {
data: {
sessionNoteId: note.id,
originalContent: note.content,
+ editedContent: body.content.trim(),
+ oldAttendanceStatus: note.attendanceStatus,
+ newAttendanceStatus: body.attendanceStatus ?? note.attendanceStatus,
reason: body.reason.trim(),
signature: signatureStored,
},
}),
prisma.sessionNote.update({
where: { id: note.id },
- data: { content: body.content.trim() },
+ data: { content: body.content.trim(),
+ ...(body.attendanceStatus && { attendanceStatus: body.attendanceStatus }),
+ },
}),
])