Skip to main content

Overview

The Medical Records API provides access to veterinary medical documentation including SOAP notes, examination findings, diagnoses, and treatment plans.

The Medical Record Object

id
string
required
Unique record identifier
petId
string
required
ID of the patient
petName
string
required
Patient name
ownerName
string
required
Owner’s name
vetName
string
required
Veterinarian who created the record
templateName
string
required
Template used (e.g., “SOAP”, “Canine Dental Chart”)
recordDate
string
required
Date of examination (ISO 8601)
status
enum
default:"draft"
Record status: draft, pending_review, reviewed, finalized
soap
SOAPContent
required
SOAP note content
notes
string
Additional clinical notes
audioUrl
string
URL to audio dictation recording
documentUrls
string[]
URLs to attached documents/images
insights
ClinicalInsight[]
AI-generated clinical insights
createdAt
string
Creation timestamp
updatedAt
string
Last update timestamp

SOAPContent Object

subjective
string
Subjective findings (owner’s report, history)
objective
string
Objective findings (physical exam, vitals)
assessment
string
Assessment and diagnosis
plan
string
Treatment plan and recommendations

ClinicalInsight Object

id
string
Insight identifier
type
enum
Type: risk, diagnosis, suggestion
priority
enum
Priority: high, medium, low
title
string
Insight title
description
string
Detailed description
confidence
number
AI confidence score (0-1)
status
enum
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

petId
string
Filter by patient
vetName
string
Filter by veterinarian
status
string
Filter by status
startDate
string
Records on or after date
endDate
string
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.

Build docs developers (and LLMs) love