Add full Dermatology, Podiatry, and Fertility specialty clinical suites.
Deploy Ladill Care / deploy (push) Successful in 35s

Bring thin catalog modules to the same depth as Cardiology with stages, clinical tabs, reports/print, demo seed, and suite tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-19 22:03:01 +00:00
co-authored by Cursor
parent 7b722c71d0
commit 8c18ecc5c9
35 changed files with 3937 additions and 39 deletions
@@ -0,0 +1,215 @@
<?php
namespace App\Http\Controllers\Care;
use App\Http\Controllers\Care\Concerns\ScopesToAccount;
use App\Http\Controllers\Controller;
use App\Models\SpecialtyClinicalRecord;
use App\Models\Visit;
use App\Services\Care\Dermatology\DermatologyAnalyticsService;
use App\Services\Care\Dermatology\DermatologyWorkflowService;
use App\Services\Care\SpecialtyClinicalRecordService;
use App\Services\Care\SpecialtyModuleService;
use App\Services\Care\SpecialtyShellService;
use App\Services\Care\SpecialtyVisitStageService;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
class DermatologyWorkspaceController extends Controller
{
use ScopesToAccount;
protected function assertDermatologyAccess(Request $request, SpecialtyModuleService $modules): void
{
$organization = $this->organization($request);
abort_unless($modules->memberCanAccess($organization, $this->member($request), 'dermatology'), 403);
}
protected function assertDermatologyManage(Request $request, SpecialtyModuleService $modules): void
{
$organization = $this->organization($request);
abort_unless($modules->memberCanManage($organization, $this->member($request), 'dermatology'), 403);
}
protected function assertVisit(Request $request, Visit $visit): void
{
abort_unless($visit->organization_id === $this->organization($request)->id, 404);
$this->authorizeBranch($request, (int) $visit->branch_id);
}
public function setStage(
Request $request,
Visit $visit,
SpecialtyModuleService $modules,
SpecialtyVisitStageService $stages,
SpecialtyShellService $shell,
): RedirectResponse {
$this->authorizeAbility($request, 'consultations.manage');
$this->assertDermatologyManage($request, $modules);
$this->assertVisit($request, $visit);
$validated = $request->validate([
'stage' => ['required', 'string', 'max:32'],
]);
try {
$stages->setStage(
$this->organization($request),
$visit,
'dermatology',
$validated['stage'],
$this->ownerRef($request),
$this->actorRef($request),
);
} catch (\InvalidArgumentException $e) {
return back()->with('error', $e->getMessage());
}
return redirect()
->route('care.specialty.workspace', [
'module' => 'dermatology',
'visit' => $visit,
'tab' => $shell->workspaceTabForStage('dermatology', $validated['stage']),
])
->with('success', 'Visit stage updated.');
}
public function saveProcedure(
Request $request,
Visit $visit,
SpecialtyModuleService $modules,
SpecialtyClinicalRecordService $clinical,
SpecialtyVisitStageService $stages,
DermatologyWorkflowService $workflow,
): RedirectResponse {
$this->authorizeAbility($request, 'consultations.manage');
$this->assertDermatologyManage($request, $modules);
$this->assertVisit($request, $visit);
$organization = $this->organization($request);
$owner = $this->ownerRef($request);
$payload = (array) $request->input('payload', []);
foreach ($clinical->fieldsFor('dermatology', 'derm_procedure') as $field) {
if (($field['type'] ?? '') === 'boolean') {
$payload[$field['name']] = $request->boolean('payload.'.$field['name']);
}
}
$request->merge(['payload' => $payload, 'tab' => 'procedure']);
$validated = $request->validate(array_merge([
'tab' => ['required', 'string'],
], $clinical->validationRules('dermatology', 'derm_procedure')));
$record = $clinical->upsert(
$organization,
$visit,
'dermatology',
'derm_procedure',
$clinical->payloadFromRequest($validated),
$owner,
$owner,
DermatologyWorkflowService::STAGE_PROCEDURE,
SpecialtyClinicalRecord::STATUS_COMPLETED,
);
try {
$stages->setStage(
$organization,
$visit,
'dermatology',
DermatologyWorkflowService::STAGE_PROCEDURE,
$owner,
$owner,
);
} catch (\InvalidArgumentException) {
}
if ($workflow->shouldCompleteVisit($record->payload ?? [])) {
try {
$stages->setStage(
$organization,
$visit,
'dermatology',
DermatologyWorkflowService::STAGE_COMPLETED,
$owner,
$owner,
);
} catch (\InvalidArgumentException) {
}
$visit->refresh();
if ($visit->status !== Visit::STATUS_COMPLETED) {
$visit->update([
'status' => Visit::STATUS_COMPLETED,
'completed_at' => $visit->completed_at ?? now(),
]);
}
$appointment = $visit->appointment;
if ($appointment && $appointment->status !== \App\Models\Appointment::STATUS_COMPLETED) {
$appointment->update([
'status' => \App\Models\Appointment::STATUS_COMPLETED,
'completed_at' => $appointment->completed_at ?? now(),
]);
}
}
return redirect()
->route('care.specialty.workspace', ['module' => 'dermatology', 'visit' => $visit, 'tab' => 'procedure'])
->with('success', 'Procedure / treatment saved.');
}
public function reports(
Request $request,
SpecialtyModuleService $modules,
SpecialtyShellService $shell,
DermatologyAnalyticsService $analytics,
): View {
$this->authorizeAbility($request, 'consultations.view');
$this->assertDermatologyAccess($request, $modules);
$organization = $this->organization($request);
$branchScope = app(\App\Services\Care\OrganizationResolver::class)->branchScope($this->member($request));
$report = $analytics->report(
$organization,
$this->ownerRef($request),
$branchScope,
$request->query('from'),
$request->query('to'),
);
return view('care.specialty.dermatology.reports', [
'moduleKey' => 'dermatology',
'definition' => $modules->definition('dermatology'),
'shellNav' => $shell->navItems('dermatology'),
'report' => $report,
'currency' => strtoupper((string) config('care.billing.currency', config('care.currency', 'GHS'))),
]);
}
public function printSummary(
Request $request,
Visit $visit,
SpecialtyModuleService $modules,
SpecialtyClinicalRecordService $clinical,
): View {
$this->authorizeAbility($request, 'consultations.view');
$this->assertDermatologyAccess($request, $modules);
$this->assertVisit($request, $visit);
$visit->loadMissing(['patient', 'appointment.practitioner', 'branch']);
return view('care.specialty.dermatology.print', [
'visit' => $visit,
'patient' => $visit->patient,
'history' => $clinical->findForVisit($visit, 'dermatology', 'derm_history'),
'exam' => $clinical->findForVisit($visit, 'dermatology', 'skin_exam'),
'investigation' => $clinical->findForVisit($visit, 'dermatology', 'derm_investigation'),
'plan' => $clinical->findForVisit($visit, 'dermatology', 'derm_plan'),
'procedure' => $clinical->findForVisit($visit, 'dermatology', 'derm_procedure'),
]);
}
}
@@ -0,0 +1,215 @@
<?php
namespace App\Http\Controllers\Care;
use App\Http\Controllers\Care\Concerns\ScopesToAccount;
use App\Http\Controllers\Controller;
use App\Models\SpecialtyClinicalRecord;
use App\Models\Visit;
use App\Services\Care\Fertility\FertilityAnalyticsService;
use App\Services\Care\Fertility\FertilityWorkflowService;
use App\Services\Care\SpecialtyClinicalRecordService;
use App\Services\Care\SpecialtyModuleService;
use App\Services\Care\SpecialtyShellService;
use App\Services\Care\SpecialtyVisitStageService;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
class FertilityWorkspaceController extends Controller
{
use ScopesToAccount;
protected function assertFertilityAccess(Request $request, SpecialtyModuleService $modules): void
{
$organization = $this->organization($request);
abort_unless($modules->memberCanAccess($organization, $this->member($request), 'fertility'), 403);
}
protected function assertFertilityManage(Request $request, SpecialtyModuleService $modules): void
{
$organization = $this->organization($request);
abort_unless($modules->memberCanManage($organization, $this->member($request), 'fertility'), 403);
}
protected function assertVisit(Request $request, Visit $visit): void
{
abort_unless($visit->organization_id === $this->organization($request)->id, 404);
$this->authorizeBranch($request, (int) $visit->branch_id);
}
public function setStage(
Request $request,
Visit $visit,
SpecialtyModuleService $modules,
SpecialtyVisitStageService $stages,
SpecialtyShellService $shell,
): RedirectResponse {
$this->authorizeAbility($request, 'consultations.manage');
$this->assertFertilityManage($request, $modules);
$this->assertVisit($request, $visit);
$validated = $request->validate([
'stage' => ['required', 'string', 'max:32'],
]);
try {
$stages->setStage(
$this->organization($request),
$visit,
'fertility',
$validated['stage'],
$this->ownerRef($request),
$this->actorRef($request),
);
} catch (\InvalidArgumentException $e) {
return back()->with('error', $e->getMessage());
}
return redirect()
->route('care.specialty.workspace', [
'module' => 'fertility',
'visit' => $visit,
'tab' => $shell->workspaceTabForStage('fertility', $validated['stage']),
])
->with('success', 'Visit stage updated.');
}
public function saveCycle(
Request $request,
Visit $visit,
SpecialtyModuleService $modules,
SpecialtyClinicalRecordService $clinical,
SpecialtyVisitStageService $stages,
FertilityWorkflowService $workflow,
): RedirectResponse {
$this->authorizeAbility($request, 'consultations.manage');
$this->assertFertilityManage($request, $modules);
$this->assertVisit($request, $visit);
$organization = $this->organization($request);
$owner = $this->ownerRef($request);
$payload = (array) $request->input('payload', []);
foreach ($clinical->fieldsFor('fertility', 'fert_cycle') as $field) {
if (($field['type'] ?? '') === 'boolean') {
$payload[$field['name']] = $request->boolean('payload.'.$field['name']);
}
}
$request->merge(['payload' => $payload, 'tab' => 'cycle']);
$validated = $request->validate(array_merge([
'tab' => ['required', 'string'],
], $clinical->validationRules('fertility', 'fert_cycle')));
$record = $clinical->upsert(
$organization,
$visit,
'fertility',
'fert_cycle',
$clinical->payloadFromRequest($validated),
$owner,
$owner,
FertilityWorkflowService::STAGE_CYCLE,
SpecialtyClinicalRecord::STATUS_COMPLETED,
);
try {
$stages->setStage(
$organization,
$visit,
'fertility',
FertilityWorkflowService::STAGE_CYCLE,
$owner,
$owner,
);
} catch (\InvalidArgumentException) {
}
if ($workflow->shouldCompleteVisit($record->payload ?? [])) {
try {
$stages->setStage(
$organization,
$visit,
'fertility',
FertilityWorkflowService::STAGE_COMPLETED,
$owner,
$owner,
);
} catch (\InvalidArgumentException) {
}
$visit->refresh();
if ($visit->status !== Visit::STATUS_COMPLETED) {
$visit->update([
'status' => Visit::STATUS_COMPLETED,
'completed_at' => $visit->completed_at ?? now(),
]);
}
$appointment = $visit->appointment;
if ($appointment && $appointment->status !== \App\Models\Appointment::STATUS_COMPLETED) {
$appointment->update([
'status' => \App\Models\Appointment::STATUS_COMPLETED,
'completed_at' => $appointment->completed_at ?? now(),
]);
}
}
return redirect()
->route('care.specialty.workspace', ['module' => 'fertility', 'visit' => $visit, 'tab' => 'cycle'])
->with('success', 'Cycle / procedure note saved.');
}
public function reports(
Request $request,
SpecialtyModuleService $modules,
SpecialtyShellService $shell,
FertilityAnalyticsService $analytics,
): View {
$this->authorizeAbility($request, 'consultations.view');
$this->assertFertilityAccess($request, $modules);
$organization = $this->organization($request);
$branchScope = app(\App\Services\Care\OrganizationResolver::class)->branchScope($this->member($request));
$report = $analytics->report(
$organization,
$this->ownerRef($request),
$branchScope,
$request->query('from'),
$request->query('to'),
);
return view('care.specialty.fertility.reports', [
'moduleKey' => 'fertility',
'definition' => $modules->definition('fertility'),
'shellNav' => $shell->navItems('fertility'),
'report' => $report,
'currency' => strtoupper((string) config('care.billing.currency', config('care.currency', 'GHS'))),
]);
}
public function printSummary(
Request $request,
Visit $visit,
SpecialtyModuleService $modules,
SpecialtyClinicalRecordService $clinical,
): View {
$this->authorizeAbility($request, 'consultations.view');
$this->assertFertilityAccess($request, $modules);
$this->assertVisit($request, $visit);
$visit->loadMissing(['patient', 'appointment.practitioner', 'branch']);
return view('care.specialty.fertility.print', [
'visit' => $visit,
'patient' => $visit->patient,
'history' => $clinical->findForVisit($visit, 'fertility', 'fert_history'),
'exam' => $clinical->findForVisit($visit, 'fertility', 'fert_exam'),
'investigation' => $clinical->findForVisit($visit, 'fertility', 'fert_investigation'),
'plan' => $clinical->findForVisit($visit, 'fertility', 'fert_plan'),
'cycle' => $clinical->findForVisit($visit, 'fertility', 'fert_cycle'),
]);
}
}
@@ -0,0 +1,215 @@
<?php
namespace App\Http\Controllers\Care;
use App\Http\Controllers\Care\Concerns\ScopesToAccount;
use App\Http\Controllers\Controller;
use App\Models\SpecialtyClinicalRecord;
use App\Models\Visit;
use App\Services\Care\Podiatry\PodiatryAnalyticsService;
use App\Services\Care\Podiatry\PodiatryWorkflowService;
use App\Services\Care\SpecialtyClinicalRecordService;
use App\Services\Care\SpecialtyModuleService;
use App\Services\Care\SpecialtyShellService;
use App\Services\Care\SpecialtyVisitStageService;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
class PodiatryWorkspaceController extends Controller
{
use ScopesToAccount;
protected function assertPodiatryAccess(Request $request, SpecialtyModuleService $modules): void
{
$organization = $this->organization($request);
abort_unless($modules->memberCanAccess($organization, $this->member($request), 'podiatry'), 403);
}
protected function assertPodiatryManage(Request $request, SpecialtyModuleService $modules): void
{
$organization = $this->organization($request);
abort_unless($modules->memberCanManage($organization, $this->member($request), 'podiatry'), 403);
}
protected function assertVisit(Request $request, Visit $visit): void
{
abort_unless($visit->organization_id === $this->organization($request)->id, 404);
$this->authorizeBranch($request, (int) $visit->branch_id);
}
public function setStage(
Request $request,
Visit $visit,
SpecialtyModuleService $modules,
SpecialtyVisitStageService $stages,
SpecialtyShellService $shell,
): RedirectResponse {
$this->authorizeAbility($request, 'consultations.manage');
$this->assertPodiatryManage($request, $modules);
$this->assertVisit($request, $visit);
$validated = $request->validate([
'stage' => ['required', 'string', 'max:32'],
]);
try {
$stages->setStage(
$this->organization($request),
$visit,
'podiatry',
$validated['stage'],
$this->ownerRef($request),
$this->actorRef($request),
);
} catch (\InvalidArgumentException $e) {
return back()->with('error', $e->getMessage());
}
return redirect()
->route('care.specialty.workspace', [
'module' => 'podiatry',
'visit' => $visit,
'tab' => $shell->workspaceTabForStage('podiatry', $validated['stage']),
])
->with('success', 'Visit stage updated.');
}
public function saveProcedure(
Request $request,
Visit $visit,
SpecialtyModuleService $modules,
SpecialtyClinicalRecordService $clinical,
SpecialtyVisitStageService $stages,
PodiatryWorkflowService $workflow,
): RedirectResponse {
$this->authorizeAbility($request, 'consultations.manage');
$this->assertPodiatryManage($request, $modules);
$this->assertVisit($request, $visit);
$organization = $this->organization($request);
$owner = $this->ownerRef($request);
$payload = (array) $request->input('payload', []);
foreach ($clinical->fieldsFor('podiatry', 'pod_procedure') as $field) {
if (($field['type'] ?? '') === 'boolean') {
$payload[$field['name']] = $request->boolean('payload.'.$field['name']);
}
}
$request->merge(['payload' => $payload, 'tab' => 'procedure']);
$validated = $request->validate(array_merge([
'tab' => ['required', 'string'],
], $clinical->validationRules('podiatry', 'pod_procedure')));
$record = $clinical->upsert(
$organization,
$visit,
'podiatry',
'pod_procedure',
$clinical->payloadFromRequest($validated),
$owner,
$owner,
PodiatryWorkflowService::STAGE_PROCEDURE,
SpecialtyClinicalRecord::STATUS_COMPLETED,
);
try {
$stages->setStage(
$organization,
$visit,
'podiatry',
PodiatryWorkflowService::STAGE_PROCEDURE,
$owner,
$owner,
);
} catch (\InvalidArgumentException) {
}
if ($workflow->shouldCompleteVisit($record->payload ?? [])) {
try {
$stages->setStage(
$organization,
$visit,
'podiatry',
PodiatryWorkflowService::STAGE_COMPLETED,
$owner,
$owner,
);
} catch (\InvalidArgumentException) {
}
$visit->refresh();
if ($visit->status !== Visit::STATUS_COMPLETED) {
$visit->update([
'status' => Visit::STATUS_COMPLETED,
'completed_at' => $visit->completed_at ?? now(),
]);
}
$appointment = $visit->appointment;
if ($appointment && $appointment->status !== \App\Models\Appointment::STATUS_COMPLETED) {
$appointment->update([
'status' => \App\Models\Appointment::STATUS_COMPLETED,
'completed_at' => $appointment->completed_at ?? now(),
]);
}
}
return redirect()
->route('care.specialty.workspace', ['module' => 'podiatry', 'visit' => $visit, 'tab' => 'procedure'])
->with('success', 'Procedure saved.');
}
public function reports(
Request $request,
SpecialtyModuleService $modules,
SpecialtyShellService $shell,
PodiatryAnalyticsService $analytics,
): View {
$this->authorizeAbility($request, 'consultations.view');
$this->assertPodiatryAccess($request, $modules);
$organization = $this->organization($request);
$branchScope = app(\App\Services\Care\OrganizationResolver::class)->branchScope($this->member($request));
$report = $analytics->report(
$organization,
$this->ownerRef($request),
$branchScope,
$request->query('from'),
$request->query('to'),
);
return view('care.specialty.podiatry.reports', [
'moduleKey' => 'podiatry',
'definition' => $modules->definition('podiatry'),
'shellNav' => $shell->navItems('podiatry'),
'report' => $report,
'currency' => strtoupper((string) config('care.billing.currency', config('care.currency', 'GHS'))),
]);
}
public function printSummary(
Request $request,
Visit $visit,
SpecialtyModuleService $modules,
SpecialtyClinicalRecordService $clinical,
): View {
$this->authorizeAbility($request, 'consultations.view');
$this->assertPodiatryAccess($request, $modules);
$this->assertVisit($request, $visit);
$visit->loadMissing(['patient', 'appointment.practitioner', 'branch']);
return view('care.specialty.podiatry.print', [
'visit' => $visit,
'patient' => $visit->patient,
'history' => $clinical->findForVisit($visit, 'podiatry', 'pod_history'),
'exam' => $clinical->findForVisit($visit, 'podiatry', 'foot_exam'),
'investigation' => $clinical->findForVisit($visit, 'podiatry', 'pod_investigation'),
'plan' => $clinical->findForVisit($visit, 'podiatry', 'pod_plan'),
'procedure' => $clinical->findForVisit($visit, 'podiatry', 'pod_procedure'),
]);
}
}
@@ -168,6 +168,9 @@ class SpecialtyModuleController extends Controller
'vaccination' => 'eligibility',
'pathology' => 'request',
'infusion' => 'assessment',
'dermatology' => 'history',
'podiatry' => 'history',
'fertility' => 'history',
default => (collect(array_keys($shellTabs))
->first(fn (string $tab) => $clinical->recordTypeForTab($module, $tab) !== null)
?? 'clinical_notes'),
@@ -254,6 +257,9 @@ class SpecialtyModuleController extends Controller
'vaccination' => 'eligibility',
'pathology' => 'request',
'infusion' => 'assessment',
'dermatology' => 'history',
'podiatry' => 'history',
'fertility' => 'history',
default => (collect(array_keys($shellTabs))
->first(fn (string $tab) => $clinical->recordTypeForTab($module, $tab) !== null)
?? 'clinical_notes'),
@@ -1019,6 +1025,108 @@ class SpecialtyModuleController extends Controller
}
}
if ($module === 'dermatology' && in_array($recordType, ['derm_history', 'skin_exam', 'derm_investigation', 'derm_plan'], true)) {
$workflow = app(\App\Services\Care\Dermatology\DermatologyWorkflowService::class);
$stageService = app(\App\Services\Care\SpecialtyVisitStageService::class);
$suggested = match ($recordType) {
'derm_history' => $workflow->stageFromHistory($record->payload ?? []),
'skin_exam' => $workflow->stageFromExam($record->payload ?? []),
'derm_investigation' => $workflow->stageFromInvestigation($record->payload ?? []),
'derm_plan' => $workflow->stageFromPlan($record->payload ?? []),
default => null,
};
$current = $visit->specialty_stage;
$early = ['check_in', 'waiting', null, ''];
$order = [
'check_in' => 0,
'history' => 1,
'exam' => 2,
'investigation' => 3,
'plan' => 4,
'procedure' => 5,
'completed' => 6,
];
if ($suggested && (! $current || in_array($current, $early, true))) {
try {
$stageService->setStage($organization, $visit, 'dermatology', $suggested, $this->ownerRef($request), $this->ownerRef($request));
} catch (\InvalidArgumentException) {
}
} elseif ($suggested && $suggested !== $current && ($order[$suggested] ?? 0) > ($order[$current] ?? 0)) {
try {
$stageService->setStage($organization, $visit, 'dermatology', $suggested, $this->ownerRef($request), $this->ownerRef($request));
} catch (\InvalidArgumentException) {
}
}
}
if ($module === 'podiatry' && in_array($recordType, ['pod_history', 'foot_exam', 'pod_investigation', 'pod_plan'], true)) {
$workflow = app(\App\Services\Care\Podiatry\PodiatryWorkflowService::class);
$stageService = app(\App\Services\Care\SpecialtyVisitStageService::class);
$suggested = match ($recordType) {
'pod_history' => $workflow->stageFromHistory($record->payload ?? []),
'foot_exam' => $workflow->stageFromExam($record->payload ?? []),
'pod_investigation' => $workflow->stageFromInvestigation($record->payload ?? []),
'pod_plan' => $workflow->stageFromPlan($record->payload ?? []),
default => null,
};
$current = $visit->specialty_stage;
$early = ['check_in', 'waiting', null, ''];
$order = [
'check_in' => 0,
'history' => 1,
'exam' => 2,
'investigation' => 3,
'plan' => 4,
'procedure' => 5,
'completed' => 6,
];
if ($suggested && (! $current || in_array($current, $early, true))) {
try {
$stageService->setStage($organization, $visit, 'podiatry', $suggested, $this->ownerRef($request), $this->ownerRef($request));
} catch (\InvalidArgumentException) {
}
} elseif ($suggested && $suggested !== $current && ($order[$suggested] ?? 0) > ($order[$current] ?? 0)) {
try {
$stageService->setStage($organization, $visit, 'podiatry', $suggested, $this->ownerRef($request), $this->ownerRef($request));
} catch (\InvalidArgumentException) {
}
}
}
if ($module === 'fertility' && in_array($recordType, ['fert_history', 'fert_exam', 'fert_investigation', 'fert_plan'], true)) {
$workflow = app(\App\Services\Care\Fertility\FertilityWorkflowService::class);
$stageService = app(\App\Services\Care\SpecialtyVisitStageService::class);
$suggested = match ($recordType) {
'fert_history' => $workflow->stageFromHistory($record->payload ?? []),
'fert_exam' => $workflow->stageFromExam($record->payload ?? []),
'fert_investigation' => $workflow->stageFromInvestigation($record->payload ?? []),
'fert_plan' => $workflow->stageFromPlan($record->payload ?? []),
default => null,
};
$current = $visit->specialty_stage;
$early = ['check_in', 'waiting', null, ''];
$order = [
'check_in' => 0,
'history' => 1,
'exam' => 2,
'investigation' => 3,
'plan' => 4,
'cycle' => 5,
'completed' => 6,
];
if ($suggested && (! $current || in_array($current, $early, true))) {
try {
$stageService->setStage($organization, $visit, 'fertility', $suggested, $this->ownerRef($request), $this->ownerRef($request));
} catch (\InvalidArgumentException) {
}
} elseif ($suggested && $suggested !== $current && ($order[$suggested] ?? 0) > ($order[$current] ?? 0)) {
try {
$stageService->setStage($organization, $visit, 'fertility', $suggested, $this->ownerRef($request), $this->ownerRef($request));
} catch (\InvalidArgumentException) {
}
}
}
return redirect()
->route('care.specialty.workspace', [
'module' => $module,
@@ -1515,6 +1623,27 @@ class SpecialtyModuleController extends Controller
$infusionMonitoring = null;
$infusionStageCodes = [];
$infusionStageFlow = [];
$dermatologyHistory = null;
$dermatologyExam = null;
$dermatologyInvestigation = null;
$dermatologyPlan = null;
$dermatologyProcedure = null;
$dermatologyStageCodes = [];
$dermatologyStageFlow = [];
$podiatryHistory = null;
$podiatryExam = null;
$podiatryInvestigation = null;
$podiatryPlan = null;
$podiatryProcedure = null;
$podiatryStageCodes = [];
$podiatryStageFlow = [];
$fertilityHistory = null;
$fertilityExam = null;
$fertilityInvestigation = null;
$fertilityPlan = null;
$fertilityCycle = null;
$fertilityStageCodes = [];
$fertilityStageFlow = [];
$activeTab = (string) $request->query('tab', array_key_first($shell->workspaceTabs($module)) ?: 'overview');
$clinical = app(SpecialtyClinicalRecordService::class);
@@ -1767,6 +1896,36 @@ class SpecialtyModuleController extends Controller
$infusionStageFlow = app(\App\Services\Care\Infusion\InfusionWorkflowService::class)->stageFlow();
}
if ($module === 'dermatology') {
$dermatologyHistory = $clinical->findForVisit($workspaceVisit, 'dermatology', 'derm_history');
$dermatologyExam = $clinical->findForVisit($workspaceVisit, 'dermatology', 'skin_exam');
$dermatologyInvestigation = $clinical->findForVisit($workspaceVisit, 'dermatology', 'derm_investigation');
$dermatologyPlan = $clinical->findForVisit($workspaceVisit, 'dermatology', 'derm_plan');
$dermatologyProcedure = $clinical->findForVisit($workspaceVisit, 'dermatology', 'derm_procedure');
$dermatologyStageCodes = collect($shell->stages('dermatology'))->pluck('code')->all();
$dermatologyStageFlow = app(\App\Services\Care\Dermatology\DermatologyWorkflowService::class)->stageFlow();
}
if ($module === 'podiatry') {
$podiatryHistory = $clinical->findForVisit($workspaceVisit, 'podiatry', 'pod_history');
$podiatryExam = $clinical->findForVisit($workspaceVisit, 'podiatry', 'foot_exam');
$podiatryInvestigation = $clinical->findForVisit($workspaceVisit, 'podiatry', 'pod_investigation');
$podiatryPlan = $clinical->findForVisit($workspaceVisit, 'podiatry', 'pod_plan');
$podiatryProcedure = $clinical->findForVisit($workspaceVisit, 'podiatry', 'pod_procedure');
$podiatryStageCodes = collect($shell->stages('podiatry'))->pluck('code')->all();
$podiatryStageFlow = app(\App\Services\Care\Podiatry\PodiatryWorkflowService::class)->stageFlow();
}
if ($module === 'fertility') {
$fertilityHistory = $clinical->findForVisit($workspaceVisit, 'fertility', 'fert_history');
$fertilityExam = $clinical->findForVisit($workspaceVisit, 'fertility', 'fert_exam');
$fertilityInvestigation = $clinical->findForVisit($workspaceVisit, 'fertility', 'fert_investigation');
$fertilityPlan = $clinical->findForVisit($workspaceVisit, 'fertility', 'fert_plan');
$fertilityCycle = $clinical->findForVisit($workspaceVisit, 'fertility', 'fert_cycle');
$fertilityStageCodes = collect($shell->stages('fertility'))->pluck('code')->all();
$fertilityStageFlow = app(\App\Services\Care\Fertility\FertilityWorkflowService::class)->stageFlow();
}
if ($patientHeader !== null) {
$patientHeader['clinical_alerts'] = $clinicalAlerts;
}
@@ -1955,6 +2114,27 @@ class SpecialtyModuleController extends Controller
'infusionMonitoring' => $infusionMonitoring,
'infusionStageCodes' => $infusionStageCodes,
'infusionStageFlow' => $infusionStageFlow,
'dermatologyHistory' => $dermatologyHistory,
'dermatologyExam' => $dermatologyExam,
'dermatologyInvestigation' => $dermatologyInvestigation,
'dermatologyPlan' => $dermatologyPlan,
'dermatologyProcedure' => $dermatologyProcedure,
'dermatologyStageCodes' => $dermatologyStageCodes,
'dermatologyStageFlow' => $dermatologyStageFlow,
'podiatryHistory' => $podiatryHistory,
'podiatryExam' => $podiatryExam,
'podiatryInvestigation' => $podiatryInvestigation,
'podiatryPlan' => $podiatryPlan,
'podiatryProcedure' => $podiatryProcedure,
'podiatryStageCodes' => $podiatryStageCodes,
'podiatryStageFlow' => $podiatryStageFlow,
'fertilityHistory' => $fertilityHistory,
'fertilityExam' => $fertilityExam,
'fertilityInvestigation' => $fertilityInvestigation,
'fertilityPlan' => $fertilityPlan,
'fertilityCycle' => $fertilityCycle,
'fertilityStageCodes' => $fertilityStageCodes,
'fertilityStageFlow' => $fertilityStageFlow,
'queueStubs' => $modules->queueStubsFor($organization, $module),
'branchId' => $branchId,
'branchLabel' => $branchLabel,