Overview
Nurse Handoff Helper integrates with AI providers to power intelligent features like handoff note generation and medical image analysis. Currently, the system supports Claude (Anthropic) with the latest Sonnet 4 model.Supported Providers
Claude (Anthropic)
Claude Sonnet 4
Model:
claude-sonnet-4-20250514Capabilities:- Text generation for handoff summaries
- Vision analysis for medical images and whiteboards
- Structured data extraction
- Trend analysis and clinical reasoning
Medical Context
Understanding clinical terminology and medical records
Vision Analysis
Reading handwritten notes and whiteboard images
Structured Output
Generating organized, scannable handoff notes
Safety Focus
Identifying and highlighting critical safety concerns
Configuration
Environment Setup
From~/workspace/source/server/index.js:8-29:
.env
Initialize Client
The backend initializes the Anthropic client at startup:~/workspace/source/server/index.js:26-29
Health Check
Verify AI provider configuration with the health endpoint:~/workspace/source/server/index.js:52-60
API Endpoints
Text Generation
Summarize Patient Record
Endpoint:POST /api/summarize-record/claude
From ~/workspace/source/server/index.js:145-296:
Prompt Engineering Details
Prompt Engineering Details
The prompt sent to Claude includes:
- Role Definition: “You are a clinical nursing assistant”
- Task Description: Analyze patient record and create handoff summary
- Structure Requirements: 6 key sections (overview, status, labs, meds, tasks, safety)
- Emphasis on Trends: “WE CARE A LOT ABOUT TRENDS”
- Task Status Details: Total, completed, and outstanding tasks with priorities
- Comparison Logic: If
previousNotesprovided, generate “Changes Since Last Handoff” - Image Integration: If
imageAnalysisprovided, merge with electronic record
~/workspace/source/server/index.js:171-275Extract Structured Data
Endpoint:POST /api/extract-patient-data/claude
Extract structured patient information from unstructured text or analysis.
From ~/workspace/source/server/index.js:1020-1103:
Vision Analysis
Analyze Medical Image
Endpoint:POST /api/analyze-image/claude
From ~/workspace/source/server/index.js:63-142:
~/workspace/source/server/index.js:79-130
Error Handling
Missing Configuration
~/workspace/source/server/index.js:68-73 and similar checks throughout
API Errors
~/workspace/source/server/index.js:134-140 and ~/workspace/source/server/index.js:289-295
Model Details
Claude Sonnet 4
- Specifications
- Use Cases
- Strengths
Model ID:
claude-sonnet-4-20250514Max Tokens: 2048 (configurable)Input: Text and images (base64 encoded)Vision: Supports image analysis up to 10MBContext Window: Large context for comprehensive patient recordsToken Usage
Typical token consumption:Token Estimates
Handoff Note Generation:
- Input: 500-1500 tokens (patient data + prompts)
- Output: 400-800 tokens (handoff summary)
- Total: ~1000-2300 tokens per generation
- Input: 1000-2000 tokens (image + prompt)
- Output: 300-600 tokens (analysis)
- Total: ~1300-2600 tokens per image
- Input: 200-500 tokens
- Output: 100-300 tokens
- Total: ~300-800 tokens
Images are processed efficiently using Claude’s vision API. The model automatically handles image encoding and processing.
Rate Limits
Anthropic API rate limits vary by tier. For production use:Provider Architecture
The API uses a provider-specific path structure to support potential future AI providers:Best Practices
API Key Security
API Key Security
- Store keys in environment variables only
- Never commit
.envfiles - Use different keys for development and production
- Rotate keys periodically
- Monitor for unusual usage patterns
Error Handling
Error Handling
- Check if client is initialized before API calls
- Provide clear error messages to users
- Log errors for debugging
- Implement retry logic for transient failures
- Have fallback behavior when AI is unavailable
Performance
Performance
- Set appropriate
max_tokenslimits - Cache frequent queries
- Process images at reasonable resolution
- Consider batch processing for multiple patients
- Monitor response times
Prompt Engineering
Prompt Engineering
- Be specific about desired output format
- Emphasize critical information (tasks, safety)
- Provide examples in prompts when needed
- Use structured prompts for consistency
- Test prompts with diverse patient scenarios
Troubleshooting
503 Service Unavailable
503 Service Unavailable
401 Unauthorized
401 Unauthorized
429 Rate Limit Exceeded
429 Rate Limit Exceeded
Cause: Too many requests in short timeSolution: Implement rate limiting and caching
- Add delays between requests
- Cache generated summaries
- Upgrade API tier if needed
Image Analysis Fails
Image Analysis Fails
Cause: Image too large, wrong format, or poor qualitySolution:
- Ensure image is under 10MB
- Use supported formats (JPEG, PNG)
- Check image quality and resolution
- Verify image is not corrupted
Next Steps
Patient Handoff
Learn how AI generates handoff notes
Image Analysis
Understand vision-based document analysis
