Replace Maternity with Women's Health (OB/GYN) and configurable service lines.
Deploy Ladill Care / deploy (push) Successful in 26s
Deploy Ladill Care / deploy (push) Successful in 26s
Keeps Fertility as a separate specialty, adds OB/GYN and fertility staff roles, and migrates live org settings from maternity → womens_health. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -47,6 +47,7 @@ class SettingsModulesController extends Controller
|
||||
CarePricingService $pricing,
|
||||
): View {
|
||||
$this->authorizeAbility($request, 'settings.view');
|
||||
$module = $modules->normalizeKey($module);
|
||||
$definition = $modules->definition($module);
|
||||
abort_unless($definition, 404);
|
||||
|
||||
@@ -69,6 +70,8 @@ class SettingsModulesController extends Controller
|
||||
'moduleKey' => $module,
|
||||
'definition' => $definition,
|
||||
'services' => $services,
|
||||
'serviceLines' => $modules->serviceLines($module),
|
||||
'enabledServiceLines' => $modules->enabledServiceLines($organization, $module),
|
||||
'enabled' => $modules->isEnabled($organization, $module),
|
||||
'canManage' => $canManage && $canUse,
|
||||
'canUseSpecialtyModules' => $canUse,
|
||||
@@ -77,6 +80,36 @@ class SettingsModulesController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateServiceLines(
|
||||
Request $request,
|
||||
string $module,
|
||||
SpecialtyModuleService $modules,
|
||||
): RedirectResponse {
|
||||
$this->authorizeAbility($request, 'settings.manage');
|
||||
$organization = $this->organization($request);
|
||||
abort_unless($modules->definition($module), 404);
|
||||
abort_unless($modules->canManage($organization), 403);
|
||||
abort_unless($modules->serviceLines($module) !== [], 404);
|
||||
|
||||
$lines = $modules->serviceLines($module);
|
||||
$rules = ['lines' => ['required', 'array']];
|
||||
foreach (array_keys($lines) as $key) {
|
||||
$rules["lines.{$key}"] = ['nullable', 'boolean'];
|
||||
}
|
||||
$validated = $request->validate($rules);
|
||||
|
||||
$desired = [];
|
||||
foreach (array_keys($lines) as $key) {
|
||||
$desired[$key] = (bool) ($validated['lines'][$key] ?? false);
|
||||
}
|
||||
|
||||
$modules->syncServiceLines($organization, $module, $desired);
|
||||
|
||||
return redirect()
|
||||
->route('care.settings.modules.show', $module)
|
||||
->with('success', 'Service lines saved.');
|
||||
}
|
||||
|
||||
public function updateServices(
|
||||
Request $request,
|
||||
string $module,
|
||||
|
||||
@@ -155,7 +155,7 @@ class SpecialtyModuleController extends Controller
|
||||
'blood_bank' => 'requests',
|
||||
'ophthalmology' => 'refraction',
|
||||
'physiotherapy' => 'assessment',
|
||||
'maternity' => 'history',
|
||||
'womens_health' => 'history',
|
||||
'radiology' => 'protocol',
|
||||
'cardiology' => 'history',
|
||||
'psychiatry' => 'history',
|
||||
@@ -246,7 +246,7 @@ class SpecialtyModuleController extends Controller
|
||||
'blood_bank' => 'requests',
|
||||
'ophthalmology' => 'refraction',
|
||||
'physiotherapy' => 'assessment',
|
||||
'maternity' => 'history',
|
||||
'womens_health' => 'history',
|
||||
'radiology' => 'protocol',
|
||||
'cardiology' => 'history',
|
||||
'psychiatry' => 'history',
|
||||
@@ -495,14 +495,14 @@ class SpecialtyModuleController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
if ($module === 'maternity' && in_array($recordType, ['anc_history', 'obstetric_exam', 'fetal_notes', 'mat_investigation', 'mat_plan'], true)) {
|
||||
$workflow = app(\App\Services\Care\Maternity\MaternityWorkflowService::class);
|
||||
if ($module === 'womens_health' && in_array($recordType, ['anc_history', 'obstetric_exam', 'fetal_notes', 'mat_investigation', 'mat_plan'], true)) {
|
||||
$workflow = app(\App\Services\Care\WomensHealth\WomensHealthWorkflowService::class);
|
||||
$stageService = app(\App\Services\Care\SpecialtyVisitStageService::class);
|
||||
$suggested = match ($recordType) {
|
||||
'anc_history' => $workflow->stageFromHistory($record->payload ?? []),
|
||||
'obstetric_exam' => $workflow->stageFromExam($record->payload ?? []),
|
||||
'fetal_notes' => $workflow->stageFromFetal($record->payload ?? []),
|
||||
'mat_investigation' => \App\Services\Care\Maternity\MaternityWorkflowService::STAGE_INVESTIGATION,
|
||||
'mat_investigation' => \App\Services\Care\WomensHealth\WomensHealthWorkflowService::STAGE_INVESTIGATION,
|
||||
'mat_plan' => $workflow->stageFromPlan($record->payload ?? []),
|
||||
default => null,
|
||||
};
|
||||
@@ -522,7 +522,7 @@ class SpecialtyModuleController extends Controller
|
||||
$stageService->setStage(
|
||||
$organization,
|
||||
$visit,
|
||||
'maternity',
|
||||
'womens_health',
|
||||
$suggested,
|
||||
$this->ownerRef($request),
|
||||
$this->ownerRef($request),
|
||||
@@ -534,7 +534,7 @@ class SpecialtyModuleController extends Controller
|
||||
$stageService->setStage(
|
||||
$organization,
|
||||
$visit,
|
||||
'maternity',
|
||||
'womens_health',
|
||||
$suggested,
|
||||
$this->ownerRef($request),
|
||||
$this->ownerRef($request),
|
||||
@@ -1424,6 +1424,7 @@ class SpecialtyModuleController extends Controller
|
||||
CareQueueBridge $queueBridge,
|
||||
?Visit $visit = null,
|
||||
): View {
|
||||
$module = $modules->normalizeKey($module);
|
||||
$definition = $modules->definition($module);
|
||||
abort_unless($definition, 404);
|
||||
|
||||
@@ -1849,15 +1850,15 @@ class SpecialtyModuleController extends Controller
|
||||
$physiotherapyStageFlow = app(\App\Services\Care\Physiotherapy\PhysiotherapyWorkflowService::class)->stageFlow();
|
||||
}
|
||||
|
||||
if ($module === 'maternity') {
|
||||
$maternityHistory = $clinical->findForVisit($workspaceVisit, 'maternity', 'anc_history');
|
||||
$maternityExam = $clinical->findForVisit($workspaceVisit, 'maternity', 'obstetric_exam');
|
||||
$maternityFetal = $clinical->findForVisit($workspaceVisit, 'maternity', 'fetal_notes');
|
||||
$maternityInvestigation = $clinical->findForVisit($workspaceVisit, 'maternity', 'mat_investigation');
|
||||
$maternityPlan = $clinical->findForVisit($workspaceVisit, 'maternity', 'mat_plan');
|
||||
$maternityPostnatal = $clinical->findForVisit($workspaceVisit, 'maternity', 'postnatal_note');
|
||||
$maternityStageCodes = collect($shell->stages('maternity'))->pluck('code')->all();
|
||||
$maternityStageFlow = app(\App\Services\Care\Maternity\MaternityWorkflowService::class)->stageFlow();
|
||||
if ($module === 'womens_health') {
|
||||
$maternityHistory = $clinical->findForVisit($workspaceVisit, 'womens_health', 'anc_history');
|
||||
$maternityExam = $clinical->findForVisit($workspaceVisit, 'womens_health', 'obstetric_exam');
|
||||
$maternityFetal = $clinical->findForVisit($workspaceVisit, 'womens_health', 'fetal_notes');
|
||||
$maternityInvestigation = $clinical->findForVisit($workspaceVisit, 'womens_health', 'mat_investigation');
|
||||
$maternityPlan = $clinical->findForVisit($workspaceVisit, 'womens_health', 'mat_plan');
|
||||
$maternityPostnatal = $clinical->findForVisit($workspaceVisit, 'womens_health', 'postnatal_note');
|
||||
$maternityStageCodes = collect($shell->stages('womens_health'))->pluck('code')->all();
|
||||
$maternityStageFlow = app(\App\Services\Care\WomensHealth\WomensHealthWorkflowService::class)->stageFlow();
|
||||
}
|
||||
|
||||
if ($module === 'radiology') {
|
||||
|
||||
+36
-36
@@ -6,8 +6,8 @@ use App\Http\Controllers\Care\Concerns\ScopesToAccount;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\SpecialtyClinicalRecord;
|
||||
use App\Models\Visit;
|
||||
use App\Services\Care\Maternity\MaternityAnalyticsService;
|
||||
use App\Services\Care\Maternity\MaternityWorkflowService;
|
||||
use App\Services\Care\WomensHealth\WomensHealthAnalyticsService;
|
||||
use App\Services\Care\WomensHealth\WomensHealthWorkflowService;
|
||||
use App\Services\Care\SpecialtyClinicalRecordService;
|
||||
use App\Services\Care\SpecialtyModuleService;
|
||||
use App\Services\Care\SpecialtyShellService;
|
||||
@@ -16,20 +16,20 @@ use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class MaternityWorkspaceController extends Controller
|
||||
class WomensHealthWorkspaceController extends Controller
|
||||
{
|
||||
use ScopesToAccount;
|
||||
|
||||
protected function assertMaternityAccess(Request $request, SpecialtyModuleService $modules): void
|
||||
protected function assertWomensHealthAccess(Request $request, SpecialtyModuleService $modules): void
|
||||
{
|
||||
$organization = $this->organization($request);
|
||||
abort_unless($modules->memberCanAccess($organization, $this->member($request), 'maternity'), 403);
|
||||
abort_unless($modules->memberCanAccess($organization, $this->member($request), 'womens_health'), 403);
|
||||
}
|
||||
|
||||
protected function assertMaternityManage(Request $request, SpecialtyModuleService $modules): void
|
||||
protected function assertWomensHealthManage(Request $request, SpecialtyModuleService $modules): void
|
||||
{
|
||||
$organization = $this->organization($request);
|
||||
abort_unless($modules->memberCanManage($organization, $this->member($request), 'maternity'), 403);
|
||||
abort_unless($modules->memberCanManage($organization, $this->member($request), 'womens_health'), 403);
|
||||
}
|
||||
|
||||
protected function assertVisit(Request $request, Visit $visit): void
|
||||
@@ -46,7 +46,7 @@ class MaternityWorkspaceController extends Controller
|
||||
SpecialtyShellService $shell,
|
||||
): RedirectResponse {
|
||||
$this->authorizeAbility($request, 'consultations.manage');
|
||||
$this->assertMaternityManage($request, $modules);
|
||||
$this->assertWomensHealthManage($request, $modules);
|
||||
$this->assertVisit($request, $visit);
|
||||
|
||||
$validated = $request->validate([
|
||||
@@ -57,7 +57,7 @@ class MaternityWorkspaceController extends Controller
|
||||
$stages->setStage(
|
||||
$this->organization($request),
|
||||
$visit,
|
||||
'maternity',
|
||||
'womens_health',
|
||||
$validated['stage'],
|
||||
$this->ownerRef($request),
|
||||
$this->actorRef($request),
|
||||
@@ -68,9 +68,9 @@ class MaternityWorkspaceController extends Controller
|
||||
|
||||
return redirect()
|
||||
->route('care.specialty.workspace', [
|
||||
'module' => 'maternity',
|
||||
'module' => 'womens_health',
|
||||
'visit' => $visit,
|
||||
'tab' => $shell->workspaceTabForStage('maternity', $validated['stage']),
|
||||
'tab' => $shell->workspaceTabForStage('womens_health', $validated['stage']),
|
||||
])
|
||||
->with('success', 'Visit stage updated.');
|
||||
}
|
||||
@@ -81,17 +81,17 @@ class MaternityWorkspaceController extends Controller
|
||||
SpecialtyModuleService $modules,
|
||||
SpecialtyClinicalRecordService $clinical,
|
||||
SpecialtyVisitStageService $stages,
|
||||
MaternityWorkflowService $workflow,
|
||||
WomensHealthWorkflowService $workflow,
|
||||
): RedirectResponse {
|
||||
$this->authorizeAbility($request, 'consultations.manage');
|
||||
$this->assertMaternityManage($request, $modules);
|
||||
$this->assertWomensHealthManage($request, $modules);
|
||||
$this->assertVisit($request, $visit);
|
||||
|
||||
$organization = $this->organization($request);
|
||||
$owner = $this->ownerRef($request);
|
||||
|
||||
$payload = (array) $request->input('payload', []);
|
||||
foreach ($clinical->fieldsFor('maternity', 'postnatal_note') as $field) {
|
||||
foreach ($clinical->fieldsFor('womens_health', 'postnatal_note') as $field) {
|
||||
if (($field['type'] ?? '') === 'boolean') {
|
||||
$payload[$field['name']] = $request->boolean('payload.'.$field['name']);
|
||||
}
|
||||
@@ -100,17 +100,17 @@ class MaternityWorkspaceController extends Controller
|
||||
|
||||
$validated = $request->validate(array_merge([
|
||||
'tab' => ['required', 'string'],
|
||||
], $clinical->validationRules('maternity', 'postnatal_note')));
|
||||
], $clinical->validationRules('womens_health', 'postnatal_note')));
|
||||
|
||||
$record = $clinical->upsert(
|
||||
$organization,
|
||||
$visit,
|
||||
'maternity',
|
||||
'womens_health',
|
||||
'postnatal_note',
|
||||
$clinical->payloadFromRequest($validated),
|
||||
$owner,
|
||||
$owner,
|
||||
MaternityWorkflowService::STAGE_POSTNATAL,
|
||||
WomensHealthWorkflowService::STAGE_POSTNATAL,
|
||||
SpecialtyClinicalRecord::STATUS_COMPLETED,
|
||||
);
|
||||
|
||||
@@ -118,8 +118,8 @@ class MaternityWorkspaceController extends Controller
|
||||
$stages->setStage(
|
||||
$organization,
|
||||
$visit,
|
||||
'maternity',
|
||||
MaternityWorkflowService::STAGE_POSTNATAL,
|
||||
'womens_health',
|
||||
WomensHealthWorkflowService::STAGE_POSTNATAL,
|
||||
$owner,
|
||||
$owner,
|
||||
);
|
||||
@@ -131,8 +131,8 @@ class MaternityWorkspaceController extends Controller
|
||||
$stages->setStage(
|
||||
$organization,
|
||||
$visit,
|
||||
'maternity',
|
||||
MaternityWorkflowService::STAGE_COMPLETED,
|
||||
'womens_health',
|
||||
WomensHealthWorkflowService::STAGE_COMPLETED,
|
||||
$owner,
|
||||
$owner,
|
||||
);
|
||||
@@ -157,7 +157,7 @@ class MaternityWorkspaceController extends Controller
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->route('care.specialty.workspace', ['module' => 'maternity', 'visit' => $visit, 'tab' => 'postnatal'])
|
||||
->route('care.specialty.workspace', ['module' => 'womens_health', 'visit' => $visit, 'tab' => 'postnatal'])
|
||||
->with('success', 'Delivery / postnatal note saved.');
|
||||
}
|
||||
|
||||
@@ -165,10 +165,10 @@ class MaternityWorkspaceController extends Controller
|
||||
Request $request,
|
||||
SpecialtyModuleService $modules,
|
||||
SpecialtyShellService $shell,
|
||||
MaternityAnalyticsService $analytics,
|
||||
WomensHealthAnalyticsService $analytics,
|
||||
): View {
|
||||
$this->authorizeAbility($request, 'consultations.view');
|
||||
$this->assertMaternityAccess($request, $modules);
|
||||
$this->assertWomensHealthAccess($request, $modules);
|
||||
|
||||
$organization = $this->organization($request);
|
||||
$branchScope = app(\App\Services\Care\OrganizationResolver::class)->branchScope($this->member($request));
|
||||
@@ -181,10 +181,10 @@ class MaternityWorkspaceController extends Controller
|
||||
$request->query('to'),
|
||||
);
|
||||
|
||||
return view('care.specialty.maternity.reports', [
|
||||
'moduleKey' => 'maternity',
|
||||
'definition' => $modules->definition('maternity'),
|
||||
'shellNav' => $shell->navItems('maternity'),
|
||||
return view('care.specialty.womens_health.reports', [
|
||||
'moduleKey' => 'womens_health',
|
||||
'definition' => $modules->definition('womens_health'),
|
||||
'shellNav' => $shell->navItems('womens_health'),
|
||||
'report' => $report,
|
||||
'currency' => strtoupper((string) config('care.billing.currency', config('care.currency', 'GHS'))),
|
||||
]);
|
||||
@@ -197,20 +197,20 @@ class MaternityWorkspaceController extends Controller
|
||||
SpecialtyClinicalRecordService $clinical,
|
||||
): View {
|
||||
$this->authorizeAbility($request, 'consultations.view');
|
||||
$this->assertMaternityAccess($request, $modules);
|
||||
$this->assertWomensHealthAccess($request, $modules);
|
||||
$this->assertVisit($request, $visit);
|
||||
|
||||
$visit->loadMissing(['patient', 'appointment.practitioner', 'branch']);
|
||||
|
||||
return view('care.specialty.maternity.print', [
|
||||
return view('care.specialty.womens_health.print', [
|
||||
'visit' => $visit,
|
||||
'patient' => $visit->patient,
|
||||
'history' => $clinical->findForVisit($visit, 'maternity', 'anc_history'),
|
||||
'exam' => $clinical->findForVisit($visit, 'maternity', 'obstetric_exam'),
|
||||
'fetal' => $clinical->findForVisit($visit, 'maternity', 'fetal_notes'),
|
||||
'investigation' => $clinical->findForVisit($visit, 'maternity', 'mat_investigation'),
|
||||
'plan' => $clinical->findForVisit($visit, 'maternity', 'mat_plan'),
|
||||
'postnatal' => $clinical->findForVisit($visit, 'maternity', 'postnatal_note'),
|
||||
'history' => $clinical->findForVisit($visit, 'womens_health', 'anc_history'),
|
||||
'exam' => $clinical->findForVisit($visit, 'womens_health', 'obstetric_exam'),
|
||||
'fetal' => $clinical->findForVisit($visit, 'womens_health', 'fetal_notes'),
|
||||
'investigation' => $clinical->findForVisit($visit, 'womens_health', 'mat_investigation'),
|
||||
'plan' => $clinical->findForVisit($visit, 'womens_health', 'mat_plan'),
|
||||
'postnatal' => $clinical->findForVisit($visit, 'womens_health', 'postnatal_note'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,11 @@ class CarePermissions
|
||||
'dentist' => ['dentistry'],
|
||||
'psychiatrist' => ['psychiatry'],
|
||||
'physiotherapist' => ['physiotherapy'],
|
||||
'midwife' => ['maternity'],
|
||||
'midwife' => ['womens_health'],
|
||||
'obstetrician' => ['womens_health'],
|
||||
'gynecologist' => ['womens_health'],
|
||||
'obgyn' => ['womens_health'],
|
||||
'labour_ward_nurse' => ['womens_health'],
|
||||
'pediatrician' => ['pediatrics'],
|
||||
'oncologist' => ['oncology', 'infusion'],
|
||||
'cardiologist' => ['cardiology'],
|
||||
@@ -70,6 +74,8 @@ class CarePermissions
|
||||
'orthopedist' => ['orthopedics'],
|
||||
'podiatrist' => ['podiatry'],
|
||||
'fertility_specialist' => ['fertility'],
|
||||
'embryologist' => ['fertility'],
|
||||
'fertility_nurse' => ['fertility'],
|
||||
'dialysis_nurse' => ['renal'],
|
||||
'ambulance_staff' => ['ambulance', 'emergency'],
|
||||
'receptionist' => [], // refer only — see roleReferApps
|
||||
@@ -77,7 +83,7 @@ class CarePermissions
|
||||
'cashier' => [],
|
||||
'accountant' => [],
|
||||
'department_manager' => null, // department analytics — all enabled modules view
|
||||
'nurse' => ['vaccination', 'child_welfare', 'infusion', 'maternity'],
|
||||
'nurse' => ['vaccination', 'child_welfare', 'infusion', 'womens_health'],
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -88,21 +94,25 @@ class CarePermissions
|
||||
*/
|
||||
protected array $roleReferApps = [
|
||||
'general_physician' => [
|
||||
'dentistry', 'physiotherapy', 'maternity', 'psychiatry', 'orthopedics',
|
||||
'dentistry', 'physiotherapy', 'womens_health', 'psychiatry', 'orthopedics',
|
||||
'oncology', 'renal', 'surgery', 'radiology', 'pathology', 'blood_bank',
|
||||
'infusion', 'podiatry', 'fertility', 'ambulance',
|
||||
],
|
||||
'doctor' => [
|
||||
'dentistry', 'physiotherapy', 'maternity', 'psychiatry', 'orthopedics',
|
||||
'dentistry', 'physiotherapy', 'womens_health', 'psychiatry', 'orthopedics',
|
||||
'oncology', 'renal', 'surgery', 'radiology', 'pathology', 'blood_bank',
|
||||
'infusion', 'podiatry', 'fertility', 'ambulance',
|
||||
],
|
||||
'nurse' => ['emergency', 'pediatrics', 'blood_bank'],
|
||||
'pharmacist' => ['oncology', 'infusion', 'maternity', 'emergency'],
|
||||
'pharmacist' => ['oncology', 'infusion', 'womens_health', 'emergency'],
|
||||
'receptionist' => [
|
||||
'emergency', 'pediatrics', 'vaccination', 'child_welfare', 'dentistry',
|
||||
'maternity', 'ambulance', 'ophthalmology', 'physiotherapy',
|
||||
'womens_health', 'ambulance', 'ophthalmology', 'physiotherapy',
|
||||
],
|
||||
'obstetrician' => ['fertility'],
|
||||
'gynecologist' => ['fertility'],
|
||||
'obgyn' => ['fertility'],
|
||||
'midwife' => ['fertility'],
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -115,7 +125,7 @@ class CarePermissions
|
||||
'lab_technician' => ['radiology'],
|
||||
'lab_manager' => ['radiology'],
|
||||
'pathologist' => ['blood_bank'],
|
||||
'pharmacist' => ['oncology', 'infusion', 'maternity', 'emergency'],
|
||||
'pharmacist' => ['oncology', 'infusion', 'womens_health', 'emergency'],
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -284,7 +294,45 @@ class CarePermissions
|
||||
'consultations.view', 'consultations.manage',
|
||||
'vitals.manage',
|
||||
'assessments.view', 'assessments.capture', 'assessments.manage',
|
||||
'maternity.view', 'maternity.manage',
|
||||
'womens_health.view', 'womens_health.manage',
|
||||
'service_queues.console',
|
||||
],
|
||||
'obstetrician' => [
|
||||
'dashboard.view', 'patients.view', 'appointments.view',
|
||||
'consultations.view', 'consultations.manage',
|
||||
'investigations.request', 'prescriptions.manage',
|
||||
'vitals.manage',
|
||||
'assessments.view', 'assessments.capture', 'assessments.manage',
|
||||
'pathways.manage',
|
||||
'womens_health.view', 'womens_health.manage',
|
||||
'service_queues.console',
|
||||
],
|
||||
'gynecologist' => [
|
||||
'dashboard.view', 'patients.view', 'appointments.view',
|
||||
'consultations.view', 'consultations.manage',
|
||||
'investigations.request', 'prescriptions.manage',
|
||||
'vitals.manage',
|
||||
'assessments.view', 'assessments.capture', 'assessments.manage',
|
||||
'pathways.manage',
|
||||
'womens_health.view', 'womens_health.manage',
|
||||
'service_queues.console',
|
||||
],
|
||||
'obgyn' => [
|
||||
'dashboard.view', 'patients.view', 'appointments.view',
|
||||
'consultations.view', 'consultations.manage',
|
||||
'investigations.request', 'prescriptions.manage',
|
||||
'vitals.manage',
|
||||
'assessments.view', 'assessments.capture', 'assessments.manage',
|
||||
'pathways.manage',
|
||||
'womens_health.view', 'womens_health.manage',
|
||||
'service_queues.console',
|
||||
],
|
||||
'labour_ward_nurse' => [
|
||||
'dashboard.view', 'patients.view', 'appointments.view',
|
||||
'consultations.view',
|
||||
'vitals.manage',
|
||||
'assessments.view', 'assessments.capture',
|
||||
'womens_health.view', 'womens_health.manage',
|
||||
'service_queues.console',
|
||||
],
|
||||
'pediatrician' => [
|
||||
@@ -378,6 +426,20 @@ class CarePermissions
|
||||
'fertility.view', 'fertility.manage',
|
||||
'service_queues.console',
|
||||
],
|
||||
'embryologist' => [
|
||||
'dashboard.view', 'patients.view', 'appointments.view',
|
||||
'consultations.view',
|
||||
'fertility.view', 'fertility.manage',
|
||||
'service_queues.console',
|
||||
],
|
||||
'fertility_nurse' => [
|
||||
'dashboard.view', 'patients.view', 'appointments.view',
|
||||
'consultations.view',
|
||||
'vitals.manage',
|
||||
'assessments.view', 'assessments.capture',
|
||||
'fertility.view', 'fertility.manage',
|
||||
'service_queues.console',
|
||||
],
|
||||
'dialysis_nurse' => [
|
||||
'dashboard.view', 'patients.view', 'appointments.view',
|
||||
'consultations.view',
|
||||
@@ -443,9 +505,10 @@ class CarePermissions
|
||||
'lab_technician', 'lab_manager', 'pathologist',
|
||||
'blood_bank_officer', 'blood_bank_manager',
|
||||
'pharmacist', 'dentist', 'psychiatrist', 'physiotherapist',
|
||||
'midwife', 'pediatrician', 'oncologist',
|
||||
'midwife', 'obstetrician', 'gynecologist', 'obgyn', 'labour_ward_nurse',
|
||||
'pediatrician', 'oncologist',
|
||||
'cardiologist', 'ent_specialist', 'dermatologist', 'ophthalmologist',
|
||||
'orthopedist', 'podiatrist', 'fertility_specialist',
|
||||
'orthopedist', 'podiatrist', 'fertility_specialist', 'embryologist', 'fertility_nurse',
|
||||
'dialysis_nurse', 'ambulance_staff', 'receptionist', 'cashier', 'billing_officer',
|
||||
'nurse',
|
||||
];
|
||||
@@ -454,9 +517,10 @@ class CarePermissions
|
||||
protected array $clinicalPractitionerRoles = [
|
||||
'emergency_physician', 'general_physician', 'doctor', 'surgeon',
|
||||
'radiologist', 'pathologist', 'dentist', 'psychiatrist',
|
||||
'physiotherapist', 'midwife', 'pediatrician', 'oncologist',
|
||||
'physiotherapist', 'midwife', 'obstetrician', 'gynecologist', 'obgyn',
|
||||
'labour_ward_nurse', 'pediatrician', 'oncologist',
|
||||
'cardiologist', 'ent_specialist', 'dermatologist', 'ophthalmologist',
|
||||
'orthopedist', 'podiatrist', 'fertility_specialist',
|
||||
'orthopedist', 'podiatrist', 'fertility_specialist', 'embryologist', 'fertility_nurse',
|
||||
'ed_nurse', 'theatre_nurse', 'dialysis_nurse', 'ambulance_staff',
|
||||
'radiographer', 'lab_technician', 'lab_manager',
|
||||
'blood_bank_officer', 'blood_bank_manager', 'pharmacist', 'nurse',
|
||||
@@ -650,8 +714,9 @@ class CarePermissions
|
||||
'emergency_physician', 'general_physician', 'doctor', 'surgeon',
|
||||
'radiologist', 'pathologist', 'dentist', 'psychiatrist',
|
||||
'pediatrician', 'oncologist', 'physiotherapist', 'midwife',
|
||||
'obstetrician', 'gynecologist', 'obgyn', 'fertility_specialist',
|
||||
'cardiologist', 'ent_specialist', 'dermatologist', 'ophthalmologist',
|
||||
'orthopedist', 'podiatrist', 'fertility_specialist',
|
||||
'orthopedist', 'podiatrist',
|
||||
], true);
|
||||
}
|
||||
|
||||
|
||||
@@ -866,7 +866,7 @@ class DemoTenantSeeder
|
||||
'dentistry' => ['Toothache', 'Dental cleaning', 'Extraction review'],
|
||||
'ophthalmology' => ['Blurry vision', 'Eye exam', 'Contact lens fitting'],
|
||||
'physiotherapy' => ['Back pain rehab', 'Post-injury physio', 'Mobility session'],
|
||||
'maternity' => ['Antenatal visit', 'Pregnancy check', 'Postnatal review'],
|
||||
'womens_health' => ['Antenatal visit', 'Pregnancy check', 'Postnatal review'],
|
||||
'radiology' => ['X-ray referral', 'Ultrasound', 'Imaging review'],
|
||||
'cardiology' => ['Chest pain review', 'ECG follow-up', 'Hypertension clinic'],
|
||||
'psychiatry' => ['Mental health review', 'Counselling session', 'Medication review'],
|
||||
@@ -1400,7 +1400,7 @@ class DemoTenantSeeder
|
||||
|
||||
$departmentIds = Department::owned($ownerRef)
|
||||
->whereIn('branch_id', $branchIds)
|
||||
->where('type', 'maternity')
|
||||
->where('type', 'womens_health')
|
||||
->where('is_active', true)
|
||||
->pluck('id');
|
||||
|
||||
@@ -1435,7 +1435,7 @@ class DemoTenantSeeder
|
||||
$clinical->upsert(
|
||||
$organization,
|
||||
$visit,
|
||||
'maternity',
|
||||
'womens_health',
|
||||
'anc_history',
|
||||
[
|
||||
'gravida' => $highRisk ? 3 : 1,
|
||||
@@ -1458,7 +1458,7 @@ class DemoTenantSeeder
|
||||
$clinical->upsert(
|
||||
$organization,
|
||||
$visit,
|
||||
'maternity',
|
||||
'womens_health',
|
||||
'obstetric_exam',
|
||||
[
|
||||
'bp' => $highRisk ? '158/102' : '118/74',
|
||||
@@ -1483,7 +1483,7 @@ class DemoTenantSeeder
|
||||
$clinical->upsert(
|
||||
$organization,
|
||||
$visit,
|
||||
'maternity',
|
||||
'womens_health',
|
||||
'fetal_notes',
|
||||
[
|
||||
'fetal_heart_rate' => $highRisk ? 168 : 142,
|
||||
@@ -1502,7 +1502,7 @@ class DemoTenantSeeder
|
||||
$clinical->upsert(
|
||||
$organization,
|
||||
$visit,
|
||||
'maternity',
|
||||
'womens_health',
|
||||
'mat_plan',
|
||||
[
|
||||
'risk_category' => 'High risk',
|
||||
|
||||
@@ -53,10 +53,16 @@ class SpecialtyClinicalRecordService
|
||||
|
||||
public function findForVisit(Visit $visit, string $moduleKey, string $recordType): ?SpecialtyClinicalRecord
|
||||
{
|
||||
$keys = [$moduleKey];
|
||||
if ($moduleKey === 'womens_health') {
|
||||
$keys[] = 'maternity'; // legacy clinical rows
|
||||
}
|
||||
|
||||
return SpecialtyClinicalRecord::owned($visit->owner_ref)
|
||||
->where('visit_id', $visit->id)
|
||||
->where('module_key', $moduleKey)
|
||||
->whereIn('module_key', $keys)
|
||||
->where('record_type', $recordType)
|
||||
->orderByDesc('id')
|
||||
->first();
|
||||
}
|
||||
|
||||
@@ -314,7 +320,7 @@ class SpecialtyClinicalRecordService
|
||||
}
|
||||
}
|
||||
|
||||
if ($moduleKey === 'maternity' && $recordType === 'obstetric_exam') {
|
||||
if ($moduleKey === 'womens_health' && $recordType === 'obstetric_exam') {
|
||||
$danger = trim((string) ($payload['danger_signs'] ?? ''));
|
||||
if ($danger !== '') {
|
||||
$alerts[] = [
|
||||
@@ -343,7 +349,7 @@ class SpecialtyClinicalRecordService
|
||||
}
|
||||
}
|
||||
|
||||
if ($moduleKey === 'maternity' && $recordType === 'fetal_notes') {
|
||||
if ($moduleKey === 'womens_health' && $recordType === 'fetal_notes') {
|
||||
$fhr = isset($payload['fetal_heart_rate']) ? (int) $payload['fetal_heart_rate'] : null;
|
||||
if ($fhr !== null && ($fhr < 110 || $fhr > 160)) {
|
||||
$alerts[] = [
|
||||
@@ -362,7 +368,7 @@ class SpecialtyClinicalRecordService
|
||||
}
|
||||
}
|
||||
|
||||
if ($moduleKey === 'maternity' && $recordType === 'mat_plan') {
|
||||
if ($moduleKey === 'womens_health' && $recordType === 'mat_plan') {
|
||||
$risk = strtolower((string) ($payload['risk_category'] ?? ''));
|
||||
if (str_contains($risk, 'high')) {
|
||||
$alerts[] = [
|
||||
|
||||
@@ -45,13 +45,160 @@ class SpecialtyModuleService
|
||||
return config('care.specialty_modules', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy maternity module key → womens_health.
|
||||
*/
|
||||
public function normalizeKey(string $key): string
|
||||
{
|
||||
return $key === 'maternity' ? 'womens_health' : $key;
|
||||
}
|
||||
|
||||
public function definition(string $key): ?array
|
||||
{
|
||||
$key = $this->normalizeKey($key);
|
||||
$catalog = $this->catalog();
|
||||
|
||||
return $catalog[$key] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate org settings from maternity → womens_health (idempotent).
|
||||
*/
|
||||
public function migrateMaternityToWomensHealth(Organization $organization): Organization
|
||||
{
|
||||
$settings = is_array($organization->settings) ? $organization->settings : [];
|
||||
$modules = is_array($settings['specialty_modules'] ?? null) ? $settings['specialty_modules'] : [];
|
||||
$provisioning = is_array($settings['specialty_module_provisioning'] ?? null)
|
||||
? $settings['specialty_module_provisioning']
|
||||
: [];
|
||||
|
||||
$changed = false;
|
||||
if (! empty($modules['maternity']) && empty($modules['womens_health'])) {
|
||||
$modules['womens_health'] = true;
|
||||
$modules['maternity'] = false;
|
||||
$changed = true;
|
||||
}
|
||||
if (isset($provisioning['maternity']) && ! isset($provisioning['womens_health'])) {
|
||||
$provisioning['womens_health'] = $provisioning['maternity'];
|
||||
unset($provisioning['maternity']);
|
||||
$changed = true;
|
||||
} elseif (isset($provisioning['maternity']) && isset($provisioning['womens_health'])) {
|
||||
unset($provisioning['maternity']);
|
||||
$changed = true;
|
||||
}
|
||||
|
||||
if (! $changed) {
|
||||
return $organization;
|
||||
}
|
||||
|
||||
$settings['specialty_modules'] = $modules;
|
||||
$settings['specialty_module_provisioning'] = $provisioning;
|
||||
$organization->update(['settings' => $settings]);
|
||||
|
||||
// Point legacy maternity departments at the new type when still labeled maternity.
|
||||
Department::query()
|
||||
->where('organization_id', $organization->id)
|
||||
->where('type', 'maternity')
|
||||
->update(['type' => 'womens_health']);
|
||||
|
||||
return $organization->fresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array{label: string, default_on: bool}>
|
||||
*/
|
||||
public function serviceLines(string $moduleKey): array
|
||||
{
|
||||
$definition = $this->definition($moduleKey);
|
||||
$lines = $definition['service_lines'] ?? [];
|
||||
if (! is_array($lines)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$out = [];
|
||||
foreach ($lines as $key => $line) {
|
||||
if (! is_string($key) || ! is_array($line)) {
|
||||
continue;
|
||||
}
|
||||
$out[$key] = [
|
||||
'label' => (string) ($line['label'] ?? $key),
|
||||
'default_on' => (bool) ($line['default_on'] ?? true),
|
||||
];
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enabled service lines for an org module (defaults when unset).
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*/
|
||||
public function enabledServiceLines(Organization $organization, string $moduleKey): array
|
||||
{
|
||||
$moduleKey = $this->normalizeKey($moduleKey);
|
||||
$catalog = $this->serviceLines($moduleKey);
|
||||
if ($catalog === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$stored = data_get(
|
||||
$organization->settings,
|
||||
"specialty_module_provisioning.{$moduleKey}.service_lines",
|
||||
[],
|
||||
);
|
||||
$stored = is_array($stored) ? $stored : [];
|
||||
|
||||
$out = [];
|
||||
foreach ($catalog as $key => $line) {
|
||||
$out[$key] = array_key_exists($key, $stored)
|
||||
? (bool) $stored[$key]
|
||||
: $line['default_on'];
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, bool> $desired
|
||||
*/
|
||||
public function syncServiceLines(Organization $organization, string $moduleKey, array $desired): void
|
||||
{
|
||||
$moduleKey = $this->normalizeKey($moduleKey);
|
||||
$catalog = $this->serviceLines($moduleKey);
|
||||
abort_unless($catalog !== [], 404);
|
||||
|
||||
$settings = is_array($organization->settings) ? $organization->settings : [];
|
||||
$provisioning = is_array($settings['specialty_module_provisioning'] ?? null)
|
||||
? $settings['specialty_module_provisioning']
|
||||
: [];
|
||||
$record = is_array($provisioning[$moduleKey] ?? null) ? $provisioning[$moduleKey] : [];
|
||||
|
||||
$lines = [];
|
||||
foreach (array_keys($catalog) as $key) {
|
||||
$lines[$key] = (bool) ($desired[$key] ?? false);
|
||||
}
|
||||
// Keep at least one line on so the module remains usable.
|
||||
if (! in_array(true, $lines, true)) {
|
||||
$first = array_key_first($catalog);
|
||||
if ($first !== null) {
|
||||
$lines[$first] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$record['service_lines'] = $lines;
|
||||
$provisioning[$moduleKey] = $record;
|
||||
$settings['specialty_module_provisioning'] = $provisioning;
|
||||
$organization->update(['settings' => $settings]);
|
||||
}
|
||||
|
||||
public function isServiceLineEnabled(Organization $organization, string $moduleKey, string $lineKey): bool
|
||||
{
|
||||
$enabled = $this->enabledServiceLines($organization, $moduleKey);
|
||||
|
||||
return (bool) ($enabled[$lineKey] ?? false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Heroicon-style icon identifier from the specialty catalog (e.g. bolt, heart).
|
||||
*/
|
||||
@@ -86,10 +233,18 @@ class SpecialtyModuleService
|
||||
|
||||
public function isEnabled(Organization $organization, string $key): bool
|
||||
{
|
||||
$key = $this->normalizeKey($key);
|
||||
|
||||
if (! $this->definition($key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// One-time maternity → womens_health settings migration.
|
||||
if ($key === 'womens_health'
|
||||
&& data_get($organization->settings, 'specialty_modules.maternity')) {
|
||||
$organization = $this->migrateMaternityToWomensHealth($organization);
|
||||
}
|
||||
|
||||
if ($this->isDefaultOnPaidPlans($key) && $this->plans->hasPaidPlan($organization)) {
|
||||
return true;
|
||||
}
|
||||
@@ -245,6 +400,7 @@ class SpecialtyModuleService
|
||||
*/
|
||||
public function memberAccessLevel(Organization $organization, ?Member $member, string $key): string
|
||||
{
|
||||
$key = $this->normalizeKey($key);
|
||||
$cacheKey = $organization->id.'|'.($member?->id ?? 'guest').'|'.$key;
|
||||
if (isset($this->memberAccessLevelCache[$cacheKey])) {
|
||||
return $this->memberAccessLevelCache[$cacheKey];
|
||||
@@ -294,6 +450,7 @@ class SpecialtyModuleService
|
||||
*/
|
||||
public function memberCanManage(Organization $organization, ?Member $member, string $key): bool
|
||||
{
|
||||
$key = $this->normalizeKey($key);
|
||||
if (! $this->isEnabled($organization, $key) || ! $member) {
|
||||
return false;
|
||||
}
|
||||
@@ -358,6 +515,7 @@ class SpecialtyModuleService
|
||||
*/
|
||||
public function memberCanView(Organization $organization, ?Member $member, string $key): bool
|
||||
{
|
||||
$key = $this->normalizeKey($key);
|
||||
if ($this->memberCanManage($organization, $member, $key)
|
||||
|| $this->memberCanRefer($organization, $member, $key)) {
|
||||
return true;
|
||||
@@ -413,6 +571,7 @@ class SpecialtyModuleService
|
||||
*/
|
||||
public function memberCanRefer(Organization $organization, ?Member $member, string $key): bool
|
||||
{
|
||||
$key = $this->normalizeKey($key);
|
||||
if ($this->memberCanManage($organization, $member, $key)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ use App\Services\Care\BloodBank\BloodBankWorkflowService;
|
||||
use App\Services\Care\Emergency\EmergencyWorkflowService;
|
||||
use App\Services\Care\Ophthalmology\OphthalmologyWorkflowService;
|
||||
use App\Services\Care\Physiotherapy\PhysiotherapyWorkflowService;
|
||||
use App\Services\Care\Maternity\MaternityWorkflowService;
|
||||
use App\Services\Care\WomensHealth\WomensHealthWorkflowService;
|
||||
use App\Services\Care\Radiology\RadiologyWorkflowService;
|
||||
use App\Services\Care\Cardiology\CardiologyWorkflowService;
|
||||
use App\Services\Care\Psychiatry\PsychiatryWorkflowService;
|
||||
@@ -48,6 +48,7 @@ class SpecialtyShellService
|
||||
*/
|
||||
public function definition(string $moduleKey): array
|
||||
{
|
||||
$moduleKey = $this->modules->normalizeKey($moduleKey);
|
||||
$base = $this->modules->definition($moduleKey) ?? [];
|
||||
$shell = config("care_specialty_shell.modules.{$moduleKey}", []);
|
||||
$defaults = config('care_specialty_shell.defaults', []);
|
||||
@@ -76,7 +77,7 @@ class SpecialtyShellService
|
||||
'blood_bank' => 'care.specialty.blood-bank.stage',
|
||||
'ophthalmology' => 'care.specialty.ophthalmology.stage',
|
||||
'physiotherapy' => 'care.specialty.physiotherapy.stage',
|
||||
'maternity' => 'care.specialty.maternity.stage',
|
||||
'womens_health' => 'care.specialty.womens_health.stage',
|
||||
'radiology' => 'care.specialty.radiology.stage',
|
||||
'cardiology' => 'care.specialty.cardiology.stage',
|
||||
'psychiatry' => 'care.specialty.psychiatry.stage',
|
||||
@@ -110,7 +111,7 @@ class SpecialtyShellService
|
||||
'blood_bank' => app(BloodBankWorkflowService::class)->stageFlow(),
|
||||
'ophthalmology' => app(OphthalmologyWorkflowService::class)->stageFlow(),
|
||||
'physiotherapy' => app(PhysiotherapyWorkflowService::class)->stageFlow(),
|
||||
'maternity' => app(MaternityWorkflowService::class)->stageFlow(),
|
||||
'womens_health' => app(WomensHealthWorkflowService::class)->stageFlow(),
|
||||
'radiology' => app(RadiologyWorkflowService::class)->stageFlow(),
|
||||
'cardiology' => app(CardiologyWorkflowService::class)->stageFlow(),
|
||||
'psychiatry' => app(PsychiatryWorkflowService::class)->stageFlow(),
|
||||
@@ -179,33 +180,52 @@ class SpecialtyShellService
|
||||
/**
|
||||
* Catalog from config (authoritative template).
|
||||
*
|
||||
* @return list<array{code: string, label: string, amount_minor: int, type: string}>
|
||||
* @return list<array{code: string, label: string, amount_minor: int, type: string, service_line?: string}>
|
||||
*/
|
||||
public function catalogServices(string $moduleKey): array
|
||||
public function catalogServices(string $moduleKey, ?Organization $organization = null): array
|
||||
{
|
||||
$moduleKey = $this->modules->normalizeKey($moduleKey);
|
||||
$services = $this->definition($moduleKey)['services'] ?? [];
|
||||
if (! is_array($services)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return array_values(array_map(function ($row) {
|
||||
return [
|
||||
$enabledLines = $organization
|
||||
? $this->modules->enabledServiceLines($organization, $moduleKey)
|
||||
: [];
|
||||
|
||||
$out = [];
|
||||
foreach ($services as $row) {
|
||||
if (! is_array($row)) {
|
||||
continue;
|
||||
}
|
||||
$line = isset($row['service_line']) ? (string) $row['service_line'] : '';
|
||||
if ($organization && $enabledLines !== [] && $line !== '') {
|
||||
if (! ($enabledLines[$line] ?? false)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$out[] = [
|
||||
'code' => (string) ($row['code'] ?? ''),
|
||||
'label' => (string) ($row['label'] ?? ''),
|
||||
'amount_minor' => (int) ($row['amount_minor'] ?? 0),
|
||||
'type' => (string) ($row['type'] ?? 'misc'),
|
||||
'service_line' => $line,
|
||||
];
|
||||
}, $services));
|
||||
}
|
||||
|
||||
return array_values($out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Seeded services stored on the organization when the module was activated.
|
||||
*
|
||||
* @return list<array{code: string, label: string, amount_minor: int, type: string}>
|
||||
* @return list<array{code: string, label: string, amount_minor: int, type: string, service_line?: string}>
|
||||
*/
|
||||
public function provisionedServices(Organization $organization, string $moduleKey): array
|
||||
{
|
||||
$catalog = collect($this->catalogServices($moduleKey))->keyBy(fn ($s) => (string) ($s['code'] ?? ''));
|
||||
$moduleKey = $this->modules->normalizeKey($moduleKey);
|
||||
$catalog = collect($this->catalogServices($moduleKey, $organization))->keyBy(fn ($s) => (string) ($s['code'] ?? ''));
|
||||
$stored = data_get($organization->settings, "specialty_module_provisioning.{$moduleKey}.services");
|
||||
if (is_array($stored)) {
|
||||
foreach ($stored as $service) {
|
||||
@@ -213,6 +233,11 @@ class SpecialtyShellService
|
||||
if ($code === '') {
|
||||
continue;
|
||||
}
|
||||
// Skip stored services for disabled service lines.
|
||||
$line = (string) ($service['service_line'] ?? $catalog->get($code)['service_line'] ?? '');
|
||||
if ($line !== '' && ! $this->modules->isServiceLineEnabled($organization, $moduleKey, $line)) {
|
||||
continue;
|
||||
}
|
||||
$prior = $catalog->get($code, []);
|
||||
$catalog->put($code, array_merge(is_array($prior) ? $prior : [], $service));
|
||||
}
|
||||
@@ -427,7 +452,7 @@ class SpecialtyShellService
|
||||
) {
|
||||
$code = (string) ($stage['code'] ?? '');
|
||||
|
||||
if (in_array($moduleKey, ['dentistry', 'emergency', 'blood_bank', 'ophthalmology', 'physiotherapy', 'maternity', 'radiology', 'cardiology', 'psychiatry', 'pediatrics', 'orthopedics', 'ent', 'oncology', 'renal', 'surgery', 'vaccination', 'pathology', 'infusion', 'dermatology', 'podiatry', 'fertility', 'child_welfare', 'ambulance'], true) && $visitIds->isNotEmpty()) {
|
||||
if (in_array($moduleKey, ['dentistry', 'emergency', 'blood_bank', 'ophthalmology', 'physiotherapy', 'womens_health', 'radiology', 'cardiology', 'psychiatry', 'pediatrics', 'orthopedics', 'ent', 'oncology', 'renal', 'surgery', 'vaccination', 'pathology', 'infusion', 'dermatology', 'podiatry', 'fertility', 'child_welfare', 'ambulance'], true) && $visitIds->isNotEmpty()) {
|
||||
$count = Visit::owned($ownerRef)
|
||||
->where('organization_id', $organization->id)
|
||||
->whereIn('id', $visitIds)
|
||||
@@ -459,7 +484,7 @@ class SpecialtyShellService
|
||||
'blood_bank' => $clinical->countOpenByType($organization, 'blood_bank', 'blood_request', $branchScope),
|
||||
'ophthalmology' => $clinical->countOpenByType($organization, 'ophthalmology', 'eye_exam', $branchScope),
|
||||
'physiotherapy' => $clinical->countOpenByType($organization, 'physiotherapy', 'pt_assessment', $branchScope),
|
||||
'maternity' => $clinical->countOpenByType($organization, 'maternity', 'anc_history', $branchScope),
|
||||
'womens_health' => $clinical->countOpenByType($organization, 'womens_health', 'anc_history', $branchScope),
|
||||
'radiology' => $clinical->countOpenByType($organization, 'radiology', 'imaging_request', $branchScope),
|
||||
'cardiology' => $clinical->countOpenByType($organization, 'cardiology', 'cardiac_exam', $branchScope),
|
||||
'psychiatry' => $clinical->countOpenByType($organization, 'psychiatry', 'mental_status', $branchScope),
|
||||
|
||||
@@ -112,11 +112,11 @@ class SpecialtyVisitStageService
|
||||
: ($stages[1] ?? ($stages[0] ?? null));
|
||||
}
|
||||
|
||||
if ($moduleKey === 'maternity') {
|
||||
if ($moduleKey === 'womens_health') {
|
||||
$stages = $this->allowedStages($moduleKey);
|
||||
|
||||
return in_array(\App\Services\Care\Maternity\MaternityWorkflowService::STAGE_HISTORY, $stages, true)
|
||||
? \App\Services\Care\Maternity\MaternityWorkflowService::STAGE_HISTORY
|
||||
return in_array(\App\Services\Care\WomensHealth\WomensHealthWorkflowService::STAGE_HISTORY, $stages, true)
|
||||
? \App\Services\Care\WomensHealth\WomensHealthWorkflowService::STAGE_HISTORY
|
||||
: ($stages[1] ?? ($stages[0] ?? null));
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Care\Maternity;
|
||||
namespace App\Services\Care\WomensHealth;
|
||||
|
||||
use App\Models\Appointment;
|
||||
use App\Models\Bill;
|
||||
@@ -12,7 +12,7 @@ use App\Services\Care\SpecialtyShellService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class MaternityAnalyticsService
|
||||
class WomensHealthAnalyticsService
|
||||
{
|
||||
public function __construct(
|
||||
protected SpecialtyShellService $shell,
|
||||
@@ -42,7 +42,7 @@ class MaternityAnalyticsService
|
||||
$rangeFrom = $from ? Carbon::parse($from)->startOfDay() : now()->startOfMonth();
|
||||
$rangeTo = $to ? Carbon::parse($to)->endOfDay() : now()->endOfDay();
|
||||
|
||||
$departmentIds = $this->shell->departmentIds($organization, 'maternity', $ownerRef, $branchId);
|
||||
$departmentIds = $this->shell->departmentIds($organization, 'womens_health', $ownerRef, $branchId);
|
||||
|
||||
$appointmentBase = Appointment::owned($ownerRef)
|
||||
->where('organization_id', $organization->id)
|
||||
@@ -69,7 +69,7 @@ class MaternityAnalyticsService
|
||||
|
||||
$highRiskOpen = SpecialtyClinicalRecord::owned($ownerRef)
|
||||
->where('organization_id', $organization->id)
|
||||
->where('module_key', 'maternity')
|
||||
->where('module_key', 'womens_health')
|
||||
->where('record_type', 'mat_plan')
|
||||
->whereIn('visit_id', $openVisitIds->isEmpty() ? [0] : $openVisitIds)
|
||||
->get()
|
||||
@@ -82,7 +82,7 @@ class MaternityAnalyticsService
|
||||
|
||||
$planRecords = SpecialtyClinicalRecord::owned($ownerRef)
|
||||
->where('organization_id', $organization->id)
|
||||
->where('module_key', 'maternity')
|
||||
->where('module_key', 'womens_health')
|
||||
->where('record_type', 'mat_plan')
|
||||
->when($branchId, fn ($q) => $q->where('branch_id', $branchId))
|
||||
->whereBetween('recorded_at', [$rangeFrom, $rangeTo])
|
||||
@@ -100,7 +100,7 @@ class MaternityAnalyticsService
|
||||
|
||||
$postnatalRecords = SpecialtyClinicalRecord::owned($ownerRef)
|
||||
->where('organization_id', $organization->id)
|
||||
->where('module_key', 'maternity')
|
||||
->where('module_key', 'womens_health')
|
||||
->where('record_type', 'postnatal_note')
|
||||
->when($branchId, fn ($q) => $q->where('branch_id', $branchId))
|
||||
->whereBetween('recorded_at', [$rangeFrom, $rangeTo])
|
||||
@@ -132,7 +132,7 @@ class MaternityAnalyticsService
|
||||
}), 1);
|
||||
}
|
||||
|
||||
$serviceLabels = collect($this->shell->provisionedServices($organization, 'maternity'))
|
||||
$serviceLabels = collect($this->shell->provisionedServices($organization, 'womens_health'))
|
||||
->pluck('label')
|
||||
->filter()
|
||||
->values()
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Care\Maternity;
|
||||
namespace App\Services\Care\WomensHealth;
|
||||
|
||||
/**
|
||||
* Map maternity / ANC clinical progress onto visit stages.
|
||||
* Map Women's Health / ANC clinical progress onto visit stages.
|
||||
*/
|
||||
class MaternityWorkflowService
|
||||
class WomensHealthWorkflowService
|
||||
{
|
||||
public const STAGE_CHECK_IN = 'check_in';
|
||||
|
||||
@@ -200,7 +200,7 @@ final class DemoWorld
|
||||
'dentistry' => ['name' => 'Dr. Ama Dental', 'role' => 'dentist'],
|
||||
'ophthalmology' => ['name' => 'Dr. Kofi Eye', 'role' => 'doctor'],
|
||||
'physiotherapy' => ['name' => 'Dr. Efua Physio', 'role' => 'physiotherapist'],
|
||||
'maternity' => ['name' => 'Abena Midwife', 'role' => 'midwife'],
|
||||
'womens_health' => ['name' => 'Abena Midwife', 'role' => 'midwife'],
|
||||
'radiology' => ['name' => 'Dr. Yaw Radiology', 'role' => 'radiologist'],
|
||||
'cardiology' => ['name' => 'Dr. Kwesi Cardiology', 'role' => 'doctor'],
|
||||
'psychiatry' => ['name' => 'Dr. Adwoa Psychiatry', 'role' => 'psychiatrist'],
|
||||
|
||||
Reference in New Issue
Block a user