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
| Field | Type | Required | Description |
|---|
name | string | ✅ | Display name for the task type (e.g. “H&E Staining”) |
duration_unit | string | ✅ | hours or days — unit used to calculate the due date |
duration_value | integer | ✅ | Number of hours or days until the task is due |
same_day_rule_enabled | boolean | ✅ | When true, tasks created within a time window are due the same day |
same_day_cutoff_start | time (HH:MM) | ❌ | Start of the same-day window (required if rule is enabled) |
same_day_cutoff_end | time (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:
{
"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
| Field | Type | Required | Description |
|---|
specimen_id | integer (FK) | ✅ (or specimen_ids) | Single specimen to link |
specimen_ids | array | ✅ (or specimen_id) | Multiple specimens for bulk creation |
work_order_type_id | integer (FK) | ✅ | The task type being assigned |
user_ids | array | ✅ | Staff members assigned to this task (min 1) |
status | string | ✅ | Enviada, En Proceso, or Finalizada |
priority | integer | ✅ | 1 (low), 2 (medium), or 3 (high) |
comments | string | ❌ | Free-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:
| Field | Type | Description |
|---|
specimen_id | integer (FK) | Linked specimen |
work_order_type_id | integer (FK) | Linked work order type |
user_id | integer (FK) | Primary assigned technician |
completed_by_id | integer (FK) | User who marked the order complete |
status | string | Enviada, En Proceso, or Finalizada |
priority | integer | 1, 2, or 3 |
comments | string | Task notes |
due_date | datetime | Calculated due date |
completed_at | datetime | Timestamp 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
Displays all work orders across the lab in a paginated table. Supports the following filters:
| Parameter | Description |
|---|
status | Filter by Enviada, En Proceso, or Finalizada |
priority | Filter by priority level (1, 2, or 3) |
work_order_type_id | Filter by task type |
date_from / date_to | Date range on created_at |
search | Searches comments, status, specimen code, patient name, task type name, and assigned user name |
sort_field | created_at, due_date, status, or priority |
sort_direction | asc or desc |
Results are paginated at 15 per page. Requires the work_orders.view permission.
Personal Work Order Queue
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.