Skip to content

Commit

Permalink
Merge pull request #144 from imsweb/invalid-date-exception-143
Browse files Browse the repository at this point in the history
Invalid date exception (#143)
  • Loading branch information
depryf authored Feb 9, 2024
2 parents cf543f3 + d469fe0 commit e3ed5cf
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Multiple Primary and Histology Coding Rules Version History

**Changes in version 1.35**

- Fixed an exception happening in GroupUtility with invalid dates. The fix in previous version was not complete.

**Changes in version 1.34**

- Implemented 2024 updates of solid tumor rules. (#136)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/imsweb/mph/mpgroups/GroupUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public DateFieldParts(MphInput input1, MphInput input2) {
if (_month2 != null && (_month2 < 1 || _month2 > 12))
_month2 = null;
_day1 = _month1 != null && NumberUtils.isDigits(input1.getDateOfDiagnosisDay()) ? Integer.parseInt(input1.getDateOfDiagnosisDay()) : null;
if (_year1 != null && _day1 != null && (_day1 < 1 && _day1 > LocalDate.of(_year1, _month1, 1).lengthOfMonth()))
if (_year1 != null && _day1 != null && (_day1 < 1 || _day1 > LocalDate.of(_year1, _month1, 1).lengthOfMonth()))
_day1 = null;
_day2 = _month2 != null && NumberUtils.isDigits(input2.getDateOfDiagnosisDay()) ? Integer.parseInt(input2.getDateOfDiagnosisDay()) : null;
if (_year2 != null && _day2 != null && (_day2 < 1 || _day2 > LocalDate.of(_year2, _month2, 1).lengthOfMonth()))
Expand Down
44 changes: 44 additions & 0 deletions src/test/java/com/imsweb/mph/GroupUtilityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,50 @@ public void testVerifyDaysApart() {
Assert.assertEquals(MphConstants.DATE_VERIFY_UNKNOWN, GroupUtility.verifyDaysApart(i2, i1, 60));
Assert.assertEquals(MphConstants.DATE_VERIFY_APART, GroupUtility.verifyDaysApart(i2, i1, 21));

i1.setDateOfDiagnosisYear("2001");
i1.setDateOfDiagnosisMonth("08");
i1.setDateOfDiagnosisDay("0");
i2.setDateOfDiagnosisYear("2001");
i2.setDateOfDiagnosisMonth("12");
i2.setDateOfDiagnosisDay("0");
Assert.assertEquals(MphConstants.DATE_VERIFY_APART, GroupUtility.verifyDaysApart(i2, i1, 60));
i1.setDateOfDiagnosisMonth("10");
Assert.assertEquals(MphConstants.DATE_VERIFY_UNKNOWN, GroupUtility.verifyDaysApart(i2, i1, 60));
Assert.assertEquals(MphConstants.DATE_VERIFY_APART, GroupUtility.verifyDaysApart(i2, i1, 21));

i1.setDateOfDiagnosisYear("2001");
i1.setDateOfDiagnosisMonth("08");
i1.setDateOfDiagnosisDay("99");
i2.setDateOfDiagnosisYear("2001");
i2.setDateOfDiagnosisMonth("12");
i2.setDateOfDiagnosisDay("99");
Assert.assertEquals(MphConstants.DATE_VERIFY_APART, GroupUtility.verifyDaysApart(i2, i1, 60));
i1.setDateOfDiagnosisMonth("10");
Assert.assertEquals(MphConstants.DATE_VERIFY_UNKNOWN, GroupUtility.verifyDaysApart(i2, i1, 60));
Assert.assertEquals(MphConstants.DATE_VERIFY_APART, GroupUtility.verifyDaysApart(i2, i1, 21));

i1.setDateOfDiagnosisYear("2001");
i1.setDateOfDiagnosisMonth("08");
i1.setDateOfDiagnosisDay("20");
i2.setDateOfDiagnosisYear("2001");
i2.setDateOfDiagnosisMonth("12");
i2.setDateOfDiagnosisDay("99");
Assert.assertEquals(MphConstants.DATE_VERIFY_APART, GroupUtility.verifyDaysApart(i2, i1, 60));
i1.setDateOfDiagnosisMonth("10");
Assert.assertEquals(MphConstants.DATE_VERIFY_UNKNOWN, GroupUtility.verifyDaysApart(i2, i1, 60));
Assert.assertEquals(MphConstants.DATE_VERIFY_APART, GroupUtility.verifyDaysApart(i2, i1, 21));

i1.setDateOfDiagnosisYear("2001");
i1.setDateOfDiagnosisMonth("08");
i1.setDateOfDiagnosisDay("99");
i2.setDateOfDiagnosisYear("2001");
i2.setDateOfDiagnosisMonth("12");
i2.setDateOfDiagnosisDay("10");
Assert.assertEquals(MphConstants.DATE_VERIFY_APART, GroupUtility.verifyDaysApart(i2, i1, 60));
i1.setDateOfDiagnosisMonth("10");
Assert.assertEquals(MphConstants.DATE_VERIFY_UNKNOWN, GroupUtility.verifyDaysApart(i2, i1, 60));
Assert.assertEquals(MphConstants.DATE_VERIFY_APART, GroupUtility.verifyDaysApart(i2, i1, 21));

}

@Test
Expand Down

0 comments on commit e3ed5cf

Please sign in to comment.