Sha256: d7b91000d121c5f262863a2714cd384f61bd80b3efb67b51c35f4e2d45043fab

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

const mongoose = require('mongoose/browser');

const Code = require('../basetypes/Code');
const Interval = require('../basetypes/Interval');
const Quantity = require('../basetypes/Quantity');
const DateTime = require('../basetypes/DateTime');
const QDMDate = require('../basetypes/QDMDate');
const Any = require('../basetypes/Any');

const [Schema] = [mongoose.Schema];

const [Number, String] = [
  mongoose.Schema.Types.Number,
  mongoose.Schema.Types.String,
];

const ComponentSchema = new mongoose.Schema({
  code: Code,
  result: Any,
  qdmVersion: { type: String, default: '5.6' },
  _type: { type: String, default: 'QDM::Component' },

});

module.exports.ComponentSchema = ComponentSchema;
class Component extends mongoose.Document {
  constructor(object) {
    super(object, ComponentSchema);
    this._type = 'QDM::Component';
  }
}

function ComponentSchemaFunction(add, options) {
  const extended = new Schema({
    code: Code,
    result: Any,
    qdmVersion: { type: String, default: '5.6' },
    _type: { type: String, default: 'QDM::Component' },


  }, options);

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

  /* eslint no-underscore-dangle: 0 */
  extended.methods._is = function _is(typeSpecifier) {
    return this._typeHierarchy().some(
      t => t.type === typeSpecifier.type && t.name === typeSpecifier.name
    );
  };

  extended.methods._typeHierarchy = function _typeHierarchy() {
    const typeName = this._type.replace(/QDM::/, '');
    const ver = this.qdmVersion.replace('.', '_');
    return [
      {
        name: `{urn:healthit-gov:qdm:v${ver}}${typeName}`,
        type: 'NamedTypeSpecifier',
      },
    ];
  };
  return extended;
}

module.exports.Component = Component;
module.exports.ComponentSchemaFunction = ComponentSchemaFunction;

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cqm-models-4.2.0 app/assets/javascripts/attributes/Component.js