Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP-4407: Add child care assessment question (PLF-Q4) #7582

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module Providers
module ProceedingMeritsTask
class ChildCareAssessmentsController < ProviderBaseController
def show
@form = ChildCareAssessmentForm.new(model: child_care_assessment)
end

def update
@form = ChildCareAssessmentForm.new(form_params.merge(proceeding_id: proceeding.id))

if @form.assessed?
save_continue_or_draft(@form)
else
render :show unless update_task_save_continue_or_draft(proceeding.ccms_code.to_sym, :client_child_care_assessment)
end
end

private

def child_care_assessment
@child_care_assessment ||= proceeding.child_care_assessment || proceeding.build_child_care_assessment
end

def proceeding
@proceeding ||= Proceeding.find(params[:merits_task_list_id])
end

def legal_aid_application
@legal_aid_application ||= proceeding.legal_aid_application
end

def form_params
merge_with_model(child_care_assessment) do
params
.require(:proceeding_merits_task_child_care_assessment)
.permit(
:assessed,
)
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module Providers
module ProceedingMeritsTask
class ChildCareAssessmentForm < BaseForm
form_for ::ProceedingMeritsTask::ChildCareAssessment

attr_accessor :proceeding_id, :assessed

validates :assessed, inclusion: %w[true false], unless: :draft?

set_callback :save, :before, :sync_result_details

def assessed?
attributes["assessed"] == "true"
end

private

def sync_result_details
if assessed_changed?
attributes["result"] = nil
attributes["details"] = nil
end
end

def assessed_changed?
attributes["assessed"] != model.assessed.to_s
end
end
end
end
1 change: 1 addition & 0 deletions app/models/proceeding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Proceeding < ApplicationRecord

has_one :chances_of_success, class_name: "ProceedingMeritsTask::ChancesOfSuccess", dependent: :destroy
has_one :prohibited_steps, class_name: "ProceedingMeritsTask::ProhibitedSteps", dependent: :destroy
has_one :child_care_assessment, class_name: "ProceedingMeritsTask::ChildCareAssessment", dependent: :destroy

has_many :final_hearings, dependent: :destroy
has_many :proceeding_linked_children, class_name: "ProceedingMeritsTask::ProceedingLinkedChild", dependent: :destroy
Expand Down
5 changes: 5 additions & 0 deletions app/models/proceeding_merits_task/child_care_assessment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module ProceedingMeritsTask
class ChildCareAssessment < ApplicationRecord
belongs_to :proceeding
end
end
1 change: 1 addition & 0 deletions app/services/flow/flows/provider_merits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class ProviderMerits < FlowSteps
linked_children: Steps::ProviderMerits::LinkedChildrenStep,
specific_issue: Steps::ProviderMerits::SpecificIssueStep,
vary_order: Steps::ProviderMerits::VaryOrderStep,
child_care_assessments: Steps::ProviderMerits::ChildCareAssessmentStep,
is_client_biological_parent: Steps::ProviderMerits::BiologicalParentStep,
does_client_have_parental_responsibilities: Steps::ProviderMerits::ParentalResponsibilitiesStep,
is_client_child_subject: Steps::ProviderMerits::ChildSubjectStep,
Expand Down
1 change: 1 addition & 0 deletions app/services/flow/merits_loop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def convert_task_to_flow_name(task)
vary_order: :vary_order,
opponents_application: :opponents_application,
client_relationship_to_proceeding: :is_client_biological_parent,
client_child_care_assessment: :child_care_assessment,
}[task]
end

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module Flow
module Steps
module ProviderMerits
ChildCareAssessmentStep = Step.new(
path: lambda do |application|
proceeding = application.proceedings.find(application.provider_step_params["merits_task_list_id"])
Steps.urls.providers_merits_task_list_child_care_assessment_path(proceeding)
end,
forward: lambda do |application|
proceeding = application.proceedings.find(application.provider_step_params["merits_task_list_id"])
Flow::MeritsLoop.forward_flow(application, proceeding.ccms_code.to_sym)
# TODO: AP-5533 - should goto question 4b or CYA page
# if proceeding.child_care_assessment.assessed?
# :child_care_assessment_result
# else
# Flow::MeritsLoop.forward_flow(application, proceeding.ccms_code.to_sym)
# end
end,
check_answers: lambda do |_application|
:check_merits_answers
# TODO: AP-5533 - should goto question 4b or CYA page
# proceeding = application.proceedings.find(application.provider_step_params["merits_task_list_id"])
# if proceeding.child_care_assessment.assessed?
# :child_care_assessment_result
# else
# :check_merits_answers
# end
end,
)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<%= form_with(
model: @form,
url: providers_merits_task_list_child_care_assessment_path(@proceeding),
method: :patch,
local: true,
) do |form| %>

