Sha256: beb5435769981a254d2497100de4cfd29b82ae3b3a1933a861770a9b7d52ad43

Contents?: true

Size: 1.45 KB

Versions: 85

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/renal"
require_dependency "renalware/renal/base_controller"

module Renalware
  module Renal
    class ProfilesController < BaseController
      before_action :load_patient

      def show
        render locals: {
          patient: patient,
          profile: find_profile
        }
      end

      def edit
        render locals: {
          patient: patient,
          profile: find_profile
        }
      end

      def update
        profile = find_profile

        if profile.update(profile_params)
          redirect_to patient_renal_profile_path(patient),
                      notice: t(".success", model_name: "profile")
        else
          render :edit, locals: {
            patient: patient,
            profile: find_profile
          }
        end
      end

      private

      def profile_params
        params
          .require(:renal_profile)
          .permit(
            :esrf_on, :first_seen_on, :prd_description_id, :weight_at_esrf,
            :modality_at_esrf, :comorbidities_updated_on,
            address_at_diagnosis_attributes: address_params, document: {}
          )
      end

      def address_params
        [
          :id, :name, :organisation_name, :street_1, :street_2, :street_3, :county, :country_id,
          :town, :postcode, :telephone, :email
        ]
      end

      def find_profile
        patient.profile || patient.build_profile
      end
    end
  end
end

Version data entries

85 entries across 85 versions & 1 rubygems

Version Path
renalware-core-2.0.167 app/controllers/renalware/renal/profiles_controller.rb
renalware-core-2.0.166 app/controllers/renalware/renal/profiles_controller.rb
renalware-core-2.0.165 app/controllers/renalware/renal/profiles_controller.rb
renalware-core-2.0.164 app/controllers/renalware/renal/profiles_controller.rb
renalware-core-2.0.163 app/controllers/renalware/renal/profiles_controller.rb
renalware-core-2.0.162 app/controllers/renalware/renal/profiles_controller.rb
renalware-core-2.0.161 app/controllers/renalware/renal/profiles_controller.rb
renalware-core-2.0.160 app/controllers/renalware/renal/profiles_controller.rb
renalware-core-2.0.159 app/controllers/renalware/renal/profiles_controller.rb
renalware-core-2.0.158 app/controllers/renalware/renal/profiles_controller.rb
renalware-core-2.0.157 app/controllers/renalware/renal/profiles_controller.rb
renalware-core-2.0.156 app/controllers/renalware/renal/profiles_controller.rb
renalware-core-2.0.155 app/controllers/renalware/renal/profiles_controller.rb
renalware-core-2.0.153 app/controllers/renalware/renal/profiles_controller.rb
renalware-core-2.0.152 app/controllers/renalware/renal/profiles_controller.rb
renalware-core-2.0.151 app/controllers/renalware/renal/profiles_controller.rb
renalware-core-2.0.149 app/controllers/renalware/renal/profiles_controller.rb
renalware-core-2.0.148 app/controllers/renalware/renal/profiles_controller.rb
renalware-core-2.0.147 app/controllers/renalware/renal/profiles_controller.rb
renalware-core-2.0.146 app/controllers/renalware/renal/profiles_controller.rb