Skip to main content

Patient Context

Use Patient IDs When Possible

Always include a patientId when available to leverage stored context and enable audit logs:
Benefits:
  • Richer, more accurate responses based on patient history
  • Complete audit trails for compliance
  • Automatic context retrieval from stored patient data

Phone Number Lookup

When you don’t have a patient ID, use phone number lookup in ANY format:
Phone numbers can be in ANY format - the system automatically normalizes them:
  • +15551234567, 15551234567, 5551234567
  • (555) 123-4567, 555-123-4567, etc.
All formats work equally well!

Conversation Management

Provide Compact History

Include the last 5-10 conversation turns for continuity without overwhelming the context:

Conversation History Format

Each conversation entry should include:
  • role: Either "user" or "assistant"
  • content: The message content as a string

Performance Optimization

Client-Side Caching

Cache responses for repeated prompts to reduce latency:

Request Batching

For multiple related questions, consider the conversation flow rather than making separate requests:

Error Handling

Implement Robust Error Handling

Handle Network Errors

Implement retry logic for network failures:

Data Management

Patient Data Override

Use patientData to provide or override specific patient information:

Provide Updated Patient Data

Use the patientData parameter to provide the most current information:

Security Considerations

API Key Management

  • Store API keys in environment variables
  • Use different keys for different environments
  • Rotate keys regularly
  • Never expose keys in client-side code

Data Privacy

  • Only send necessary patient information
  • Implement proper access controls
  • Log API usage for audit purposes
  • Follow healthcare data compliance requirements (HIPAA, etc.)

Monitoring and Logging

Track API Usage

Monitor your API usage patterns:

Log Important Events

Be careful not to log sensitive patient information in your application logs.