
com.imsweb.algorithms.ephtsubcounty.EphtSubCountyUtils Maven / Gradle / Ivy
/*
* Copyright (C) 2013 Information Management Services, Inc.
*/
package com.imsweb.algorithms.ephtsubcounty;
import com.imsweb.algorithms.StateCountyTractInputDto;
import com.imsweb.algorithms.StateCountyTractInputDto.CensusTract;
import com.imsweb.algorithms.internal.CensusData;
import com.imsweb.algorithms.internal.CountryData;
import com.imsweb.algorithms.internal.CountyData;
import com.imsweb.algorithms.internal.StateData;
/**
* This class can be used to calculate EPHT 2010 GEO ID 5K and EPHT 2010 GEO ID 20K.
*/
public final class EphtSubCountyUtils {
public static final String ALG_NAME = "NPCR EPHT SubCounty";
public static final String ALG_VERSION = "version 1.0 released in August 2021";
public static final String EPHT_2010_GEO_ID_UNK_A = "A";
public static final String EPHT_2010_GEO_ID_UNK_B = "B";
public static final String EPHT_2010_GEO_ID_UNK_C = "C";
public static final String EPHT_2010_GEO_ID_UNK_D = "D";
private EphtSubCountyUtils() {
// no instances of this class allowed!
}
/**
* Calculates the EPHT 2010 GEO ID 5K and EPHT 2010 GEO ID 20K for the provided input DTO
*
* The provided input dto has the following parameters used in the calculation:
*
* - addressAtDxState (#80)
* - countyAtDxAnalysis (#89)
* - censusTract2010 (#135)
*
* All those properties are defined as constants in this class.
*
* The returned dto will have either an 11-digit value for EPHT 2010 GEO ID 5K, EPHT 2010 GEO ID 20K and EPHT 2010 GEO ID 50K, or one of the possible unknown values:
*
* - A = State, county, or tract are invalid
* - B = State and tract are valid, but county was not reported
* - C = State + county + tract combination was not found
* - D = State, county, or tract are blank or unknown/li>
*
*
* @param input a StateCountyTractInputDto
input object
* @return a EphtSubCountyOutputDto
object
*/
public static EphtSubCountyOutputDto computeEphtSubCounty(StateCountyTractInputDto input) {
EphtSubCountyOutputDto result = new EphtSubCountyOutputDto();
input.applyRecodes();
if (input.hasInvalidStateCountyOrCensusTract(CensusTract.CENSUS_2010)) {
result.setEpht2010GeoId5k(EPHT_2010_GEO_ID_UNK_A);
result.setEpht2010GeoId20k(EPHT_2010_GEO_ID_UNK_A);
result.setEpht2010GeoId50k(EPHT_2010_GEO_ID_UNK_A);
}
else if (input.hasUnknownStateCountyOrCensusTract(CensusTract.CENSUS_2010)) {
result.setEpht2010GeoId5k(EPHT_2010_GEO_ID_UNK_D);
result.setEpht2010GeoId20k(EPHT_2010_GEO_ID_UNK_D);
result.setEpht2010GeoId50k(EPHT_2010_GEO_ID_UNK_D);
}
else if (input.countyIsNotReported()) {
result.setEpht2010GeoId5k(EPHT_2010_GEO_ID_UNK_B);
result.setEpht2010GeoId20k(EPHT_2010_GEO_ID_UNK_B);
result.setEpht2010GeoId50k(EPHT_2010_GEO_ID_UNK_B);
}
else {
if (!CountryData.getInstance().isTractDataInitialized(input.getAddressAtDxState()))
CountryData.getInstance().initializeTractData(input.getAddressAtDxState());
StateData stateData = CountryData.getInstance().getTractData(input.getAddressAtDxState());
if (stateData != null) {
CountyData countyData = stateData.getCountyData(input.getCountyAtDxAnalysis());
if (countyData != null) {
CensusData censusData = countyData.getCensusData(input.getCensusTract2010());
if (censusData != null) {
result.setEpht2010GeoId5k(censusData.getEpht2010GeoId5k());
result.setEpht2010GeoId20k(censusData.getEpht2010GeoId20k());
result.setEpht2010GeoId50k(censusData.getEpht2010GeoId50k());
}
}
}
}
if (result.getEpht2010GeoId5k() == null)
result.setEpht2010GeoId5k(EPHT_2010_GEO_ID_UNK_C);
if (result.getEpht2010GeoId20k() == null)
result.setEpht2010GeoId20k(EPHT_2010_GEO_ID_UNK_C);
if (result.getEpht2010GeoId50k() == null)
result.setEpht2010GeoId50k(EPHT_2010_GEO_ID_UNK_C);
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy