Integration Patterns

Common architectures for embedding PearMedica into hospitals, telemedicine platforms, mobile health apps, and EHR systems. Each pattern includes data flow diagrams and code guidance.

Hospital Triage Kiosk

Embed the assessment API into a self-service kiosk in the hospital reception area. Patients input symptoms on a tablet, and the API returns triage urgency and recommended department routing.

javascript
// 1. Patient inputs symptoms on kiosk touchscreen
// 2. Backend server calls PearMedica API
// 3. Triage result displayed + printed ticket

// Your backend (Node.js / Python / PHP)
try {
  const result = await fetch('https://api.pearmedica.com/v1/assess', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer sk_live_your_key',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      patient: { age: 45, sex: 'female', location: 'lagos_nigeria' },
      evidence: [
        { id: 's_chest_pain', choice_id: 'present', source: 'initial' },
        { id: 's_shortness_of_breath', choice_id: 'present', source: 'initial' },
      ],
    }),
  });

  if (!result.ok) {
    throw new Error(`API error: ${result.status} ${result.statusText}`);
  }

  const assessment = await result.json();

  // Route patient based on triage urgency
  if (assessment.triage.urgency === 'emergency') {
    // Alert nursing station immediately
    await alertNursingStation(assessment);
  } else {
    // Print queue ticket with department assignment
    printTicket(assessment.triage.recommended_specialist);
  }
} catch (error) {
  console.error('PearMedica API call failed:', error);
  // Show fallback UI / manual triage form
  showFallbackTriageForm();
}

Telemedicine Pre-Consultation

Run a conversational symptom interview before the doctor joins the call. The doctor receives a structured summary with differential diagnosis, urgency rating, and recommended next questions.

1

Patient Books Appointment

Via your app or website. Store the booking ID.

2

Symptom Interview

Use the conversational flow API (X-Interview-Id) to gather evidence iteratively.

3

Assessment Summary

When should_stop is true, save the assessment result to the appointment record.

4

Doctor Dashboard

Doctor sees structured data: conditions ranked by probability, triage level, and red flags.

EHR / EMR Integration

PearMedica assessment results include standardised medical identifiers that map to common health data standards:

API FieldStandardUse Case
conditions[].idInternal → ICD-10 mappableDiagnosis coding for insurance claims
evidence[].idInternal → SNOMED CT mappableClinical documentation in EHR problem list
triage.urgency5-level triage scaleESI-compatible triage assignment
nearest_facilitiesLat/lng coordinatesGIS integration for facility routing

Free-Text Intake Form

Use the NLP Parse endpoint to convert free-text patient descriptions into structured evidence, then feed that evidence into the assessment engine:

javascript
// Step 1: Parse free text into structured symptoms
const parsed = await fetch('https://api.pearmedica.com/v1/parse', {
  method: 'POST',
  headers: { 'Authorization': 'Bearer sk_live_key', 'Content-Type': 'application/json' },
  body: JSON.stringify({
    text: "I have a bad headache and fever for 3 days, no cough",
    age: { value: 30 },
    sex: "female"
  }),
});

const { mentions } = await parsed.json();
// mentions → [{ id: "s_headache", choice_id: "present" }, { id: "s_fever", ... }, ...]

// Step 2: Feed parsed evidence into assessment
const assessment = await fetch('https://api.pearmedica.com/v1/assess', {
  method: 'POST',
  headers: { 'Authorization': 'Bearer sk_live_key', 'Content-Type': 'application/json' },
  body: JSON.stringify({
    patient: { age: 30, sex: 'female' },
    evidence: mentions.map(m => ({
      id: m.id, choice_id: m.choice_id, source: 'initial'
    })),
  }),
});

Related Resources