lib/generator/characteristic.js.erb in hqmf2js-1.3.0 vs lib/generator/characteristic.js.erb in hqmf2js-1.4.0
- old
+ new
@@ -1,30 +1,41 @@
var value = patient.<%= criteria.property %>(<%= js_for_date_bound(criteria) if criteria.property == :age %>) || null;
<%- if criteria.property == :birthtime -%>
- var events = [value];
+ 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 -%>
- events.specificContext=hqmf.SpecificsManager.identity();
+ <%- 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 return_value = matchingValue(value, 'true');
-
+<%- elsif criteria.property == :expired -%>
+ var events = value ? [patient.deathdate()] : [];
<%- 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 -%>
+ <%- 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 -%>
-return_value.specificContext=hqmf.SpecificsManager.identity();
-return return_value
+ <%- 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 -%>
\ No newline at end of file
+<%- end -%>