Files
ladill-care/app/Models/InvestigationRequest.php
T
isaaccladandCursor 015a4cc7fe
Deploy Ladill Care / deploy (push) Successful in 1m45s
Wire Care lists into Ladill Queue workflows instead of reception panels.
When Queue integration is on, role pages issue tickets into their own
department queues and drive Call next → Serve → Complete on the native
lists. Integration off leaves existing UI unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-17 16:27:48 +00:00

117 lines
3.1 KiB
PHP

<?php
namespace App\Models;
use App\Models\Concerns\BelongsToOwner;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Str;
class InvestigationRequest extends Model
{
use BelongsToOwner, SoftDeletes;
public const STATUS_PENDING = 'pending';
public const STATUS_SAMPLE_COLLECTED = 'sample_collected';
public const STATUS_IN_PROGRESS = 'in_progress';
public const STATUS_AWAITING_REVIEW = 'awaiting_review';
public const STATUS_COMPLETED = 'completed';
public const STATUS_DELIVERED = 'delivered';
public const STATUS_CANCELLED = 'cancelled';
protected $table = 'care_investigation_requests';
protected $fillable = [
'uuid', 'queue_ticket_uuid', 'queue_ticket_number', 'queue_ticket_status',
'owner_ref', 'organization_id', 'branch_id', 'visit_id', 'consultation_id',
'patient_id', 'investigation_type_id', 'practitioner_id', 'status', 'priority',
'clinical_notes', 'requested_by', 'assigned_member_id', 'sample_barcode',
'sample_collected_at', 'sample_collected_by', 'completed_at', 'delivered_at',
'approved_by', 'approved_at',
];
protected function casts(): array
{
return [
'sample_collected_at' => 'datetime',
'completed_at' => 'datetime',
'delivered_at' => 'datetime',
'approved_at' => 'datetime',
];
}
protected static function booted(): void
{
static::creating(function (InvestigationRequest $request) {
if (! $request->uuid) {
$request->uuid = (string) Str::uuid();
}
});
}
public function getRouteKeyName(): string
{
return 'uuid';
}
public function investigationType(): BelongsTo
{
return $this->belongsTo(InvestigationType::class, 'investigation_type_id');
}
public function patient(): BelongsTo
{
return $this->belongsTo(Patient::class, 'patient_id');
}
public function visit(): BelongsTo
{
return $this->belongsTo(Visit::class, 'visit_id');
}
public function consultation(): BelongsTo
{
return $this->belongsTo(Consultation::class, 'consultation_id');
}
public function practitioner(): BelongsTo
{
return $this->belongsTo(Practitioner::class, 'practitioner_id');
}
public function branch(): BelongsTo
{
return $this->belongsTo(Branch::class, 'branch_id');
}
public function assignedMember(): BelongsTo
{
return $this->belongsTo(Member::class, 'assigned_member_id');
}
public function result(): HasOne
{
return $this->hasOne(InvestigationResult::class, 'investigation_request_id');
}
/** @return list<string> */
public static function activeStatuses(): array
{
return [
self::STATUS_PENDING,
self::STATUS_SAMPLE_COLLECTED,
self::STATUS_IN_PROGRESS,
self::STATUS_AWAITING_REVIEW,
self::STATUS_COMPLETED,
];
}
}