Skip to content

Commit

Permalink
Add more comments, formatting changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dondevun committed Jan 16, 2025
1 parent dc14505 commit ea43adf
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ public Long call() {
}

/**
* Processes a claim with SamhsaUtil to check for SAMHSA codes.
* Processes a claim with SamhsaUtil to check for SAMHSA codes. Does not use Entities, instead
* using the positions in the array to determine the column type. This obviously relies on the
* queries being constructed in a particular way, so it's not ideal -- but, since it does not have
* to construct an entity, it is the fastest way to query.
*
* @param claim the claim to process
* @param datesMap Contains previously fetched claim dates for this claim id. This is useful if a
Expand Down Expand Up @@ -187,14 +190,15 @@ protected int processClaim(
}

/**
* Builds the SAMHSA query strings.
* Builds the SAMHSA query string template.
*
* @param table The table.
* @param claimField The claim id field.
* @param columns The columns to check.
* @return The query string for a particular table.
*/
protected static String buildQueryString(String table, String claimField, String... columns) {
protected static String buildQueryStringTemplate(
String table, String claimField, String... columns) {
String concatColumns = String.join(", ", columns);
StringBuilder builder = new StringBuilder();
builder.append("SELECT ");
Expand All @@ -205,8 +209,8 @@ protected static String buildQueryString(String table, String claimField, String
builder.append(table);
builder.append(
" ${gtClaimLine} ORDER BY "); // ${gtClaimLine} is used to insert the last processed claim
// id into the query. If there is no last processed claim id,
// ${gtClaimLine} will be evaluated to an empty string.
// id into the query. If there is no last processed claim id,
// ${gtClaimLine} will be evaluated to an empty string.
builder.append(claimField);
builder.append(" limit :limit"); // limit will be the batch size set in the configuration.
return builder.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class CCWSamhsaBackfill extends AbstractSamhsaBackfill {

/** carrier_claims query. */
private static final String CARRIER_CLAIMS_QUERY =
buildQueryString(
buildQueryStringTemplate(
"ccw.carrier_claims",
CLAIM_FIELD,
CLAIM_FROM_DATE,
Expand All @@ -63,15 +63,15 @@ public class CCWSamhsaBackfill extends AbstractSamhsaBackfill {

/** carrier_claim_lines query. */
private static final String CARRIER_CLAIM_LINES_QUERY =
buildQueryString(
buildQueryStringTemplate(
"ccw.carrier_claim_lines",
CLAIM_FIELD,
LINE_ICD_DIAGNOSIS_CODE_COLUMN,
HCPCS_CODE_COLUMN);

/** dme_claims query. */
private static final String DME_CLAIMS_QUERY =
buildQueryString(
buildQueryStringTemplate(
"ccw.dme_claims",
CLAIM_FIELD,
CLAIM_FROM_DATE,
Expand All @@ -81,12 +81,12 @@ public class CCWSamhsaBackfill extends AbstractSamhsaBackfill {

/** dme_claim_lines query. */
private static final String DME_CLAIM_LINES_QUERY =
buildQueryString(
buildQueryStringTemplate(
"ccw.dme_claim_lines", CLAIM_FIELD, LINE_ICD_DIAGNOSIS_CODE_COLUMN, HCPCS_CODE_COLUMN);

/** hospice_claims query. */
private static final String HOSPICE_CLAIMS_QUERY =
buildQueryString(
buildQueryStringTemplate(
"ccw.hospice_claims",
CLAIM_FIELD,
CLAIM_FROM_DATE,
Expand All @@ -98,11 +98,11 @@ public class CCWSamhsaBackfill extends AbstractSamhsaBackfill {

/** hospice_claim_lines query. */
private static final String HOSPICE_CLAIM_LINES_QUERY =
buildQueryString("ccw.hospice_claim_lines", CLAIM_FIELD, HCPCS_CODE_COLUMN);
buildQueryStringTemplate("ccw.hospice_claim_lines", CLAIM_FIELD, HCPCS_CODE_COLUMN);

/** hha_claims query. */
private static final String HHA_CLAIMS_QUERY =
buildQueryString(
buildQueryStringTemplate(
"ccw.hha_claims",
CLAIM_FIELD,
CLAIM_FROM_DATE,
Expand All @@ -114,12 +114,12 @@ public class CCWSamhsaBackfill extends AbstractSamhsaBackfill {

/** hha_claim_lines query. */
private static final String HHA_CLAIM_LINES_QUERY =
buildQueryString(
buildQueryStringTemplate(
"ccw.hha_claim_lines", CLAIM_FIELD, HCPCS_CODE_COLUMN, REV_CENTER_APC_HIPPS_CODE_COLUMN);

/** snf_claims query. */
private static final String SNF_CLAIMS_QUERY =
buildQueryString(
buildQueryStringTemplate(
"ccw.snf_claims",
CLAIM_FIELD,
CLAIM_FROM_DATE,
Expand All @@ -134,11 +134,11 @@ public class CCWSamhsaBackfill extends AbstractSamhsaBackfill {

/** snf_claim_lines query. */
private static final String SNF_CLAIM_LINES_QUERY =
buildQueryString("ccw.snf_claim_lines", CLAIM_FIELD, HCPCS_CODE_COLUMN);
buildQueryStringTemplate("ccw.snf_claim_lines", CLAIM_FIELD, HCPCS_CODE_COLUMN);

/** inpatient_claims query. */
private static final String INPATIENT_CLAIMS_QUERY =
buildQueryString(
buildQueryStringTemplate(
"ccw.inpatient_claims",
CLAIM_FIELD,
CLAIM_FROM_DATE,
Expand All @@ -153,11 +153,11 @@ public class CCWSamhsaBackfill extends AbstractSamhsaBackfill {

/** inpatient_claim_lines query. */
private static final String INPATIENT_CLAIM_LINES_QUERY =
buildQueryString("ccw.inpatient_claim_lines", CLAIM_FIELD, HCPCS_CODE_COLUMN);
buildQueryStringTemplate("ccw.inpatient_claim_lines", CLAIM_FIELD, HCPCS_CODE_COLUMN);

/** outpatient_claims query. */
private static final String OUTPATIENT_CLAIMS_QUERY =
buildQueryString(
buildQueryStringTemplate(
"ccw.outpatient_claims",
CLAIM_FIELD,
CLAIM_FROM_DATE,
Expand All @@ -171,7 +171,7 @@ public class CCWSamhsaBackfill extends AbstractSamhsaBackfill {

/** outpatient_claim_lines query. */
private static final String OUTPATIENT_CLAIM_LINES_QUERY =
buildQueryString(
buildQueryStringTemplate(
"ccw.outpatient_claim_lines",
CLAIM_FIELD,
HCPCS_CODE_COLUMN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,31 @@ public class RDASamhsaBackfill extends AbstractSamhsaBackfill {

/** mcs_diagnosis_codes query. */
private static String MCS_DIAGNOSIS_QUERY =
buildQueryString("rda.mcs_diagnosis_codes", MCS_CLAIM_ID_FIELD, MCS_DIAGNOSIS_SAMHSA_COLUMNS);
buildQueryStringTemplate(
"rda.mcs_diagnosis_codes", MCS_CLAIM_ID_FIELD, MCS_DIAGNOSIS_SAMHSA_COLUMNS);

/** mcs_details query. */
private static String MCS_DETAILS_QUERY =
buildQueryString("rda.mcs_details", MCS_CLAIM_ID_FIELD, MCS_DETAILS_SAMHSA_COLUMNS);
buildQueryStringTemplate("rda.mcs_details", MCS_CLAIM_ID_FIELD, MCS_DETAILS_SAMHSA_COLUMNS);

/** fiss_claims query. */
private static String FISS_QUERY =
buildQueryString("rda.fiss_claims", FISS_CLAIM_ID_FIELD, FISS_SAMHSA_COLUMNS);
buildQueryStringTemplate("rda.fiss_claims", FISS_CLAIM_ID_FIELD, FISS_SAMHSA_COLUMNS);

/** fiss_revenue_lines query. */
private static String FISS_REVENUE_QUERY =
buildQueryString(
buildQueryStringTemplate(
"rda.fiss_revenue_lines", FISS_CLAIM_ID_FIELD, FISS_REVENUE_LINES_SAMHSA_COLUMNS);

/** fiss_diagnosis_codes query. */
private static String FISS_DIAGNOSIS_QUERY =
buildQueryString(
buildQueryStringTemplate(
"rda.fiss_diagnosis_codes", FISS_CLAIM_ID_FIELD, FISS_DIAGNOSIS_SAMHSA_COLUMNS);

/** fiss_proc_codes query. */
private static String FISS_PROC_QUERY =
buildQueryString("rda.fiss_proc_codes", FISS_CLAIM_ID_FIELD, FISS_PROC_SAMHSA_COLUMNS);
buildQueryStringTemplate(
"rda.fiss_proc_codes", FISS_CLAIM_ID_FIELD, FISS_PROC_SAMHSA_COLUMNS);

/** The list of table entries for RDA claims. */
public enum RDA_TABLES {
Expand Down

0 comments on commit ea43adf

Please sign in to comment.