app/assets/javascripts/hqmf_util.js.coffee in hqmf2js-1.2.0 vs app/assets/javascripts/hqmf_util.js.coffee in hqmf2js-1.2.1

- old
+ new

@@ -129,11 +129,12 @@ else (later.getUTCFullYear()-earlier.getUTCFullYear())*12+later.getUTCMonth()-earlier.getUTCMonth()-1 # Number of whole minutes between the two time stamps (as Date objects) @minutesDifference: (earlier, later) -> - Math.floor(((later.getTime()-earlier.getTime())/1000)/60) + [e,l] = TS.dropSeconds(earlier,later) + Math.floor(((l.getTime()-e.getTime())/1000)/60) # Number of whole hours between the two time stamps (as Date objects) @hoursDifference: (earlier, later) -> Math.floor(TS.minutesDifference(earlier,later)/60) @@ -450,11 +451,12 @@ @filterEventsByValue = filterEventsByValue # Return only those events with a field that matches the supplied value filterEventsByField = (events, field, value) -> respondingEvents = (event for event in events when event.respondTo(field)) - result = (event for event in respondingEvents when value.match(event[field]())) + unit = value.unit() if value.unit? + result = (event for event in respondingEvents when value.match(event[field](unit))) hqmf.SpecificsManager.maintainSpecifics(result, events) @filterEventsByField = filterEventsByField shiftTimes = (event, field) -> shiftedEvent = new event.constructor(event.json) @@ -508,14 +510,17 @@ # all the elements of the compoent arrays and the component arrays themselves class CrossProduct extends Array constructor: (allEventLists) -> super() @eventLists = [] + # keep track of the specific occurrences by encounter ID. This is used in eventsMatchBounds (specifically in buildRowsForMatching down the _.isObject path) + @specific_occurrence = {} for eventList in allEventLists @eventLists.push eventList for event in eventList this.push(event) + @specific_occurrence[event.id] = eventList.specific_occurrence if eventList.specific_occurrence listCount: -> @eventLists.length childList: (index) -> @eventLists[index] # Create a CrossProduct of the supplied event lists. XPRODUCT = (eventLists...) -> @@ -523,13 +528,17 @@ @XPRODUCT = XPRODUCT # Create a new list containing all the events from the supplied event lists UNION = (eventLists...) -> union = [] + # keep track of the specific occurrences by encounter ID. This is used in eventsMatchBounds (specifically in buildRowsForMatching down the _.isObject path) + specific_occurrence = {} for eventList in eventLists for event in eventList + specific_occurrence[event.id] = eventList.specific_occurrence if eventList.specific_occurrence union.push(event) + union.specific_occurrence = specific_occurrence unless _.isEmpty(specific_occurrence) hqmf.SpecificsManager.unionAll(union, eventLists) @UNION = UNION # Return true if the number of events matches the supplied range COUNT = (events, range) -> @@ -637,10 +646,10 @@ matchingBounds=eventMatchesBounds(event, bounds, methodName, range) matchingEvents.push(event) if matchingBounds.length > 0 if hasSpecificOccurrence matchingEvents.specific_occurrence = events.specific_occurrence - # TODO: well need a temporary variable for non specific occurrences on the left so that we can do rejections based on restrictions in the data criteria + # we use a temporary variable for non specific occurrences on the left so that we can do rejections based on restrictions in the data criteria specificContext.addRows(Row.buildRowsForMatching(events.specific_occurrence, event, bounds.specific_occurrence, matchingBounds)) else # add all stars specificContext.addIdentityRow()