<commit_before>class ModalitiesController < ApplicationController

  before_filter :find_patient

  def new
    @modality = Modality.new(patient: @patient)
  end

  def index
    @modalities = @patient.modalities.with_deleted.order('termination_date DESC')
  end

  def create
    @patient.set_modality(modality_params)
    if @patient.modality_code.name == 'Death'
      redirect_to edit_patient_path(@patient), :notice => "Please make sure to update patient date of death and cause of death!"
    else
      redirect_to clinical_summary_patient_path(@patient)
    end    
  end

  private

  def modality_params
    params.require(:modality).permit(
      :patient_id, :user_id, :modality_code_id, :modality_change_type,
      :modality_reason_id, :start_date)
  end

  def find_patient
    @patient = Patient.find(params[:patient_id])
  end
end<commit_msg>Corrected redirect path for a non death saved modality.<commit_after>class ModalitiesController < ApplicationController

  before_filter :find_patient

  def new
    @modality = Modality.new(patient: @patient)
  end

  def index
    @modalities = @patient.modalities.with_deleted.order('termination_date DESC')
  end

  def create
    @patient.set_modality(modality_params)

    redirect_to patient_modalities_path(@patient)    
  end

  private

  def modality_params
    params.require(:modality).permit(
      :patient_id, :user_id, :modality_code_id, :modality_change_type,
      :modality_reason_id, :start_date)
  end

  def find_patient
    @patient = Patient.find(params[:patient_id])
  end
end
{'fraction_non_alphanumeric': 0.08199871877001921, 'fraction_numerical': 0.0, 'mean_word_length': 4.206666666666667, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '237677', 'n_tokens_mistral': 506, 'n_tokens_neox': 481, 'n_words': 108}