Skip to content

Lab Requests (طلبات الفحص)

Lab Requests represent test orders placed by doctors for patients. Each request contains one or more investigations and tracks the order through its lifecycle from creation to completion or cancellation.

Entity Attributes

FieldTypeRequiredDescription
idintegerautoPrimary key
request_numberstringautoAuto-generated request number
patient_idFKyesPatient being tested
doctor_idFKyesOrdering doctor
priorityenumyesroutine, urgent, stat
statusenumautopending, sample_collected, in_progress, partial_result, completed, cancelled
sourceenumyeswalk_in, in_patient, emergency, external
clinical_infotextnoClinical information / reason for test
notestextnoAdditional notes
total_amountdecimal(12,3)autoSum of investigation prices
discount_amountdecimal(12,3)noTotal discount applied
net_amountdecimal(12,3)autoTotal minus discount
branch_idFKnoBranch where request was placed
requested_atdatetimeautoWhen the request was created
completed_atdatetimeautoWhen all results are released
cancelled_atdatetimeautoWhen the request was cancelled
cancellation_reasonstringnoReason for cancellation

Request Investigation (Pivot)

FieldTypeDescription
lab_request_idFKParent request
investigation_idFKOrdered investigation
statusstringPer-investigation status
pricedecimal(12,3)Investigation price
discountdecimal(12,3)Per-investigation discount
net_pricedecimal(12,3)Price minus discount
notestextInvestigation-specific notes

Status Workflow

API Endpoints

MethodEndpointDescriptionPermission
GET/api/lis/requestsList requests (paginated)lis.requests.view
POST/api/lis/requestsCreate a requestlis.requests.create
GET/api/lis/requests/{id}Get request detailslis.requests.view
PUT/api/lis/requests/{id}Update a requestlis.requests.update
POST/api/lis/requests/{id}/cancelCancel a requestlis.requests.update
POST/api/lis/requests/{id}/investigationsAdd investigationlis.requests.update
DELETE/api/lis/requests/{id}/investigations/{inv_id}Remove investigationlis.requests.update

Query Parameters (List)

ParameterTypeDescription
searchstringSearch by request number or patient name
statusstringFilter by status
prioritystringFilter by priority
sourcestringFilter by source
patient_idintegerFilter by patient
doctor_idintegerFilter by doctor
fromdateStart date filter
todateEnd date filter

Request / Response Examples

Create Request

bash
curl -X POST /api/lis/requests \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
    "patient_id": 1,
    "doctor_id": 1,
    "priority": "routine",
    "source": "walk_in",
    "clinical_info": "Annual checkup",
    "investigations": [
      {"investigation_id": 1},
      {"investigation_id": 5, "notes": "Fasting sample"}
    ],
    "branch_id": 1
  }'
dart
final response = await dio.post('/api/lis/requests', data: {
  'patient_id': 1,
  'doctor_id': 1,
  'priority': 'routine',
  'source': 'walk_in',
  'clinical_info': 'Annual checkup',
  'investigations': [
    {'investigation_id': 1},
    {'investigation_id': 5, 'notes': 'Fasting sample'},
  ],
  'branch_id': 1,
});

Cancel Request

bash
curl -X POST /api/lis/requests/1/cancel \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{"cancellation_reason": "Patient did not arrive"}'
dart
final response = await dio.post('/api/lis/requests/1/cancel', data: {
  'cancellation_reason': 'Patient did not arrive',
});

Add Investigation to Request

bash
curl -X POST /api/lis/requests/1/investigations \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{"investigation_id": 10}'
dart
final response = await dio.post('/api/lis/requests/1/investigations', data: {
  'investigation_id': 10,
});

Business Rules

  1. No delete -- Requests cannot be deleted, only cancelled.
  2. Cancel restrictions -- Only requests with status pending or sample_collected can be cancelled.
  3. Panel expansion -- When a panel investigation is added, all its member investigations are also added.
  4. Price calculation -- total_amount is automatically calculated from investigation prices at the time of creation.
  5. Add/remove investigations -- Investigations can be added or removed from active requests. Amounts are recalculated.

Moon ERP API Documentation