public function testSpecificationIsTrue() { $questionnaire = new Questionnaire((new Person())->setGender(Person::GENDER_MALE)); $questionnaire->getDrinking()->setWhichDaysDoYouDrink('mon, tue, wed, thur')->setBingingFrequency(Drinking::BINGE_MONTHLY)->setDoYouDrink(Drinking::DOES_DRINK)->setWeekdayDrinks((new Drinks())->setSpiritsAmount(1)); $this->assertTrue(DrinkingDoesNotExceed14UnitsAWeekButHasBingedSpecification::isSatisfiedBy($questionnaire)); }
/** * @param Questionnaire $questionnaire */ protected function buildAmberDrinkingBehaviours(Questionnaire $questionnaire) { switch (true) { case DrinkingExceeds14UnitsAnd5DaysSpecification::isSatisfiedBy($questionnaire): $prefix = '_gt_14_units_gte_6_days'; break; case DrinkingExceeds14UnitsAndDoesNotExceed5DaysSpecification::isSatisfiedBy($questionnaire): $prefix = '_gt_14_units_lte_5_days'; break; case DrinkingExceeds5DaysButNot14UnitsSpecification::isSatisfiedBy($questionnaire): $prefix = '_lte_14_units_gte_6_days'; break; case DrinkingDoesNotExceed14UnitsAWeekButHasBingedSpecification::isSatisfiedBy($questionnaire): $prefix = '_lte_14_units_has_binge'; break; default: $prefix = '_gte_3_units_lte_2_days'; break; } if (RespondentIsMaleSpecification::isSatisfiedBy($questionnaire)) { $suffix = '_' . Person::GENDER_MALE; } else { $suffix = '_' . Person::GENDER_FEMALE; } $this->narrative->addMessages(self::SECTION_NAME, array(DrinkingNarrativeBuilder::SECTION_NAME => 'behaviours_drinking_amber' . $prefix . $suffix)); }
/** * @param Questionnaire $questionnaire * @return bool */ protected function ragIsAmber(Questionnaire $questionnaire) { switch (true) { case $this->isAmberDueToDaysGTE5AndLowerRiskGender($questionnaire): case DrinkingSpec\DrinkingDoesNotExceed14UnitsAWeekButHasBingedSpecification::isSatisfiedBy($questionnaire): case $this->isAmberDueToDayExceedsRiskUnits($questionnaire): case $this->isAmberDueToMoreThanThreeUnitsAndTwoOrFewerDays($questionnaire): case DrinkingSpec\DrinkingExceeds5DaysButNot14UnitsSpecification::isSatisfiedBy($questionnaire): case DrinkingSpec\DrinkingUnitsInLowerRiskForGenderSpecification::isSatisfiedBy($questionnaire): return true; default: return false; } }
/** * @param Questionnaire $questionnaire */ protected function buildAmberDrinkingNarrative(Questionnaire $questionnaire) { switch (true) { case DrinkingExceeds14UnitsAnd5DaysSpecification::isSatisfiedBy($questionnaire): $suffix = '_gt_14_units_gte_6_days'; break; case DrinkingExceeds14UnitsAndDoesNotExceed5DaysSpecification::isSatisfiedBy($questionnaire): $suffix = '_gt_14_units_lte_5_days'; break; case DrinkingExceeds5DaysButNot14UnitsSpecification::isSatisfiedBy($questionnaire): $suffix = '_lte_14_units_gte_6_days'; break; case DrinkingDoesNotExceed14UnitsAWeekButHasBingedSpecification::isSatisfiedBy($questionnaire): $suffix = '_lte_14_units_has_binge'; break; default: $suffix = '_gte_3_units_lte_2_days'; break; } $this->buildDrinkingBehaviours($questionnaire, RagScore::RAG_AMBER, $suffix); }