@@ -292,4 +292,34 @@ public void adjustBMIVectorForSuccessfulManagementRunOnce() {
292292 assertEquals (expectedTailAge , pgt .tail ().ageInMonths );
293293 assertEquals (expectedBMI , pgt .tail ().bmi , 0.001 );
294294 }
295- }
295+
296+ @ Test
297+ public void transitionRegression () {
298+ long birthDay = TestHelper .timestamp (1990 , 1 , 1 , 0 , 0 , 0 );
299+ long weightLossStart = TestHelper .timestamp (2003 , 12 , 2 , 0 , 0 , 0 );
300+ long transitionRegressionTime = TestHelper .timestamp (2010 , 1 , 1 , 0 , 0 , 0 );
301+ Person person = new Person (0L );
302+ String gender = "M" ;
303+ double bmiPercentileChange = 0.01 ;
304+ person .attributes .put (Person .BIRTHDATE , birthDay );
305+ person .attributes .put (Person .GENDER , gender );
306+ person .attributes .put (WeightLossModule .WEIGHT_MANAGEMENT_START , weightLossStart );
307+ person .attributes .put (WeightLossModule .WEIGHT_LOSS_BMI_PERCENTILE_CHANGE , bmiPercentileChange );
308+ person .setVitalSign (VitalSign .HEIGHT_PERCENTILE , 0.75 );
309+ PediatricGrowthTrajectory pgt = new PediatricGrowthTrajectory (0L , birthDay );
310+ int yearToCheck = 1993 ;
311+ for (int i = 0 ; i < 17 ; i ++) {
312+ long timeToCheck = TestHelper .timestamp (yearToCheck + i , 1 , 1 , 0 , 0 , 0 );
313+ pgt .currentBMI (person , timeToCheck );
314+ }
315+
316+ person .attributes .put (Person .GROWTH_TRAJECTORY , pgt );
317+
318+ double weight = mod .transitionRegression (person , transitionRegressionTime );
319+ // The seeded pgt will target a BMI around 24.9 at age 20
320+ // The person is in the 75th percentile for height which would make them ~181.65 cm
321+ // Therefore, the weight should be about 82.14 kg, since this is the end of the transition
322+ // back to the original weight trajectory
323+ assertEquals (82.14 , weight , 0.01 );
324+ }
325+ }
0 commit comments