Laboratory

The Laboratory API manages lab orders, specimen collection, and results. Lab orders can be fulfilled at any participating laboratory in the MediLoop network.

Endpoints

POST/api/v1/lab-orders/Create a lab order
GET/api/v1/lab-orders/List lab orders
GET/api/v1/lab-orders/{id}/Get lab order details
PUT/api/v1/lab-orders/{id}/Update lab order
POST/api/v1/lab-orders/{id}/cancel/Cancel lab order
GET/api/v1/lab-orders/{id}/results/Get lab results

The LabOrder Object

Attributes

iduuid

Unique identifier.

order_numberstring

Human-readable order number.

patient_uhidstring

Patient UHID.

encounter_iduuidnullable

Associated encounter.

statusstring

Order status.

prioritystring

Priority: routine, urgent, stat.

test_codestring

LOINC code for the test.

test_namestring

Test display name.

categorystring

Test category (hematology, chemistry, etc.).

ordering_provider_iduuid

Ordering provider ID.

ordering_provider_namestring

Provider name.

performing_lab_iduuidnullable

Lab facility ID.

performing_lab_namestringnullable

Lab name.

clinical_notesstringnullable

Clinical notes for lab.

specimen_collectedboolean

Whether specimen was collected.

specimen_collected_atdatetimenullable

Collection timestamp.

results_availableboolean

Whether results are ready.

ordered_atdatetime

When order was placed.

fhir_service_request_idstring

FHIR resource ID.

RESPONSE200
{
  "id": "lab-123-456-789",
  "order_number": "LAB-2024-001234",
  "patient_uhid": "UG123456789A",
  "encounter_id": "enc-abc-123",
  "status": "active",
  "priority": "routine",
  "test_code": "58410-2",
  "test_name": "Complete Blood Count (CBC)",
  "category": "hematology",
  "ordering_provider_id": "prov-xyz-789",
  "ordering_provider_name": "Dr. Sarah Nakamya",
  "performing_lab_id": "fac-lab-001",
  "performing_lab_name": "Lancet Laboratories",
  "clinical_notes": "Rule out anemia",
  "specimen_collected": true,
  "specimen_collected_at": "2024-01-15T11:00:00Z",
  "results_available": false,
  "ordered_at": "2024-01-15T10:30:00Z"
}

Create a Lab Order

Creates a new laboratory order for a patient.

POST/api/v1/lab-orders/

Request Body

patient_uhidstringrequired

Patient UHID

test_codestringrequired

LOINC test code

test_namestringrequired

Test name

categorystringrequired

Test category

encounter_iduuidoptional

Associated encounter

prioritystringoptional

Priority level

Default: routine

performing_lab_iduuidoptional

Preferred lab

clinical_notesstringoptional

Notes for lab

fasting_requiredbooleanoptional

Fasting required

Request
bash
curl -X POST https://api.mediloop.co/api/v1/lab-orders/ \
  -H "Authorization: Bearer sk_test_..." \
  -H "Content-Type: application/json" \
  -d '{
    "patient_uhid": "UG123456789A",
    "test_code": "58410-2",
    "test_name": "Complete Blood Count (CBC)",
    "category": "hematology",
    "encounter_id": "enc-abc-123",
    "priority": "routine",
    "clinical_notes": "Rule out anemia"
  }'
RESPONSE201
{
  "id": "lab-new-123",
  "order_number": "LAB-2024-001234",
  "patient_uhid": "UG123456789A",
  "status": "active",
  "test_name": "Complete Blood Count (CBC)",
  "priority": "routine",
  "ordered_at": "2024-01-15T10:30:00Z"
}

Get Lab Results

Retrieve results for a completed lab order.

GET/api/v1/lab-orders/{id}/results/
Request
bash
curl https://api.mediloop.co/api/v1/lab-orders/lab-123-456/results/ \
  -H "Authorization: Bearer sk_test_..."
RESPONSE200
{
  "order_id": "lab-123-456",
  "order_number": "LAB-2024-001234",
  "test_name": "Complete Blood Count (CBC)",
  "status": "final",
  "results": [
    {
      "code": "718-7",
      "name": "Hemoglobin",
      "value": 14.2,
      "unit": "g/dL",
      "reference_range": "12.0-16.0",
      "interpretation": "normal"
    },
    {
      "code": "789-8",
      "name": "Red Blood Cells",
      "value": 4.8,
      "unit": "million/uL",
      "reference_range": "4.0-5.5",
      "interpretation": "normal"
    },
    {
      "code": "6690-2",
      "name": "White Blood Cells",
      "value": 7.2,
      "unit": "thousand/uL",
      "reference_range": "4.5-11.0",
      "interpretation": "normal"
    }
  ],
  "resulted_at": "2024-01-15T14:00:00Z",
  "verified_by": "Lab Tech John"
}

List Lab Orders

GET/api/v1/lab-orders/

Query Parameters

patient_uhidstringoptional

Filter by patient

statusstringoptional

Filter by status

categorystringoptional

Filter by category

results_availablebooleanoptional

Filter by results status

date_fromdateoptional

Filter from date

date_todateoptional

Filter to date

Order Status

StatusDescription
draftOrder created but not submitted
activeOrder submitted, awaiting specimen
on-holdOrder temporarily on hold
completedResults available
cancelledOrder cancelled

Test Categories

hematology
chemistry
microbiology
immunology
urinalysis
coagulation
endocrinology
toxicology
pathology