Skip to content

Commit

Permalink
Add flags to AppPatientCardComponent
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thomasleese committed Dec 13, 2024
1 parent c08f136 commit 8bbdc2a
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/components/app_patient_card_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ class AppPatientCardComponent < ViewComponent::Base
erb_template <<-ERB
<%= render AppCardComponent.new do |card| %>
<% card.with_heading { "Child record" } %>
<% if Flipper.enabled?(:"v1.2.0") %>
<% 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,
Expand Down
49 changes: 49 additions & 0 deletions spec/components/app_patient_card_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(:"v1.2.0") }
after { Flipper.enable(:"v1.2.0") }

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(:"v1.2.0") }
after { Flipper.enable(:"v1.2.0") }

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(:"v1.2.0") }
after { Flipper.enable(:"v1.2.0") }

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

0 comments on commit 8bbdc2a

Please sign in to comment.