Files
isaacclad 2ce4bc8993
Deploy Ladill Care / deploy (push) Successful in 1m26s
feat(assessments): layered clinical assessment engine end-to-end
Add a template-driven assessment system with universal intake, clinical
pathways, disease instruments (stroke MVP + extended, diabetes, and ten
specialty packs), scoring, patient outcome trends, REST/API + FHIR
export, and Enterprise org-level assessment analytics. Seed packs and
design/licensing docs ship for deploy and pre-GA review.
2026-07-16 22:58:09 +00:00

127 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\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Str;
class Patient extends Model
{
use BelongsToOwner, SoftDeletes;
protected $table = 'care_patients';
protected $fillable = [
'uuid', 'owner_ref', 'organization_id', 'branch_id', 'patient_number',
'first_name', 'last_name', 'other_names', 'gender', 'date_of_birth',
'phone', 'email', 'national_id', 'address', 'city', 'region', 'notes',
];
protected function casts(): array
{
return ['date_of_birth' => 'date'];
}
protected static function booted(): void
{
static::creating(function (Patient $patient) {
if (! $patient->uuid) {
$patient->uuid = (string) Str::uuid();
}
});
}
public function getRouteKeyName(): string
{
return 'uuid';
}
public function fullName(): string
{
return trim(implode(' ', array_filter([
$this->first_name,
$this->other_names,
$this->last_name,
])));
}
public function organization(): BelongsTo
{
return $this->belongsTo(Organization::class, 'organization_id');
}
public function branch(): BelongsTo
{
return $this->belongsTo(Branch::class, 'branch_id');
}
public function allergies(): HasMany
{
return $this->hasMany(PatientAllergy::class, 'patient_id');
}
public function conditions(): HasMany
{
return $this->hasMany(PatientCondition::class, 'patient_id');
}
public function familyHistory(): HasMany
{
return $this->hasMany(PatientFamilyHistory::class, 'patient_id');
}
public function emergencyContacts(): HasMany
{
return $this->hasMany(EmergencyContact::class, 'patient_id');
}
public function insurancePolicies(): HasMany
{
return $this->hasMany(InsurancePolicy::class, 'patient_id');
}
public function attachments(): HasMany
{
return $this->hasMany(PatientAttachment::class, 'patient_id');
}
public function appointments(): HasMany
{
return $this->hasMany(Appointment::class, 'patient_id');
}
public function visits(): HasMany
{
return $this->hasMany(Visit::class, 'patient_id');
}
public function assessments(): HasMany
{
return $this->hasMany(Assessment::class, 'patient_id');
}
public function pathways(): HasMany
{
return $this->hasMany(PatientPathway::class, 'patient_id');
}
public function investigationRequests(): HasMany
{
return $this->hasMany(InvestigationRequest::class, 'patient_id');
}
public function prescriptions(): HasMany
{
return $this->hasMany(Prescription::class, 'patient_id');
}
public function bills(): HasMany
{
return $this->hasMany(Bill::class, 'patient_id');
}
}