Sha256: 851e7e85a5eea4ded2ff12beeeac4c4333dade1c2d342859ff63560ea1c96fc0

Contents?: true

Size: 595 Bytes

Versions: 60

Compression:

Stored size: 595 Bytes

Contents

# frozen_string_literal: true

module Renalware
  module Clinical
    class AllergyStatusForm
      include ActiveModel::Model
      include Virtus::Model

      attribute :no_known_allergies, Integer

      def save(patient, user)
        return unless patient.allergies.count == 0

        patient.allergy_status = no_known_allergies? ? :no_known_allergies : :unrecorded
        patient.by = user
        patient.allergy_status_updated_at = Time.zone.now
        patient.save!
      end

      private

      def no_known_allergies?
        no_known_allergies == 1
      end
    end
  end
end

Version data entries

60 entries across 60 versions & 1 rubygems

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