Add Lab and Blood Bank manager roles with admin UIs.
Deploy Ladill Care / deploy (push) Successful in 46s
Deploy Ladill Care / deploy (push) Successful in 46s
Give lab_manager catalog/ops admin access and blood_bank_manager a branch-level stock register plus specialty admin surface, while keeping technicians on clinical queues. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Care;
|
||||
|
||||
use App\Http\Controllers\Care\Concerns\ScopesToAccount;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Care\BloodBank\BloodBankAnalyticsService;
|
||||
use App\Services\Care\BloodBank\BloodBankInventoryService;
|
||||
use App\Services\Care\BranchContext;
|
||||
use App\Services\Care\CarePermissions;
|
||||
use App\Services\Care\SpecialtyModuleService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class BloodBankAdminController extends Controller
|
||||
{
|
||||
use ScopesToAccount;
|
||||
|
||||
public function __construct(
|
||||
protected BloodBankInventoryService $inventory,
|
||||
protected BloodBankAnalyticsService $analytics,
|
||||
protected BranchContext $branchContext,
|
||||
) {}
|
||||
|
||||
public function index(
|
||||
Request $request,
|
||||
SpecialtyModuleService $modules,
|
||||
): View {
|
||||
$this->authorizeAbility($request, 'blood_bank.manage');
|
||||
$organization = $this->organization($request);
|
||||
abort_unless($modules->isEnabled($organization, 'blood_bank'), 404);
|
||||
|
||||
$member = $this->member($request);
|
||||
$branches = $this->branchContext->branches($request, $organization, $member);
|
||||
$branchId = $this->branchContext->resolve($request, $organization, $member);
|
||||
$branchScope = $branchId > 0 ? $branchId : null;
|
||||
|
||||
$overview = $this->inventory->adminOverview(
|
||||
$organization,
|
||||
$this->ownerRef($request),
|
||||
$branchScope,
|
||||
);
|
||||
|
||||
$report = $this->analytics->report(
|
||||
$organization,
|
||||
$this->ownerRef($request),
|
||||
$branchScope,
|
||||
);
|
||||
|
||||
return view('care.blood-bank.admin.index', [
|
||||
'organization' => $organization,
|
||||
'branches' => $branches,
|
||||
'branchId' => $branchId,
|
||||
'canSwitchBranch' => $this->branchContext->canSwitch($member),
|
||||
'overview' => $overview,
|
||||
'report' => $report,
|
||||
'isAdmin' => app(CarePermissions::class)->isAdmin($member),
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateStock(
|
||||
Request $request,
|
||||
SpecialtyModuleService $modules,
|
||||
): RedirectResponse {
|
||||
$this->authorizeAbility($request, 'blood_bank.manage');
|
||||
$organization = $this->organization($request);
|
||||
abort_unless($modules->isEnabled($organization, 'blood_bank'), 404);
|
||||
|
||||
$member = $this->member($request);
|
||||
$branchId = $this->branchContext->resolve($request, $organization, $member);
|
||||
$branchScope = $branchId > 0 ? $branchId : null;
|
||||
|
||||
$validated = $request->validate([
|
||||
'stock' => ['required', 'array'],
|
||||
'stock.*.product_code' => ['required', 'string', 'max:64'],
|
||||
'stock.*.units_on_hand' => ['required', 'integer', 'min:0', 'max:99999'],
|
||||
'stock.*.reorder_level' => ['required', 'integer', 'min:0', 'max:9999'],
|
||||
'stock.*.notes' => ['nullable', 'string', 'max:2000'],
|
||||
]);
|
||||
|
||||
$this->inventory->updateStock(
|
||||
$organization,
|
||||
$this->ownerRef($request),
|
||||
$branchScope,
|
||||
array_values($validated['stock']),
|
||||
$this->actorRef($request),
|
||||
);
|
||||
|
||||
return redirect()
|
||||
->route('care.blood-bank.admin.index', array_filter([
|
||||
'branch_id' => $branchId > 0 ? $branchId : null,
|
||||
]))
|
||||
->with('success', 'Blood Bank operational inventory updated.');
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ use App\Models\SpecialtyClinicalRecord;
|
||||
use App\Models\Visit;
|
||||
use App\Services\Care\BloodBank\BloodBankAnalyticsService;
|
||||
use App\Services\Care\BloodBank\BloodBankWorkflowService;
|
||||
use App\Services\Care\CarePermissions;
|
||||
use App\Services\Care\SpecialtyClinicalRecordService;
|
||||
use App\Services\Care\SpecialtyModuleService;
|
||||
use App\Services\Care\SpecialtyShellService;
|
||||
@@ -38,13 +39,40 @@ class BloodBankWorkspaceController extends Controller
|
||||
$this->authorizeBranch($request, (int) $visit->branch_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Doctors use consultations.manage; Blood Bank managers use blood_bank.manage.
|
||||
*/
|
||||
protected function authorizeBloodBankClinical(Request $request): void
|
||||
{
|
||||
$permissions = app(CarePermissions::class);
|
||||
$member = $this->member($request);
|
||||
abort_unless(
|
||||
$permissions->can($member, 'blood_bank.manage')
|
||||
|| $permissions->can($member, 'consultations.manage'),
|
||||
403,
|
||||
);
|
||||
}
|
||||
|
||||
protected function authorizeBloodBankViewAbility(Request $request): void
|
||||
{
|
||||
$permissions = app(CarePermissions::class);
|
||||
$member = $this->member($request);
|
||||
abort_unless(
|
||||
$permissions->can($member, 'blood_bank.view')
|
||||
|| $permissions->can($member, 'blood_bank.manage')
|
||||
|| $permissions->can($member, 'consultations.view')
|
||||
|| $permissions->can($member, 'consultations.manage'),
|
||||
403,
|
||||
);
|
||||
}
|
||||
|
||||
public function setStage(
|
||||
Request $request,
|
||||
Visit $visit,
|
||||
SpecialtyModuleService $modules,
|
||||
SpecialtyVisitStageService $stages,
|
||||
): RedirectResponse {
|
||||
$this->authorizeAbility($request, 'consultations.manage');
|
||||
$this->authorizeBloodBankClinical($request);
|
||||
$this->assertBloodBankManage($request, $modules);
|
||||
$this->assertVisit($request, $visit);
|
||||
|
||||
@@ -79,7 +107,7 @@ class BloodBankWorkspaceController extends Controller
|
||||
SpecialtyShellService $shell,
|
||||
BloodBankWorkflowService $workflow,
|
||||
): RedirectResponse {
|
||||
$this->authorizeAbility($request, 'consultations.manage');
|
||||
$this->authorizeBloodBankClinical($request);
|
||||
$this->assertBloodBankManage($request, $modules);
|
||||
$this->assertVisit($request, $visit);
|
||||
|
||||
@@ -187,7 +215,7 @@ class BloodBankWorkspaceController extends Controller
|
||||
SpecialtyVisitStageService $stages,
|
||||
BloodBankWorkflowService $workflow,
|
||||
): RedirectResponse {
|
||||
$this->authorizeAbility($request, 'consultations.manage');
|
||||
$this->authorizeBloodBankClinical($request);
|
||||
$this->assertBloodBankManage($request, $modules);
|
||||
$this->assertVisit($request, $visit);
|
||||
|
||||
@@ -271,7 +299,7 @@ class BloodBankWorkspaceController extends Controller
|
||||
SpecialtyShellService $shell,
|
||||
BloodBankAnalyticsService $analytics,
|
||||
): View {
|
||||
$this->authorizeAbility($request, 'consultations.view');
|
||||
$this->authorizeBloodBankViewAbility($request);
|
||||
$this->assertBloodBankAccess($request, $modules);
|
||||
|
||||
$organization = $this->organization($request);
|
||||
@@ -300,7 +328,7 @@ class BloodBankWorkspaceController extends Controller
|
||||
SpecialtyModuleService $modules,
|
||||
SpecialtyClinicalRecordService $clinical,
|
||||
): View {
|
||||
$this->authorizeAbility($request, 'consultations.view');
|
||||
$this->authorizeBloodBankViewAbility($request);
|
||||
$this->assertBloodBankAccess($request, $modules);
|
||||
$this->assertVisit($request, $visit);
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Care;
|
||||
|
||||
use App\Http\Controllers\Care\Concerns\ScopesToAccount;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\InvestigationRequest;
|
||||
use App\Models\InvestigationType;
|
||||
use App\Services\Care\BranchContext;
|
||||
use App\Services\Care\CarePermissions;
|
||||
use App\Services\Care\InvestigationService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class LabAdminController extends Controller
|
||||
{
|
||||
use ScopesToAccount;
|
||||
|
||||
public function __construct(
|
||||
protected InvestigationService $investigations,
|
||||
protected BranchContext $branchContext,
|
||||
) {}
|
||||
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$this->authorizeAbility($request, 'lab.catalog.manage');
|
||||
$organization = $this->organization($request);
|
||||
$member = $this->member($request);
|
||||
$owner = $this->ownerRef($request);
|
||||
$branches = $this->branchContext->branches($request, $organization, $member);
|
||||
$branchId = $this->branchContext->resolve($request, $organization, $member);
|
||||
$branchScope = $branchId > 0 ? $branchId : null;
|
||||
|
||||
$catalogCount = InvestigationType::query()
|
||||
->where('organization_id', $organization->id)
|
||||
->count();
|
||||
|
||||
$activeCatalogCount = InvestigationType::query()
|
||||
->where('organization_id', $organization->id)
|
||||
->where('is_active', true)
|
||||
->count();
|
||||
|
||||
$queueCounts = InvestigationRequest::owned($owner)
|
||||
->where('organization_id', $organization->id)
|
||||
->when($branchScope, fn ($q) => $q->where('branch_id', $branchScope))
|
||||
->whereIn('status', [
|
||||
InvestigationRequest::STATUS_PENDING,
|
||||
InvestigationRequest::STATUS_SAMPLE_COLLECTED,
|
||||
InvestigationRequest::STATUS_IN_PROGRESS,
|
||||
InvestigationRequest::STATUS_AWAITING_REVIEW,
|
||||
])
|
||||
->select('status', DB::raw('count(*) as total'))
|
||||
->groupBy('status')
|
||||
->pluck('total', 'status');
|
||||
|
||||
$openQueue = (int) $queueCounts->sum();
|
||||
$queue = $branchScope
|
||||
? $this->investigations->workQueue($owner, $branchScope)
|
||||
: collect();
|
||||
|
||||
return view('care.lab.admin.index', [
|
||||
'organization' => $organization,
|
||||
'branches' => $branches,
|
||||
'branchId' => $branchId,
|
||||
'canSwitchBranch' => $this->branchContext->canSwitch($member),
|
||||
'catalogCount' => $catalogCount,
|
||||
'activeCatalogCount' => $activeCatalogCount,
|
||||
'openQueue' => $openQueue,
|
||||
'queueCounts' => $queueCounts,
|
||||
'recentQueue' => $queue->take(8),
|
||||
'statuses' => config('care.investigation_statuses'),
|
||||
'isAdmin' => app(CarePermissions::class)->isAdmin($member),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ class MemberController extends Controller
|
||||
->get();
|
||||
|
||||
$adminRoles = ['super_admin', 'hospital_admin'];
|
||||
$clinicalRoles = ['doctor', 'nurse', 'lab_technician', 'pharmacist'];
|
||||
$clinicalRoles = ['doctor', 'nurse', 'lab_technician', 'lab_manager', 'pharmacist', 'blood_bank_manager'];
|
||||
|
||||
$heroStats = [
|
||||
'total' => $members->count(),
|
||||
|
||||
@@ -210,7 +210,7 @@ class PractitionerController extends Controller
|
||||
{
|
||||
return Member::owned($owner)
|
||||
->where('organization_id', $organizationId)
|
||||
->whereIn('role', ['doctor', 'nurse', 'lab_technician', 'pharmacist', 'hospital_admin', 'super_admin'])
|
||||
->whereIn('role', ['doctor', 'nurse', 'lab_technician', 'lab_manager', 'pharmacist', 'blood_bank_manager', 'hospital_admin', 'super_admin'])
|
||||
->orderBy('user_ref')
|
||||
->get();
|
||||
}
|
||||
|
||||
@@ -60,7 +60,8 @@ class ServiceQueueController extends Controller
|
||||
return match ($member?->role) {
|
||||
'cashier' => 'care.bills.index',
|
||||
'pharmacist' => 'care.prescriptions.queue',
|
||||
'lab_technician' => 'care.lab.queue.index',
|
||||
'lab_technician', 'lab_manager' => 'care.lab.queue.index',
|
||||
'blood_bank_manager' => 'care.blood-bank.admin.index',
|
||||
'receptionist', 'nurse' => 'care.appointments.index',
|
||||
default => 'care.dashboard',
|
||||
};
|
||||
|
||||
@@ -670,7 +670,10 @@ class SpecialtyModuleController extends Controller
|
||||
// Ability-based for every role (doctor, nurse, receptionist, lab, pharmacist, …).
|
||||
// Module canManage alone is not enough — flags must match what mutate routes authorize.
|
||||
$canConsult = $permissions->can($member, 'consultations.manage') && $canManageSpecialty;
|
||||
$canAdvanceStage = $canConsult;
|
||||
$canAdvanceStage = $canConsult
|
||||
|| ($module === 'blood_bank'
|
||||
&& $canManageSpecialty
|
||||
&& $permissions->can($member, 'blood_bank.manage'));
|
||||
$canStartConsultation = $canConsult;
|
||||
$canCallNext = $canManageSpecialty;
|
||||
$canManageClinical = $canManageSpecialty;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToOwner;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class BloodBankStock extends Model
|
||||
{
|
||||
use BelongsToOwner;
|
||||
|
||||
protected $table = 'care_blood_bank_stock';
|
||||
|
||||
protected $fillable = [
|
||||
'owner_ref',
|
||||
'organization_id',
|
||||
'branch_id',
|
||||
'product_code',
|
||||
'product_label',
|
||||
'units_on_hand',
|
||||
'reorder_level',
|
||||
'notes',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function organization(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Organization::class, 'organization_id');
|
||||
}
|
||||
|
||||
public function branch(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Branch::class, 'branch_id');
|
||||
}
|
||||
|
||||
public function isLowStock(): bool
|
||||
{
|
||||
return (int) $this->units_on_hand <= (int) $this->reorder_level;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Care\BloodBank;
|
||||
|
||||
use App\Models\BloodBankStock;
|
||||
use App\Models\Organization;
|
||||
use App\Models\SpecialtyClinicalRecord;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class BloodBankInventoryService
|
||||
{
|
||||
/**
|
||||
* Canonical operational products for branch-level stock (thin register, not bag ledger).
|
||||
*
|
||||
* @return array<string, array{label: string, reorder_level: int}>
|
||||
*/
|
||||
public function catalogProducts(): array
|
||||
{
|
||||
return [
|
||||
'whole_blood' => ['label' => 'Whole blood', 'reorder_level' => 2],
|
||||
'packed_rbc' => ['label' => 'Packed RBC', 'reorder_level' => 2],
|
||||
'platelets' => ['label' => 'Platelets', 'reorder_level' => 2],
|
||||
'ffp' => ['label' => 'FFP', 'reorder_level' => 2],
|
||||
'cryo' => ['label' => 'Cryoprecipitate', 'reorder_level' => 1],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure catalog rows exist for the branch, then return them ordered.
|
||||
*
|
||||
* @return Collection<int, BloodBankStock>
|
||||
*/
|
||||
public function ensureStockRows(
|
||||
Organization $organization,
|
||||
string $ownerRef,
|
||||
?int $branchId,
|
||||
): Collection {
|
||||
foreach ($this->catalogProducts() as $code => $meta) {
|
||||
BloodBankStock::query()->firstOrCreate(
|
||||
[
|
||||
'organization_id' => $organization->id,
|
||||
'branch_id' => $branchId,
|
||||
'product_code' => $code,
|
||||
],
|
||||
[
|
||||
'owner_ref' => $ownerRef,
|
||||
'product_label' => $meta['label'],
|
||||
'units_on_hand' => 0,
|
||||
'reorder_level' => $meta['reorder_level'],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return BloodBankStock::owned($ownerRef)
|
||||
->where('organization_id', $organization->id)
|
||||
->when(
|
||||
$branchId === null,
|
||||
fn ($q) => $q->whereNull('branch_id'),
|
||||
fn ($q) => $q->where('branch_id', $branchId),
|
||||
)
|
||||
->orderBy('product_label')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array{product_code: string, units_on_hand: int, reorder_level: int, notes?: ?string}> $rows
|
||||
* @return Collection<int, BloodBankStock>
|
||||
*/
|
||||
public function updateStock(
|
||||
Organization $organization,
|
||||
string $ownerRef,
|
||||
?int $branchId,
|
||||
array $rows,
|
||||
?string $actorRef = null,
|
||||
): Collection {
|
||||
$allowed = array_keys($this->catalogProducts());
|
||||
|
||||
return DB::transaction(function () use ($organization, $ownerRef, $branchId, $rows, $actorRef, $allowed) {
|
||||
$this->ensureStockRows($organization, $ownerRef, $branchId);
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$code = (string) ($row['product_code'] ?? '');
|
||||
if (! in_array($code, $allowed, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$stock = BloodBankStock::owned($ownerRef)
|
||||
->where('organization_id', $organization->id)
|
||||
->where('product_code', $code)
|
||||
->when(
|
||||
$branchId === null,
|
||||
fn ($q) => $q->whereNull('branch_id'),
|
||||
fn ($q) => $q->where('branch_id', $branchId),
|
||||
)
|
||||
->first();
|
||||
|
||||
if (! $stock) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$stock->update([
|
||||
'units_on_hand' => max(0, (int) ($row['units_on_hand'] ?? 0)),
|
||||
'reorder_level' => max(0, (int) ($row['reorder_level'] ?? $stock->reorder_level)),
|
||||
'notes' => isset($row['notes']) ? (string) $row['notes'] : $stock->notes,
|
||||
'updated_by' => $actorRef,
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->ensureStockRows($organization, $ownerRef, $branchId);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{
|
||||
* stock: Collection<int, BloodBankStock>,
|
||||
* low_stock: Collection<int, BloodBankStock>,
|
||||
* low_stock_count: int,
|
||||
* total_units: int,
|
||||
* recent_notes: Collection<int, SpecialtyClinicalRecord>
|
||||
* }
|
||||
*/
|
||||
public function adminOverview(
|
||||
Organization $organization,
|
||||
string $ownerRef,
|
||||
?int $branchId,
|
||||
): array {
|
||||
$stock = $this->ensureStockRows($organization, $ownerRef, $branchId);
|
||||
$lowStock = $stock->filter(fn (BloodBankStock $row) => $row->isLowStock())->values();
|
||||
|
||||
$recentNotes = SpecialtyClinicalRecord::owned($ownerRef)
|
||||
->where('organization_id', $organization->id)
|
||||
->where('module_key', 'blood_bank')
|
||||
->where('record_type', 'inventory_note')
|
||||
->when($branchId, fn ($q) => $q->where('branch_id', $branchId))
|
||||
->with(['visit.patient'])
|
||||
->orderByDesc('recorded_at')
|
||||
->limit(8)
|
||||
->get();
|
||||
|
||||
return [
|
||||
'stock' => $stock,
|
||||
'low_stock' => $lowStock,
|
||||
'low_stock_count' => $lowStock->count(),
|
||||
'total_units' => (int) $stock->sum('units_on_hand'),
|
||||
'recent_notes' => $recentNotes,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,8 @@ class BranchContext
|
||||
'nurse',
|
||||
'pharmacist',
|
||||
'lab_technician',
|
||||
'lab_manager',
|
||||
'blood_bank_manager',
|
||||
'cashier',
|
||||
'receptionist',
|
||||
], true)) {
|
||||
|
||||
@@ -9,10 +9,13 @@ class CarePermissions
|
||||
/**
|
||||
* Role abilities.
|
||||
*
|
||||
* Lab catalog pricing uses `lab.catalog.manage` (admins only via `*`).
|
||||
* Lab catalog pricing uses `lab.catalog.manage` (admins via `*`, plus `lab_manager`).
|
||||
* Lab technicians keep `lab.manage` for queue / sample / process / results —
|
||||
* not catalog CRUD or price edits.
|
||||
*
|
||||
* Blood Bank operational inventory uses `blood_bank.manage` (managers + admins).
|
||||
* Clinical visit stage/issue for managers also requires specialty module manage.
|
||||
*
|
||||
* @var array<string, list<string>>
|
||||
*/
|
||||
protected array $roleAbilities = [
|
||||
@@ -42,11 +45,21 @@ class CarePermissions
|
||||
'dashboard.view', 'patients.view', 'lab.view', 'lab.manage',
|
||||
'service_queues.console',
|
||||
],
|
||||
'lab_manager' => [
|
||||
'dashboard.view', 'patients.view', 'lab.view', 'lab.manage',
|
||||
'lab.catalog.manage',
|
||||
'service_queues.console',
|
||||
],
|
||||
'pharmacist' => [
|
||||
'dashboard.view', 'patients.view', 'prescriptions.view', 'prescriptions.dispense',
|
||||
'pharmacy.view', 'pharmacy.manage',
|
||||
'service_queues.console',
|
||||
],
|
||||
'blood_bank_manager' => [
|
||||
'dashboard.view', 'patients.view',
|
||||
'blood_bank.view', 'blood_bank.manage',
|
||||
'service_queues.console',
|
||||
],
|
||||
// Cashiers run the Billing desk (bills / payments). They do not get
|
||||
// Ladill POS app access — see filterAllowedAppSlugs() / DemoWorld.
|
||||
'cashier' => [
|
||||
@@ -67,6 +80,7 @@ class CarePermissions
|
||||
'admin.members.view', 'admin.members.manage',
|
||||
'settings.view', 'settings.manage',
|
||||
'lab.catalog.manage',
|
||||
'blood_bank.view', 'blood_bank.manage',
|
||||
'devices.view', 'devices.manage',
|
||||
'displays.view', 'displays.manage',
|
||||
'audit.view', 'audit.export',
|
||||
@@ -106,7 +120,9 @@ class CarePermissions
|
||||
'doctor',
|
||||
'nurse',
|
||||
'lab_technician',
|
||||
'lab_manager',
|
||||
'pharmacist',
|
||||
'blood_bank_manager',
|
||||
'receptionist',
|
||||
'cashier',
|
||||
], true);
|
||||
|
||||
@@ -282,6 +282,20 @@ final class DemoWorld
|
||||
'apps' => ['care'],
|
||||
'roles' => ['care' => 'lab_technician'],
|
||||
],
|
||||
[
|
||||
'key' => 'lab_manager',
|
||||
'email' => 'demo-pro-lab-manager@ladill.com',
|
||||
'name' => 'Ama Lab Manager (Pro)',
|
||||
'apps' => ['care'],
|
||||
'roles' => ['care' => 'lab_manager'],
|
||||
],
|
||||
[
|
||||
'key' => 'blood_bank_manager',
|
||||
'email' => 'demo-pro-blood-bank-manager@ladill.com',
|
||||
'name' => 'Kofi Blood Bank Manager (Pro)',
|
||||
'apps' => ['care'],
|
||||
'roles' => ['care' => 'blood_bank_manager'],
|
||||
],
|
||||
[
|
||||
'key' => 'cashier',
|
||||
'email' => 'demo-pro-cashier@ladill.com',
|
||||
@@ -370,6 +384,20 @@ final class DemoWorld
|
||||
'apps' => ['care'],
|
||||
'roles' => ['care' => 'lab_technician'],
|
||||
],
|
||||
[
|
||||
'key' => 'lab_manager',
|
||||
'email' => 'demo-enterprise-lab-manager@ladill.com',
|
||||
'name' => 'Ama Lab Manager',
|
||||
'apps' => ['care'],
|
||||
'roles' => ['care' => 'lab_manager'],
|
||||
],
|
||||
[
|
||||
'key' => 'blood_bank_manager',
|
||||
'email' => 'demo-enterprise-blood-bank-manager@ladill.com',
|
||||
'name' => 'Kofi Blood Bank Manager',
|
||||
'apps' => ['care'],
|
||||
'roles' => ['care' => 'blood_bank_manager'],
|
||||
],
|
||||
[
|
||||
'key' => 'cashier',
|
||||
'email' => 'demo-enterprise-cashier@ladill.com',
|
||||
|
||||
@@ -9,7 +9,9 @@ return [
|
||||
'doctor' => 'Doctor',
|
||||
'nurse' => 'Nurse',
|
||||
'lab_technician' => 'Laboratory Technician',
|
||||
'lab_manager' => 'Laboratory Manager',
|
||||
'pharmacist' => 'Pharmacist',
|
||||
'blood_bank_manager' => 'Blood Bank Manager',
|
||||
'cashier' => 'Cashier',
|
||||
'accountant' => 'Accountant',
|
||||
],
|
||||
|
||||
@@ -4,12 +4,15 @@
|
||||
* Specialty practice modules (Settings → Modules).
|
||||
* Pro-gated via plans.*.features specialty_modules.
|
||||
*
|
||||
* Access tiers (RBAC via Care member roles — do not invent new roles):
|
||||
* Access tiers (RBAC via Care member roles):
|
||||
* - general: broad day-to-day access for listed roles (GPs = doctor without specialty desk)
|
||||
* - limited: GPs + nurses (and listed roles); desk specialists only when specialty keywords match
|
||||
* - restricted: specialist doctors (department / specialty keywords) + optional support_roles;
|
||||
* GPs use view_roles / refer_roles; desk specialists only see matching modules
|
||||
*
|
||||
* Prefer existing clinical role slugs on allowlists. Dedicated managers (e.g. blood_bank_manager,
|
||||
* lab_manager) are intentional product roles — add them to the relevant module roles lists.
|
||||
*
|
||||
* Desk specialists (doctor whose practitioner specialty matches specialist_keywords, or who is
|
||||
* assigned to the module department) only see modules relevant to their work — non-matching
|
||||
* modules are access "none" (hidden from sidebar). Nurses / receptionists keep role allowlists.
|
||||
@@ -44,7 +47,7 @@ return [
|
||||
'icon' => 'droplet',
|
||||
'queue_keywords' => ['blood', 'transfusion', 'crossmatch', 'donor'],
|
||||
'access' => 'general',
|
||||
'roles' => ['lab_technician', 'nurse', 'doctor', 'receptionist'],
|
||||
'roles' => ['blood_bank_manager', 'lab_technician', 'nurse', 'doctor', 'receptionist'],
|
||||
'default_on_paid_plans' => true,
|
||||
],
|
||||
'dentistry' => [
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('care_blood_bank_stock', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('owner_ref')->index();
|
||||
$table->foreignId('organization_id')->constrained('care_organizations')->cascadeOnDelete();
|
||||
$table->foreignId('branch_id')->nullable()->constrained('care_branches')->nullOnDelete();
|
||||
$table->string('product_code', 64);
|
||||
$table->string('product_label');
|
||||
$table->unsignedInteger('units_on_hand')->default(0);
|
||||
$table->unsignedInteger('reorder_level')->default(2);
|
||||
$table->text('notes')->nullable();
|
||||
$table->string('updated_by')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(
|
||||
['organization_id', 'branch_id', 'product_code'],
|
||||
'care_bb_stock_org_branch_product_unique',
|
||||
);
|
||||
$table->index(['organization_id', 'branch_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('care_blood_bank_stock');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,120 @@
|
||||
<x-app-layout title="Blood Bank admin">
|
||||
<div class="space-y-6">
|
||||
<x-care.page-hero
|
||||
badge="Blood Bank · Operations · Inventory"
|
||||
title="Blood Bank admin"
|
||||
description="Maintain operational product stock, low-stock thresholds, and jump into clinical Blood Bank work."
|
||||
:stats="[
|
||||
['value' => number_format($overview['total_units']), 'label' => 'Units on hand'],
|
||||
['value' => number_format($overview['low_stock_count']), 'label' => 'Low stock'],
|
||||
['value' => number_format($report['requests_today'] ?? 0), 'label' => 'Requests today'],
|
||||
['value' => number_format($report['high_urgency_open'] ?? 0), 'label' => 'High urgency open'],
|
||||
]">
|
||||
<x-slot name="actions">
|
||||
<a href="{{ route('care.specialty.show', 'blood_bank') }}" class="rounded-lg border border-slate-200 bg-white px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50">Clinical list</a>
|
||||
<a href="{{ route('care.specialty.blood-bank.reports') }}" class="rounded-lg border border-slate-200 bg-white px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50">Reports</a>
|
||||
</x-slot>
|
||||
</x-care.page-hero>
|
||||
|
||||
@if (($canSwitchBranch ?? false) && isset($branches) && $branches->count() > 1)
|
||||
<form method="GET" class="rounded-2xl border border-slate-200 bg-white p-4">
|
||||
<label class="block text-xs font-medium text-slate-600">Branch</label>
|
||||
<select name="branch_id" class="mt-1 rounded-lg border-slate-300 text-sm" onchange="this.form.submit()">
|
||||
@foreach ($branches as $branch)
|
||||
<option value="{{ $branch->id }}" @selected($branchId == $branch->id)>{{ $branch->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</form>
|
||||
@elseif (isset($branches) && $branches->isNotEmpty())
|
||||
<p class="text-sm text-slate-600">Branch: <span class="font-medium text-slate-900">{{ $branches->firstWhere('id', $branchId)?->name ?? $branches->first()->name }}</span></p>
|
||||
@endif
|
||||
|
||||
@if ($overview['low_stock']->isNotEmpty())
|
||||
<div class="rounded-xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-900">
|
||||
{{ $overview['low_stock']->count() }} product(s) at or below reorder level.
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<section class="rounded-2xl border border-slate-200 bg-white p-5">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<h2 class="text-sm font-semibold text-slate-900">Operational inventory</h2>
|
||||
<p class="mt-0.5 text-xs text-slate-500">Branch-level units on hand — separate from visit-scoped clinical inventory notes.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form method="POST" action="{{ route('care.blood-bank.admin.stock.update') }}" class="mt-4 space-y-3">
|
||||
@csrf
|
||||
@if ($branchId > 0)
|
||||
<input type="hidden" name="branch_id" value="{{ $branchId }}">
|
||||
@endif
|
||||
|
||||
<div class="overflow-hidden rounded-xl border border-slate-100">
|
||||
<table class="min-w-full text-sm">
|
||||
<thead class="bg-slate-50 text-left text-xs uppercase text-slate-500">
|
||||
<tr>
|
||||
<th class="px-4 py-3">Product</th>
|
||||
<th class="px-4 py-3">Units on hand</th>
|
||||
<th class="px-4 py-3">Reorder level</th>
|
||||
<th class="px-4 py-3">Notes</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-50">
|
||||
@foreach ($overview['stock'] as $i => $row)
|
||||
<tr @class(['bg-amber-50/60' => $row->isLowStock()])>
|
||||
<td class="px-4 py-3 font-medium text-slate-900">
|
||||
{{ $row->product_label }}
|
||||
@if ($row->isLowStock())
|
||||
<span class="ml-2 text-xs font-semibold text-amber-800">Low</span>
|
||||
@endif
|
||||
<input type="hidden" name="stock[{{ $i }}][product_code]" value="{{ $row->product_code }}">
|
||||
</td>
|
||||
<td class="px-4 py-3">
|
||||
<input type="number" min="0" name="stock[{{ $i }}][units_on_hand]" value="{{ old('stock.'.$i.'.units_on_hand', $row->units_on_hand) }}" class="w-24 rounded-lg border-slate-300 text-sm">
|
||||
</td>
|
||||
<td class="px-4 py-3">
|
||||
<input type="number" min="0" name="stock[{{ $i }}][reorder_level]" value="{{ old('stock.'.$i.'.reorder_level', $row->reorder_level) }}" class="w-24 rounded-lg border-slate-300 text-sm">
|
||||
</td>
|
||||
<td class="px-4 py-3">
|
||||
<input type="text" name="stock[{{ $i }}][notes]" value="{{ old('stock.'.$i.'.notes', $row->notes) }}" class="w-full max-w-xs rounded-lg border-slate-300 text-sm" placeholder="Optional">
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end">
|
||||
<button type="submit" class="btn-primary">Save inventory</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section class="rounded-2xl border border-slate-200 bg-white p-5">
|
||||
<h2 class="text-sm font-semibold text-slate-900">Recent visit inventory notes</h2>
|
||||
<p class="mt-0.5 text-xs text-slate-500">Clinical notes from Blood Bank visits (not the operational register above).</p>
|
||||
<ul class="mt-3 divide-y divide-slate-50 text-sm">
|
||||
@forelse ($overview['recent_notes'] as $note)
|
||||
<li class="flex flex-wrap items-center justify-between gap-2 py-3">
|
||||
<div>
|
||||
<p class="font-medium text-slate-900">
|
||||
{{ $note->visit?->patient?->fullName() ?? 'Visit #'.$note->visit_id }}
|
||||
</p>
|
||||
<p class="text-xs text-slate-500">
|
||||
{{ $note->recorded_at?->format('d M Y H:i') ?? '—' }}
|
||||
@if (! empty($note->payload['low_stock_alert']))
|
||||
· <span class="text-amber-800">Low stock flagged</span>
|
||||
@endif
|
||||
</p>
|
||||
</div>
|
||||
@if ($note->visit_id)
|
||||
<a href="{{ route('care.specialty.workspace', ['module' => 'blood_bank', 'visit' => $note->visit_id, 'tab' => 'inventory']) }}" class="text-sky-600">Open</a>
|
||||
@endif
|
||||
</li>
|
||||
@empty
|
||||
<li class="py-6 text-center text-slate-500">No recent inventory notes.</li>
|
||||
@endforelse
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
@@ -0,0 +1,95 @@
|
||||
<x-app-layout title="Lab admin">
|
||||
<div class="space-y-6">
|
||||
<x-care.page-hero
|
||||
badge="Laboratory · Catalog · Queue ops"
|
||||
title="Lab admin"
|
||||
description="Manage investigation catalog pricing, review open queue load, and jump into laboratory operations."
|
||||
:stats="[
|
||||
['value' => number_format($activeCatalogCount), 'label' => 'Active tests'],
|
||||
['value' => number_format($catalogCount), 'label' => 'Catalog total'],
|
||||
['value' => number_format($openQueue), 'label' => 'Open queue'],
|
||||
['value' => number_format($queueCounts[\App\Models\InvestigationRequest::STATUS_AWAITING_REVIEW] ?? 0), 'label' => 'Awaiting review'],
|
||||
]">
|
||||
<x-slot name="actions">
|
||||
<a href="{{ route('care.lab.catalog.index') }}" class="btn-primary">Manage catalog</a>
|
||||
<a href="{{ route('care.lab.queue.index') }}" class="rounded-lg border border-slate-200 bg-white px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50">Lab queue</a>
|
||||
<a href="{{ route('care.lab.catalog.create') }}" class="rounded-lg border border-slate-200 bg-white px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50">Add test</a>
|
||||
</x-slot>
|
||||
</x-care.page-hero>
|
||||
|
||||
@if (($canSwitchBranch ?? false) && isset($branches) && $branches->count() > 1)
|
||||
<form method="GET" class="rounded-2xl border border-slate-200 bg-white p-4">
|
||||
<label class="block text-xs font-medium text-slate-600">Branch</label>
|
||||
<select name="branch_id" class="mt-1 rounded-lg border-slate-300 text-sm" onchange="this.form.submit()">
|
||||
@foreach ($branches as $branch)
|
||||
<option value="{{ $branch->id }}" @selected($branchId == $branch->id)>{{ $branch->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</form>
|
||||
@elseif (isset($branches) && $branches->isNotEmpty())
|
||||
<p class="text-sm text-slate-600">Branch: <span class="font-medium text-slate-900">{{ $branches->firstWhere('id', $branchId)?->name ?? $branches->first()->name }}</span></p>
|
||||
@endif
|
||||
|
||||
<div class="grid gap-4 lg:grid-cols-2">
|
||||
<section class="rounded-2xl border border-slate-200 bg-white p-5">
|
||||
<h2 class="text-sm font-semibold text-slate-900">Queue by status</h2>
|
||||
<ul class="mt-3 space-y-2 text-sm">
|
||||
@foreach ([
|
||||
\App\Models\InvestigationRequest::STATUS_PENDING,
|
||||
\App\Models\InvestigationRequest::STATUS_SAMPLE_COLLECTED,
|
||||
\App\Models\InvestigationRequest::STATUS_IN_PROGRESS,
|
||||
\App\Models\InvestigationRequest::STATUS_AWAITING_REVIEW,
|
||||
] as $status)
|
||||
<li class="flex justify-between gap-3">
|
||||
<span>{{ $statuses[$status] ?? $status }}</span>
|
||||
<span class="tabular-nums text-slate-600">{{ number_format($queueCounts[$status] ?? 0) }}</span>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
<div class="mt-4">
|
||||
<a href="{{ route('care.lab.queue.index') }}" class="text-sm font-medium text-indigo-600">Open work queue →</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="rounded-2xl border border-slate-200 bg-white p-5">
|
||||
<h2 class="text-sm font-semibold text-slate-900">Catalog management</h2>
|
||||
<p class="mt-1 text-sm text-slate-500">Add or edit investigation types and prices. Technicians process samples from the queue; managers own the catalog.</p>
|
||||
<div class="mt-4 flex flex-wrap gap-2">
|
||||
<a href="{{ route('care.lab.catalog.index') }}" class="rounded-lg bg-indigo-600 px-3 py-2 text-sm font-semibold text-white">Investigation catalog</a>
|
||||
<a href="{{ route('care.lab.catalog.create') }}" class="rounded-lg border border-slate-200 px-3 py-2 text-sm font-medium text-slate-700">Add test</a>
|
||||
<a href="{{ route('care.lab.requests.index') }}" class="rounded-lg border border-slate-200 px-3 py-2 text-sm font-medium text-slate-700">All requests</a>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section class="rounded-2xl border border-slate-200 bg-white p-5">
|
||||
<h2 class="text-sm font-semibold text-slate-900">Current queue snapshot</h2>
|
||||
<div class="mt-3 overflow-hidden rounded-xl border border-slate-100">
|
||||
<table class="min-w-full text-sm">
|
||||
<thead class="bg-slate-50 text-left text-xs uppercase text-slate-500">
|
||||
<tr>
|
||||
<th class="px-4 py-3">Patient</th>
|
||||
<th class="px-4 py-3">Test</th>
|
||||
<th class="px-4 py-3">Status</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-50">
|
||||
@forelse ($recentQueue as $item)
|
||||
<tr>
|
||||
<td class="px-4 py-3 font-medium">{{ $item->patient?->fullName() ?? '—' }}</td>
|
||||
<td class="px-4 py-3">{{ $item->investigationType?->name ?? '—' }}</td>
|
||||
<td class="px-4 py-3">{{ $statuses[$item->status] ?? $item->status }}</td>
|
||||
<td class="px-4 py-3 text-right">
|
||||
<a href="{{ route('care.lab.requests.show', $item) }}" class="text-sky-600">Open</a>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="4" class="px-4 py-8 text-center text-slate-500">No open lab work for this branch.</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
@@ -2,9 +2,12 @@
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 class="text-xl font-semibold text-slate-900">Investigation catalog</h1>
|
||||
<p class="mt-1 text-sm text-slate-500">Admins manage test types and prices. Lab technicians process samples from the laboratory queue.</p>
|
||||
<p class="mt-1 text-sm text-slate-500">Managers and admins set test types and prices. Lab technicians process samples from the laboratory queue.</p>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<a href="{{ route('care.lab.admin.index') }}" class="rounded-lg border border-slate-200 px-4 py-2 text-sm">Lab admin</a>
|
||||
<a href="{{ route('care.lab.catalog.create') }}" class="btn-primary">Add test</a>
|
||||
</div>
|
||||
<a href="{{ route('care.lab.catalog.create') }}" class="btn-primary">Add test</a>
|
||||
</div>
|
||||
<div class="mt-4 overflow-hidden rounded-2xl border border-slate-200 bg-white">
|
||||
<table class="min-w-full text-sm">
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<div class="flex gap-2">
|
||||
<a href="{{ route('care.lab.requests.index') }}" class="rounded-lg border border-slate-200 px-4 py-2 text-sm">All requests</a>
|
||||
@if (app(\App\Services\Care\CarePermissions::class)->can(auth()->user() ? app(\App\Services\Care\OrganizationResolver::class)->memberFor(auth()->user(), $organization) : null, 'lab.catalog.manage'))
|
||||
<a href="{{ route('care.lab.admin.index') }}" class="rounded-lg border border-slate-200 px-4 py-2 text-sm">Lab admin</a>
|
||||
<a href="{{ route('care.lab.catalog.index') }}" class="rounded-lg border border-slate-200 px-4 py-2 text-sm">Catalog</a>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@@ -127,12 +127,22 @@
|
||||
</a>
|
||||
</li>
|
||||
@if (! empty($hasPaidPlan) && ($canManageLabCatalog ?? false))
|
||||
<li>
|
||||
<a href="{{ route('care.lab.admin.index') }}"
|
||||
class="flex items-center justify-between rounded-xl border border-slate-100 bg-slate-50 px-4 py-3 text-sm text-slate-700 hover:text-indigo-700">
|
||||
<span>
|
||||
Laboratory admin
|
||||
<span class="mt-0.5 block text-xs text-slate-500">Queue overview, catalog entry points, and lab ops</span>
|
||||
</span>
|
||||
<span class="text-slate-400">→</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ route('care.lab.catalog.index') }}"
|
||||
class="flex items-center justify-between rounded-xl border border-slate-100 bg-slate-50 px-4 py-3 text-sm text-slate-700 hover:text-indigo-700">
|
||||
<span>
|
||||
Laboratory catalog
|
||||
<span class="mt-0.5 block text-xs text-slate-500">Investigation types and lab test prices (admins only)</span>
|
||||
<span class="mt-0.5 block text-xs text-slate-500">Investigation types and lab test prices</span>
|
||||
</span>
|
||||
<span class="text-slate-400">→</span>
|
||||
</a>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
$inventoryPayload = $bloodBankInventory?->payload ?? [];
|
||||
$currentStage = $workspaceVisit->specialty_stage;
|
||||
$stageFlow = $bloodBankStageFlow ?? [];
|
||||
$canManage = $canConsult ?? false;
|
||||
$canManage = $canAdvanceStage ?? $canConsult ?? false;
|
||||
$urgency = (string) ($payload['urgency'] ?? '');
|
||||
$isHighUrgency = str_contains(strtolower($urgency), 'urgent')
|
||||
|| str_contains(strtolower($urgency), 'emergency')
|
||||
|
||||
@@ -25,6 +25,14 @@
|
||||
@endif
|
||||
@if ($moduleKey === 'blood_bank')
|
||||
<a href="{{ route('care.specialty.blood-bank.reports') }}" class="text-slate-600 hover:text-slate-900">Reports</a>
|
||||
@php
|
||||
$bbAdminMember = auth()->user()
|
||||
? app(\App\Services\Care\OrganizationResolver::class)->memberFor(auth()->user(), $organization)
|
||||
: null;
|
||||
@endphp
|
||||
@if (app(\App\Services\Care\CarePermissions::class)->can($bbAdminMember, 'blood_bank.manage'))
|
||||
<a href="{{ route('care.blood-bank.admin.index') }}" class="text-slate-600 hover:text-slate-900">Admin</a>
|
||||
@endif
|
||||
@endif
|
||||
<a href="{{ route('care.specialty.history', $moduleKey) }}" class="text-slate-600 hover:text-slate-900">History</a>
|
||||
@if ($canManageClinical ?? $canManageSpecialty ?? true)
|
||||
|
||||
@@ -103,8 +103,14 @@
|
||||
|
||||
$adminNav = [];
|
||||
if (! empty($hasPaidPlan) && $permissions->can($member, 'lab.catalog.manage')) {
|
||||
$adminNav[] = ['name' => 'Lab catalog', 'route' => route('care.lab.catalog.index'), 'active' => request()->routeIs('care.lab.catalog.*'),
|
||||
$adminNav[] = ['name' => 'Lab admin', 'route' => route('care.lab.admin.index'), 'active' => request()->routeIs('care.lab.admin.*'),
|
||||
'icon' => '<path stroke-linecap="round" stroke-linejoin="round" d="M9.75 3.104v5.714a2.25 2.25 0 0 1-.659 1.591L5 14.5M9.75 3.104c-.251.023-.501.05-.75.082m.75-.082a24.301 24.301 0 0 1 4.5 0m0 0v5.714a2.25 2.25 0 0 0 .659 1.591L19 14.5M14.25 3.104c.251.023.501.05.75.082M19 14.5l-2.47 2.47a2.25 2.25 0 0 1-1.59.659H9.06a2.25 2.25 0 0 1-1.591-.659L5 14.5m14 0V17a2.25 2.25 0 0 1-2.25 2.25H7.25A2.25 2.25 0 0 1 5 17v-2.5" />'];
|
||||
$adminNav[] = ['name' => 'Lab catalog', 'route' => route('care.lab.catalog.index'), 'active' => request()->routeIs('care.lab.catalog.*'),
|
||||
'icon' => '<path stroke-linecap="round" stroke-linejoin="round" d="M10.5 6h9.75M10.5 6a1.5 1.5 0 1 1-3 0m3 0a1.5 1.5 0 1 0-3 0M3.75 6H7.5m3 12h9.75m-9.75 0a1.5 1.5 0 0 1-3 0m3 0a1.5 1.5 0 0 0-3 0m-3.75 0H7.5m9-6h3.75m-3.75 0a1.5 1.5 0 0 1-3 0m3 0a1.5 1.5 0 0 0-3 0m-9.75 0h9.75" />'];
|
||||
}
|
||||
if (! empty($hasPaidPlan) && $permissions->can($member, 'blood_bank.manage')) {
|
||||
$adminNav[] = ['name' => 'Blood Bank admin', 'route' => route('care.blood-bank.admin.index'), 'active' => request()->routeIs('care.blood-bank.admin.*'),
|
||||
'icon' => '<path stroke-linecap="round" stroke-linejoin="round" d="M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12Z" />'];
|
||||
}
|
||||
if ($permissions->can($member, 'admin.departments.view')) {
|
||||
$adminNav[] = ['name' => 'Departments', 'route' => route('care.departments.index'), 'active' => request()->routeIs('care.departments.*'),
|
||||
|
||||
@@ -37,7 +37,9 @@ use App\Http\Controllers\Care\SettingsController;
|
||||
use App\Http\Controllers\Care\SettingsGpPricingController;
|
||||
use App\Http\Controllers\Care\SettingsModulesController;
|
||||
use App\Http\Controllers\Care\DentistryWorkspaceController;
|
||||
use App\Http\Controllers\Care\BloodBankAdminController;
|
||||
use App\Http\Controllers\Care\BloodBankWorkspaceController;
|
||||
use App\Http\Controllers\Care\LabAdminController;
|
||||
use App\Http\Controllers\Care\EmergencyWorkspaceController;
|
||||
use App\Http\Controllers\Care\SpecialtyModuleController;
|
||||
use App\Http\Controllers\Care\VisitWorkflowController;
|
||||
@@ -158,6 +160,7 @@ Route::middleware(['auth', 'platform.session'])->group(function () {
|
||||
Route::post('/specialty/{module}/call-next', [SpecialtyModuleController::class, 'callNext'])->name('care.specialty.call-next');
|
||||
Route::post('/specialty/{module}/refer', [SpecialtyModuleController::class, 'refer'])->name('care.specialty.refer');
|
||||
|
||||
Route::get('/lab/admin', [LabAdminController::class, 'index'])->name('care.lab.admin.index');
|
||||
Route::get('/lab/requests', [InvestigationController::class, 'index'])->name('care.lab.requests.index');
|
||||
Route::get('/lab/queue', [InvestigationController::class, 'queue'])->name('care.lab.queue.index');
|
||||
Route::post('/lab/queue/call-next', [InvestigationController::class, 'callNext'])->name('care.lab.queue.call-next');
|
||||
@@ -177,6 +180,9 @@ Route::middleware(['auth', 'platform.session'])->group(function () {
|
||||
Route::get('/lab/catalog/{investigationType}/edit', [InvestigationTypeController::class, 'edit'])->name('care.lab.catalog.edit');
|
||||
Route::put('/lab/catalog/{investigationType}', [InvestigationTypeController::class, 'update'])->name('care.lab.catalog.update');
|
||||
|
||||
Route::get('/blood-bank/admin', [BloodBankAdminController::class, 'index'])->name('care.blood-bank.admin.index');
|
||||
Route::post('/blood-bank/admin/stock', [BloodBankAdminController::class, 'updateStock'])->name('care.blood-bank.admin.stock.update');
|
||||
|
||||
Route::get('/prescriptions', [PrescriptionController::class, 'index'])->name('care.prescriptions.index');
|
||||
Route::get('/prescriptions/queue', [PrescriptionController::class, 'queue'])->name('care.prescriptions.queue');
|
||||
Route::post('/prescriptions/queue/call-next', [PrescriptionController::class, 'callNext'])->name('care.prescriptions.call-next');
|
||||
|
||||
@@ -295,4 +295,82 @@ class CareBloodBankSuiteTest extends TestCase
|
||||
->assertSee('Blood Bank summary')
|
||||
->assertSee($this->patient->fullName());
|
||||
}
|
||||
|
||||
public function test_blood_bank_manager_can_manage_admin_inventory(): void
|
||||
{
|
||||
Member::query()->where('user_ref', $this->owner->public_id)->update([
|
||||
'role' => 'blood_bank_manager',
|
||||
'branch_id' => $this->branch->id,
|
||||
]);
|
||||
|
||||
$this->actingAs($this->owner)
|
||||
->get(route('care.blood-bank.admin.index', ['branch_id' => $this->branch->id]))
|
||||
->assertOk()
|
||||
->assertSee('Blood Bank admin')
|
||||
->assertSee('Operational inventory');
|
||||
|
||||
$this->actingAs($this->owner)
|
||||
->post(route('care.blood-bank.admin.stock.update'), [
|
||||
'branch_id' => $this->branch->id,
|
||||
'stock' => [
|
||||
[
|
||||
'product_code' => 'packed_rbc',
|
||||
'units_on_hand' => 12,
|
||||
'reorder_level' => 3,
|
||||
'notes' => 'Restocked',
|
||||
],
|
||||
[
|
||||
'product_code' => 'whole_blood',
|
||||
'units_on_hand' => 1,
|
||||
'reorder_level' => 2,
|
||||
'notes' => null,
|
||||
],
|
||||
[
|
||||
'product_code' => 'platelets',
|
||||
'units_on_hand' => 4,
|
||||
'reorder_level' => 2,
|
||||
],
|
||||
[
|
||||
'product_code' => 'ffp',
|
||||
'units_on_hand' => 5,
|
||||
'reorder_level' => 2,
|
||||
],
|
||||
[
|
||||
'product_code' => 'cryo',
|
||||
'units_on_hand' => 2,
|
||||
'reorder_level' => 1,
|
||||
],
|
||||
],
|
||||
])
|
||||
->assertRedirect();
|
||||
|
||||
$this->assertDatabaseHas('care_blood_bank_stock', [
|
||||
'organization_id' => $this->organization->id,
|
||||
'branch_id' => $this->branch->id,
|
||||
'product_code' => 'packed_rbc',
|
||||
'units_on_hand' => 12,
|
||||
'reorder_level' => 3,
|
||||
]);
|
||||
|
||||
$this->actingAs($this->owner)
|
||||
->get(route('care.specialty.show', 'blood_bank'))
|
||||
->assertOk();
|
||||
|
||||
$this->actingAs($this->owner)
|
||||
->get(route('care.specialty.blood-bank.reports'))
|
||||
->assertOk()
|
||||
->assertSee('Blood Bank reports');
|
||||
}
|
||||
|
||||
public function test_lab_technician_cannot_access_blood_bank_admin(): void
|
||||
{
|
||||
Member::query()->where('user_ref', $this->owner->public_id)->update([
|
||||
'role' => 'lab_technician',
|
||||
'branch_id' => $this->branch->id,
|
||||
]);
|
||||
|
||||
$this->actingAs($this->owner)
|
||||
->get(route('care.blood-bank.admin.index'))
|
||||
->assertForbidden();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,6 +286,50 @@ class CareLabTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_lab_manager_can_access_admin_and_catalog(): void
|
||||
{
|
||||
Member::where('user_ref', $this->user->public_id)->update([
|
||||
'role' => 'lab_manager',
|
||||
'branch_id' => $this->branch->id,
|
||||
]);
|
||||
|
||||
$this->actingAs($this->user)
|
||||
->get(route('care.lab.admin.index', ['branch_id' => $this->branch->id]))
|
||||
->assertOk()
|
||||
->assertSee('Lab admin')
|
||||
->assertSee('Manage catalog');
|
||||
|
||||
$this->actingAs($this->user)
|
||||
->get(route('care.lab.catalog.index'))
|
||||
->assertOk()
|
||||
->assertSee('Investigation catalog');
|
||||
|
||||
$this->actingAs($this->user)
|
||||
->post(route('care.lab.catalog.store'), [
|
||||
'name' => 'Manager Panel',
|
||||
'code' => 'MGR',
|
||||
'category' => 'blood',
|
||||
'price_minor' => 2200,
|
||||
'is_active' => true,
|
||||
])
|
||||
->assertRedirect(route('care.lab.catalog.index'));
|
||||
|
||||
$this->assertDatabaseHas('care_investigation_types', [
|
||||
'organization_id' => $this->organization->id,
|
||||
'name' => 'Manager Panel',
|
||||
'price_minor' => 2200,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_lab_technician_cannot_access_lab_admin(): void
|
||||
{
|
||||
Member::where('user_ref', $this->user->public_id)->update(['role' => 'lab_technician']);
|
||||
|
||||
$this->actingAs($this->user)
|
||||
->get(route('care.lab.admin.index'))
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_api_can_request_investigation(): void
|
||||
{
|
||||
Sanctum::actingAs($this->user);
|
||||
|
||||
Reference in New Issue
Block a user