Sha256: 8e4dcf0ac4c64f76480fd99febd30ed2eabe6c3557cb6e9e2e0a012c498daa66

Contents?: true

Size: 1.02 KB

Versions: 8

Compression:

Stored size: 1.02 KB

Contents

require_dependency "renalware/clinical"

module Renalware
  module Clinical
    class AllergiesController < Clinical::BaseController

      def create
        result = CreateAllergy.new(patient, current_user).call(allergy_params) do |allergy|
          authorize allergy
        end
        if result.success?
          redirect_back fallback_location: patient_clinical_profile_path(patient),
                        notice: success_msg_for("allergy")

        else
          # we use client-side validation so will not get here
          raise NotImplementedError
        end
      end

      def destroy
        allergy = patient.allergies.find(params[:id])
        authorize allergy
        DeleteAllergy.new(allergy, current_user).call
        redirect_back fallback_location: patient_clinical_profile_path(patient),
                      notice: t(".success_with_name", name: allergy.description)
      end

      private

      def allergy_params
        params.require(:clinical_allergy).permit([:description])
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta11 app/controllers/renalware/clinical/allergies_controller.rb
renalware-core-2.0.0.pre.beta10 app/controllers/renalware/clinical/allergies_controller.rb
renalware-core-2.0.0.pre.beta9 app/controllers/renalware/clinical/allergies_controller.rb
renalware-core-2.0.0.pre.beta8 app/controllers/renalware/clinical/allergies_controller.rb
renalware-core-2.0.0.pre.beta7 app/controllers/renalware/clinical/allergies_controller.rb
renalware-core-2.0.0.pre.beta6 app/controllers/renalware/clinical/allergies_controller.rb
renalware-core-2.0.0.pre.beta5 app/controllers/renalware/clinical/allergies_controller.rb
renalware-core-2.0.0.pre.beta4 app/controllers/renalware/clinical/allergies_controller.rb