<commit_before>class PatientsController < BaseController
  before_action :logged_in_user, only: [:index, :edit, :update, :destroy]
  def index
    if params[:name]
      name = params[:name].split(' ') if params[:name]
      params[:patient_name] = name[0]
      params[:patient_lastname] = name[1]
    end
    render json: Patient.filter(params.slice(:patient_name, :patient_lastname, :patient_gender, :type)).where(active: true).joins(:patients_users).where(patients_users: { user_id: current_user.id })
  end

  def show
    @patient = Patient.find_by! patient_find_params
    render json: @patient
  end

  def create
    @patient = Patient.create! patient_create_params
    handle_diseases(@patient, params)
    render json: @patient
  end

  def update
    @patient = Patient.find_by! patient_find_params
    @patient.update!(patient_update_params)
    handle_diseases(@patient, params)
    render json: @patient
  end<commit_msg>add the patient to the current user<commit_after>class PatientsController < BaseController
  before_action :logged_in_user, only: [:index, :edit, :update, :destroy]
  def index
    if params[:name]
      name = params[:name].split(' ') if params[:name]
      params[:patient_name] = name[0]
      params[:patient_lastname] = name[1]
    end
    render json: Patient.filter(params.slice(:patient_name, :patient_lastname, :patient_gender, :type)).where(active: true).joins(:patients_users).where(patients_users: { user_id: current_user.id })
  end

  def show
    @patient = Patient.find_by! patient_find_params
    render json: @patient
  end

  def create
    @patient = Patient.create! patient_create_params
    current_user.patients << @patient
    handle_diseases(@patient, params)
    render json: @patient
  end

  def update
    @patient = Patient.find_by! patient_find_params
    @patient.update!(patient_update_params)
    handle_diseases(@patient, params)
    render json: @patient
  end
{'fraction_non_alphanumeric': 0.10973084886128365, 'fraction_numerical': 0.002070393374741201, 'mean_word_length': 4.3844011142061285, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '1198037', 'n_tokens_mistral': 614, 'n_tokens_neox': 592, 'n_words': 137}