chore(strip): verwijder kapotte intake-tabs anamnese, onderzoeken en ROM

Opslaan faalde altijd door label/code-mismatch met de database-constraints
(reviewbevinding). Tabs komen terug bij de rebuild op het nieuwe datamodel.

- tab-mappen anamnese/, examination/, rom/ verwijderd
- tabs uit intake-tabs.tsx, server actions uit actions.ts
- intake-status API telt de secties niet meer mee (voortgangsring klopt)
- Cortex-navigatiedoelen (regex, entity-mapping, prompt) bijgewerkt zodat
  'ga naar anamnese' geen 404 meer geeft

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
colinislit
2026-07-14 22:44:09 +02:00
parent 5e910c3053
commit a8b02c1ef3
14 changed files with 9 additions and 559 deletions

View File

@@ -186,116 +186,6 @@ export async function deleteRiskAssessment(patientId: string, intakeId: string,
revalidatePath(buildPath(patientId, intakeId));
}
// ---------------- Anamneses ----------------
export async function getAnamneses(intakeId: string) {
const supabase = await getSupabase();
const { data, error } = await supabase
.from('anamneses')
.select('*')
.eq('intake_id', intakeId)
.order('anamnese_date', { ascending: false });
if (error) {
console.error('getAnamneses error', error);
throw new Error('Kon anamneses niet ophalen');
}
return data || [];
}
export interface AnamnesePayload {
patientId: string;
intakeId: string;
date: string;
type: string;
content: string;
notes?: string;
}
export async function createAnamnese(payload: AnamnesePayload) {
const supabase = await getSupabase();
const { error } = await supabase.from('anamneses').insert({
intake_id: payload.intakeId,
anamnese_date: payload.date,
anamnese_type: payload.type,
content: payload.content,
notes: payload.notes,
});
if (error) {
console.error('createAnamnese error', error);
throw new Error(error.message);
}
revalidatePath(buildPath(payload.patientId, payload.intakeId, 'anamnese'));
revalidatePath(buildPath(payload.patientId, payload.intakeId));
}
export async function deleteAnamnese(patientId: string, intakeId: string, anamneseId: string) {
const supabase = await getSupabase();
const { error } = await supabase.from('anamneses').delete().eq('id', anamneseId);
if (error) {
console.error('deleteAnamnese error', error);
throw new Error(error.message);
}
revalidatePath(buildPath(patientId, intakeId, 'anamnese'));
revalidatePath(buildPath(patientId, intakeId));
}
// ---------------- Examinations (including ROM) ----------------
export async function getExaminations(intakeId: string) {
const supabase = await getSupabase();
const { data, error } = await supabase
.from('examinations')
.select('*')
.eq('intake_id', intakeId)
.order('examination_date', { ascending: false });
if (error) {
console.error('getExaminations error', error);
throw new Error('Kon onderzoeken niet ophalen');
}
return data || [];
}
export interface ExaminationPayload {
patientId: string;
intakeId: string;
date: string;
type: string;
findings: string;
performer?: string;
reason?: string;
notes?: string;
isRom?: boolean;
}
export async function createExamination(payload: ExaminationPayload) {
const supabase = await getSupabase();
const { error } = await supabase.from('examinations').insert({
intake_id: payload.intakeId,
examination_date: payload.date,
examination_type: payload.isRom ? 'ROM' : payload.type,
findings: payload.findings,
performed_by: payload.performer,
reason: payload.reason,
notes: payload.notes,
});
if (error) {
console.error('createExamination error', error);
throw new Error(error.message);
}
const tab = payload.isRom ? 'rom' : 'examination';
revalidatePath(buildPath(payload.patientId, payload.intakeId, tab));
revalidatePath(buildPath(payload.patientId, payload.intakeId));
}
export async function deleteExamination(patientId: string, intakeId: string, examinationId: string) {
const supabase = await getSupabase();
const { error } = await supabase.from('examinations').delete().eq('id', examinationId);
if (error) {
console.error('deleteExamination error', error);
throw new Error(error.message);
}
revalidatePath(buildPath(patientId, intakeId, 'examination'));
revalidatePath(buildPath(patientId, intakeId, 'rom'));
revalidatePath(buildPath(patientId, intakeId));
}
// ---------------- Diagnoses ----------------
export async function getDiagnoses(intakeId: string) {

View File

@@ -1,143 +0,0 @@
'use client';
import { useState, useTransition } from 'react';
import { createAnamnese, deleteAnamnese, type Anamnese } from '../../actions';
import { Loader2, Trash2 } from 'lucide-react';
import { format } from 'date-fns';
import { nl } from 'date-fns/locale';
const types = [
'Psychiatrische anamnese',
'Sociale anamnese',
'Medische anamnese',
'Familieanamnese',
'Ontwikkelingsanamnese',
'Overig',
];
interface AnamneseManagerProps {
patientId: string;
intakeId: string;
anamneses: Anamnese[];
}
export function AnamneseManager({ patientId, intakeId, anamneses }: AnamneseManagerProps) {
const [form, setForm] = useState({
date: '',
type: types[0],
content: '',
notes: '',
});
const [error, setError] = useState<string | null>(null);
const [isPending, startTransition] = useTransition();
const [deletingId, setDeletingId] = useState<string | null>(null);
const handleSubmit = () => {
if (!form.date || !form.content) {
setError('Datum en inhoud zijn verplicht.');
return;
}
setError(null);
startTransition(async () => {
try {
await createAnamnese({
patientId,
intakeId,
date: form.date,
type: form.type,
content: form.content,
notes: form.notes,
});
setForm({ ...form, content: '', notes: '' });
} catch (err) {
setError(err instanceof Error ? err.message : 'Opslaan mislukt');
}
});
};
const handleDelete = (id: string) => {
setDeletingId(id);
startTransition(async () => {
try {
await deleteAnamnese(patientId, intakeId, id);
} catch (err) {
setError(err instanceof Error ? err.message : 'Verwijderen mislukt');
} finally {
setDeletingId(null);
}
});
};
return (
<div className="space-y-4">
<div className="grid grid-cols-1 gap-3">
{anamneses.length === 0 && <p className="text-sm text-slate-500">Nog geen anamneses.</p>}
{anamneses.map((item) => (
<div key={item.id} className="rounded-lg border border-slate-200 p-4 space-y-1">
<div className="flex items-center justify-between">
<div>
<p className="font-medium text-slate-900">{item.anamnese_type}</p>
<p className="text-xs text-slate-500">
{format(new Date(item.anamnese_date), 'd MMM yyyy', { locale: nl })}
</p>
</div>
<button
type="button"
onClick={() => handleDelete(item.id)}
disabled={deletingId === item.id}
className="inline-flex items-center gap-1 rounded-md border border-red-200 px-3 py-1.5 text-xs text-red-600"
>
{deletingId === item.id ? <Loader2 className="h-4 w-4 animate-spin" /> : <Trash2 className="h-4 w-4" />} Verwijder
</button>
</div>
<p className="text-sm text-slate-700 whitespace-pre-line">{item.content}</p>
{item.notes && <p className="text-xs text-slate-500">Notities: {item.notes}</p>}
</div>
))}
</div>
<div className="rounded-lg border border-slate-200 p-4 space-y-3">
<h3 className="text-sm font-semibold text-slate-900">Nieuwe anamnese</h3>
<input
type="date"
value={form.date}
onChange={(e) => setForm((prev) => ({ ...prev, date: e.target.value }))}
className="h-10 rounded-md border border-slate-300 px-3 text-sm"
/>
<select
value={form.type}
onChange={(e) => setForm((prev) => ({ ...prev, type: e.target.value }))}
className="h-10 rounded-md border border-slate-300 px-3 text-sm"
>
{types.map((type) => (
<option key={type} value={type}>
{type}
</option>
))}
</select>
<textarea
value={form.content}
onChange={(e) => setForm((prev) => ({ ...prev, content: e.target.value }))}
placeholder="Inhoud"
className="w-full rounded-md border border-slate-300 px-3 py-2 text-sm"
/>
<textarea
value={form.notes}
onChange={(e) => setForm((prev) => ({ ...prev, notes: e.target.value }))}
placeholder="Notities"
className="w-full rounded-md border border-slate-300 px-3 py-2 text-sm"
/>
{error && <p className="text-sm text-red-600">{error}</p>}
<button
type="button"
onClick={handleSubmit}
disabled={isPending}
className="inline-flex items-center gap-2 rounded-md bg-teal-600 px-4 py-2 text-sm font-medium text-white"
>
{isPending && <Loader2 className="h-4 w-4 animate-spin" />}
Opslaan
</button>
</div>
</div>
);
}

View File

@@ -1,23 +0,0 @@
import { getAnamneses } from '../actions';
import { AnamneseManager } from './components/anamnese-manager';
export default async function IntakeAnamnesePage({
params,
}: {
params: Promise<{ id: string; intakeId: string }>;
}) {
const { id, intakeId } = await params;
const anamneses = await getAnamneses(intakeId);
return (
<div className="space-y-4">
<div>
<h2 className="text-lg font-semibold text-slate-900">Anamnese</h2>
<p className="text-sm text-slate-600">
Vastleggen van psychiatrische, sociale en andere anamneses.
</p>
</div>
<AnamneseManager patientId={id} intakeId={intakeId} anamneses={anamneses} />
</div>
);
}

View File

@@ -56,9 +56,6 @@ export function IntakeTabs({ patientId, intakeId }: IntakeTabsProps) {
{ name: 'Contactmomenten', href: `${baseUrl}/contacts` },
{ name: 'Kindcheck', href: `${baseUrl}/kindcheck` },
{ name: 'Risicotaxatie', href: `${baseUrl}/risk` },
{ name: 'Anamnese', href: `${baseUrl}/anamnese` },
{ name: 'Onderzoeken', href: `${baseUrl}/examination` },
{ name: 'ROM', href: `${baseUrl}/rom` },
{ name: 'Diagnose', href: `${baseUrl}/diagnosis` },
{ name: 'Behandeladvies', href: `${baseUrl}/behandeladvies` },
], [baseUrl]);

