Skip to content

Commit e935ac1

Browse files
committed
Only consider today's Gillick assessments as valid
Gillick assessments are only considered valid for the day that they were recorded on. Outside of that, the child needs to be re-assessed before they can self-consent. Jira-Issue: MAV-5915
1 parent e8624fb commit e935ac1

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

app/controllers/draft_consents_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def set_new_or_existing_contact_options
232232
@new_or_existing_contact_options = []
233233

234234
if @patient.can_self_consent_after_gillick_assessment?(
235-
session: @session,
235+
location: @session.location,
236236
programme_type: @programme.type
237237
)
238238
@new_or_existing_contact_options << NewOrExistingContactOption.new(

app/models/patient.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,9 @@ def show_year_group?(team:)
547547
end
548548
end
549549

550-
def can_self_consent_after_gillick_assessment?(session:, programme_type:)
550+
def can_self_consent_after_gillick_assessment?(location:, programme_type:)
551551
gillick_assessments
552-
.for_session(session)
553-
.where(programme_type:)
552+
.where(location:, programme_type:, date: Date.current)
554553
.order(created_at: :desc)
555554
&.first
556555
&.gillick_competent? || false

spec/models/patient_spec.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@
911911
describe "#can_self_consent_after_gillick_assessment?" do
912912
subject(:can_self_consent_after_gillick_assessment) do
913913
patient.can_self_consent_after_gillick_assessment?(
914-
session:,
914+
location: session.location,
915915
programme_type: programme.type
916916
)
917917
end
@@ -956,6 +956,21 @@
956956
it { should be(false) }
957957
end
958958

959+
context "when patient has a Gillick assessment on a different date" do
960+
before do
961+
create(
962+
:gillick_assessment,
963+
:competent,
964+
patient:,
965+
programme_type: programme.type,
966+
session:,
967+
date: Date.yesterday
968+
)
969+
end
970+
971+
it { should be(false) }
972+
end
973+
959974
context "when patient has a not competent Gillick assessment" do
960975
before do
961976
create(

0 commit comments

Comments
 (0)