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 11, 2024
1 parent 708510a commit 58e8794
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/assets/stylesheets/_warning_text.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.govuk-warning-text__icon {
background: $color_nhsuk-blue;
border: 3px solid $color_nhsuk-blue;
}

.govuk-warning-text__text {
color: $color_nhsuk-blue;
}
2 changes: 2 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ $govuk-assets-path: "/";
@import "govuk-frontend/dist/govuk/components/notification-banner/index";
@import "govuk-frontend/dist/govuk/components/pagination/index";
@import "govuk-frontend/dist/govuk/components/panel/index";
@import "govuk-frontend/dist/govuk/components/warning-text/index";

// Configure and import NHS.UK Frontend
$nhsuk-fonts-path: "/";
Expand Down Expand Up @@ -65,6 +66,7 @@ $color_app-dark-orange: color.scale(
@import "tag";
@import "typography";
@import "utilities";
@import "warning_text";

// Fix checkbox check sizing
.nhsuk-checkboxes__label::after {
Expand Down
14 changes: 14 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,20 @@ 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? %>
<%= govuk_warning_text(text: "Record updated with child’s date of death") %>
<% end %>
<% if @patient.invalidated? %>
<%= govuk_warning_text(text: "Record flagged as invalid") %>
<% end %>
<% if @patient.restricted? %>
<%= govuk_warning_text(text: "Record flagged as sensitive") %>
<% end %>
<% end %>
<%= render AppPatientSummaryComponent.new(
patient,
Expand Down
3 changes: 2 additions & 1 deletion config/initializers/govuk_components.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
config.brand_overrides = {
"GovukComponent::NotificationBannerComponent" => "govuk",
"GovukComponent::PaginationComponent" => "govuk",
"GovukComponent::PanelComponent" => "govuk"
"GovukComponent::PanelComponent" => "govuk",
"GovukComponent::WarningTextComponent" => "govuk"
}
end
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(: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

0 comments on commit 58e8794

Please sign in to comment.