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

- old
+ new

@@ -1,22 +1,25 @@ - var events = patient.<%= patient_api_method(criteria) %>(); - <%- if criteria.specific_occurrence -%> - events.specific_occurrence = '<%= criteria.source_data_criteria %>' - <%- end -%> -<%- if criteria.status -%> - events = events.withStatuses(["<%= criteria.status %>"]<%= ", false" if criteria.hard_status %>); -<%- end -%> -<%- if criteria.negation -%> - events = events.withNegation(<%= "getCodes(\"#{criteria.negation_code_list_id}\")" if criteria.negation_code_list_id %>); -<%- else -%> - events = events.withoutNegation(); -<%- end -%> - var codes = <%= js_for_code_list(criteria) %>; - var start = null; - var end = null; +<%- eventType = patient_api_method(criteria) -%> +<%- valueSetId = criteria.code_list_id -%> +<%- valueSet = criteria.inline_code_list ? js_for_code_list(criteria) : nil -%> +<%- negationValueSetId = criteria.negation_code_list_id -%> +<%- statuses = criteria.status ? "[\"#{criteria.status}\"]" : nil -%> +<%- includeEventsWithoutStatus = criteria.hard_status ? false : true -%> +<%- start = nil -%> +<%- stop = nil -%> <%- if criteria.effective_time -%> <%- startExp = js_for_value(criteria.effective_time.low) -%> - start = <%= startExp %><%= '.asDate()' if startExp != 'null' %>; - <%- endExp = js_for_value(criteria.effective_time.high) -%> - end = <%= endExp %><%= '.asDate()' if endExp != 'null' %>; + <%- start = startExp+'.asDate()' if startExp != 'null' -%> + <%- stopExp = js_for_value(criteria.effective_time.high) -%> + <%- stop = stopExp+'.asDate()' if stopExp != 'null' -%> <%- end -%> - events = events.match(codes, start, end, true); + var eventCriteria = {"type": "<%= eventType %>"<%- -%> +<%= ", \"statuses\": #{statuses}" if statuses %> <%- -%> +<%= ", \"includeEventsWithoutStatus\": #{includeEventsWithoutStatus}" if includeEventsWithoutStatus %> <%- -%> +<%= ", \"negated\": #{criteria.negation}" if criteria.negation %> <%- -%> +<%= ", \"negationValueSetId\": \"#{negationValueSetId}\"" if criteria.negation && negationValueSetId %> <%- -%> +<%= ", \"valueSetId\": \"#{valueSetId}\"" if valueSetId %> <%- -%> +<%= ", \"valueSet\": #{valueSet}" if valueSet %> <%- -%> +<%= ", \"start\": #{start}" if start %> <%- -%> +<%= ", \"stop\": #{stop}" if stop %> <%- -%> +<%= ", \"specificOccurrence\": \"#{criteria.source_data_criteria}\"" if criteria.specific_occurrence %>}; + var events = patient.getEvents(eventCriteria);