Sha256: 795007fa8cbe0a919ded34e0907772f3991765dec23c47ff5d9d29ba092bcadd

Contents?: true

Size: 897 Bytes

Versions: 7

Compression:

Stored size: 897 Bytes

Contents

const mongoose = require('mongoose');
const Code = require('./Code.js');

const [Schema] = [mongoose.Schema];

function DataElementSchema(add, options) {
  const extended = new Schema({
    dataElementCodes: { type: [Code] },
    description: { type: String },
  }, options);

  if (add) {
    extended.add(add);
  }

  // Returns all of the codes on this data element
  // in a format usable by the cql-execution framework
  extended.methods.getCode = function getCode() {
    return this.dataElementCodes.map((code) => {
      const result = {};
      result.code = code.code;
      result.system = code.code_system;
      return result;
    });
  };

  // Returns all of the codes on this data element
  // in their normal form.
  extended.methods.codes = function getCodes() {
    return this.dataElementCodes;
  };

  return extended;
}

module.exports.DataElementSchema = DataElementSchema;

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cqm-models-0.8.0 app/assets/javascripts/basetypes/DataElement.js
cqm-models-0.7.7 app/assets/javascripts/basetypes/DataElement.js
cqm-models-0.7.6 app/assets/javascripts/basetypes/DataElement.js
cqm-models-0.7.5 app/assets/javascripts/basetypes/DataElement.js
cqm-models-0.7.4 app/assets/javascripts/basetypes/DataElement.js
cqm-models-0.7.3 app/assets/javascripts/basetypes/DataElement.js
cqm-models-0.7.2 app/assets/javascripts/basetypes/DataElement.js