Sha256: 366fb7f9e7a42a6dd4d266c8296096e0ea9c3520b5217570e3d5ea2e727cfff8
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
const mongoose = require('mongoose'); const Code = require('./Code.js'); const cql = require('cql-execution'); const [Schema] = [mongoose.Schema]; function DataElementSchema(add, options) { const extended = new Schema({ dataElementCodes: { type: [] }, 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 => new cql.Code(code.code, code.codeSystem, code.version, code.descriptor)); }; // Return the first code on this data element in a format usable by // the cql-execution framework. extended.methods.code = function code() { if (this.dataElementCodes && this.dataElementCodes[0]) { const qdmCode = this.dataElementCodes[0]; return new cql.Code(qdmCode.code, qdmCode.codeSystem, qdmCode.version, qdmCode.descriptor); } return null; }; return extended; } module.exports.DataElementSchema = DataElementSchema;
Version data entries
3 entries across 3 versions & 1 rubygems