Sha256: e1e1428faec74dfc215a52674da66ad0c757a10344d62479c64a79dbfef1b67a

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

module QME
  module Bundle
    # Delete a list of collections. By default, this function drops all of collections related to measures and patients.
    #
    # @param [Array] collection_names Optionally, an array of collection names to be dropped.
    def self.drop_collections(db, collection_names=[])
      collection_names = ["bundles", "records", "measures", "selected_measures", "patient_cache", "query_cache", "system.js"] if collection_names.empty?
      collection_names.each {|collection| db[collection].drop}
    end

    # Save a javascript function into Mongo's system.js collection for measure execution.
    #
    # @param [String] name The name by which the function will be referred.
    # @param [String] fn The body of the function being saved.
    def self.save_system_js_fn(db, name, fn)
      fn = "function () {\n #{fn} \n }"
      db['system.js'].find('_id' => name).upsert(
        {
          "_id" => name,
          "value" => Moped::BSON::Code.new(fn)
        }
      )
    end

    # A utility function for finding files in a bundle. Strip a file path of it's extension and just give the filename.
    #
    # @param [String] original A file path.
    # @param [String] extension A file extension.
    # @return The filename at the end of the original String path with the extension removed. e.g. "/boo/urns.html" -> "urns"
    def self.entry_key(original, extension)
      original.split('/').last.gsub(".#{extension}", '')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quality-measure-engine-2.0.0 lib/qme/bundle/bundle.rb