app/assets/javascripts/Patient.js in cqm-models-0.8.3 vs app/assets/javascripts/Patient.js in cqm-models-0.8.4

- old
+ new

@@ -88,18 +88,14 @@ // If isNegated == true, only return data elements with a negationRationale that is not null. // If isNegated == false, only return data elements with a null negationRationale. // If isNegated == null, return all matching data elements by type, regardless of negationRationale. const results = this.dataElements.filter(element => element._type === `QDM::${profile}` && (isNegated === null || !!element.negationRationale === isNegated)); return results.map((result) => { - const getCodeFunction = Object.getPrototypeOf(result).getCode; - const codeFunction = Object.getPrototypeOf(result).code; - const idField = result.id; const removedMongooseItems = AllDataElements[profile](result).toObject(); - // toObject() will remove all mongoose functions but also removed the getCode and code functions - // the execution engine requires the code and getCode functions so we have to add them back - removedMongooseItems.getCode = getCodeFunction; - removedMongooseItems.code = codeFunction; - removedMongooseItems.id = idField; + // toObject() will remove all mongoose functions but also remove the schema methods, so we add them back + Object.entries(Object.getPrototypeOf(result).schema.methods).forEach(([method_name, method]) => { + removedMongooseItems[method_name] = method; + }); return removedMongooseItems; }); }; // This method is called by the CQL execution engine on a CQLPatient when