@@ -11,8 +11,8 @@ class DraftVaccinationRecord
11
11
attribute :delivery_method , :string
12
12
attribute :delivery_site , :string
13
13
attribute :dose_sequence , :integer
14
+ attribute :first_active_wizard_step , :string
14
15
attribute :full_dose , :boolean
15
- attribute :protocol , :string
16
16
attribute :identity_check_confirmed_by_other_name , :string
17
17
attribute :identity_check_confirmed_by_other_relationship , :string
18
18
attribute :identity_check_confirmed_by_patient , :boolean
@@ -27,8 +27,9 @@ class DraftVaccinationRecord
27
27
attribute :performed_by_user_id , :integer
28
28
attribute :performed_ods_code , :string
29
29
attribute :programme_id , :integer
30
+ attribute :protocol , :string
30
31
attribute :session_id , :integer
31
- attribute :first_active_wizard_step , :string
32
+ attribute :supplied_by_user_id , :integer
32
33
33
34
def initialize ( current_user :, **attributes )
34
35
@current_user = current_user
@@ -47,6 +48,7 @@ def wizard_steps
47
48
:notes ,
48
49
:date_and_time ,
49
50
( :outcome if can_change_outcome? ) ,
51
+ ( :supplier if requires_supplied_by? ) ,
50
52
( :delivery if administered? ) ,
51
53
( :dose if administered? && can_be_half_dose? ) ,
52
54
( :batch if administered? ) ,
@@ -187,13 +189,27 @@ def programme=(value)
187
189
def session
188
190
return nil if session_id . nil?
189
191
190
- SessionPolicy ::Scope . new ( @current_user , Session ) . resolve . find ( session_id )
192
+ SessionPolicy ::Scope
193
+ . new ( @current_user , Session )
194
+ . resolve
195
+ . includes ( :programmes )
196
+ . find ( session_id )
191
197
end
192
198
193
199
def session = ( value )
194
200
self . session_id = value . id
195
201
end
196
202
203
+ def supplied_by
204
+ return nil if supplied_by_user_id . nil?
205
+
206
+ User . find ( supplied_by_user_id )
207
+ end
208
+
209
+ def supplied_by = ( value )
210
+ self . supplied_by_user_id = value . id
211
+ end
212
+
197
213
def vaccination_record
198
214
return nil if editing_id . nil?
199
215
@@ -272,7 +288,6 @@ def writable_attribute_names
272
288
delivery_site
273
289
dose_sequence
274
290
full_dose
275
- protocol
276
291
identity_check
277
292
location_id
278
293
location_name
@@ -285,7 +300,9 @@ def writable_attribute_names
285
300
performed_by_user_id
286
301
performed_ods_code
287
302
programme_id
303
+ protocol
288
304
session_id
305
+ supplied_by_user_id
289
306
vaccine_id
290
307
]
291
308
end
@@ -344,6 +361,10 @@ def can_change_outcome?
344
361
outcome != "already_had" || editing? || session . nil? || session . today?
345
362
end
346
363
364
+ def requires_supplied_by?
365
+ performed_by_user && !performed_by_user &.show_in_suppliers
366
+ end
367
+
347
368
def delivery_site_matches_delivery_method
348
369
return if delivery_method . blank?
349
370
0 commit comments