Complete Developer Guide for Frontend Integration
Interactive API testing and documentation
Step-by-step integration guide
Create and manage test orders
Connect with ADMA Doctor Backend
Welcome to the ADMA Laboratory Management System API. This documentation provides comprehensive information for frontend developers to integrate with our lab management system.
| Environment | URL |
|---|---|
| Production | https://labsapi.adma.pk/api |
| Development | http://localhost:5000/api |
{
"success": true,
"data": { ... }
}
// Error Response
{
"success": false,
"message": "Error description"
}
Most endpoints require JWT authentication. Include the token in the Authorization header.
Login to get authentication token
// Login Request fetch('/api/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: "lab@example.com", password: "password123" }) }) .then(res => res.json()) .then(data => { const token = data.token; // Save token for future requests });
// All authenticated requests fetch('/api/test-orders', { headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' } })
Get all active labs
Find nearby labs by location
Get single lab details
// Get user's location navigator.geolocation.getCurrentPosition(async (position) => { const { latitude, longitude } = position.coords; const response = await fetch( `/api/labs/nearby?latitude=${latitude}&longitude=${longitude}&radius=10` ); const { labs } = await response.json(); // Display labs on map });
Create and manage test orders for patients
Create new test order
Get all test orders (with filters)
Update order status
async function createTestOrder(orderData) { const response = await fetch('/api/test-orders', { method: 'POST', headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ patientName: "John Doe", patientPhone: "+92-300-1234567", patientCnic: "42101-1234567-8", labId: 1, testType: "blood_test", tests: ["CBC", "Blood Glucose"], preferredDate: "2026-02-20", preferredTime: "10:00 AM" }) }); return await response.json(); }
| Status | Description |
|---|---|
| Pending | Order created, waiting for lab confirmation |
| Confirmed | Lab confirmed the order |
| Sample Collected | Patient sample collected |
| Processing | Tests are being performed |
| Completed | Results ready |
| Cancelled | Order cancelled |
Create/Upload test results
Get test results for an order
Get all results for a patient
// Fetch all results for a patient async function getPatientResults(phoneNumber) { const response = await fetch( `/api/test-results/patient/${phoneNumber}`, { headers: { 'Authorization': `Bearer ${token}` } } ); const { results } = await response.json(); return results; }
Integration with ADMA Doctor Backend for seamless test ordering
Create test order from Doctor's prescription
Verify patient ADMA card
// Doctor sends test order from their system const doctorOrder = { doctorId: "DOC001", doctorName: "Dr. Sarah Khan", hospitalName: "City Hospital", patient: { patientId: "P001", name: "John Doe", phone: "+92-300-1234567", admaCardNumber: "ADMA123456789" }, labId: 1, testType: "blood_test", tests: ["CBC", "Liver Function Test"], priority: "urgent", notes: "Check liver function" };
Patient uses location-based search to find nearby labs
GET /api/labs/nearby?latitude=24.8607&longitude=67.0011
Verify patient's ADMA card for coverage
POST /api/integration/verify-adma-card
Patient or Doctor creates a test order
POST /api/test-orders
Lab confirms, collects sample, runs tests
PUT /api/test-orders/:id/status
Lab uploads test results with report
POST /api/test-results
Patient retrieves results via order ID or phone number
GET /api/test-results/patient/:phone
| Status Code | Description |
|---|---|
| 200 | Success |
| 201 | Created |
| 400 | Bad Request - Invalid parameters |
| 401 | Unauthorized - Invalid or missing token |
| 404 | Not Found |
| 500 | Internal Server Error |
{
"success": false,
"message": "Invalid credentials"
}