Health History Tracking
Health History Tracking
Section titled “Health History Tracking”Beyond conversation memory, Vitamem can serve as the persistent health history layer for your AI application — accumulating a rich, searchable record of a user’s health journey across many sessions over months or years.
What to Track
Section titled “What to Track”Vitamem’s fact extraction works best when your extraction prompt focuses on specific categories:
| Category | Examples |
|---|---|
| Conditions | ”Has hypertension”, “Diagnosed with anxiety disorder” |
| Medications | ”Takes lisinopril 10mg daily”, “Recently stopped statins” |
| Vitals & labs | ”A1C was 7.2 in March”, “Blood pressure averaging 130/85” |
| Lifestyle | ”Exercises 4x per week”, “Follows a low-carb diet” |
| Goals | ”Wants to lose 15 pounds by summer”, “Aiming for A1C under 7.0” |
| Care team | ”Primary care: Dr. Chen”, “Sees endocrinologist quarterly” |
| Family history | ”Father had heart disease”, “Mother has Type 2 diabetes” |
Example: Chronic Condition Tracking
Section titled “Example: Chronic Condition Tracking”// Extraction prompt tuned for chronic condition managementasync extractMemories(messages) { const prompt = `Review this health check-in conversation and extract health history facts.
Categories to extract:- Medical conditions (diagnosed or suspected)- Medications and supplements (name, dose, frequency)- Lab values and vital signs (with dates if mentioned)- Lifestyle factors (diet, exercise, sleep, stress)- Health goals and progress- Symptoms mentioned- Care team and appointments
Conversation:${messages.map(m => `${m.role}: ${m.content}`).join('\n')}
Return JSON only: [{ "content": "specific factual statement", "source": "confirmed" | "inferred" }]Be specific — include numbers, dates, and dosages when provided.`;
const raw = await this.chat([{ role: 'user', content: prompt }]); return JSON.parse(raw);},Building a Health Timeline
Section titled “Building a Health Timeline”You can reconstruct a user’s health timeline by querying their memories:
// Get a broad snapshot of the user's health historyconst healthSnapshot = await mem.retrieve({ userId: 'user-789', query: 'health conditions medications lifestyle diet exercise', limit: 20,});
// Format as a health summary for injection into a new sessionconst healthSummary = healthSnapshot .filter(m => m.score > 0.7) // Only high-relevance memories .map(m => `- ${m.content} (${m.source === 'confirmed' ? 'stated' : 'observed'})`) .join('\n');
const systemPrompt = `You are a health companion for this user.
Known health history:${healthSummary}
Use this context to give personalized, relevant support.`;Handling Health Record Updates
Section titled “Handling Health Record Updates”When a user’s health situation changes (new diagnosis, medication change, etc.), Vitamem handles it naturally:
- The new fact is extracted at dormant transition
- Deduplication compares it against existing memories
- If it’s genuinely new (e.g., “Now on insulin” when previously only metformin was recorded), it’s saved
- If it’s an update to an existing fact (e.g., A1C went from 7.4% to 6.8%), the supersede mechanism updates the existing memory in-place with the new value. The storage adapter tracks
previousValuefor vitals, giving you a history of changes.
Privacy Considerations
Section titled “Privacy Considerations”Health history data is sensitive. When building on Vitamem:
- Use encrypted storage —
SupabaseAdapterwith Row Level Security enabled - Scope memories to users — Vitamem already scopes all memories by
userId - Right to deletion — Use
deleteUserData(userId)to remove all memories for a user (GDPR/CCPA compliance) - Minimize retention — Use
closedTimeoutMswithsweepThreads()to automatically close old threads - Don’t store PHI without safeguards — if you’re handling Protected Health Information, consult a compliance specialist
See SECURITY.md for our security policy.