Skip to main content

Service Requests

Service requests (FHIR ServiceRequest) represent orders for clinical services — lab orders, imaging requests, referrals, procedure orders, and other clinical activities that need to be fulfilled.

Create a Service Request

const { data: order } = await clinik.serviceRequests.create({
  status: 'active',
  intent: 'order',
  patientId: 'pt_abc123',
  encounterId: 'enc_xyz789',
  code: {
    system: 'http://loinc.org',
    code: '24323-8',
    display: 'Comprehensive Metabolic Panel',
  },
  category: ['laboratory'],
  priority: 'urgent',
  requesterId: 'prac_def456',
  occurrenceDateTime: '2025-02-01T08:00:00Z',
  reasonCode: ['Pre-operative assessment'],
  note: 'Fasting required — draw before 10am',
  patientInstruction: 'Do not eat or drink after midnight',
});

Common Use Cases

Lab Order

const { data } = await clinik.serviceRequests.create({
  status: 'active',
  intent: 'order',
  patientId: 'pt_abc123',
  code: { system: 'http://loinc.org', code: '24331-1', display: 'Lipid Panel' },
  category: ['laboratory'],
  priority: 'routine',
  requesterId: 'prac_def456',
});

Imaging Request

const { data } = await clinik.serviceRequests.create({
  status: 'active',
  intent: 'order',
  patientId: 'pt_abc123',
  code: 'MRI Brain without contrast',
  category: ['imaging'],
  priority: 'urgent',
  requesterId: 'prac_def456',
  reasonCode: ['Persistent headaches', 'Rule out intracranial pathology'],
  bodySite: ['Brain'],
});

Referral

const { data } = await clinik.serviceRequests.create({
  status: 'active',
  intent: 'order',
  patientId: 'pt_abc123',
  code: 'Cardiology consultation',
  category: ['referral'],
  priority: 'routine',
  requesterId: 'prac_pcp',
  performerType: 'Cardiologist',
  reasonCode: ['Uncontrolled hypertension despite dual therapy'],
  patientInstruction: 'Bring your home blood pressure log to the appointment',
});

Do Not Perform

const { data } = await clinik.serviceRequests.create({
  status: 'active',
  intent: 'order',
  patientId: 'pt_abc123',
  code: 'Aspirin administration',
  doNotPerform: true,
  reasonCode: ['Aspirin allergy'],
});

Status Lifecycle

draftactiveon-holdcompleted / revoked

Linking to Tasks

Service requests are often fulfilled by tasks:
// Create the order
const { data: order } = await clinik.serviceRequests.create({
  status: 'active', intent: 'order',
  patientId: 'pt_abc123',
  code: 'CBC',
  category: ['laboratory'],
});

// Create a task to fulfill it
const { data: task } = await clinik.tasks.create({
  status: 'requested', intent: 'order',
  patientId: 'pt_abc123',
  basedOn: [`ServiceRequest/${order.id}`],
  code: 'lab-draw',
  description: 'Draw blood for CBC',
});

Search Service Requests

const { data } = await clinik.serviceRequests.search({
  patientId: 'pt_abc123',
  status: 'active',
  category: 'laboratory',
  priority: 'urgent',
  sort: '-date',
});