The Specimen module is the operational core of PatoLab. Every diagnostic case begins here: when a specimen is received, it is registered alongside its patient, specimen type, examination, referrer, and billing information, and it immediately enters a prioritised Kanban board where laboratory staff can track it through every phase of the diagnostic process. All subsequent workflows — report editing, invoicing, commissions, and patient notifications — are anchored to a specimen record.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.
Workflow Statuses
Each specimen carries astatus field that advances through seven defined stages. The platform maps each status to a distinct colour so staff can identify a specimen’s phase at a glance on the Kanban board.
| Status | Hex Colour | Tailwind Alias | Description |
|---|---|---|---|
received | #3b82f6 | blue-500 | Specimen has arrived at the lab and been registered. |
macroscopic_review | #8b5cf6 | violet-500 | Pathologist is performing gross (macroscopic) examination. |
processing | #f59e0b | amber-500 | Tissue is being processed (fixation, embedding, sectioning). |
microscopic_review | #d946ef | fuchsia-500 | Pathologist is examining slides under the microscope. |
finalized | #10b981 | emerald-500 | Report has been signed off and the PDF has been generated. |
delivered | #64748b | slate-500 | Report has been delivered to the patient. |
cancelled | #ef4444 | red-500 | Specimen has been voided and removed from active views. |
status_color attribute is automatically appended to every Specimen response, so the React frontend never needs to map status to colour independently.
Kanban Board
Specimens on the index page (GET /specimens) are organised into priority lanes — one swimlane per configured Priority record. Within each lane, cards are sorted by an explicit board_order integer stored in the priorities_specimens_order table, so drag-and-drop reordering is fully server-persisted.
When a card is moved to a different lane or reordered within a lane, the frontend sends a batch update:
priority_id field automatically.
Key Operations
Creating a specimen
Creating a specimen
Specimens are created via the Kanban board’s creation modal. The request is submitted to:Specimen fields (stored in the
Invoice billing fields (passed in the same request but stored in the
Creating a specimen also generates an invoice, consumes a CAI sequence number, deducts any linked
specimen table):| Field | Type | Required | Notes |
|---|---|---|---|
customer | integer (FK) | ✅ | References customers.id |
specimen_type | integer (FK) | ✅ | References specimen_type.id |
specimen_type_examination | integer (FK) | ✅ | References specimen_type_examination.id |
specimen_category | integer (FK) | ✅ | References specimen_category.id |
referrer | integer (FK) | ✅ | References referrers.id |
priority_id | integer (FK) | ✅ | References priorities.id |
status | string | ✅ | Initial status (typically received) |
anatomic_site | string | ❌ | Location of the tissue biopsy |
diagnosis | string | ❌ | Preliminary clinical diagnosis |
clinical_notes | string | ❌ | Free-text clinical context |
medical_order_file | file | ❌ | PDF or image (max 30 MB PDF / 10 MB image) |
invoices table):| Field | Type | Required | Notes |
|---|---|---|---|
quantity | integer | ✅ | Invoice line quantity (min: 1) |
amount | numeric | ✅ | Gross invoice amount |
discount | numeric | ✅ | Discount amount |
payment_type | string | ✅ | cash, credit card, bank transfer, check, or credit |
age_discount_type | string | ❌ | third or fourth age discount |
age_discount_amount | numeric | ❌ | Age-based discount amount |
custom_amount | numeric | ❌ | Override charge separate from the base price |
custom_amount_reason | string | ❌ | Explanation for the custom amount |
insumos (supply products) from inventory, and sends a WhatsApp notification to the patient.Assigning a pathologist
Assigning a pathologist
Each specimen may have one or more pathologists assigned to it. Access can be scoped independently to the macroscopy and microscopy phases.Assign a pathologist:If the user is already assigned, the pivot record is updated in place (no duplicate).Remove a pathologist:Pathologist access flags (
macroscopy_access, microscopy_access) control which editor sections the user can write to inside the report editor.Bulk actions
Bulk actions
Select multiple specimens on the Kanban board to apply an action to all of them at once:Supported
Deleting via bulk action performs a soft delete by setting
action values:| Action | value | Required permission |
|---|---|---|
change_status | New status string | specimens.edit |
change_priority | Priority ID | specimens.edit |
assign_pathologist | User ID | specimens.manage |
unassign_pathologist | User ID | specimens.manage |
delete | (not used) | specimens.delete |
active = false; the record is not removed from the database.Grouping specimens
Grouping specimens
Multiple specimens belonging to the same patient visit can be bundled into a specimen group for collective invoicing and public tracking:A group has its own combined invoice and its own public progress page (see Public Tracking URLs below).
Public Tracking URLs
PatoLab generates two unauthenticated, token-protected pages that patients can access without logging in.Individual Specimen Progress
finalized, a delivery_token is embedded in the WhatsApp notification link. Visiting the page with the correct delivery_token automatically advances the status to delivered.
Specimen Group Progress
The
Specimen model has two grouping flags: is_group (boolean, cast) marks specimens that are part of a group billing scenario, and group_id (FK to specimen_groups) links the individual specimen to its parent group. Check both fields when building invoicing or reporting logic that must account for grouped cases.