templates/mongoose_template.js.erb in cqm-models-3.1.2 vs templates/mongoose_template.js.erb in cqm-models-4.0.0

- old
+ new

@@ -24,11 +24,11 @@ const DateTime = require('../basetypes/DateTime'); const QDMDate = require('../basetypes/QDMDate'); const Any = require('../basetypes/Any'); const [Schema] = [mongoose.Schema]; -<% elsif datatype.downcase == 'carepartner' || datatype.downcase == 'organization' || datatype.downcase == 'practitioner' || datatype.downcase == 'patiententity'%> +<% elsif datatype.downcase == 'carepartner' || datatype.downcase == 'organization' || datatype.downcase == 'practitioner' || datatype.downcase == 'patiententity' || datatype.downcase == 'location'%> const { EntitySchemaFunction } = require('./Entity'); const Code = require('../basetypes/Code'); const Interval = require('../basetypes/Interval'); const Quantity = require('../basetypes/Quantity'); const DateTime = require('../basetypes/DateTime'); @@ -63,11 +63,11 @@ const <%= datatype -%>Schema = ComponentSchemaFunction({ <%- for attribute in attrs_with_extras -%> <% if attribute[:default] %><%= attribute[:name] %>: { type: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>, default: '<%= attribute[:default] %>' },<% else %><%= attribute[:name] %>: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>,<%- end %> <%- end %> }); -<% elsif datatype.downcase == 'carepartner' || datatype.downcase == 'organization' || datatype.downcase == 'practitioner' || datatype.downcase == 'patiententity'%> +<% elsif datatype.downcase == 'carepartner' || datatype.downcase == 'organization' || datatype.downcase == 'practitioner' || datatype.downcase == 'patiententity' || datatype.downcase == 'location'%> const <%= datatype -%>Schema = EntitySchemaFunction({ <%- for attribute in attrs_with_extras -%> <% if attribute[:default] %><%= attribute[:name] %>: { type: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>, default: '<%= attribute[:default] %>' },<% else %><%= attribute[:name] %>: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>,<%- end %> <%- end %> }); @@ -81,9 +81,16 @@ module.exports.<%= datatype %>Schema = <%= datatype %>Schema; class <%= datatype %> extends mongoose.Document { constructor(object) { super(object, <%= datatype %>Schema); this._type = 'QDM::<%= datatype %>'; + <%- for attribute in attrs_with_extras -%> + <%- if RESERVED_WORDS[attribute[:name].to_s] -%> + if (object && object.<%= RESERVED_WORDS[attribute[:name].to_s] %>) { + this.<%= attribute[:name] %> = object.<%= RESERVED_WORDS[attribute[:name].to_s] %>; + } + <%- end -%> + <%- end -%> } } <% if datatype.downcase == 'entity' || datatype.downcase == 'component'%> function <%= datatype %>SchemaFunction(add, options) { const extended = new Schema({