Sha256: b3a0433ddc206d2c90ed24a6dd64d3d36d9735ccdf42b40ca7555aa4e691483e
Contents?: true
Size: 1.82 KB
Versions: 8
Compression:
Stored size: 1.82 KB
Contents
require_dependency "renalware/pd" module Renalware module PD class AssessmentsController < BaseController def show assessment = find_assessment authorize assessment render locals: { patient: patient, assessment: assessment } end def new assessment = PD::Assessment.for_patient(patient).new authorize assessment render locals: { patient: patient, assessment: assessment } end def create assessment = PD::Assessment.for_patient(patient).new(assessment_params) authorize assessment if assessment.save redirect_to patient_pd_dashboard_path(patient), notice: success_msg_for("assessment") else render :new, locals: { patient: patient, assessment: assessment } end end def edit assessment = find_assessment authorize assessment render locals: { patient: patient, assessment: assessment } end def update assessment = find_assessment authorize assessment if assessment.update(assessment_params) redirect_to patient_pd_dashboard_path(patient), notice: success_msg_for("assessment") else render :edit, locals: { patient: patient, assessment: assessment } end end private def find_assessment PD::Assessment.for_patient(patient).find(params[:id]) end def assessment_params params .require(:assessment) .permit(attributes) .merge(document: document_attributes, by: current_user) end def attributes [ document: [] ] end def document_attributes params.require(:assessment).fetch(:document, nil).try(:permit!) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems