Add full Vaccination, Pathology, and Infusion specialty clinical suites.
Deploy Ladill Care / deploy (push) Successful in 34s
Deploy Ladill Care / deploy (push) Successful in 34s
Mirror Oncology-depth stage flows, workspace controllers, clinical forms, reports/print, demo seed, and suite tests. Pathology stays clinic specialty complementary to the Lab app. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Care\Vaccination;
|
||||
|
||||
/**
|
||||
* Map vaccination clinical progress onto visit stages.
|
||||
*/
|
||||
class VaccinationWorkflowService
|
||||
{
|
||||
public const STAGE_CHECK_IN = 'check_in';
|
||||
|
||||
public const STAGE_ELIGIBILITY = 'eligibility';
|
||||
|
||||
public const STAGE_CONSENT = 'consent';
|
||||
|
||||
public const STAGE_ADMINISTER = 'administer';
|
||||
|
||||
public const STAGE_OBSERVATION = 'observation';
|
||||
|
||||
public const STAGE_COMPLETED = 'completed';
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $payload
|
||||
*/
|
||||
public function stageFromEligibility(array $payload): string
|
||||
{
|
||||
if (! empty($payload['cleared']) || ! empty($payload['vaccine'])) {
|
||||
return self::STAGE_ELIGIBILITY;
|
||||
}
|
||||
|
||||
return self::STAGE_CHECK_IN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $payload
|
||||
*/
|
||||
public function stageFromConsent(array $payload): string
|
||||
{
|
||||
if (! empty($payload['consent_obtained'])) {
|
||||
return self::STAGE_ADMINISTER;
|
||||
}
|
||||
|
||||
if (! empty($payload['information_given'])) {
|
||||
return self::STAGE_CONSENT;
|
||||
}
|
||||
|
||||
return self::STAGE_ELIGIBILITY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $payload
|
||||
*/
|
||||
public function stageFromAdmin(array $payload): string
|
||||
{
|
||||
$outcome = strtolower((string) ($payload['outcome'] ?? ''));
|
||||
if (str_contains($outcome, 'completed') || ! empty($payload['batch'])) {
|
||||
return self::STAGE_OBSERVATION;
|
||||
}
|
||||
|
||||
return self::STAGE_ADMINISTER;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $payload
|
||||
*/
|
||||
public function stageFromObservation(array $payload): string
|
||||
{
|
||||
if ($this->shouldCompleteVisit($payload)) {
|
||||
return self::STAGE_COMPLETED;
|
||||
}
|
||||
|
||||
$aefi = strtolower((string) ($payload['aefi'] ?? ''));
|
||||
if ($aefi !== '' || ! empty($payload['outcome'])) {
|
||||
return self::STAGE_OBSERVATION;
|
||||
}
|
||||
|
||||
return self::STAGE_ADMINISTER;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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_ELIGIBILITY, 'label' => 'Start eligibility'],
|
||||
self::STAGE_ELIGIBILITY => ['next' => self::STAGE_CONSENT, 'label' => 'Move to consent'],
|
||||
self::STAGE_CONSENT => ['next' => self::STAGE_ADMINISTER, 'label' => 'Move to administer'],
|
||||
self::STAGE_ADMINISTER => ['next' => self::STAGE_OBSERVATION, 'label' => 'Move to observation'],
|
||||
self::STAGE_OBSERVATION => ['next' => self::STAGE_COMPLETED, 'label' => 'Complete visit'],
|
||||
self::STAGE_COMPLETED => ['next' => self::STAGE_COMPLETED, 'label' => 'Completed'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user