Clarify patient vs nurse unit placement on nursing charts.
Deploy Ladill Care / deploy (push) Successful in 55s

The empty state referred to the patient but read like the nurse was unassigned; show duty units and patient-specific copy instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-20 16:36:35 +00:00
co-authored by Cursor
parent cebc9c8e4c
commit 5c394cec2e
4 changed files with 155 additions and 10 deletions
@@ -214,6 +214,7 @@ class PatientController extends Controller
$nursingAssessments = collect();
$activePlacedVisit = null;
$latestVitals = null;
$nurseDutyUnits = collect();
if ($canViewAssessments) {
$branchScope = app(OrganizationResolver::class)->branchScope($member);
@@ -243,10 +244,13 @@ class PatientController extends Controller
}
if ($isNurseStation) {
$nurseDutyUnits = app(\App\Services\Care\NurseStationService::class)
->dutyUnits($organization, $member, $this->ownerRef($request));
$activePlacedVisit = $patient->visits()
->whereIn('status', [Visit::STATUS_OPEN, Visit::STATUS_IN_PROGRESS])
->whereNotNull('care_unit_id')
->with(['careUnit', 'bed'])
->with(['careUnit.department.branch', 'bed'])
->orderByDesc('placed_at')
->first();
@@ -269,6 +273,7 @@ class PatientController extends Controller
'canViewPathways' => $canViewPathways,
'activePlacedVisit' => $activePlacedVisit,
'latestVitals' => $latestVitals,
'nurseDutyUnits' => $nurseDutyUnits,
'nursingAssessments' => $nursingAssessments,
'messagingSmsReady' => $suiteSmsReady || $credential->hasValidSms(),
'messagingEmailReady' => $suiteEmailReady || $credential->hasValidBird(),
+61
View File
@@ -118,4 +118,65 @@ class NurseStationService
'selected_unit' => $selected,
];
}
/**
* Units the nurse is on duty for today (roster) or has an active home placement.
*
* @return Collection<int, CareUnit>
*/
public function dutyUnits(Organization $organization, Member $member, string $ownerRef): Collection
{
$dutyToday = RosterEntry::owned($ownerRef)
->where('organization_id', $organization->id)
->where('member_id', $member->id)
->whereDate('duty_date', now()->toDateString())
->where('status', '!=', RosterEntry::STATUS_CANCELLED)
->orderBy('shift_id')
->get(['care_unit_id']);
$placements = StaffAssignment::owned($ownerRef)
->where('organization_id', $organization->id)
->where('member_id', $member->id)
->where('status', 'active')
->unitPlacements()
->effectiveOn(now())
->whereNotNull('care_unit_id')
->get(['care_unit_id']);
$unitIds = $dutyToday->pluck('care_unit_id')
->merge($placements->pluck('care_unit_id'))
->filter()
->map(fn ($id) => (int) $id)
->unique()
->values();
if ($unitIds->isEmpty()) {
return collect();
}
$units = CareUnit::owned($ownerRef)
->where('organization_id', $organization->id)
->whereIn('id', $unitIds->all())
->where('is_active', true)
->with('department.branch')
->get()
->keyBy('id');
// Preserve roster order, then placement-only units.
$ordered = collect();
foreach ($dutyToday as $entry) {
$id = (int) $entry->care_unit_id;
if ($units->has($id) && ! $ordered->has($id)) {
$ordered->put($id, $units->get($id));
}
}
foreach ($placements as $assignment) {
$id = (int) $assignment->care_unit_id;
if ($units->has($id) && ! $ordered->has($id)) {
$ordered->put($id, $units->get($id));
}
}
return $ordered->values();
}
}