@@ -77,7 +77,7 @@ class MLPPExposuresTransformerSuite extends SharedContext {
7777
7878 // When
7979 import MLPPExposuresTransformer .ExposuresDataFrame
80- val result = input.filterDiagnosedPatients (true ).select(" patientID" , " category" )
80+ val result = input.filterEarlyDiagnosedPatients (true ).select(" patientID" , " category" )
8181
8282 // Then
8383 import RichDataFrames ._
@@ -100,7 +100,7 @@ class MLPPExposuresTransformerSuite extends SharedContext {
100100
101101 // When
102102 import MLPPExposuresTransformer .ExposuresDataFrame
103- val result = input.filterDiagnosedPatients (false )
103+ val result = input.filterEarlyDiagnosedPatients (false )
104104
105105 // Then
106106 import RichDataFrames ._
@@ -135,6 +135,37 @@ class MLPPExposuresTransformerSuite extends SharedContext {
135135 assert(result === expected)
136136 }
137137
138+ " filterNeverSickPatients" should " remove patients who never have a target disease" in {
139+ val sqlCtx = sqlContext
140+ import sqlCtx .implicits ._
141+
142+ // Given
143+ val input = Seq (
144+ (" Patient_A" , " molecule" , " " , makeTS(2006 , 1 , 1 )),
145+ (" Patient_A" , " molecule" , " " , makeTS(2006 , 3 , 1 )),
146+ (" Patient_A" , " disease" , " targetDisease" , makeTS(2006 , 6 , 1 )),
147+ (" Patient_B" , " molecule" , " " , makeTS(2006 , 5 , 1 )),
148+ (" Patient_B" , " molecule" , " " , makeTS(2007 , 1 , 1 )),
149+ (" Patient_C" , " molecule" , " " , makeTS(2006 , 11 , 1 ))
150+ ).toDF(" patientID" , " category" , " eventId" , " start" )
151+
152+ val expected = Seq (
153+ (" Patient_A" , " molecule" , " " , makeTS(2006 , 1 , 1 )),
154+ (" Patient_A" , " molecule" , " " , makeTS(2006 , 3 , 1 )),
155+ (" Patient_A" , " disease" , " targetDisease" , makeTS(2006 , 6 , 1 ))
156+ ).toDF(" patientID" , " category" , " eventId" , " start" )
157+
158+ // When
159+ import MLPPExposuresTransformer .ExposuresDataFrame
160+ val result = input.filterNeverSickPatients(true )
161+
162+ // Then
163+ import RichDataFrames ._
164+ result.show
165+ expected.show
166+ assert(result === expected)
167+ }
168+
138169 " withExposureStart" should " add a column with the start of the default MLPP exposure definition" in {
139170 val sqlCtx = sqlContext
140171 import sqlCtx .implicits ._
0 commit comments