lib/generator/data_criteria.js.erb in hqmf2js-1.2.1 vs lib/generator/data_criteria.js.erb in hqmf2js-1.3.0
- old
+ new
@@ -6,14 +6,14 @@
// Data critera
<%- all_criteria.select {|c| c.type != :variable}.each do |criteria| -%>
hqmfjs.<%= js_name(criteria) %> = function(patient, initialSpecificContext) {
<%- if criteria.type == :characteristic and !criteria.property.nil? -%>
-<%= js_for_characteristic(criteria) %>
+<%= js_for_characteristic(criteria) -%>
<%- else -%>
<%- if criteria.type != :derived -%>
-<%= js_for_patient_data(criteria) %>
+<%= js_for_patient_data(criteria) -%>
<%- else # derived criteria -%>
<%= js_for_derived_data(criteria) %>
<%- end -%>
<%- if criteria.value -%>
events = filterEventsByValue(events, <%= js_for_bounds(criteria.value) %>);
@@ -24,16 +24,16 @@
<%- end -%>
<%- end -%>
<%- if criteria.temporal_references and criteria.temporal_references.length > 0 -%>
<%- criteria.temporal_references.each do |temporal_reference| -%>
if (events.length > 0) events = <%= temporal_reference.type %>(events, hqmfjs.<%= temporal_reference.reference.id %>(patient)<%= ", #{js_for_bounds(temporal_reference.range)}" if temporal_reference.range %>);
- else events.specificContext=hqmf.SpecificsManager.empty();
<%- end -%>
- <%- else -%>
+ if (events.length == 0) events.specificContext=hqmf.SpecificsManager.empty();
+ <%- else # no temporal refs -%>
<%- if criteria.specific_occurrence -%>
events.specificContext=new hqmf.SpecificOccurrence(Row.buildForDataCriteria(events.specific_occurrence, events))
<%- else -%>
- events.specificContext=hqmf.SpecificsManager.identity()
+ hqmf.SpecificsManager.setIfNull(events);
<%- end -%>
<%- end -%>
<%- if criteria.subset_operators -%>
<%- criteria.subset_operators.select {|subset_operator| subset_operator.type}.each do |subset_operator| -%>
events = <%= subset_operator.type %>(events<%= ", #{js_for_bounds(subset_operator.value)}" if subset_operator.value %>, initialSpecificContext);
\ No newline at end of file