Sha256: 67e158adece8e87d41070266d20ff1f0e4b90d7e55bdb8d1fecec996ff7bc41c

Contents?: true

Size: 1.31 KB

Versions: 93

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/clinical"

module Renalware
  module Clinical
    class ProfilesController < Clinical::BaseController
      def show
        authorize patient
        render locals: {
          patient: patient,
          profile: Clinical::ProfilePresenter.new(patient: patient, params: params)
        }
      end

      def edit
        authorize patient
        render locals: { patient: patient }
      end

      def update
        authorize patient
        if update_patient
          redirect_to patient_clinical_profile_path(patient),
                      notice: t(".success", model_name: "clinical history")
        else
          render :edit, locals: { patient: patient }
        end
      end

      private

      def update_patient
        document = patient.document
        %i(diabetes history).each do |document_attribute|
          document.send(
            :"#{document_attribute}=",
            profile_params[document_attribute].symbolize_keys
          )
        end
        patient.by = current_user
        patient.save!
      end

      def profile_params
        params
          .require(:clinical_profile)
          .permit(
            diabetes: %i(diagnosis diagnosed_on),
            history: %i(alcohol smoking))
          .to_h
      end
    end
  end
end

Version data entries

93 entries across 93 versions & 1 rubygems

Version Path
renalware-core-2.0.121 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.120 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.119 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.118 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.117 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.116 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.115 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.113 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.112 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.111 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.110 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.109 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.108 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.106 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.105 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.104 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.103 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.102 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.101 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.100 app/controllers/renalware/clinical/profiles_controller.rb