Improve specialty workspace actions and Call next handoff.
Deploy Ladill Care / deploy (push) Successful in 40s
Deploy Ladill Care / deploy (push) Successful in 40s
Move timeline into a workspace tab, surface Complete consultation and Call again in Actions, and make Call next end the current encounter then open the next called patient. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -11,6 +11,7 @@ use App\Services\Care\BranchContext;
|
|||||||
use App\Services\Care\CarePermissions;
|
use App\Services\Care\CarePermissions;
|
||||||
use App\Services\Care\CareQueueBridge;
|
use App\Services\Care\CareQueueBridge;
|
||||||
use App\Services\Care\CareQueueContexts;
|
use App\Services\Care\CareQueueContexts;
|
||||||
|
use App\Services\Care\CareQueueSessionAdvance;
|
||||||
use App\Services\Care\ConsultationService;
|
use App\Services\Care\ConsultationService;
|
||||||
use App\Services\Care\OrganizationResolver;
|
use App\Services\Care\OrganizationResolver;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
@@ -157,7 +158,7 @@ class QueueController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function callNext(Request $request): RedirectResponse
|
public function callNext(Request $request, CareQueueSessionAdvance $advance): RedirectResponse
|
||||||
{
|
{
|
||||||
abort_unless(app(CarePermissions::class)->handlesFloorCare($this->member($request)), 403);
|
abort_unless(app(CarePermissions::class)->handlesFloorCare($this->member($request)), 403);
|
||||||
$this->authorizeAbility($request, 'appointments.view');
|
$this->authorizeAbility($request, 'appointments.view');
|
||||||
@@ -165,6 +166,7 @@ class QueueController extends Controller
|
|||||||
abort_unless($this->queueBridge->isEnabled($organization), 404);
|
abort_unless($this->queueBridge->isEnabled($organization), 404);
|
||||||
|
|
||||||
$member = $this->member($request);
|
$member = $this->member($request);
|
||||||
|
$owner = $this->ownerRef($request);
|
||||||
$practitionerScope = app(OrganizationResolver::class)->practitionerScope($organization, $member);
|
$practitionerScope = app(OrganizationResolver::class)->practitionerScope($organization, $member);
|
||||||
$branchId = $this->branchContext->resolve($request, $organization, $member);
|
$branchId = $this->branchContext->resolve($request, $organization, $member);
|
||||||
$practitionerId = $request->input('practitioner_id') ? (int) $request->input('practitioner_id') : null;
|
$practitionerId = $request->input('practitioner_id') ? (int) $request->input('practitioner_id') : null;
|
||||||
@@ -172,7 +174,7 @@ class QueueController extends Controller
|
|||||||
if ($practitionerScope !== null) {
|
if ($practitionerScope !== null) {
|
||||||
abort_unless($practitionerScope !== [], 422);
|
abort_unless($practitionerScope !== [], 422);
|
||||||
$practitionerId = $practitionerScope[0];
|
$practitionerId = $practitionerScope[0];
|
||||||
$prac = Practitioner::owned($this->ownerRef($request))->find($practitionerId);
|
$prac = Practitioner::owned($owner)->find($practitionerId);
|
||||||
$branchId = (int) ($prac?->branch_id ?: $branchId);
|
$branchId = (int) ($prac?->branch_id ?: $branchId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,13 +182,20 @@ class QueueController extends Controller
|
|||||||
|
|
||||||
$context = CareQueueContexts::CONSULTATION;
|
$context = CareQueueContexts::CONSULTATION;
|
||||||
if ($practitionerId) {
|
if ($practitionerId) {
|
||||||
$prac = Practitioner::owned($this->ownerRef($request))->find($practitionerId);
|
$prac = Practitioner::owned($owner)->find($practitionerId);
|
||||||
$specialtyContext = $this->queueBridge->contextForPractitioner($organization, $prac);
|
$specialtyContext = $this->queueBridge->contextForPractitioner($organization, $prac);
|
||||||
if ($specialtyContext !== CareQueueContexts::CONSULTATION) {
|
if ($specialtyContext !== CareQueueContexts::CONSULTATION) {
|
||||||
$context = $specialtyContext;
|
$context = $specialtyContext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($request->filled('appointment_id')) {
|
||||||
|
$current = Appointment::owned($owner)
|
||||||
|
->where('organization_id', $organization->id)
|
||||||
|
->findOrFail((int) $request->input('appointment_id'));
|
||||||
|
$advance->endCurrentEncounter($current, $owner, $owner);
|
||||||
|
}
|
||||||
|
|
||||||
$result = $this->queueBridge->callNext(
|
$result = $this->queueBridge->callNext(
|
||||||
$organization,
|
$organization,
|
||||||
$context,
|
$context,
|
||||||
@@ -203,6 +212,11 @@ class QueueController extends Controller
|
|||||||
return back()->with('info', "No patients waiting at your {$label} service point.");
|
return back()->with('info', "No patients waiting at your {$label} service point.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$entity = $result['entity'] ?? null;
|
||||||
|
if ($entity instanceof Appointment) {
|
||||||
|
return $advance->redirectToOpenedPatient($entity, $ticket);
|
||||||
|
}
|
||||||
|
|
||||||
return back()->with('success', 'Called '.$ticket['ticket_number'].' — '.($ticket['customer_name'] ?? 'patient').'.');
|
return back()->with('success', 'Called '.$ticket['ticket_number'].' — '.($ticket['customer_name'] ?? 'patient').'.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use App\Models\PatientAttachment;
|
|||||||
use App\Models\Visit;
|
use App\Models\Visit;
|
||||||
use App\Services\Care\AppointmentService;
|
use App\Services\Care\AppointmentService;
|
||||||
use App\Services\Care\CareQueueBridge;
|
use App\Services\Care\CareQueueBridge;
|
||||||
|
use App\Services\Care\CareQueueSessionAdvance;
|
||||||
use App\Services\Care\ConsultationService;
|
use App\Services\Care\ConsultationService;
|
||||||
use App\Services\Care\OrganizationResolver;
|
use App\Services\Care\OrganizationResolver;
|
||||||
use App\Services\Care\SpecialtyClinicalRecordService;
|
use App\Services\Care\SpecialtyClinicalRecordService;
|
||||||
@@ -309,12 +310,14 @@ class SpecialtyModuleController extends Controller
|
|||||||
string $module,
|
string $module,
|
||||||
SpecialtyModuleService $modules,
|
SpecialtyModuleService $modules,
|
||||||
CareQueueBridge $queueBridge,
|
CareQueueBridge $queueBridge,
|
||||||
|
CareQueueSessionAdvance $advance,
|
||||||
): RedirectResponse {
|
): RedirectResponse {
|
||||||
$definition = $modules->definition($module);
|
$definition = $modules->definition($module);
|
||||||
abort_unless($definition, 404);
|
abort_unless($definition, 404);
|
||||||
|
|
||||||
$organization = $this->organization($request);
|
$organization = $this->organization($request);
|
||||||
$member = $this->member($request);
|
$member = $this->member($request);
|
||||||
|
$owner = $this->ownerRef($request);
|
||||||
abort_unless($modules->memberCanAccess($organization, $member, $module), 403);
|
abort_unless($modules->memberCanAccess($organization, $member, $module), 403);
|
||||||
abort_unless($queueBridge->isEnabled($organization), 404);
|
abort_unless($queueBridge->isEnabled($organization), 404);
|
||||||
|
|
||||||
@@ -327,7 +330,7 @@ class SpecialtyModuleController extends Controller
|
|||||||
if ($practitionerScope !== null) {
|
if ($practitionerScope !== null) {
|
||||||
abort_unless($practitionerScope !== [], 422);
|
abort_unless($practitionerScope !== [], 422);
|
||||||
$practitionerId = $practitionerScope[0];
|
$practitionerId = $practitionerScope[0];
|
||||||
$pracBranch = (int) \App\Models\Practitioner::owned($this->ownerRef($request))
|
$pracBranch = (int) \App\Models\Practitioner::owned($owner)
|
||||||
->whereKey($practitionerId)
|
->whereKey($practitionerId)
|
||||||
->value('branch_id');
|
->value('branch_id');
|
||||||
if ($pracBranch > 0) {
|
if ($pracBranch > 0) {
|
||||||
@@ -337,10 +340,16 @@ class SpecialtyModuleController extends Controller
|
|||||||
|
|
||||||
abort_unless($branchId > 0, 422);
|
abort_unless($branchId > 0, 422);
|
||||||
|
|
||||||
|
if ($request->filled('appointment_id')) {
|
||||||
|
$current = Appointment::owned($owner)
|
||||||
|
->where('organization_id', $organization->id)
|
||||||
|
->findOrFail((int) $request->input('appointment_id'));
|
||||||
|
$advance->endCurrentEncounter($current, $owner, $owner);
|
||||||
|
}
|
||||||
|
|
||||||
$result = $queueBridge->callNext($organization, $module, $branchId, $member, $practitionerId);
|
$result = $queueBridge->callNext($organization, $module, $branchId, $member, $practitionerId);
|
||||||
$ticket = $result['ticket'] ?? null;
|
$ticket = $result['ticket'] ?? null;
|
||||||
if (! $ticket) {
|
if (! $ticket) {
|
||||||
$owner = $this->ownerRef($request);
|
|
||||||
$departmentIds = Department::owned($owner)
|
$departmentIds = Department::owned($owner)
|
||||||
->where('type', $definition['department_type'] ?? 'general')
|
->where('type', $definition['department_type'] ?? 'general')
|
||||||
->where('is_active', true)
|
->where('is_active', true)
|
||||||
@@ -381,6 +390,15 @@ class SpecialtyModuleController extends Controller
|
|||||||
return back()->with('info', 'No patients waiting in this queue.');
|
return back()->with('info', 'No patients waiting in this queue.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$entity = $result['entity'] ?? null;
|
||||||
|
if ($entity instanceof Appointment) {
|
||||||
|
return $advance->redirectToOpenedPatient(
|
||||||
|
$entity,
|
||||||
|
$ticket,
|
||||||
|
'care.queue.index',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$name = $ticket['customer_name'] ?? 'patient';
|
$name = $ticket['customer_name'] ?? 'patient';
|
||||||
|
|
||||||
return back()->with('success', 'Called '.$ticket['ticket_number'].' — '.$name.'.');
|
return back()->with('success', 'Called '.$ticket['ticket_number'].' — '.$name.'.');
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Care;
|
||||||
|
|
||||||
|
use App\Models\Appointment;
|
||||||
|
use App\Models\Consultation;
|
||||||
|
use App\Services\Care\CareQueueContexts;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
|
class CareQueueSessionAdvance
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
protected CareQueueBridge $queueBridge,
|
||||||
|
protected ConsultationService $consultations,
|
||||||
|
protected AppointmentService $appointments,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* End the current encounter so Call next can open the following patient.
|
||||||
|
*/
|
||||||
|
public function endCurrentEncounter(Appointment $appointment, string $ownerRef, ?string $actorRef = null): void
|
||||||
|
{
|
||||||
|
$appointment->loadMissing(['consultation', 'organization']);
|
||||||
|
|
||||||
|
$consultation = $appointment->consultation;
|
||||||
|
if ($consultation && $consultation->status !== Consultation::STATUS_COMPLETED) {
|
||||||
|
$this->consultations->complete($consultation, $ownerRef, $actorRef);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($appointment->status === Appointment::STATUS_IN_CONSULTATION) {
|
||||||
|
$this->appointments->complete($appointment, $ownerRef, $actorRef);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($appointment->organization && in_array($appointment->queue_ticket_status, ['called', 'serving'], true)) {
|
||||||
|
$this->queueBridge->complete($appointment->organization, $appointment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open the patient who was just called — without starting the session.
|
||||||
|
* Specialty → workspace overview; GP → appointment (Start + Call again).
|
||||||
|
*/
|
||||||
|
public function redirectToOpenedPatient(
|
||||||
|
Appointment|Model|null $entity,
|
||||||
|
array $ticket,
|
||||||
|
string $fallbackRoute = 'care.queue.index',
|
||||||
|
array $fallbackParams = [],
|
||||||
|
): RedirectResponse {
|
||||||
|
$message = 'Called '.($ticket['ticket_number'] ?? 'next').' — '.($ticket['customer_name'] ?? 'patient').'.';
|
||||||
|
|
||||||
|
if (! $entity instanceof Appointment) {
|
||||||
|
return redirect()->route($fallbackRoute, $fallbackParams)->with('success', $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
$entity->loadMissing(['visit', 'organization', 'department']);
|
||||||
|
$organization = $entity->organization;
|
||||||
|
if (! $organization) {
|
||||||
|
return redirect()->route($fallbackRoute, $fallbackParams)->with('success', $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
$context = $this->queueBridge->contextForAppointment($organization, $entity);
|
||||||
|
|
||||||
|
if ($context !== CareQueueContexts::CONSULTATION && $entity->visit) {
|
||||||
|
return redirect()
|
||||||
|
->route('care.specialty.workspace', [
|
||||||
|
'module' => $context,
|
||||||
|
'visit' => $entity->visit,
|
||||||
|
'tab' => 'overview',
|
||||||
|
])
|
||||||
|
->with('success', $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('care.appointments.show', $entity)
|
||||||
|
->with('success', $message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -119,8 +119,27 @@ class SpecialtyShellService
|
|||||||
public function workspaceTabs(string $moduleKey): array
|
public function workspaceTabs(string $moduleKey): array
|
||||||
{
|
{
|
||||||
$tabs = $this->definition($moduleKey)['workspace_tabs'] ?? [];
|
$tabs = $this->definition($moduleKey)['workspace_tabs'] ?? [];
|
||||||
|
if (! is_array($tabs)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
return is_array($tabs) ? $tabs : [];
|
if (array_key_exists('timeline', $tabs)) {
|
||||||
|
return $tabs;
|
||||||
|
}
|
||||||
|
|
||||||
|
$merged = [];
|
||||||
|
foreach ($tabs as $key => $label) {
|
||||||
|
$merged[$key] = $label;
|
||||||
|
if ($key === 'overview') {
|
||||||
|
$merged['timeline'] = 'Timeline';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! array_key_exists('timeline', $merged)) {
|
||||||
|
$merged['timeline'] = 'Timeline';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $merged;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ return [
|
|||||||
],
|
],
|
||||||
'workspace_tabs' => [
|
'workspace_tabs' => [
|
||||||
'overview' => 'Overview',
|
'overview' => 'Overview',
|
||||||
|
'timeline' => 'Timeline',
|
||||||
'clinical_notes' => 'Clinical notes',
|
'clinical_notes' => 'Clinical notes',
|
||||||
'orders' => 'Orders',
|
'orders' => 'Orders',
|
||||||
'billing' => 'Billing',
|
'billing' => 'Billing',
|
||||||
|
|||||||
@@ -19,6 +19,12 @@
|
|||||||
<x-btn type="submit" variant="warning">No show</x-btn>
|
<x-btn type="submit" variant="warning">No show</x-btn>
|
||||||
</form>
|
</form>
|
||||||
@endif
|
@endif
|
||||||
|
@if ($appointment->queue_ticket_status === 'called')
|
||||||
|
<form method="POST" action="{{ route('care.queue.recall', $appointment) }}">
|
||||||
|
@csrf
|
||||||
|
<button type="submit" class="rounded-lg border border-indigo-200 bg-indigo-50 px-4 py-2 text-sm font-medium text-indigo-700 hover:bg-indigo-100">Call again</button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
@if (($canStartConsultation ?? $canConsult) && in_array($appointment->status, [\App\Models\Appointment::STATUS_WAITING, \App\Models\Appointment::STATUS_CHECKED_IN], true))
|
@if (($canStartConsultation ?? $canConsult) && in_array($appointment->status, [\App\Models\Appointment::STATUS_WAITING, \App\Models\Appointment::STATUS_CHECKED_IN], true))
|
||||||
<form method="POST" action="{{ route('care.queue.start', $appointment) }}">
|
<form method="POST" action="{{ route('care.queue.start', $appointment) }}">
|
||||||
@csrf
|
@csrf
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
$btnPrimary = $btn.' bg-indigo-600 text-white hover:bg-indigo-700';
|
$btnPrimary = $btn.' bg-indigo-600 text-white hover:bg-indigo-700';
|
||||||
$btnSecondary = $btn.' border border-slate-200 bg-white text-slate-800 hover:bg-slate-50';
|
$btnSecondary = $btn.' border border-slate-200 bg-white text-slate-800 hover:bg-slate-50';
|
||||||
$btnAccent = $btn.' border border-sky-200 bg-sky-50 text-sky-900 hover:bg-sky-100';
|
$btnAccent = $btn.' border border-sky-200 bg-sky-50 text-sky-900 hover:bg-sky-100';
|
||||||
|
$appointment = $consultation->appointment;
|
||||||
|
$ticketCalled = $appointment && $appointment->queue_ticket_status === 'called';
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
@include('care.partials.queue-ops', [
|
@include('care.partials.queue-ops', [
|
||||||
@@ -12,8 +14,16 @@
|
|||||||
'queueCallNextRoute' => 'care.queue.call-next',
|
'queueCallNextRoute' => 'care.queue.call-next',
|
||||||
'queueCallNextParams' => [],
|
'queueCallNextParams' => [],
|
||||||
'branchId' => $queueBranchId ?? null,
|
'branchId' => $queueBranchId ?? null,
|
||||||
|
'currentAppointmentId' => $appointment?->id,
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@if ($ticketCalled && $appointment)
|
||||||
|
<form method="POST" action="{{ route('care.queue.recall', $appointment) }}" class="w-full" @click.stop>
|
||||||
|
@csrf
|
||||||
|
<button type="submit" class="{{ $btnAccent }}">Call again</button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
|
|
||||||
@if ($canManage && ! $isCompleted)
|
@if ($canManage && ! $isCompleted)
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
@@ -3,9 +3,10 @@
|
|||||||
$qi = $queueIntegration ?? null;
|
$qi = $queueIntegration ?? null;
|
||||||
$callNextRoute = $queueCallNextRoute ?? null;
|
$callNextRoute = $queueCallNextRoute ?? null;
|
||||||
$callNextParams = $queueCallNextParams ?? [];
|
$callNextParams = $queueCallNextParams ?? [];
|
||||||
|
$currentAppointmentId = $currentAppointmentId ?? null;
|
||||||
@endphp
|
@endphp
|
||||||
@if (! empty($qi['enabled']) && $callNextRoute)
|
@if (! empty($qi['enabled']) && $callNextRoute)
|
||||||
<form method="POST" action="{{ route($callNextRoute, $callNextParams) }}" class="w-full">
|
<form method="POST" action="{{ route($callNextRoute, $callNextParams) }}" class="w-full" @click.stop>
|
||||||
@csrf
|
@csrf
|
||||||
@foreach ($callNextParams as $key => $value)
|
@foreach ($callNextParams as $key => $value)
|
||||||
@if (is_scalar($value))
|
@if (is_scalar($value))
|
||||||
@@ -15,6 +16,9 @@
|
|||||||
@if (! empty($branchId))
|
@if (! empty($branchId))
|
||||||
<input type="hidden" name="branch_id" value="{{ $branchId }}">
|
<input type="hidden" name="branch_id" value="{{ $branchId }}">
|
||||||
@endif
|
@endif
|
||||||
|
@if (! empty($currentAppointmentId))
|
||||||
|
<input type="hidden" name="appointment_id" value="{{ $currentAppointmentId }}">
|
||||||
|
@endif
|
||||||
<button type="submit" class="btn-primary flex w-full items-center justify-center text-sm">Call next</button>
|
<button type="submit" class="btn-primary flex w-full items-center justify-center text-sm">Call next</button>
|
||||||
</form>
|
</form>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@@ -5,6 +5,25 @@
|
|||||||
$btnSecondary = $btn.' border border-slate-200 bg-white text-slate-800 hover:bg-slate-50';
|
$btnSecondary = $btn.' border border-slate-200 bg-white text-slate-800 hover:bg-slate-50';
|
||||||
$btnAccent = $btn.' border border-indigo-200 bg-indigo-50 text-indigo-900 hover:bg-indigo-100';
|
$btnAccent = $btn.' border border-indigo-200 bg-indigo-50 text-indigo-900 hover:bg-indigo-100';
|
||||||
$onWorkspace = ($section ?? '') === 'workspace';
|
$onWorkspace = ($section ?? '') === 'workspace';
|
||||||
|
$appointment = $workspaceVisit?->appointment;
|
||||||
|
$openConsultation = $appointment?->consultation;
|
||||||
|
$ticketCalled = $appointment && $appointment->queue_ticket_status === 'called';
|
||||||
|
$canStartConsultation = $appointment && in_array($appointment->status, [
|
||||||
|
\App\Models\Appointment::STATUS_WAITING,
|
||||||
|
\App\Models\Appointment::STATUS_CHECKED_IN,
|
||||||
|
], true);
|
||||||
|
$consultationInProgress = $appointment
|
||||||
|
&& (
|
||||||
|
$appointment->status === \App\Models\Appointment::STATUS_IN_CONSULTATION
|
||||||
|
|| ($openConsultation && $openConsultation->status !== \App\Models\Consultation::STATUS_COMPLETED)
|
||||||
|
);
|
||||||
|
$canCompleteConsultation = $consultationInProgress
|
||||||
|
&& $openConsultation
|
||||||
|
&& $openConsultation->status !== \App\Models\Consultation::STATUS_COMPLETED;
|
||||||
|
$chartTab = collect($workspaceTabs ?? [])
|
||||||
|
->keys()
|
||||||
|
->first(fn ($key) => ! in_array($key, ['overview', 'timeline', 'orders', 'billing', 'documents'], true))
|
||||||
|
?: 'clinical_notes';
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
@if ($onWorkspace)
|
@if ($onWorkspace)
|
||||||
@@ -13,30 +32,31 @@
|
|||||||
'queueCallNextRoute' => 'care.specialty.call-next',
|
'queueCallNextRoute' => 'care.specialty.call-next',
|
||||||
'queueCallNextParams' => ['module' => $moduleKey],
|
'queueCallNextParams' => ['module' => $moduleKey],
|
||||||
'branchId' => $branchId ?? null,
|
'branchId' => $branchId ?? null,
|
||||||
|
'currentAppointmentId' => $appointment?->id,
|
||||||
])
|
])
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if ($ticketCalled && $appointment)
|
||||||
|
<form method="POST" action="{{ route('care.queue.recall', $appointment) }}" class="w-full" @click.stop>
|
||||||
|
@csrf
|
||||||
|
<button type="submit" class="{{ $btnAccent }}">Call again</button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
|
|
||||||
@if ($workspaceVisit)
|
@if ($workspaceVisit)
|
||||||
@php
|
@if ($canCompleteConsultation)
|
||||||
$appointment = $workspaceVisit->appointment;
|
<button
|
||||||
$openConsultation = $appointment?->consultation;
|
type="button"
|
||||||
$canStartConsultation = $appointment && in_array($appointment->status, [
|
class="{{ $btnPrimary }}"
|
||||||
\App\Models\Appointment::STATUS_WAITING,
|
@click.stop="$dispatch('open-modal', {{ \Illuminate\Support\Js::from('complete-consultation-'.$openConsultation->id) }})"
|
||||||
\App\Models\Appointment::STATUS_CHECKED_IN,
|
>
|
||||||
], true);
|
Complete consultation
|
||||||
$consultationInProgress = $appointment
|
</button>
|
||||||
&& (
|
@endif
|
||||||
$appointment->status === \App\Models\Appointment::STATUS_IN_CONSULTATION
|
|
||||||
|| ($openConsultation && $openConsultation->status !== \App\Models\Consultation::STATUS_COMPLETED)
|
|
||||||
);
|
|
||||||
$chartTab = collect($workspaceTabs ?? [])
|
|
||||||
->keys()
|
|
||||||
->first(fn ($key) => ! in_array($key, ['overview', 'orders', 'billing', 'documents'], true))
|
|
||||||
?: 'clinical_notes';
|
|
||||||
@endphp
|
|
||||||
@if ($consultationInProgress)
|
@if ($consultationInProgress)
|
||||||
<a href="{{ route('care.specialty.workspace', ['module' => $moduleKey, 'visit' => $workspaceVisit, 'tab' => $chartTab]) }}"
|
<a href="{{ route('care.specialty.workspace', ['module' => $moduleKey, 'visit' => $workspaceVisit, 'tab' => $chartTab]) }}"
|
||||||
class="{{ $btnPrimary }}">
|
class="{{ $btnSecondary }}">
|
||||||
Open chart
|
Open chart
|
||||||
</a>
|
</a>
|
||||||
@elseif ($canStartConsultation)
|
@elseif ($canStartConsultation)
|
||||||
|
|||||||
@@ -33,128 +33,124 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid gap-4 lg:grid-cols-5">
|
<div class="space-y-4">
|
||||||
<div class="space-y-4 lg:col-span-3">
|
@if ($activeTab === 'timeline')
|
||||||
@if ($activeTab === 'billing')
|
|
||||||
<section class="rounded-2xl border border-slate-200 bg-white p-5">
|
|
||||||
<h3 class="text-sm font-semibold text-slate-900">Add specialty service</h3>
|
|
||||||
<form method="POST" action="{{ route('care.specialty.services.add', ['module' => $moduleKey, 'visit' => $workspaceVisit]) }}" class="mt-3 space-y-3">
|
|
||||||
@csrf
|
|
||||||
<select name="service_code" required class="w-full rounded-xl border border-slate-200 px-3 py-2 text-sm">
|
|
||||||
<option value="">Select service…</option>
|
|
||||||
@foreach ($services as $service)
|
|
||||||
<option value="{{ $service['code'] }}">
|
|
||||||
{{ $service['label'] }} — {{ $currency ?? 'GHS' }} {{ number_format(((int) $service['amount_minor']) / 100, 2) }}
|
|
||||||
</option>
|
|
||||||
@endforeach
|
|
||||||
</select>
|
|
||||||
<button type="submit" class="btn-primary">{{ $actions['invoice'] ?? 'Add to invoice' }}</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
@if ($workspaceVisit->bill)
|
|
||||||
<div class="mt-6 border-t border-slate-100 pt-4">
|
|
||||||
<p class="text-xs font-semibold uppercase tracking-wide text-slate-500">Current invoice {{ $workspaceVisit->bill->invoice_number }}</p>
|
|
||||||
<ul class="mt-2 space-y-1 text-sm">
|
|
||||||
@forelse ($workspaceVisit->bill->lineItems as $line)
|
|
||||||
<li class="flex justify-between gap-3">
|
|
||||||
<span>{{ $line->description }}</span>
|
|
||||||
<span class="tabular-nums">{{ number_format($line->total_minor / 100, 2) }}</span>
|
|
||||||
</li>
|
|
||||||
@empty
|
|
||||||
<li class="text-slate-500">No line items yet.</li>
|
|
||||||
@endforelse
|
|
||||||
</ul>
|
|
||||||
<a href="{{ route('care.bills.show', $workspaceVisit->bill) }}" class="mt-3 inline-flex text-sm font-medium text-indigo-600">Open bill</a>
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
</section>
|
|
||||||
@elseif (! empty($clinicalFields))
|
|
||||||
@include('care.specialty.partials.clinical-form')
|
|
||||||
@elseif ($activeTab === 'orders')
|
|
||||||
<section class="rounded-2xl border border-slate-200 bg-white p-5">
|
|
||||||
<h3 class="text-sm font-semibold text-slate-900">Orders</h3>
|
|
||||||
<p class="mt-2 text-sm text-slate-500">Order lab / imaging from the consultation flow. Specialty order sets can extend this later.</p>
|
|
||||||
<div class="mt-3 flex flex-wrap gap-3">
|
|
||||||
<a href="{{ route('care.lab.requests.index') }}" class="text-sm font-medium text-indigo-600">Lab requests</a>
|
|
||||||
@if ($workspaceVisit->appointment)
|
|
||||||
<a href="{{ route('care.appointments.show', $workspaceVisit->appointment) }}" class="text-sm font-medium text-indigo-600">Appointment</a>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
@elseif ($activeTab === 'documents')
|
|
||||||
<section class="rounded-2xl border border-slate-200 bg-white p-5">
|
|
||||||
<h3 class="text-sm font-semibold text-slate-900">Documents</h3>
|
|
||||||
<p class="mt-1 text-xs text-slate-500">Specialty documents attach to the patient chart for this episode.</p>
|
|
||||||
|
|
||||||
<form method="POST" action="{{ route('care.specialty.documents.upload', ['module' => $moduleKey, 'visit' => $workspaceVisit]) }}" enctype="multipart/form-data" class="mt-4 space-y-3">
|
|
||||||
@csrf
|
|
||||||
<input type="file" name="attachment" required accept=".pdf,.jpg,.jpeg,.png,.webp" class="block w-full text-sm">
|
|
||||||
<button type="submit" class="btn-primary">Upload document</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<ul class="mt-4 space-y-2 text-sm">
|
|
||||||
@forelse ($visitDocuments ?? [] as $doc)
|
|
||||||
<li class="flex items-center justify-between gap-3 rounded-xl border border-slate-100 bg-slate-50 px-3 py-2">
|
|
||||||
<div class="min-w-0">
|
|
||||||
<p class="truncate font-medium text-slate-800">{{ $doc->original_name }}</p>
|
|
||||||
<p class="text-xs text-slate-500">{{ $doc->document_type }} · {{ $doc->created_at?->format('d M Y H:i') }}</p>
|
|
||||||
</div>
|
|
||||||
@if ($doc->file_path)
|
|
||||||
<a href="{{ \Illuminate\Support\Facades\Storage::disk('public')->url($doc->file_path) }}" target="_blank" class="shrink-0 text-xs font-medium text-sky-600">Open</a>
|
|
||||||
@endif
|
|
||||||
</li>
|
|
||||||
@empty
|
|
||||||
<li class="text-slate-500">No documents yet.</li>
|
|
||||||
@endforelse
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
@if ($workspaceVisit->patient)
|
|
||||||
<a href="{{ route('care.patients.show', $workspaceVisit->patient) }}" class="mt-3 inline-flex text-sm font-medium text-indigo-600">Patient chart</a>
|
|
||||||
@endif
|
|
||||||
</section>
|
|
||||||
@else
|
|
||||||
<section class="rounded-2xl border border-slate-200 bg-white p-5">
|
|
||||||
<h3 class="text-sm font-semibold text-slate-900">Overview</h3>
|
|
||||||
<dl class="mt-3 grid gap-3 text-sm sm:grid-cols-2">
|
|
||||||
<div>
|
|
||||||
<dt class="text-slate-500">Visit status</dt>
|
|
||||||
<dd class="font-medium text-slate-900">{{ ucfirst(str_replace('_', ' ', $workspaceVisit->status)) }}</dd>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<dt class="text-slate-500">Checked in</dt>
|
|
||||||
<dd class="font-medium text-slate-900">{{ $workspaceVisit->checked_in_at?->format('d M Y H:i') ?? '—' }}</dd>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<dt class="text-slate-500">Department</dt>
|
|
||||||
<dd class="font-medium text-slate-900">{{ $workspaceVisit->appointment?->department?->name ?? '—' }}</dd>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<dt class="text-slate-500">Queue</dt>
|
|
||||||
<dd class="font-medium text-slate-900">
|
|
||||||
{{ $workspaceVisit->appointment?->queue_ticket_number ?? '—' }}
|
|
||||||
@if ($workspaceVisit->appointment?->queue_ticket_status)
|
|
||||||
<span class="text-slate-500">({{ $workspaceVisit->appointment->queue_ticket_status }})</span>
|
|
||||||
@endif
|
|
||||||
</dd>
|
|
||||||
</div>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
@if (! empty($clinicalAlerts))
|
|
||||||
<div class="mt-4 space-y-1.5 border-t border-slate-100 pt-4">
|
|
||||||
<p class="text-xs font-semibold uppercase tracking-wide text-slate-500">Clinical alerts</p>
|
|
||||||
@foreach ($clinicalAlerts as $alert)
|
|
||||||
<p class="text-sm {{ ($alert['severity'] ?? '') === 'critical' ? 'text-rose-700' : 'text-amber-800' }}">
|
|
||||||
{{ $alert['message'] ?? '' }}
|
|
||||||
</p>
|
|
||||||
@endforeach
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
</section>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="lg:col-span-2">
|
|
||||||
@include('care.partials.patient-timeline', ['events' => $timeline ?? []])
|
@include('care.partials.patient-timeline', ['events' => $timeline ?? []])
|
||||||
</div>
|
@elseif ($activeTab === 'billing')
|
||||||
|
<section class="rounded-2xl border border-slate-200 bg-white p-5">
|
||||||
|
<h3 class="text-sm font-semibold text-slate-900">Add specialty service</h3>
|
||||||
|
<form method="POST" action="{{ route('care.specialty.services.add', ['module' => $moduleKey, 'visit' => $workspaceVisit]) }}" class="mt-3 space-y-3">
|
||||||
|
@csrf
|
||||||
|
<select name="service_code" required class="w-full rounded-xl border border-slate-200 px-3 py-2 text-sm">
|
||||||
|
<option value="">Select service…</option>
|
||||||
|
@foreach ($services as $service)
|
||||||
|
<option value="{{ $service['code'] }}">
|
||||||
|
{{ $service['label'] }} — {{ $currency ?? 'GHS' }} {{ number_format(((int) $service['amount_minor']) / 100, 2) }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
<button type="submit" class="btn-primary">{{ $actions['invoice'] ?? 'Add to invoice' }}</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
@if ($workspaceVisit->bill)
|
||||||
|
<div class="mt-6 border-t border-slate-100 pt-4">
|
||||||
|
<p class="text-xs font-semibold uppercase tracking-wide text-slate-500">Current invoice {{ $workspaceVisit->bill->invoice_number }}</p>
|
||||||
|
<ul class="mt-2 space-y-1 text-sm">
|
||||||
|
@forelse ($workspaceVisit->bill->lineItems as $line)
|
||||||
|
<li class="flex justify-between gap-3">
|
||||||
|
<span>{{ $line->description }}</span>
|
||||||
|
<span class="tabular-nums">{{ number_format($line->total_minor / 100, 2) }}</span>
|
||||||
|
</li>
|
||||||
|
@empty
|
||||||
|
<li class="text-slate-500">No line items yet.</li>
|
||||||
|
@endforelse
|
||||||
|
</ul>
|
||||||
|
<a href="{{ route('care.bills.show', $workspaceVisit->bill) }}" class="mt-3 inline-flex text-sm font-medium text-indigo-600">Open bill</a>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</section>
|
||||||
|
@elseif (! empty($clinicalFields))
|
||||||
|
@include('care.specialty.partials.clinical-form')
|
||||||
|
@elseif ($activeTab === 'orders')
|
||||||
|
<section class="rounded-2xl border border-slate-200 bg-white p-5">
|
||||||
|
<h3 class="text-sm font-semibold text-slate-900">Orders</h3>
|
||||||
|
<p class="mt-2 text-sm text-slate-500">Order lab / imaging from the consultation flow. Specialty order sets can extend this later.</p>
|
||||||
|
<div class="mt-3 flex flex-wrap gap-3">
|
||||||
|
<a href="{{ route('care.lab.requests.index') }}" class="text-sm font-medium text-indigo-600">Lab requests</a>
|
||||||
|
@if ($workspaceVisit->appointment)
|
||||||
|
<a href="{{ route('care.appointments.show', $workspaceVisit->appointment) }}" class="text-sm font-medium text-indigo-600">Appointment</a>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
@elseif ($activeTab === 'documents')
|
||||||
|
<section class="rounded-2xl border border-slate-200 bg-white p-5">
|
||||||
|
<h3 class="text-sm font-semibold text-slate-900">Documents</h3>
|
||||||
|
<p class="mt-1 text-xs text-slate-500">Specialty documents attach to the patient chart for this episode.</p>
|
||||||
|
|
||||||
|
<form method="POST" action="{{ route('care.specialty.documents.upload', ['module' => $moduleKey, 'visit' => $workspaceVisit]) }}" enctype="multipart/form-data" class="mt-4 space-y-3">
|
||||||
|
@csrf
|
||||||
|
<input type="file" name="attachment" required accept=".pdf,.jpg,.jpeg,.png,.webp" class="block w-full text-sm">
|
||||||
|
<button type="submit" class="btn-primary">Upload document</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<ul class="mt-4 space-y-2 text-sm">
|
||||||
|
@forelse ($visitDocuments ?? [] as $doc)
|
||||||
|
<li class="flex items-center justify-between gap-3 rounded-xl border border-slate-100 bg-slate-50 px-3 py-2">
|
||||||
|
<div class="min-w-0">
|
||||||
|
<p class="truncate font-medium text-slate-800">{{ $doc->original_name }}</p>
|
||||||
|
<p class="text-xs text-slate-500">{{ $doc->document_type }} · {{ $doc->created_at?->format('d M Y H:i') }}</p>
|
||||||
|
</div>
|
||||||
|
@if ($doc->file_path)
|
||||||
|
<a href="{{ \Illuminate\Support\Facades\Storage::disk('public')->url($doc->file_path) }}" target="_blank" class="shrink-0 text-xs font-medium text-sky-600">Open</a>
|
||||||
|
@endif
|
||||||
|
</li>
|
||||||
|
@empty
|
||||||
|
<li class="text-slate-500">No documents yet.</li>
|
||||||
|
@endforelse
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
@if ($workspaceVisit->patient)
|
||||||
|
<a href="{{ route('care.patients.show', $workspaceVisit->patient) }}" class="mt-3 inline-flex text-sm font-medium text-indigo-600">Patient chart</a>
|
||||||
|
@endif
|
||||||
|
</section>
|
||||||
|
@else
|
||||||
|
<section class="rounded-2xl border border-slate-200 bg-white p-5">
|
||||||
|
<h3 class="text-sm font-semibold text-slate-900">Overview</h3>
|
||||||
|
<dl class="mt-3 grid gap-3 text-sm sm:grid-cols-2">
|
||||||
|
<div>
|
||||||
|
<dt class="text-slate-500">Visit status</dt>
|
||||||
|
<dd class="font-medium text-slate-900">{{ ucfirst(str_replace('_', ' ', $workspaceVisit->status)) }}</dd>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dt class="text-slate-500">Checked in</dt>
|
||||||
|
<dd class="font-medium text-slate-900">{{ $workspaceVisit->checked_in_at?->format('d M Y H:i') ?? '—' }}</dd>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dt class="text-slate-500">Department</dt>
|
||||||
|
<dd class="font-medium text-slate-900">{{ $workspaceVisit->appointment?->department?->name ?? '—' }}</dd>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<dt class="text-slate-500">Queue</dt>
|
||||||
|
<dd class="font-medium text-slate-900">
|
||||||
|
{{ $workspaceVisit->appointment?->queue_ticket_number ?? '—' }}
|
||||||
|
@if ($workspaceVisit->appointment?->queue_ticket_status)
|
||||||
|
<span class="text-slate-500">({{ $workspaceVisit->appointment->queue_ticket_status }})</span>
|
||||||
|
@endif
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
@if (! empty($clinicalAlerts))
|
||||||
|
<div class="mt-4 space-y-1.5 border-t border-slate-100 pt-4">
|
||||||
|
<p class="text-xs font-semibold uppercase tracking-wide text-slate-500">Clinical alerts</p>
|
||||||
|
@foreach ($clinicalAlerts as $alert)
|
||||||
|
<p class="text-sm {{ ($alert['severity'] ?? '') === 'critical' ? 'text-rose-700' : 'text-amber-800' }}">
|
||||||
|
{{ $alert['message'] ?? '' }}
|
||||||
|
</p>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</section>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@@ -31,6 +31,20 @@
|
|||||||
'actionsView' => 'care.specialty.partials.actions-menu',
|
'actionsView' => 'care.specialty.partials.actions-menu',
|
||||||
'title' => 'Actions',
|
'title' => 'Actions',
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@php
|
||||||
|
$completeConsultation = $workspaceVisit?->appointment?->consultation;
|
||||||
|
@endphp
|
||||||
|
@if ($completeConsultation && $completeConsultation->status !== \App\Models\Consultation::STATUS_COMPLETED)
|
||||||
|
<x-confirm-dialog
|
||||||
|
:name="'complete-consultation-'.$completeConsultation->id"
|
||||||
|
title="Complete this consultation?"
|
||||||
|
message="Mark the consultation as finished. You can still prescribe or generate a bill afterward."
|
||||||
|
:action="route('care.consultations.complete', $completeConsultation)"
|
||||||
|
confirm-label="Complete consultation"
|
||||||
|
variant="primary"
|
||||||
|
/>
|
||||||
|
@endif
|
||||||
@elseif ($section === 'history')
|
@elseif ($section === 'history')
|
||||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -198,18 +198,18 @@ class CareQueueBridgeTest extends TestCase
|
|||||||
'queue_position' => 1,
|
'queue_position' => 1,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->actingAs($this->owner)
|
$response = $this->actingAs($this->owner)
|
||||||
->from(route('care.queue.index'))
|
->from(route('care.queue.index'))
|
||||||
->post(route('care.queue.call-next'), [
|
->post(route('care.queue.call-next'), [
|
||||||
'branch_id' => $this->branch->id,
|
'branch_id' => $this->branch->id,
|
||||||
'practitioner_id' => $practitioner->id,
|
'practitioner_id' => $practitioner->id,
|
||||||
])
|
])
|
||||||
->assertRedirect(route('care.queue.index'))
|
|
||||||
->assertSessionHas('success');
|
->assertSessionHas('success');
|
||||||
|
|
||||||
$appointment = Appointment::query()->where('patient_id', $this->patient->id)->first();
|
$appointment = Appointment::query()->where('patient_id', $this->patient->id)->first();
|
||||||
$this->assertNotNull($appointment?->queue_ticket_uuid);
|
$this->assertNotNull($appointment?->queue_ticket_uuid);
|
||||||
$this->assertSame('called', $appointment->queue_ticket_status);
|
$this->assertSame('called', $appointment->queue_ticket_status);
|
||||||
|
$response->assertRedirect(route('care.appointments.show', $appointment));
|
||||||
$this->assertDatabaseHas('care_queue_tickets', [
|
$this->assertDatabaseHas('care_queue_tickets', [
|
||||||
'uuid' => $appointment->queue_ticket_uuid,
|
'uuid' => $appointment->queue_ticket_uuid,
|
||||||
'status' => CareQueueTicket::STATUS_CALLED,
|
'status' => CareQueueTicket::STATUS_CALLED,
|
||||||
@@ -387,4 +387,114 @@ class CareQueueBridgeTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
Http::assertNothingSent();
|
Http::assertNothingSent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_call_next_ends_current_session_and_opens_next_patient(): void
|
||||||
|
{
|
||||||
|
Http::fake();
|
||||||
|
|
||||||
|
$practitioner = \App\Models\Practitioner::create([
|
||||||
|
'owner_ref' => $this->owner->public_id,
|
||||||
|
'organization_id' => $this->organization->id,
|
||||||
|
'branch_id' => $this->branch->id,
|
||||||
|
'name' => 'Dr. Advance',
|
||||||
|
'room' => 'Room 4',
|
||||||
|
'is_active' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$currentPatient = Patient::create([
|
||||||
|
'owner_ref' => $this->owner->public_id,
|
||||||
|
'organization_id' => $this->organization->id,
|
||||||
|
'branch_id' => $this->branch->id,
|
||||||
|
'patient_number' => 'P-CUR',
|
||||||
|
'first_name' => 'Current',
|
||||||
|
'last_name' => 'Patient',
|
||||||
|
'gender' => 'female',
|
||||||
|
'date_of_birth' => '1991-01-01',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$currentVisit = \App\Models\Visit::create([
|
||||||
|
'owner_ref' => $this->owner->public_id,
|
||||||
|
'organization_id' => $this->organization->id,
|
||||||
|
'branch_id' => $this->branch->id,
|
||||||
|
'patient_id' => $currentPatient->id,
|
||||||
|
'status' => \App\Models\Visit::STATUS_IN_PROGRESS,
|
||||||
|
'checked_in_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$current = Appointment::create([
|
||||||
|
'owner_ref' => $this->owner->public_id,
|
||||||
|
'organization_id' => $this->organization->id,
|
||||||
|
'branch_id' => $this->branch->id,
|
||||||
|
'patient_id' => $currentPatient->id,
|
||||||
|
'practitioner_id' => $practitioner->id,
|
||||||
|
'visit_id' => $currentVisit->id,
|
||||||
|
'type' => Appointment::TYPE_WALK_IN,
|
||||||
|
'status' => Appointment::STATUS_IN_CONSULTATION,
|
||||||
|
'scheduled_at' => now()->subHour(),
|
||||||
|
'waiting_at' => now()->subHour(),
|
||||||
|
'checked_in_at' => now()->subHour(),
|
||||||
|
'started_at' => now()->subMinutes(30),
|
||||||
|
'queue_ticket_status' => 'serving',
|
||||||
|
]);
|
||||||
|
|
||||||
|
\App\Models\Consultation::create([
|
||||||
|
'owner_ref' => $this->owner->public_id,
|
||||||
|
'visit_id' => $currentVisit->id,
|
||||||
|
'appointment_id' => $current->id,
|
||||||
|
'practitioner_id' => $practitioner->id,
|
||||||
|
'patient_id' => $currentPatient->id,
|
||||||
|
'status' => \App\Models\Consultation::STATUS_DRAFT,
|
||||||
|
'started_at' => now()->subMinutes(30),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$nextVisit = \App\Models\Visit::create([
|
||||||
|
'owner_ref' => $this->owner->public_id,
|
||||||
|
'organization_id' => $this->organization->id,
|
||||||
|
'branch_id' => $this->branch->id,
|
||||||
|
'patient_id' => $this->patient->id,
|
||||||
|
'status' => \App\Models\Visit::STATUS_OPEN,
|
||||||
|
'checked_in_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$next = Appointment::create([
|
||||||
|
'owner_ref' => $this->owner->public_id,
|
||||||
|
'organization_id' => $this->organization->id,
|
||||||
|
'branch_id' => $this->branch->id,
|
||||||
|
'patient_id' => $this->patient->id,
|
||||||
|
'practitioner_id' => $practitioner->id,
|
||||||
|
'visit_id' => $nextVisit->id,
|
||||||
|
'type' => Appointment::TYPE_WALK_IN,
|
||||||
|
'status' => Appointment::STATUS_WAITING,
|
||||||
|
'scheduled_at' => now(),
|
||||||
|
'waiting_at' => now(),
|
||||||
|
'checked_in_at' => now(),
|
||||||
|
'queue_position' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
|
app(\App\Services\Care\CareQueueBridge::class)->issueForAppointment(
|
||||||
|
$this->organization->fresh(),
|
||||||
|
$next->fresh(['patient', 'practitioner', 'organization']),
|
||||||
|
);
|
||||||
|
|
||||||
|
$response = $this->actingAs($this->owner)
|
||||||
|
->post(route('care.queue.call-next'), [
|
||||||
|
'branch_id' => $this->branch->id,
|
||||||
|
'practitioner_id' => $practitioner->id,
|
||||||
|
'appointment_id' => $current->id,
|
||||||
|
])
|
||||||
|
->assertSessionHas('success');
|
||||||
|
|
||||||
|
$this->assertSame(Appointment::STATUS_COMPLETED, $current->fresh()->status);
|
||||||
|
$this->assertSame(\App\Models\Consultation::STATUS_COMPLETED, $current->consultation->fresh()->status);
|
||||||
|
|
||||||
|
$next = $next->fresh();
|
||||||
|
$this->assertSame('called', $next->queue_ticket_status);
|
||||||
|
$response->assertRedirect(route('care.appointments.show', $next));
|
||||||
|
|
||||||
|
$this->actingAs($this->owner)
|
||||||
|
->get(route('care.appointments.show', $next))
|
||||||
|
->assertOk()
|
||||||
|
->assertSee('Call again');
|
||||||
|
Http::assertNothingSent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -291,4 +291,148 @@ class CareSpecialtyShellTest extends TestCase
|
|||||||
]));
|
]));
|
||||||
$this->assertSame(Appointment::STATUS_IN_CONSULTATION, $appointment->fresh()->status);
|
$this->assertSame(Appointment::STATUS_IN_CONSULTATION, $appointment->fresh()->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_workspace_includes_timeline_tab_and_complete_action(): void
|
||||||
|
{
|
||||||
|
app(SpecialtyModuleService::class)->activate(
|
||||||
|
$this->organization,
|
||||||
|
$this->owner->public_id,
|
||||||
|
'dentistry',
|
||||||
|
);
|
||||||
|
|
||||||
|
$department = Department::query()
|
||||||
|
->where('branch_id', $this->branch->id)
|
||||||
|
->where('type', 'dental')
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
$patient = Patient::create([
|
||||||
|
'owner_ref' => $this->owner->public_id,
|
||||||
|
'organization_id' => $this->organization->id,
|
||||||
|
'branch_id' => $this->branch->id,
|
||||||
|
'patient_number' => 'P-DEN-TL',
|
||||||
|
'first_name' => 'Afia',
|
||||||
|
'last_name' => 'Darko',
|
||||||
|
'gender' => 'female',
|
||||||
|
'date_of_birth' => '1992-01-01',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$visit = Visit::create([
|
||||||
|
'owner_ref' => $this->owner->public_id,
|
||||||
|
'organization_id' => $this->organization->id,
|
||||||
|
'branch_id' => $this->branch->id,
|
||||||
|
'patient_id' => $patient->id,
|
||||||
|
'status' => Visit::STATUS_IN_PROGRESS,
|
||||||
|
'checked_in_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$appointment = Appointment::create([
|
||||||
|
'owner_ref' => $this->owner->public_id,
|
||||||
|
'organization_id' => $this->organization->id,
|
||||||
|
'branch_id' => $this->branch->id,
|
||||||
|
'patient_id' => $patient->id,
|
||||||
|
'department_id' => $department->id,
|
||||||
|
'visit_id' => $visit->id,
|
||||||
|
'type' => Appointment::TYPE_WALK_IN,
|
||||||
|
'status' => Appointment::STATUS_IN_CONSULTATION,
|
||||||
|
'scheduled_at' => now(),
|
||||||
|
'waiting_at' => now(),
|
||||||
|
'checked_in_at' => now(),
|
||||||
|
'started_at' => now(),
|
||||||
|
'queue_ticket_status' => 'serving',
|
||||||
|
]);
|
||||||
|
|
||||||
|
\App\Models\Consultation::create([
|
||||||
|
'owner_ref' => $this->owner->public_id,
|
||||||
|
'visit_id' => $visit->id,
|
||||||
|
'appointment_id' => $appointment->id,
|
||||||
|
'patient_id' => $patient->id,
|
||||||
|
'status' => \App\Models\Consultation::STATUS_DRAFT,
|
||||||
|
'started_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$tabs = app(SpecialtyShellService::class)->workspaceTabs('dentistry');
|
||||||
|
$this->assertArrayHasKey('timeline', $tabs);
|
||||||
|
$this->assertSame(['overview', 'timeline'], array_slice(array_keys($tabs), 0, 2));
|
||||||
|
|
||||||
|
$this->actingAs($this->owner)
|
||||||
|
->get(route('care.specialty.workspace', [
|
||||||
|
'module' => 'dentistry',
|
||||||
|
'visit' => $visit,
|
||||||
|
'tab' => 'timeline',
|
||||||
|
]))
|
||||||
|
->assertOk()
|
||||||
|
->assertSee('Timeline')
|
||||||
|
->assertSee('Patient timeline')
|
||||||
|
->assertSee('Complete consultation')
|
||||||
|
->assertDontSee('>Call again<', false);
|
||||||
|
|
||||||
|
$this->actingAs($this->owner)
|
||||||
|
->get(route('care.specialty.workspace', [
|
||||||
|
'module' => 'dentistry',
|
||||||
|
'visit' => $visit,
|
||||||
|
'tab' => 'overview',
|
||||||
|
]))
|
||||||
|
->assertOk()
|
||||||
|
->assertDontSee('Patient timeline');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_called_workspace_shows_call_again_until_session_starts(): void
|
||||||
|
{
|
||||||
|
app(SpecialtyModuleService::class)->activate(
|
||||||
|
$this->organization,
|
||||||
|
$this->owner->public_id,
|
||||||
|
'dentistry',
|
||||||
|
);
|
||||||
|
|
||||||
|
$department = Department::query()
|
||||||
|
->where('branch_id', $this->branch->id)
|
||||||
|
->where('type', 'dental')
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
$patient = Patient::create([
|
||||||
|
'owner_ref' => $this->owner->public_id,
|
||||||
|
'organization_id' => $this->organization->id,
|
||||||
|
'branch_id' => $this->branch->id,
|
||||||
|
'patient_number' => 'P-DEN-CALL',
|
||||||
|
'first_name' => 'Kofi',
|
||||||
|
'last_name' => 'Mensah',
|
||||||
|
'gender' => 'male',
|
||||||
|
'date_of_birth' => '1988-01-01',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$visit = Visit::create([
|
||||||
|
'owner_ref' => $this->owner->public_id,
|
||||||
|
'organization_id' => $this->organization->id,
|
||||||
|
'branch_id' => $this->branch->id,
|
||||||
|
'patient_id' => $patient->id,
|
||||||
|
'status' => Visit::STATUS_OPEN,
|
||||||
|
'checked_in_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
Appointment::create([
|
||||||
|
'owner_ref' => $this->owner->public_id,
|
||||||
|
'organization_id' => $this->organization->id,
|
||||||
|
'branch_id' => $this->branch->id,
|
||||||
|
'patient_id' => $patient->id,
|
||||||
|
'department_id' => $department->id,
|
||||||
|
'visit_id' => $visit->id,
|
||||||
|
'type' => Appointment::TYPE_WALK_IN,
|
||||||
|
'status' => Appointment::STATUS_WAITING,
|
||||||
|
'scheduled_at' => now(),
|
||||||
|
'waiting_at' => now(),
|
||||||
|
'checked_in_at' => now(),
|
||||||
|
'queue_ticket_status' => 'called',
|
||||||
|
'queue_ticket_number' => 'DEN001',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->actingAs($this->owner)
|
||||||
|
->get(route('care.specialty.workspace', [
|
||||||
|
'module' => 'dentistry',
|
||||||
|
'visit' => $visit,
|
||||||
|
]))
|
||||||
|
->assertOk()
|
||||||
|
->assertSee('Call again')
|
||||||
|
->assertSee('Start')
|
||||||
|
->assertDontSee('Complete consultation');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user