View File

@@ -1,167 +0,0 @@
'use client';
import { useState, useTransition } from 'react';
import { createExamination, deleteExamination, type Examination } from '../../actions';
import { Loader2, Trash2 } from 'lucide-react';
import { format } from 'date-fns';
import { nl } from 'date-fns/locale';
const examinationTypes = ['Bloedonderzoek', 'Neuropsychologisch onderzoek', 'Psychodiagnostiek', 'IQ-test', 'Persoonlijkheidsonderzoek', 'Overig'];
interface ExaminationManagerProps {
patientId: string;
intakeId: string;
examinations: Examination[];
isRom?: boolean;
}
export function ExaminationManager({ patientId, intakeId, examinations, isRom }: ExaminationManagerProps) {
const filtered = examinations.filter((exam) =>
isRom ? exam.examination_type === 'ROM' : exam.examination_type !== 'ROM'
);
const [form, setForm] = useState({
date: '',
type: examinationTypes[0],
performer: '',
findings: '',
reason: '',
notes: '',
});
const [error, setError] = useState<string | null>(null);
const [isPending, startTransition] = useTransition();
const [deletingId, setDeletingId] = useState<string | null>(null);
const handleSubmit = () => {
if (!form.date || !form.findings) {
setError('Datum en bevindingen zijn verplicht.');
return;
}
setError(null);
startTransition(async () => {
try {
await createExamination({
patientId,
intakeId,
date: form.date,
type: form.type,
findings: form.findings,
performer: form.performer,
reason: form.reason,
notes: form.notes,
isRom,
});
setForm({ ...form, findings: '', notes: '' });
} catch (err) {
setError(err instanceof Error ? err.message : 'Opslaan mislukt');
}
});
};
const handleDelete = (id: string) => {
setDeletingId(id);
startTransition(async () => {
try {
await deleteExamination(patientId, intakeId, id);
} catch (err) {
setError(err instanceof Error ? err.message : 'Verwijderen mislukt');
} finally {
setDeletingId(null);
}
});
};
return (
<div className="space-y-4">
<div className="grid grid-cols-1 gap-3">
{filtered.length === 0 && (
<p className="text-sm text-slate-500">
{isRom ? 'Nog geen ROM-metingen' : 'Nog geen onderzoeken geregistreerd.'}
</p>
)}
{filtered.map((exam) => (
<div key={exam.id} className="rounded-lg border border-slate-200 p-4 space-y-1">
<div className="flex items-center justify-between">
<div>
<p className="font-medium text-slate-900">{exam.examination_type}</p>
<p className="text-xs text-slate-500">
{format(new Date(exam.examination_date), 'd MMM yyyy', { locale: nl })}
</p>
</div>
<button
type="button"
onClick={() => handleDelete(exam.id)}
disabled={deletingId === exam.id}
className="inline-flex items-center gap-1 rounded-md border border-red-200 px-3 py-1.5 text-xs text-red-600"
>
{deletingId === exam.id ? <Loader2 className="h-4 w-4 animate-spin" /> : <Trash2 className="h-4 w-4" />} Verwijder
</button>
</div>
<p className="text-sm text-slate-700 whitespace-pre-line">{exam.findings}</p>
{exam.notes && <p className="text-xs text-slate-500">Notities: {exam.notes}</p>}
</div>
))}
</div>
<div className="rounded-lg border border-slate-200 p-4 space-y-3">
<h3 className="text-sm font-semibold text-slate-900">
{isRom ? 'Nieuwe ROM-meting' : 'Nieuw onderzoek'}
</h3>
<input
type="date"
value={form.date}
onChange={(e) => setForm((prev) => ({ ...prev, date: e.target.value }))}
className="h-10 rounded-md border border-slate-300 px-3 text-sm"
/>
{!isRom && (
<select
value={form.type}
onChange={(e) => setForm((prev) => ({ ...prev, type: e.target.value }))}
className="h-10 rounded-md border border-slate-300 px-3 text-sm"
>
{examinationTypes.map((type) => (
<option key={type} value={type}>
{type}
</option>
))}
</select>
)}
<input
type="text"
placeholder={isRom ? 'Instrument / score' : 'Uitgevoerd door'}
value={form.performer}
onChange={(e) => setForm((prev) => ({ ...prev, performer: e.target.value }))}
className="h-10 rounded-md border border-slate-300 px-3 text-sm"
/>
<textarea
value={form.findings}
onChange={(e) => setForm((prev) => ({ ...prev, findings: e.target.value }))}
placeholder={isRom ? 'Score en interpretatie' : 'Bevindingen'}
className="w-full rounded-md border border-slate-300 px-3 py-2 text-sm"
/>
<textarea
value={form.reason}
onChange={(e) => setForm((prev) => ({ ...prev, reason: e.target.value }))}
placeholder="Reden"
className="w-full rounded-md border border-slate-300 px-3 py-2 text-sm"
/>
<textarea
value={form.notes}
onChange={(e) => setForm((prev) => ({ ...prev, notes: e.target.value }))}
placeholder="Notities"
className="w-full rounded-md border border-slate-300 px-3 py-2 text-sm"
/>
{error && <p className="text-sm text-red-600">{error}</p>}
<button
type="button"
onClick={handleSubmit}
disabled={isPending}
className="inline-flex items-center gap-2 rounded-md bg-teal-600 px-4 py-2 text-sm font-medium text-white"
>
{isPending && <Loader2 className="h-4 w-4 animate-spin" />}
Opslaan
</button>
</div>
</div>
);
}

