From fbf7defde45cf9916fd58bebdce42f592da963e2 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Wed, 11 Dec 2024 10:39:45 +0000 Subject: [PATCH] Add flags to AppPatientCardComponent This adds a number of flags to the component when viewing a "child record" allowing the nurses to see clearly if there are any flags on the patient. --- app/components/app_patient_card_component.rb | 20 ++++++++ .../app_patient_card_component_spec.rb | 49 +++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/app/components/app_patient_card_component.rb b/app/components/app_patient_card_component.rb index e5fcb61c04..22b80661f2 100644 --- a/app/components/app_patient_card_component.rb +++ b/app/components/app_patient_card_component.rb @@ -4,6 +4,26 @@ class AppPatientCardComponent < ViewComponent::Base erb_template <<-ERB <%= render AppCardComponent.new do |card| %> <% card.with_heading { "Child record" } %> + + <% if Flipper.enabled?(:release_1_2) %> + <% if @patient.date_of_death.present? %> + <%= render AppNoticeStatusComponent.new( + text: "Record updated with child’s date of death" + ) %> + <% end %> + + <% if @patient.invalidated? %> + <%= render AppNoticeStatusComponent.new( + text: "Record flagged as invalid" + ) %> + <% end %> + + <% if @patient.restricted? %> + <%= render AppNoticeStatusComponent.new( + text: "Record flagged as sensitive" + ) %> + <% end %> + <% end %> <%= render AppPatientSummaryComponent.new( patient, diff --git a/spec/components/app_patient_card_component_spec.rb b/spec/components/app_patient_card_component_spec.rb index b5c33edea1..0fa205e78f 100644 --- a/spec/components/app_patient_card_component_spec.rb +++ b/spec/components/app_patient_card_component_spec.rb @@ -12,4 +12,53 @@ it { should have_content("Full name") } it { should have_content("Date of birth") } it { should have_content("Address") } + + context "with a deceased patient" do + let(:patient) { create(:patient, :deceased) } + + context "with feature flag enabled" do + before { Flipper.enable(:release_1_2) } + after { Flipper.enable(:release_1_2) } + + it { should have_content("Record updated with child’s date of death") } + end + + context "without feature flag enabled" do + it do + expect(rendered).not_to have_content( + "Record updated with child’s date of death" + ) + end + end + end + + context "with an invalidated patient" do + let(:patient) { create(:patient, :invalidated) } + + context "with feature flag enabled" do + before { Flipper.enable(:release_1_2) } + after { Flipper.enable(:release_1_2) } + + it { should have_content("Record flagged as invalid") } + end + + context "without feature flag enabled" do + it { should_not have_content("Record flagged as invalid") } + end + end + + context "with a restricted patient" do + let(:patient) { create(:patient, :restricted) } + + context "with feature flag enabled" do + before { Flipper.enable(:release_1_2) } + after { Flipper.enable(:release_1_2) } + + it { should have_content("Record flagged as sensitive") } + end + + context "without feature flag enabled" do + it { should_not have_content("Record flagged as sensitive") } + end + end end