<%= page_template page_title: t(".h1-heading"),
head_title: "#{@proceeding.meaning} - " + t(".h1-heading"),
template: :basic,
form: do %>
<%= form.govuk_collection_radio_buttons :assessed,
yes_no_options(yes: t(".radio_hint_yes")),
:value, # value_method
:label, # text_method
:radio_hint, # hint_method
bold_labels: false,
caption: { text: @proceeding.meaning, size: "xl" },
legend: { text: content_for(:page_title), tag: "h1", size: "xl" },
hint: { text: t(".hint") } %>

<%= next_action_buttons(show_draft: true, form:) %>
<% end %>
<% end %>
4 changes: 4 additions & 0 deletions config/locales/en/activemodel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ en:
attributes:
details:
blank: Enter details of the changes since the original order was made
proceeding_merits_task/child_care_assessment:
attributes:
assessed:
inclusion: Select yes if the local authority has assessed your client's ability to care for the children involved
partner:
attributes:
date_of_birth:
Expand Down
7 changes: 7 additions & 0 deletions config/locales/en/providers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,11 @@ en:
show:
page_title: Check who your client is
paragraph: You must answer 'yes' to one of these questions. Check your answers and change the one that is wrong.
child_care_assessments:
show:
h1-heading: Has the local authority assessed your client's ability to care for the children involved?
radio_hint_yes: You'll need to upload supporting evidence later.
hint: For example, if your client is the grandparent, the local authority may check if they could be a suitable carer.
application_merits_task:
involved_children:
new:
Expand Down Expand Up @@ -1428,6 +1433,7 @@ en:
opponents_application_html: <span class="govuk-visually-hidden">%{proceeding} </span>Opponent application
vary_order_html: <span class="govuk-visually-hidden">%{proceeding} </span>Changes since original order was made
client_relationship_to_proceeding_html: <span class="govuk-visually-hidden">%{proceeding} </span>Who your client is in the proceeding
client_child_care_assessment_html: <span class="govuk-visually-hidden">%{proceeding} </span>Assessment of your client
states:
not_started: Not started
waiting_for_dependency: Cannot start yet
Expand Down Expand Up @@ -1457,6 +1463,7 @@ en:
client_relationship_to_proceeding: is_client_biological_parent
check_who_client_is: check_who_client_is
second_appeal: second_appeal
client_child_care_assessment: child_care_assessment
merits_reports:
show:
heading: Merits report
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@
resource :does_client_have_parental_responsibility, only: %i[show update]
resource :is_client_child_subject, only: %i[show update], controller: :is_client_child_subject, path: "is_client_a_child_subject_of_proceeding"
resource :check_who_client_is, only: %i[show update]
resource :child_care_assessment, only: %i[show update], path: "assessment_of_client"
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions db/anonymise/rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@
row_context[:field_1_val] = Faker::Lorem.paragraph(sentence_count: 2) unless original_value.eql?('\N')
end,
},
child_care_assessments: {
details: lambda do |original_value, row_context|
row_context[:field_1_val] = Faker::Lorem.paragraph(sentence_count: 2) unless original_value.eql?('\N')
end,
},
citizen_access_tokens: {},
debugs: {},
dependants: {
Expand Down
12 changes: 12 additions & 0 deletions db/migrate/20250114142619_create_child_care_assessments.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CreateChildCareAssessments < ActiveRecord::Migration[7.2]
def change
create_table :child_care_assessments, id: :uuid do |t|
t.belongs_to :proceeding, null: false, foreign_key: true, type: :uuid
t.boolean :assessed
t.boolean :result
t.string :details

t.timestamps
end
end
end
13 changes: 12 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.2].define(version: 2024_12_12_085816) do
ActiveRecord::Schema[7.2].define(version: 2025_01_14_142619) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
Expand Down Expand Up @@ -418,6 +418,16 @@
t.index ["proceeding_id"], name: "index_chances_of_successes_on_proceeding_id"
end

