From cfd487565ec40ccbb1898fbe98a71b61a20e864a Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Wed, 11 Dec 2024 16:31:55 +0000 Subject: [PATCH 1/5] Add v1.2.0 feature flag This allows us to hide features for release 1.2.0 behind a feature flag and only enable it once we're able to release it. --- db/seeds.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 951adf6b33b0867be20e14de7d5cf59ff55b5571 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Wed, 11 Dec 2024 09:59:13 +0000 Subject: [PATCH 2/5] Remove highlight from AppPatientSummaryComponent This was only used in one place and it helps to keep this component simpler by removing it, instead the caller can clear any changes and that gives the caller more flexibility in terms of what changes get highlighted. --- app/components/app_patient_summary_component.rb | 12 ++---------- app/controllers/consent_forms_controller.rb | 3 ++- app/views/consent_forms/new_patient.html.erb | 4 +--- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/app/components/app_patient_summary_component.rb b/app/components/app_patient_summary_component.rb index 6a0dd0e6f..3480afa55 100644 --- a/app/components/app_patient_summary_component.rb +++ b/app/components/app_patient_summary_component.rb @@ -1,19 +1,13 @@ # frozen_string_literal: true class AppPatientSummaryComponent < ViewComponent::Base - def initialize( - patient, - show_parent_or_guardians: false, - change_links: {}, - highlight: true - ) + def initialize(patient, show_parent_or_guardians: false, change_links: {}) super @patient = patient @show_parent_or_guardians = show_parent_or_guardians @change_links = change_links - @highlight = highlight end def call @@ -171,8 +165,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..0d0878c81 100644 --- a/app/views/consent_forms/new_patient.html.erb +++ b/app/views/consent_forms/new_patient.html.erb @@ -12,9 +12,7 @@ <%= render AppCardComponent.new do |c| %> <% c.with_heading { "Child record" } %> - <%= render AppPatientSummaryComponent.new(@patient, - show_parent_or_guardians: true, - highlight: false) %> + <%= render AppPatientSummaryComponent.new(@patient, show_parent_or_guardians: true) %> <% end %> <%= render AppCardComponent.new do |c| From 4f9cc410921854da8b07ed0d484669d8e3eb9eac Mon Sep 17 00:00:00 2001 From: Paul Robert Lloyd Date: Thu, 12 Dec 2024 15:39:07 +0000 Subject: [PATCH 3/5] Add AppNoticeStatusComponent --- app/assets/stylesheets/_status.scss | 4 +++ app/components/app_notice_status_component.rb | 30 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 app/components/app_notice_status_component.rb 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 From c08f1362215ef85d781ea62e934d55bf6d38c43c Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Wed, 11 Dec 2024 10:28:20 +0000 Subject: [PATCH 4/5] Add AppPatientCardComponent This encapsulates the logic related to render a "Child record" card which is shown in a number of different places. --- app/components/app_patient_card_component.rb | 26 +++++++++++++++++++ .../app_patient_page_component.html.erb | 5 +--- .../app_patient_summary_component.rb | 5 ++-- app/views/consent_forms/new_patient.html.erb | 5 +--- app/views/patients/edit.html.erb | 8 +++--- .../patients/edit/nhs_number_merge.html.erb | 5 +--- app/views/patients/show.html.erb | 4 +-- app/views/vaccination_records/show.html.erb | 5 +--- .../app_patient_card_component_spec.rb | 15 +++++++++++ .../app_patient_page_component_spec.rb | 4 +-- 10 files changed, 53 insertions(+), 29 deletions(-) create mode 100644 app/components/app_patient_card_component.rb create mode 100644 spec/components/app_patient_card_component_spec.rb diff --git a/app/components/app_patient_card_component.rb b/app/components/app_patient_card_component.rb new file mode 100644 index 000000000..e5fcb61c0 --- /dev/null +++ b/app/components/app_patient_card_component.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class AppPatientCardComponent < ViewComponent::Base + erb_template <<-ERB + <%= render AppCardComponent.new do |card| %> + <% card.with_heading { "Child record" } %> + + <%= 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 3480afa55..0d96b497b 100644 --- a/app/components/app_patient_summary_component.rb +++ b/app/components/app_patient_summary_component.rb @@ -1,13 +1,12 @@ # frozen_string_literal: true class AppPatientSummaryComponent < ViewComponent::Base - def initialize(patient, show_parent_or_guardians: false, change_links: {}) + 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 + @show_parent_or_guardians = show_parent_or_guardians end def call diff --git a/app/views/consent_forms/new_patient.html.erb b/app/views/consent_forms/new_patient.html.erb index 0d0878c81..52a51e57d 100644 --- a/app/views/consent_forms/new_patient.html.erb +++ b/app/views/consent_forms/new_patient.html.erb @@ -10,10 +10,7 @@ <%= page_title %> <% end %> -<%= 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 { "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/spec/components/app_patient_card_component_spec.rb b/spec/components/app_patient_card_component_spec.rb new file mode 100644 index 000000000..b5c33edea --- /dev/null +++ b/spec/components/app_patient_card_component_spec.rb @@ -0,0 +1,15 @@ +# 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") } +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") } From 8bbdc2ab8dfc2c9ada891a6eec5bb75f25224f5c Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Wed, 11 Dec 2024 10:39:45 +0000 Subject: [PATCH 5/5] 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 e5fcb61c0..0e26664eb 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?(:"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, diff --git a/spec/components/app_patient_card_component_spec.rb b/spec/components/app_patient_card_component_spec.rb index b5c33edea..e5d1c5ddd 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(:"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