lib/generator/characteristic.js.erb in hqmf2js-1.2.1 vs lib/generator/characteristic.js.erb in hqmf2js-1.3.0

- old
+ new

@@ -1,19 +1,30 @@ -var value = patient.<%= criteria.property %>(<%= js_for_date_bound(criteria) if criteria.property == :age %>) || null; - <%- if criteria.property == :birthtime -%> -var events = [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 -%> + var value = patient.<%= criteria.property %>(<%= js_for_date_bound(criteria) if criteria.property == :age %>) || null; +<%- if criteria.property == :birthtime -%> + var events = [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 -%> -events.specificContext=hqmf.SpecificsManager.identity(); -return events; - <%- elsif criteria.property == :expired or criteria.property == :clinicalTrialParticipant -%> -matching = matchingValue(value, 'true'); -matching.specificContext=hqmf.SpecificsManager.identity(); -return matching - <%- else -%> -matching = matchingValue(value, <%= js_for_bounds(criteria.value) %>); -matching.specificContext=hqmf.SpecificsManager.identity(); -return matching; <%- end -%> + events.specificContext=hqmf.SpecificsManager.identity(); + return events; + <%- elsif criteria.property == :expired %> + var return_value = matchingValue(value, 'true'); + + <%- if criteria.temporal_references -%> + var events = [patient.deathdate()]; + <%- criteria.temporal_references.each do |temporal_reference| -%> + return_value = <%= temporal_reference.type %>(events, hqmfjs.<%= temporal_reference.reference.id %>(patient)<%= ", #{js_for_bounds(temporal_reference.range)}" if temporal_reference.range %>); + <%- end -%> + <%- end -%> +return_value.specificContext=hqmf.SpecificsManager.identity(); +return return_value +<%- elsif criteria.property == :clinicalTrialParticipant -%> + matching = matchingValue(value, 'true'); + matching.specificContext=hqmf.SpecificsManager.identity(); + return matching; +<%- else -%> + matching = matchingValue(value, <%= js_for_bounds(criteria.value) %>); + matching.specificContext=hqmf.SpecificsManager.identity(); + return matching; +<%- end -%> \ No newline at end of file