Sha256: 45b21715f958feb5abb0b6bd982bb6c676bd2cc0d8683edf31a1b189ffd1b3d7
Contents?: true
Size: 1.8 KB
Versions: 1
Compression:
Stored size: 1.8 KB
Contents
require_dependency "renalware/deaths" module Renalware module Modalities class ModalitiesController < BaseController before_action :load_patient def new modality = Modality.new(patient: patient) render locals: { patient: patient, modality: modality } end def index modalities = patient.modalities.ordered render locals: { patient: patient, modalities: modalities } end def create modality = Modality.new(modality_params.merge!(patient: patient)) if modality.valid? patient.set_modality(modality_params) handle_valid_modality else flash[:error] = t(".failed", model_name: "modality") render :new, locals: { patient: patient, modality: modality } end end private def params_are_valid? Modality.new(modality_params).valid? end def modality_params params.require(:modality) .permit( :description_id, :modal_change_type, :reason_id, :notes, :started_on ).merge(by: current_user) end def handle_valid_modality if patient.modality_description.is_a? Deaths::ModalityDescription redirect_to edit_patient_death_path(patient), flash: { warning: "Please make sure to update patient date of death and cause of death!" } elsif patient.modality_description.is_a? Transplants::DonorModalityDescription redirect_to new_patient_transplants_donation_path(patient), flash: { warning: "If you have the information on-hand, please enter the potential donation." } else redirect_to patient_modalities_path(patient), notice: t(".success", model_name: "modality") end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
renalware-core-2.0.0.pre.beta4 | app/controllers/renalware/modalities/modalities_controller.rb |