Sha256: f685b18859fde23c33102960fa34b6df27a4af4c5347e74dedd0da92f5ee2872
Contents?: true
Size: 1.54 KB
Versions: 43
Compression:
Stored size: 1.54 KB
Contents
# frozen_string_literal: true require_dependency "renalware/clinical" module Renalware module Clinical # Note that there is no concrete Clinical::Profile, most data here is persisted in the patient 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 patient.named_consultant_id = profile_params[:named_consultant_id] document = patient.document %i(diabetes history).each do |document_attribute| document.send( :"#{document_attribute}=", profile_params[:document][document_attribute].symbolize_keys ) end patient.save_by! current_user end def profile_params params .require(:clinical_profile) .permit( :named_consultant_id, document: { diabetes: %i(diagnosis diagnosed_on), history: %i(alcohol smoking) } ).to_h end end end end
Version data entries
43 entries across 43 versions & 1 rubygems