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

adjust initial call / appointment date period to diverge a little bit, for late callers #3264

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion app/models/patient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def as_json
private

def confirm_appointment_after_initial_call
if appointment_date.present? && initial_call_date&.send(:>, appointment_date)
if appointment_date.present? && initial_call_date.present? && (initial_call_date - 60.days)&.send(:>, appointment_date)
errors.add(:appointment_date, 'must be after date of initial call')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we reword this error?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
errors.add(:appointment_date, 'must be after date of initial call')
errors.add(:appointment_date, 'must be closer to the date of initial call')

maybe?

end
end
Expand Down
6 changes: 3 additions & 3 deletions test/models/patient_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ class PatientTest < ActiveSupport::TestCase
end
end

it 'should require appointment_date to be after initial_call_date' do
it 'should require appointment_date to be reasonably after initial_call_date' do
# when initial call date is nil
@patient.appointment_date = '2016-05-01'
@patient.initial_call_date = nil
refute @patient.valid?
# when initial call date is after appointment date
@patient.initial_call_date = '2016-06-01'
@patient.initial_call_date = '2016-09-01'
refute @patient.valid?
# when appointment date is nil
@patient.appointment_date = nil
assert @patient.valid?
# when appointment date is after initial call date
@patient.appointment_date = '2016-07-01'
@patient.appointment_date = '2016-08-01'
assert @patient.valid?
end

Expand Down
Loading