Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Janblack07/OxygenDispatch/llms.txt

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

OxygenDispatch is built on a set of Eloquent models that map closely to the physical and operational reality of medical gas cylinder management. The core lifecycle runs from a Batch (a shipment of cylinders) through individual TankUnit records (one per physical cylinder), across Dispatch and DispatchLine records (outbound deliveries to clients), and back through TechnicalReception and TankTechnicalReview records (incoming quality control). Supporting catalog models — GasType, CylinderCapacity, WarehouseArea, TechnicalStatus, and CatalogProduct — act as lookup tables that classify and locate every cylinder at all times. All models live under the App\Models namespace.

Core Models

The Batch model represents a single incoming shipment of cylinders from a supplier. Every TankUnit that enters the system must belong to exactly one batch. Batches carry the procurement paper trail — voucher numbers, sanitary registries, supplier codes — and connect logically to a TechnicalReception document via a shared document_number.Table: batchesFillable fields
FieldTypeNotes
batch_numberstringUnique identifier for the batch
gas_type_idbigint (nullable FK)References gas_types.id
capacity_idbigint (nullable FK)References cylinder_capacities.id
received_atdatetimeDate and time the batch was received
document_numberstring (nullable)Shared with TechnicalReception for logical linking
supplier_namestring (nullable)Name of the supplying company
supplier_codestring (nullable)Supplier’s internal code
voucher_typestring (nullable)Type of purchase voucher
voucher_numberstring (nullable)Voucher document number
voucher_datedate (nullable)Date on the voucher
sanitary_registrystring (nullable)Sanitary registry number
manufactured_atdate (nullable)Manufacture date
expires_atdate (nullable)Expiry date
notestext (nullable)Free-text notes
created_by_user_emailstringEmail of the user who created the record
Casts
FieldCast
received_atdatetime
voucher_datedate
manufactured_atdate
expires_atdate
Relationships
MethodTypeTarget
gasType()belongsToGasType
capacity()belongsToCylinderCapacity (via capacity_id)
tankUnits()hasManyTankUnit
technicalReception()hasOneTechnicalReception — matched on document_number (logical FK, not a database foreign key)
The TankUnit model represents a single physical gas cylinder. It is the central entity of the system — every movement, dispatch, and technical review ultimately references a tank unit. The primary key is a UUID (powered by the HasUuids trait), which means $incrementing is false and $keyType is 'string'.Table: tank_unitsPrimary key: id (UUID — auto-generated via HasUuids)Fillable fields
FieldTypeNotes
iduuidUUID primary key
serialstringFull serial string, unique across all units
serial_prefixstring (nullable)Alphabetic prefix extracted from the serial
serial_numberbigint (nullable)Numeric portion extracted from the serial
batch_idbigint (FK)References batches.id, cascades on delete
product_idbigint (nullable FK)References catalog_products.id
gas_type_idbigint (FK)References gas_types.id
capacity_idbigint (FK)References cylinder_capacities.id
warehouse_area_idbigint (FK)References warehouse_areas.id
technical_status_idbigint (FK)References technical_statuses.id
sanitary_registrystring (nullable)Sanitary registry number for this unit
manufactured_atdate (nullable)Manufacture date
expires_atdate (nullable)Expiry date
statustinyintCast to TankStatus enum (1 = DISPONIBLE default)
dispatched_atdatetime (nullable)Timestamp when the unit was last dispatched
Casts
FieldCast
statusTankStatus (enum)
dispatched_atdatetime
manufactured_atdate
expires_atdate
Relationships
MethodTypeTargetNotes
batch()belongsToBatch
product()belongsToCatalogProduct (via product_id)
gasType()belongsToGasType
capacity()belongsToCylinderCapacity (via capacity_id)
warehouseArea()belongsToWarehouseArea
technicalStatus()belongsToTechnicalStatus
movements()hasManyInventoryMovement (via tank_unit_id)Ordered by occurred_at descending
technicalReviews()hasManyTankTechnicalReview (via tank_unit_id)Ordered by reviewed_at descending
latestTechnicalReview()hasOneTankTechnicalReview (via tank_unit_id)Uses latestOfMany('reviewed_at')
Notable methodsisAvailableForDispatch(): boolReturns true only when all three conditions are met:
  1. status is TankStatus::DISPONIBLE
  2. technicalStatus->name equals 'Aprobado' (case-insensitive)
  3. warehouseArea->name equals 'Productos aprobados' (case-insensitive)
