Files
Khalid Abdi 929bec8f31 feat: AI-added records save with placeholders + "Added by AI" provenance
Stop blocking AI imports/proposals on missing non-critical fields. Records
the chat agent drafts now save with safe placeholders, auto-generated file
numbers, and a source="ai" marker that surfaces an "Added by AI" badge so a
clinician can review/edit them later.

Backend:
- add `source` (manual|ai) column to patients/appointments/prescriptions
  (migration 0014) + canonical types, services, validation schemas
- relax patient/appointment validation: empty file number allowed, demographic
  + type/provider/initials fall back to placeholders (initials derived from name)
- patients.generateFileNumber() auto-assigns an MRN when one is missing
- proposeAppointment accepts a name when no file number resolves; AI commits +
  /api/ai/import stamp source="ai"

Frontend:
- `source` on Appointment/Patient/Prescription types; AI commits send source="ai"
- reusable <AiBadge> shown on the Patients table/detail and prescriptions list

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-14 19:27:17 +03:00

103 lines
2.7 KiB
TypeScript

"use client";
import {
Test,
TestError,
TestErrorMessage,
TestErrorStack,
TestResults,
TestResultsContent,
TestResultsDuration,
TestResultsHeader,
TestResultsProgress,
TestResultsSummary,
TestSuite,
TestSuiteContent,
TestSuiteName,
} from "@/components/ai-elements/test-results";
const Example = () => (
<TestResults
summary={{
duration: 3245,
failed: 2,
passed: 12,
skipped: 1,
total: 15,
}}
>
<TestResultsHeader>
<TestResultsSummary />
<TestResultsDuration />
</TestResultsHeader>
<div className="border-b px-4 py-3">
<TestResultsProgress />
</div>
<TestResultsContent>
<TestSuite defaultOpen={true} name="Authentication" status="passed">
<TestSuiteName />
<TestSuiteContent>
<Test
duration={45}
name="should login with valid credentials"
status="passed"
/>
<Test
duration={32}
name="should reject invalid password"
status="passed"
/>
<Test
duration={28}
name="should handle expired tokens"
status="passed"
/>
</TestSuiteContent>
</TestSuite>
<TestSuite defaultOpen={true} name="User API" status="failed">
<TestSuiteName />
<TestSuiteContent>
<Test duration={120} name="should create new user" status="passed" />
<Test duration={85} name="should update user profile" status="failed">
<TestError>
<TestErrorMessage>
Expected status 200 but received 500
</TestErrorMessage>
<TestErrorStack>
{` at Object.<anonymous> (src/user.test.ts:45:12)
at Promise.then.completed (node_modules/jest-circus/build/utils.js:391:28)`}
</TestErrorStack>
</TestError>
</Test>
<Test name="should delete user" status="skipped" />
</TestSuiteContent>
</TestSuite>
<TestSuite name="Database" status="failed">
<TestSuiteName />
<TestSuiteContent>
<Test
duration={200}
name="should connect to database"
status="passed"
/>
<Test
duration={5000}
name="should handle connection timeout"
status="failed"
>
<TestError>
<TestErrorMessage>
Connection timed out after 5000ms
</TestErrorMessage>
</TestError>
</Test>
</TestSuiteContent>
</TestSuite>
</TestResultsContent>
</TestResults>
);
export default Example;