Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/lerichardv/patolab-platform/llms.txt

Use this file to discover all available pages before exploring further.

The Work Orders system in PatoLab provides a lightweight task management layer on top of the specimen workflow. While specimen statuses track the diagnostic progress of a case, work orders track the ancillary lab tasks that must be completed alongside that diagnostic work — such as staining, slide preparation, immunohistochemistry, or equipment maintenance. Each work order is linked to a specimen and assigned to one or more staff members with a defined priority, due date, and completion status.
Work orders are independent of specimen status. Updating a work order’s status does not change the linked specimen’s status, and vice versa. They represent parallel task tracks, not a replacement for the specimen’s diagnostic workflow.

Work Order Types

Work order types define the catalogue of lab tasks that can be assigned. They configure timing rules so that due dates are calculated automatically when a work order is created.

Work Order Type Routes

GET    /work-orders                              # List all work order types (paginated)
POST   /work-orders                              # Create a new work order type
PUT    /work-orders/{work_order_type}            # Update a work order type
DELETE /work-orders/{work_order_type}            # Soft-delete a work order type
The resource route is declared with the work_order_type parameter alias (i.e. Route::resource('work-orders', WorkOrderTypeController::class)->parameters(['work-orders' => 'work_order_type'])), so the path segment placeholder is {work_order_type}. These routes map to the WorkOrderTypeController and require work_orders.view, work_orders.create, work_orders.edit, and work_orders.delete permissions respectively.

Work Order Type Fields

FieldTypeRequiredDescription
namestringDisplay name for the task type (e.g. “H&E Staining”)
duration_unitstringhours or days — unit used to calculate the due date
duration_valueintegerNumber of hours or days until the task is due
same_day_rule_enabledbooleanWhen true, tasks created within a time window are due the same day
same_day_cutoff_starttime (HH:MM)Start of the same-day window (required if rule is enabled)
same_day_cutoff_endtime (HH:MM)End of the same-day window (must be after same_day_cutoff_start)
Same-day rule: If same_day_rule_enabled is true and the work order is created while the current time falls between same_day_cutoff_start and same_day_cutoff_end, the due date is set to end-of-day today. Otherwise, the due date is calculated by adding duration_value hours or days to the creation time.

Creating a Work Order Record

Work order records link a work order type to one or more specimens and assign them to one or more users:
POST /work-order-records
{
  "specimen_id": 42,
  "work_order_type_id": 3,
  "user_ids": [7, 12],
  "status": "Enviada",
  "priority": 2,
  "comments": "Rush staining required for frozen section."
}
You can also create work orders for multiple specimens in one request using specimen_ids instead of specimen_id:
{
  "specimen_ids": [42, 43, 44],
  "work_order_type_id": 3,
  "user_ids": [7],
  "status": "Enviada",
  "priority": 1
}

Work Order Record Fields

FieldTypeRequiredDescription
specimen_idinteger (FK)✅ (or specimen_ids)Single specimen to link
specimen_idsarray✅ (or specimen_id)Multiple specimens for bulk creation
work_order_type_idinteger (FK)The task type being assigned
user_idsarrayStaff members assigned to this task (min 1)
statusstringEnviada, En Proceso, or Finalizada
priorityinteger1 (low), 2 (medium), or 3 (high)
commentsstringFree-text notes for the assignee
The first user in user_ids is stored as the primary assignee (user_id). All users in the array are linked via the work_orders_users pivot table.

Work Order Model Fields

The WorkOrder Eloquent model has the following $fillable attributes:
FieldTypeDescription
specimen_idinteger (FK)Linked specimen
work_order_type_idinteger (FK)Linked work order type
user_idinteger (FK)Primary assigned technician
completed_by_idinteger (FK)User who marked the order complete
statusstringEnviada, En Proceso, or Finalizada
priorityinteger1, 2, or 3
commentsstringTask notes
due_datedatetimeCalculated due date
completed_atdatetimeTimestamp when the order was finalised
Work orders use SoftDeletes — deleting a work order type or record sets deleted_at rather than permanently removing the row.

Admin View

GET /admin-work-orders
Displays all work orders across the lab in a paginated table. Supports the following filters:
ParameterDescription
statusFilter by Enviada, En Proceso, or Finalizada
priorityFilter by priority level (1, 2, or 3)
work_order_type_idFilter by task type
date_from / date_toDate range on created_at
searchSearches comments, status, specimen code, patient name, task type name, and assigned user name
sort_fieldcreated_at, due_date, status, or priority
sort_directionasc or desc
Results are paginated at 15 per page. Requires the work_orders.view permission.

Personal Work Order Queue

GET /my-work-orders
Shows only the work orders assigned to the currently authenticated user. The list uses the same status and date range filters as the admin view, with filter state persisted in per-user cookies (cookie key: status_filter_my_work_orders_user_{id}).

Updating a Work Order Status

PUT /my-work-orders/{work_order}/status
Allows the assigned staff member to advance their own work order through the Enviada → En Proceso → Finalizada lifecycle. When a work order is marked Finalizada, the completed_at timestamp and completed_by_id are recorded automatically.

Build docs developers (and LLMs) love