Skip to main content

GET /api/patients

Retrieve all patient records with room assignments and task information.

Request

No parameters required.
curl http://localhost:3001/api/patients

Response

Returns an array of patient objects.
patients
array
Array of patient objects, each containing:

Response Example

[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "patient_id": "PT-001",
    "mrn": "123456",
    "name": "John Doe",
    "age": 67,
    "sex": "M",
    "diagnosis": "Acute MI",
    "condition": "Stable",
    "risk_level": "high",
    "code_status": "Full Code",
    "medications": ["Aspirin 81mg daily", "Metoprolol 25mg BID"],
    "allergies": ["Penicillin"],
    "admission_date": "2026-03-01T08:00:00Z",
    "last_vitals": {
      "bp": "142/88",
      "hr": 78,
      "temp": "98.6",
      "respRate": 16,
      "o2Sat": 96
    },
    "handoff_notes": "Patient stable, troponin trending down...",
    "image_analysis": "Whiteboard shows BP improvement...",
    "last_handoff_update": "2026-03-04T19:00:00Z",
    "rooms": {
      "id": "401A",
      "grid_x": 2,
      "grid_y": 3
    },
    "tasks": [
      {
        "id": "task-001",
        "time": "20:00",
        "description": "Evening medications",
        "priority": "high",
        "type": "medication",
        "completed": false
      }
    ],
    "created_at": "2026-03-01T08:00:00Z",
    "updated_at": "2026-03-04T19:00:00Z"
  }
]

GET /api/patients/:id

Retrieve a single patient record by MRN.

Request

id
string
required
Patient MRN (Medical Record Number)
curl http://localhost:3001/api/patients/123456

Response

Returns a single patient object (same structure as GET /api/patients array items).
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "patient_id": "PT-001",
  "mrn": "123456",
  "name": "John Doe",
  "age": 67,
  "sex": "M",
  "diagnosis": "Acute MI",
  "rooms": {
    "id": "401A",
    "grid_x": 2,
    "grid_y": 3
  },
  "tasks": [...]
}

Error Responses

404
error
Patient not found
{"error": "Patient not found"}

POST /api/patients/:id/handoff

Save handoff notes and image analysis for a patient.

Request

id
string
required
Patient MRN
handoffNotes
string
required
AI-generated handoff summary (from /api/summarize-record/claude)
imageAnalysis
string
Image analysis text (from /api/analyze-image/claude)
timestamp
string
ISO 8601 timestamp. Defaults to current time if not provided.

Request Example

curl -X POST http://localhost:3001/api/patients/123456/handoff \
  -H "Content-Type: application/json" \
  -d '{
    "handoffNotes": "## Changes Since Last Handoff\n\n**COMPLETED:** Troponin draw...",
    "imageAnalysis": "Whiteboard shows BP trending down from 158/92...",
    "timestamp": "2026-03-04T19:00:00Z"
  }'

Response

success
boolean
Whether the operation succeeded
message
string
Success message
handoffData
object
Saved handoff information

Response Example

{
  "success": true,
  "message": "Handoff notes saved successfully",
  "handoffData": {
    "handoffNotes": "## Changes Since Last Handoff\n\n**COMPLETED:** Troponin draw...",
    "imageAnalysis": "Whiteboard shows BP trending down...",
    "lastHandoffUpdate": "2026-03-04T19:00:00Z"
  }
}

Error Responses

404
error
Patient not found
{
  "error": "Patient not found",
  "searchedMRN": "123456"
}
500
error
Failed to save
{
  "error": "Failed to save handoff notes",
  "details": "Error message"
}

Complete Handoff Workflow

1

Analyze Whiteboard Image

const imageResult = await fetch('/api/analyze-image/claude', {
  method: 'POST',
  body: formData
}).then(r => r.json());
2

Get Patient Data

const patient = await fetch('/api/patients/123456')
  .then(r => r.json());
3

Generate Handoff Summary

const summary = await fetch('/api/summarize-record/claude', {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    patientData: patient,
    previousNotes: patient.handoff_notes,
    imageAnalysis: imageResult.summary
  })
}).then(r => r.json());
4

Save Handoff

await fetch('/api/patients/123456/handoff', {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    handoffNotes: summary.summary,
    imageAnalysis: imageResult.summary,
    timestamp: new Date().toISOString()
  })
});

Integration Example

// Complete handoff workflow
async function performHandoff(mrn, whiteboardImage) {
  try {
    // 1. Analyze whiteboard
    const formData = new FormData();
    formData.append('image', whiteboardImage);
    
    const imageAnalysis = await fetch('/api/analyze-image/claude', {
      method: 'POST',
      body: formData
    }).then(r => r.json());
    
    // 2. Get patient data
    const patient = await fetch(`/api/patients/${mrn}`)
      .then(r => r.json());
    
    // 3. Generate comprehensive summary
    const summary = await fetch('/api/summarize-record/claude', {
      method: 'POST',
      headers: {'Content-Type': 'application/json'},
      body: JSON.stringify({
        patientData: patient,
        previousNotes: patient.handoff_notes,
        imageAnalysis: imageAnalysis.summary
      })
    }).then(r => r.json());
    
    // 4. Save handoff
    const result = await fetch(`/api/patients/${mrn}/handoff`, {
      method: 'POST',
      headers: {'Content-Type': 'application/json'},
      body: JSON.stringify({
        handoffNotes: summary.summary,
        imageAnalysis: imageAnalysis.summary,
        timestamp: new Date().toISOString()
      })
    }).then(r => r.json());
    
    console.log('Handoff completed:', result.message);
    return result;
    
  } catch (error) {
    console.error('Handoff failed:', error);
    throw error;
  }
}

// Usage
performHandoff('123456', fileInput.files[0]);

Build docs developers (and LLMs) love