From ea43adf5420089358a4be159799aa17d9c83d5cd Mon Sep 17 00:00:00 2001 From: Don DeVun Date: Thu, 16 Jan 2025 14:04:18 +0000 Subject: [PATCH] Add more comments, formatting changes. --- .../backfill/AbstractSamhsaBackfill.java | 14 ++++++---- .../samhsa/backfill/CCWSamhsaBackfill.java | 28 +++++++++---------- .../samhsa/backfill/RDASamhsaBackfill.java | 14 ++++++---- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/apps/bfd-pipeline/bfd-pipeline-shared-utils/src/main/java/gov/cms/bfd/pipeline/sharedutils/samhsa/backfill/AbstractSamhsaBackfill.java b/apps/bfd-pipeline/bfd-pipeline-shared-utils/src/main/java/gov/cms/bfd/pipeline/sharedutils/samhsa/backfill/AbstractSamhsaBackfill.java index 2a394e367a..3e589231e6 100644 --- a/apps/bfd-pipeline/bfd-pipeline-shared-utils/src/main/java/gov/cms/bfd/pipeline/sharedutils/samhsa/backfill/AbstractSamhsaBackfill.java +++ b/apps/bfd-pipeline/bfd-pipeline-shared-utils/src/main/java/gov/cms/bfd/pipeline/sharedutils/samhsa/backfill/AbstractSamhsaBackfill.java @@ -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 @@ -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 "); @@ -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(); diff --git a/apps/bfd-pipeline/bfd-pipeline-shared-utils/src/main/java/gov/cms/bfd/pipeline/sharedutils/samhsa/backfill/CCWSamhsaBackfill.java b/apps/bfd-pipeline/bfd-pipeline-shared-utils/src/main/java/gov/cms/bfd/pipeline/sharedutils/samhsa/backfill/CCWSamhsaBackfill.java index bdc502b91b..4aeaf3a0e8 100644 --- a/apps/bfd-pipeline/bfd-pipeline-shared-utils/src/main/java/gov/cms/bfd/pipeline/sharedutils/samhsa/backfill/CCWSamhsaBackfill.java +++ b/apps/bfd-pipeline/bfd-pipeline-shared-utils/src/main/java/gov/cms/bfd/pipeline/sharedutils/samhsa/backfill/CCWSamhsaBackfill.java @@ -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, @@ -63,7 +63,7 @@ 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, @@ -71,7 +71,7 @@ public class CCWSamhsaBackfill extends AbstractSamhsaBackfill { /** dme_claims query. */ private static final String DME_CLAIMS_QUERY = - buildQueryString( + buildQueryStringTemplate( "ccw.dme_claims", CLAIM_FIELD, CLAIM_FROM_DATE, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, diff --git a/apps/bfd-pipeline/bfd-pipeline-shared-utils/src/main/java/gov/cms/bfd/pipeline/sharedutils/samhsa/backfill/RDASamhsaBackfill.java b/apps/bfd-pipeline/bfd-pipeline-shared-utils/src/main/java/gov/cms/bfd/pipeline/sharedutils/samhsa/backfill/RDASamhsaBackfill.java index a2eff582c0..3a8fd14b2e 100644 --- a/apps/bfd-pipeline/bfd-pipeline-shared-utils/src/main/java/gov/cms/bfd/pipeline/sharedutils/samhsa/backfill/RDASamhsaBackfill.java +++ b/apps/bfd-pipeline/bfd-pipeline-shared-utils/src/main/java/gov/cms/bfd/pipeline/sharedutils/samhsa/backfill/RDASamhsaBackfill.java @@ -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 {