Skip to content
Merged
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
11 changes: 6 additions & 5 deletions src/main/java/com/imsweb/algorithms/StateCountyInputDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,26 @@

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.apache.commons.lang3.math.NumberUtils;

public class StateCountyInputDto {

//Valid NAACCR values for state at dx
private static final List<String> _VALID_STATES = Arrays.asList("AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FL", "GA",
private static final Set<String> _VALID_STATES = new HashSet<>(Arrays.asList("AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FL", "GA",
"HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ",
"NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY",
"AS", "GU", "MP", "PW", "PR", "UM", "VI", "FM", "MH", "TT", "AB", "BC", "MB", "NB", "NL", "NS", "NT", "NU", "ON", "PE",
"QC", "SK", "YT", "AA", "AE", "AP");
"QC", "SK", "YT", "AA", "AE", "AP"));

//NAACCR values for missing or unknown state at dx
private static final List<String> _MISSING_OR_UNKNOWN_STATES = Arrays.asList("", "CD", "US", "XX", "YY", "ZZ");
private static final Set<String> _MISSING_OR_UNKNOWN_STATES = new HashSet<>(Arrays.asList("", "CD", "US", "XX", "YY", "ZZ"));

//NAACCR values for missing or unknown county at dx
private static final List<String> _MISSING_OR_UNKNOWN_COUNTIES = Arrays.asList("", "999");
private static final Set<String> _MISSING_OR_UNKNOWN_COUNTIES = new HashSet<>(Arrays.asList("", "999"));

// SEER City recodes
private static final Map<String, String> _SEER_CITY_RECODES = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
package com.imsweb.algorithms;

import java.util.Arrays;
import java.util.List;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang3.math.NumberUtils;

Expand All @@ -15,7 +16,7 @@ public enum CensusTract {
}

//NAACCR values for missing or unknown census tract
private static final List<String> _MISSING_OR_UNKNOWN_CENSUS_TRACTS = Arrays.asList("", "000000", "999999");
private static final Set<String> _MISSING_OR_UNKNOWN_CENSUS_TRACTS = new HashSet<>(Arrays.asList("", "000000", "999999"));

private String _censusTract2000;
private String _censusTract2010;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;

Expand Down Expand Up @@ -38,7 +39,7 @@ public final class CountyAtDxAnalysisUtils {
public static final String OTHER_STATE_OR_DX_YEAR_BLANK = "10";
public static final String OTHER_REP_AND_GEO_BLANK = "10.1";

private static final List<String> _CANADIAN_STATE_ABBREVIATIONS = Arrays.asList("AB", "BC", "MB", "NB", "NL", "NS", "NT", "NU", "ON", "PE", "QC", "SK", "YT");
private static final Set<String> _CANADIAN_STATE_ABBREVIATIONS = new HashSet<>(Arrays.asList("AB", "BC", "MB", "NB", "NL", "NS", "NT", "NU", "ON", "PE", "QC", "SK", "YT"));

private CountyAtDxAnalysisUtils() {
// no instances of this class allowed!
Expand Down Expand Up @@ -115,11 +116,11 @@ else if (!isBlankOrNineFilled(geocoderCertainty) && isBlankOrNineFilled(input.ge
output.setCountyAtDxAnalysis(geocoderCountyAtDx);
output.setCountyAtDxAnalysisFlag(GEO_CERT_KNOWN_REP_UNK);
}
else if (Arrays.asList("1", "6").contains(geocoderCertainty)) {
else if ("1".equals(geocoderCertainty) || "6".equals(geocoderCertainty)) {
output.setCountyAtDxAnalysis(geocoderCountyAtDx);
output.setCountyAtDxAnalysisFlag(GEO_CERT_1_OR_6);
}
else if (Arrays.asList("2", "3", "4").contains(geocoderCertainty)) {
else if ("2".equals(geocoderCertainty) || "3".equals(geocoderCertainty) || "4".equals(geocoderCertainty)) {
output.setCountyAtDxAnalysis(input.getCountyAtDx());
output.setCountyAtDxAnalysisFlag(REP_CERT_2_3_OR_4);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
*/
package com.imsweb.algorithms.derivedgrade;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang3.ArrayUtils;

public final class DerivedSummaryGradeUtils {
Expand All @@ -15,12 +19,12 @@ public final class DerivedSummaryGradeUtils {

private static final String _BREAST_SCHEMA = "00480";

private static final String[] _SPECIAL_SCHEMAS = new String[] {"00790", "00795", "00811", "00812", "00821", "00822", "00830"};
private static final Set<String> _SPECIAL_SCHEMAS = new HashSet<>(Arrays.asList("00790", "00795", "00811", "00812", "00821", "00822", "00830"));

private static final String[] _PRIO_BREAST_IN_SITU = new String[] {"H", "M", "L", "3", "2", "1", "D", "C", "B", "A", "9", null};
private static final String[] _PRIO_BREAST_MALIGNANT = new String[] {"3", "2", "1", "H", "M", "L", "D", "C", "B", "A", "9", null};
private static final String[] _PRIO_SPECIAL = new String[] {"8", null};
private static final String[] _PRIO_OTHER = new String[] {"S", "5", "4", "3", "2", "1", "E", "D", "C", "B", "A", "H", "M", "L", "9", null};
private static final String[] _PRIORITY_BREAST_IN_SITU = new String[] {"H", "M", "L", "3", "2", "1", "D", "C", "B", "A", "9", null};
private static final String[] _PRIORITY_BREAST_MALIGNANT = new String[] {"3", "2", "1", "H", "M", "L", "D", "C", "B", "A", "9", null};
private static final String[] _PRIORITY_SPECIAL = new String[] {"8", null};
private static final String[] _PRIORITY_OTHER = new String[] {"S", "5", "4", "3", "2", "1", "E", "D", "C", "B", "A", "H", "M", "L", "9", null};

private DerivedSummaryGradeUtils() {
// no instances of this class allowed!
Expand All @@ -30,14 +34,14 @@ public static String deriveSummaryGrade(String schemaId, String behavior, String
String[] priorities = null;
if (_BREAST_SCHEMA.equals(schemaId)) {
if ("2".equals(behavior))
priorities = _PRIO_BREAST_IN_SITU;
priorities = _PRIORITY_BREAST_IN_SITU;
else if ("3".equals(behavior))
priorities = _PRIO_BREAST_MALIGNANT;
priorities = _PRIORITY_BREAST_MALIGNANT;
}
else if (ArrayUtils.contains(_SPECIAL_SCHEMAS, schemaId))
priorities = _PRIO_SPECIAL;
else if (_SPECIAL_SCHEMAS.contains(schemaId))
priorities = _PRIORITY_SPECIAL;
else
priorities = _PRIO_OTHER;
priorities = _PRIORITY_OTHER;

if (priorities != null) {

Expand Down
107 changes: 56 additions & 51 deletions src/main/java/com/imsweb/algorithms/iarc/IarcUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.apache.commons.lang3.math.NumberUtils;
import org.apache.commons.lang3.tuple.Pair;

import com.imsweb.algorithms.internal.Utils;

Expand All @@ -26,6 +29,37 @@ public final class IarcUtils {
public static final Integer PRIMARY = 1;
public static final Integer INSITU = 9;

private static final Set<String> _SITE_GROUP_C02 = new HashSet<>(Arrays.asList("C01", "C02"));
private static final Set<String> _SITE_GROUP_C06 = new HashSet<>(Arrays.asList("C00", "C03", "C04", "C05", "C06"));
private static final Set<String> _SITE_GROUP_C14 = new HashSet<>(Arrays.asList("C09", "C10", "C12", "C13", "C14"));
private static final Set<String> _SITE_GROUP_C20 = new HashSet<>(Arrays.asList("C19", "C20"));
private static final Set<String> _SITE_GROUP_C24 = new HashSet<>(Arrays.asList("C23", "C24"));
private static final Set<String> _SITE_GROUP_C34 = new HashSet<>(Arrays.asList("C33", "C34"));
private static final Set<String> _SITE_GROUP_C41 = new HashSet<>(Arrays.asList("C40", "C41"));
private static final Set<String> _SITE_GROUP_C68 = new HashSet<>(Arrays.asList("C65", "C66", "C67", "C68"));

private static final List<Pair<List<Object>, Integer>> _HISTOLOGY_RANGES = new ArrayList<>();

static {
_HISTOLOGY_RANGES.add(Pair.of(Utils.expandHistologiesAsIntegers("8051-8084,8120-8131"), 1));
_HISTOLOGY_RANGES.add(Pair.of(Utils.expandHistologiesAsIntegers("8090-8110"), 2));
_HISTOLOGY_RANGES.add(Pair.of(Utils.expandHistologiesAsIntegers("8140-8149,8160-8162,8190-8221,8260-8337,8350-8551,8570-8576,8940-8941"), 3));
_HISTOLOGY_RANGES.add(Pair.of(Utils.expandHistologiesAsIntegers("8030-8046,8150-8157,8170-8180,8230-8255,8340-8347,8560-8562,8580-8671"), 4));
_HISTOLOGY_RANGES.add(Pair.of(Utils.expandHistologiesAsIntegers("8010-8015,8020-8022,8050"), 5));
_HISTOLOGY_RANGES.add(Pair.of(Utils.expandHistologiesAsIntegers("8680-8713,8800-8921,8990-8991,9040-9044,9120-9125,9130-9136,9141-9252,9370-9373,9540-9582"), 6));
_HISTOLOGY_RANGES.add(Pair.of(Utils.expandHistologiesAsIntegers("9050-9055"), 7));
_HISTOLOGY_RANGES.add(Pair.of(Utils.expandHistologiesAsIntegers("9840,9861-9931,9945-9946,9950,9961-9964,9980-9987,9991-9992"), 8));
_HISTOLOGY_RANGES.add(Pair.of(Utils.expandHistologiesAsIntegers("9597,9670-9699,9712,9728,9731-9738,9761-9767,9769,9811-9818,9823-9826,9833,9836,9940"), 9));
_HISTOLOGY_RANGES.add(Pair.of(Utils.expandHistologiesAsIntegers("9700-9726,9729,9768,9827-9831,9834,9837,9948"), 10));
_HISTOLOGY_RANGES.add(Pair.of(Utils.expandHistologiesAsIntegers("9650-9667"), 11));
_HISTOLOGY_RANGES.add(Pair.of(Utils.expandHistologiesAsIntegers("9740-9742"), 12));
_HISTOLOGY_RANGES.add(Pair.of(Utils.expandHistologiesAsIntegers("9750-9759"), 13));
_HISTOLOGY_RANGES.add(Pair.of(Utils.expandHistologiesAsIntegers("9590-9591,9596,9727,9760,9800-9809,9820,9832,9835,9860,9960,9965-9975,9989"), 14));
_HISTOLOGY_RANGES.add(Pair.of(Utils.expandHistologiesAsIntegers("9140"), 15));
_HISTOLOGY_RANGES.add(Pair.of(Utils.expandHistologiesAsIntegers("8720-8790,8930-8936,8950-8983,9000-9030,9060-9110,9260-9365,9380-9539"), 16));
_HISTOLOGY_RANGES.add(Pair.of(Utils.expandHistologiesAsIntegers("8000-8005"), 17));
}

private IarcUtils() {
// utility class
}
Expand Down Expand Up @@ -112,21 +146,21 @@ private static String calculateSiteGroup(String site) {
String siteGroup = site != null && site.length() >= 3 ? site.toUpperCase().substring(0, 3) : null;

if (siteGroup != null) {
if (Arrays.asList("C01", "C02").contains(siteGroup))
if (_SITE_GROUP_C02.contains(siteGroup))
siteGroup = "C02";
else if (Arrays.asList("C00", "C03", "C04", "C05", "C06").contains(siteGroup))
else if (_SITE_GROUP_C06.contains(siteGroup))
siteGroup = "C06";
else if (Arrays.asList("C09", "C10", "C12", "C13", "C14").contains(siteGroup))
else if (_SITE_GROUP_C14.contains(siteGroup))
siteGroup = "C14";
else if (Arrays.asList("C19", "C20").contains(siteGroup))
else if (_SITE_GROUP_C20.contains(siteGroup))
siteGroup = "C20";
else if (Arrays.asList("C23", "C24").contains(siteGroup))
else if (_SITE_GROUP_C24.contains(siteGroup))
siteGroup = "C24";
else if (Arrays.asList("C33", "C34").contains(siteGroup))
else if (_SITE_GROUP_C34.contains(siteGroup))
siteGroup = "C34";
else if (Arrays.asList("C40", "C41").contains(siteGroup))
else if (_SITE_GROUP_C41.contains(siteGroup))
siteGroup = "C41";
else if (Arrays.asList("C65", "C66", "C67", "C68").contains(siteGroup))
else if (_SITE_GROUP_C68.contains(siteGroup))
siteGroup = "C68";
}

Expand All @@ -138,41 +172,12 @@ private static Integer calculateHistGroup(String histology) {

if (NumberUtils.isDigits(histology)) {
int hist = NumberUtils.toInt(histology);

if (Utils.isHistologyContained("8051-8084,8120-8131", hist))
histologyGroup = 1;
else if (Utils.isHistologyContained("8090-8110", hist))
histologyGroup = 2;
else if (Utils.isHistologyContained("8140-8149,8160-8162,8190-8221,8260-8337,8350-8551,8570-8576,8940-8941", hist))
histologyGroup = 3;
else if (Utils.isHistologyContained("8030-8046,8150-8157,8170-8180,8230-8255,8340-8347,8560-8562,8580-8671", hist))
histologyGroup = 4;
else if (Utils.isHistologyContained("8010-8015,8020-8022,8050", hist))
histologyGroup = 5;
else if (Utils.isHistologyContained("8680-8713,8800-8921,8990-8991,9040-9044,9120-9125,9130-9136,9141-9252,9370-9373,9540-9582", hist))
histologyGroup = 6;
else if (Utils.isHistologyContained("9050-9055", hist))
histologyGroup = 7;
else if (Utils.isHistologyContained("9840,9861-9931,9945-9946,9950,9961-9964,9980-9987,9991-9992", hist))
histologyGroup = 8;
else if (Utils.isHistologyContained("9597,9670-9699,9712,9728,9731-9738,9761-9767,9769,9811-9818,9823-9826,9833,9836,9940", hist))
histologyGroup = 9;
else if (Utils.isHistologyContained("9700-9726,9729,9768,9827-9831,9834,9837,9948", hist))
histologyGroup = 10;
else if (Utils.isHistologyContained("9650-9667", hist))
histologyGroup = 11;
else if (Utils.isHistologyContained("9740-9742", hist))
histologyGroup = 12;
else if (Utils.isHistologyContained("9750-9759", hist))
histologyGroup = 13;
else if (Utils.isHistologyContained("9590-9591,9596,9727,9760,9800-9809,9820,9832,9835,9860,9960,9965-9975,9989", hist))
histologyGroup = 14;
else if (hist == 9140)
histologyGroup = 15;
else if (Utils.isHistologyContained("8720-8790,8930-8936,8950-8983,9000-9030,9060-9110,9260-9365,9380-9539", hist))
histologyGroup = 16;
else if (Utils.isHistologyContained("8000-8005", hist))
histologyGroup = 17;
for (Pair<List<Object>, Integer> pair : _HISTOLOGY_RANGES) {
if (Utils.isContained(pair.getLeft(), hist)) {
histologyGroup = pair.getRight();
break;
}
}
}

return histologyGroup;
Expand Down Expand Up @@ -204,18 +209,18 @@ private static boolean isNosVsSpecific(IarcMpInputRecordDto rec1, IarcMpInputRec
//14 is NOS for 8-13
//5 is NOS for 1-4
return (rec1.getHistGroup() == 17 && ((rec2.getHistGroup() >= 1 && rec2.getHistGroup() <= 7) || rec2.getHistGroup() == 15 || rec2.getHistGroup() == 16)) ||
(rec2.getHistGroup() == 17 && ((rec1.getHistGroup() >= 1 && rec1.getHistGroup() <= 7) || rec1.getHistGroup() == 15 || rec1.getHistGroup() == 16)) ||
(rec1.getHistGroup() == 14 && rec2.getHistGroup() >= 8 && rec2.getHistGroup() <= 13) ||
(rec2.getHistGroup() == 14 && rec1.getHistGroup() >= 8 && rec1.getHistGroup() <= 13) ||
(rec1.getHistGroup() == 5 && rec2.getHistGroup() >= 1 && rec2.getHistGroup() <= 4) ||
(rec2.getHistGroup() == 5 && rec1.getHistGroup() >= 1 && rec1.getHistGroup() <= 4);
(rec2.getHistGroup() == 17 && ((rec1.getHistGroup() >= 1 && rec1.getHistGroup() <= 7) || rec1.getHistGroup() == 15 || rec1.getHistGroup() == 16)) ||
(rec1.getHistGroup() == 14 && rec2.getHistGroup() >= 8 && rec2.getHistGroup() <= 13) ||
(rec2.getHistGroup() == 14 && rec1.getHistGroup() >= 8 && rec1.getHistGroup() <= 13) ||
(rec1.getHistGroup() == 5 && rec2.getHistGroup() >= 1 && rec2.getHistGroup() <= 4) ||
(rec2.getHistGroup() == 5 && rec1.getHistGroup() >= 1 && rec1.getHistGroup() <= 4);
}

private static boolean needToUpdateHistology(IarcMpInputRecordDto primaryRec, IarcMpInputRecordDto dupRecord) {
return (primaryRec.getHistGroup() == 17 && ((dupRecord.getHistGroup() >= 1 && dupRecord.getHistGroup() <= 7) || dupRecord.getHistGroup() == 15 || dupRecord.getHistGroup() == 16)) ||
(primaryRec.getHistGroup() == 14 && dupRecord.getHistGroup() >= 8 && dupRecord.getHistGroup() <= 13) ||
(primaryRec.getHistGroup() == 5 && dupRecord.getHistGroup() >= 1 && dupRecord.getHistGroup() <= 4) ||
(primaryRec.getHistGroup().equals(dupRecord.getHistGroup()) && NumberUtils.toInt(primaryRec.getHistology()) < NumberUtils.toInt(dupRecord.getHistology()));
(primaryRec.getHistGroup() == 14 && dupRecord.getHistGroup() >= 8 && dupRecord.getHistGroup() <= 13) ||
(primaryRec.getHistGroup() == 5 && dupRecord.getHistGroup() >= 1 && dupRecord.getHistGroup() <= 4) ||
(primaryRec.getHistGroup().equals(dupRecord.getHistGroup()) && NumberUtils.toInt(primaryRec.getHistology()) < NumberUtils.toInt(dupRecord.getHistology()));
}

private static class InternalRecDto implements Comparable<InternalRecDto> {
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/com/imsweb/algorithms/internal/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,6 @@ public static boolean isContained(List<?> list, Integer value) {
return false;
}

public static boolean isHistologyContained(String list, Integer value) {
return isContained(expandHistologiesAsIntegers(list), value);
}

public static Map<String, Object> extractPatient(AlgorithmInput input) {
return input.getPatient() == null ? Collections.emptyMap() : input.getPatient();
}
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/com/imsweb/algorithms/napiia/NapiiaUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.ReentrantReadWriteLock;

import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -84,11 +86,11 @@ public final class NapiiaUtils {
}

//Asian birth place countries excluded from indirect identification based on names
private static final List<String> _BPC_EXCLUDE_ASIAN = Arrays.asList("MDV", "NPL", "BTN", "BGD", "LKA", "MMR", "XMS", "MYS", "SGP", "BND", "IDN", "TLS", "MNG");
private static final Set<String> _BPC_EXCLUDE_ASIAN = new HashSet<>(Arrays.asList("MDV", "NPL", "BTN", "BGD", "LKA", "MMR", "XMS", "MYS", "SGP", "BND", "IDN", "TLS", "MNG"));
//Hispanic birth place countries excluded from identification based on names
private static final List<String> _BPC_EXCLUDE_HISP = Arrays.asList("PRI", "MEX", "CUB", "DOM", "ZZC", "GTM", "HND", "SLV", "NIC", "CRI", "PAN", "ZZS", "COL", "VEN", "ECU", "PER", "BOL", "CHL",
"ARG", "PRY", "URY", "ESP", "AND");
private static final List<String> _SPANISH_ORIGIN_IS_SPANISH = Arrays.asList("1", "2", "3", "4", "5", "6", "8");
private static final Set<String> _BPC_EXCLUDE_HISP = new HashSet<>(Arrays.asList("PRI", "MEX", "CUB", "DOM", "ZZC", "GTM", "HND", "SLV", "NIC", "CRI", "PAN", "ZZS", "COL", "VEN", "ECU", "PER",
"BOL", "CHL", "ARG", "PRY", "URY", "ESP", "AND"));
private static final Set<String> _SPANISH_ORIGIN_IS_SPANISH = new HashSet<>(Arrays.asList("1", "2", "3", "4", "5", "6", "8"));

//lookups
private static final Map<String, Short> _LKUP_NAPIIA_SURNAME_CENSUS_ASIAN = new HashMap<>();
Expand Down
Loading