lib/health-data-standards/models/cqm/bundle.rb in health-data-standards-3.2.12 vs lib/health-data-standards/models/cqm/bundle.rb in health-data-standards-3.3.0
- old
+ new
@@ -1,10 +1,11 @@
module HealthDataStandards
module CQM
class Bundle
include Mongoid::Document
+ include Mongoid::Timestamps
store_in collection: 'bundles'
field :title, type: String
field :version, type: String
field :license, type: String
field :extensions, type: Array
@@ -13,33 +14,32 @@
field :records, type: Array
field :active, type: Boolean
validates_presence_of :version
- def self.active
- self.where({active: true})
+ 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]])
+ 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]])
+ 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
end
\ No newline at end of file