diff --git a/app/assets/stylesheets/_status.scss b/app/assets/stylesheets/_status.scss index d153a00d1..30a541779 100644 --- a/app/assets/stylesheets/_status.scss +++ b/app/assets/stylesheets/_status.scss @@ -12,6 +12,10 @@ color: $color_nhsuk-aqua-green; } + &--blue { + color: $color_nhsuk-blue; + } + &--dark-orange { color: $color_app-dark-orange; } diff --git a/app/components/app_notice_status_component.rb b/app/components/app_notice_status_component.rb new file mode 100644 index 000000000..68878d320 --- /dev/null +++ b/app/components/app_notice_status_component.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +class AppNoticeStatusComponent < ViewComponent::Base + def call + icon_warning @text, "blue" + end + + def initialize(text:) + super + + @text = text + end + + private + + def icon_warning(content, color) + template = <<-ERB +

+ + #{content} +

+ ERB + template.html_safe + end +end diff --git a/app/components/app_patient_card_component.rb b/app/components/app_patient_card_component.rb new file mode 100644 index 000000000..0e26664eb --- /dev/null +++ b/app/components/app_patient_card_component.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +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, + show_parent_or_guardians: true + ) %> + + <%= content %> + <% end %> + ERB + + def initialize(patient) + super + + @patient = patient + end + + private + + attr_reader :patient +end diff --git a/app/components/app_patient_page_component.html.erb b/app/components/app_patient_page_component.html.erb index 83136a4f5..5970419ec 100644 --- a/app/components/app_patient_page_component.html.erb +++ b/app/components/app_patient_page_component.html.erb @@ -10,10 +10,7 @@ render AppSimpleStatusBannerComponent.new(patient_session:) end %> -<%= render AppCardComponent.new do |c| %> - <% c.with_heading { "Child details" } %> - <%= render AppPatientSummaryComponent.new(patient, show_parent_or_guardians: true) %> -<% end %> +<%= render AppPatientCardComponent.new(patient) %> <% if display_gillick_assessment_card? %> <%= render AppCardComponent.new do |c| %> diff --git a/app/components/app_patient_summary_component.rb b/app/components/app_patient_summary_component.rb index 6a0dd0e6f..0d96b497b 100644 --- a/app/components/app_patient_summary_component.rb +++ b/app/components/app_patient_summary_component.rb @@ -1,19 +1,12 @@ # frozen_string_literal: true class AppPatientSummaryComponent < ViewComponent::Base - def initialize( - patient, - show_parent_or_guardians: false, - change_links: {}, - highlight: true - ) + def initialize(patient, change_links: {}, show_parent_or_guardians: false) super @patient = patient - - @show_parent_or_guardians = show_parent_or_guardians @change_links = change_links - @highlight = highlight + @show_parent_or_guardians = show_parent_or_guardians end def call @@ -171,8 +164,6 @@ def format_parent_or_guardians end def highlight_if(value, condition) - return value unless @highlight && condition - - tag.span value, class: "app-highlight" + condition ? tag.span(value, class: "app-highlight") : value end end diff --git a/app/controllers/consent_forms_controller.rb b/app/controllers/consent_forms_controller.rb index f3ced06f2..86e1fd4b8 100644 --- a/app/controllers/consent_forms_controller.rb +++ b/app/controllers/consent_forms_controller.rb @@ -46,7 +46,8 @@ def update_match end def new_patient - @patient = Patient.from_consent_form(@consent_form) + @patient = + Patient.from_consent_form(@consent_form).tap(&:clear_changes_information) render layout: "two_thirds" end diff --git a/app/views/consent_forms/new_patient.html.erb b/app/views/consent_forms/new_patient.html.erb index 2725e6eb5..52a51e57d 100644 --- a/app/views/consent_forms/new_patient.html.erb +++ b/app/views/consent_forms/new_patient.html.erb @@ -10,12 +10,7 @@ <%= page_title %> <% end %> -<%= render AppCardComponent.new do |c| %> - <% c.with_heading { "Child record" } %> - <%= render AppPatientSummaryComponent.new(@patient, - show_parent_or_guardians: true, - highlight: false) %> -<% end %> +<%= render AppPatientCardComponent.new(@patient) %> <%= render AppCardComponent.new do |c| c.with_heading { "Consent response" } diff --git a/app/views/patients/edit.html.erb b/app/views/patients/edit.html.erb index 21c093f1f..139f11908 100644 --- a/app/views/patients/edit.html.erb +++ b/app/views/patients/edit.html.erb @@ -9,13 +9,11 @@ <%= page_title %> <% end %> +<% change_links = { nhs_number: edit_nhs_number_patient_path(@patient) } %> + <%= render AppCardComponent.new do |card| %> <% card.with_heading { "Record details" } %> - <%= render AppPatientSummaryComponent.new( - @patient, - show_parent_or_guardians: true, - change_links: { nhs_number: edit_nhs_number_patient_path(@patient) }, - ) %> + <%= render AppPatientSummaryComponent.new(@patient, change_links:) %> <% end %> <%= govuk_button_link_to "Continue", patient_path(@patient) %> diff --git a/app/views/patients/edit/nhs_number_merge.html.erb b/app/views/patients/edit/nhs_number_merge.html.erb index f6883495d..420507631 100644 --- a/app/views/patients/edit/nhs_number_merge.html.erb +++ b/app/views/patients/edit/nhs_number_merge.html.erb @@ -13,10 +13,7 @@ Updating the NHS number for <%= @patient.full_name %> will merge their record with an existing record:

