callmed-node
v1.0.0
Published
Official Node.js/TypeScript SDK for the CallMed Healthcare Rails API
Maintainers
Readme
@callmed/node
The official Node.js/TypeScript SDK for the CallMed Healthcare Rails API.
Build healthcare integrations in minutes. Verify practitioners, check insurance eligibility, process claims, and access FHIR health records — all with a single, type-safe client.
Installation
npm install @callmed/nodeQuick Start
import { CallMed } from '@callmed/node';
const callmed = new CallMed({
apiKey: 'cmd_live_...', // Your API Key from the CallMed Dashboard
// baseURL: 'http://localhost:3000' // Optional: for local development
});Usage
Provider Rail — Verify a Doctor's License
const result = await callmed.provider.verifyLicense('MDCN/2008/45231');
console.log(result.data.practitioner.name);
// "Dr. Adewale Ogunbiyi"
console.log(result.data.practitioner.verification.status);
// "verified"Provider Rail — Search Practitioners
const results = await callmed.provider.search({
specialty: 'Cardiology',
state: 'Lagos',
verified_only: true,
});Insurance Rail — Check Patient Eligibility
const eligibility = await callmed.insurance.checkEligibility({
callmedId: 'CMD-DEMO01',
procedureCode: 'GP001',
});
if (eligibility.data.is_eligible) {
console.log(`Covered: ₦${eligibility.data.coverage.covered_amount}`);
console.log(`Copay: ₦${eligibility.data.coverage.patient_copay}`);
}Insurance Rail — Submit a Claim
const claim = await callmed.insurance.submitClaim({
callmed_id: 'CMD-DEMO01',
procedure_codes: ['GP001'],
diagnosis_codes: ['Z00.0'],
total_amount: 15000,
treatment_date: '2026-03-04',
});
console.log(claim.data.claim_id);
// "CLM-9F8K2A-XP1Z"Identity Rail — Sign in with CallMed (OAuth 2.0)
// 1. Generate the OAuth authorization URL
const authUrl = callmed.identity.generateAuthorizationUrl(
'your_client_id',
{
redirect_uri: 'https://yourapp.com/callback',
scope: 'profile vitals insurance',
}
);
// Redirect user to `authUrl`
// 2. Exchange the authorization code for a token
const token = await callmed.identity.exchangeToken({
code: 'auth_code_from_callback',
redirect_uri: 'https://yourapp.com/callback',
});
// 3. Use the token to fetch the user's CallMed profile
const profile = await callmed.identity.getProfile(token.data.access_token);
console.log(profile.data.full_name);Data Rail — FHIR Health Records
// Fetch patient records (requires User Access Token)
const records = await callmed.data.getPatientRecords(userAccessToken, {
resourceType: 'Observation',
limit: 10,
});
// Write a new health record
await callmed.data.createRecord('CMD-DEMO01', {
resourceType: 'Observation',
status: 'final',
code: { text: 'Blood Pressure' },
valueQuantity: { value: 120, unit: 'mmHg' },
});Payment Rail — Smart Health Wallets
// Get wallets
const wallets = await callmed.payment.getWallets(userAccessToken);
// Authorize a transaction
const tx = await callmed.payment.authorizeTransaction({
wallet_id: wallets.data[0].id,
amount: 5000,
type: 'debit',
description: 'Pharmacy purchase at HealthPlus',
});Error Handling
The SDK provides structured error classes for common failure scenarios:
import { CallMedError, CallMedAuthenticationError, CallMedRateLimitError } from '@callmed/node';
try {
await callmed.provider.verifyLicense('INVALID_LICENSE');
} catch (error) {
if (error instanceof CallMedAuthenticationError) {
console.error('Invalid API Key');
} else if (error instanceof CallMedRateLimitError) {
console.error(`Rate limited. Retry in ${error.retryAfter}ms`);
} else if (error instanceof CallMedError) {
console.error(`API Error [${error.code}]: ${error.message}`);
}
}Note: The SDK automatically retries
429(Rate Limit) responses up to 2 times by default. You can configure this withmaxRetries.
Configuration
| Option | Description | Default |
| ------------ | ------------------------------------------ | ------------------------- |
| apiKey | Your CallMed API Key (required) | — |
| baseURL | Base URL for API requests | https://api.callmed.io |
| maxRetries | Max retries on rate-limited responses | 2 |
Available Rails
| Rail | Namespace | Description |
| ------------- | ---------------------- | ---------------------------------------------- |
| Identity | callmed.identity | OAuth 2.0, CallMed ID, user profiles |
| Provider | callmed.provider | Practitioner verification & search |
| Insurance | callmed.insurance | Eligibility checks & claims management |
| Data | callmed.data | FHIR R4 health records exchange |
| Payment | callmed.payment | Smart health wallets & transactions |
License
MIT © CallMed Technologies
