Timesheet Upload Feature
Upload handwritten or digital timesheets for AI processing and validation
Timesheet Upload Feature
Overview
The timesheet upload feature allows clinicians and administrators to upload handwritten or digital timesheets for AI processing and validation. This feature integrates with the billing system to automatically extract visit data and create billing records using OpenAI's Vision API.
Features
1. File Upload
- Supported Formats: PDF, JPEG, PNG, TIFF
- File Size Limit: 10MB
- Upload Sources:
- Admin: Always "manual" (hidden from UI)
- Public Link: Always "clinician_link" (automatic)
2. AI Processing with OpenAI
- OpenAI Vision API: Uses GPT-4o for intelligent text extraction
- Automatic Processing: Files are automatically processed for data extraction
- Confidence Scoring: Each extraction includes a confidence score (0-100%)
- Status Tracking: pending → processing → completed/failed
3. Data Extraction
- Extracted Fields: Date, start time, end time, total hours, patient name, clinician name, visit type, notes
- Metadata Storage: Original file, AI confidence, extraction details
- JSON Storage: All extracted data stored in structured format
4. Validation Workflow
- Manual Review: Human validation of AI results
- Status Management: pending → validated/rejected
- Audit Trail: Track who validated what and when
How to Use
Uploading a Timesheet
Option 1: Admin Dashboard (Authenticated Users)
-
Navigate to Billing Dashboard
- Go to
/admin/billing - Click the "Upload Timesheet" button in the top navigation
- Go to
-
Select File
- Click "Select File" and choose your timesheet
- Supported formats: PDF, JPEG, PNG, TIFF
- Maximum size: 10MB
- Upload source automatically set to "manual"
-
Upload
- Click "Upload Timesheet"
- Watch the progress bar
- File will be uploaded to private Supabase Storage
-
Copy Clinician Link
- Use the "Copy Clinician Link" button to get a shareable link for clinicians
- Link automatically sets upload source to "clinician_link"
Option 2: Public Clinician Link (Unauthenticated Users)
-
Use Direct Link
- Navigate to
/timesheet-upload/[organizationId]/[clinicianId] - No login required
- Organization and clinician IDs are embedded in the URL
- Navigate to
-
Upload Process
- Same file validation and upload process
- Automatically tagged with
clinician_linksource - Secure organization-based storage
Monitoring AI Processing Status
-
Check Timesheet Tab
- Switch to the "Timesheets" tab in the dashboard
- View all uploaded timesheets with their current status
-
Status Indicators
- Pending: File uploaded, waiting for AI processing
- Processing: AI analysis in progress
- Completed: AI processing finished successfully
- Failed: AI processing failed, retry available
-
Confidence Scores
- Green (80%+): High confidence, likely accurate
- Yellow (60-79%): Medium confidence, review recommended
- Red (<60%): Low confidence, manual review required
Validating Results
-
Review Extracted Data
- Click on completed timesheets to view extracted information
- Verify date, times, and hours are correct
-
Approve or Reject
- Approve: Mark as validated, data becomes available for billing
- Reject: Mark as rejected, requires correction and re-upload
-
Retry Failed Processing
- For failed AI processing, click "Retry OCR" to process again
- Useful for poor quality scans or AI processing errors
Security & Permissions
Row Level Security (RLS)
- Users can only access timesheets from their organization
- File uploads restricted to organization-specific storage folders
- Validation actions logged with user and timestamp
File Access Control
- Private Storage: Files not publicly accessible
- Signed URLs: Temporary access for authenticated users
- Organization Isolation: Files stored by organization ID
- Public Upload: Clinician link allows unauthenticated uploads to specific orgs
Integration with Billing
Data Flow
- Upload → File stored in private Supabase Storage
- AI Processing → OpenAI Vision API extracts data
- Validation → Human review and approval
- Billing → Data available for visit creation and billing
Billing Status Impact
- Validated timesheets contribute to billing calculations
- AI confidence scores affect billing status determination
- Extracted data used to create visit records automatically
Troubleshooting
Common Issues
-
Upload Fails
- Check file size (must be < 10MB)
- Verify file format (PDF, JPEG, PNG, TIFF)
- Ensure valid organization ID format
-
AI Processing Fails
- Check image quality (clear, well-lit, good contrast)
- Verify text is readable and not handwritten in cursive
- Check OpenAI API key configuration
-
Low Confidence Scores
- Review original file quality
- Check for smudges, shadows, or poor lighting
- Consider manual data entry for critical records
Best Practices
-
File Quality
- Use high-resolution scans (300 DPI minimum)
- Ensure good lighting and contrast
- Avoid shadows, creases, or damage
-
Content Clarity
- Use clear, printed text when possible
- Avoid cursive handwriting
- Ensure all required fields are visible
-
Regular Monitoring
- Check AI processing status regularly
- Validate results promptly
- Address failed processing quickly