Sha256: e0c0c582bf370edff7d55c26e354790949d08d9aa50161d4988ac8d6140ca81f

Contents?: true

Size: 902 Bytes

Versions: 44

Compression:

Stored size: 902 Bytes

Contents

# frozen_string_literal: true

module Renalware
  module HD
    class PatientListener
      def patient_modality_changed_to_death(patient:, modality:, actor:)
        nullify_significant_hd_profile_attributes(patient, by: actor)
      end

      def request_default_electronic_cc_recipients_for_use_in_letters(patient:, array_of_user_ids:)
        patient = HD.cast_patient(patient)
        if patient.current_modality_hd?
          named_nurse_id = patient.hd_profile&.named_nurse&.id
          array_of_user_ids.push(named_nurse_id) if named_nurse_id.present?
        end
      end

      private

      def nullify_significant_hd_profile_attributes(patient, by:)
        hd_profile = HD.cast_patient(patient).hd_profile
        return if hd_profile.nil?

        hd_profile.hospital_unit = nil
        hd_profile.schedule_definition = nil
        hd_profile.save_by!(by)
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
renalware-core-2.0.111 app/models/renalware/hd/patient_listener.rb
renalware-core-2.0.110 app/models/renalware/hd/patient_listener.rb
renalware-core-2.0.109 app/models/renalware/hd/patient_listener.rb
renalware-core-2.0.108 app/models/renalware/hd/patient_listener.rb
renalware-core-2.0.106 app/models/renalware/hd/patient_listener.rb
renalware-core-2.0.105 app/models/renalware/hd/patient_listener.rb
renalware-core-2.0.104 app/models/renalware/hd/patient_listener.rb
renalware-core-2.0.103 app/models/renalware/hd/patient_listener.rb
renalware-core-2.0.102 app/models/renalware/hd/patient_listener.rb
renalware-core-2.0.101 app/models/renalware/hd/patient_listener.rb
renalware-core-2.0.100 app/models/renalware/hd/patient_listener.rb
renalware-core-2.0.99 app/models/renalware/hd/patient_listener.rb
renalware-core-2.0.98 app/models/renalware/hd/patient_listener.rb
renalware-core-2.0.97 app/models/renalware/hd/patient_listener.rb
renalware-core-2.0.96 app/models/renalware/hd/patient_listener.rb
renalware-core-2.0.95 app/models/renalware/hd/patient_listener.rb
renalware-core-2.0.94 app/models/renalware/hd/patient_listener.rb
renalware-core-2.0.93 app/models/renalware/hd/patient_listener.rb
renalware-core-2.0.92 app/models/renalware/hd/patient_listener.rb
renalware-core-2.0.91 app/models/renalware/hd/patient_listener.rb