Automatically lazy-loads technicalStatus and warehouseArea before evaluating.
if ($tank->isAvailableForDispatch()) {
    // safe to include in a dispatch
}
scopeDispatchable(Builder $query): BuilderQuery scope that filters tank units at the database level to only those eligible for dispatch. It constrains three conditions in a single query: status equals TankStatus::DISPONIBLE, the related technicalStatus.name equals 'Aprobado' (exact match via whereHas), and the related warehouseArea.name equals 'Productos aprobados' (exact match via whereHas). Use this scope when building dispatch selection lists to avoid N+1 loads.
$tanks = TankUnit::dispatchable()->get();
The Dispatch model represents a completed outbound delivery event — one or more cylinders dispatched to a client at a specific date and time. The full list of delivered cylinders is stored in child DispatchLine records.Table: dispatchesFillable fields
FieldTypeNotes
client_idbigint (nullable FK)References clients.id; set to null on client deletion
dispatched_atdatetimeWhen the dispatch occurred
document_numberstring (nullable)Internal document reference
entity_typetinyint (nullable)Cast to EntityType enum
remission_platestring (nullable)Vehicle plate used for remission
performed_by_user_emailstringEmail of the operator who performed the dispatch
voucher_typestring (nullable)Type of delivery voucher
voucher_numberstring (nullable)Delivery voucher number
remission_numberstring (nullable)Remission guide number
notestext (nullable)Free-text notes
Casts
FieldCast
dispatched_atdatetime
entity_typeEntityType (enum)
Relationships
MethodTypeTarget
client()belongsToClient
lines()hasManyDispatchLine
The DispatchLine model is a pivot/join record linking one Dispatch to one TankUnit. Each row represents a single cylinder included in a dispatch. The table has a composite unique constraint on (dispatch_id, tank_unit_id).Table: dispatch_linesTimestamps: disabled ($timestamps = false)Fillable fields
FieldTypeNotes
dispatch_idbigint (FK)References dispatches.id, cascades on delete
tank_unit_iduuid (FK)References tank_units.id, restrict on delete
Relationships
MethodTypeTarget
dispatch()belongsToDispatch
tankUnit()belongsToTankUnit
The Client model stores the recipient institutions and individuals that receive cylinder dispatches. The entity_type field is cast to the EntityType enum, which distinguishes between institutional clients, IESS home-care patients, and unaffiliated support cases.Table: clientsFillable fields
FieldTypeNotes
namestringClient name (max 200 chars)
entity_typetinyint (nullable)Cast to EntityType enum
documentstring (nullable)ID or RUC document number
phonestring (nullable)Contact phone
emailstring (nullable)Contact email
addressstring (nullable)Physical address
Casts
FieldCast
entity_typeEntityType (enum)
Relationships
MethodTypeTarget
dispatches()hasManyDispatch
InventoryMovement is the immutable audit log for every state change that affects a cylinder’s location or status. Movements are never updated — they are append-only, and together they form the full history of any tank unit. The type field is cast to the MovementType enum.Table: inventory_movementsTimestamps: disabled ($timestamps = false)Fillable fields
FieldTypeNotes
typetinyintCast to MovementType enum
occurred_atdatetimeWhen the movement took place
tank_unit_iduuid (FK)References tank_units.id, cascades on delete
from_area_idbigint (nullable FK)Source warehouse area
to_area_idbigint (nullable FK)Destination warehouse area
batch_idbigint (nullable FK)Associated batch (set to null on batch deletion)
reference_documentstring (nullable)Any reference document number
performed_by_user_emailstringEmail of the operator who recorded the movement
notesstring (nullable)Free-text notes (max 500 chars)
Casts
FieldCast
typeMovementType (enum)
occurred_atdatetime
Relationships
MethodTypeTarget
tankUnit()belongsToTankUnit
fromArea()belongsToWarehouseArea (via from_area_id)
toArea()belongsToWarehouseArea (via to_area_id)
batch()belongsToBatch
The TechnicalReception model captures the formal quality-control document produced when a batch of cylinders is received. It stores supplier metadata, compliance results, a responsible-party signature block, and an optional path to the signed PDF. The document_number field ties it logically to a Batch record (see Batch::technicalReception()).Table: technical_receptionsFillable fields
FieldTypeNotes
document_numberstring (unique)Shared with batches.document_number for logical linking
reception_datedatetime (nullable)Date of the physical reception inspection
invoice_numberstring (nullable)Invoice reference
remission_guide_numberstring (nullable)Remission guide reference
supplier_namestring (nullable)Supplier name
manufacturer_namestring (nullable)Manufacturer name
delivered_bystring (nullable)Name of the delivery person
received_bystring (nullable)Name of the receiving person
storage_conditionstext (nullable)Description of storage conditions observed
quantity_receivedintegerNumber of cylinders received
documentation_compliesboolean (nullable)Whether accompanying documentation is compliant
final_resultstringOverall result: 'pendiente', 'aprobado', or 'rechazado'
responsible_namestring (nullable)Name of the responsible signatory
responsible_positionstring (nullable)Position of the responsible signatory
responsible_observationtext (nullable)Observations from the responsible signatory
signed_pdf_pathstring (nullable)Storage path to the uploaded signed PDF
signed_pdf_uploaded_atdatetime (nullable)When the signed PDF was uploaded
signed_pdf_uploaded_bystring (nullable)Email of the user who uploaded the signed PDF
created_by_user_emailstring (nullable)Email of the user who created the record
Casts
FieldCast
reception_datedatetime
quantity_receivedinteger
documentation_compliesboolean
signed_pdf_uploaded_atdatetime
Relationships
MethodTypeTargetNotes
items()hasManyTechnicalReceptionItemOrdered by sort_order ascending
batches()Query BuilderBatchReturns a query builder filtered by document_number; not a standard Eloquent relation
Notable methods
MethodReturnsDescription
isApproved()booltrue when final_result === 'aprobado'
isRejected()booltrue when final_result === 'rechazado'
TechnicalReceptionItem stores the individual checklist rows of a technical reception form. Each item belongs to a section, has a label, and records whether it complies along with an optional observation. The sort_order field controls the display order within a section.Table: technical_reception_itemsFillable fields
FieldTypeNotes
technical_reception_idbigint (FK)References technical_receptions.id, cascades on delete
sectionstringSection heading this item belongs to (max 120 chars)
labeltextHuman-readable checklist label
compliesboolean (nullable)Whether this item complies; null means not yet evaluated
observationtext (nullable)Optional observation or note
sort_orderintegerDisplay order within the section (default 0)
Casts
FieldCast
compliesboolean
sort_orderinteger
Relationships
MethodTypeTarget
technicalReception()belongsToTechnicalReception
The TankTechnicalReview model records the per-cylinder outcome of a technical inspection. It links a single TankUnit to a TechnicalReception event and stores the final result (approved or rejected), an optional anomaly type, and the reviewer’s details.Table: tank_technical_reviewsFillable fields
FieldTypeNotes
tank_unit_iduuid (FK)References tank_units.id, cascades on delete
technical_reception_idbigint (nullable FK)References technical_receptions.id; set to null on reception deletion
resultstring'approved' or 'rejected'
anomaly_typestring (nullable)Type of anomaly found (populated when rejected)
observationtext (nullable)Free-text reviewer observation
reviewed_by_user_emailstringEmail of the reviewer
reviewed_atdatetimeTimestamp of the review
Casts
FieldCast
reviewed_atdatetime
Relationships
MethodTypeTarget
tankUnit()belongsToTankUnit
technicalReception()belongsToTechnicalReception
Notable methods
MethodReturnsDescription
isApproved()booltrue when result === 'approved'
isRejected()booltrue when result === 'rejected'
CatalogProduct represents an officially registered product in the catalog — a specific combination of gas type, cylinder capacity, product code, and sanitary registry. Tank units can be linked to a catalog product via the optional product_id field to make their classification official.Table: catalog_productsFillable fields
FieldTypeNotes
codestring (unique)Product code, e.g. OMG-1 or 00AC
detailstringHuman-readable product description, e.g. OXÍGENO MEDICINAL GAS 1 m³
gas_type_idbigint (FK)References gas_types.id
capacity_idbigint (nullable FK)References cylinder_capacities.id
sanitary_registrystring (nullable)Sanitary registry number for the product
Relationships
MethodTypeTarget
gasType()belongsToGasType
capacity()belongsToCylinderCapacity (via capacity_id)

