fix(cortex): integrate intake intents into full chat + artifact flow
Fixes 4 bugs preventing intake blocks from working: 1. Chat API validation: Add 'nudge' to message type enum, allow empty content for streaming messages 2. AI chat recognition: Add P3 intake intents (intake_status, risico_query, diagnose_query, intake_navigeer) to system prompt with triggers, entities, and JSON examples 3. Artifact rendering: Add intake block imports and switch cases to artifact-container.tsx 4. API 400 error: Convert null to undefined for optional Zod params (searchParams.get returns null, Zod .optional() expects undefined) Also adds: - Testplan for E2E testing (60+ test cases) - Session log with lessons learned and new intent checklist Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -74,7 +74,7 @@ export async function GET(request: NextRequest) {
|
||||
// Parse and validate query parameters
|
||||
const searchParams = request.nextUrl.searchParams;
|
||||
const patientId = searchParams.get('patientId');
|
||||
const intakeId = searchParams.get('intakeId');
|
||||
const intakeId = searchParams.get('intakeId') || undefined; // Convert null to undefined for Zod
|
||||
|
||||
if (!patientId) {
|
||||
return NextResponse.json(
|
||||
|
||||
@@ -93,7 +93,7 @@ export async function GET(request: NextRequest) {
|
||||
// Parse and validate query parameters
|
||||
const searchParams = request.nextUrl.searchParams;
|
||||
const patientId = searchParams.get('patientId');
|
||||
const intakeId = searchParams.get('intakeId');
|
||||
const intakeId = searchParams.get('intakeId') || undefined; // Convert null to undefined for Zod
|
||||
|
||||
if (!patientId) {
|
||||
return NextResponse.json(
|
||||
|
||||
@@ -71,9 +71,12 @@ export async function GET(request: NextRequest) {
|
||||
// Parse and validate query parameters
|
||||
const searchParams = request.nextUrl.searchParams;
|
||||
const patientId = searchParams.get('patientId');
|
||||
const intakeId = searchParams.get('intakeId');
|
||||
const intakeId = searchParams.get('intakeId') || undefined; // Convert null to undefined for Zod
|
||||
|
||||
console.log('[Intake Status API] Request params:', { patientId, intakeId });
|
||||
|
||||
if (!patientId) {
|
||||
console.log('[Intake Status API] Missing patientId');
|
||||
return NextResponse.json(
|
||||
{ error: 'Query parameter "patientId" is verplicht' },
|
||||
{ status: 400 }
|
||||
@@ -85,6 +88,7 @@ export async function GET(request: NextRequest) {
|
||||
const errorMessage = validation.error.issues
|
||||
.map((e) => e.message)
|
||||
.join(', ');
|
||||
console.log('[Intake Status API] Validation failed:', errorMessage);
|
||||
return NextResponse.json({ error: errorMessage }, { status: 400 });
|
||||
}
|
||||
|
||||
@@ -110,8 +114,9 @@ export async function GET(request: NextRequest) {
|
||||
}
|
||||
|
||||
if (!latestIntake) {
|
||||
console.log('[Intake Status API] No active intake found for patient:', patientId);
|
||||
return NextResponse.json(
|
||||
{ error: 'Geen actieve intake gevonden voor deze patiënt' },
|
||||
{ error: 'Geen actieve intake gevonden voor deze patiënt. Start eerst een intake.' },
|
||||
{ status: 404 }
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user