Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update overlaps to ignore end date #14

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/assets/javascripts/hqmf_util.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,15 @@ class IVL_TS
DURING: (other) -> this.SDU(other) && this.EDU(other)

# Overlap: this overlaps with other
OVERLAP: (other) -> this.SDU(other) || this.EDU(other) || (this.SBS(other) && this.EAE(other))
OVERLAP: (other) ->
if @high.date == null && other.high.date == null
true # If neither have ends, they inherently overlap on the timeline
else if @high.date == null
!this.SAE(other)
else if other.high.date == null
!this.EBS(other)
else
this.SDU(other) || this.EDU(other) || (this.SBS(other) && this.EAE(other))

# Concurrent: this low and high are the same as other low and high
CONCURRENT: (other) -> this.SCW(other) && this.ECW(other)
Expand Down
10 changes: 10 additions & 0 deletions test/unit/library_function_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,22 @@ def test_temporal_operators
@context.eval('var events1 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120105"), new TS("20120105"));}}]')
@context.eval('var events2 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120102"), new TS("20120105"));}}]')
@context.eval('var events3 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120105203030"), new TS("20120105203030"));}}]')
@context.eval('var nullEndEvent = new IVL_TS(new TS("20110101"), new TS("20120105"));')
@context.eval('nullEndEvent.high.date = null;')
@context.eval('var events4 = [{"asIVL_TS": function() {return nullEndEvent;}}]')
@context.eval('var events5 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20140101"), new TS("20140201"));}}]')
@context.eval('var bound1 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120105"), new TS("20120105"));}}]')
@context.eval('var bound2 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120107"), new TS("20120107"));}}]')
@context.eval('var bound3 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120103"), new TS("20120107"));}}]')
@context.eval('var bound4 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120106"), new TS("20120107"));}}]')
@context.eval('var bound5 = {"asIVL_TS": function() {return new IVL_TS(new TS("20120106"), new TS("20120107"));}}')
@context.eval('var nullStartBound = new IVL_TS(new TS("20120105"), new TS("20120105"));')
@context.eval('nullStartBound.low.date = null;')
@context.eval('var nullEndBound = new IVL_TS(new TS("20140601"), new TS("20140601"));')
@context.eval('nullEndBound.high.date = null;')
@context.eval('var bound6 = {"asIVL_TS": function() {return nullStartBound;}}')
@context.eval('var bound7 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120105193030"), new TS("20120105193030"));}}]')
@context.eval('var bound8 = {"asIVL_TS": function() {return nullEndBound;}}')
@context.eval('var range1 = new IVL_PQ(null, new PQ(1, "d"))')
@context.eval('var range2 = new IVL_PQ(new PQ(1, "d"), null)')
@context.eval('var range3 = new IVL_PQ(new PQ(0, "d"), null)')
Expand Down Expand Up @@ -430,6 +437,9 @@ def test_temporal_operators
assert_equal 0, @context.eval('OVERLAP(events2, XPRODUCT(bound6))').count
assert_equal 1, @context.eval('OVERLAP(events2, XPRODUCT(bound1))').count
assert_equal 0, @context.eval('OVERLAP(events2, XPRODUCT(bound2))').count
## Overlap with null ending
assert_equal 1, @context.eval('OVERLAP(events4, bound1)').count
assert_equal 0, @context.eval('OVERLAP(events5, bound8)').count

# SCW
assert_equal 1, @context.eval('SCW(events1, bound1)').count
Expand Down