Dictionary Commands
Przegląd
Dział zatytułowany „Przegląd”Dictionary w Viście to system wykrywania i zapisywania terminów medycznych znalezionych podczas edycji wizyt. Działa jako część AI Suite i integruje się z wizytami przez VisitDictionaryService.
VisitDictionaryService
Dział zatytułowany „VisitDictionaryService”Plik: src/services/visitDictionaryService.ts
Term Detection Flow
Dział zatytułowany „Term Detection Flow”sequenceDiagram participant AI as AI Component participant VS as useVisitSelection participant DS as VisitDictionaryService participant API as visits API
AI->>VS: onTermsFound(terms) VS->>VS: Check signature (unique?) VS->>DS: saveTermsToVisit(visitId, terms) DS->>API: visits.get(visitId) API-->>DS: visit with attachments DS->>DS: Filter old dictionary_terms DS->>DS: Add new attachment DS->>API: visits.update({ attachments }) API-->>DS: success DS-->>VS: success VS->>VS: Show notificationhandleTermsFound
Dział zatytułowany „handleTermsFound”handleTermsFound(terms: FoundTerm[]) { if (!selectedVisit?.id || terms.length === 0) return;
// Unique signature to avoid duplicates const signature = `${visitId}:${matchedText}-${start}-${end}-${type}`;
if (isNewSignature(signature)) { lastSavedTermsRef.current = signature;
setTimeout(() => { VisitDictionaryService.saveTermsToVisit(currentVisitId, terms); }, 0);
// Notification notify({ title: t('dictionaryNotifications.savedTitle'), message: t('dictionaryNotifications.savedMessage', { count: terms.length }) }); }}saveTermsToVisit
Dział zatytułowany „saveTermsToVisit”async saveTermsToVisit(visitId: string, foundTerms: FoundTerm[]) { // 1. Get current visit const visit = await api.visits.get(visitId);
// 2. Parse existing attachments const attachments = JSON.parse(visit.attachments || '[]');
// 3. Filter old dictionary_terms const filtered = attachments.filter(a => a.type !== 'dictionary_terms');
// 4. Add new attachment filtered.push({ type: 'dictionary_terms', data: { visitId, foundTerms, analyzedAt: new Date().toISOString(), stats: { /* term statistics */ } }, timestamp: Date.now() });
// 5. Save back await api.visits.update(visitId, { attachments: JSON.stringify(filtered) });}FoundTerm Model
Dział zatytułowany „FoundTerm Model”interface FoundTerm { matchedText: string; // Znaleziony tekst start: number; // Pozycja początkowa end: number; // Pozycja końcowa type: TermType; // Typ terminu definition?: string; // Definicja ze słownika confidence?: number; // Pewność dopasowania}
type TermType = | 'diagnosis' // Rozpoznanie | 'procedure' // Procedura | 'medication' // Lek | 'anatomy' // Anatomia | 'symptom' // Objaw | 'lab_value'; // Wartość laboratoryjnaStorage Format
Dział zatytułowany „Storage Format”Terminy zapisywane są w visit.attachments jako JSON:
{ "type": "dictionary_terms", "data": { "visitId": "uuid-123", "foundTerms": [ { "matchedText": "hipoglikemia", "start": 45, "end": 56, "type": "diagnosis", "definition": "Niski poziom cukru we krwi" } ], "analyzedAt": "2024-01-15T10:30:00Z", "stats": { "totalTerms": 5, "byType": { "diagnosis": 2, "medication": 3 } } }, "timestamp": 1705315800000}Integration Points
Dział zatytułowany „Integration Points”| Component | Usage |
|---|---|
RightPanel (Visits) | Panel słownika/AI |
useVisitSelection | onTermsFound callback |
VisitDictionaryService | Zapis do DB |
| AI Components | Wykrywanie terminów |
Future: Custom Dictionary
Dział zatytułowany „Future: Custom Dictionary”Powiązane dokumenty
Dział zatytułowany „Powiązane dokumenty”- Visits Commands - CRUD wizyt, attachments
- AI Commands - AI term detection
- Features: Dictionary - User documentation