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.70 app/models/renalware/clinical/allergy_status_form.rb
renalware-core-2.0.69 app/models/renalware/clinical/allergy_status_form.rb
renalware-core-2.0.68 app/models/renalware/clinical/allergy_status_form.rb
renalware-core-2.0.67 app/models/renalware/clinical/allergy_status_form.rb
renalware-core-2.0.64 app/models/renalware/clinical/allergy_status_form.rb
renalware-core-2.0.63 app/models/renalware/clinical/allergy_status_form.rb
renalware-core-2.0.62 app/models/renalware/clinical/allergy_status_form.rb
renalware-core-2.0.61 app/models/renalware/clinical/allergy_status_form.rb
renalware-core-2.0.60 app/models/renalware/clinical/allergy_status_form.rb
renalware-core-2.0.58 app/models/renalware/clinical/allergy_status_form.rb
renalware-core-2.0.57 app/models/renalware/clinical/allergy_status_form.rb
renalware-core-2.0.56 app/models/renalware/clinical/allergy_status_form.rb
renalware-core-2.0.55 app/models/renalware/clinical/allergy_status_form.rb
renalware-core-2.0.54 app/models/renalware/clinical/allergy_status_form.rb
renalware-core-2.0.53 app/models/renalware/clinical/allergy_status_form.rb
renalware-core-2.0.52 app/models/renalware/clinical/allergy_status_form.rb
renalware-core-2.0.51 app/models/renalware/clinical/allergy_status_form.rb
renalware-core-2.0.50 app/models/renalware/clinical/allergy_status_form.rb
renalware-core-2.0.48 app/models/renalware/clinical/allergy_status_form.rb
renalware-core-2.0.47 app/models/renalware/clinical/allergy_status_form.rb