File tree Expand file tree Collapse file tree 3 files changed +23
-23
lines changed Expand file tree Collapse file tree 3 files changed +23
-23
lines changed Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ module PatientAttendanceValidation
4
+ extend ActiveSupport ::Concern
5
+
6
+ private
7
+
8
+ def patient_attended_session
9
+ return if session . nil? || patient . nil?
10
+
11
+ unless patient . attending? ( session :) || patient . completed? ( session :)
12
+ date = performed_at . to_date
13
+ errors . add ( :session_id , :patient_not_attending ,
14
+ patient_full_name : patient . full_name ,
15
+ display_date : date . today? ? "Today (#{ date . to_fs ( :long ) } )" : date . to_fs ( :long ) ,
16
+ location_name : location [ :name ]
17
+ )
18
+ end
19
+ end
20
+ end
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ class DraftVaccinationRecord
4
4
include RequestSessionPersistable
5
5
include EditableWrapper
6
6
include HasDoseVolume
7
+ include PatientAttendanceValidation
7
8
include VaccinationRecordPerformedByConcern
8
9
include WizardStepConcern
9
10
@@ -213,16 +214,5 @@ def can_change_outcome?
213
214
outcome != "already_had" || editing? || session . nil? || session . today?
214
215
end
215
216
216
- def patient_attended_session
217
- return if patient . nil? || session . nil?
218
217
219
- unless patient . attending? ( session :) || patient . completed? ( session :)
220
- date = performed_at . to_date
221
- errors . add ( :session_id , :patient_not_attending ,
222
- patient_full_name : patient . full_name ,
223
- display_date : date . today? ? "Today (#{ date . to_fs ( :long ) } )" : date . to_fs ( :long ) ,
224
- location_name : location [ :name ]
225
- )
226
- end
227
- end
228
218
end
Original file line number Diff line number Diff line change 52
52
class VaccinationRecord < ApplicationRecord
53
53
include Discard ::Model
54
54
include HasDoseVolume
55
+ include PatientAttendanceValidation
55
56
include PendingChangesConcern
56
57
include VaccinationRecordPerformedByConcern
57
58
@@ -186,18 +187,7 @@ def requires_location_name?
186
187
session . nil? || location &.generic_clinic?
187
188
end
188
189
189
- def patient_attended_session
190
- return if session . nil? || patient . nil?
191
-
192
- unless patient . attending? ( session :) || patient . completed? ( session :)
193
- date = performed_at . to_date
194
- errors . add ( :session_id , :patient_not_attending ,
195
- patient_full_name : patient . full_name ,
196
- display_date : date . today? ? "Today (#{ date . to_fs ( :long ) } )" : date . to_fs ( :long ) ,
197
- location_name : location [ :name ]
198
- )
199
- end
200
- end
190
+
201
191
202
192
delegate :maximum_dose_sequence , to : :programme
203
193
end
You can’t perform that action at this time.
0 commit comments