Wire specialty Start consultation to the real consultation page.
Deploy Ladill Care / deploy (push) Successful in 58s
Deploy Ladill Care / deploy (push) Successful in 58s
Doctors leave the specialty shell into Care consultations instead of a no-op workspace link. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -8,7 +8,9 @@ use App\Models\Appointment;
|
||||
use App\Models\Department;
|
||||
use App\Models\PatientAttachment;
|
||||
use App\Models\Visit;
|
||||
use App\Services\Care\AppointmentService;
|
||||
use App\Services\Care\CareQueueBridge;
|
||||
use App\Services\Care\ConsultationService;
|
||||
use App\Services\Care\OrganizationResolver;
|
||||
use App\Services\Care\SpecialtyClinicalRecordService;
|
||||
use App\Services\Care\SpecialtyModuleService;
|
||||
@@ -107,6 +109,69 @@ class SpecialtyModuleController extends Controller
|
||||
return back()->with('success', 'Added to invoice '.$bill->invoice_number.'.');
|
||||
}
|
||||
|
||||
public function startConsultation(
|
||||
Request $request,
|
||||
string $module,
|
||||
Visit $visit,
|
||||
SpecialtyModuleService $modules,
|
||||
AppointmentService $appointments,
|
||||
ConsultationService $consultations,
|
||||
): RedirectResponse {
|
||||
$this->authorizeAbility($request, 'consultations.manage');
|
||||
|
||||
$definition = $modules->definition($module);
|
||||
abort_unless($definition, 404);
|
||||
|
||||
$organization = $this->organization($request);
|
||||
$member = $this->member($request);
|
||||
abort_unless($modules->memberCanAccess($organization, $member, $module), 403);
|
||||
abort_unless($visit->organization_id === $organization->id, 404);
|
||||
$this->authorizeBranch($request, (int) $visit->branch_id);
|
||||
|
||||
$visit->loadMissing(['appointment.consultation', 'appointment.practitioner']);
|
||||
$appointment = $visit->appointment;
|
||||
if (! $appointment || $appointment->organization_id !== $organization->id) {
|
||||
return back()->with('error', 'This visit has no appointment to start a consultation from.');
|
||||
}
|
||||
|
||||
$owner = $this->ownerRef($request);
|
||||
$openConsultation = $appointment->consultation;
|
||||
if ($openConsultation && $openConsultation->status !== \App\Models\Consultation::STATUS_COMPLETED) {
|
||||
return redirect()
|
||||
->route('care.consultations.show', $openConsultation)
|
||||
->with('success', 'Consultation already in progress.');
|
||||
}
|
||||
|
||||
try {
|
||||
if (in_array($appointment->status, [
|
||||
Appointment::STATUS_WAITING,
|
||||
Appointment::STATUS_CHECKED_IN,
|
||||
], true)) {
|
||||
$appointments->startConsultation(
|
||||
$appointment,
|
||||
$owner,
|
||||
$appointment->practitioner_id,
|
||||
$owner,
|
||||
);
|
||||
$appointment = $appointment->fresh(['practitioner', 'visit']);
|
||||
} elseif ($appointment->status !== Appointment::STATUS_IN_CONSULTATION) {
|
||||
return back()->with('error', 'This appointment cannot start a consultation from its current status.');
|
||||
}
|
||||
|
||||
$consultation = $consultations->startFromAppointment(
|
||||
$appointment,
|
||||
$owner,
|
||||
$owner,
|
||||
);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
return back()->with('error', $e->getMessage());
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->route('care.consultations.show', $consultation)
|
||||
->with('success', 'Consultation started.');
|
||||
}
|
||||
|
||||
public function saveClinical(
|
||||
Request $request,
|
||||
string $module,
|
||||
@@ -327,6 +392,7 @@ class SpecialtyModuleController extends Controller
|
||||
'patient.emergencyContacts',
|
||||
'patient.attachments',
|
||||
'appointment.practitioner',
|
||||
'appointment.consultation',
|
||||
'bill.lineItems',
|
||||
'consultations',
|
||||
]);
|
||||
@@ -346,6 +412,7 @@ class SpecialtyModuleController extends Controller
|
||||
'patient.emergencyContacts',
|
||||
'patient.attachments',
|
||||
'appointment.practitioner',
|
||||
'appointment.consultation',
|
||||
'bill.lineItems',
|
||||
'consultations',
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user