Skip to content

Commit

Permalink
VACMS-17114: Refactors office visits logic to be more ... logical
Browse files Browse the repository at this point in the history
  • Loading branch information
omahane committed Feb 16, 2024
1 parent 55b5126 commit f590996
Showing 1 changed file with 35 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,40 @@ protected function getOnlineScheduling(string $online_scheduling_avail) {
return $map[$online_scheduling_avail];
}

/**
* Finds the best way to visit, among options chosen.
*
* @param string $office_visits
* The machine value of the Office visits option.
*/
protected function chooseBestOfficeVisitOption(string $office_visits) {
switch ($office_visits) {

case 'yes_with_or_without_appointment':
$text = $office_visits;
break;

case 'yes_first_come_first_served_basis':
case 'yes_appointment_only':
$text = ($this->officeVisits === 'yes_with_or_without_appointment')
? $this->officeVisits
: $office_visits;
break;

case 'no':
$text = ($this->officeVisits === 'yes_with_or_without_appointment'
|| $this->officeVisits === 'yes_first_come_first_served_basis'
|| $this->officeVisits === 'yes_appointment_only')
? $this->officeVisits
: $office_visits;
break;

default:
$text = $office_visits;
}
return $this->stringNullify($text);
}

/**
* Builds the array of service locations.
*
Expand Down Expand Up @@ -380,10 +414,7 @@ protected function getServiceLocations(): array {

// Set the office visits policy to non-default for the service.
$office_visits = $location->get('field_office_visits')->value;
$this->officeVisits = (($this->officeVisits !== "yes_with_or_without_appointment")
|| !isset($this->officeVisits))
? $this->stringNullify($office_visits)
: $this->officeVisits;
$this->officeVisits = $this->chooseBestOfficeVisitOption($office_visits);

// Set the appointment text values to the non-default for the service.
$field_appt_intro_text_type = $location->get('field_appt_intro_text_type')->value;
Expand Down

0 comments on commit f590996

Please sign in to comment.