Skip to content

Commit

Permalink
Merge branch 'master' into same-row-rules-130
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/com/imsweb/mph/mpgroups/GroupUtility.java
#	src/test/java/com/imsweb/mph/GroupUtilityTest.java
  • Loading branch information
bekeles committed Oct 31, 2023
2 parents b46406b + 7170686 commit 372c5f4
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 4 deletions.
12 changes: 11 additions & 1 deletion src/main/java/com/imsweb/mph/mpgroups/GroupUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ public static boolean sameHistologies(String icd1, String icd2) {

}

/**
* check if diagnosis dates are valid and same
*/
public static boolean sameKnownDateParts(MphInput i1, MphInput i2) {
DateFieldParts date = new DateFieldParts(i1, i2);
return date.getYear1() != null && date.getYear1().equals(date.getYear2()) &&
(date.getMonth1() == null || date.getMonth2() == null || (date.getMonth1().equals(date.getMonth2()) &&
(date.getDay1() == null || date.getDay2() == null || date.getDay1().equals(date.getDay2()))));
}

/**
* Checks if integer value is in a list of ranges
*/
Expand Down Expand Up @@ -379,7 +389,7 @@ public DateFieldParts(MphInput input1, MphInput input2) {
_month2 = NumberUtils.isDigits(input2.getDateOfDiagnosisMonth()) ? Integer.parseInt(input2.getDateOfDiagnosisMonth()) : null;
if (_month2 != null && (_month2 < 1 || _month2 > 12))
_month2 = null;
_day1 = _month1 != null && NumberUtils.isDigits(input1.getDateOfDiagnosisDay())? Integer.parseInt(input1.getDateOfDiagnosisDay()) : null;
_day1 = _month1 != null && NumberUtils.isDigits(input1.getDateOfDiagnosisDay()) ? Integer.parseInt(input1.getDateOfDiagnosisDay()) : null;
if (_year1 != null && _day1 != null && _day1 > LocalDate.of(_year1, _month1, 1).lengthOfMonth())
_day1 = null;
_day2 = _month2 != null && NumberUtils.isDigits(input2.getDateOfDiagnosisDay()) ? Integer.parseInt(input2.getDateOfDiagnosisDay()) : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

import com.imsweb.mph.MphConstants;
import com.imsweb.mph.MphGroup;
Expand Down Expand Up @@ -447,9 +446,9 @@ public TempRuleResult apply(MphInput i1, MphInput i2, RuleExecutionContext conte
if (GroupUtility.differentCategory(i1.getHistology(), i2.getHistology(), MphConstants.PTLD, combined)) {
//Even if the dx date is known to be the same, we don't know if it is in one biopsy.
//If dx date is same, return a potential single primary! If M15 confirms the cases as single, we will return single.
if (i1.getDateOfDiagnosisYear().equals(i2.getDateOfDiagnosisYear()) && Objects.equals(i1.getDateOfDiagnosisMonth(), i2.getDateOfDiagnosisMonth()) && Objects.equals(i1.getDateOfDiagnosisDay(), i2.getDateOfDiagnosisDay())) {
if (GroupUtility.sameKnownDateParts(i1, i2)) {
result.setPotentialResult(MphUtils.MpResult.SINGLE_PRIMARY);
result.setMessageUnknownDiagnosisDate(this.getStep(), this.getGroupName());
result.setMessage("Unable to apply Rule " + this.getStep() + " of " + this.getGroupName() + ". Manual review required to determine whether the histologies were diagnosed from the same biopsy.");
}
}
return result;
Expand Down
29 changes: 29 additions & 0 deletions src/test/java/com/imsweb/mph/GroupUtilityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,35 @@ public void testSameHistologies() {
Assert.assertFalse(GroupUtility.sameHistologies("8000/3", "8000/3"));
}

@Test
public void testSameKnownDateParts() {
MphInput i1 = new MphInput();
MphInput i2 = new MphInput();
Assert.assertFalse(GroupUtility.sameKnownDateParts(i1, i2));
i1.setDateOfDiagnosisYear("2010");
Assert.assertFalse(GroupUtility.sameKnownDateParts(i1, i2));
i2.setDateOfDiagnosisYear("2011");
Assert.assertFalse(GroupUtility.sameKnownDateParts(i1, i2));
i2.setDateOfDiagnosisYear("2010");
Assert.assertTrue(GroupUtility.sameKnownDateParts(i1, i2));
i1.setDateOfDiagnosisMonth("02");
Assert.assertTrue(GroupUtility.sameKnownDateParts(i1, i2));
i2.setDateOfDiagnosisMonth("99");
Assert.assertTrue(GroupUtility.sameKnownDateParts(i1, i2));
i2.setDateOfDiagnosisMonth("03");
Assert.assertFalse(GroupUtility.sameKnownDateParts(i1, i2));
i2.setDateOfDiagnosisMonth("02");
Assert.assertTrue(GroupUtility.sameKnownDateParts(i1, i2));
i1.setDateOfDiagnosisDay("03");
Assert.assertTrue(GroupUtility.sameKnownDateParts(i1, i2));
i2.setDateOfDiagnosisDay("AA");
Assert.assertTrue(GroupUtility.sameKnownDateParts(i1, i2));
i2.setDateOfDiagnosisDay("03");
Assert.assertTrue(GroupUtility.sameKnownDateParts(i1, i2));
i2.setDateOfDiagnosisDay("04");
Assert.assertFalse(GroupUtility.sameKnownDateParts(i1, i2));
}

@Test
public void testValidateProperties() {
Assert.assertFalse(GroupUtility.validateProperties(null, "8100", "1", 2007));
Expand Down
19 changes: 19 additions & 0 deletions src/test/java/com/imsweb/mph/MphUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2166,6 +2166,25 @@ public void test2010Hematopoietic() {
i2.setDateOfDiagnosisDay("02"); //skip if they are not same date
output = _utils.computePrimaries(i1, i2);
Assert.assertEquals(15, output.getAppliedRules().size());
//Same know dates (day part is missing and invalid)
i1.setDateOfDiagnosisYear("2010");
i2.setDateOfDiagnosisYear("2010");
i1.setDateOfDiagnosisMonth("01");
i2.setDateOfDiagnosisMonth("01");
i1.setDateOfDiagnosisDay("99");
i2.setDateOfDiagnosisDay("AA");
output = _utils.computePrimaries(i1, i2);
Assert.assertEquals(14, output.getAppliedRules().size());
Assert.assertEquals(MphUtils.MpResult.QUESTIONABLE, output.getResult());
//Same know dates (month part is missing also)
i2.setDateOfDiagnosisMonth(null);
output = _utils.computePrimaries(i1, i2);
Assert.assertEquals(14, output.getAppliedRules().size());
Assert.assertEquals(MphUtils.MpResult.QUESTIONABLE, output.getResult());
//Month is different
i2.setDateOfDiagnosisMonth("02");
output = _utils.computePrimaries(i1, i2);
Assert.assertEquals(15, output.getAppliedRules().size());

//M15 Use the Heme DB Multiple Primaries Calculator to determine the number of primaries
Assert.assertEquals(MphUtils.MpResult.MULTIPLE_PRIMARIES, output.getResult());//9732 and 9971 are not same primaries
Expand Down

0 comments on commit 372c5f4

Please sign in to comment.