Catalog / Lookup Models

These four models are simple reference tables with no complex logic. They act as lookup data that classifies cylinders and controls which values are valid in the rest of the system.
Defines the type of gas contained in a cylinder (e.g., medical oxygen, nitrogen).Table: gas_typesFillable fields: name (string, unique, max 120 chars)Relationships
MethodTypeTarget
batches()hasManyBatch
tankUnits()hasManyTankUnit
Defines the volumetric capacity of a cylinder type in cubic metres.Table: cylinder_capacitiesFillable fields: name (string, unique, max 120 chars), m3 (decimal, nullable)Casts
FieldCast
m3decimal:2
Defines a named physical zone inside the warehouse (e.g., Cuarentena, Productos aprobados, Baja). Tank units are always assigned to one area, and area transitions are tracked via InventoryMovement.Table: warehouse_areasFillable fields: name (string, unique, max 120 chars)
Defines the technical inspection status assigned to a cylinder after a review cycle (e.g., Aprobado, Rechazado, En revisión).Table: technical_statusesFillable fields: name (string, unique, max 120 chars)
The isAvailableForDispatch() method on TankUnit checks that technicalStatus->name equals 'Aprobado'. Renaming this record in the database will silently break dispatch eligibility checks.

Build docs developers (and LLMs) love