var value = patient.<%= criteria.property %>(<%= js_for_date_bound(criteria) if criteria.property == :age %>) || null; <%- if criteria.property == :birthtime -%> var events = value ? [value] : []; <%- if criteria.temporal_references -%> <%- criteria.temporal_references.each do |temporal_reference| -%> events = <%= temporal_reference.type %>(events, hqmfjs.<%= temporal_reference.reference.id %>(patient)<%= ", #{js_for_bounds(temporal_reference.range)}" if temporal_reference.range %>); <%- end -%> <%- end -%> <%- if criteria.field_values.present? -%> <%- criteria.field_values.keys.each do |field| -%> events = matchingValue(value, <%= js_for_bounds(criteria.field_values[field]) %>).isTrue() ? events : []; <%- end -%> <%- end -%> events.specificContext=events.specificContext||hqmf.SpecificsManager.identity(); return events; <%- elsif criteria.property == :expired -%> var events = value ? [patient.deathdate()] : []; <%- if criteria.temporal_references -%> <%- criteria.temporal_references.each do |temporal_reference| -%> events = <%= temporal_reference.type %>(events, hqmfjs.<%= temporal_reference.reference.id %>(patient)<%= ", #{js_for_bounds(temporal_reference.range)}" if temporal_reference.range %>); <%- end -%> <%- end -%> events.specificContext=events.specificContext||hqmf.SpecificsManager.identity(); return events; <%- elsif criteria.property == :clinicalTrialParticipant -%> matching = matchingValue(value, 'true'); matching.specificContext=hqmf.SpecificsManager.identity(); return matching; <%- elsif criteria.property == :race || criteria.property == :payer -%> if (value === null) { matching = new Boolean(false); } else { matching = new Boolean(value.includedIn(<%=criteria.inline_code_list.to_json%>)); } matching.specificContext=hqmf.SpecificsManager.identity(); return matching; <%- else -%> matching = matchingValue(value, <%= js_for_bounds(criteria.value) %>); matching.specificContext=hqmf.SpecificsManager.identity(); return matching; <%- end -%>