
com.imsweb.algorithms.tractestcongressdist.TractEstCongressDistUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of algorithms Show documentation
Show all versions of algorithms Show documentation
Java implementation of cancer-related algorithms (NHIA, NAPIIA, Survival Time, etc...)
The newest version!
/*
* Copyright (C) 2021 Information Management Services, Inc.
*/
package com.imsweb.algorithms.tractestcongressdist;
import com.imsweb.algorithms.StateCountyTractInputDto;
import com.imsweb.algorithms.StateCountyTractInputDto.CensusTract;
import com.imsweb.algorithms.internal.CensusData;
import com.imsweb.algorithms.internal.CountryData;
public final class TractEstCongressDistUtils {
public static final String ALG_NAME = "NAACCR Tract-Estimated Congressional Districts";
public static final String ALG_VERSION = "version 1.0 released in August 2021";
//Unknown values for each code
public static final String TRACT_EST_CONGRESS_DIST_UNK_A = "A";
public static final String TRACT_EST_CONGRESS_DIST_UNK_B = "B";
public static final String TRACT_EST_CONGRESS_DIST_UNK_C = "C";
public static final String TRACT_EST_CONGRESS_DIST_UNK_D = "D";
private TractEstCongressDistUtils() {
// no instances of this class allowed!
}
/**
* Calculates the Tract Estimated Congressional Districts code 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 Tract Estimated Congressional Districts will have the following values :
*
* - 00-53 = the Tract Estimated Congressional District value
* - 98 = Unknown value
* - ZZ = Unknown value
* - 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 the computed Tract Estimated Congressional Districts value
*/
public static TractEstCongressDistOutputDto computeTractEstCongressDist(StateCountyTractInputDto input) {
TractEstCongressDistOutputDto result = new TractEstCongressDistOutputDto();
input.applyRecodes();
if (input.hasInvalidStateCountyOrCensusTract(CensusTract.CENSUS_2010))
result.setTractEstCongressDist(TRACT_EST_CONGRESS_DIST_UNK_A);
else if (input.hasUnknownStateCountyOrCensusTract(CensusTract.CENSUS_2010))
result.setTractEstCongressDist(TRACT_EST_CONGRESS_DIST_UNK_D);
else if (input.countyIsNotReported())
result.setTractEstCongressDist(TRACT_EST_CONGRESS_DIST_UNK_B);
else {
CensusData censusData = CountryData.getCensusData(input, CensusTract.CENSUS_2010);
if (censusData != null)
result.setTractEstCongressDist(censusData.getCongressionalDistrict());
}
if (result.getTractEstCongressDist() == null)
result.setTractEstCongressDist(TRACT_EST_CONGRESS_DIST_UNK_C);
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy