|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +describe HealthAnswersDeduplicator do |
| 4 | + subject(:health_answers) { described_class.call(vaccines:) } |
| 5 | + |
| 6 | + let(:vaccines) { Vaccine.where(programme: programmes) } |
| 7 | + |
| 8 | + context "with doubles programmes" do |
| 9 | + let(:programmes) do |
| 10 | + [create(:programme, :menacwy), create(:programme, :td_ipv)] |
| 11 | + end |
| 12 | + |
| 13 | + it "generates the correct health answers" do |
| 14 | + expect(health_answers.count).to eq(6) |
| 15 | + |
| 16 | + expect(health_answers[0].question).to eq( |
| 17 | + "Does your child have a bleeding disorder or another medical condition they receive treatment for?" |
| 18 | + ) |
| 19 | + expect(health_answers[0].next_question).to eq(1) |
| 20 | + expect(health_answers[0].follow_up_question).to be_nil |
| 21 | + |
| 22 | + expect(health_answers[1].question).to eq( |
| 23 | + "Does your child have any severe allergies?" |
| 24 | + ) |
| 25 | + expect(health_answers[1].next_question).to eq(2) |
| 26 | + expect(health_answers[1].follow_up_question).to be_nil |
| 27 | + |
| 28 | + expect(health_answers[2].question).to eq( |
| 29 | + "Has your child ever had a severe reaction to any medicines, including vaccines?" |
| 30 | + ) |
| 31 | + expect(health_answers[2].next_question).to eq(3) |
| 32 | + expect(health_answers[2].follow_up_question).to be_nil |
| 33 | + |
| 34 | + expect(health_answers[3].question).to eq( |
| 35 | + "Does your child need extra support during vaccination sessions?" |
| 36 | + ) |
| 37 | + expect(health_answers[3].next_question).to eq(4) |
| 38 | + expect(health_answers[3].follow_up_question).to be_nil |
| 39 | + |
| 40 | + expect(health_answers[4].question).to eq( |
| 41 | + "Has your child had a meningitis (MenACWY) vaccination in the last 5 years?" |
| 42 | + ) |
| 43 | + expect(health_answers[4].next_question).to eq(5) |
| 44 | + expect(health_answers[4].follow_up_question).to be_nil |
| 45 | + |
| 46 | + expect(health_answers[5].question).to eq( |
| 47 | + "Has your child had a tetanus, diphtheria and polio vaccination in the last 5 years?" |
| 48 | + ) |
| 49 | + expect(health_answers[5].next_question).to be_nil |
| 50 | + expect(health_answers[5].follow_up_question).to be_nil |
| 51 | + end |
| 52 | + end |
| 53 | + |
| 54 | + context "with a Flu programme" do |
| 55 | + let(:programmes) { [create(:programme, :flu_all_vaccines)] } |
| 56 | + |
| 57 | + it "generates the correct health answers" do |
| 58 | + expect(health_answers.count).to eq(10) |
| 59 | + |
| 60 | + expect(health_answers[0].question).to eq( |
| 61 | + "Has your child been diagnosed with asthma?" |
| 62 | + ) |
| 63 | + expect(health_answers[0].next_question).to eq(3) |
| 64 | + expect(health_answers[0].follow_up_question).to eq(1) |
| 65 | + |
| 66 | + expect(health_answers[1].question).to eq( |
| 67 | + "Have they taken oral steroids in the last 2 weeks?" |
| 68 | + ) |
| 69 | + expect(health_answers[1].next_question).to eq(2) |
| 70 | + expect(health_answers[1].follow_up_question).to be_nil |
| 71 | + |
| 72 | + expect(health_answers[2].question).to eq( |
| 73 | + "Have they been admitted to intensive care for their asthma?" |
| 74 | + ) |
| 75 | + expect(health_answers[2].next_question).to eq(3) |
| 76 | + expect(health_answers[2].follow_up_question).to be_nil |
| 77 | + |
| 78 | + expect(health_answers[3].question).to eq( |
| 79 | + "Has your child had a flu vaccination in the last 5 months?" |
| 80 | + ) |
| 81 | + expect(health_answers[3].next_question).to eq(4) |
| 82 | + expect(health_answers[3].follow_up_question).to be_nil |
| 83 | + |
| 84 | + expect(health_answers[4].question).to eq( |
| 85 | + "Does your child have a disease or treatment that severely affects their immune system?" |
| 86 | + ) |
| 87 | + expect(health_answers[4].next_question).to eq(5) |
| 88 | + expect(health_answers[4].follow_up_question).to be_nil |
| 89 | + |
| 90 | + expect(health_answers[5].question).to eq( |
| 91 | + "Is anyone in your household currently having treatment that severely affects their immune system?" |
| 92 | + ) |
| 93 | + expect(health_answers[5].next_question).to eq(6) |
| 94 | + expect(health_answers[5].follow_up_question).to be_nil |
| 95 | + |
| 96 | + expect(health_answers[6].question).to eq( |
| 97 | + "Has your child ever been admitted to intensive care due to an allergic reaction to egg?" |
| 98 | + ) |
| 99 | + expect(health_answers[6].next_question).to eq(7) |
| 100 | + expect(health_answers[6].follow_up_question).to be_nil |
| 101 | + |
| 102 | + expect(health_answers[7].question).to eq( |
| 103 | + "Does your child have any allergies to medication?" |
| 104 | + ) |
| 105 | + expect(health_answers[7].next_question).to eq(8) |
| 106 | + expect(health_answers[7].follow_up_question).to be_nil |
| 107 | + |
| 108 | + expect(health_answers[8].question).to eq( |
| 109 | + "Has your child ever had a reaction to previous vaccinations?" |
| 110 | + ) |
| 111 | + expect(health_answers[8].next_question).to eq(9) |
| 112 | + expect(health_answers[8].follow_up_question).to be_nil |
| 113 | + |
| 114 | + expect(health_answers[9].question).to eq( |
| 115 | + "Does you child take regular aspirin?" |
| 116 | + ) |
| 117 | + expect(health_answers[9].next_question).to be_nil |
| 118 | + expect(health_answers[9].follow_up_question).to be_nil |
| 119 | + end |
| 120 | + end |
| 121 | +end |
0 commit comments