Deploy Ladill Care / deploy (push) Successful in 43s
Mirror Cardiology-depth stage flows, workspace tabs, reports/print, clinical alerts, demo seeds, and PHPUnit coverage for child health, fracture clinic, and ENT pathways. Co-authored-by: Cursor <cursoragent@cursor.com>
105 lines
2.8 KiB
PHP
105 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Care\Orthopedics;
|
|
|
|
/**
|
|
* Map orthopedics clinical progress onto visit stages.
|
|
*/
|
|
class OrthopedicsWorkflowService
|
|
{
|
|
public const STAGE_CHECK_IN = 'check_in';
|
|
|
|
public const STAGE_HISTORY = 'history';
|
|
|
|
public const STAGE_EXAM = 'exam';
|
|
|
|
public const STAGE_IMAGING = 'imaging';
|
|
|
|
public const STAGE_PLAN = 'plan';
|
|
|
|
public const STAGE_PROCEDURE = 'procedure';
|
|
|
|
public const STAGE_COMPLETED = 'completed';
|
|
|
|
/**
|
|
* @param array<string, mixed> $payload
|
|
*/
|
|
public function stageFromHistory(array $payload): string
|
|
{
|
|
$history = trim((string) ($payload['history'] ?? ''));
|
|
if ($history !== '') {
|
|
return self::STAGE_HISTORY;
|
|
}
|
|
|
|
return self::STAGE_CHECK_IN;
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $payload
|
|
*/
|
|
public function stageFromExam(array $payload): string
|
|
{
|
|
if (! empty($payload['region']) || ! empty($payload['chief_complaint'])) {
|
|
return self::STAGE_EXAM;
|
|
}
|
|
|
|
return self::STAGE_HISTORY;
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $payload
|
|
*/
|
|
public function stageFromImaging(array $payload): string
|
|
{
|
|
$findings = trim((string) ($payload['findings'] ?? ''));
|
|
if ($findings !== '') {
|
|
return self::STAGE_IMAGING;
|
|
}
|
|
|
|
return self::STAGE_EXAM;
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $payload
|
|
*/
|
|
public function stageFromPlan(array $payload): string
|
|
{
|
|
if (! empty($payload['procedure_planned'])) {
|
|
return self::STAGE_PROCEDURE;
|
|
}
|
|
|
|
$plan = trim((string) ($payload['plan'] ?? ''));
|
|
if ($plan !== '') {
|
|
return self::STAGE_PLAN;
|
|
}
|
|
|
|
return self::STAGE_IMAGING;
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $payload
|
|
*/
|
|
public function shouldCompleteVisit(array $payload): bool
|
|
{
|
|
$outcome = strtolower((string) ($payload['outcome'] ?? ''));
|
|
|
|
return str_contains($outcome, 'completed');
|
|
}
|
|
|
|
/**
|
|
* @return array<string, array{next: string, label: string}>
|
|
*/
|
|
public function stageFlow(): array
|
|
{
|
|
return [
|
|
self::STAGE_CHECK_IN => ['next' => self::STAGE_HISTORY, 'label' => 'Start history'],
|
|
self::STAGE_HISTORY => ['next' => self::STAGE_EXAM, 'label' => 'Move to exam'],
|
|
self::STAGE_EXAM => ['next' => self::STAGE_IMAGING, 'label' => 'Move to imaging'],
|
|
self::STAGE_IMAGING => ['next' => self::STAGE_PLAN, 'label' => 'Move to diagnosis & plan'],
|
|
self::STAGE_PLAN => ['next' => self::STAGE_PROCEDURE, 'label' => 'Move to procedure / cast'],
|
|
self::STAGE_PROCEDURE => ['next' => self::STAGE_COMPLETED, 'label' => 'Complete visit'],
|
|
self::STAGE_COMPLETED => ['next' => self::STAGE_COMPLETED, 'label' => 'Completed'],
|
|
];
|
|
}
|
|
}
|