wip
This commit is contained in:
parent
5ec37cd58e
commit
a9d2b34e6f
@ -13,31 +13,31 @@ public static function worklist_stats(int $days, int $report_status)
|
|||||||
SELECT
|
SELECT
|
||||||
users."id",
|
users."id",
|
||||||
users.display_name,
|
users.display_name,
|
||||||
COALESCE (studies.assign_counts, 0) AS workload
|
COALESCE (cte.assign_counts, 0) AS workload
|
||||||
FROM
|
FROM
|
||||||
roles
|
roles
|
||||||
INNER JOIN model_has_roles ON roles."id" = model_has_roles.role_id
|
INNER JOIN model_has_roles ON roles."id" = model_has_roles.role_id
|
||||||
INNER JOIN users ON users."id" = model_has_roles.model_id
|
INNER JOIN users ON users."id" = model_has_roles.model_id
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT
|
SELECT
|
||||||
assigned_physician_id,
|
sa.user_id,
|
||||||
COUNT(*) AS assign_counts
|
COUNT(sa.*) AS assign_counts
|
||||||
FROM
|
FROM
|
||||||
studies
|
study_assignments AS sa
|
||||||
WHERE
|
INNER JOIN studies st ON st.ID = sa.study_id
|
||||||
--received_at::DATE >= NOW() - INTERVAL '3 DAY'
|
WHERE
|
||||||
assigned_at::DATE >= NOW() - INTERVAL '%d DAY'
|
--st.received_at :: DATE >= NOW() - INTERVAL '3 DAY'
|
||||||
AND report_status < %d
|
st.received_at::DATE >= NOW() - INTERVAL '%d DAY'
|
||||||
AND reported_at IS NULL
|
AND st.report_status < %d
|
||||||
GROUP BY
|
AND st.read_at IS NULL
|
||||||
assigned_physician_id
|
GROUP BY
|
||||||
) AS studies ON studies.assigned_physician_id = users."id"
|
sa.user_id) AS cte ON cte.user_id = users."id"
|
||||||
WHERE
|
WHERE
|
||||||
roles."name" = 'radiologist'
|
roles."name" = 'radiologist'
|
||||||
AND users.is_active = TRUE
|
AND users.is_active = TRUE
|
||||||
GROUP BY
|
GROUP BY
|
||||||
users."id",
|
users."id",
|
||||||
studies.assign_counts
|
cte.assign_counts
|
||||||
ORDER BY
|
ORDER BY
|
||||||
users.display_name
|
users.display_name
|
||||||
SQL;
|
SQL;
|
||||||
|
@ -19,30 +19,35 @@ public function show()
|
|||||||
{
|
{
|
||||||
abort_unless(auth()->user()->may(Permission::AssignRadiologist), 403);
|
abort_unless(auth()->user()->may(Permission::AssignRadiologist), 403);
|
||||||
$this->decodeKeys();
|
$this->decodeKeys();
|
||||||
$study = Study::with('assignedPhysician')->findOrFail($this->key);
|
$study = Study::with('assignedPhysicians')->findOrFail($this->key);
|
||||||
$rads = User::active()->role(Role::Radiologist)->get(['id', 'display_name', 'profile_photo_path', 'first_name', 'last_name', 'created_at']);
|
$rads = User::active()->role(Role::Radiologist)->get(['id', 'display_name', 'profile_photo_path', 'first_name', 'last_name', 'created_at']);
|
||||||
$stats = Radiologists::worklist_stats(3, ReportStatus::Finalized->value);
|
$stats = Radiologists::worklist_stats(3, ReportStatus::Finalized->value);
|
||||||
foreach ($stats as $rad) {
|
foreach ($stats as $rad) {
|
||||||
$found = $rads->where('id', $rad->id)->first();
|
$found = $rads->where('id', $rad->id)->first();
|
||||||
if ($found) {
|
if ($found) {
|
||||||
$found->info['workload'] = $rad->workload;
|
$found->info['workload'] = $rad->workload;
|
||||||
$found->info['last_seen'] = ($rad->last_seen ?? Carbon::now()->addHours(-10))->diffForHumans();
|
$found->info['last_seen'] = ($rad->last_seen ?? Carbon::now()->addHours(-random_int(1, 36)))->diffForHumans();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('staff.studies.assign-form', compact('study', 'rads'));
|
return view('staff.studies.assign-form', compact('study', 'rads'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function remove()
|
public function remove(AssignPhysicianRequest $request)
|
||||||
{
|
{
|
||||||
abort_unless(auth()->user()->may(Permission::AssignRadiologist), 403);
|
abort_unless(auth()->user()->may(Permission::AssignRadiologist), 403);
|
||||||
$this->decodeKeys();
|
$this->decodeKeys();
|
||||||
$study = Study::with('assignedPhysician')->findOrFail($this->key);
|
$study = Study::with('assignedPhysicians')->findOrFail($this->key);
|
||||||
if ($study->assigned_physician_id !== null) {
|
$user = User::active()->findOrFail($request->input('rad_id'));
|
||||||
$study->update(['assigned_physician_id' => null, 'assigned_at' => null]);
|
|
||||||
|
if ($study->isAssigned($user)) {
|
||||||
|
$study->assignedPhysicians()->detach($user->id);
|
||||||
|
if ($study->assignedPhysicians->count() === 0) {
|
||||||
|
$study->update(['assigned_at' => null]);
|
||||||
|
}
|
||||||
audit()
|
audit()
|
||||||
->did(Activity::Unassign_Physician)
|
->did(Activity::Unassign_Physician)
|
||||||
->notes("Unassigned: {$study->assignedPhysician?->display_name}")
|
->notes("Unassigned: {$user->display_name}")
|
||||||
->on($study)
|
->on($study)
|
||||||
->log();
|
->log();
|
||||||
}
|
}
|
||||||
@ -54,17 +59,11 @@ public function save(AssignPhysicianRequest $request)
|
|||||||
{
|
{
|
||||||
abort_unless(auth()->user()->may(Permission::AssignRadiologist), 403);
|
abort_unless(auth()->user()->may(Permission::AssignRadiologist), 403);
|
||||||
$this->decodeKeys();
|
$this->decodeKeys();
|
||||||
$study = Study::findOrFail($this->key);
|
$study = Study::with('assignedPhysicians')->findOrFail($this->key);
|
||||||
$rad = User::active()->findOrFail($request->input('rad_id'));
|
$rad = User::active()->findOrFail($request->input('rad_id'));
|
||||||
if ($study->assigned_physician_id !== null) {
|
|
||||||
audit()
|
|
||||||
->did(Activity::Unassign_Physician)
|
|
||||||
->notes("Unassigned: {$study->assignedPhysician?->display_name}")
|
|
||||||
->on($study)
|
|
||||||
->log();
|
|
||||||
}
|
|
||||||
|
|
||||||
$study->update(['assigned_physician_id' => $rad->id, 'assigned_at' => now()]);
|
$study->assignedPhysicians()->attach($rad->id);
|
||||||
|
$study->update(['assigned_at' => now()]);
|
||||||
audit()
|
audit()
|
||||||
->did(Activity::Assign_Physician)
|
->did(Activity::Assign_Physician)
|
||||||
->on($study)
|
->on($study)
|
||||||
|
@ -12,32 +12,41 @@
|
|||||||
<td>Patient Name</td>
|
<td>Patient Name</td>
|
||||||
<td class="fw-semibold">{{ $study->patient_name }}</td>
|
<td class="fw-semibold">{{ $study->patient_name }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-4 bg-light">
|
||||||
|
<h6 class="p-2">Currently Assigned Radiologist(s)</h6>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table class="table table-borderless table-sm">
|
||||||
|
@foreach ($study->assignedPhysicians as $physician)
|
||||||
<tr>
|
<tr>
|
||||||
<td>Currently assigned</td>
|
|
||||||
<td>
|
<td>
|
||||||
@isset($study->assignedPhysician)
|
{{ $physician->display_name }}
|
||||||
<div class="d-inline-flex">
|
</td>
|
||||||
<span class="fw-semibold me-4">{{ $study->assignedPhysician?->display_name }}</span>
|
<td>
|
||||||
<form action="{{ route('staff.assign.remove', $study->hash) }}" class="inline" method="post">
|
<form action="{{ route('staff.assign.remove', $study->hash) }}" method="POST">
|
||||||
@csrf
|
@csrf
|
||||||
@method('DELETE')
|
@method('DELETE')
|
||||||
<button class="btn btn-danger btn-xs" type="submit">
|
<input type="hidden" name="rad_id" value="{{ $physician->id }}">
|
||||||
<i class="fa-light fa-user-slash me-2"></i>
|
<button class="btn btn-outline-danger btn-xs" type="submit">
|
||||||
Remove
|
<i class="fa-light fa-user-slash me-1"></i>
|
||||||
</button>
|
Remove
|
||||||
</form>
|
</button>
|
||||||
</div>
|
</form>
|
||||||
@endisset
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
@endforeach
|
||||||
<div class="col-2">
|
</table>
|
||||||
</div>
|
|
||||||
|
<div class="mb-4 bg-light">
|
||||||
|
<h6 class="p-2">Available Radiologists</h6>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table class="table table-sm">
|
<table class="table table-sm">
|
||||||
<tr class="fw-light">
|
<tr class="fw-light">
|
||||||
<td>Physician</td>
|
<td>Radiologist</td>
|
||||||
<td>Workload</td>
|
<td>Workload</td>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -82,6 +91,6 @@
|
|||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
Loading…
Reference in New Issue
Block a user