Sha256: 3eb79eceb5f11e3a14d2036bbe0e07361e6eeb507594989f53f447da87e9b599

Contents?: true

Size: 1.34 KB

Versions: 16

Compression:

Stored size: 1.34 KB

Contents

module HealthDataStandards
  module CQM

    class Bundle
      include Mongoid::Document
      include Mongoid::Timestamps
      include Mongoid::Attributes::Dynamic
      store_in collection: 'bundles'
      field :title, type: String
      field :name, type: String
      field :version, type: String
      field :license, type: String
      field :extensions, type: Array
      field :measures, type: Array
      field :effective_date
      field :measure_period_start
      field :records, type: Array
      field :active, type: Boolean
      field :done_importing, type: Boolean, default: false

      validates_presence_of :version

      has_many :value_sets, class_name: "HealthDataStandards::SVS::ValueSet", inverse_of: :bundle

      scope :active, -> {where(active: true)}

      def self.latest_bundle_id
        desc(:exported).first.try(:_id)
      end

      def measures
        HealthDataStandards::CQM::Measure.where({bundle_id: self.id}).order_by([["id", :asc],["sub_id",:asc]])
      end

      def records
        Record.where(bundle_id: self._id, test_id: nil).order_by([["last", :asc]])
      end

      # def value_sets
      #   HealthDataStandards::SVS::ValueSet.in(bundle_id: self.id)
      # end

      def delete
        self.measures.destroy
        self.records.destroy
        self.value_sets.destroy
        super
      end
     end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
health-data-standards-4.3.5 lib/health-data-standards/models/cqm/bundle.rb
health-data-standards-4.3.4 lib/health-data-standards/models/cqm/bundle.rb
health-data-standards-4.3.3 lib/health-data-standards/models/cqm/bundle.rb
health-data-standards-4.3.2 lib/health-data-standards/models/cqm/bundle.rb
health-data-standards-4.3.1 lib/health-data-standards/models/cqm/bundle.rb
health-data-standards-4.3.0 lib/health-data-standards/models/cqm/bundle.rb
health-data-standards-4.2.0 lib/health-data-standards/models/cqm/bundle.rb
health-data-standards-4.1.0 lib/health-data-standards/models/cqm/bundle.rb
health-data-standards-4.0.6 lib/health-data-standards/models/cqm/bundle.rb
health-data-standards-4.0.5 lib/health-data-standards/models/cqm/bundle.rb
health-data-standards-4.0.4 lib/health-data-standards/models/cqm/bundle.rb
health-data-standards-4.0.3 lib/health-data-standards/models/cqm/bundle.rb
health-data-standards-4.0.2 lib/health-data-standards/models/cqm/bundle.rb
health-data-standards-4.0.1 lib/health-data-standards/models/cqm/bundle.rb
health-data-standards-4.0.0 lib/health-data-standards/models/cqm/bundle.rb
health-data-standards-3.7.0 lib/health-data-standards/models/cqm/bundle.rb