-<%= render AppCardComponent.new do |card| %> - <% card.with_heading { "Child record" } %> - <%= render AppPatientSummaryComponent.new(@existing_patient) %> -<% end %> +<%= render AppPatientCardComponent.new(@existing_patient) %> <%= form_with model: @patient, url: edit_nhs_number_merge_patient_path(@patient), method: :put do |f| %> <%= f.hidden_field :nhs_number, value: @existing_patient.nhs_number %> diff --git a/app/views/patients/show.html.erb b/app/views/patients/show.html.erb index 2bbe62633..25a992788 100644 --- a/app/views/patients/show.html.erb +++ b/app/views/patients/show.html.erb @@ -14,9 +14,7 @@ nav.with_item(href: log_patient_path(@patient), text: "Activity log") end %> -<%= render AppCardComponent.new do |c| %> - <% c.with_heading { "Child record" } %> - <%= render AppPatientSummaryComponent.new(@patient, show_parent_or_guardians: true) %> +<%= render AppPatientCardComponent.new(@patient) do %> <%= govuk_button_link_to "Edit child record", edit_patient_path(@patient), class: "app-button--secondary" %> <% end %> diff --git a/app/views/vaccination_records/show.html.erb b/app/views/vaccination_records/show.html.erb index 46617de35..5b1d17d39 100644 --- a/app/views/vaccination_records/show.html.erb +++ b/app/views/vaccination_records/show.html.erb @@ -8,10 +8,7 @@ <%= h1 @patient.full_name %> -<%= render AppCardComponent.new do |c| %> - <% c.with_heading { "Child record" } %> - <%= render AppPatientSummaryComponent.new(@patient, show_parent_or_guardians: true) %> -<% end %> +<%= render AppPatientCardComponent.new(@patient) %> <%= render AppCardComponent.new do |c| %> <% c.with_heading { "Vaccination details" } %> diff --git a/db/seeds.rb b/db/seeds.rb index a5b38fa02..27b1f5c5d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -8,7 +8,7 @@ Faker::Config.locale = "en-GB" def set_feature_flags - %i[dev_tools mesh_jobs cis2].each do |feature_flag| + %i[dev_tools mesh_jobs cis2 v1.2.0].each do |feature_flag| Flipper.add(feature_flag) unless Flipper.exist?(feature_flag) end end diff --git a/spec/components/app_patient_card_component_spec.rb b/spec/components/app_patient_card_component_spec.rb new file mode 100644 index 000000000..e5d1c5ddd --- /dev/null +++ b/spec/components/app_patient_card_component_spec.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +describe AppPatientCardComponent do + subject(:rendered) { render_inline(component) } + + let(:component) { described_class.new(patient) } + + let(:patient) { create(:patient) } + + it { should have_content("Child record") } + + 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 diff --git a/spec/components/app_patient_page_component_spec.rb b/spec/components/app_patient_page_component_spec.rb index af30349c6..8b5bc3810 100644 --- a/spec/components/app_patient_page_component_spec.rb +++ b/spec/components/app_patient_page_component_spec.rb @@ -34,7 +34,7 @@ ) end - it { should have_css(".nhsuk-card__heading", text: "Child details") } + it { should have_css(".nhsuk-card__heading", text: "Child record") } it { should have_css(".nhsuk-card__heading", text: "Consent") } it { should_not have_css(".nhsuk-card__heading", text: "Triage notes") } @@ -77,7 +77,7 @@ ) end - it { should have_css(".nhsuk-card__heading", text: "Child details") } + it { should have_css(".nhsuk-card__heading", text: "Child record") } it { should have_css(".nhsuk-card__heading", text: "Consent") } it { should have_css(".nhsuk-card__heading", text: "Triage notes") }