Files
ladill-care/app/Services/Care/Dentistry/DentalVisitNoteService.php
T
isaaccladandCursor 0edd653187
Deploy Ladill Care / deploy (push) Failing after 36s
Ship commercial Dentistry suite with odontogram and treatment plans.
Replace placeholder clinical forms with patient-level FDI charting, multi-visit plans, procedure-to-bill linking, imaging, reports, and demo seed data.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-18 16:33:34 +00:00

52 lines
1.5 KiB
PHP

<?php
namespace App\Services\Care\Dentistry;
use App\Models\DentalVisitNote;
use App\Models\Organization;
use App\Models\Visit;
use App\Services\Care\AuditLogger;
class DentalVisitNoteService
{
/**
* @param array{chief_complaint?: ?string, soft_tissue?: ?string, occlusion?: ?string, notes?: ?string} $data
*/
public function upsert(
Organization $organization,
Visit $visit,
array $data,
string $ownerRef,
?string $actorRef = null,
): DentalVisitNote {
$visit->loadMissing('patient');
$note = DentalVisitNote::owned($ownerRef)
->where('visit_id', $visit->id)
->first();
$attributes = [
'owner_ref' => $ownerRef,
'organization_id' => $organization->id,
'visit_id' => $visit->id,
'patient_id' => $visit->patient_id,
'chief_complaint' => $data['chief_complaint'] ?? null,
'soft_tissue' => $data['soft_tissue'] ?? null,
'occlusion' => $data['occlusion'] ?? null,
'notes' => $data['notes'] ?? null,
'recorded_by' => $actorRef ?? $ownerRef,
'recorded_at' => now(),
];
if ($note) {
$note->update($attributes);
} else {
$note = DentalVisitNote::create($attributes);
}
AuditLogger::record($ownerRef, 'dental.notes.saved', $organization->id, $actorRef, DentalVisitNote::class, $note->id);
return $note->fresh();
}
}