View File

@@ -1,23 +0,0 @@
import { getExaminations } from '../actions';
import { ExaminationManager } from './components/examination-manager';
export default async function IntakeExaminationPage({
params,
}: {
params: Promise<{ id: string; intakeId: string }>;
}) {
const { id, intakeId } = await params;
const examinations = await getExaminations(intakeId);
return (
<div className="space-y-4">
<div>
<h2 className="text-lg font-semibold text-slate-900">Onderzoeken</h2>
<p className="text-sm text-slate-600">
Psychodiagnostiek, medische onderzoeken en rapportage.
</p>
</div>
<ExaminationManager patientId={id} intakeId={intakeId} examinations={examinations} />
</div>
);
}

View File

@@ -1,28 +0,0 @@
import { getExaminations } from '../actions';
import { ExaminationManager } from '../examination/components/examination-manager';
export default async function IntakeRomPage({
params,
}: {
params: Promise<{ id: string; intakeId: string }>;
}) {
const { id, intakeId } = await params;
const examinations = await getExaminations(intakeId);
return (
<div className="space-y-4">
<div>
<h2 className="text-lg font-semibold text-slate-900">ROM-metingen</h2>
<p className="text-sm text-slate-600">
Registeren van ROM-scores gekoppeld aan deze intake.
</p>
</div>
<ExaminationManager
patientId={id}
intakeId={intakeId}
examinations={examinations}
isRom
/>
</div>
);
}