
com.imsweb.algorithms.ephtsubcounty.EphtSubCountyUtils Maven / Gradle / Ivy
/*
* Copyright (C) 2013 Information Management Services, Inc.
*/
package com.imsweb.algorithms.ephtsubcounty;
/**
* 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_C = "C";
public static final String EPHT_2010_GEO_ID_UNK_D = "D";
private static EphtSubCountyDataProvider _PROVIDER;
/**
* 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 and EPHT 2010 GEO ID 20K, 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 EphtSubCountyInputDto
input object
* @return a EphtSubCountyOutputDto
object
*/
public static EphtSubCountyOutputDto computeEphtSubCounty(EphtSubCountyInputDto input) {
EphtSubCountyOutputDto result = new EphtSubCountyOutputDto();
input.applyRecodes();
if (!input.isStateValidOrMissingOrUnknown() || !input.isCountyValidOrMissingOrUnknown() || !input.isCensusTract2010ValidOrMissingOrUnknown()) {
result.setEpht2010GeoId5k(EPHT_2010_GEO_ID_UNK_A);
result.setEpht2010GeoId20k(EPHT_2010_GEO_ID_UNK_A);
}
else if (input.isStateMissingOrUnknown() || input.isCountyMissingOrUnknown() || input.isCensusTract2010MissingOrUnknown()) {
result.setEpht2010GeoId5k(EPHT_2010_GEO_ID_UNK_D);
result.setEpht2010GeoId20k(EPHT_2010_GEO_ID_UNK_D);
}
else if ("000".equals(input.getCountyAtDxAnalysis())) {
result.setEpht2010GeoId5k("B");
result.setEpht2010GeoId20k("B");
}
else {
if (_PROVIDER == null)
initializeInternalDataProvider();
result.setEpht2010GeoId5k(_PROVIDER.getEPHT2010GeoId5k(input.getAddressAtDxState(), input.getCountyAtDxAnalysis(), input.getCensusTract2010()));
result.setEpht2010GeoId20k(_PROVIDER.getEPHT2010GeoId20k(input.getAddressAtDxState(), input.getCountyAtDxAnalysis(), input.getCensusTract2010()));
}
if (result.getEpht2010GeoId5k() == null)
result.setEpht2010GeoId5k(EPHT_2010_GEO_ID_UNK_C);
if (result.getEpht2010GeoId20k() == null)
result.setEpht2010GeoId20k(EPHT_2010_GEO_ID_UNK_C);
return result;
}
/**
* Use this method to register your own data provider instead of using the internal one that is entirely in memory.
*
* This has to be done before the first call to the compute method, or the internal one will be registered by default.
*
* Once a provider has been set, this method cannot be called (it will throw an exception).
* @param provider the EphtSubCountyDataProvider
to set
*/
public static synchronized void setDataProvider(EphtSubCountyDataProvider provider) {
if (_PROVIDER != null)
throw new RuntimeException("The data provider has already been set!");
_PROVIDER = provider;
}
private static synchronized void initializeInternalDataProvider() {
if (_PROVIDER != null)
return;
_PROVIDER = new EphtSubCountyCsvData();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy