Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (C) 2013 Information Management Services, Inc.
*/
package com.imsweb.algorithms.napiia;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.opencsv.CSVReader;
/**
* This class is used to calculate the NAPIIA variable. More information can be found here:
* http://www.naaccr.org/Research/DataAnalysisTools.aspx
*
* This Java implementation is based ONLY on the SAS implementation of the algorithm; the PDF documentation was not accurate when
* this algorithm was implemented and therefore was not taken into account.
*/
public final class NapiiaUtils {
public static final String ALG_NAME = "NAACCR Asian/Pacific Islander Identification Algorithm";
public static final String ALG_VERSION = "17";
public static final String ALG_INFO = "NHAPIIA v17 released in April 2017";
public static final String PROP_RACE1 = "race1";
public static final String PROP_RACE2 = "race2";
public static final String PROP_RACE3 = "race3";
public static final String PROP_RACE4 = "race4";
public static final String PROP_RACE5 = "race5";
public static final String PROP_SPANISH_HISPANIC_ORIGIN = "spanishHispanicOrigin";
public static final String PROP_BIRTH_PLACE_COUNTRY = "birthplaceCountry";
public static final String PROP_SEX = "sex";
public static final String PROP_NAME_LAST = "nameLast";
public static final String PROP_NAME_MAIDEN = "nameMaiden";
public static final String PROP_NAME_FIRST = "nameFirst";
public static final String REASON_1_3_3 = "More than one race 04-32 and one race 96 or 97 (step 1.3.3).";
public static final String REASON_1_3_5 = "One or more races 02-03 and one race 96 (step 1.3.5).";
public static final String REASON_1_3_6 = "One race 96 and one race 97 (step 1.3.6).";
public static final String REASON_1_3_7 = "Multiple combination of races involving race 96 (step 1.3.7).";
public static final String REASON_2_2_3 = "Multiple combination of races (step 2.2.3).";
private static final String _GENDER_MALE = "1";
private static final String _GENDER_FEMALE = "2";
// special birth place countries corresponding to a given race (indirect identification based on birth place) - Asian
private static final String[][] _BPC_ASIAN = {{"XCH", "04"}, // Chinese
{"CHN", "04"}, // Chinese
{"HKG", "04"}, // Chinese
{"TWN", "04"}, // Chinese
{"MAC", "04"}, // Chinese
{"JPN", "05"}, // Japanese
{"PHL", "06"}, // Filipino
{"KOR", "08"}, // Korean
{"PRK", "08"}, // Korean
{"VNM", "10"}, // Vietnamese
{"KHM", "13"}, // Kampuchean
{"THA", "14"}, // Thai
{"IND", "16"}, // Asian Indian
{"PAK", "17"} // Pakistan
};
private static final Map _BPC_MAP_ASIAN = new HashMap<>();
static {
for (String[] s : _BPC_ASIAN)
_BPC_MAP_ASIAN.put(s[0], s[1]);
}
// special birth place countries corresponding to a given race (indirect identification based on birth place) - Asian
private static final String[][] _BPC_PACIFIC_ISLANDER = {{"ASM", "27"}, // Samoan
{"KIR", "20"}, // Micronesian, NOS
{"FSM", "20"}, // Micronesian, NOS
{"MHL", "20"}, // Micronesian, NOS
{"PLW", "20"}, // Micronesian, NOS
{"XMC", "20"}, // Micronesian, NOS
{"NRU", "20"}, // Micronesian, NOS
{"COK", "25"}, // Polynesian, NOS
{"TUV", "25"}, // Polynesian, NOS
{"TKL", "25"}, // Polynesian, NOS
{"XPL", "25"}, // Polynesian, NOS
{"PYF", "25"}, // Polynesian, NOS
{"NFK", "25"}, // Polynesian, NOS
{"PCN", "25"}, // Polynesian, NOS
{"WSM", "25"}, // Polynesian, NOS
{"TON", "25"} // Polynesian, NOS
};
private static final Map _BPC_MAP_PACIFIC_ISLANDER = new HashMap<>();
static {
for (String[] s : _BPC_PACIFIC_ISLANDER)
_BPC_MAP_PACIFIC_ISLANDER.put(s[0], s[1]);
}
//Asian birth place countries excluded from indirect identification based on names
private static final List _BPC_EXCLUDE_ASIAN = 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 _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 _SPANISH_ORIGIN_IS_SPANISH = Arrays.asList("1", "2", "3", "4", "5", "6", "8");
//lookups
private static Map _LKUP_NAPIIA_SURNAME_CENSUS_ASIAN = new HashMap<>();
private static Map _LKUP_NAPIIA_SURNAME_CENSUS_PI = new HashMap<>();
private static Map _LKUP_NAPIIA_SURNAME_LAUD = new HashMap<>();
private static Map _LKUP_NAPIIA_GIVEN_LAUD_MALE = new HashMap<>();
private static Map _LKUP_NAPIIA_GIVEN_LAUD_FEMALE = new HashMap<>();
private static Map _LKUP_NAPIIA_SURNAME_NAACCR = new HashMap<>();
private static Map _LKUP_NAPIIA_GIVEN_NAACCR = new HashMap<>();
/**
* Calculates the NAPIIA value for the provided record.
*
* The provided record doesn't need to contain all the input variables, but the algorithm wil use the following ones:
*
*
race1 (#160)
*
race2 (#160)
*
race3 (#160)
*
race4 (#160)
*
race5 (#160)
*
spanishHispanicOrigin (#190)
*
birthplaceCountry (#254)
*
sex (#220)
*
nameLast (#2230)
*
nameMaiden (#2390)
*
nameFirst (#2240)
*
* All those properties are defined as constants in this class.
*
* Note that some of those properties are part of the full NAACCR Abstract; providing only Indicence information is not enough
* for this algorithm.
*
* This algorithm returns a result containing the calculated value, a boolean indication whether a human review is required, in which case
* a reason is also provided.
* @param record a map of properties representing a NAACCR line
* @return the computed NAPIIA Results Dto, which has a calculated napiia value, a boolean which indicates whether a human review is needed or not and a reason if human review is required
*/
public static NapiiaResultsDto computeNapiia(Map record) {
NapiiaInputRecordDto input = new NapiiaInputRecordDto();
input.setRace1(record.get(PROP_RACE1));
input.setRace2(record.get(PROP_RACE2));
input.setRace3(record.get(PROP_RACE3));
input.setRace4(record.get(PROP_RACE4));
input.setRace5(record.get(PROP_RACE5));
input.setSpanishHispanicOrigin(record.get(PROP_SPANISH_HISPANIC_ORIGIN));
input.setBirthplaceCountry(record.get(PROP_BIRTH_PLACE_COUNTRY));
input.setSex(record.get(PROP_SEX));
input.setNameLast(record.get(PROP_NAME_LAST));
input.setNameMaiden(record.get(PROP_NAME_MAIDEN));
input.setNameFirst(record.get(PROP_NAME_FIRST));
return computeNapiia(input);
}
/**
* Calculates the NAPIIA value for the provided Patient.
*
* The provided patient doesn't need to contain all the input variables, but the algorithm wil use the following ones:
*
*
race1 (#160)
*
race2 (#160)
*
race3 (#160)
*
race4 (#160)
*
race5 (#160)
*
spanishHispanicOrigin (#190)
*
birthplaceCountry (#254)
*
sex (#220)
*
nameLast (#2230)
*
nameMaiden (#2390)
*
nameFirst (#2240)
*
* All those properties are defined as constants in this class.
*
* Note that some of those properties are part of the full NAACCR Abstract; providing only Indicence information is not enough
* for this algorithm.
*
* This algorithm returns a result containing the calculated value, a boolean indication whether a human review is required, in which case
* a reason is also provided.
* @param patient a list of map of properties representing a NAACCR line
* @return the computed NAPIIA Results Dto, which has a calculated napiia value, a boolean which indicates whether a human review is needed or not and a reason if human review is required
*/
public static NapiiaResultsDto computeNapiia(List