create_table "child_care_assessments", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "proceeding_id", null: false
t.boolean "assessed"
t.boolean "result"
t.string "details"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["proceeding_id"], name: "index_child_care_assessments_on_proceeding_id"
end

create_table "citizen_access_tokens", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "legal_aid_application_id", null: false
t.string "token", default: "", null: false
Expand Down Expand Up @@ -1139,6 +1149,7 @@
add_foreign_key "ccms_submissions", "legal_aid_applications", on_delete: :cascade
add_foreign_key "cfe_submissions", "legal_aid_applications"
add_foreign_key "chances_of_successes", "proceedings", on_delete: :cascade
add_foreign_key "child_care_assessments", "proceedings"
add_foreign_key "citizen_access_tokens", "legal_aid_applications", on_delete: :cascade
add_foreign_key "dependants", "legal_aid_applications"
add_foreign_key "domestic_abuse_summaries", "legal_aid_applications"
Expand Down
4 changes: 4 additions & 0 deletions spec/factories/legal_framework_merits_task_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
serialized_data { build(:legal_framework_serializable_merits_task_list, :pbm01a).to_yaml }
end

trait :pbm32_as_applicant do
serialized_data { build(:legal_framework_serializable_merits_task_list, :pbm32_as_applicant).to_yaml }
end

trait :broken_opponent do
serialized_data { build(:legal_framework_serializable_merits_task_list, :broken_opponent).to_yaml }
end
Expand Down
25 changes: 25 additions & 0 deletions spec/factories/legal_framework_serialized_merits_task_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,31 @@
end
end

trait :pbm32_as_applicant do
lfa_response do
{
request_id: SecureRandom.uuid,
application: {
tasks: {
opponent_name: [],
statement_of_case: [],
children_application: [],
},
},
proceedings: [
{
ccms_code: "PBM32",
tasks: {
children_proceeding: [:children_application],
chances_of_success: [],
client_child_care_assessment: [],
},
},
],
}
end
end

trait :broken_opponent do
lfa_response do
{
Expand Down
18 changes: 18 additions & 0 deletions spec/factories/proceeding_merits_task/child_care_assessments.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FactoryBot.define do
factory :child_care_assessment, class: "ProceedingMeritsTask::ChildCareAssessment" do
proceeding
assessed { false }

trait :negative_assessment do
assessed { true }
result { false }
details { Faker::Lorem.paragraph(sentence_count: 2) }
end

trait :positive_assessment do
assessed { true }
result { true }
details { nil }
end
end
end
19 changes: 19 additions & 0 deletions spec/factories/proceedings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -419,4 +419,23 @@
client_involvement_type_ccms_code { "A" }
client_involvement_type_description { "Applicant/Claimant/Petitioner" }
end

trait :pbm32 do
lead_proceeding { false }
ccms_code { "PBM32" }
meaning { "Special guardianship order" }
description { "to be represented on an application for a Special Guardianship Order" }
substantive_cost_limitation { 25_000 }
delegated_functions_cost_limitation { 2_250 }
used_delegated_functions { nil }
used_delegated_functions_on { nil }
used_delegated_functions_reported_on { nil }
name { "special_guardianship_order_plf" }
matter_type { "public law family (PLF)" }
category_of_law { "Family" }
category_law_code { "MAT" }
ccms_matter_code { "KPBLB" }
client_involvement_type_ccms_code { "A" }
client_involvement_type_description { "Applicant/Claimant/Petitioner" }
end
end
Loading
Loading