Skip to content

Commit 1bae08c

Browse files
colinxfleminglomky
andauthored
adjust initial call / appointment date period to diverge a little bit, for late callers (#3264)
* allow 60 day grace period from initial call * Update app/models/patient.rb Co-authored-by: ktipton <kathryn.tipton@gmail.com> --------- Co-authored-by: ktipton <kathryn.tipton@gmail.com>
1 parent 0c4c230 commit 1bae08c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

app/models/patient.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ def as_json
247247
private
248248

249249
def confirm_appointment_after_initial_call
250-
if appointment_date.present? && initial_call_date&.send(:>, appointment_date)
251-
errors.add(:appointment_date, 'must be after date of initial call')
250+
if appointment_date.present? && initial_call_date.present? && (initial_call_date - 60.days)&.send(:>, appointment_date)
251+
errors.add(:appointment_date, 'must be closer to the date of initial call')
252252
end
253253
end
254254

test/models/patient_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,19 @@ class PatientTest < ActiveSupport::TestCase
7979
end
8080
end
8181

82-
it 'should require appointment_date to be after initial_call_date' do
82+
it 'should require appointment_date to be reasonably after initial_call_date' do
8383
# when initial call date is nil
8484
@patient.appointment_date = '2016-05-01'
8585
@patient.initial_call_date = nil
8686
refute @patient.valid?
8787
# when initial call date is after appointment date
88-
@patient.initial_call_date = '2016-06-01'
88+
@patient.initial_call_date = '2016-09-01'
8989
refute @patient.valid?
9090
# when appointment date is nil
9191
@patient.appointment_date = nil
9292
assert @patient.valid?
9393
# when appointment date is after initial call date
94-
@patient.appointment_date = '2016-07-01'
94+
@patient.appointment_date = '2016-08-01'
9595
assert @patient.valid?
9696
end
9797

0 commit comments

Comments
 (0)