diff --git a/src/example/browser/cql4browsers.js b/src/example/browser/cql4browsers.js index b3a6b7a67..c9e6910a8 100644 --- a/src/example/browser/cql4browsers.js +++ b/src/example/browser/cql4browsers.js @@ -43831,8 +43831,9 @@ } Results.prototype.recordPatientResult = function(patient_ctx, resultName, result) { - var base, patientId; - patientId = patient_ctx.patient.id(); + var base, p, patientId; + p = patient_ctx.patient; + patientId = typeof p.getId === 'function' ? p.getId() : p.id(); if ((base = this.patientResults)[patientId] == null) { base[patientId] = {}; } diff --git a/src/runtime/results.coffee b/src/runtime/results.coffee index e44fe4032..b2a542d9e 100644 --- a/src/runtime/results.coffee +++ b/src/runtime/results.coffee @@ -5,7 +5,11 @@ module.exports.Results = class Results @localIdPatientResultsMap = {} recordPatientResult: (patient_ctx, resultName, result) -> - patientId = patient_ctx.patient.id() + p = patient_ctx.patient + # NOTE: From now on prefer getId() over id() because some data models may have an id property + # that is not a string (e.g., FHIR) -- so reserve getId() for the API (and expect a string + # representation) but leave id() for data-model specific formats. + patientId = if typeof p.getId == 'function' then p.getId() else p.id() @patientResults[patientId] ?= {} @patientResults[patientId][resultName] = result @localIdPatientResultsMap[patientId] = patient_ctx.getAllLocalIds()