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.79 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.78 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.77 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.76 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.75 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.74 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.73 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.72 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.71 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.70 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.69 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.68 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.67 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.64 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.63 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.62 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.61 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.60 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.58 app/controllers/renalware/clinical/profiles_controller.rb
renalware-core-2.0.57 app/controllers/renalware/clinical/profiles_controller.rb