def create
authorize Triage
@triage_form =
TriageForm.new(
current_user:,
patient: @patient,
session: @session,
programme: @programme,
**triage_form_params
)
if (triage = @triage_form.save)
PatientStatusUpdater.call(patient: @patient)
ConsentGrouper
.call(
@patient.reload.consents.includes(:team),
programme_type: @programme.type,
academic_year: @academic_year
)
.each do |consent|
consent.notifier.send_confirmation(
session: @session,
triage:,
sent_by: current_user
)
end
redirect_to redirect_path, flash: { success: "Triage outcome updated" }
else
render :new, status: :unprocessable_entity
end
end