Overview
The Medical Records API provides access to veterinary medical documentation including SOAP notes, examination findings, diagnoses, and treatment plans.
The Medical Record Object
Veterinarian who created the record
Template used (e.g., “SOAP”, “Canine Dental Chart”)
Date of examination (ISO 8601)
Record status: draft, pending_review, reviewed, finalized
Additional clinical notes
URL to audio dictation recording
URLs to attached documents/images
AI-generated clinical insights
SOAPContent Object
Subjective findings (owner’s report, history)
Objective findings (physical exam, vitals)
Treatment plan and recommendations
ClinicalInsight Object
Type: risk, diagnosis, suggestion
Priority: high, medium, low
AI confidence score (0-1)
Status: pending, accepted, rejected
Create Medical Record
Create a new medical record from SOAP notes:
curl -X POST http://localhost:3000/api/medical-records \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"petId": "pet-123",
"petName": "Buddy",
"ownerName": "John Smith",
"vetName": "Dr. Sarah Chen",
"templateName": "SOAP",
"recordDate": "2024-12-15T10:00:00Z",
"status": "draft",
"soap": {
"subjective": "Owner reports decreased appetite for 2 days. Vomiting once yesterday.",
"objective": "T: 101.5°F, HR: 90, RR: 20. Mild abdominal tenderness.",
"assessment": "Likely gastroenteritis. DDx: dietary indiscretion.",
"plan": "Bland diet 3-5 days. Cerenia 1mg/kg PO SID x3 days."
}
}'
List Medical Records
curl -X GET "http://localhost:3000/api/medical-records?petId=pet-123&status=finalized" \
-H "Authorization: Bearer $TOKEN"
Query Parameters
Records on or before date
Response
[
{
"id": "rec-001",
"petId": "pet-123",
"petName": "Buddy",
"ownerName": "John Smith",
"vetName": "Dr. Sarah Chen",
"templateName": "SOAP",
"recordDate": "2024-12-15T10:00:00Z",
"status": "finalized",
"soap": {
"subjective": "Owner reports decreased appetite for 2 days. Vomiting once yesterday. Still drinking water normally.",
"objective": "T: 101.5°F, HR: 90, RR: 20. Mild abdominal tenderness on palpation. No masses palpable. Mucous membranes pink and moist.",
"assessment": "Likely mild gastroenteritis. DDx includes dietary indiscretion, parasitic infection, foreign body.",
"plan": "Bland diet (boiled chicken and rice) for 3-5 days. Cerenia 1mg/kg PO SID x3 days. Recheck if vomiting continues >48hrs."
},
"notes": "Client counseled on dietary management",
"insights": [
{
"id": "ins-001",
"type": "suggestion",
"priority": "medium",
"title": "Consider Fecal Examination",
"description": "Given the GI symptoms, a fecal examination could rule out parasitic causes.",
"confidence": 0.75,
"status": "pending"
}
],
"createdAt": "2024-12-15T10:30:00Z",
"updatedAt": "2024-12-15T11:00:00Z"
}
]
Get Record by ID
curl -X GET http://localhost:3000/api/medical-records/rec-001 \
-H "Authorization: Bearer $TOKEN"
Update Medical Record
curl -X PATCH http://localhost:3000/api/medical-records/rec-001 \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"status": "finalized",
"notes": "Follow-up scheduled for 1 week"
}'
Complete Workflow Example
import { supabase } from '@/lib/supabase';
// 1. Create draft record during appointment
const { data: draft } = await supabase
.from('medical_records')
.insert({
id: `rec-${Date.now()}`,
pet_id: 'pet-123',
pet_name: 'Buddy',
owner_name: 'John Smith',
vet_name: 'Dr. Sarah Chen',
template_name: 'SOAP',
record_date: new Date().toISOString().split('T')[0],
status: 'draft',
soap_subjective: 'Acute vomiting and diarrhea',
soap_objective: 'Dehydrated, elevated temp',
soap_assessment: 'Gastroenteritis',
soap_plan: 'IV fluids, anti-emetics'
})
.select()
.single();
// 2. Update with additional findings
await supabase
.from('medical_records')
.update({
soap_objective: draft.soap_objective + '. Weight: 30kg (down from 32kg).',
status: 'pending_review'
})
.eq('id', draft.id);
// 3. Reviewing veterinarian approves
await supabase
.from('medical_records')
.update({ status: 'reviewed' })
.eq('id', draft.id);
// 4. Finalize record
await supabase
.from('medical_records')
.update({
status: 'finalized',
notes: 'Client given printed discharge instructions'
})
.eq('id', draft.id);
// 5. Log to audit trail
await supabase.from('audit_log').insert({
id: `audit-${Date.now()}`,
user_name: 'Dr. Sarah Chen',
action: 'finalized',
resource: 'medical_records',
resource_id: draft.id,
details: 'SOAP record finalized for Buddy',
timestamp: new Date().toISOString()
});
Status Transitions
Valid status transitions:
draft → pending_review → reviewed → finalized
↓ ↓ ↓
draft draft draft
Records marked as finalized cannot be edited. Create an addendum record instead.