feat(swift): voeg date/time parsing toe (E2)

Epic 2 compleet: NLP-helpers voor datum en tijd interpretatie.

Implementatie:
- parseRelativeDate(): ondersteunt "vandaag", "morgen", "deze week",
  weekdagen (maandag-zondag), en absolute datums (30 december, 28-12-2024)
- parseTime(): ondersteunt "14:00", "14", "half drie", "kwart voor drie",
  en natuurlijke taal tijdsaanduidingen
- combineDatetime(): combineert datum + tijd naar ISO string
- isNotInPast(): validatie voor toekomstige datums
- isDateRange(): type guard voor datum ranges

Integratie:
- Entity extractor gebruikt date/time parser voor agenda intents
- Normaliseert ruwe strings ("morgen", "14:00") naar Date objecten
- Ondersteunt Nederlandse tijdsaanduidingen

Tests & validatie:
- Unit tests voor alle parser functies
- Verify script voor handmatige testing
- Review document met bevindingen en suggesties

Story points: 7 SP (E2.S1: 3, E2.S2: 2, E2.S3: 2)
This commit is contained in:
colinislit
2025-12-27 22:14:22 +01:00
parent d2ffccc22b
commit 0031bd5fd1
5 changed files with 1050 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
# Epic 2 Review Findings
Context: quick review of Epic 2 changes (date/time parsing + agenda entity extraction).
## Findings
1. High - Patient name detection is too permissive for agenda intents and can misclassify appointment tokens as names.
- Details: create/cancel/reschedule extraction uses `filteredWords` + `isLikelyName`; tokens like "intake", "morgen", or times can be treated as names.
- Impact: wrong patient selected or wrong appointment targeted.
- Files: `lib/swift/entity-extractor.ts`
- Suggestion: skip tokens that parse as date/time or match appointment/location keywords before `isLikelyName`.
2. Medium - Agenda query defaults to "vandaag" when no date is present (e.g., "volgende afspraak").
- Impact: only today is queried, which can miss the actual next appointment.
- Files: `lib/swift/entity-extractor.ts`
- Suggestion: leave `dateRange` undefined or mark "from now" and let backend decide.
3. Medium - `ExtractedEntities` now carries Date objects, but the classify API returns JSON, so Dates become strings.
- Impact: downstream date ops may break on serialized strings.
- Files: `lib/swift/types.ts` (see API flow in `app/api/intent/classify/route.ts`)
- Suggestion: use ISO strings in the DTO or normalize in the API response.
4. Medium - Type drift between lib and store: the store `ExtractedEntities` does not include the new agenda structures.
- Impact: UI usage may drop agenda fields or require unsafe casting.
- Files: `stores/swift-store.ts`, `lib/swift/types.ts`
- Suggestion: align store types with lib types (or re-export the shared type).
5. Low - AI fallback path does not run local extractor; low-confidence agenda intents lose structured entities.
- Impact: less reliable agenda prefill when AI is used.
- Files: `app/api/intent/classify/route.ts`, `lib/swift/intent-classifier-ai.ts`
- Suggestion: post-process AI results with local extractor for agenda intents.
## Testing / QA notes
- Untracked tests exist: `lib/swift/__tests__/date-time-parser.test.ts`.
- Manual scripts exist: `lib/swift/verify-parser.ts` and `lib/swift/verify-entity-extraction.ts` (not run here).