From 1b668f01568342757c1129f0347add0d9852eede Mon Sep 17 00:00:00 2001 From: Don DeVun <160619336+dondevun@users.noreply.github.com> Date: Mon, 24 Jun 2024 15:48:34 -0400 Subject: [PATCH] BFD-3134: Remove HSQL placeholders and migration.old folder (#2363) --- ...e_add_claimquerycode_and_carrclmblgnpi.sql | 14 - ...edicare_coverage_fields_to_beneficiary.sql | 9 - .../V102__rda_0_12_0_updates.sql | 34 - .../V103__change_fiss_claims_primary_key.sql | 35 - .../migration.old/V104__rda_0_12_0_hotfix.sql | 3 - .../V105__rda_0_12_0_hotfix2.sql | 3 - .../V106__rda_0_13_0_updates.sql | 3 - .../V107__reingest_fiss_claims.sql | 14 - .../V108__change_claim_id_length_rda.sql | 5 - .../V109__change_claim_id_length_rda.sql | 21 - ..._beneficiary_beneficiaryHistory_colmns.sql | 187 --- ...V110__add_loaded_batch_loaded_file_idx.sql | 10 - ...11__setup_claims_availability_function.sql | 111 -- ...Support_Medicare_BeneficiaryId_History.sql | 16 - .../V113__Create_MBI_NUM_Indexes.sql | 10 - .../migration.old/V114__s3_file_tracking.sql | 50 - .../V115__s3_data_file_progress.sql | 4 - ...__Find_Beneficiary_Identifier_Function.sql | 67 - .../V117__Remove_RDA_FK_Constraints.sql | 99 -- .../V118__rda_0_14_1_updates.sql | 19 - .../V119__add_roles_to_schema_fix.sql | 42 - ..._medicare_beneficiary_id_history_table.sql | 41 - .../V120__public_to_ccw_schema_migration.sql | 259 ---- ..._Create_beneficiary_history_temp_table.sql | 30 - ..._Rename_beneficiary_history_temp_table.sql | 21 - ...te_MbiHistory_BeneficiaryId_to_varchar.sql | 9 - .../migration.old/V16__Drop_hfj_objects.sql | 42 - .../V17__Drop_hfj_tablespaces.sql | 12 - .../migration.old/V18__Drop_trm_objects.sql | 10 - .../V19__Add_inner_join_relationships.sql | 85 - ...1__Create_beneficiary_and_claim_tables.sql | 1368 ----------------- ...0__Add_BeneficiaryHistory_beneId_index.sql | 9 - .../db/migration.old/V21__Add_MBI_hash.sql | 9 - .../migration.old/V22__Add_MBI_hash_index.sql | 12 - .../db/migration.old/V23__Add_lastUpdated.sql | 74 - .../migration.old/V24__Add_Loaded_index.sql | 8 - .../V25__Add_partd_contract_number_index.sql | 42 - ...__Add_fields_to_BeneficiariesInpatient.sql | 41 - .../V27__Create_BeneficiaryMonthlytable.sql | 144 -- ...__Create_BeneficiaryMonthlytable_Index.sql | 4 - ...d_Create_BeneficiaryMonthlytable_Index.sql | 7 - ...ter_CarrierClaimLines.hctHgbTestResult.sql | 7 - ...0__Create_preadjudicated_claims_tables.sql | 57 - .../V31__preadj_claim_table_updates.sql | 136 -- .../V32__preadj_schema_perms.sql | 35 - .../V33__preadj_rda_0_4_table_updates.sql | 61 - .../V34__preadj_rda_replay_table_updates.sql | 28 - .../V35__Modify_beneficiary_monthly_index.sql | 4 - .../V36__preadj_api_source_column.sql | 5 - .../V37__preadj_rda_0_5_table_updates.sql | 176 --- ...V38__preadj_rda_0_5_post_table_updates.sql | 16 - .../migration.old/V39__api_progress_table.sql | 15 - ...im_beneficiary_constraints_and_indexes.sql | 72 - .../V40__Table_column_rename_Beneficiary.sql | 315 ---- ...V41__Table_column_rename_CarrierClaims.sql | 144 -- .../V42__Table_column_rename_DMEClaims.sql | 138 -- .../V43__Table_column_rename_HHAClaims.sql | 176 --- ...V44__Table_column_rename_HospiceClaims.sql | 174 --- ...5__Table_column_rename_InpatientClaims.sql | 318 ---- ...__Table_column_rename_OutpatientClaims.sql | 279 ---- .../V47__Table_column_rename_PartDEvents.sql | 75 - .../V48__Table_column_rename_SNFClaims.sql | 275 ---- .../V49__Table_column_rename_BeneHistory.sql | 62 - .../V4__Correct_claim_line_index_ordering.sql | 49 - .../V50__Table_column_rename_BeneMonthly.sql | 52 - .../V51__Table_column_rename_LoadedBatch.sql | 64 - ...2__Table_column_rename_MediBeneHistory.sql | 75 - .../V53__Remove_unused_db_objects.sql | 10 - .../V54__preadj_mbi_caching_create_table.sql | 36 - ...V55__preadj_mbi_caching_populate_table.sql | 22 - ...6__preadj_mbi_caching_drop_old_columns.sql | 9 - .../V57__rda_message_metadata.sql | 12 - .../V58__Add_rif_records_skipped_Table.sql | 43 - .../V59__fiss_claims_prov_fields.sql | 4 - .../V5__Fix_claim_line_parentClaim_widths.sql | 27 - ...0__Alter_beneficiaries_bene_id_numeric.sql | 34 - .../V61__populate_bene_id_numeric.sql | 35 - .../V61__populate_bene_id_numeric.sql.conf | 7 - .../migration.old/V62__create_rda_schema.sql | 354 ----- .../V63__new_schema_snf_claims.sql | 854 ---------- .../V64__drop_pre_adj_schema.sql | 6 - ...5__Add_PreUpdate_Trigger_Beneficiaries.sql | 40 - .../V66__new_schema_snf_claims_fix.sql | 821 ---------- .../V67__new_schema_dme_claims.sql | 427 ----- .../V68__rda_dead_letter_table.sql | 23 - ...9__new_schema_hospice_claims_migration.sql | 519 ------- .../V6__Add_final_action_status_columns.sql | 40 - .../V70__new_schema_hha_claims.sql | 525 ------- .../V71__new_schema_carrier_claims.sql | 440 ------ .../V72__new_schema_inpatient_claims.sql | 965 ------------ .../V73__new_schema_outpatient_claims.sql | 843 ---------- .../V74__new_schema_partd_events.sql | 212 --- ...5__new_schema_remove_old_claims_tables.sql | 27 - .../V76__rda_meta_data_extra_columns.sql | 21 - .../V77__pac_add_rda_position.sql | 31 - .../V78__add_db_rbac_admin_functions.sql | 183 --- .../V79__add_bfd_and_rda_rbac_roles.sql | 106 -- ...s_need_to_have_monetary_representation.sql | 10 - .../V80__new_schema_beneficiaries.sql | 727 --------- .../V81__new_schema_beneficiary_monthly.sql | 102 -- .../V82__new_schema_mbi_hist.sql | 107 -- .../V83__new_schema_beneficiaries_history.sql | 101 -- .../V84__new_schema_skipped_rif_records.sql | 78 - .../V85__drop_mbi_ubique_constraint.sql | 8 - ...w_schema_remove_old_beneficiary_tables.sql | 10 - ..._schema_rebuild_claims_fk_constraints.conf | 5 - ...w_schema_rebuild_claims_fk_constraints.sql | 151 -- .../V88__new_schema_create_views.sql | 117 -- .../V89__drop_obsolete_rda_metadata_table.sql | 11 - .../V8__Add_beneficiary_hicnHash_index.sql | 17 - .../V90__new_schema_rename_to_original.sql | 534 ------- .../migration.old/V91__add_clm_grp_index.sql | 28 - .../V92__add_clm_grp_index_correction.sql | 24 - .../V93__remove_clm_grp_index.sql | 27 - .../V94__new_schema_final_cleanup.sql | 55 - .../V95__add_rda_record_source.sql | 10 - ..._add_rda_message_error_obsolete_column.sql | 1 - .../V97__recreate_pre_adj_child_tables.sql | 198 --- .../migration.old/V98__rda_0_10_0_updates.sql | 7 - .../V99__ccw_eoy_2022_audit_changes.sql | 101 -- .../V9__Create_beneficiary_history_table.sql | 28 - .../db/migration.old/createSchema.sql | 183 --- .../cms/bfd/DatabaseTestSchemaManager.java | 2 - .../database/DatabaseSchemaManager.java | 2 - ops/Dockerfile | 2 - 125 files changed, 15113 deletions(-) delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V100__update_drgcode_add_claimquerycode_and_carrclmblgnpi.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V101__add_medicare_coverage_fields_to_beneficiary.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V102__rda_0_12_0_updates.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V103__change_fiss_claims_primary_key.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V104__rda_0_12_0_hotfix.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V105__rda_0_12_0_hotfix2.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V106__rda_0_13_0_updates.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V107__reingest_fiss_claims.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V108__change_claim_id_length_rda.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V109__change_claim_id_length_rda.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V10__Add_beneficiary_beneficiaryHistory_colmns.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V110__add_loaded_batch_loaded_file_idx.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V111__setup_claims_availability_function.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V112__Drop_Support_Medicare_BeneficiaryId_History.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V113__Create_MBI_NUM_Indexes.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V114__s3_file_tracking.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V115__s3_data_file_progress.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V116__Find_Beneficiary_Identifier_Function.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V117__Remove_RDA_FK_Constraints.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V118__rda_0_14_1_updates.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V119__add_roles_to_schema_fix.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V11__Create_medicare_beneficiary_id_history_table.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V120__public_to_ccw_schema_migration.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V13__Create_beneficiary_history_temp_table.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V14__Rename_beneficiary_history_temp_table.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V15__Update_MbiHistory_BeneficiaryId_to_varchar.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V16__Drop_hfj_objects.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V17__Drop_hfj_tablespaces.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V18__Drop_trm_objects.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V19__Add_inner_join_relationships.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V1__Create_beneficiary_and_claim_tables.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V20__Add_BeneficiaryHistory_beneId_index.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V21__Add_MBI_hash.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V22__Add_MBI_hash_index.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V23__Add_lastUpdated.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V24__Add_Loaded_index.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V25__Add_partd_contract_number_index.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V26__Add_fields_to_BeneficiariesInpatient.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V27__Create_BeneficiaryMonthlytable.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V28__Create_BeneficiaryMonthlytable_Index.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V29__Drop_And_Create_BeneficiaryMonthlytable_Index.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V2__CBBD-288_Alter_CarrierClaimLines.hctHgbTestResult.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V30__Create_preadjudicated_claims_tables.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V31__preadj_claim_table_updates.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V32__preadj_schema_perms.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V33__preadj_rda_0_4_table_updates.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V34__preadj_rda_replay_table_updates.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V35__Modify_beneficiary_monthly_index.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V36__preadj_api_source_column.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V37__preadj_rda_0_5_table_updates.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V38__preadj_rda_0_5_post_table_updates.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V39__api_progress_table.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V3__Add_claim_beneficiary_constraints_and_indexes.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V40__Table_column_rename_Beneficiary.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V41__Table_column_rename_CarrierClaims.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V42__Table_column_rename_DMEClaims.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V43__Table_column_rename_HHAClaims.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V44__Table_column_rename_HospiceClaims.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V45__Table_column_rename_InpatientClaims.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V46__Table_column_rename_OutpatientClaims.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V47__Table_column_rename_PartDEvents.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V48__Table_column_rename_SNFClaims.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V49__Table_column_rename_BeneHistory.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V4__Correct_claim_line_index_ordering.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V50__Table_column_rename_BeneMonthly.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V51__Table_column_rename_LoadedBatch.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V52__Table_column_rename_MediBeneHistory.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V53__Remove_unused_db_objects.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V54__preadj_mbi_caching_create_table.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V55__preadj_mbi_caching_populate_table.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V56__preadj_mbi_caching_drop_old_columns.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V57__rda_message_metadata.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V58__Add_rif_records_skipped_Table.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V59__fiss_claims_prov_fields.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V5__Fix_claim_line_parentClaim_widths.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V60__Alter_beneficiaries_bene_id_numeric.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V61__populate_bene_id_numeric.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V61__populate_bene_id_numeric.sql.conf delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V62__create_rda_schema.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V63__new_schema_snf_claims.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V64__drop_pre_adj_schema.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V65__Add_PreUpdate_Trigger_Beneficiaries.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V66__new_schema_snf_claims_fix.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V67__new_schema_dme_claims.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V68__rda_dead_letter_table.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V69__new_schema_hospice_claims_migration.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V6__Add_final_action_status_columns.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V70__new_schema_hha_claims.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V71__new_schema_carrier_claims.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V72__new_schema_inpatient_claims.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V73__new_schema_outpatient_claims.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V74__new_schema_partd_events.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V75__new_schema_remove_old_claims_tables.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V76__rda_meta_data_extra_columns.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V77__pac_add_rda_position.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V78__add_db_rbac_admin_functions.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V79__add_bfd_and_rda_rbac_roles.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V7__CBBF-147_Inpatient_Claim_fields_need_to_have_monetary_representation.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V80__new_schema_beneficiaries.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V81__new_schema_beneficiary_monthly.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V82__new_schema_mbi_hist.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V83__new_schema_beneficiaries_history.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V84__new_schema_skipped_rif_records.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V85__drop_mbi_ubique_constraint.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V86__new_schema_remove_old_beneficiary_tables.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V87__new_schema_rebuild_claims_fk_constraints.conf delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V87__new_schema_rebuild_claims_fk_constraints.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V88__new_schema_create_views.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V89__drop_obsolete_rda_metadata_table.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V8__Add_beneficiary_hicnHash_index.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V90__new_schema_rename_to_original.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V91__add_clm_grp_index.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V92__add_clm_grp_index_correction.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V93__remove_clm_grp_index.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V94__new_schema_final_cleanup.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V95__add_rda_record_source.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V96__add_rda_message_error_obsolete_column.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V97__recreate_pre_adj_child_tables.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V98__rda_0_10_0_updates.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V99__ccw_eoy_2022_audit_changes.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V9__Create_beneficiary_history_table.sql delete mode 100644 apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/createSchema.sql diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V100__update_drgcode_add_claimquerycode_and_carrclmblgnpi.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V100__update_drgcode_add_claimquerycode_and_carrclmblgnpi.sql deleted file mode 100644 index 3992b6b417..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V100__update_drgcode_add_claimquerycode_and_carrclmblgnpi.sql +++ /dev/null @@ -1,14 +0,0 @@ --- This script is to alter the clm_drg_code datatype size from 3 to 4 characters for --- the inpatient and snf claims tables, add the claim_query_code to the hha --- and hospice claims tables, and add the carr_clm_blg_npi_num to the carrier claims table. - --- Update DRG Code from 3 to 4 characters -ALTER TABLE public.inpatient_claims ALTER COLUMN clm_drg_cd ${logic.alter-column-type} varchar(4); -ALTER TABLE public.snf_claims ALTER COLUMN clm_drg_cd ${logic.alter-column-type} varchar(4); - --- Add claim query code to the HHA Claims and Hospice Claims table. -ALTER TABLE public.hha_claims ADD claim_query_code character(1); -ALTER TABLE public.hospice_claims ADD claim_query_code character(1); - --- Add carrier claim blg npi number to the Carrier Claims table. -ALTER TABLE public.carrier_claims ADD carr_clm_blg_npi_num varchar(10); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V101__add_medicare_coverage_fields_to_beneficiary.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V101__add_medicare_coverage_fields_to_beneficiary.sql deleted file mode 100644 index 3a7388f64b..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V101__add_medicare_coverage_fields_to_beneficiary.sql +++ /dev/null @@ -1,9 +0,0 @@ --- This script is to add the Medicare Part A Start and End Dates, --- Part B Start and End Dates, and Part D Start and End Dates to the Beneficiaries table. - -ALTER TABLE public.beneficiaries ADD pta_cvrg_strt_dt date; -ALTER TABLE public.beneficiaries ADD pta_cvrg_end_dt date; -ALTER TABLE public.beneficiaries ADD ptb_cvrg_strt_dt date; -ALTER TABLE public.beneficiaries ADD ptb_cvrg_end_dt date; -ALTER TABLE public.beneficiaries ADD ptd_cvrg_strt_dt date; -ALTER TABLE public.beneficiaries ADD ptd_cvrg_end_dt date; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V102__rda_0_12_0_updates.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V102__rda_0_12_0_updates.sql deleted file mode 100644 index e0720da1dd..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V102__rda_0_12_0_updates.sql +++ /dev/null @@ -1,34 +0,0 @@ --- As part of the 0.12 RDA API update, new claim level fields added and revenue lines support added - -alter table rda.fiss_claims add received_date_text varchar(10); -alter table rda.fiss_claims add curr_tran_date_text varchar(10); -alter table rda.fiss_claims add drg_cd varchar(4); -alter table rda.fiss_claims add group_code varchar(2); -alter table rda.fiss_claims add clm_typ_ind varchar(1); - -/* - * fiss_revenue_lines - */ -CREATE TABLE rda.fiss_revenue_lines ( - dcn varchar(23) NOT NULL, - rda_position smallint NOT NULL, - non_bill_rev_code varchar(1) NOT NULL, - rev_cd varchar(4), - rev_units_billed integer, - rev_serv_unit_cnt integer, - serv_dt_cymd date, - serv_dt_cymd_text varchar(10), - hcpc_cd varchar(5), - hcpc_ind varchar(1), - hcpc_modifier varchar(2), - hcpc_modifier2 varchar(2), - hcpc_modifier3 varchar(2), - hcpc_modifier4 varchar(2), - hcpc_modifier5 varchar(2), - apc_hcpcs_apc varchar(5), - aco_red_rarc varchar(5), - aco_red_carc varchar(3), - aco_red_cagc varchar(2), - CONSTRAINT fiss_revenue_lines_key PRIMARY KEY (dcn, rda_position), - CONSTRAINT fiss_revenue_lines_parent FOREIGN KEY (dcn) REFERENCES rda.fiss_claims(dcn) -); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V103__change_fiss_claims_primary_key.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V103__change_fiss_claims_primary_key.sql deleted file mode 100644 index 71d5a56636..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V103__change_fiss_claims_primary_key.sql +++ /dev/null @@ -1,35 +0,0 @@ --- PACA-751 switches to using a new RDA API primary key field for FISS claims. - --- These changes require that all of the fiss tables are empty. - -${logic.psql-only} TRUNCATE rda.fiss_claims CASCADE; - --- Now that fiss_claims has been truncated we can fix nullable status on clm_typ_ind - -ALTER TABLE rda.fiss_claims ALTER COLUMN clm_typ_ind SET NOT NULL; - --- Using RENAME leaves all of the foreign key references intact. - -ALTER TABLE rda.fiss_audit_trails ${logic.alter-rename-column} dcn ${logic.rename-to} claim_id; -ALTER TABLE rda.fiss_diagnosis_codes ${logic.alter-rename-column} dcn ${logic.rename-to} claim_id; -ALTER TABLE rda.fiss_payers ${logic.alter-rename-column} dcn ${logic.rename-to} claim_id; -ALTER TABLE rda.fiss_proc_codes ${logic.alter-rename-column} dcn ${logic.rename-to} claim_id; -ALTER TABLE rda.fiss_revenue_lines ${logic.alter-rename-column} dcn ${logic.rename-to} claim_id; - --- We still want a dcn column in fiss_claims. - -ALTER TABLE rda.fiss_claims ${logic.alter-rename-column} dcn ${logic.rename-to} claim_id; -ALTER TABLE rda.fiss_claims ADD dcn varchar(23) NOT NULL; - --- Allow extra space for the new claim_id to be larger than dcn was. - -ALTER TABLE rda.fiss_claims ALTER COLUMN claim_id ${logic.alter-column-type} varchar(32); -ALTER TABLE rda.fiss_audit_trails ALTER COLUMN claim_id ${logic.alter-column-type} varchar(32); -ALTER TABLE rda.fiss_diagnosis_codes ALTER COLUMN claim_id ${logic.alter-column-type} varchar(32); -ALTER TABLE rda.fiss_payers ALTER COLUMN claim_id ${logic.alter-column-type} varchar(32); -ALTER TABLE rda.fiss_proc_codes ALTER COLUMN claim_id ${logic.alter-column-type} varchar(32); -ALTER TABLE rda.fiss_revenue_lines ALTER COLUMN claim_id ${logic.alter-column-type} varchar(32); - --- Reset the progress table so we can reingest all FISS claims under the new schema. - -DELETE FROM rda.rda_api_progress WHERE claim_type = 'FISS'; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V104__rda_0_12_0_hotfix.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V104__rda_0_12_0_hotfix.sql deleted file mode 100644 index 7e7d7fb8d6..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V104__rda_0_12_0_hotfix.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Hot fix for the 0.12 RDA API update, remove not null constraint on non_bill_rev_code - -alter table rda.fiss_revenue_lines alter column non_bill_rev_code drop not null; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V105__rda_0_12_0_hotfix2.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V105__rda_0_12_0_hotfix2.sql deleted file mode 100644 index 1c5a0957a1..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V105__rda_0_12_0_hotfix2.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Hot fix for the 0.12 RDA API update, remove not null constraint on clm_typ_ind - -alter table rda.fiss_claims alter column clm_typ_ind drop not null; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V106__rda_0_13_0_updates.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V106__rda_0_13_0_updates.sql deleted file mode 100644 index 8c668d8f44..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V106__rda_0_13_0_updates.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Add new column introduced in RDA API v0.13 - -ALTER TABLE rda.fiss_claims ADD intermediary_nb varchar(5); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V107__reingest_fiss_claims.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V107__reingest_fiss_claims.sql deleted file mode 100644 index a9ff6de947..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V107__reingest_fiss_claims.sql +++ /dev/null @@ -1,14 +0,0 @@ --- PACA-752 uses rdaClaimKey field for claimId instead of dcn - --- Truncate the fiss_claims table since all claimIds are going to change and --- we need to set intermediary_nb to be not null. - -${logic.psql-only} TRUNCATE rda.fiss_claims CASCADE; - --- Now that the table is truncated we can make intermediary_nb not nullable. - -ALTER TABLE rda.fiss_claims ALTER COLUMN intermediary_nb SET NOT NULL; - --- Reset the progress table so we can re-ingest all FISS claims using the new claimIds. - -DELETE FROM rda.rda_api_progress WHERE claim_type = 'FISS'; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V108__change_claim_id_length_rda.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V108__change_claim_id_length_rda.sql deleted file mode 100644 index 07ffe293bf..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V108__change_claim_id_length_rda.sql +++ /dev/null @@ -1,5 +0,0 @@ - --- Allow extra space for the new claim_id to be larger than dcn was. - -ALTER TABLE rda.claim_message_meta_data ALTER COLUMN claim_id ${logic.alter-column-type} varchar(32); -ALTER TABLE rda.message_errors ALTER COLUMN claim_id ${logic.alter-column-type} varchar(32); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V109__change_claim_id_length_rda.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V109__change_claim_id_length_rda.sql deleted file mode 100644 index 68299c5e37..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V109__change_claim_id_length_rda.sql +++ /dev/null @@ -1,21 +0,0 @@ - --- Allow extra space for the new claim_id to accommodate the Base64 encoding. - -ALTER TABLE rda.fiss_claims ALTER COLUMN claim_id ${logic.alter-column-type} varchar(43); -ALTER TABLE rda.fiss_audit_trails ALTER COLUMN claim_id ${logic.alter-column-type} varchar(43); -ALTER TABLE rda.fiss_diagnosis_codes ALTER COLUMN claim_id ${logic.alter-column-type} varchar(43); -ALTER TABLE rda.fiss_payers ALTER COLUMN claim_id ${logic.alter-column-type} varchar(43); -ALTER TABLE rda.fiss_proc_codes ALTER COLUMN claim_id ${logic.alter-column-type} varchar(43); -ALTER TABLE rda.fiss_revenue_lines ALTER COLUMN claim_id ${logic.alter-column-type} varchar(43); -ALTER TABLE rda.claim_message_meta_data ALTER COLUMN claim_id ${logic.alter-column-type} varchar(43); -ALTER TABLE rda.message_errors ALTER COLUMN claim_id ${logic.alter-column-type} varchar(43); - --- Truncate FISS claims and associated meta data, the key they use is invalid now - -${logic.psql-only} TRUNCATE rda.fiss_claims CASCADE; - -DELETE FROM rda.claim_message_meta_data WHERE claim_type = 'F'; - --- Reset the progress table so we can re-ingest all FISS claims with the new key. - -DELETE FROM rda.rda_api_progress WHERE claim_type = 'FISS'; \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V10__Add_beneficiary_beneficiaryHistory_colmns.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V10__Add_beneficiary_beneficiaryHistory_colmns.sql deleted file mode 100644 index ed2cc2b565..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V10__Add_beneficiary_beneficiaryHistory_colmns.sql +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Alters the Beneficiaries and Beneficiaries History table to add additional BSF columns - * - * See: - * * https://jira.cms.gov/browse/BLUEBUTTON-620 - */ - -alter table "Beneficiaries" add column "hicnUnhashed" varchar(11); - -alter table "Beneficiaries" add column "medicareBeneficiaryId" varchar(11); -alter table "Beneficiaries" add column "beneficiaryDateOfDeath" date; -alter table "Beneficiaries" add column "beneEnrollmentReferenceYear" numeric(4); -alter table "Beneficiaries" add column "partAMonthsCount" numeric(3); -alter table "Beneficiaries" add column "partBMonthsCount" numeric(3); -alter table "Beneficiaries" add column "stateBuyInCoverageCount" numeric(3); -alter table "Beneficiaries" add column "hmoCoverageCount" numeric(3); -alter table "Beneficiaries" add column "monthsRetireeDrugSubsidyCoverage" numeric(3); -alter table "Beneficiaries" add column "sourceOfEnrollmentData" varchar(3); -alter table "Beneficiaries" add column "sampleMedicareGroupIndicator" varchar(2); -alter table "Beneficiaries" add column "enhancedMedicareSampleIndicator" char(1); -alter table "Beneficiaries" add column "currentBeneficiaryIdCode" varchar(2); -alter table "Beneficiaries" add column "ageOfBeneficiary" numeric(3); -alter table "Beneficiaries" add column "medicareCoverageStartDate" date; -alter table "Beneficiaries" add column "monthsOfDualEligibility" numeric(3); -alter table "Beneficiaries" add column "fipsStateCntyJanCode" varchar(5); -alter table "Beneficiaries" add column "fipsStateCntyFebCode" varchar(5); -alter table "Beneficiaries" add column "fipsStateCntyMarCode" varchar(5); -alter table "Beneficiaries" add column "fipsStateCntyAprCode" varchar(5); -alter table "Beneficiaries" add column "fipsStateCntyMayCode" varchar(5); -alter table "Beneficiaries" add column "fipsStateCntyJunCode" varchar(5); -alter table "Beneficiaries" add column "fipsStateCntyJulCode" varchar(5); -alter table "Beneficiaries" add column "fipsStateCntyAugCode" varchar(5); -alter table "Beneficiaries" add column "fipsStateCntySeptCode" varchar(5); -alter table "Beneficiaries" add column "fipsStateCntyOctCode" varchar(5); -alter table "Beneficiaries" add column "fipsStateCntyNovCode" varchar(5); -alter table "Beneficiaries" add column "fipsStateCntyDecCode" varchar(5); -alter table "Beneficiaries" add column "validDateOfDeathSw" char(1); -alter table "Beneficiaries" add column "rtiRaceCode" char(1); -alter table "Beneficiaries" add column "medicareStatusJanCode" varchar(2); -alter table "Beneficiaries" add column "medicareStatusFebCode" varchar(2); -alter table "Beneficiaries" add column "medicareStatusMarCode" varchar(2); -alter table "Beneficiaries" add column "medicareStatusAprCode" varchar(2); -alter table "Beneficiaries" add column "medicareStatusMayCode" varchar(2); -alter table "Beneficiaries" add column "medicareStatusJunCode" varchar(2); -alter table "Beneficiaries" add column "medicareStatusJulCode" varchar(2); -alter table "Beneficiaries" add column "medicareStatusAugCode" varchar(2); -alter table "Beneficiaries" add column "medicareStatusSeptCode" varchar(2); -alter table "Beneficiaries" add column "medicareStatusOctCode" varchar(2); -alter table "Beneficiaries" add column "medicareStatusNovCode" varchar(2); -alter table "Beneficiaries" add column "medicareStatusDecCode" varchar(2); -alter table "Beneficiaries" add column "partDMonthsCount" numeric(3); -alter table "Beneficiaries" add column "entitlementBuyInJanInd" char(1); -alter table "Beneficiaries" add column "entitlementBuyInFebInd" char(1); -alter table "Beneficiaries" add column "entitlementBuyInMarInd" char(1); -alter table "Beneficiaries" add column "entitlementBuyInAprInd" char(1); -alter table "Beneficiaries" add column "entitlementBuyInMayInd" char(1); -alter table "Beneficiaries" add column "entitlementBuyInJunInd" char(1); -alter table "Beneficiaries" add column "entitlementBuyInJulInd" char(1); -alter table "Beneficiaries" add column "entitlementBuyInAugInd" char(1); -alter table "Beneficiaries" add column "entitlementBuyInSeptInd" char(1); -alter table "Beneficiaries" add column "entitlementBuyInOctInd" char(1); -alter table "Beneficiaries" add column "entitlementBuyInNovInd" char(1); -alter table "Beneficiaries" add column "entitlementBuyInDecInd" char(1); -alter table "Beneficiaries" add column "hmoIndicatorJanInd" char(1); -alter table "Beneficiaries" add column "hmoIndicatorFebInd" char(1); -alter table "Beneficiaries" add column "hmoIndicatorMarInd" char(1); -alter table "Beneficiaries" add column "hmoIndicatorAprInd" char(1); -alter table "Beneficiaries" add column "hmoIndicatorMayInd" char(1); -alter table "Beneficiaries" add column "hmoIndicatorJunInd" char(1); -alter table "Beneficiaries" add column "hmoIndicatorJulInd" char(1); -alter table "Beneficiaries" add column "hmoIndicatorAugInd" char(1); -alter table "Beneficiaries" add column "hmoIndicatorSeptInd" char(1); -alter table "Beneficiaries" add column "hmoIndicatorOctInd" char(1); -alter table "Beneficiaries" add column "hmoIndicatorNovInd" char(1); -alter table "Beneficiaries" add column "hmoIndicatorDecInd" char(1); -alter table "Beneficiaries" add column "partCContractNumberJanId" varchar(5); -alter table "Beneficiaries" add column "partCContractNumberFebId" varchar(5); -alter table "Beneficiaries" add column "partCContractNumberMarId" varchar(5); -alter table "Beneficiaries" add column "partCContractNumberAprId" varchar(5); -alter table "Beneficiaries" add column "partCContractNumberMayId" varchar(5); -alter table "Beneficiaries" add column "partCContractNumberJunId" varchar(5); -alter table "Beneficiaries" add column "partCContractNumberJulId" varchar(5); -alter table "Beneficiaries" add column "partCContractNumberAugId" varchar(5); -alter table "Beneficiaries" add column "partCContractNumberSeptId" varchar(5); -alter table "Beneficiaries" add column "partCContractNumberOctId" varchar(5); -alter table "Beneficiaries" add column "partCContractNumberNovId" varchar(5); -alter table "Beneficiaries" add column "partCContractNumberDecId" varchar(5); -alter table "Beneficiaries" add column "partCPbpNumberJanId" varchar(3); -alter table "Beneficiaries" add column "partCPbpNumberFebId" varchar(3); -alter table "Beneficiaries" add column "partCPbpNumberMarId" varchar(3); -alter table "Beneficiaries" add column "partCPbpNumberAprId" varchar(3); -alter table "Beneficiaries" add column "partCPbpNumberMayId" varchar(3); -alter table "Beneficiaries" add column "partCPbpNumberJunId" varchar(3); -alter table "Beneficiaries" add column "partCPbpNumberJulId" varchar(3); -alter table "Beneficiaries" add column "partCPbpNumberAugId" varchar(3); -alter table "Beneficiaries" add column "partCPbpNumberSeptId" varchar(3); -alter table "Beneficiaries" add column "partCPbpNumberOctId" varchar(3); -alter table "Beneficiaries" add column "partCPbpNumberNovId" varchar(3); -alter table "Beneficiaries" add column "partCPbpNumberDecId" varchar(3); -alter table "Beneficiaries" add column "partCPlanTypeJanCode" varchar(3); -alter table "Beneficiaries" add column "partCPlanTypeFebCode" varchar(3); -alter table "Beneficiaries" add column "partCPlanTypeMarCode" varchar(3); -alter table "Beneficiaries" add column "partCPlanTypeAprCode" varchar(3); -alter table "Beneficiaries" add column "partCPlanTypeMayCode" varchar(3); -alter table "Beneficiaries" add column "partCPlanTypeJunCode" varchar(3); -alter table "Beneficiaries" add column "partCPlanTypeJulCode" varchar(3); -alter table "Beneficiaries" add column "partCPlanTypeAugCode" varchar(3); -alter table "Beneficiaries" add column "partCPlanTypeSeptCode" varchar(3); -alter table "Beneficiaries" add column "partCPlanTypeOctCode" varchar(3); -alter table "Beneficiaries" add column "partCPlanTypeNovCode" varchar(3); -alter table "Beneficiaries" add column "partCPlanTypeDecCode" varchar(3); -alter table "Beneficiaries" add column "partDContractNumberJanId" varchar(5); -alter table "Beneficiaries" add column "partDContractNumberFebId" varchar(5); -alter table "Beneficiaries" add column "partDContractNumberMarId" varchar(5); -alter table "Beneficiaries" add column "partDContractNumberAprId" varchar(5); -alter table "Beneficiaries" add column "partDContractNumberMayId" varchar(5); -alter table "Beneficiaries" add column "partDContractNumberJunId" varchar(5); -alter table "Beneficiaries" add column "partDContractNumberJulId" varchar(5); -alter table "Beneficiaries" add column "partDContractNumberAugId" varchar(5); -alter table "Beneficiaries" add column "partDContractNumberSeptId" varchar(5); -alter table "Beneficiaries" add column "partDContractNumberOctId" varchar(5); -alter table "Beneficiaries" add column "partDContractNumberNovId" varchar(5); -alter table "Beneficiaries" add column "partDContractNumberDecId" varchar(5); -alter table "Beneficiaries" add column "partDPbpNumberJanId" varchar(3); -alter table "Beneficiaries" add column "partDPbpNumberFebId" varchar(3); -alter table "Beneficiaries" add column "partDPbpNumberMarId" varchar(3); -alter table "Beneficiaries" add column "partDPbpNumberAprId" varchar(3); -alter table "Beneficiaries" add column "partDPbpNumberMayId" varchar(3); -alter table "Beneficiaries" add column "partDPbpNumberJunId" varchar(3); -alter table "Beneficiaries" add column "partDPbpNumberJulId" varchar(3); -alter table "Beneficiaries" add column "partDPbpNumberAugId" varchar(3); -alter table "Beneficiaries" add column "partDPbpNumberSeptId" varchar(3); -alter table "Beneficiaries" add column "partDPbpNumberOctId" varchar(3); -alter table "Beneficiaries" add column "partDPbpNumberNovId" varchar(3); -alter table "Beneficiaries" add column "partDPbpNumberDecId" varchar(3); -alter table "Beneficiaries" add column "partDSegmentNumberJanId" varchar(3); -alter table "Beneficiaries" add column "partDSegmentNumberFebId" varchar(3); -alter table "Beneficiaries" add column "partDSegmentNumberMarId" varchar(3); -alter table "Beneficiaries" add column "partDSegmentNumberAprId" varchar(3); -alter table "Beneficiaries" add column "partDSegmentNumberMayId" varchar(3); -alter table "Beneficiaries" add column "partDSegmentNumberJunId" varchar(3); -alter table "Beneficiaries" add column "partDSegmentNumberJulId" varchar(3); -alter table "Beneficiaries" add column "partDSegmentNumberAugId" varchar(3); -alter table "Beneficiaries" add column "partDSegmentNumberSeptId" varchar(3); -alter table "Beneficiaries" add column "partDSegmentNumberOctId" varchar(3); -alter table "Beneficiaries" add column "partDSegmentNumberNovId" varchar(3); -alter table "Beneficiaries" add column "partDSegmentNumberDecId" varchar(3); -alter table "Beneficiaries" add column "partDRetireeDrugSubsidyJanInd" char(1); -alter table "Beneficiaries" add column "partDRetireeDrugSubsidyFebInd" char(1); -alter table "Beneficiaries" add column "partDRetireeDrugSubsidyMarInd" char(1); -alter table "Beneficiaries" add column "partDRetireeDrugSubsidyAprInd" char(1); -alter table "Beneficiaries" add column "partDRetireeDrugSubsidyMayInd" char(1); -alter table "Beneficiaries" add column "partDRetireeDrugSubsidyJunInd" char(1); -alter table "Beneficiaries" add column "partDRetireeDrugSubsidyJulInd" char(1); -alter table "Beneficiaries" add column "partDRetireeDrugSubsidyAugInd" char(1); -alter table "Beneficiaries" add column "partDRetireeDrugSubsidySeptInd" char(1); -alter table "Beneficiaries" add column "partDRetireeDrugSubsidyOctInd" char(1); -alter table "Beneficiaries" add column "partDRetireeDrugSubsidyNovInd" char(1); -alter table "Beneficiaries" add column "partDRetireeDrugSubsidyDecInd" char(1); -alter table "Beneficiaries" add column "medicaidDualEligibilityJanCode" varchar(2); -alter table "Beneficiaries" add column "medicaidDualEligibilityFebCode" varchar(2); -alter table "Beneficiaries" add column "medicaidDualEligibilityMarCode" varchar(2); -alter table "Beneficiaries" add column "medicaidDualEligibilityAprCode" varchar(2); -alter table "Beneficiaries" add column "medicaidDualEligibilityMayCode" varchar(2); -alter table "Beneficiaries" add column "medicaidDualEligibilityJunCode" varchar(2); -alter table "Beneficiaries" add column "medicaidDualEligibilityJulCode" varchar(2); -alter table "Beneficiaries" add column "medicaidDualEligibilityAugCode" varchar(2); -alter table "Beneficiaries" add column "medicaidDualEligibilitySeptCode" varchar(2); -alter table "Beneficiaries" add column "medicaidDualEligibilityOctCode" varchar(2); -alter table "Beneficiaries" add column "medicaidDualEligibilityNovCode" varchar(2); -alter table "Beneficiaries" add column "medicaidDualEligibilityDecCode" varchar(2); -alter table "Beneficiaries" add column "partDLowIncomeCostShareGroupJanCode" varchar(2); -alter table "Beneficiaries" add column "partDLowIncomeCostShareGroupFebCode" varchar(2); -alter table "Beneficiaries" add column "partDLowIncomeCostShareGroupMarCode" varchar(2); -alter table "Beneficiaries" add column "partDLowIncomeCostShareGroupAprCode" varchar(2); -alter table "Beneficiaries" add column "partDLowIncomeCostShareGroupMayCode" varchar(2); -alter table "Beneficiaries" add column "partDLowIncomeCostShareGroupJunCode" varchar(2); -alter table "Beneficiaries" add column "partDLowIncomeCostShareGroupJulCode" varchar(2); -alter table "Beneficiaries" add column "partDLowIncomeCostShareGroupAugCode" varchar(2); -alter table "Beneficiaries" add column "partDLowIncomeCostShareGroupSeptCode" varchar(2); -alter table "Beneficiaries" add column "partDLowIncomeCostShareGroupOctCode" varchar(2); -alter table "Beneficiaries" add column "partDLowIncomeCostShareGroupNovCode" varchar(2); -alter table "Beneficiaries" add column "partDLowIncomeCostShareGroupDecCode" varchar(2); - -alter table "BeneficiariesHistory" add column "hicnUnhashed" varchar(11); -alter table "BeneficiariesHistory" add column "medicareBeneficiaryId" varchar(11); - diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V110__add_loaded_batch_loaded_file_idx.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V110__add_loaded_batch_loaded_file_idx.sql deleted file mode 100644 index 06a3a3b73b..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V110__add_loaded_batch_loaded_file_idx.sql +++ /dev/null @@ -1,10 +0,0 @@ -/* - BFD-1505 - There are periodic JDBC errors related to the Loaded Filter Manager bloom filter implementation. - - This may correct the issue by having postgres not do a sequential scan on loaded_batches with an index. - */ - -create index ${logic.index-create-concurrently} -if not exists loaded_batches_loaded_file_id_idx on loaded_batches (loaded_file_id DESC ${logic.psql-only} nulls last -); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V111__setup_claims_availability_function.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V111__setup_claims_availability_function.sql deleted file mode 100644 index 30a9c869cd..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V111__setup_claims_availability_function.sql +++ /dev/null @@ -1,111 +0,0 @@ --- BFD-2549 --- SETUP_CLAIMS_AVAILABILITY_FUNCTION.SQL --- flyway migration to reate a db function that takes a bene_id as an input parameter, --- and returns a bit mask denoting available claims data for that beneficiary. This --- function will be invoked during ExplanationOfBenefitResourceProvider (STU3, R4) to --- improve performance, especially for the case(s) when there are no claims wahtsoever --- for a given Claim type for the Beneficiary. --- -${logic.psql-only} CREATE OR REPLACE FUNCTION check_claims_mask(v_bene_id bigint) -${logic.psql-only} RETURNS integer -${logic.psql-only} LANGUAGE plpgsql AS -${logic.psql-only} $func$ -${logic.psql-only} DECLARE -${logic.psql-only} v_rslt integer := 0; -${logic.psql-only} -- Java definitions -${logic.psql-only} V_CARRIER integer := 1; -- public static final int V_CARRIER_HAS_DATA = (1 << 0); -${logic.psql-only} V_INPATIENT integer := 2; -- public static final int V_INPATIENT_HAS_DATA = (1 << 1); -${logic.psql-only} V_OUTPATIENT integer := 4; -- public static final int V_OUTPATIENT_HAS_DATA = (1 << 2); -${logic.psql-only} V_SNF integer := 8; -- public static final int V_SNF_HAS_DATA = (1 << 3); -${logic.psql-only} V_DME integer := 16; -- public static final int V_DME_HAS_DATA = (1 << 4); -${logic.psql-only} V_HHA integer := 32; -- public static final int V_HHA_HAS_DATA = (1 << 5); -${logic.psql-only} V_HOSPICE integer := 64; -- public static final int V_HOSPICE_HAS_DATA = (1 << 6); -${logic.psql-only} V_PART_D integer := 128; -- public static final int V_PART_D_HAS_DATA = (1 << 7); -${logic.psql-only} BEGIN -${logic.psql-only} PERFORM 1 FROM carrier_claims WHERE bene_id = v_bene_id limit 1; -${logic.psql-only} IF FOUND THEN -${logic.psql-only} v_rslt = V_CARRIER; -${logic.psql-only} END IF; -${logic.psql-only} PERFORM 1 FROM inpatient_claims WHERE bene_id = v_bene_id limit 1; -${logic.psql-only} IF FOUND THEN -${logic.psql-only} v_rslt = v_rslt + V_INPATIENT; -${logic.psql-only} END IF; -${logic.psql-only} PERFORM 1 FROM outpatient_claims WHERE bene_id = v_bene_id limit 1; -${logic.psql-only} IF FOUND THEN -${logic.psql-only} v_rslt = v_rslt + V_OUTPATIENT; -${logic.psql-only} END IF; -${logic.psql-only} PERFORM 1 FROM snf_claims WHERE bene_id = v_bene_id limit 1; -${logic.psql-only} IF FOUND THEN -${logic.psql-only} v_rslt = v_rslt + V_SNF; -${logic.psql-only} END IF; -${logic.psql-only} PERFORM 1 FROM dme_claims WHERE bene_id = v_bene_id limit 1; -${logic.psql-only} IF FOUND THEN -${logic.psql-only} v_rslt = v_rslt + V_DME; -${logic.psql-only} END IF; -${logic.psql-only} PERFORM 1 FROM hha_claims WHERE bene_id = v_bene_id limit 1; -${logic.psql-only} IF FOUND THEN -${logic.psql-only} v_rslt = v_rslt + V_HHA; -${logic.psql-only} END IF; -${logic.psql-only} PERFORM 1 FROM hospice_claims WHERE bene_id = v_bene_id limit 1; -${logic.psql-only} IF FOUND THEN -${logic.psql-only} v_rslt = v_rslt + V_HOSPICE; -${logic.psql-only} END IF; -${logic.psql-only} PERFORM 1 FROM partd_events WHERE bene_id = v_bene_id limit 1; -${logic.psql-only} IF FOUND THEN -${logic.psql-only} v_rslt = v_rslt + V_PART_D; -${logic.psql-only} END IF; - --- Uncomment following line to enable HSQL detail logging during a migration --- ${logic.hsql-only} set database event log level 4 - -${logic.hsql-only} CREATE FUNCTION check_claims_mask(IN v_bene_id bigint) -${logic.hsql-only} RETURNS integer -${logic.hsql-only} READS SQL DATA -${logic.hsql-only} BEGIN ATOMIC -${logic.hsql-only} DECLARE v_rslt integer DEFAULT 0; -${logic.hsql-only} DECLARE v_cnt integer DEFAULT 0; -${logic.hsql-only} DECLARE V_CARRIER integer DEFAULT 1; -${logic.hsql-only} DECLARE V_INPATIENT integer DEFAULT 2; -${logic.hsql-only} DECLARE V_OUTPATIENT integer DEFAULT 4; -${logic.hsql-only} DECLARE V_SNF integer DEFAULT 8; -${logic.hsql-only} DECLARE V_DME integer DEFAULT 16; -${logic.hsql-only} DECLARE V_HHA integer DEFAULT 32; -${logic.hsql-only} DECLARE V_HOSPICE integer DEFAULT 64; -${logic.hsql-only} DECLARE V_PART_D integer DEFAULT 128; - -${logic.hsql-only} SELECT COUNT(BENE_ID) INTO v_cnt FROM carrier_claims WHERE bene_id = v_bene_id; -${logic.hsql-only} IF v_cnt > 0 THEN -${logic.hsql-only} SET v_rslt = V_CARRIER; -${logic.hsql-only} END IF; -${logic.hsql-only} SELECT COUNT(BENE_ID) INTO v_cnt FROM inpatient_claims WHERE bene_id = v_bene_id; -${logic.hsql-only} IF v_cnt > 0 THEN -${logic.hsql-only} SET v_rslt = v_rslt + V_INPATIENT; -${logic.hsql-only} END IF; -${logic.hsql-only} SELECT COUNT(BENE_ID) INTO v_cnt FROM outpatient_claims WHERE bene_id = v_bene_id; -${logic.hsql-only} IF v_cnt > 0 THEN -${logic.hsql-only} SET v_rslt = v_rslt + V_OUTPATIENT; -${logic.hsql-only} END IF; -${logic.hsql-only} SELECT COUNT(BENE_ID) INTO v_cnt FROM snf_claims WHERE bene_id = v_bene_id; -${logic.hsql-only} IF v_cnt > 0 THEN -${logic.hsql-only} SET v_rslt = v_rslt + V_SNF; -${logic.hsql-only} END IF; -${logic.hsql-only} SELECT COUNT(BENE_ID) INTO v_cnt FROM dme_claims WHERE bene_id = v_bene_id; -${logic.hsql-only} IF v_cnt > 0 THEN -${logic.hsql-only} SET v_rslt = v_rslt + V_DME; -${logic.hsql-only} END IF; -${logic.hsql-only} SELECT COUNT(BENE_ID) INTO v_cnt FROM hha_claims WHERE bene_id = v_bene_id; -${logic.hsql-only} IF v_cnt > 0 THEN -${logic.hsql-only} SET v_rslt = v_rslt + V_HHA; -${logic.hsql-only} END IF; -${logic.hsql-only} SELECT COUNT(BENE_ID) INTO v_cnt FROM hospice_claims WHERE bene_id = v_bene_id; -${logic.hsql-only} IF v_cnt > 0 THEN -${logic.hsql-only} SET v_rslt = v_rslt + V_HOSPICE; -${logic.hsql-only} END IF; -${logic.hsql-only} SELECT COUNT(BENE_ID) INTO v_cnt FROM partd_events WHERE bene_id = v_bene_id; -${logic.hsql-only} IF v_cnt > 0 THEN -${logic.hsql-only} SET v_rslt = v_rslt + V_PART_D; -${logic.hsql-only} END IF; - - RETURN v_rslt; -END; -${logic.psql-only} $func$; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V112__Drop_Support_Medicare_BeneficiaryId_History.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V112__Drop_Support_Medicare_BeneficiaryId_History.sql deleted file mode 100644 index d3c030f95a..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V112__Drop_Support_Medicare_BeneficiaryId_History.sql +++ /dev/null @@ -1,16 +0,0 @@ --- BFD-2629 --- Drop_Support_Medicare_BeneficiaryId_History --- flyway migration to drop support for; --- - medicare_beneficiaryid_history --- - medicare_beneficiaryid_history_invalid_beneficiaries --- --- These tables were created as a one-time CCW data drop containing --- historical MBI data; historical MBI data (i.e., MBI_NUM) can be --- used to derive a bene_id (beneficiary) using old(er) data. --- --- Current BFD functionality for looking up bene_id using historical --- MBI_NUM is now handled by the beneficiaries_history table. --- -drop table if exists medicare_beneficiaryid_history cascade; -drop table if exists medicare_beneficiaryid_history_invalid_beneficiaries cascade; -drop table if exists medicare_beneficiaryid_history_temp cascade; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V113__Create_MBI_NUM_Indexes.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V113__Create_MBI_NUM_Indexes.sql deleted file mode 100644 index a04ad39085..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V113__Create_MBI_NUM_Indexes.sql +++ /dev/null @@ -1,10 +0,0 @@ --- BFD-3163 --- Create index on MBI_NUM to support lookup using us-mbi lookup. The MBI lookup --- needs to check both the current beneficiaries table as well as the --- beneficiaries_history table. --- -CREATE INDEX CONCURRENTLY IF NOT EXISTS beneficiaries_history_mbi_idx - ON beneficiaries_history (mbi_num); - -CREATE INDEX CONCURRENTLY IF NOT EXISTS beneficiaries_mbi_idx - ON beneficiaries (mbi_num); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V114__s3_file_tracking.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V114__s3_file_tracking.sql deleted file mode 100644 index 866740cbc4..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V114__s3_file_tracking.sql +++ /dev/null @@ -1,50 +0,0 @@ - -/* - * Table to track CCW S3 manifest files in database. - */ -CREATE TABLE s3_manifest_files ( - manifest_id bigint NOT NULL, - s3_key varchar(1024) NOT NULL, - status varchar(24) NOT NULL, - status_timestamp timestamp with time zone, - manifest_timestamp timestamp with time zone NOT NULL, - discovery_timestamp timestamp with time zone NOT NULL, - CONSTRAINT pk_s3_manifest_files PRIMARY KEY (manifest_id) -); - -/* - * Sequence used to generate primary key manifest_id - */ -create sequence s3_manifest_files_manifest_id_seq ${logic.sequence-start} 1 ${logic.sequence-increment} 1; - -/* - * Index used when checking status of a file from S3 bucket - */ -create unique index idx_s3_manifest_files_s3_key on s3_manifest_files(s3_key); - -/* - * Table to track CCW S3 data files in database. - */ -CREATE TABLE s3_data_files ( - manifest_id bigint NOT NULL, - index smallint NOT NULL, - file_name varchar(128) NOT NULL, - file_type varchar(50) NOT NULL, - s3_key varchar(1024) NOT NULL, - status varchar(24) NOT NULL, - status_timestamp timestamp with time zone, - discovery_timestamp timestamp with time zone NOT NULL, - CONSTRAINT pk_s3_data_files PRIMARY KEY (manifest_id, file_name), - CONSTRAINT fk_s3_data_files_s3_manifest_files FOREIGN KEY (manifest_id) REFERENCES s3_manifest_files(manifest_id) -); - -/* - * Index used when checking status of a file from S3 bucket - */ -create unique index idx_s3_data_files_s3_key on s3_data_files(s3_key); - -/* - * Columns used to relate a record back the s3_data_files record it came from. - */ -alter table loaded_files add column s3_manifest_id bigint; -alter table loaded_files add column s3_file_index smallint; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V115__s3_data_file_progress.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V115__s3_data_file_progress.sql deleted file mode 100644 index 4100533440..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V115__s3_data_file_progress.sql +++ /dev/null @@ -1,4 +0,0 @@ -/* - * Adds a column to track progress of the file at the record level. - */ -ALTER TABLE s3_data_files ADD last_record_number bigint not null default(0); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V116__Find_Beneficiary_Identifier_Function.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V116__Find_Beneficiary_Identifier_Function.sql deleted file mode 100644 index 1599770ba9..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V116__Find_Beneficiary_Identifier_Function.sql +++ /dev/null @@ -1,67 +0,0 @@ --- BFD-3073 --- Function to derive a Beneficiary's BENE_ID from either: --- mbi --- mbi-hash --- hicn-hash --- --- Since MBI_NUM can change over time (i.e., a beneficiary is re-issued --- a new MBI), this function searches both the current as well as --- historical data. --- p_type - meta identifier for the type of data encapsulated in --- the p_value. Valid values: mbi, mbi-hash, hicn-hash --- p_value - value to use when performing the lookup. --- --- Returns a text array of BENE_ID values; in theory this should only --- contain a single value, but both mbi-hash and hicn-hash values have --- hash collisions (duplicates) in our db. --- --- When BFD sunsets support for mbi-hash and/or hicn-hash lookups, this --- function should be changed to remove mbi-hash and hicn-hash support --- and return a single bigint value for the mbi lookup. The necessity --- to support an array of values is solely a function of handling any --- hash collisions. - -CREATE OR REPLACE FUNCTION find_beneficiary(p_type text, p_value text) -RETURNS text -LANGUAGE plpgsql AS -$func$ -DECLARE - v_rslt text; - v_type text := lower(p_type); -BEGIN - IF v_type = 'mbi' THEN - SELECT string_agg(distinct t1.bene_id::text, ',') INTO v_rslt - FROM - ( - select distinct b.bene_id from beneficiaries_history b - where b.mbi_num = p_value - union - select distinct a.bene_id from beneficiaries a - where a.mbi_num = p_value - ) t1; - - ELSIF v_type = 'mbi-hash' THEN - SELECT string_agg(distinct t1.bene_id::text, ',') INTO v_rslt - FROM - ( - select distinct b.bene_id from beneficiaries_history b - where b.mbi_hash = p_value - union - select distinct a.bene_id from beneficiaries a - where a.mbi_hash = p_value - ) t1; - - ELSIF v_type = 'hicn-hash' THEN - SELECT string_agg(distinct t1.bene_id::text, ',') INTO v_rslt - FROM - ( - select distinct b.bene_id from beneficiaries_history b - where b.bene_crnt_hic_num = p_value - union - select distinct a.bene_id from beneficiaries a - where a.bene_crnt_hic_num = p_value - ) t1; - END IF; - RETURN v_rslt; -END; -$func$; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V117__Remove_RDA_FK_Constraints.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V117__Remove_RDA_FK_Constraints.sql deleted file mode 100644 index 7c35995777..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V117__Remove_RDA_FK_Constraints.sql +++ /dev/null @@ -1,99 +0,0 @@ -ALTER TABLE rda.fiss_audit_trails -DROP CONSTRAINT IF EXISTS fiss_audit_trails_parent; - -ALTER TABLE rda.fiss_audit_trails - ADD CONSTRAINT fiss_audit_trails_parent - FOREIGN KEY (claim_id) - REFERENCES rda.fiss_claims - (claim_id) - ON DELETE CASCADE; - -ALTER TABLE rda.fiss_diagnosis_codes -DROP CONSTRAINT IF EXISTS fiss_diagnosis_codes_parent; - -ALTER TABLE rda.fiss_diagnosis_codes - ADD CONSTRAINT fiss_diagnosis_codes_parent - FOREIGN KEY (claim_id) - REFERENCES rda.fiss_claims - (claim_id) - ON DELETE CASCADE; - -ALTER TABLE rda.fiss_payers -DROP CONSTRAINT IF EXISTS fiss_payers_parent; - -ALTER TABLE rda.fiss_payers - ADD CONSTRAINT fiss_payers_parent - FOREIGN KEY (claim_id) - REFERENCES rda.fiss_claims - (claim_id) - ON DELETE CASCADE; - -ALTER TABLE rda.fiss_proc_codes -DROP CONSTRAINT IF EXISTS fiss_proc_codes_parent; - -ALTER TABLE rda.fiss_proc_codes - ADD CONSTRAINT fiss_proc_codes_parent - FOREIGN KEY (claim_id) - REFERENCES rda.fiss_claims - (claim_id) - ON DELETE CASCADE; - -ALTER TABLE rda.fiss_revenue_lines -DROP CONSTRAINT IF EXISTS fiss_revenue_lines_parent; - -ALTER TABLE rda.fiss_revenue_lines - ADD CONSTRAINT fiss_revenue_lines_parent - FOREIGN KEY (claim_id) - REFERENCES rda.fiss_claims - (claim_id) - ON DELETE CASCADE; - -ALTER TABLE rda.mcs_adjustments -DROP CONSTRAINT IF EXISTS mcs_adjustments_parent; - -ALTER TABLE rda.mcs_adjustments - ADD CONSTRAINT mcs_adjustments_parent - FOREIGN KEY (idr_clm_hd_icn) - REFERENCES rda.mcs_claims - (idr_clm_hd_icn) - ON DELETE CASCADE; - -ALTER TABLE rda.mcs_audits -DROP CONSTRAINT IF EXISTS mcs_audits_parent; - -ALTER TABLE rda.mcs_audits - ADD CONSTRAINT mcs_audits_parent - FOREIGN KEY (idr_clm_hd_icn) - REFERENCES rda.mcs_claims - (idr_clm_hd_icn) - ON DELETE CASCADE; - -ALTER TABLE rda.mcs_details -DROP CONSTRAINT IF EXISTS mcs_details_parent; - -ALTER TABLE rda.mcs_details - ADD CONSTRAINT mcs_details_parent - FOREIGN KEY (idr_clm_hd_icn) - REFERENCES rda.mcs_claims - (idr_clm_hd_icn) - ON DELETE CASCADE; - -ALTER TABLE rda.mcs_diagnosis_codes -DROP CONSTRAINT IF EXISTS mcs_diagnosis_codes_parent; - -ALTER TABLE rda.mcs_diagnosis_codes - ADD CONSTRAINT mcs_diagnosis_codes_parent - FOREIGN KEY (idr_clm_hd_icn) - REFERENCES rda.mcs_claims - (idr_clm_hd_icn) - ON DELETE CASCADE; - -ALTER TABLE rda.mcs_locations -DROP CONSTRAINT IF EXISTS mcs_locations_parent; - -ALTER TABLE rda.mcs_locations - ADD CONSTRAINT mcs_locations_parent - FOREIGN KEY (idr_clm_hd_icn) - REFERENCES rda.mcs_claims - (idr_clm_hd_icn) - ON DELETE CASCADE; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V118__rda_0_14_1_updates.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V118__rda_0_14_1_updates.sql deleted file mode 100644 index 4f8f0c7362..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V118__rda_0_14_1_updates.sql +++ /dev/null @@ -1,19 +0,0 @@ --- As part of the 0.14.1 RDA API update, new fields added - -/* -* fiss_claims -*/ -ALTER TABLE rda.fiss_claims ADD adm_typ_cd varchar(2); - -/* -* fiss_revenue_lines -*/ -ALTER TABLE rda.fiss_revenue_lines ADD ndc varchar(11); -ALTER TABLE rda.fiss_revenue_lines ADD ndc_qty varchar(11); -ALTER TABLE rda.fiss_revenue_lines ADD ndc_qty_qual varchar(2); - -/* -* mcs_details -*/ -ALTER TABLE rda.mcs_details ADD idr_dtl_ndc varchar(48); -ALTER TABLE rda.mcs_details ADD idr_dtl_ndc_unit_count varchar(15); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V119__add_roles_to_schema_fix.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V119__add_roles_to_schema_fix.sql deleted file mode 100644 index 3818c522f8..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V119__add_roles_to_schema_fix.sql +++ /dev/null @@ -1,42 +0,0 @@ --- there is a bug in add_reader_role_to_schema(), add_migrator_role() and add_writer_role_to_schema() functions --- where the parameters for the revoke_schema_privs() function call were reversed. This fixes it. - -${logic.psql-only} CREATE OR REPLACE FUNCTION add_reader_role_to_schema(role_name TEXT, schema_name TEXT) RETURNS void AS $func$ -${logic.psql-only} BEGIN -${logic.psql-only} PERFORM create_role_if_not_exists(role_name); -${logic.psql-only} PERFORM revoke_schema_privs(schema_name, role_name); -${logic.psql-only} EXECUTE format('GRANT USAGE ON SCHEMA %I TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('GRANT SELECT ON ALL TABLES IN SCHEMA %I TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('GRANT SELECT ON ALL SEQUENCES IN SCHEMA %I TO %I;', schema_name, role_name); --curval -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT SELECT ON TABLES TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT SELECT ON SEQUENCES TO %I;', schema_name, role_name); -${logic.psql-only} END $func$ LANGUAGE plpgsql; - -${logic.psql-only} CREATE OR REPLACE FUNCTION add_writer_role_to_schema(role_name TEXT, schema_name TEXT) RETURNS void AS $func$ -${logic.psql-only} BEGIN -${logic.psql-only} PERFORM create_role_if_not_exists(role_name); -${logic.psql-only} PERFORM revoke_schema_privs(schema_name, role_name); -${logic.psql-only} EXECUTE format('GRANT USAGE ON SCHEMA %I TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA %I TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('GRANT USAGE ON ALL SEQUENCES IN SCHEMA %I TO %I;', schema_name, role_name); --curval, nextval -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT USAGE ON SEQUENCES TO %I;', schema_name, role_name); -${logic.psql-only} END $func$ LANGUAGE plpgsql; - -${logic.psql-only} CREATE OR REPLACE FUNCTION add_migrator_role_to_schema(role_name TEXT, schema_name TEXT) RETURNS void AS $func$ -${logic.psql-only} BEGIN -${logic.psql-only} PERFORM create_role_if_not_exists(role_name); -${logic.psql-only} PERFORM revoke_schema_privs(schema_name, role_name); -${logic.psql-only} EXECUTE format('GRANT ALL ON SCHEMA %I TO %I;', schema_name, role_name); -- uwsage + create -${logic.psql-only} EXECUTE format('GRANT ALL ON ALL TABLES IN SCHEMA %I TO %I;', schema_name, role_name); -- tables/views -${logic.psql-only} EXECUTE format('GRANT ALL ON ALL SEQUENCES IN SCHEMA %I TO %I;', schema_name, role_name); --curval, nextval, setval -${logic.psql-only} BEGIN -${logic.psql-only} -- in aurora, we will get an error if we try to modify perms on routines installed via system extensions -${logic.psql-only} -- like pg_stat_statements, so just log the error and skip it -${logic.psql-only} EXECUTE format('GRANT ALL ON ALL ROUTINES IN SCHEMA %I TO %I;', schema_name, role_name); -${logic.psql-only} EXCEPTION WHEN SQLSTATE '42501' THEN RAISE NOTICE '%, skipping', SQLERRM USING ERRCODE = SQLSTATE; -${logic.psql-only} END; -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT ALL ON TABLES TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT ALL ON SEQUENCES TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT ALL ON ROUTINES TO %I;', schema_name, role_name); -${logic.psql-only} END $func$ LANGUAGE plpgsql; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V11__Create_medicare_beneficiary_id_history_table.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V11__Create_medicare_beneficiary_id_history_table.sql deleted file mode 100644 index 70a0019fcf..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V11__Create_medicare_beneficiary_id_history_table.sql +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Creates the MedicareBeneficiaryIdHistory table required by the application. This - * schema is derived from the JPA metadata, via the - * gov.hhs.cms.bluebutton.data.pipeline.rif.schema.HibernateSchemaPrinter - * utility. - */ - -${logic.tablespaces-escape} SET default_tablespace = fhirdb_ts2; - -create table "MedicareBeneficiaryIdHistory" ( - "medicareBeneficiaryIdKey" numeric not null, - "beneficiaryId" numeric, - "claimAccountNumber" varchar(9), - "beneficiaryIdCode" varchar(2), - "mbiSequenceNumber" numeric, - "medicareBeneficiaryId" varchar(11), - "mbiEffectiveDate" date, - "mbiEndDate" date, - "mbiEffectiveReasonCode" varchar(5), - "mbiEndReasonCode" varchar(5), - "mbiCardRequestDate" date, - "mbiAddUser" varchar(30), - "mbiAddDate" timestamp, - "mbiUpdateUser" varchar(30), - "mbiUpdateDate" timestamp, - "mbiCrntRecIndId" numeric, - - constraint "MedicareBeneficiaryIdHistory_pkey" primary key ("medicareBeneficiaryIdKey") -) -${logic.tablespaces-escape} tablespace "medicarebeneficiaryidhistory_ts" -; - -create index "MedicareBeneficiaryIdHistory_beneficiaryId_idx" - on "MedicareBeneficiaryIdHistory" ("beneficiaryId"); - - - - - - - diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V120__public_to_ccw_schema_migration.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V120__public_to_ccw_schema_migration.sql deleted file mode 100644 index 242dddf13c..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V120__public_to_ccw_schema_migration.sql +++ /dev/null @@ -1,259 +0,0 @@ --- Create the schema -CREATE SCHEMA IF NOT EXISTS ccw; - --- Add the roles to the new schema -${logic.psql-only} DO $$ -${logic.psql-only} BEGIN -${logic.psql-only} PERFORM add_reader_role_to_schema('bfd_reader_role', 'ccw'); -${logic.psql-only} PERFORM add_writer_role_to_schema('bfd_writer_role', 'ccw'); -${logic.psql-only} PERFORM add_migrator_role_to_schema('bfd_migrator_role', 'ccw'); -${logic.psql-only} END -${logic.psql-only} $$ LANGUAGE plpgsql; - --- move the tables to the new schema -DROP TABLE IF EXISTS ccw.beneficiaries CASCADE; -ALTER TABLE public.beneficiaries - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.beneficiaries_history CASCADE; -ALTER TABLE public.beneficiaries_history - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.beneficiaries_history_invalid_beneficiaries CASCADE; -ALTER TABLE public.beneficiaries_history_invalid_beneficiaries - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.beneficiary_monthly CASCADE; -ALTER TABLE public.beneficiary_monthly - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.beneficiary_monthly_audit CASCADE; -ALTER TABLE public.beneficiary_monthly_audit - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.carrier_claim_lines CASCADE; -ALTER TABLE public.carrier_claim_lines - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.carrier_claims CASCADE; -ALTER TABLE public.carrier_claims - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.dme_claim_lines CASCADE; -ALTER TABLE public.dme_claim_lines - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.dme_claims CASCADE; -ALTER TABLE public.dme_claims - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.hha_claims CASCADE; -ALTER TABLE public.hha_claims - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.hha_claim_lines CASCADE; -ALTER TABLE public.hha_claim_lines - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.hospice_claim_lines CASCADE; -ALTER TABLE public.hospice_claim_lines - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.hospice_claims CASCADE; -ALTER TABLE public.hospice_claims - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.inpatient_claim_lines CASCADE; -ALTER TABLE public.inpatient_claim_lines - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.inpatient_claims CASCADE; -ALTER TABLE public.inpatient_claims - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.loaded_batches CASCADE; -ALTER TABLE public.loaded_batches - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.loaded_files CASCADE; -ALTER TABLE public.loaded_files - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.outpatient_claim_lines CASCADE; -ALTER TABLE public.outpatient_claim_lines - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.outpatient_claims CASCADE; -ALTER TABLE public.outpatient_claims - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.partd_events CASCADE; -ALTER TABLE public.partd_events - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.s3_data_files CASCADE; -ALTER TABLE public.s3_data_files - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.s3_manifest_files CASCADE; -ALTER TABLE public.s3_manifest_files - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.skipped_rif_records CASCADE; -ALTER TABLE public.skipped_rif_records - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.snf_claim_lines CASCADE; -ALTER TABLE public.snf_claim_lines - SET SCHEMA ccw; -DROP TABLE IF EXISTS ccw.snf_claims CASCADE; -ALTER TABLE public.snf_claims - SET SCHEMA ccw; - -DROP FUNCTION IF EXISTS public.track_bene_monthly_change() CASCADE; --- Some of the functions and triggers need to be rewritten to use the new schema -${logic.psql-only} CREATE OR REPLACE FUNCTION ccw.track_bene_monthly_change() RETURNS TRIGGER -${logic.psql-only} AS $beneficiary_monthly_audit$ -${logic.psql-only} BEGIN -${logic.psql-only} IF (TG_OP = 'UPDATE') THEN -${logic.psql-only} INSERT INTO ccw.beneficiary_monthly_audit VALUES (OLD.*, 'U', now(), nextval('ccw.bene_monthly_audit_seq')); -${logic.psql-only} RETURN NEW; -${logic.psql-only} END IF; -${logic.psql-only} RETURN NULL; -- result is ignored since this is an AFTER trigger -${logic.psql-only} END; -${logic.psql-only} $beneficiary_monthly_audit$ LANGUAGE plpgsql; - -${logic.psql-only} DROP TRIGGER IF EXISTS audit_ccw_update ON ccw.beneficiary_monthly; - -${logic.psql-only} CREATE TRIGGER audit_ccw_update -${logic.psql-only} AFTER UPDATE ON ccw.beneficiary_monthly -${logic.psql-only} FOR EACH ROW -${logic.psql-only} WHEN (( -${logic.psql-only} OLD.partd_contract_number_id <> '0' OR -${logic.psql-only} OLD.partc_contract_number_id <> '0') -${logic.psql-only} AND (( -${logic.psql-only} OLD.partd_contract_number_id, -${logic.psql-only} OLD.partc_contract_number_id, -${logic.psql-only} OLD.medicare_status_code, -${logic.psql-only} OLD.fips_state_cnty_code, -${logic.psql-only} OLD.entitlement_buy_in_ind, -${logic.psql-only} OLD.hmo_indicator_ind, -${logic.psql-only} OLD.medicaid_dual_eligibility_code, -${logic.psql-only} OLD.partd_pbp_number_id, -${logic.psql-only} OLD.partd_segment_number_id, -${logic.psql-only} OLD.partd_low_income_cost_share_group_code, -${logic.psql-only} OLD.partc_pbp_number_id, -${logic.psql-only} OLD.partc_plan_type_code) -${logic.psql-only} IS DISTINCT FROM ( -${logic.psql-only} NEW.partd_contract_number_id, -${logic.psql-only} NEW.partc_contract_number_id, -${logic.psql-only} NEW.medicare_status_code, -${logic.psql-only} NEW.fips_state_cnty_code, -${logic.psql-only} NEW.entitlement_buy_in_ind, -${logic.psql-only} NEW.hmo_indicator_ind, -${logic.psql-only} NEW.medicaid_dual_eligibility_code, -${logic.psql-only} NEW.partd_pbp_number_id, -${logic.psql-only} NEW.partd_segment_number_id, -${logic.psql-only} NEW.partd_low_income_cost_share_group_code, -${logic.psql-only} NEW.partc_pbp_number_id, -${logic.psql-only} NEW.partc_plan_type_code)) ) -${logic.psql-only} EXECUTE FUNCTION ccw.track_bene_monthly_change(); - -DROP FUNCTION IF EXISTS check_claims_mask(bigint); -${logic.psql-only} CREATE OR REPLACE FUNCTION ccw.check_claims_mask(v_bene_id bigint) -${logic.psql-only} RETURNS integer -${logic.psql-only} LANGUAGE plpgsql AS -${logic.psql-only} $func$ -${logic.psql-only} DECLARE -${logic.psql-only} v_rslt integer := 0; -${logic.psql-only} -- Java definitions -${logic.psql-only} V_CARRIER integer := 1; -- public static final int V_CARRIER_HAS_DATA = (1 << 0); -${logic.psql-only} V_INPATIENT integer := 2; -- public static final int V_INPATIENT_HAS_DATA = (1 << 1); -${logic.psql-only} V_OUTPATIENT integer := 4; -- public static final int V_OUTPATIENT_HAS_DATA = (1 << 2); -${logic.psql-only} V_SNF integer := 8; -- public static final int V_SNF_HAS_DATA = (1 << 3); -${logic.psql-only} V_DME integer := 16; -- public static final int V_DME_HAS_DATA = (1 << 4); -${logic.psql-only} V_HHA integer := 32; -- public static final int V_HHA_HAS_DATA = (1 << 5); -${logic.psql-only} V_HOSPICE integer := 64; -- public static final int V_HOSPICE_HAS_DATA = (1 << 6); -${logic.psql-only} V_PART_D integer := 128; -- public static final int V_PART_D_HAS_DATA = (1 << 7); -${logic.psql-only} BEGIN -${logic.psql-only} PERFORM 1 FROM ccw.carrier_claims WHERE bene_id = v_bene_id limit 1; -${logic.psql-only} IF FOUND THEN -${logic.psql-only} v_rslt = V_CARRIER; -${logic.psql-only} END IF; -${logic.psql-only} PERFORM 1 FROM ccw.inpatient_claims WHERE bene_id = v_bene_id limit 1; -${logic.psql-only} IF FOUND THEN -${logic.psql-only} v_rslt = v_rslt + V_INPATIENT; -${logic.psql-only} END IF; -${logic.psql-only} PERFORM 1 FROM ccw.outpatient_claims WHERE bene_id = v_bene_id limit 1; -${logic.psql-only} IF FOUND THEN -${logic.psql-only} v_rslt = v_rslt + V_OUTPATIENT; -${logic.psql-only} END IF; -${logic.psql-only} PERFORM 1 FROM ccw.snf_claims WHERE bene_id = v_bene_id limit 1; -${logic.psql-only} IF FOUND THEN -${logic.psql-only} v_rslt = v_rslt + V_SNF; -${logic.psql-only} END IF; -${logic.psql-only} PERFORM 1 FROM ccw.dme_claims WHERE bene_id = v_bene_id limit 1; -${logic.psql-only} IF FOUND THEN -${logic.psql-only} v_rslt = v_rslt + V_DME; -${logic.psql-only} END IF; -${logic.psql-only} PERFORM 1 FROM ccw.hha_claims WHERE bene_id = v_bene_id limit 1; -${logic.psql-only} IF FOUND THEN -${logic.psql-only} v_rslt = v_rslt + V_HHA; -${logic.psql-only} END IF; -${logic.psql-only} PERFORM 1 FROM ccw.hospice_claims WHERE bene_id = v_bene_id limit 1; -${logic.psql-only} IF FOUND THEN -${logic.psql-only} v_rslt = v_rslt + V_HOSPICE; -${logic.psql-only} END IF; -${logic.psql-only} PERFORM 1 FROM ccw.partd_events WHERE bene_id = v_bene_id limit 1; -${logic.psql-only} IF FOUND THEN -${logic.psql-only} v_rslt = v_rslt + V_PART_D; -${logic.psql-only} END IF; -${logic.psql-only} RETURN v_rslt; -${logic.psql-only} END; -${logic.psql-only} $func$; - -DROP FUNCTION IF EXISTS find_beneficiary(text, text); -CREATE OR REPLACE FUNCTION ccw.find_beneficiary(p_type text, p_value text) -RETURNS text -LANGUAGE plpgsql AS -$func$ -DECLARE -v_rslt text; - v_type text := lower(p_type); -BEGIN - IF v_type = 'mbi' THEN -SELECT string_agg(distinct t1.bene_id::text, ',') INTO v_rslt -FROM - ( - select distinct b.bene_id from ccw.beneficiaries_history b - where b.mbi_num = p_value - union - select distinct a.bene_id from ccw.beneficiaries a - where a.mbi_num = p_value - ) t1; - -ELSIF v_type = 'mbi-hash' THEN -SELECT string_agg(distinct t1.bene_id::text, ',') INTO v_rslt -FROM - ( - select distinct b.bene_id from ccw.beneficiaries_history b - where b.mbi_hash = p_value - union - select distinct a.bene_id from ccw.beneficiaries a - where a.mbi_hash = p_value - ) t1; - -ELSIF v_type = 'hicn-hash' THEN -SELECT string_agg(distinct t1.bene_id::text, ',') INTO v_rslt -FROM - ( - select distinct b.bene_id from ccw.beneficiaries_history b - where b.bene_crnt_hic_num = p_value - union - select distinct a.bene_id from ccw.beneficiaries a - where a.bene_crnt_hic_num = p_value - ) t1; -END IF; -RETURN v_rslt; -END; -$func$; - --- Move the sequences to the new schema -DROP SEQUENCE IF EXISTS ccw.bene_monthly_audit_seq; -ALTER SEQUENCE public.bene_monthly_audit_seq - SET SCHEMA ccw; -DROP SEQUENCE IF EXISTS ccw.beneficiaryhistory_beneficiaryhistoryid_seq; -ALTER SEQUENCE public.beneficiaryhistory_beneficiaryhistoryid_seq - SET SCHEMA ccw; -DROP SEQUENCE IF EXISTS ccw.beneficiaryhistorytemp_beneficiaryhistoryid_seq; -ALTER SEQUENCE public.beneficiaryhistorytemp_beneficiaryhistoryid_seq - SET SCHEMA ccw; -DROP SEQUENCE IF EXISTS ccw.loadedbatches_loadedbatchid_seq; -ALTER SEQUENCE public.loadedbatches_loadedbatchid_seq - SET SCHEMA ccw; -DROP SEQUENCE IF EXISTS ccw.loadedfiles_loadedfileid_seq; -ALTER SEQUENCE public.loadedfiles_loadedfileid_seq - SET SCHEMA ccw; -DROP SEQUENCE IF EXISTS ccw.s3_manifest_files_manifest_id_seq; -ALTER SEQUENCE public.s3_manifest_files_manifest_id_seq - SET SCHEMA ccw; -DROP SEQUENCE IF EXISTS ccw.skipped_rif_records_record_id_seq; -ALTER SEQUENCE public.skipped_rif_records_record_id_seq - SET SCHEMA ccw; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V13__Create_beneficiary_history_temp_table.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V13__Create_beneficiary_history_temp_table.sql deleted file mode 100644 index b5a00cfce8..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V13__Create_beneficiary_history_temp_table.sql +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Creates the beneficiary ID history table required by the application. This - * schema is derived from the JPA metadata, via the - * gov.hhs.cms.bluebutton.data.pipeline.rif.schema.HibernateSchemaPrinter - * utility. - */ - -${logic.tablespaces-escape} SET default_tablespace = pg_default; - -create table "BeneficiariesHistoryTemp" ( - "beneficiaryHistoryId" bigint not null, - "beneficiaryId" varchar(15) not null, - "birthDate" date not null, - "hicn" varchar(64) not null, - "sex" char(1) not null, - "hicnUnhashed" varchar(11), - "medicareBeneficiaryId" varchar(11), - constraint "BeneficiariesHistoryTemp_pkey" primary key ("beneficiaryHistoryId") -) - -; - -/* - * FIXME For consistency, sequence names should be mixed-case, but can't be, due - * to https://hibernate.atlassian.net/browse/HHH-9431. - */ -create sequence beneficiaryHistoryTemp_beneficiaryHistoryId_seq ${logic.sequence-start} 1 ${logic.sequence-increment} 50; - -create index "BeneficiariesHistoryTemp_hicn_idx" - on "BeneficiariesHistoryTemp" ("hicn"); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V14__Rename_beneficiary_history_temp_table.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V14__Rename_beneficiary_history_temp_table.sql deleted file mode 100644 index c97ab56dd7..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V14__Rename_beneficiary_history_temp_table.sql +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Rename BeneficiariesHistoryTemp table/index/constraint to BeneficariesHistory table/index/constraint - */ - --- Rename Old table,Index and Constraint - -alter table public."BeneficiariesHistory" rename to "BeneficiariesHistory_old"; -alter index public."BeneficiariesHistory_hicn_idx" rename to "BeneficiariesHistory_hicn_idx_old"; ---alter table public."BeneficiariesHistory_old" rename constraint "BeneficiariesHistory_pkey" TO "BeneficiariesHistory_pkey_old"; -alter table public."BeneficiariesHistory_old" drop constraint "BeneficiariesHistory_pkey"; -alter table public."BeneficiariesHistory_old" - add constraint "BeneficiariesHistory_pkey_old" primary key ("beneficiaryHistoryId"); - --- Rename New table,Index and Constraint -alter table public."BeneficiariesHistoryTemp" rename to "BeneficiariesHistory"; -alter index public."BeneficiariesHistoryTemp_hicn_idx" rename to "BeneficiariesHistory_hicn_idx"; ---alter table public."BeneficiariesHistory" rename constraint "BeneficiariesHistoryTemp_pkey" TO "BeneficiariesHistory_pkey"; -alter table public."BeneficiariesHistory" drop constraint "BeneficiariesHistoryTemp_pkey"; -alter table public."BeneficiariesHistory" - add constraint "BeneficiariesHistory_pkey" primary key ("beneficiaryHistoryId"); - diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V15__Update_MbiHistory_BeneficiaryId_to_varchar.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V15__Update_MbiHistory_BeneficiaryId_to_varchar.sql deleted file mode 100644 index f23263d813..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V15__Update_MbiHistory_BeneficiaryId_to_varchar.sql +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Alters the MedicareBeneficiaryIdHistory table's `beneficiaryId` to be a varchar(15), - * making it consistent with the current representation in our other tables. - * - * See https://jira.cms.gov/browse/BLUEBUTTON-1010. - */ - -alter table "MedicareBeneficiaryIdHistory" - alter column "beneficiaryId" ${logic.alter-column-type} varchar(15); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V16__Drop_hfj_objects.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V16__Drop_hfj_objects.sql deleted file mode 100644 index e286e09137..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V16__Drop_hfj_objects.sql +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Drops all hfj objects - */ - --- DROP hfj_* TABLES FROM PROD------------------------------ - DROP TABLE IF EXISTS public.hfj_spidx_token CASCADE; - DROP TABLE IF EXISTS public.hfj_spidx_uri CASCADE; - DROP TABLE IF EXISTS public.hfj_spidx_string CASCADE; - DROP TABLE IF EXISTS public.hfj_subscription CASCADE; - DROP TABLE IF EXISTS public.hfj_spidx_number CASCADE; - DROP TABLE IF EXISTS public.hfj_search_result CASCADE; - DROP TABLE IF EXISTS public.hfj_spidx_quantity CASCADE; - DROP TABLE IF EXISTS public.hfj_res_ver CASCADE; - DROP TABLE IF EXISTS public.hfj_subscription_flag_res CASCADE; - DROP TABLE IF EXISTS public.hfj_spidx_coords CASCADE; - DROP TABLE IF EXISTS public.hfj_res_link CASCADE; - DROP TABLE IF EXISTS public.hfj_res_tag CASCADE; - DROP TABLE IF EXISTS public.hfj_spidx_date CASCADE; - DROP TABLE IF EXISTS public.hfj_search_include CASCADE; - DROP TABLE IF EXISTS public.hfj_search CASCADE; - DROP TABLE IF EXISTS public.hfj_resource CASCADE; - DROP TABLE IF EXISTS public.hfj_forced_id CASCADE; - DROP TABLE IF EXISTS public.hfj_history_tag CASCADE; - DROP TABLE IF EXISTS public.hfj_tag_def CASCADE; - - -- DROP RELATED SEQUENCES -------------------------- - DROP SEQUENCE IF EXISTS seq_codesystem_pid CASCADE; - DROP SEQUENCE IF EXISTS seq_codesystemver_pid CASCADE; - DROP SEQUENCE IF EXISTS seq_concept_pc_pid CASCADE; - DROP SEQUENCE IF EXISTS seq_concept_pid CASCADE; - DROP SEQUENCE IF EXISTS seq_resource_history_id CASCADE; - DROP SEQUENCE IF EXISTS seq_resource_id CASCADE; - DROP SEQUENCE IF EXISTS seq_search CASCADE; - DROP SEQUENCE IF EXISTS seq_search_inc CASCADE; - DROP SEQUENCE IF EXISTS seq_search_res CASCADE; - DROP SEQUENCE IF EXISTS seq_spidx_coords CASCADE; - DROP SEQUENCE IF EXISTS seq_spidx_date CASCADE; - DROP SEQUENCE IF EXISTS seq_spidx_number CASCADE; - DROP SEQUENCE IF EXISTS seq_spidx_quantity CASCADE; - DROP SEQUENCE IF EXISTS seq_spidx_string CASCADE; - DROP SEQUENCE IF EXISTS seq_spidx_token CASCADE; - DROP SEQUENCE IF EXISTS seq_spidx_uri CASCADE; \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V17__Drop_hfj_tablespaces.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V17__Drop_hfj_tablespaces.sql deleted file mode 100644 index d92034b386..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V17__Drop_hfj_tablespaces.sql +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Drops all hfj tablespaces - */ - - -- DROP RELATED TABLESPACES--------------------------- -${logic.drop-tablespaces-escape} DROP TABLESPACE IF EXISTS fhirdb_cmn_ts; -${logic.drop-tablespaces-escape} DROP TABLESPACE IF EXISTS fhirdb_date_ts; -${logic.drop-tablespaces-escape} DROP TABLESPACE IF EXISTS fhirdb_link_ts; -${logic.drop-tablespaces-escape} DROP TABLESPACE IF EXISTS fhirdb_resource_ts; -${logic.drop-tablespaces-escape} DROP TABLESPACE IF EXISTS fhirdb_string_ts; -${logic.drop-tablespaces-escape} DROP TABLESPACE IF EXISTS fhirdb_token_ts; -${logic.drop-tablespaces-escape} DROP TABLESPACE IF EXISTS fhirdb_ver_ts; \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V18__Drop_trm_objects.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V18__Drop_trm_objects.sql deleted file mode 100644 index 18be9a70c9..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V18__Drop_trm_objects.sql +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Drops all trm objects - * These tables are from HAPI's JPA layer, which we're no longer using. - */ - --- DROP trm_* TABLES FROM PROD------------------------------ -DROP TABLE IF EXISTS public.trm_codesystem CASCADE; -DROP TABLE IF EXISTS public.trm_codesystem_ver CASCADE; -DROP TABLE IF EXISTS public.trm_concept CASCADE; -DROP TABLE IF EXISTS public.trm_concept_pc_link CASCADE; \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V19__Add_inner_join_relationships.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V19__Add_inner_join_relationships.sql deleted file mode 100644 index 1400c55b44..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V19__Add_inner_join_relationships.sql +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Alters the BeneficiariesHistory and MedicareBeneficiaryIdHistory tables to add foreign - * keys to Beneficiary. - * - * See: https://jira.cms.gov/browse/BLUEBUTTON-865 - */ - -/* - * Move all BeneificariesHistory entries that don't point to a valid Beneficiaries record to - * a separate table (we could delete it, but people who delete data are bad people). Really, - * we should not have ever received these BeneficiariesHistory entries from the CCW in the - * first place: we can't use them, and they prevent us from having a foreign key (and JPA - * relationship) on this table. - */ - -create table "BeneficiariesHistoryInvalidBeneficiaries" ( - "beneficiaryHistoryId" bigint not null, - "beneficiaryId" varchar(15), - "birthDate" date not null, - "hicn" varchar(64) not null, - "sex" char(1) not null, - "hicnUnhashed" varchar(11), - "medicareBeneficiaryId" varchar(11), - constraint "BeneficiariesHistoryInvalidBeneficiaries_pkey" primary key ("beneficiaryHistoryId") -) -${logic.tablespaces-escape} tablespace "beneficiaries_ts" -; - -insert into "BeneficiariesHistoryInvalidBeneficiaries" - select "BeneficiariesHistory".* - from "BeneficiariesHistory" - left join "Beneficiaries" - on "BeneficiariesHistory"."beneficiaryId" = "Beneficiaries"."beneficiaryId" - where "Beneficiaries"."beneficiaryId" is NULL; -delete - from "BeneficiariesHistory" - where "beneficiaryHistoryId" in ( - select "beneficiaryHistoryId" from "BeneficiariesHistoryInvalidBeneficiaries" - ); - -alter table "BeneficiariesHistory" - add constraint "BeneficiariesHistory_beneficiaryId_to_Beneficiary" - foreign key ("beneficiaryId") - references "Beneficiaries"; - --- Move all MedicareBeneficiaryIdHistory entries that don't point to a valid Beneficiaries --- record to a separate table, just as we did with BeneficiariesHistory entries above. -create table "MedicareBeneficiaryIdHistoryInvalidBeneficiaries" ( - "medicareBeneficiaryIdKey" numeric not null, - "beneficiaryId" varchar(15), - "claimAccountNumber" varchar(9), - "beneficiaryIdCode" varchar(2), - "mbiSequenceNumber" numeric, - "medicareBeneficiaryId" varchar(11), - "mbiEffectiveDate" date, - "mbiEndDate" date, - "mbiEffectiveReasonCode" varchar(5), - "mbiEndReasonCode" varchar(5), - "mbiCardRequestDate" date, - "mbiAddUser" varchar(30), - "mbiAddDate" timestamp, - "mbiUpdateUser" varchar(30), - "mbiUpdateDate" timestamp, - "mbiCrntRecIndId" numeric, - constraint "MedicareBeneficiaryIdHistoryInvalidBeneficiaries_pkey" primary key ("medicareBeneficiaryIdKey") -) -${logic.tablespaces-escape} tablespace "beneficiaries_ts" -; - -insert into "MedicareBeneficiaryIdHistoryInvalidBeneficiaries" - select "MedicareBeneficiaryIdHistory".* - from "MedicareBeneficiaryIdHistory" - left join "Beneficiaries" - on "MedicareBeneficiaryIdHistory"."beneficiaryId" = "Beneficiaries"."beneficiaryId" - where "Beneficiaries"."beneficiaryId" is NULL; -delete - from "MedicareBeneficiaryIdHistory" - where "medicareBeneficiaryIdKey" in ( - select "medicareBeneficiaryIdKey" from "MedicareBeneficiaryIdHistoryInvalidBeneficiaries" - ); - -alter table "MedicareBeneficiaryIdHistory" - add constraint "MedicareBeneficiaryIdHistory_beneficiaryId_to_Beneficiary" - foreign key ("beneficiaryId") - references "Beneficiaries"; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V1__Create_beneficiary_and_claim_tables.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V1__Create_beneficiary_and_claim_tables.sql deleted file mode 100644 index cac5e7266c..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V1__Create_beneficiary_and_claim_tables.sql +++ /dev/null @@ -1,1368 +0,0 @@ -/* - * Creates the beneficiary and claim tables required by the application. This - * schema is derived from the JPA metadata, via the - * gov.hhs.cms.bluebutton.data.pipeline.rif.schema.HibernateSchemaPrinter - * utility. - */ - -${logic.tablespaces-escape} SET default_tablespace = fhirdb_ts2; - -create table "Beneficiaries" ( - "beneficiaryId" varchar(15) not null, - "birthDate" date not null, - "countyCode" varchar(10) not null, - "endStageRenalDiseaseCode" char(1), - "entitlementCodeCurrent" char(1), - "entitlementCodeOriginal" char(1), - "hicn" varchar(64) not null, - "medicareEnrollmentStatusCode" varchar(2), - "nameGiven" varchar(15) not null, - "nameMiddleInitial" char(1), - "nameSurname" varchar(24) not null, - "partATerminationCode" char(1), - "partBTerminationCode" char(1), - "postalCode" varchar(9) not null, - "race" char(1), - "sex" char(1) not null, - "stateCode" varchar(2) not null, - constraint "Beneficiaries_pkey" primary key ("beneficiaryId") -) -${logic.tablespaces-escape} tablespace "beneficiaries_ts" -; - -create table "CarrierClaimLines" ( - "lineNumber" numeric not null, - "parentClaim" varchar(255) not null, - "allowedChargeAmount" numeric(12, 2) not null, - "anesthesiaUnitCount" numeric not null, - "beneficiaryPartBDeductAmount" numeric(12, 2) not null, - "beneficiaryPaymentAmount" numeric(12, 2) not null, - "betosCode" varchar(3), - "cliaLabNumber" varchar(10), - "cmsServiceTypeCode" char(1) not null, - "coinsuranceAmount" numeric(12, 2) not null, - "diagnosisCode" varchar(7), - "diagnosisCodeVersion" char(1), - "firstExpenseDate" date, - "hcpcsCode" varchar(5), - "hcpcsInitialModifierCode" varchar(5), - "hcpcsSecondModifierCode" varchar(5), - "hctHgbTestResult" numeric(4) not null, - "hctHgbTestTypeCode" varchar(2), - "hpsaScarcityCode" char(1), - "lastExpenseDate" date, - "linePricingLocalityCode" varchar(2) not null, - "mtusCode" char(1), - "mtusCount" numeric not null, - "nationalDrugCode" varchar(11), - "organizationNpi" varchar(10), - "paymentAmount" numeric(12, 2) not null, - "paymentCode" char(1), - "performingPhysicianNpi" varchar(12), - "performingPhysicianUpin" varchar(12), - "performingProviderIdNumber" varchar(15) not null, - "placeOfServiceCode" varchar(2) not null, - "primaryPayerCode" char(1), - "primaryPayerPaidAmount" numeric(12, 2) not null, - "processingIndicatorCode" varchar(2), - "providerParticipatingIndCode" char(1), - "providerPaymentAmount" numeric(12, 2) not null, - "providerSpecialityCode" varchar(3), - "providerStateCode" varchar(2), - "providerTaxNumber" varchar(10) not null, - "providerTypeCode" char(1) not null, - "providerZipCode" varchar(9), - "reducedPaymentPhysicianAsstCode" char(1) not null, - "rxNumber" varchar(30), - "serviceCount" numeric not null, - "serviceDeductibleCode" char(1), - "submittedChargeAmount" numeric(12, 2) not null, - constraint "CarrierClaimLines_pkey" primary key ("lineNumber", "parentClaim") -) -${logic.tablespaces-escape} tablespace "carrierclaimlines_ts" -; - -create table "CarrierClaims" ( - "claimId" varchar(15) not null, - "allowedChargeAmount" numeric(12, 2) not null, - "beneficiaryId" varchar(15) not null, - "beneficiaryPartBDeductAmount" numeric(12, 2) not null, - "beneficiaryPaymentAmount" numeric(12, 2) not null, - "carrierNumber" varchar(5) not null, - "claimDispositionCode" varchar(2) not null, - "claimEntryCode" char(1) not null, - "claimGroupId" numeric(12) not null, - "claimTypeCode" varchar(2) not null, - "clinicalTrialNumber" varchar(8), - "dateFrom" date not null, - "dateThrough" date not null, - "diagnosis10Code" varchar(7), - "diagnosis10CodeVersion" char(1), - "diagnosis11Code" varchar(7), - "diagnosis11CodeVersion" char(1), - "diagnosis12Code" varchar(7), - "diagnosis12CodeVersion" char(1), - "diagnosis1Code" varchar(7), - "diagnosis1CodeVersion" char(1), - "diagnosis2Code" varchar(7), - "diagnosis2CodeVersion" char(1), - "diagnosis3Code" varchar(7), - "diagnosis3CodeVersion" char(1), - "diagnosis4Code" varchar(7), - "diagnosis4CodeVersion" char(1), - "diagnosis5Code" varchar(7), - "diagnosis5CodeVersion" char(1), - "diagnosis6Code" varchar(7), - "diagnosis6CodeVersion" char(1), - "diagnosis7Code" varchar(7), - "diagnosis7CodeVersion" char(1), - "diagnosis8Code" varchar(7), - "diagnosis8CodeVersion" char(1), - "diagnosis9Code" varchar(7), - "diagnosis9CodeVersion" char(1), - "diagnosisPrincipalCode" varchar(7), - "diagnosisPrincipalCodeVersion" char(1), - "hcpcsYearCode" char(1), - "nearLineRecordIdCode" char(1) not null, - "paymentAmount" numeric(12, 2) not null, - "paymentDenialCode" varchar(2) not null, - "primaryPayerPaidAmount" numeric(12, 2) not null, - "providerAssignmentIndicator" char(1), - "providerPaymentAmount" numeric(12, 2) not null, - "referringPhysicianNpi" varchar(12), - "referringPhysicianUpin" varchar(12), - "referringProviderIdNumber" varchar(14) not null, - "submittedChargeAmount" numeric(12, 2) not null, - "weeklyProcessDate" date not null, - constraint "CarrierClaims_pkey" primary key ("claimId") -) -${logic.tablespaces-escape} tablespace "carrierclaims_ts" -; - -create table "DMEClaimLines" ( - "lineNumber" numeric not null, - "parentClaim" varchar(255) not null, - "allowedChargeAmount" numeric(12, 2) not null, - "beneficiaryPartBDeductAmount" numeric(12, 2) not null, - "beneficiaryPaymentAmount" numeric(12, 2) not null, - "betosCode" varchar(3), - "cmsServiceTypeCode" char(1) not null, - "coinsuranceAmount" numeric(12, 2) not null, - "diagnosisCode" varchar(7), - "diagnosisCodeVersion" char(1), - "firstExpenseDate" date, - "hcpcsCode" varchar(5), - "hcpcsFourthModifierCode" varchar(5), - "hcpcsInitialModifierCode" varchar(5), - "hcpcsSecondModifierCode" varchar(5), - "hcpcsThirdModifierCode" varchar(5), - "hctHgbTestResult" numeric(3, 1) not null, - "hctHgbTestTypeCode" varchar(2), - "lastExpenseDate" date, - "mtusCode" char(1), - "mtusCount" numeric not null, - "nationalDrugCode" varchar(11), - "paymentAmount" numeric(12, 2) not null, - "paymentCode" char(1), - "placeOfServiceCode" varchar(2) not null, - "pricingStateCode" varchar(2), - "primaryPayerAllowedChargeAmount" numeric(12, 2) not null, - "primaryPayerCode" char(1), - "primaryPayerPaidAmount" numeric(12, 2) not null, - "processingIndicatorCode" varchar(2), - "providerBillingNumber" varchar(10), - "providerNPI" varchar(12), - "providerParticipatingIndCode" char(1), - "providerPaymentAmount" numeric(12, 2) not null, - "providerSpecialityCode" varchar(3), - "providerStateCode" varchar(2) not null, - "providerTaxNumber" varchar(10) not null, - "purchasePriceAmount" numeric(12, 2) not null, - "screenSavingsAmount" numeric(12, 2), - "serviceCount" numeric not null, - "serviceDeductibleCode" char(1), - "submittedChargeAmount" numeric(12, 2) not null, - "supplierTypeCode" char(1), - constraint "DMEClaimLines_pkey" primary key ("lineNumber", "parentClaim") -) -${logic.tablespaces-escape} tablespace "dmeclaimlines_ts" -; - -create table "DMEClaims" ( - "claimId" varchar(15) not null, - "allowedChargeAmount" numeric(12, 2) not null, - "beneficiaryId" varchar(15) not null, - "beneficiaryPartBDeductAmount" numeric(12, 2) not null, - "beneficiaryPaymentAmount" numeric(12, 2) not null, - "carrierNumber" varchar(5) not null, - "claimDispositionCode" varchar(2) not null, - "claimEntryCode" char(1) not null, - "claimGroupId" numeric(12) not null, - "claimTypeCode" varchar(2) not null, - "clinicalTrialNumber" varchar(8), - "dateFrom" date not null, - "dateThrough" date not null, - "diagnosis10Code" varchar(7), - "diagnosis10CodeVersion" char(1), - "diagnosis11Code" varchar(7), - "diagnosis11CodeVersion" char(1), - "diagnosis12Code" varchar(7), - "diagnosis12CodeVersion" char(1), - "diagnosis1Code" varchar(7), - "diagnosis1CodeVersion" char(1), - "diagnosis2Code" varchar(7), - "diagnosis2CodeVersion" char(1), - "diagnosis3Code" varchar(7), - "diagnosis3CodeVersion" char(1), - "diagnosis4Code" varchar(7), - "diagnosis4CodeVersion" char(1), - "diagnosis5Code" varchar(7), - "diagnosis5CodeVersion" char(1), - "diagnosis6Code" varchar(7), - "diagnosis6CodeVersion" char(1), - "diagnosis7Code" varchar(7), - "diagnosis7CodeVersion" char(1), - "diagnosis8Code" varchar(7), - "diagnosis8CodeVersion" char(1), - "diagnosis9Code" varchar(7), - "diagnosis9CodeVersion" char(1), - "diagnosisPrincipalCode" varchar(7), - "diagnosisPrincipalCodeVersion" char(1), - "hcpcsYearCode" char(1), - "nearLineRecordIdCode" char(1) not null, - "paymentAmount" numeric(12, 2) not null, - "paymentDenialCode" varchar(2) not null, - "primaryPayerPaidAmount" numeric(12, 2) not null, - "providerAssignmentIndicator" char(1) not null, - "providerPaymentAmount" numeric(12, 2) not null, - "referringPhysicianNpi" varchar(12), - "referringPhysicianUpin" varchar(12), - "submittedChargeAmount" numeric(12, 2) not null, - "weeklyProcessDate" date not null, - constraint "DMEClaims_pkey" primary key ("claimId") -) -${logic.tablespaces-escape} tablespace "dmeclaims_ts" -; - -create table "HHAClaimLines" ( - "lineNumber" numeric not null, - "parentClaim" varchar(255) not null, - "apcOrHippsCode" varchar(5), - "deductibleCoinsuranceCd" char(1), - "hcpcsCode" varchar(5), - "hcpcsInitialModifierCode" varchar(5), - "hcpcsSecondModifierCode" varchar(5), - "nationalDrugCodeQualifierCode" varchar(2), - "nationalDrugCodeQuantity" numeric, - "nonCoveredChargeAmount" numeric(12, 2) not null, - "paymentAmount" numeric(12, 2) not null, - "paymentMethodCode" varchar(2), - "rateAmount" numeric(12, 2) not null, - "revCntr1stAnsiCd" varchar(5), - "revenueCenterCode" varchar(4) not null, - "revenueCenterDate" date, - "revenueCenterRenderingPhysicianNPI" varchar(12), - "revenueCenterRenderingPhysicianUPIN" varchar(12), - "statusCode" varchar(2), - "totalChargeAmount" numeric(12, 2) not null, - "unitCount" numeric not null, - constraint "HHAClaimLines_pkey" primary key ("lineNumber", "parentClaim") -) -${logic.tablespaces-escape} tablespace "hhaclaimlines_ts" -; - -create table "HHAClaims" ( - "claimId" varchar(15) not null, - "attendingPhysicianNpi" varchar(10), - "attendingPhysicianUpin" varchar(9), - "beneficiaryId" varchar(15) not null, - "careStartDate" date, - "claimFacilityTypeCode" char(1) not null, - "claimFrequencyCode" char(1) not null, - "claimGroupId" numeric(12) not null, - "claimLUPACode" char(1), - "claimNonPaymentReasonCode" varchar(2), - "claimPrimaryPayerCode" char(1), - "claimReferralCode" char(1), - "claimServiceClassificationTypeCode" char(1) not null, - "claimTypeCode" varchar(2) not null, - "dateFrom" date not null, - "dateThrough" date not null, - "diagnosis10Code" varchar(7), - "diagnosis10CodeVersion" char(1), - "diagnosis11Code" varchar(7), - "diagnosis11CodeVersion" char(1), - "diagnosis12Code" varchar(7), - "diagnosis12CodeVersion" char(1), - "diagnosis13Code" varchar(7), - "diagnosis13CodeVersion" char(1), - "diagnosis14Code" varchar(7), - "diagnosis14CodeVersion" char(1), - "diagnosis15Code" varchar(7), - "diagnosis15CodeVersion" char(1), - "diagnosis16Code" varchar(7), - "diagnosis16CodeVersion" char(1), - "diagnosis17Code" varchar(7), - "diagnosis17CodeVersion" char(1), - "diagnosis18Code" varchar(7), - "diagnosis18CodeVersion" char(1), - "diagnosis19Code" varchar(7), - "diagnosis19CodeVersion" char(1), - "diagnosis1Code" varchar(7), - "diagnosis1CodeVersion" char(1), - "diagnosis20Code" varchar(7), - "diagnosis20CodeVersion" char(1), - "diagnosis21Code" varchar(7), - "diagnosis21CodeVersion" char(1), - "diagnosis22Code" varchar(7), - "diagnosis22CodeVersion" char(1), - "diagnosis23Code" varchar(7), - "diagnosis23CodeVersion" char(1), - "diagnosis24Code" varchar(7), - "diagnosis24CodeVersion" char(1), - "diagnosis25Code" varchar(7), - "diagnosis25CodeVersion" char(1), - "diagnosis2Code" varchar(7), - "diagnosis2CodeVersion" char(1), - "diagnosis3Code" varchar(7), - "diagnosis3CodeVersion" char(1), - "diagnosis4Code" varchar(7), - "diagnosis4CodeVersion" char(1), - "diagnosis5Code" varchar(7), - "diagnosis5CodeVersion" char(1), - "diagnosis6Code" varchar(7), - "diagnosis6CodeVersion" char(1), - "diagnosis7Code" varchar(7), - "diagnosis7CodeVersion" char(1), - "diagnosis8Code" varchar(7), - "diagnosis8CodeVersion" char(1), - "diagnosis9Code" varchar(7), - "diagnosis9CodeVersion" char(1), - "diagnosisExternal10Code" varchar(7), - "diagnosisExternal10CodeVersion" char(1), - "diagnosisExternal11Code" varchar(7), - "diagnosisExternal11CodeVersion" char(1), - "diagnosisExternal12Code" varchar(7), - "diagnosisExternal12CodeVersion" char(1), - "diagnosisExternal1Code" varchar(7), - "diagnosisExternal1CodeVersion" char(1), - "diagnosisExternal2Code" varchar(7), - "diagnosisExternal2CodeVersion" char(1), - "diagnosisExternal3Code" varchar(7), - "diagnosisExternal3CodeVersion" char(1), - "diagnosisExternal4Code" varchar(7), - "diagnosisExternal4CodeVersion" char(1), - "diagnosisExternal5Code" varchar(7), - "diagnosisExternal5CodeVersion" char(1), - "diagnosisExternal6Code" varchar(7), - "diagnosisExternal6CodeVersion" char(1), - "diagnosisExternal7Code" varchar(7), - "diagnosisExternal7CodeVersion" char(1), - "diagnosisExternal8Code" varchar(7), - "diagnosisExternal8CodeVersion" char(1), - "diagnosisExternal9Code" varchar(7), - "diagnosisExternal9CodeVersion" char(1), - "diagnosisExternalFirstCode" varchar(7), - "diagnosisExternalFirstCodeVersion" char(1), - "diagnosisPrincipalCode" varchar(7), - "diagnosisPrincipalCodeVersion" char(1), - "fiscalIntermediaryClaimProcessDate" date, - "fiscalIntermediaryNumber" varchar(5), - "nearLineRecordIdCode" char(1) not null, - "organizationNpi" varchar(10), - "patientDischargeStatusCode" varchar(2) not null, - "paymentAmount" numeric(12, 2) not null, - "primaryPayerPaidAmount" numeric(12, 2) not null, - "prospectivePaymentCode" char(1) not null, - "providerNumber" varchar(9) not null, - "providerStateCode" varchar(2) not null, - "totalChargeAmount" numeric(12, 2) not null, - "totalVisitCount" numeric(4) not null, - "weeklyProcessDate" date not null, - constraint "HHAClaims_pkey" primary key ("claimId") -) -${logic.tablespaces-escape} tablespace "hhaclaims_ts" -; - -create table "HospiceClaimLines" ( - "lineNumber" numeric not null, - "parentClaim" varchar(255) not null, - "benficiaryPaymentAmount" numeric(12, 2) not null, - "deductibleCoinsuranceCd" char(1), - "hcpcsCode" varchar(5), - "hcpcsInitialModifierCode" varchar(5), - "hcpcsSecondModifierCode" varchar(5), - "nationalDrugCodeQualifierCode" varchar(2), - "nationalDrugCodeQuantity" numeric, - "nonCoveredChargeAmount" numeric(12, 2), - "paymentAmount" numeric(12, 2) not null, - "providerPaymentAmount" numeric(12, 2) not null, - "rateAmount" numeric(12, 2) not null, - "revenueCenterCode" varchar(4) not null, - "revenueCenterDate" date, - "revenueCenterRenderingPhysicianNPI" varchar(12), - "revenueCenterRenderingPhysicianUPIN" varchar(12), - "totalChargeAmount" numeric(12, 2) not null, - "unitCount" numeric not null, - constraint "HospiceClaimLines_pkey" primary key ("lineNumber", "parentClaim") -) -${logic.tablespaces-escape} tablespace "hospiceclaimlines_ts" -; - -create table "HospiceClaims" ( - "claimId" varchar(15) not null, - "attendingPhysicianNpi" varchar(10), - "attendingPhysicianUpin" varchar(9), - "beneficiaryDischargeDate" date, - "beneficiaryId" varchar(15) not null, - "claimFacilityTypeCode" char(1) not null, - "claimFrequencyCode" char(1) not null, - "claimGroupId" numeric(12) not null, - "claimHospiceStartDate" date, - "claimNonPaymentReasonCode" varchar(2), - "claimPrimaryPayerCode" char(1), - "claimServiceClassificationTypeCode" char(1) not null, - "claimTypeCode" varchar(2) not null, - "dateFrom" date not null, - "dateThrough" date not null, - "diagnosis10Code" varchar(7), - "diagnosis10CodeVersion" char(1), - "diagnosis11Code" varchar(7), - "diagnosis11CodeVersion" char(1), - "diagnosis12Code" varchar(7), - "diagnosis12CodeVersion" char(1), - "diagnosis13Code" varchar(7), - "diagnosis13CodeVersion" char(1), - "diagnosis14Code" varchar(7), - "diagnosis14CodeVersion" char(1), - "diagnosis15Code" varchar(7), - "diagnosis15CodeVersion" char(1), - "diagnosis16Code" varchar(7), - "diagnosis16CodeVersion" char(1), - "diagnosis17Code" varchar(7), - "diagnosis17CodeVersion" char(1), - "diagnosis18Code" varchar(7), - "diagnosis18CodeVersion" char(1), - "diagnosis19Code" varchar(7), - "diagnosis19CodeVersion" char(1), - "diagnosis1Code" varchar(7), - "diagnosis1CodeVersion" char(1), - "diagnosis20Code" varchar(7), - "diagnosis20CodeVersion" char(1), - "diagnosis21Code" varchar(7), - "diagnosis21CodeVersion" char(1), - "diagnosis22Code" varchar(7), - "diagnosis22CodeVersion" char(1), - "diagnosis23Code" varchar(7), - "diagnosis23CodeVersion" char(1), - "diagnosis24Code" varchar(7), - "diagnosis24CodeVersion" char(1), - "diagnosis25Code" varchar(7), - "diagnosis25CodeVersion" char(1), - "diagnosis2Code" varchar(7), - "diagnosis2CodeVersion" char(1), - "diagnosis3Code" varchar(7), - "diagnosis3CodeVersion" char(1), - "diagnosis4Code" varchar(7), - "diagnosis4CodeVersion" char(1), - "diagnosis5Code" varchar(7), - "diagnosis5CodeVersion" char(1), - "diagnosis6Code" varchar(7), - "diagnosis6CodeVersion" char(1), - "diagnosis7Code" varchar(7), - "diagnosis7CodeVersion" char(1), - "diagnosis8Code" varchar(7), - "diagnosis8CodeVersion" char(1), - "diagnosis9Code" varchar(7), - "diagnosis9CodeVersion" char(1), - "diagnosisExternal10Code" varchar(7), - "diagnosisExternal10CodeVersion" char(1), - "diagnosisExternal11Code" varchar(7), - "diagnosisExternal11CodeVersion" char(1), - "diagnosisExternal12Code" varchar(7), - "diagnosisExternal12CodeVersion" char(1), - "diagnosisExternal1Code" varchar(7), - "diagnosisExternal1CodeVersion" char(1), - "diagnosisExternal2Code" varchar(7), - "diagnosisExternal2CodeVersion" char(1), - "diagnosisExternal3Code" varchar(7), - "diagnosisExternal3CodeVersion" char(1), - "diagnosisExternal4Code" varchar(7), - "diagnosisExternal4CodeVersion" char(1), - "diagnosisExternal5Code" varchar(7), - "diagnosisExternal5CodeVersion" char(1), - "diagnosisExternal6Code" varchar(7), - "diagnosisExternal6CodeVersion" char(1), - "diagnosisExternal7Code" varchar(7), - "diagnosisExternal7CodeVersion" char(1), - "diagnosisExternal8Code" varchar(7), - "diagnosisExternal8CodeVersion" char(1), - "diagnosisExternal9Code" varchar(7), - "diagnosisExternal9CodeVersion" char(1), - "diagnosisExternalFirstCode" varchar(7), - "diagnosisExternalFirstCodeVersion" char(1), - "diagnosisPrincipalCode" varchar(7), - "diagnosisPrincipalCodeVersion" char(1), - "fiscalIntermediaryClaimProcessDate" date, - "fiscalIntermediaryNumber" varchar(5), - "hospicePeriodCount" numeric(2), - "nearLineRecordIdCode" char(1) not null, - "organizationNpi" varchar(10), - "patientDischargeStatusCode" varchar(2) not null, - "patientStatusCd" char(1), - "paymentAmount" numeric(12, 2) not null, - "primaryPayerPaidAmount" numeric(12, 2) not null, - "providerNumber" varchar(9) not null, - "providerStateCode" varchar(2) not null, - "totalChargeAmount" numeric(12, 2) not null, - "utilizationDayCount" numeric not null, - "weeklyProcessDate" date not null, - constraint "HospiceClaims_pkey" primary key ("claimId") -) -${logic.tablespaces-escape} tablespace "hospiceclaims_ts" -; - -create table "InpatientClaimLines" ( - "lineNumber" numeric not null, - "parentClaim" varchar(255) not null, - "deductibleCoinsuranceCd" char(1), - "hcpcsCode" varchar(5), - "nationalDrugCodeQualifierCode" varchar(2), - "nationalDrugCodeQuantity" numeric, - "nonCoveredChargeAmount" numeric(12, 2) not null, - "rateAmount" numeric(12, 2) not null, - "revenueCenter" varchar(4) not null, - "revenueCenterRenderingPhysicianNPI" varchar(12), - "revenueCenterRenderingPhysicianUPIN" varchar(12), - "totalChargeAmount" numeric(12, 2) not null, - "unitCount" numeric not null, - constraint "InpatientClaimLines_pkey" primary key ("lineNumber", "parentClaim") -) -${logic.tablespaces-escape} tablespace "inpatientclaimlines_ts" -; - -create table "InpatientClaims" ( - "claimId" varchar(15) not null, - "admissionTypeCd" char(1) not null, - "attendingPhysicianNpi" varchar(10), - "attendingPhysicianUpin" varchar(9), - "beneficiaryDischargeDate" date, - "beneficiaryId" varchar(15) not null, - "bloodDeductibleLiabilityAmount" numeric(12, 2) not null, - "bloodPintsFurnishedQty" numeric not null, - "claimAdmissionDate" date, - "claimFacilityTypeCode" char(1) not null, - "claimFrequencyCode" char(1) not null, - "claimGroupId" numeric(12) not null, - "claimNonPaymentReasonCode" varchar(2), - "claimPPSCapitalDisproportionateShareAmt" numeric(12, 2), - "claimPPSCapitalDrgWeightNumber" numeric(7, 4), - "claimPPSCapitalExceptionAmount" numeric(12, 2), - "claimPPSCapitalFSPAmount" numeric(12, 2), - "claimPPSCapitalIMEAmount" numeric(12, 2), - "claimPPSCapitalOutlierAmount" numeric(12, 2), - "claimPPSOldCapitalHoldHarmlessAmount" numeric(12, 2), - "claimPrimaryPayerCode" char(1), - "claimQueryCode" char(1) not null, - "claimServiceClassificationTypeCode" char(1) not null, - "claimTotalPPSCapitalAmount" numeric(12, 2), - "claimTypeCode" varchar(2) not null, - "coinsuranceDayCount" numeric not null, - "coveredCareThoughDate" date, - "dateFrom" date not null, - "dateThrough" date not null, - "deductibleAmount" numeric(12, 2) not null, - "diagnosis10Code" varchar(7), - "diagnosis10CodeVersion" char(1), - "diagnosis10PresentOnAdmissionCode" char(1), - "diagnosis11Code" varchar(7), - "diagnosis11CodeVersion" char(1), - "diagnosis11PresentOnAdmissionCode" char(1), - "diagnosis12Code" varchar(7), - "diagnosis12CodeVersion" char(1), - "diagnosis12PresentOnAdmissionCode" char(1), - "diagnosis13Code" varchar(7), - "diagnosis13CodeVersion" char(1), - "diagnosis13PresentOnAdmissionCode" char(1), - "diagnosis14Code" varchar(7), - "diagnosis14CodeVersion" char(1), - "diagnosis14PresentOnAdmissionCode" char(1), - "diagnosis15Code" varchar(7), - "diagnosis15CodeVersion" char(1), - "diagnosis15PresentOnAdmissionCode" char(1), - "diagnosis16Code" varchar(7), - "diagnosis16CodeVersion" char(1), - "diagnosis16PresentOnAdmissionCode" char(1), - "diagnosis17Code" varchar(7), - "diagnosis17CodeVersion" char(1), - "diagnosis17PresentOnAdmissionCode" char(1), - "diagnosis18Code" varchar(7), - "diagnosis18CodeVersion" char(1), - "diagnosis18PresentOnAdmissionCode" char(1), - "diagnosis19Code" varchar(7), - "diagnosis19CodeVersion" char(1), - "diagnosis19PresentOnAdmissionCode" char(1), - "diagnosis1Code" varchar(7), - "diagnosis1CodeVersion" char(1), - "diagnosis1PresentOnAdmissionCode" char(1), - "diagnosis20Code" varchar(7), - "diagnosis20CodeVersion" char(1), - "diagnosis20PresentOnAdmissionCode" char(1), - "diagnosis21Code" varchar(7), - "diagnosis21CodeVersion" char(1), - "diagnosis21PresentOnAdmissionCode" char(1), - "diagnosis22Code" varchar(7), - "diagnosis22CodeVersion" char(1), - "diagnosis22PresentOnAdmissionCode" char(1), - "diagnosis23Code" varchar(7), - "diagnosis23CodeVersion" char(1), - "diagnosis23PresentOnAdmissionCode" char(1), - "diagnosis24Code" varchar(7), - "diagnosis24CodeVersion" char(1), - "diagnosis24PresentOnAdmissionCode" char(1), - "diagnosis25Code" varchar(7), - "diagnosis25CodeVersion" char(1), - "diagnosis25PresentOnAdmissionCode" char(1), - "diagnosis2Code" varchar(7), - "diagnosis2CodeVersion" char(1), - "diagnosis2PresentOnAdmissionCode" char(1), - "diagnosis3Code" varchar(7), - "diagnosis3CodeVersion" char(1), - "diagnosis3PresentOnAdmissionCode" char(1), - "diagnosis4Code" varchar(7), - "diagnosis4CodeVersion" char(1), - "diagnosis4PresentOnAdmissionCode" char(1), - "diagnosis5Code" varchar(7), - "diagnosis5CodeVersion" char(1), - "diagnosis5PresentOnAdmissionCode" char(1), - "diagnosis6Code" varchar(7), - "diagnosis6CodeVersion" char(1), - "diagnosis6PresentOnAdmissionCode" char(1), - "diagnosis7Code" varchar(7), - "diagnosis7CodeVersion" char(1), - "diagnosis7PresentOnAdmissionCode" char(1), - "diagnosis8Code" varchar(7), - "diagnosis8CodeVersion" char(1), - "diagnosis8PresentOnAdmissionCode" char(1), - "diagnosis9Code" varchar(7), - "diagnosis9CodeVersion" char(1), - "diagnosis9PresentOnAdmissionCode" char(1), - "diagnosisAdmittingCode" varchar(7), - "diagnosisAdmittingCodeVersion" char(1), - "diagnosisExternal10Code" varchar(7), - "diagnosisExternal10CodeVersion" char(1), - "diagnosisExternal10PresentOnAdmissionCode" char(1), - "diagnosisExternal11Code" varchar(7), - "diagnosisExternal11CodeVersion" char(1), - "diagnosisExternal11PresentOnAdmissionCode" char(1), - "diagnosisExternal12Code" varchar(7), - "diagnosisExternal12CodeVersion" char(1), - "diagnosisExternal12PresentOnAdmissionCode" char(1), - "diagnosisExternal1Code" varchar(7), - "diagnosisExternal1CodeVersion" char(1), - "diagnosisExternal1PresentOnAdmissionCode" char(1), - "diagnosisExternal2Code" varchar(7), - "diagnosisExternal2CodeVersion" char(1), - "diagnosisExternal2PresentOnAdmissionCode" char(1), - "diagnosisExternal3Code" varchar(7), - "diagnosisExternal3CodeVersion" char(1), - "diagnosisExternal3PresentOnAdmissionCode" char(1), - "diagnosisExternal4Code" varchar(7), - "diagnosisExternal4CodeVersion" char(1), - "diagnosisExternal4PresentOnAdmissionCode" char(1), - "diagnosisExternal5Code" varchar(7), - "diagnosisExternal5CodeVersion" char(1), - "diagnosisExternal5PresentOnAdmissionCode" char(1), - "diagnosisExternal6Code" varchar(7), - "diagnosisExternal6CodeVersion" char(1), - "diagnosisExternal6PresentOnAdmissionCode" char(1), - "diagnosisExternal7Code" varchar(7), - "diagnosisExternal7CodeVersion" char(1), - "diagnosisExternal7PresentOnAdmissionCode" char(1), - "diagnosisExternal8Code" varchar(7), - "diagnosisExternal8CodeVersion" char(1), - "diagnosisExternal8PresentOnAdmissionCode" char(1), - "diagnosisExternal9Code" varchar(7), - "diagnosisExternal9CodeVersion" char(1), - "diagnosisExternal9PresentOnAdmissionCode" char(1), - "diagnosisExternalFirstCode" varchar(7), - "diagnosisExternalFirstCodeVersion" char(1), - "diagnosisPrincipalCode" varchar(7), - "diagnosisPrincipalCodeVersion" char(1), - "diagnosisRelatedGroupCd" varchar(3), - "diagnosisRelatedGroupOutlierStayCd" char(1) not null, - "disproportionateShareAmount" numeric, - "drgOutlierApprovedPaymentAmount" numeric(12, 2), - "fiscalIntermediaryClaimActionCode" char(1), - "fiscalIntermediaryClaimProcessDate" date, - "fiscalIntermediaryNumber" varchar(5), - "indirectMedicalEducationAmount" numeric, - "lifetimeReservedDaysUsedCount" numeric, - "mcoPaidSw" char(1), - "medicareBenefitsExhaustedDate" date, - "nearLineRecordIdCode" char(1) not null, - "nonUtilizationDayCount" numeric not null, - "noncoveredCharge" numeric(12, 2) not null, - "noncoveredStayFromDate" date, - "noncoveredStayThroughDate" date, - "operatingPhysicianNpi" varchar(10), - "operatingPhysicianUpin" varchar(9), - "organizationNpi" varchar(10), - "otherPhysicianNpi" varchar(10), - "otherPhysicianUpin" varchar(9), - "partACoinsuranceLiabilityAmount" numeric(12, 2) not null, - "passThruPerDiemAmount" numeric(12, 2) not null, - "patientDischargeStatusCode" varchar(2) not null, - "patientStatusCd" char(1), - "paymentAmount" numeric(12, 2) not null, - "primaryPayerPaidAmount" numeric(12, 2) not null, - "procedure10Code" varchar(7), - "procedure10CodeVersion" char(1), - "procedure10Date" date, - "procedure11Code" varchar(7), - "procedure11CodeVersion" char(1), - "procedure11Date" date, - "procedure12Code" varchar(7), - "procedure12CodeVersion" char(1), - "procedure12Date" date, - "procedure13Code" varchar(7), - "procedure13CodeVersion" char(1), - "procedure13Date" date, - "procedure14Code" varchar(7), - "procedure14CodeVersion" char(1), - "procedure14Date" date, - "procedure15Code" varchar(7), - "procedure15CodeVersion" char(1), - "procedure15Date" date, - "procedure16Code" varchar(7), - "procedure16CodeVersion" char(1), - "procedure16Date" date, - "procedure17Code" varchar(7), - "procedure17CodeVersion" char(1), - "procedure17Date" date, - "procedure18Code" varchar(7), - "procedure18CodeVersion" char(1), - "procedure18Date" date, - "procedure19Code" varchar(7), - "procedure19CodeVersion" char(1), - "procedure19Date" date, - "procedure1Code" varchar(7), - "procedure1CodeVersion" char(1), - "procedure1Date" date, - "procedure20Code" varchar(7), - "procedure20CodeVersion" char(1), - "procedure20Date" date, - "procedure21Code" varchar(7), - "procedure21CodeVersion" char(1), - "procedure21Date" date, - "procedure22Code" varchar(7), - "procedure22CodeVersion" char(1), - "procedure22Date" date, - "procedure23Code" varchar(7), - "procedure23CodeVersion" char(1), - "procedure23Date" date, - "procedure24Code" varchar(7), - "procedure24CodeVersion" char(1), - "procedure24Date" date, - "procedure25Code" varchar(7), - "procedure25CodeVersion" char(1), - "procedure25Date" date, - "procedure2Code" varchar(7), - "procedure2CodeVersion" char(1), - "procedure2Date" date, - "procedure3Code" varchar(7), - "procedure3CodeVersion" char(1), - "procedure3Date" date, - "procedure4Code" varchar(7), - "procedure4CodeVersion" char(1), - "procedure4Date" date, - "procedure5Code" varchar(7), - "procedure5CodeVersion" char(1), - "procedure5Date" date, - "procedure6Code" varchar(7), - "procedure6CodeVersion" char(1), - "procedure6Date" date, - "procedure7Code" varchar(7), - "procedure7CodeVersion" char(1), - "procedure7Date" date, - "procedure8Code" varchar(7), - "procedure8CodeVersion" char(1), - "procedure8Date" date, - "procedure9Code" varchar(7), - "procedure9CodeVersion" char(1), - "procedure9Date" date, - "professionalComponentCharge" numeric(12, 2) not null, - "prospectivePaymentCode" char(1), - "providerNumber" varchar(9) not null, - "providerStateCode" varchar(2) not null, - "sourceAdmissionCd" char(1), - "totalChargeAmount" numeric(12, 2) not null, - "totalDeductionAmount" numeric(12, 2) not null, - "utilizationDayCount" numeric not null, - "weeklyProcessDate" date not null, - constraint "InpatientClaims_pkey" primary key ("claimId") -) -${logic.tablespaces-escape} tablespace "inpatientclaims_ts" -; - -create table "OutpatientClaimLines" ( - "lineNumber" numeric not null, - "parentClaim" varchar(255) not null, - "apcOrHippsCode" varchar(5), - "benficiaryPaymentAmount" numeric(12, 2) not null, - "bloodDeductibleAmount" numeric(12, 2) not null, - "cashDeductibleAmount" numeric(12, 2) not null, - "discountCode" char(1), - "firstMspPaidAmount" numeric(12, 2) not null, - "hcpcsCode" varchar(5), - "hcpcsInitialModifierCode" varchar(5), - "hcpcsSecondModifierCode" varchar(5), - "nationalDrugCode" varchar(24), - "nationalDrugCodeQualifierCode" varchar(2), - "nationalDrugCodeQuantity" numeric, - "nonCoveredChargeAmount" numeric(12, 2) not null, - "obligationToAcceptAsFullPaymentCode" char(1), - "packagingCode" char(1), - "patientResponsibilityAmount" numeric(12, 2) not null, - "paymentAmount" numeric(12, 2) not null, - "paymentMethodCode" varchar(2), - "providerPaymentAmount" numeric(12, 2) not null, - "rateAmount" numeric(12, 2) not null, - "reducedCoinsuranceAmount" numeric(12, 2) not null, - "revCntr1stAnsiCd" varchar(5), - "revCntr2ndAnsiCd" varchar(5), - "revCntr3rdAnsiCd" varchar(5), - "revCntr4thAnsiCd" varchar(5), - "revenueCenterCode" varchar(4) not null, - "revenueCenterDate" date, - "revenueCenterRenderingPhysicianNPI" varchar(12), - "revenueCenterRenderingPhysicianUPIN" varchar(12), - "secondMspPaidAmount" numeric(12, 2) not null, - "statusCode" varchar(2), - "totalChargeAmount" numeric(12, 2) not null, - "unitCount" numeric not null, - "wageAdjustedCoinsuranceAmount" numeric(12, 2) not null, - constraint "OutpatientClaimLines_pkey" primary key ("lineNumber", "parentClaim") -) -${logic.tablespaces-escape} tablespace "outpatientclaimlines_ts" -; - -create table "OutpatientClaims" ( - "claimId" varchar(15) not null, - "attendingPhysicianNpi" varchar(10), - "attendingPhysicianUpin" varchar(9), - "beneficiaryId" varchar(15) not null, - "beneficiaryPaymentAmount" numeric(12, 2) not null, - "bloodDeductibleLiabilityAmount" numeric(12, 2) not null, - "claimFacilityTypeCode" char(1) not null, - "claimFrequencyCode" char(1) not null, - "claimGroupId" numeric(12) not null, - "claimNonPaymentReasonCode" varchar(2), - "claimPrimaryPayerCode" char(1), - "claimQueryCode" char(1) not null, - "claimServiceClassificationTypeCode" char(1) not null, - "claimTypeCode" varchar(2) not null, - "coinsuranceAmount" numeric(12, 2) not null, - "dateFrom" date not null, - "dateThrough" date not null, - "deductibleAmount" numeric(12, 2) not null, - "diagnosis10Code" varchar(7), - "diagnosis10CodeVersion" char(1), - "diagnosis11Code" varchar(7), - "diagnosis11CodeVersion" char(1), - "diagnosis12Code" varchar(7), - "diagnosis12CodeVersion" char(1), - "diagnosis13Code" varchar(7), - "diagnosis13CodeVersion" char(1), - "diagnosis14Code" varchar(7), - "diagnosis14CodeVersion" char(1), - "diagnosis15Code" varchar(7), - "diagnosis15CodeVersion" char(1), - "diagnosis16Code" varchar(7), - "diagnosis16CodeVersion" char(1), - "diagnosis17Code" varchar(7), - "diagnosis17CodeVersion" char(1), - "diagnosis18Code" varchar(7), - "diagnosis18CodeVersion" char(1), - "diagnosis19Code" varchar(7), - "diagnosis19CodeVersion" char(1), - "diagnosis1Code" varchar(7), - "diagnosis1CodeVersion" char(1), - "diagnosis20Code" varchar(7), - "diagnosis20CodeVersion" char(1), - "diagnosis21Code" varchar(7), - "diagnosis21CodeVersion" char(1), - "diagnosis22Code" varchar(7), - "diagnosis22CodeVersion" char(1), - "diagnosis23Code" varchar(7), - "diagnosis23CodeVersion" char(1), - "diagnosis24Code" varchar(7), - "diagnosis24CodeVersion" char(1), - "diagnosis25Code" varchar(7), - "diagnosis25CodeVersion" char(1), - "diagnosis2Code" varchar(7), - "diagnosis2CodeVersion" char(1), - "diagnosis3Code" varchar(7), - "diagnosis3CodeVersion" char(1), - "diagnosis4Code" varchar(7), - "diagnosis4CodeVersion" char(1), - "diagnosis5Code" varchar(7), - "diagnosis5CodeVersion" char(1), - "diagnosis6Code" varchar(7), - "diagnosis6CodeVersion" char(1), - "diagnosis7Code" varchar(7), - "diagnosis7CodeVersion" char(1), - "diagnosis8Code" varchar(7), - "diagnosis8CodeVersion" char(1), - "diagnosis9Code" varchar(7), - "diagnosis9CodeVersion" char(1), - "diagnosisAdmission1Code" varchar(7), - "diagnosisAdmission1CodeVersion" char(1), - "diagnosisAdmission2Code" varchar(7), - "diagnosisAdmission2CodeVersion" char(1), - "diagnosisAdmission3Code" varchar(7), - "diagnosisAdmission3CodeVersion" char(1), - "diagnosisExternal10Code" varchar(7), - "diagnosisExternal10CodeVersion" char(1), - "diagnosisExternal11Code" varchar(7), - "diagnosisExternal11CodeVersion" char(1), - "diagnosisExternal12Code" varchar(7), - "diagnosisExternal12CodeVersion" char(1), - "diagnosisExternal1Code" varchar(7), - "diagnosisExternal1CodeVersion" char(1), - "diagnosisExternal2Code" varchar(7), - "diagnosisExternal2CodeVersion" char(1), - "diagnosisExternal3Code" varchar(7), - "diagnosisExternal3CodeVersion" char(1), - "diagnosisExternal4Code" varchar(7), - "diagnosisExternal4CodeVersion" char(1), - "diagnosisExternal5Code" varchar(7), - "diagnosisExternal5CodeVersion" char(1), - "diagnosisExternal6Code" varchar(7), - "diagnosisExternal6CodeVersion" char(1), - "diagnosisExternal7Code" varchar(7), - "diagnosisExternal7CodeVersion" char(1), - "diagnosisExternal8Code" varchar(7), - "diagnosisExternal8CodeVersion" char(1), - "diagnosisExternal9Code" varchar(7), - "diagnosisExternal9CodeVersion" char(1), - "diagnosisExternalFirstCode" varchar(7), - "diagnosisExternalFirstCodeVersion" char(1), - "diagnosisPrincipalCode" varchar(7), - "diagnosisPrincipalCodeVersion" char(1), - "fiscalIntermediaryClaimProcessDate" date, - "fiscalIntermediaryNumber" varchar(5), - "mcoPaidSw" char(1), - "nearLineRecordIdCode" char(1) not null, - "operatingPhysicianNpi" varchar(10), - "operatingPhysicianUpin" varchar(9), - "organizationNpi" varchar(10), - "otherPhysicianNpi" varchar(10), - "otherPhysicianUpin" varchar(9), - "patientDischargeStatusCode" varchar(2), - "paymentAmount" numeric(12, 2) not null, - "primaryPayerPaidAmount" numeric(12, 2) not null, - "procedure10Code" varchar(7), - "procedure10CodeVersion" char(1), - "procedure10Date" date, - "procedure11Code" varchar(7), - "procedure11CodeVersion" char(1), - "procedure11Date" date, - "procedure12Code" varchar(7), - "procedure12CodeVersion" char(1), - "procedure12Date" date, - "procedure13Code" varchar(7), - "procedure13CodeVersion" char(1), - "procedure13Date" date, - "procedure14Code" varchar(7), - "procedure14CodeVersion" char(1), - "procedure14Date" date, - "procedure15Code" varchar(7), - "procedure15CodeVersion" char(1), - "procedure15Date" date, - "procedure16Code" varchar(7), - "procedure16CodeVersion" char(1), - "procedure16Date" date, - "procedure17Code" varchar(7), - "procedure17CodeVersion" char(1), - "procedure17Date" date, - "procedure18Code" varchar(7), - "procedure18CodeVersion" char(1), - "procedure18Date" date, - "procedure19Code" varchar(7), - "procedure19CodeVersion" char(1), - "procedure19Date" date, - "procedure1Code" varchar(7), - "procedure1CodeVersion" char(1), - "procedure1Date" date, - "procedure20Code" varchar(7), - "procedure20CodeVersion" char(1), - "procedure20Date" date, - "procedure21Code" varchar(7), - "procedure21CodeVersion" char(1), - "procedure21Date" date, - "procedure22Code" varchar(7), - "procedure22CodeVersion" char(1), - "procedure22Date" date, - "procedure23Code" varchar(7), - "procedure23CodeVersion" char(1), - "procedure23Date" date, - "procedure24Code" varchar(7), - "procedure24CodeVersion" char(1), - "procedure24Date" date, - "procedure25Code" varchar(7), - "procedure25CodeVersion" char(1), - "procedure25Date" date, - "procedure2Code" varchar(7), - "procedure2CodeVersion" char(1), - "procedure2Date" date, - "procedure3Code" varchar(7), - "procedure3CodeVersion" char(1), - "procedure3Date" date, - "procedure4Code" varchar(7), - "procedure4CodeVersion" char(1), - "procedure4Date" date, - "procedure5Code" varchar(7), - "procedure5CodeVersion" char(1), - "procedure5Date" date, - "procedure6Code" varchar(7), - "procedure6CodeVersion" char(1), - "procedure6Date" date, - "procedure7Code" varchar(7), - "procedure7CodeVersion" char(1), - "procedure7Date" date, - "procedure8Code" varchar(7), - "procedure8CodeVersion" char(1), - "procedure8Date" date, - "procedure9Code" varchar(7), - "procedure9CodeVersion" char(1), - "procedure9Date" date, - "professionalComponentCharge" numeric(12, 2) not null, - "providerNumber" varchar(9) not null, - "providerPaymentAmount" numeric(12, 2) not null, - "providerStateCode" varchar(2) not null, - "totalChargeAmount" numeric(12, 2) not null, - "weeklyProcessDate" date not null, - constraint "OutpatientClaims_pkey" primary key ("claimId") -) -${logic.tablespaces-escape} tablespace "outpatientclaims_ts" -; - -create table "PartDEvents" ( - "eventId" varchar(15) not null, - "adjustmentDeletionCode" char(1), - "beneficiaryId" varchar(15) not null, - "brandGenericCode" char(1), - "catastrophicCoverageCode" char(1), - "claimGroupId" numeric(12) not null, - "compoundCode" ${type.int4} not null, - "daysSupply" numeric not null, - "dispenseAsWrittenProductSelectionCode" char(1) not null, - "dispensingStatusCode" char(1), - "drugCoverageStatusCode" char(1) not null, - "fillNumber" numeric not null, - "gapDiscountAmount" numeric(8, 2) not null, - "grossCostAboveOutOfPocketThreshold" numeric(8, 2) not null, - "grossCostBelowOutOfPocketThreshold" numeric(8, 2) not null, - "lowIncomeSubsidyPaidAmount" numeric(8, 2) not null, - "nationalDrugCode" varchar(19) not null, - "nonstandardFormatCode" char(1), - "otherTrueOutOfPocketPaidAmount" numeric(8, 2) not null, - "partDPlanCoveredPaidAmount" numeric(8, 2) not null, - "partDPlanNonCoveredPaidAmount" numeric(8, 2) not null, - "patientLiabilityReductionOtherPaidAmount" numeric(8, 2) not null, - "patientPaidAmount" numeric(8, 2) not null, - "patientResidenceCode" varchar(2) not null, - "paymentDate" date, - "pharmacyTypeCode" varchar(2) not null, - "planBenefitPackageId" varchar(3) not null, - "planContractId" varchar(5) not null, - "prescriberId" varchar(15) not null, - "prescriberIdQualifierCode" varchar(2) not null, - "prescriptionFillDate" date not null, - "prescriptionOriginationCode" char(1), - "prescriptionReferenceNumber" numeric(12) not null, - "pricingExceptionCode" char(1), - "quantityDispensed" numeric(10, 3) not null, - "serviceProviderId" varchar(15) not null, - "serviceProviderIdQualiferCode" varchar(2) not null, - "submissionClarificationCode" varchar(2), - "totalPrescriptionCost" numeric(8, 2) not null, - constraint "PartDEvents_pkey" primary key ("eventId") -) -${logic.tablespaces-escape} tablespace "partdevents_ts" -; - -create table "SNFClaimLines" ( - "lineNumber" numeric not null, - "parentClaim" varchar(255) not null, - "deductibleCoinsuranceCd" char(1), - "hcpcsCode" varchar(5), - "nationalDrugCodeQualifierCode" varchar(2), - "nationalDrugCodeQuantity" numeric, - "nonCoveredChargeAmount" numeric(12, 2) not null, - "rateAmount" numeric(12, 2) not null, - "revenueCenter" varchar(4) not null, - "revenueCenterRenderingPhysicianNPI" varchar(12), - "revenueCenterRenderingPhysicianUPIN" varchar(12), - "totalChargeAmount" numeric(12, 2) not null, - "unitCount" ${type.int4} not null, - constraint "SNFClaimLines_pkey" primary key ("lineNumber", "parentClaim") -) -${logic.tablespaces-escape} tablespace "snfclaimlines_ts" -; - -create table "SNFClaims" ( - "claimId" varchar(15) not null, - "admissionTypeCd" char(1) not null, - "attendingPhysicianNpi" varchar(10), - "attendingPhysicianUpin" varchar(9), - "beneficiaryDischargeDate" date, - "beneficiaryId" varchar(15) not null, - "bloodDeductibleLiabilityAmount" numeric(12, 2) not null, - "bloodPintsFurnishedQty" numeric not null, - "claimAdmissionDate" date, - "claimFacilityTypeCode" char(1) not null, - "claimFrequencyCode" char(1) not null, - "claimGroupId" numeric(12) not null, - "claimNonPaymentReasonCode" varchar(2), - "claimPPSCapitalDisproportionateShareAmt" numeric(12, 2), - "claimPPSCapitalExceptionAmount" numeric(12, 2), - "claimPPSCapitalFSPAmount" numeric(12, 2), - "claimPPSCapitalIMEAmount" numeric(12, 2), - "claimPPSCapitalOutlierAmount" numeric(12, 2), - "claimPPSOldCapitalHoldHarmlessAmount" numeric(12, 2), - "claimPrimaryPayerCode" char(1), - "claimQueryCode" char(1) not null, - "claimServiceClassificationTypeCode" char(1) not null, - "claimTypeCode" varchar(2) not null, - "coinsuranceDayCount" numeric not null, - "coveredCareThroughDate" date, - "dateFrom" date not null, - "dateThrough" date not null, - "deductibleAmount" numeric(12, 2) not null, - "diagnosis10Code" varchar(7), - "diagnosis10CodeVersion" char(1), - "diagnosis11Code" varchar(7), - "diagnosis11CodeVersion" char(1), - "diagnosis12Code" varchar(7), - "diagnosis12CodeVersion" char(1), - "diagnosis13Code" varchar(7), - "diagnosis13CodeVersion" char(1), - "diagnosis14Code" varchar(7), - "diagnosis14CodeVersion" char(1), - "diagnosis15Code" varchar(7), - "diagnosis15CodeVersion" char(1), - "diagnosis16Code" varchar(7), - "diagnosis16CodeVersion" char(1), - "diagnosis17Code" varchar(7), - "diagnosis17CodeVersion" char(1), - "diagnosis18Code" varchar(7), - "diagnosis18CodeVersion" char(1), - "diagnosis19Code" varchar(7), - "diagnosis19CodeVersion" char(1), - "diagnosis1Code" varchar(7), - "diagnosis1CodeVersion" char(1), - "diagnosis20Code" varchar(7), - "diagnosis20CodeVersion" char(1), - "diagnosis21Code" varchar(7), - "diagnosis21CodeVersion" char(1), - "diagnosis22Code" varchar(7), - "diagnosis22CodeVersion" char(1), - "diagnosis23Code" varchar(7), - "diagnosis23CodeVersion" char(1), - "diagnosis24Code" varchar(7), - "diagnosis24CodeVersion" char(1), - "diagnosis25Code" varchar(7), - "diagnosis25CodeVersion" char(1), - "diagnosis2Code" varchar(7), - "diagnosis2CodeVersion" char(1), - "diagnosis3Code" varchar(7), - "diagnosis3CodeVersion" char(1), - "diagnosis4Code" varchar(7), - "diagnosis4CodeVersion" char(1), - "diagnosis5Code" varchar(7), - "diagnosis5CodeVersion" char(1), - "diagnosis6Code" varchar(7), - "diagnosis6CodeVersion" char(1), - "diagnosis7Code" varchar(7), - "diagnosis7CodeVersion" char(1), - "diagnosis8Code" varchar(7), - "diagnosis8CodeVersion" char(1), - "diagnosis9Code" varchar(7), - "diagnosis9CodeVersion" char(1), - "diagnosisAdmittingCode" varchar(7), - "diagnosisAdmittingCodeVersion" char(1), - "diagnosisExternal10Code" varchar(7), - "diagnosisExternal10CodeVersion" char(1), - "diagnosisExternal11Code" varchar(7), - "diagnosisExternal11CodeVersion" char(1), - "diagnosisExternal12Code" varchar(7), - "diagnosisExternal12CodeVersion" char(1), - "diagnosisExternal1Code" varchar(7), - "diagnosisExternal1CodeVersion" char(1), - "diagnosisExternal2Code" varchar(7), - "diagnosisExternal2CodeVersion" char(1), - "diagnosisExternal3Code" varchar(7), - "diagnosisExternal3CodeVersion" char(1), - "diagnosisExternal4Code" varchar(7), - "diagnosisExternal4CodeVersion" char(1), - "diagnosisExternal5Code" varchar(7), - "diagnosisExternal5CodeVersion" char(1), - "diagnosisExternal6Code" varchar(7), - "diagnosisExternal6CodeVersion" char(1), - "diagnosisExternal7Code" varchar(7), - "diagnosisExternal7CodeVersion" char(1), - "diagnosisExternal8Code" varchar(7), - "diagnosisExternal8CodeVersion" char(1), - "diagnosisExternal9Code" varchar(7), - "diagnosisExternal9CodeVersion" char(1), - "diagnosisExternalFirstCode" varchar(7), - "diagnosisExternalFirstCodeVersion" char(1), - "diagnosisPrincipalCode" varchar(7), - "diagnosisPrincipalCodeVersion" char(1), - "diagnosisRelatedGroupCd" varchar(3), - "fiscalIntermediaryClaimActionCode" char(1), - "fiscalIntermediaryClaimProcessDate" date, - "fiscalIntermediaryNumber" varchar(5), - "mcoPaidSw" char(1), - "medicareBenefitsExhaustedDate" date, - "nearLineRecordIdCode" char(1) not null, - "nonUtilizationDayCount" numeric not null, - "noncoveredCharge" numeric(12, 2) not null, - "noncoveredStayFromDate" date, - "noncoveredStayThroughDate" date, - "operatingPhysicianNpi" varchar(10), - "operatingPhysicianUpin" varchar(9), - "organizationNpi" varchar(10), - "otherPhysicianNpi" varchar(10), - "otherPhysicianUpin" varchar(9), - "partACoinsuranceLiabilityAmount" numeric(12, 2) not null, - "patientDischargeStatusCode" varchar(2) not null, - "patientStatusCd" char(1), - "paymentAmount" numeric(12, 2) not null, - "primaryPayerPaidAmount" numeric(12, 2) not null, - "procedure10Code" varchar(7), - "procedure10CodeVersion" char(1), - "procedure10Date" date, - "procedure11Code" varchar(7), - "procedure11CodeVersion" char(1), - "procedure11Date" date, - "procedure12Code" varchar(7), - "procedure12CodeVersion" char(1), - "procedure12Date" date, - "procedure13Code" varchar(7), - "procedure13CodeVersion" char(1), - "procedure13Date" date, - "procedure14Code" varchar(7), - "procedure14CodeVersion" char(1), - "procedure14Date" date, - "procedure15Code" varchar(7), - "procedure15CodeVersion" char(1), - "procedure15Date" date, - "procedure16Code" varchar(7), - "procedure16CodeVersion" char(1), - "procedure16Date" date, - "procedure17Code" varchar(7), - "procedure17CodeVersion" char(1), - "procedure17Date" date, - "procedure18Code" varchar(7), - "procedure18CodeVersion" char(1), - "procedure18Date" date, - "procedure19Code" varchar(7), - "procedure19CodeVersion" char(1), - "procedure19Date" date, - "procedure1Code" varchar(7), - "procedure1CodeVersion" char(1), - "procedure1Date" date, - "procedure20Code" varchar(7), - "procedure20CodeVersion" char(1), - "procedure20Date" date, - "procedure21Code" varchar(7), - "procedure21CodeVersion" char(1), - "procedure21Date" date, - "procedure22Code" varchar(7), - "procedure22CodeVersion" char(1), - "procedure22Date" date, - "procedure23Code" varchar(7), - "procedure23CodeVersion" char(1), - "procedure23Date" date, - "procedure24Code" varchar(7), - "procedure24CodeVersion" char(1), - "procedure24Date" date, - "procedure25Code" varchar(7), - "procedure25CodeVersion" char(1), - "procedure25Date" date, - "procedure2Code" varchar(7), - "procedure2CodeVersion" char(1), - "procedure2Date" date, - "procedure3Code" varchar(7), - "procedure3CodeVersion" char(1), - "procedure3Date" date, - "procedure4Code" varchar(7), - "procedure4CodeVersion" char(1), - "procedure4Date" date, - "procedure5Code" varchar(7), - "procedure5CodeVersion" char(1), - "procedure5Date" date, - "procedure6Code" varchar(7), - "procedure6CodeVersion" char(1), - "procedure6Date" date, - "procedure7Code" varchar(7), - "procedure7CodeVersion" char(1), - "procedure7Date" date, - "procedure8Code" varchar(7), - "procedure8CodeVersion" char(1), - "procedure8Date" date, - "procedure9Code" varchar(7), - "procedure9CodeVersion" char(1), - "procedure9Date" date, - "prospectivePaymentCode" char(1), - "providerNumber" varchar(9) not null, - "providerStateCode" varchar(2) not null, - "qualifiedStayFromDate" date, - "qualifiedStayThroughDate" date, - "sourceAdmissionCd" char(1), - "totalChargeAmount" numeric(12, 2) not null, - "totalDeductionAmount" numeric(12, 2) not null, - "utilizationDayCount" numeric not null, - "weeklyProcessDate" date not null, - constraint "SNFClaims_pkey" primary key ("claimId") -) -${logic.tablespaces-escape} tablespace "snfclaims_ts" -; - -alter table "CarrierClaimLines" - add constraint "CarrierClaimLines_parentClaim_to_CarrierClaims" - foreign key ("parentClaim") - references "CarrierClaims"; - -alter table "DMEClaimLines" - add constraint "DMEClaimLines_parentClaim_to_DMEClaims" - foreign key ("parentClaim") - references "DMEClaims"; - -alter table "HHAClaimLines" - add constraint "HHAClaimLines_parentClaim_to_HHAClaims" - foreign key ("parentClaim") - references "HHAClaims"; - -alter table "HospiceClaimLines" - add constraint "HospiceClaimLines_parentClaim_to_HospiceClaims" - foreign key ("parentClaim") - references "HospiceClaims"; - -alter table "InpatientClaimLines" - add constraint "InpatientClaimLines_parentClaim_to_InpatientClaims" - foreign key ("parentClaim") - references "InpatientClaims"; - -alter table "OutpatientClaimLines" - add constraint "OutpatientClaimLines_parentClaim_to_OutpatientClaims" - foreign key ("parentClaim") - references "OutpatientClaims"; - -alter table "SNFClaimLines" - add constraint "SNFClaimLines_parentClaim_to_SNFClaims" - foreign key ("parentClaim") - references "SNFClaims"; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V20__Add_BeneficiaryHistory_beneId_index.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V20__Add_BeneficiaryHistory_beneId_index.sql deleted file mode 100644 index 2516455933..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V20__Add_BeneficiaryHistory_beneId_index.sql +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Adds an index to the BeneficiariesHistory table to support queries against - * the beneficiaryId column. - * - * See: https://jira.cms.gov/browse/BLUEBUTTON-1110 - */ - -create index ${logic.index-create-concurrently} "BeneficiariesHistory_beneficiaryId_idx" - on "BeneficiariesHistory" ("beneficiaryId"); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V21__Add_MBI_hash.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V21__Add_MBI_hash.sql deleted file mode 100644 index 3d2e5218ee..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V21__Add_MBI_hash.sql +++ /dev/null @@ -1,9 +0,0 @@ -/* - * The column doesn't have a default value to avoid updating the column on migration. The pipeline server - * will populate the column as new beneficaries are added or existing beneficaries are updated. - */ - -alter table "Beneficiaries" add column "mbiHash" varchar(64); - -alter table "BeneficiariesHistory" add column "mbiHash" varchar(64); - diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V22__Add_MBI_hash_index.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V22__Add_MBI_hash_index.sql deleted file mode 100644 index f9e49ed778..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V22__Add_MBI_hash_index.sql +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Add a MedicareBeneficiaryIdentifier (MBI) hash column for mbi searches. - * The search is used by partners to cross-walk to the beneficiaryId. - * Since this is a frequent operation, the hash is indexed. - */ - -create index ${logic.index-create-concurrently} "Beneficiaries_mbi_hash_idx" - on "Beneficiaries" ("mbiHash"); - -create index ${logic.index-create-concurrently} "Beneficiaries_history_mbi_hash_idx" - on "BeneficiariesHistory" ("mbiHash"); - diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V23__Add_lastUpdated.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V23__Add_lastUpdated.sql deleted file mode 100644 index ba9b06961c..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V23__Add_lastUpdated.sql +++ /dev/null @@ -1,74 +0,0 @@ --- Add a column without writing a data to every row --- --- From the PostgreSQL 9.6 ALTER command documentation... --- --- When a column is added with ADD COLUMN, all existing rows in the table are initialized with the --- column's default value (NULL if no DEFAULT clause is specified). If there is no DEFAULT clause, this is merely a --- metadata change and does not require any immediate update of the table's data; the added NULL values are supplied --- on readout, instead. --- --- Based on this information, alters have the implicit default null --- - -alter table "Beneficiaries" add column lastUpdated timestamp with time zone; - -alter table "BeneficiariesHistory" add column lastUpdated timestamp with time zone; - -alter table "MedicareBeneficiaryIdHistory" add column lastUpdated timestamp with time zone; - -alter table "PartDEvents" add column lastUpdated timestamp with time zone; - -alter table "CarrierClaims" add column lastUpdated timestamp with time zone; - -alter table "InpatientClaims" add column lastUpdated timestamp with time zone; - -alter table "OutpatientClaims" add column lastUpdated timestamp with time zone; - -alter table "HHAClaims" add column lastUpdated timestamp with time zone; - -alter table "DMEClaims" add column lastUpdated timestamp with time zone; - -alter table "HospiceClaims" add column lastUpdated timestamp with time zone; - -alter table "SNFClaims" add column lastUpdated timestamp with time zone; - --- --- Add tables that tracks the ETL process --- --- One row for each RIF file loaded. --- The timestamp represents the start time of the RIF file processing --- -create table "LoadedFiles" ( - "loadedFileId" bigint primary key, - "rifType" varchar(48) not null, - "created" timestamp with time zone not null -) -${logic.tablespaces-escape} tablespace "loadedfiles_ts" -; - -create sequence loadedFiles_loadedFileId_seq ${logic.sequence-start} 1 ${logic.sequence-increment} 1 cycle; - --- One row for each batch of beneficiaries loaded. Indexed on loadedFileId. --- --- Dev Note: --- Many ways of storing beneIds where tried and considered. Since RIF records are written in --- batches, creating a record that represents that batch was considered to be efficient enough. --- More importantly since RIF record batches are put inside a transaction, the LoadedBatches --- table will always be consistent with the loaded RIF records. Beneficiaries is not an array --- because Hibernate doesn't work well with that type. --- -create table "LoadedBatches" ( - "loadedBatchId" bigint primary key, - "loadedFileId" bigint not null, - "beneficiaries" varchar(20000) not null, - "created" timestamp with time zone not null -) -${logic.tablespaces-escape} tablespace "loadedbatches_ts" -; - -alter table "LoadedBatches" - add constraint "loadedBatches_loadedFileId" - foreign key ("loadedFileId") - references "LoadedFiles"; - -create sequence loadedBatches_loadedBatchId_seq ${logic.sequence-start} 1 ${logic.sequence-increment} 20 cycle; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V24__Add_Loaded_index.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V24__Add_Loaded_index.sql deleted file mode 100644 index 8a35f6a36d..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V24__Add_Loaded_index.sql +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Add an index on the created timestamp of LoadedBatches table which is a frequently searched column. - * The index creation is done in a separate migration to avoid mixed - * transactional and non-transactional statements in migrations - */ - -create index ${logic.index-create-concurrently} "LoadedBatches_created_index" - on "LoadedBatches" ("created"); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V25__Add_partd_contract_number_index.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V25__Add_partd_contract_number_index.sql deleted file mode 100644 index 4af29b5c12..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V25__Add_partd_contract_number_index.sql +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Create an index for each of the Part D Contract Number fields (jan - dec). - * This makes finding a patient by a specific contract number tenable. - * - * More context can be found in BLUEBUTTON-1841 and related ticktes. - */ - -create index ${logic.index-create-concurrently} "Beneficiaries_partd_contract_number_jan_id_idx" - on "Beneficiaries" ("partDContractNumberJanId"); - -create index ${logic.index-create-concurrently} "Beneficiaries_partd_contract_number_feb_id_idx" - on "Beneficiaries" ("partDContractNumberFebId"); - -create index ${logic.index-create-concurrently} "Beneficiaries_partd_contract_number_mar_id_idx" - on "Beneficiaries" ("partDContractNumberMarId"); - -create index ${logic.index-create-concurrently} "Beneficiaries_partd_contract_number_apr_id_idx" - on "Beneficiaries" ("partDContractNumberAprId"); - -create index ${logic.index-create-concurrently} "Beneficiaries_partd_contract_number_may_id_idx" - on "Beneficiaries" ("partDContractNumberMayId"); - -create index ${logic.index-create-concurrently} "Beneficiaries_partd_contract_number_jun_id_idx" - on "Beneficiaries" ("partDContractNumberJunId"); - -create index ${logic.index-create-concurrently} "Beneficiaries_partd_contract_number_jul_id_idx" - on "Beneficiaries" ("partDContractNumberJulId"); - -create index ${logic.index-create-concurrently} "Beneficiaries_partd_contract_number_aug_id_idx" - on "Beneficiaries" ("partDContractNumberAugId"); - -create index ${logic.index-create-concurrently} "Beneficiaries_partd_contract_number_sept_id_idx" - on "Beneficiaries" ("partDContractNumberSeptId"); - -create index ${logic.index-create-concurrently} "Beneficiaries_partd_contract_number_oct_id_idx" - on "Beneficiaries" ("partDContractNumberOctId"); - -create index ${logic.index-create-concurrently} "Beneficiaries_partd_contract_number_nov_id_idx" - on "Beneficiaries" ("partDContractNumberNovId"); - -create index ${logic.index-create-concurrently} "Beneficiaries_partd_contract_number_dec_id_idx" - on "Beneficiaries" ("partDContractNumberDecId"); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V26__Add_fields_to_BeneficiariesInpatient.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V26__Add_fields_to_BeneficiariesInpatient.sql deleted file mode 100644 index 3d40496a15..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V26__Add_fields_to_BeneficiariesInpatient.sql +++ /dev/null @@ -1,41 +0,0 @@ -/* - * The column doesn't have a default value to avoid updating the column on migration. The pipeline server - * will populate the column as new beneficaries are added or existing beneficaries are updated. - */ - -alter table "Beneficiaries" add column "derivedMailingAddress1" varchar(40); -alter table "Beneficiaries" add column "derivedMailingAddress2" varchar(40); -alter table "Beneficiaries" add column "derivedMailingAddress3" varchar(40); -alter table "Beneficiaries" add column "derivedMailingAddress4" varchar(40); -alter table "Beneficiaries" add column "derivedMailingAddress5" varchar(40); -alter table "Beneficiaries" add column "derivedMailingAddress6" varchar(40); -alter table "Beneficiaries" add column "derivedCityName" varchar(100); -alter table "Beneficiaries" add column "derivedStateCode" varchar(2); -alter table "Beneficiaries" add column "derivedZipCode" varchar(9); -alter table "Beneficiaries" add column "mbiEffectiveDate" date; -alter table "Beneficiaries" add column "mbiObsoleteDate" date; -alter table "Beneficiaries" add column "beneLinkKey" numeric(38); - -alter table "BeneficiariesHistory" add column "mbiEffectiveDate" date; -alter table "BeneficiariesHistory" add column "mbiObsoleteDate" date; - -alter table "InpatientClaims" add column "claimUncompensatedCareAmount" numeric(38, 2); - -alter table "CarrierClaims" add column "claimCarrierControlNumber" varchar(23); - -alter table "DMEClaims" add column "claimCarrierControlNumber" varchar(23); - -alter table "HHAClaims" add column "fiDocumentClaimControlNumber" varchar(23); -alter table "HHAClaims" add column "fiOriginalClaimControlNumber" varchar(23); - -alter table "HospiceClaims" add column "fiDocumentClaimControlNumber" varchar(23); -alter table "HospiceClaims" add column "fiOriginalClaimControlNumber" varchar(23); - -alter table "InpatientClaims" add column "fiDocumentClaimControlNumber" varchar(23); -alter table "InpatientClaims" add column "fiOriginalClaimControlNumber" varchar(23); - -alter table "OutpatientClaims" add column "fiDocumentClaimControlNumber" varchar(23); -alter table "OutpatientClaims" add column "fiOriginalClaimControlNumber" varchar(23); - -alter table "SNFClaims" add column "fiDocumentClaimControlNumber" varchar(23); -alter table "SNFClaims" add column "fiOriginalClaimControlNumber" varchar(23); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V27__Create_BeneficiaryMonthlytable.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V27__Create_BeneficiaryMonthlytable.sql deleted file mode 100644 index 906a6ab827..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V27__Create_BeneficiaryMonthlytable.sql +++ /dev/null @@ -1,144 +0,0 @@ -/* - * The pipeline server will populate the table as new beneficaries are added or existing beneficaries are updated. - */ - -${logic.tablespaces-escape} SET default_tablespace = fhirdb_ts2; - -create table "BeneficiaryMonthly" ( - "parentBeneficiary" varchar(255) not null, - "yearMonth" date not null, - "fipsStateCntyCode" varchar(5), - "medicareStatusCode" varchar(2), - "entitlementBuyInInd" char(1), - "hmoIndicatorInd" char(1), - "partCContractNumberId" varchar(5), - "partCPbpNumberId" varchar(3), - "partCPlanTypeCode" varchar(3), - "partDContractNumberId" varchar(5), - "partDPbpNumberId" varchar(3), - "partDSegmentNumberId" varchar(3), - "partDRetireeDrugSubsidyInd" char(1), - "medicaidDualEligibilityCode" varchar(2), - "partDLowIncomeCostShareGroupCode" varchar(2), - constraint "BeneficiaryMonthly_pkey" primary key ("parentBeneficiary", "yearMonth") -) -${logic.tablespaces-escape} tablespace "beneficiarymonthly_ts" -; - -/* - * Per the CCW folks, the beneEnrollmentReferenceYear column is null for newer bene records that - * haven't received data from all sources yet. There are over a million such records, which is a bit concerning, - * but that will be addressed in a separate ticket, if needed. - */ -INSERT INTO "BeneficiaryMonthly" - SELECT "beneficiaryId", TO_DATE(CONCAT("beneEnrollmentReferenceYear", '/01/01'), 'YYYY/MM/DD') as "yearMonth", "fipsStateCntyJanCode", - "medicareStatusJanCode", "entitlementBuyInJanInd", "hmoIndicatorJanInd", - "partCContractNumberJanId", "partCPbpNumberJanId", "partCPlanTypeJanCode", - "partDContractNumberJanId", "partDPbpNumberJanId", "partDSegmentNumberJanId", - "partDRetireeDrugSubsidyJanInd", "medicaidDualEligibilityJanCode", "partDLowIncomeCostShareGroupJanCode" - FROM "Beneficiaries" - WHERE "beneEnrollmentReferenceYear" is not null; - -INSERT INTO "BeneficiaryMonthly" - SELECT "beneficiaryId", TO_DATE(CONCAT("beneEnrollmentReferenceYear", '/02/01'), 'YYYY/MM/DD') as "yearMonth", "fipsStateCntyFebCode", - "medicareStatusFebCode", "entitlementBuyInFebInd", "hmoIndicatorFebInd", - "partCContractNumberFebId", "partCPbpNumberFebId", "partCPlanTypeFebCode", - "partDContractNumberFebId", "partDPbpNumberFebId", "partDSegmentNumberFebId", - "partDRetireeDrugSubsidyFebInd", "medicaidDualEligibilityFebCode", "partDLowIncomeCostShareGroupFebCode" - FROM "Beneficiaries" - WHERE "beneEnrollmentReferenceYear" is not null; - -INSERT INTO "BeneficiaryMonthly" - SELECT "beneficiaryId", TO_DATE(CONCAT("beneEnrollmentReferenceYear", '/03/01'), 'YYYY/MM/DD') as "yearMonth", "fipsStateCntyMarCode", - "medicareStatusMarCode", "entitlementBuyInMarInd", "hmoIndicatorMarInd", - "partCContractNumberMarId", "partCPbpNumberMarId", "partCPlanTypeMarCode", - "partDContractNumberMarId", "partDPbpNumberMarId", "partDSegmentNumberMarId", - "partDRetireeDrugSubsidyMarInd", "medicaidDualEligibilityMarCode", "partDLowIncomeCostShareGroupMarCode" - FROM "Beneficiaries" - WHERE "beneEnrollmentReferenceYear" is not null; - -INSERT INTO "BeneficiaryMonthly" - SELECT "beneficiaryId", TO_DATE(CONCAT("beneEnrollmentReferenceYear", '/04/01'), 'YYYY/MM/DD') as "yearMonth", "fipsStateCntyAprCode", - "medicareStatusAprCode", "entitlementBuyInAprInd", "hmoIndicatorAprInd", - "partCContractNumberAprId", "partCPbpNumberAprId", "partCPlanTypeAprCode", - "partDContractNumberAprId", "partDPbpNumberAprId", "partDSegmentNumberAprId", - "partDRetireeDrugSubsidyAprInd", "medicaidDualEligibilityAprCode", "partDLowIncomeCostShareGroupAprCode" - FROM "Beneficiaries" - WHERE "beneEnrollmentReferenceYear" is not null; - -INSERT INTO "BeneficiaryMonthly" - SELECT "beneficiaryId", TO_DATE(CONCAT("beneEnrollmentReferenceYear", '/05/01'), 'YYYY/MM/DD') as "yearMonth", "fipsStateCntyMayCode", - "medicareStatusMayCode", "entitlementBuyInMayInd", "hmoIndicatorMayInd", - "partCContractNumberMayId", "partCPbpNumberMayId", "partCPlanTypeMayCode", - "partDContractNumberMayId", "partDPbpNumberMayId", "partDSegmentNumberMayId", - "partDRetireeDrugSubsidyMayInd", "medicaidDualEligibilityMayCode", "partDLowIncomeCostShareGroupMayCode" - FROM "Beneficiaries" - WHERE "beneEnrollmentReferenceYear" is not null; - -INSERT INTO "BeneficiaryMonthly" - SELECT "beneficiaryId", TO_DATE(CONCAT("beneEnrollmentReferenceYear", '/06/01'), 'YYYY/MM/DD') as "yearMonth", "fipsStateCntyJunCode", - "medicareStatusJunCode", "entitlementBuyInJunInd", "hmoIndicatorJunInd", - "partCContractNumberJunId", "partCPbpNumberJunId", "partCPlanTypeJunCode", - "partDContractNumberJunId", "partDPbpNumberJunId", "partDSegmentNumberJunId", - "partDRetireeDrugSubsidyJunInd", "medicaidDualEligibilityJunCode", "partDLowIncomeCostShareGroupJunCode" - FROM "Beneficiaries" - WHERE "beneEnrollmentReferenceYear" is not null; - -INSERT INTO "BeneficiaryMonthly" - SELECT "beneficiaryId", TO_DATE(CONCAT("beneEnrollmentReferenceYear", '/07/01'), 'YYYY/MM/DD')as "yearMonth", "fipsStateCntyJulCode", - "medicareStatusJulCode", "entitlementBuyInJulInd", "hmoIndicatorJulInd", - "partCContractNumberJulId", "partCPbpNumberJulId", "partCPlanTypeJulCode", - "partDContractNumberJulId", "partDPbpNumberJulId", "partDSegmentNumberJulId", - "partDRetireeDrugSubsidyJulInd", "medicaidDualEligibilityJulCode", "partDLowIncomeCostShareGroupJulCode" - FROM "Beneficiaries" - WHERE "beneEnrollmentReferenceYear" is not null; - -INSERT INTO "BeneficiaryMonthly" - SELECT "beneficiaryId", TO_DATE(CONCAT("beneEnrollmentReferenceYear", '/08/01'), 'YYYY/MM/DD') as "yearMonth", "fipsStateCntyAugCode", - "medicareStatusAugCode", "entitlementBuyInAugInd", "hmoIndicatorAugInd", - "partCContractNumberAugId", "partCPbpNumberAugId", "partCPlanTypeAugCode", - "partDContractNumberAugId", "partDPbpNumberAugId", "partDSegmentNumberAugId", - "partDRetireeDrugSubsidyAugInd", "medicaidDualEligibilityAugCode", "partDLowIncomeCostShareGroupAugCode" - FROM "Beneficiaries" - WHERE "beneEnrollmentReferenceYear" is not null; - -INSERT INTO "BeneficiaryMonthly" - SELECT "beneficiaryId", TO_DATE(CONCAT("beneEnrollmentReferenceYear", '/09/01'), 'YYYY/MM/DD') as "yearMonth", "fipsStateCntySeptCode", - "medicareStatusSeptCode", "entitlementBuyInSeptInd", "hmoIndicatorSeptInd", - "partCContractNumberSeptId", "partCPbpNumberSeptId", "partCPlanTypeSeptCode", - "partDContractNumberSeptId", "partDPbpNumberSeptId", "partDSegmentNumberSeptId", - "partDRetireeDrugSubsidySeptInd", "medicaidDualEligibilitySeptCode", "partDLowIncomeCostShareGroupSeptCode" - FROM "Beneficiaries" - WHERE "beneEnrollmentReferenceYear" is not null; - -INSERT INTO "BeneficiaryMonthly" - SELECT "beneficiaryId", TO_DATE(CONCAT("beneEnrollmentReferenceYear", '/10/01'), 'YYYY/MM/DD') as "yearMonth", "fipsStateCntyOctCode", - "medicareStatusOctCode", "entitlementBuyInOctInd", "hmoIndicatorOctInd", - "partCContractNumberOctId", "partCPbpNumberOctId", "partCPlanTypeOctCode", - "partDContractNumberOctId", "partDPbpNumberOctId", "partDSegmentNumberOctId", - "partDRetireeDrugSubsidyOctInd", "medicaidDualEligibilityOctCode", "partDLowIncomeCostShareGroupOctCode" - FROM "Beneficiaries" - WHERE "beneEnrollmentReferenceYear" is not null; - -INSERT INTO "BeneficiaryMonthly" - SELECT "beneficiaryId", TO_DATE(CONCAT("beneEnrollmentReferenceYear", '/11/01'), 'YYYY/MM/DD') as "yearMonth", "fipsStateCntyNovCode", - "medicareStatusNovCode", "entitlementBuyInNovInd", "hmoIndicatorNovInd", - "partCContractNumberNovId", "partCPbpNumberNovId", "partCPlanTypeNovCode", - "partDContractNumberNovId", "partDPbpNumberNovId", "partDSegmentNumberNovId", - "partDRetireeDrugSubsidyNovInd", "medicaidDualEligibilityNovCode", "partDLowIncomeCostShareGroupNovCode" - FROM "Beneficiaries" - WHERE "beneEnrollmentReferenceYear" is not null; - -INSERT INTO "BeneficiaryMonthly" - SELECT "beneficiaryId", TO_DATE(CONCAT("beneEnrollmentReferenceYear", '/12/01'), 'YYYY/MM/DD') as "yearMonth", "fipsStateCntyDecCode", - "medicareStatusDecCode", "entitlementBuyInDecInd", "hmoIndicatorDecInd", - "partCContractNumberDecId", "partCPbpNumberDecId", "partCPlanTypeDecCode", - "partDContractNumberDecId", "partDPbpNumberDecId", "partDSegmentNumberDecId", - "partDRetireeDrugSubsidyDecInd", "medicaidDualEligibilityDecCode", "partDLowIncomeCostShareGroupDecCode" - FROM "Beneficiaries" - WHERE "beneEnrollmentReferenceYear" is not null; - -alter table "BeneficiaryMonthly" - add constraint "BeneficiaryMonthly_parentBeneficiary_to_Beneficiary" foreign key ("parentBeneficiary") - references "Beneficiaries"; - diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V28__Create_BeneficiaryMonthlytable_Index.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V28__Create_BeneficiaryMonthlytable_Index.sql deleted file mode 100644 index f9b856416a..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V28__Create_BeneficiaryMonthlytable_Index.sql +++ /dev/null @@ -1,4 +0,0 @@ --- Create index for BeneficiaryMonthly for column indexes yearMonth and partDContractNumberId. - -CREATE INDEX "BeneficiaryMonthly_yearmonth_partDContractNumberId_idx" -ON "BeneficiaryMonthly" ("yearMonth", "partDContractNumberId"); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V29__Drop_And_Create_BeneficiaryMonthlytable_Index.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V29__Drop_And_Create_BeneficiaryMonthlytable_Index.sql deleted file mode 100644 index a9f4591482..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V29__Drop_And_Create_BeneficiaryMonthlytable_Index.sql +++ /dev/null @@ -1,7 +0,0 @@ --- Create index for BeneficiaryMonthly for column indexes yearMonth and partDContractNumberId. - - -DROP INDEX "BeneficiaryMonthly_yearmonth_partDContractNumberId_idx"; - -CREATE INDEX "BeneficiaryMonthly_partDContractNumberId_yearmonth_idx" -ON "BeneficiaryMonthly" ("partDContractNumberId", "yearMonth"); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V2__CBBD-288_Alter_CarrierClaimLines.hctHgbTestResult.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V2__CBBD-288_Alter_CarrierClaimLines.hctHgbTestResult.sql deleted file mode 100644 index 653c4cdf37..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V2__CBBD-288_Alter_CarrierClaimLines.hctHgbTestResult.sql +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Resolves http://issues.hhsdevcloud.us/browse/CBBD-288, correcting the - * precision and scale of the `CarrierClaimLines.hctHgbTestResult` column. - */ - -alter table "CarrierClaimLines" - alter column "hctHgbTestResult" ${logic.alter-column-type} numeric(4,1); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V30__Create_preadjudicated_claims_tables.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V30__Create_preadjudicated_claims_tables.sql deleted file mode 100644 index fb780bc5e2..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V30__Create_preadjudicated_claims_tables.sql +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Creates the RDA FISS pre-adjudicated claims tables required by the application. - * https://confluenceent.cms.gov/pages/viewpage.action?spaceKey=MPSM&title=MVP+0.1+Data+Dictionary+for+Replicated+Data+Access+API - */ - -CREATE SCHEMA IF NOT EXISTS "pre_adj"; - -/* - * Where possible column names map directly to fields in the RDA API result message. - */ -create table "pre_adj"."FissClaims" -( - "dcn" varchar(23) not null, - "hicNo" varchar(12) not null, - "currStatus" char(1) not null, - "currLoc1" char(1) not null, - "currLoc2" varchar(5) not null, - "medaProvId" varchar(13), - "totalChargeAmount" decimal(11, 2), - "receivedDate" date, - "currTranDate" date, - "admitDiagCode" varchar(7), - "principleDiag" varchar(7), - "npiNumber" varchar(10), - "mbi" varchar(13), - "mbiHash" varchar(64), - "fedTaxNumber" varchar(10), - "lastUpdated" timestamp with time zone, - constraint "FissClaims_pkey" primary key ("dcn") -); - -/* - * Index the MedicareBeneficiaryIdentifier (MBI) hash column for mbi searches. - * The search is used by partners to find claims for specific beneficiaries. - * Since this is a frequent operation, the hash is indexed. - */ - -create index "FissClaims_mbi_hash_idx" - on "pre_adj"."FissClaims" ("mbiHash"); - -/* - * Where possible column names map directly to fields in the RDA API result message. - * - * The priority column is a 0 based index indicating the order in which the codes - * appear in the RDA API result message for the claim. - */ -create table "pre_adj"."FissProcCodes" -( - "dcn" varchar(23) not null, - "priority" smallint not null, - "procCode" varchar(10) not null, - "procFlag" varchar(4), - "procDate" date, - "lastUpdated" timestamp with time zone, - constraint "FissProcCodes_pkey" primary key ("dcn", "priority"), - constraint "FissProcCodes_claim" foreign key ("dcn") references "pre_adj"."FissClaims" ("dcn") -); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V31__preadj_claim_table_updates.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V31__preadj_claim_table_updates.sql deleted file mode 100644 index 54def34c4f..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V31__preadj_claim_table_updates.sql +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Creates RDA MCS pre-adjudicated claims tables required by the application. - * https://confluenceent.cms.gov/display/MPSM/2021-04-22+Tech+Spec%3A+Specific+Schema+for+MVP+v0.2 - * - * Where possible column names map directly to fields in the RDA API result message. - */ - -/* - * Add new FISS claim fields from RDA API MVP 0.2 release. - */ -alter table "pre_adj"."FissClaims" - add "pracLocAddr1" ${type.text}; -alter table "pre_adj"."FissClaims" - add "pracLocAddr2" ${type.text}; -alter table "pre_adj"."FissClaims" - add "pracLocCity" ${type.text}; -alter table "pre_adj"."FissClaims" - add "pracLocState" varchar(2); -alter table "pre_adj"."FissClaims" - add "pracLocZip" varchar(15); -alter table "pre_adj"."FissClaims" - add "medaProv_6" varchar(6); -alter table "pre_adj"."FissClaims" - add "stmtCovFromDate" date; -alter table "pre_adj"."FissClaims" - add "stmtCovToDate" date; - -/* - * Add new FISS Claim diagnosis code table from RDA API 0.2 release. - * The priority column is used to sort the detail records and is populated using array index in RDA - * API response array. - */ - -create table "pre_adj"."FissDiagnosisCodes" ( - "dcn" varchar(23) not null, - "priority" smallint not null, - "diagCd2" varchar(7) not null, - "diagPoaInd" varchar(1) not null, - "bitFlags" varchar(4), - "lastUpdated" timestamp with time zone, - constraint "FissDiagnosisCodes_pkey" primary key ("dcn", "priority"), - constraint "FissDiagnosisCodes_claim" foreign key ("dcn") references "pre_adj"."FissClaims"("dcn") -); - -/* - * Add table for MSC claims. - */ -create table "pre_adj"."McsClaims" ( - "idrClmHdIcn" varchar(15) not null, - "idrContrId" varchar(5) not null, - "idrHic" varchar(12), - "idrClaimType" varchar(1) not null, - "idrDtlCnt" int, - "idrBeneLast_1_6" varchar(6), - "idrBeneFirstInit" varchar(1), - "idrBeneMidInit" varchar(1), - "idrBeneSex" varchar(1), - "idrStatusCode" varchar(1), - "idrStatusDate" date, - "idrBillProvNpi" varchar(10), - "idrBillProvNum" varchar(10), - "idrBillProvEin" varchar(10), - "idrBillProvType" varchar(2), - "idrBillProvSpec" varchar(2), - "idrBillProvGroupInd" varchar(1), - "idrBillProvPriceSpec" varchar(2), - "idrBillProvCounty" varchar(2), - "idrBillProvLoc" varchar(2), - "idrTotAllowed" decimal(7, 2), - "idrCoinsurance" decimal(7, 2), - "idrDeductible" decimal(7, 2), - "idrBillProvStatusCd" varchar(1), - "idrTotBilledAmt" decimal(7, 2), - "idrClaimReceiptDate" date, - "idrClaimMbi" varchar(13), - "idrClaimMbiHash" varchar(64), - "idrHdrFromDateOfSvc" date, - "idrHdrToDateOfSvc" date, - "lastUpdated" timestamp with time zone, - constraint "McsClaims_pkey" primary key ("idrClmHdIcn") -); - -/* - * Index the MedicareBeneficiaryIdentifier (MBI) hash column for mbi searches. - * The search is used by partners to find claims for specific beneficiaries. - * Since this is a frequent operation, the hash is indexed. - */ - -create -index "McsClaims_mbi_hash_idx" - on "pre_adj"."McsClaims" ("idrClaimMbiHash"); - -/* - * The priority column is used to sort the detail records and is populated using array index in RDA - * API response array. - */ -create table "pre_adj"."McsDiagnosisCodes" ( - "idrClmHdIcn" varchar(15) not null, - "priority" smallint not null, - "idrDiagIcdType" varchar(1), - "idrDiagCode" varchar(7), - "lastUpdated" timestamp with time zone, - constraint "McsDiagnosisCodes_pkey" primary key ("idrClmHdIcn", "priority"), - constraint "McsDiagnosisCodes_claim" foreign key ("idrClmHdIcn") references "pre_adj"."McsClaims"("idrClmHdIcn") -); - -/* - * The priority column is used to sort the detail records and is populated using array index in RDA - * API response array. - */ -create table "pre_adj"."McsDetails" ( - "idrClmHdIcn" varchar(15) not null, - "priority" smallint not null, - "idrDtlStatus" varchar(1), - "idrDtlFromDate" date, - "idrDtlToDate" date, - "idrProcCode" varchar(5), - "idrModOne" varchar(2), - "idrModTwo" varchar(2), - "idrModThree" varchar(2), - "idrModFour" varchar(2), - "idrDtlDiagIcdType" varchar(1), - "idrDtlPrimaryDiagCode" varchar(7), - "idrKPosLnameOrg" varchar(60), - "idrKPosFname" varchar(35), - "idrKPosMname" varchar(25), - "idrKPosAddr1" varchar(55), - "idrKPosAddr2_1st" varchar(30), - "idrKPosAddr2_2nd" varchar(25), - "idrKPosCity" varchar(30), - "idrKPosState" varchar(2), - "idrKPosZip" varchar(15), - "lastUpdated" timestamp with time zone, - constraint "McsDetails_pkey" primary key ("idrClmHdIcn", "priority"), - constraint "McsDetails_claim" foreign key ("idrClmHdIcn") references "pre_adj"."McsClaims"("idrClmHdIcn") -); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V32__preadj_schema_perms.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V32__preadj_schema_perms.sql deleted file mode 100644 index 1d06222465..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V32__preadj_schema_perms.sql +++ /dev/null @@ -1,35 +0,0 @@ -/* -GRANTS DEFAULT PERMS ON THE PRE_ADJ SCHEMA (IF RUN ON POSTGRES) -NOTES: -- DO runs an anonymous block using the default language (PL/pgSQL). -- $$ is to make the block readable. See https://www.postgresqltutorial.com/plpgsql-block-structure/ -- PL/pgSQL's BEGIN/END are only for grouping, they do not start or end a transaction. -- The logic.perms placeholder will be replaced by '--' (commented out) if hsql, removed if postgres. -- So these perms will only be applied if run on postgres. See DatabaseSchemaManager.java for placeholders. -- Fixes perms on existing tables. -*/ - -${logic.perms} DO $$ -${logic.perms} BEGIN -${logic.perms} IF EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = 'read_only_bb') THEN -${logic.perms} GRANT USAGE ON SCHEMA pre_adj TO read_only_bb; -${logic.perms} ALTER DEFAULT PRIVILEGES IN SCHEMA pre_adj GRANT SELECT ON TABLES TO read_only_bb; -${logic.perms} GRANT SELECT ON TABLE pre_adj."FissClaims" TO read_only_bb; -${logic.perms} GRANT SELECT ON TABLE pre_adj."FissDiagnosisCodes" TO read_only_bb; -${logic.perms} GRANT SELECT ON TABLE pre_adj."FissProcCodes" TO read_only_bb; -${logic.perms} GRANT SELECT ON TABLE pre_adj."McsClaims" TO read_only_bb; -${logic.perms} GRANT SELECT ON TABLE pre_adj."McsDetails" TO read_only_bb; -${logic.perms} GRANT SELECT ON TABLE pre_adj."McsDiagnosisCodes" TO read_only_bb; -${logic.perms} END IF; -${logic.perms} IF EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = 'svc_bfd_pipeline_role') THEN -${logic.perms} GRANT USAGE ON SCHEMA pre_adj TO svc_bfd_pipeline_role; -${logic.perms} ALTER DEFAULT PRIVILEGES IN SCHEMA pre_adj GRANT ALL ON TABLES TO svc_bfd_pipeline_role; -${logic.perms} ALTER DEFAULT PRIVILEGES IN SCHEMA pre_adj GRANT ALL ON SEQUENCES TO svc_bfd_pipeline_role; -${logic.perms} GRANT ALL ON TABLE pre_adj."FissClaims" TO svc_bfd_pipeline_role; -${logic.perms} GRANT ALL ON TABLE pre_adj."FissDiagnosisCodes" TO svc_bfd_pipeline_role; -${logic.perms} GRANT ALL ON TABLE pre_adj."FissProcCodes" TO svc_bfd_pipeline_role; -${logic.perms} GRANT ALL ON TABLE pre_adj."McsClaims" TO svc_bfd_pipeline_role; -${logic.perms} GRANT ALL ON TABLE pre_adj."McsDetails" TO svc_bfd_pipeline_role; -${logic.perms} GRANT ALL ON TABLE pre_adj."McsDiagnosisCodes" TO svc_bfd_pipeline_role; -${logic.perms} END IF; -${logic.perms} END $$; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V33__preadj_rda_0_4_table_updates.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V33__preadj_rda_0_4_table_updates.sql deleted file mode 100644 index fc504c2866..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V33__preadj_rda_0_4_table_updates.sql +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Creates RDA FissPayers table for pre-adjudicated claim payers and adds - * new columns to FissClaims for RDA API 0.4. - * https://confluenceent.cms.gov/display/MPSM/MVP+0.4+Data+Dictionary+for+Replicated+Data+Access+API - * - * Where possible column names map directly to fields in the RDA API result message. - */ - -/* - * Add new FISS claim fields from RDA API MVP 0.2 release. - */ -alter table "pre_adj"."FissClaims" - add "lobCd" varchar(1); -alter table "pre_adj"."FissClaims" - add "servTypeCdMapping" varchar(20); -alter table "pre_adj"."FissClaims" - add "servTypeCd" varchar(1); -alter table "pre_adj"."FissClaims" - add "freqCd" varchar(1); -alter table "pre_adj"."FissClaims" - add "billTypCd" varchar(3); - -/* - * Add new FISS Claim payers table from RDA API 0.4 release. - * The priority column is used to sort the payer records and is populated using array index in RDA - * API response array. - */ - -create table "pre_adj"."FissPayers" ( - "dcn" varchar(23) not null, - "priority" smallint not null, - "payerType" varchar(20), - "payersId" varchar(1), - "payersName" varchar(32), - "relInd" varchar(1), - "assignInd" varchar(1), - "providerNumber" varchar(13), - "adjDcnIcn" varchar(23), - "priorPmt" decimal(11, 2), - "estAmtDue" decimal(11, 2), - "beneRel" varchar(2), - "beneLastName" varchar(15), - "beneFirstName" varchar(10), - "beneMidInit" varchar(1), - "beneSsnHic" varchar(19), - "insuredRel" varchar(2), - "insuredName" varchar(25), - "insuredSsnHic" varchar(19), - "insuredGroupName" varchar(17), - "insuredGroupNbr" varchar(20), - "beneDob" date, - "beneSex" varchar(1), - "treatAuthCd" varchar(18), - "insuredSex" varchar(1), - "insuredRelX12" varchar(2), - "insuredDob" date, - "insuredDobText" varchar(9), - "lastUpdated" timestamp with time zone, - constraint "FissPayers_pkey" primary key ("dcn", "priority"), - constraint "FissPayers_claim" foreign key ("dcn") references "pre_adj"."FissClaims"("dcn") -); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V34__preadj_rda_replay_table_updates.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V34__preadj_rda_replay_table_updates.sql deleted file mode 100644 index 84677448c9..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V34__preadj_rda_replay_table_updates.sql +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Every claim change from the RDA API contains a 64-bit sequence number that can be used - * to request a replay of past updates. Each claim in the database will have the most recent - * sequence number that affected that claim stored in a column. - */ - -/* - * Add the sequence number column used to track which update from RDA API was - * used to create or update the claim. - */ -alter table "pre_adj"."FissClaims" - add "sequenceNumber" bigint default 0 not null; -alter table "pre_adj"."McsClaims" - add "sequenceNumber" bigint default 0 not null; - -/* Remove the default values on the columns. They were only needed to add the not null column. */ -ALTER TABLE "pre_adj"."FissClaims" - ALTER COLUMN "sequenceNumber" DROP DEFAULT; -ALTER TABLE "pre_adj"."McsClaims" - ALTER COLUMN "sequenceNumber" DROP DEFAULT; - -/* Index to allow quick determination of where to resume stream in calls to RDA API. */ -create index "FissClaims_sequenceNumber_idx" on "pre_adj"."FissClaims" ("sequenceNumber"); -create index "McsClaims_sequenceNumber_idx" on "pre_adj"."McsClaims" ("sequenceNumber"); - -/* Index to allow fast query by update time by BFD API. */ -create index "FissClaims_lastUpdated_idx" on "pre_adj"."FissClaims" ("lastUpdated"); -create index "McsClaims_lastUpdated_idx" on "pre_adj"."McsClaims" ("lastUpdated"); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V35__Modify_beneficiary_monthly_index.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V35__Modify_beneficiary_monthly_index.sql deleted file mode 100644 index 0f807ceabb..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V35__Modify_beneficiary_monthly_index.sql +++ /dev/null @@ -1,4 +0,0 @@ --- create index for BeneficiaryMonthly for column indexes yearMonth, partDContractNumberId, parentBeneficiary - -CREATE INDEX IF NOT EXISTS "BeneficiaryMonthly_partDContractNumId_yearMonth_parentBene_idx" - ON public."BeneficiaryMonthly" ("partDContractNumberId" ASC, "yearMonth" ASC, "parentBeneficiary" ASC); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V36__preadj_api_source_column.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V36__preadj_api_source_column.sql deleted file mode 100644 index 96afd2a99a..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V36__preadj_api_source_column.sql +++ /dev/null @@ -1,5 +0,0 @@ -/* - * Add column used to track version of server that produced each claim. - */ -alter table "pre_adj"."FissClaims" add "apiSource" varchar(24); -alter table "pre_adj"."McsClaims" add "apiSource" varchar(24); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V37__preadj_rda_0_5_table_updates.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V37__preadj_rda_0_5_table_updates.sql deleted file mode 100644 index a78d8b04ed..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V37__preadj_rda_0_5_table_updates.sql +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Schema updates required for compatibility with RDA API Version 0.5. - * - * New tables: - * FissAuditTrails - * McsAdjustments - * McsAudits - * McsLocations - * - * Changed tables: - * FissClaims - * FissDiagnosisCodes - * McsClaims - * McsDetails - */ - -/************************** CREATES **************************/ - -/* - * FissAuditTrails - */ -CREATE TABLE "pre_adj"."FissAuditTrails" ( - "dcn" varchar(23) NOT NULL, - "priority" smallint NOT NULL, - "lastUpdated" timestamp with time zone, - "badtStatus" varchar(1), - "badtLoc" varchar(5), - "badtOperId" varchar(9), - "badtReas" varchar(5), - "badtCurrDate" date, - CONSTRAINT "FissAuditTrails_key" PRIMARY KEY ("dcn", "priority"), - CONSTRAINT "FissAuditTrails_parent" FOREIGN KEY ("dcn") REFERENCES "pre_adj"."FissClaims"("dcn") -); - -/* - * McsAdjustments - */ -CREATE TABLE "pre_adj"."McsAdjustments" ( - "idrClmHdIcn" varchar(15) NOT NULL, - "priority" smallint NOT NULL, - "lastUpdated" timestamp with time zone, - "idrAdjDate" date, - "idrXrefIcn" varchar(15), - "idrAdjClerk" varchar(4), - "idrInitCcn" varchar(15), - "idrAdjChkWrtDt" date, - "idrAdjBEombAmt" decimal(7,2), - "idrAdjPEombAmt" decimal(7,2), - CONSTRAINT "McsAdjustments_key" PRIMARY KEY ("idrClmHdIcn", "priority"), - CONSTRAINT "McsAdjustments_parent" FOREIGN KEY ("idrClmHdIcn") REFERENCES "pre_adj"."McsClaims"("idrClmHdIcn") -); - -/* - * McsAudits - */ -CREATE TABLE "pre_adj"."McsAudits" ( - "idrClmHdIcn" varchar(15) NOT NULL, - "priority" smallint NOT NULL, - "lastUpdated" timestamp with time zone, - "idrJAuditNum" int, - "idrJAuditInd" varchar(1), - "idrJAuditDisp" varchar(1), - CONSTRAINT "McsAudits_key" PRIMARY KEY ("idrClmHdIcn", "priority"), - CONSTRAINT "McsAudits_parent" FOREIGN KEY ("idrClmHdIcn") REFERENCES "pre_adj"."McsClaims"("idrClmHdIcn") -); - -/* - * McsLocations - */ -CREATE TABLE "pre_adj"."McsLocations" ( - "idrClmHdIcn" varchar(15) NOT NULL, - "priority" smallint NOT NULL, - "lastUpdated" timestamp with time zone, - "idrLocClerk" varchar(4), - "idrLocCode" varchar(3), - "idrLocDate" date, - "idrLocActvCode" varchar(1), - CONSTRAINT "McsLocations_key" PRIMARY KEY ("idrClmHdIcn", "priority"), - CONSTRAINT "McsLocations_parent" FOREIGN KEY ("idrClmHdIcn") REFERENCES "pre_adj"."McsClaims"("idrClmHdIcn") -); - -/************************** CHANGES **************************/ - -/* - * FissClaims - */ -ALTER TABLE "pre_adj"."FissClaims" ADD "rejectCd" varchar(5); -ALTER TABLE "pre_adj"."FissClaims" ADD "fullPartDenInd" varchar(1); -ALTER TABLE "pre_adj"."FissClaims" ADD "nonPayInd" varchar(2); -ALTER TABLE "pre_adj"."FissClaims" ADD "xrefDcnNbr" varchar(23); -ALTER TABLE "pre_adj"."FissClaims" ADD "adjReqCd" varchar(1); -ALTER TABLE "pre_adj"."FissClaims" ADD "adjReasCd" varchar(2); -ALTER TABLE "pre_adj"."FissClaims" ADD "cancelXrefDcn" varchar(23); -ALTER TABLE "pre_adj"."FissClaims" ADD "cancelDate" date; -ALTER TABLE "pre_adj"."FissClaims" ADD "cancAdjCd" varchar(1); -ALTER TABLE "pre_adj"."FissClaims" ADD "originalXrefDcn" varchar(23); -ALTER TABLE "pre_adj"."FissClaims" ADD "paidDt" date; -ALTER TABLE "pre_adj"."FissClaims" ADD "admDate" date; -ALTER TABLE "pre_adj"."FissClaims" ADD "admSource" varchar(1); -ALTER TABLE "pre_adj"."FissClaims" ADD "primaryPayerCode" varchar(1); -ALTER TABLE "pre_adj"."FissClaims" ADD "attendPhysId" varchar(16); -ALTER TABLE "pre_adj"."FissClaims" ADD "attendPhysLname" varchar(17); -ALTER TABLE "pre_adj"."FissClaims" ADD "attendPhysFname" varchar(18); -ALTER TABLE "pre_adj"."FissClaims" ADD "attendPhysMint" varchar(1); -ALTER TABLE "pre_adj"."FissClaims" ADD "attendPhysFlag" varchar(1); -ALTER TABLE "pre_adj"."FissClaims" ADD "operatingPhysId" varchar(16); -ALTER TABLE "pre_adj"."FissClaims" ADD "operPhysLname" varchar(17); -ALTER TABLE "pre_adj"."FissClaims" ADD "operPhysFname" varchar(18); -ALTER TABLE "pre_adj"."FissClaims" ADD "operPhysMint" varchar(1); -ALTER TABLE "pre_adj"."FissClaims" ADD "operPhysFlag" varchar(1); -ALTER TABLE "pre_adj"."FissClaims" ADD "othPhysId" varchar(16); -ALTER TABLE "pre_adj"."FissClaims" ADD "othPhysLname" varchar(17); -ALTER TABLE "pre_adj"."FissClaims" ADD "othPhysFname" varchar(18); -ALTER TABLE "pre_adj"."FissClaims" ADD "othPhysMint" varchar(1); -ALTER TABLE "pre_adj"."FissClaims" ADD "othPhysFlag" varchar(1); -ALTER TABLE "pre_adj"."FissClaims" ADD "xrefHicNbr" varchar(12); -ALTER TABLE "pre_adj"."FissClaims" ADD "procNewHicInd" varchar(1); -ALTER TABLE "pre_adj"."FissClaims" ADD "newHic" varchar(12); -ALTER TABLE "pre_adj"."FissClaims" ADD "reposInd" varchar(1); -ALTER TABLE "pre_adj"."FissClaims" ADD "reposHic" varchar(12); -ALTER TABLE "pre_adj"."FissClaims" ADD "mbiSubmBeneInd" varchar(1); -ALTER TABLE "pre_adj"."FissClaims" ADD "adjMbiInd" varchar(1); -ALTER TABLE "pre_adj"."FissClaims" ADD "adjMbi" varchar(11); -ALTER TABLE "pre_adj"."FissClaims" ADD "medicalRecordNo" varchar(17); - -/* - * FissDiagnosisCodes - */ -ALTER TABLE "pre_adj"."FissDiagnosisCodes" ALTER COLUMN "diagPoaInd" DROP NOT NULL; - -/* - * McsClaims - */ -ALTER TABLE "pre_adj"."McsClaims" ADD "idrAssignment" varchar(1); -ALTER TABLE "pre_adj"."McsClaims" ADD "idrClmLevelInd" varchar(1); -ALTER TABLE "pre_adj"."McsClaims" ADD "idrHdrAudit" int; -ALTER TABLE "pre_adj"."McsClaims" ADD "idrHdrAuditInd" varchar(1); -ALTER TABLE "pre_adj"."McsClaims" ADD "idrUSplitReason" varchar(1); -ALTER TABLE "pre_adj"."McsClaims" ADD "idrJReferringProvNpi" varchar(10); -ALTER TABLE "pre_adj"."McsClaims" ADD "idrJFacProvNpi" varchar(10); -ALTER TABLE "pre_adj"."McsClaims" ADD "idrUDemoProvNpi" varchar(10); -ALTER TABLE "pre_adj"."McsClaims" ADD "idrUSuperNpi" varchar(10); -ALTER TABLE "pre_adj"."McsClaims" ADD "idrUFcadjBilNpi" varchar(10); -ALTER TABLE "pre_adj"."McsClaims" ADD "idrAmbPickupAddresLine1" varchar(25); -ALTER TABLE "pre_adj"."McsClaims" ADD "idrAmbPickupAddresLine2" varchar(20); -ALTER TABLE "pre_adj"."McsClaims" ADD "idrAmbPickupCity" varchar(20); -ALTER TABLE "pre_adj"."McsClaims" ADD "idrAmbPickupState" varchar(2); -ALTER TABLE "pre_adj"."McsClaims" ADD "idrAmbPickupZipcode" varchar(9); -ALTER TABLE "pre_adj"."McsClaims" ADD "idrAmbDropoffName" varchar(24); -ALTER TABLE "pre_adj"."McsClaims" ADD "idrAmbDropoffAddrLine1" varchar(25); -ALTER TABLE "pre_adj"."McsClaims" ADD "idrAmbDropoffAddrLine2" varchar(20); -ALTER TABLE "pre_adj"."McsClaims" ADD "idrAmbDropoffCity" varchar(20); -ALTER TABLE "pre_adj"."McsClaims" ADD "idrAmbDropoffState" varchar(2); -ALTER TABLE "pre_adj"."McsClaims" ADD "idrAmbDropoffZipcode" varchar(9); - -/* - * McsDetails - */ -ALTER TABLE "pre_adj"."McsDetails" ADD "idrTos" varchar(1); -ALTER TABLE "pre_adj"."McsDetails" ADD "idrTwoDigitPos" varchar(2); -ALTER TABLE "pre_adj"."McsDetails" ADD "idrDtlRendType" varchar(2); -ALTER TABLE "pre_adj"."McsDetails" ADD "idrDtlRendSpec" varchar(2); -ALTER TABLE "pre_adj"."McsDetails" ADD "idrDtlRendNpi" varchar(10); -ALTER TABLE "pre_adj"."McsDetails" ADD "idrDtlRendProv" varchar(10); -ALTER TABLE "pre_adj"."McsDetails" ADD "idrKDtlFacProvNpi" varchar(10); -ALTER TABLE "pre_adj"."McsDetails" ADD "idrDtlAmbPickupAddres1" varchar(25); -ALTER TABLE "pre_adj"."McsDetails" ADD "idrDtlAmbPickupAddres2" varchar(20); -ALTER TABLE "pre_adj"."McsDetails" ADD "idrDtlAmbPickupCity" varchar(20); -ALTER TABLE "pre_adj"."McsDetails" ADD "idrDtlAmbPickupState" varchar(2); -ALTER TABLE "pre_adj"."McsDetails" ADD "idrDtlAmbPickupZipcode" varchar(9); -ALTER TABLE "pre_adj"."McsDetails" ADD "idrDtlAmbDropoffName" varchar(24); -ALTER TABLE "pre_adj"."McsDetails" ADD "idrDtlAmbDropoffAddrL1" varchar(25); -ALTER TABLE "pre_adj"."McsDetails" ADD "idrDtlAmbDropoffAddrL2" varchar(20); -ALTER TABLE "pre_adj"."McsDetails" ADD "idrDtlAmbDropoffCity" varchar(20); -ALTER TABLE "pre_adj"."McsDetails" ADD "idrDtlAmbDropoffState" varchar(2); -ALTER TABLE "pre_adj"."McsDetails" ADD "idrDtlAmbDropoffZipcode" varchar(9); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V38__preadj_rda_0_5_post_table_updates.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V38__preadj_rda_0_5_post_table_updates.sql deleted file mode 100644 index b7366410a5..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V38__preadj_rda_0_5_post_table_updates.sql +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Schema updates required for compatibility with RDA API Version 0.5. - * - * Changed tables: - * McsDiagnosisCodes - */ - -/************************** CHANGES **************************/ - - -/* - * McsDiagnosisCodes - */ - -UPDATE "pre_adj"."McsDiagnosisCodes" SET "idrDiagCode"='' WHERE "idrDiagCode" IS NULL; -ALTER TABLE "pre_adj"."McsDiagnosisCodes" ALTER COLUMN "idrDiagCode" SET NOT NULL; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V39__api_progress_table.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V39__api_progress_table.sql deleted file mode 100644 index 0834114f55..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V39__api_progress_table.sql +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Creates a table to track the highest sequence number imported into the database. - * A query of this table can be used to track the sequence number to pass as a - * {@code since} parameter to the RDA API. - */ - -create table "pre_adj"."RdaApiProgress" ( - "claimType" VARCHAR(20) NOT NULL PRIMARY KEY, - "lastSequenceNumber" BIGINT NOT NULL, - "lastUpdated" timestamp with time zone -); - -/* These are no longer required since we are tracking the replay sequence number in RdaApiProgress. */ -drop index "pre_adj"."FissClaims_sequenceNumber_idx"; -drop index "pre_adj"."McsClaims_sequenceNumber_idx"; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V3__Add_claim_beneficiary_constraints_and_indexes.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V3__Add_claim_beneficiary_constraints_and_indexes.sql deleted file mode 100644 index 1102fae99b..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V3__Add_claim_beneficiary_constraints_and_indexes.sql +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Adds the foreign keys and indexes required to manage the relationships - * between the claim tables and the "Beneficiaries" table. - */ - - --- Create all of the claim-to-bene table foreign keys. -alter table "CarrierClaims" - add constraint "CarrierClaims_beneficiaryId_to_Beneficiaries" - foreign key ("beneficiaryId") - references "Beneficiaries"; - -alter table "DMEClaims" - add constraint "DMEClaims_beneficiaryId_to_Beneficiaries" - foreign key ("beneficiaryId") - references "Beneficiaries"; - -alter table "HHAClaims" - add constraint "HHAClaims_beneficiaryId_to_Beneficiaries" - foreign key ("beneficiaryId") - references "Beneficiaries"; - -alter table "HospiceClaims" - add constraint "HospiceClaims_beneficiaryId_to_Beneficiaries" - foreign key ("beneficiaryId") - references "Beneficiaries"; - -alter table "InpatientClaims" - add constraint "InpatientClaims_beneficiaryId_to_Beneficiaries" - foreign key ("beneficiaryId") - references "Beneficiaries"; - -alter table "OutpatientClaims" - add constraint "OutpatientClaims_beneficiaryId_to_Beneficiaries" - foreign key ("beneficiaryId") - references "Beneficiaries"; - -alter table "PartDEvents" - add constraint "PartDEvents_beneficiaryId_to_Beneficiaries" - foreign key ("beneficiaryId") - references "Beneficiaries"; - -alter table "SNFClaims" - add constraint "SNFClaims_beneficiaryId_to_Beneficiaries" - foreign key ("beneficiaryId") - references "Beneficiaries"; - - --- Create all of the "beneficiaryId" column indexes for claim tables. -create index "CarrierClaims_beneficiaryId_idx" - on "CarrierClaims" ("beneficiaryId"); - -create index "DMEClaims_beneficiaryId_idx" - on "DMEClaims" ("beneficiaryId"); - -create index "HHAClaims_beneficiaryId_idx" - on "HHAClaims" ("beneficiaryId"); - -create index "HospiceClaims_beneficiaryId_idx" - on "HospiceClaims" ("beneficiaryId"); - -create index "InpatientClaims_beneficiaryId_idx" - on "InpatientClaims" ("beneficiaryId"); - -create index "OutpatientClaims_beneficiaryId_idx" - on "OutpatientClaims" ("beneficiaryId"); - -create index "PartDEvents_beneficiaryId_idx" - on "PartDEvents" ("beneficiaryId"); - -create index "SNFClaims_beneficiaryId_idx" - on "SNFClaims" ("beneficiaryId"); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V40__Table_column_rename_Beneficiary.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V40__Table_column_rename_Beneficiary.sql deleted file mode 100644 index ca42935f19..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V40__Table_column_rename_Beneficiary.sql +++ /dev/null @@ -1,315 +0,0 @@ --- The V40 through V52 migrations rename our tables and columns for CCW-sourced data, such that: --- 1. We follow PostgreSQL's general snake_case naming conventions, to improve the developer experience: DB --- object names won't have to be quoted all over the place, anymore. --- 2. Column names match those in our upstream source system, the CCW, to improve traceability as data flows --- through our systems. --- 3. Rename the "parentXXX" foreign key columns to instead have names that match their target column. - --- NOTES: --- Postgres (psql) and Hmem (hsql) differ in their support for renaming in place db artifacts; --- the rules can be summarized as: --- psql - supports table, table column, table constraint and table index renaming --- hsql - supports table and table column renaming, but does not support renaming a constraint; --- it also does not allow you to rename a primary key index, but does allow a rename for --- index that is not a primary key. Thus for primary key index name and table constraint --- name, the original index or constraint will need to be dropped and re-built. --- --- uncomment the following SCRIPT directive if you want to to dump the hsql database schema to a file --- prior to performing table or column renaming. --- --- SCRIPT './bfd_schema_pre.txt'; --- --- Drop foreign key constraints (hsql only) --- -${logic.hsql-only-alter} table public."BeneficiariesHistory" drop constraint "BeneficiariesHistory_beneficiaryId_to_Beneficiary"; -${logic.hsql-only-alter} table public."BeneficiaryMonthly" drop constraint "BeneficiaryMonthly_parentBeneficiary_to_Beneficiary"; -${logic.hsql-only-alter} table public."CarrierClaimLines" drop constraint "CarrierClaimLines_parentClaim_to_CarrierClaims"; -${logic.hsql-only-alter} table public."CarrierClaims" drop constraint "CarrierClaims_beneficiaryId_to_Beneficiaries"; -${logic.hsql-only-alter} table public."DMEClaimLines" drop constraint "DMEClaimLines_parentClaim_to_DMEClaims"; -${logic.hsql-only-alter} table public."DMEClaims" drop constraint "DMEClaims_beneficiaryId_to_Beneficiaries"; -${logic.hsql-only-alter} table public."HHAClaimLines" drop constraint "HHAClaimLines_parentClaim_to_HHAClaims"; -${logic.hsql-only-alter} table public."HHAClaims" drop constraint "HHAClaims_beneficiaryId_to_Beneficiaries"; -${logic.hsql-only-alter} table public."HospiceClaimLines" drop constraint "HospiceClaimLines_parentClaim_to_HospiceClaims"; -${logic.hsql-only-alter} table public."HospiceClaims" drop constraint "HospiceClaims_beneficiaryId_to_Beneficiaries"; -${logic.hsql-only-alter} table public."InpatientClaimLines" drop constraint "InpatientClaimLines_parentClaim_to_InpatientClaims"; -${logic.hsql-only-alter} table public."InpatientClaims" drop constraint "InpatientClaims_beneficiaryId_to_Beneficiaries"; -${logic.hsql-only-alter} table public."MedicareBeneficiaryIdHistory" drop constraint "MedicareBeneficiaryIdHistory_beneficiaryId_to_Beneficiary"; -${logic.hsql-only-alter} table public."OutpatientClaimLines" drop constraint "OutpatientClaimLines_parentClaim_to_OutpatientClaims"; -${logic.hsql-only-alter} table public."OutpatientClaims" drop constraint "OutpatientClaims_beneficiaryId_to_Beneficiaries"; -${logic.hsql-only-alter} table public."PartDEvents" drop constraint "PartDEvents_beneficiaryId_to_Beneficiaries"; -${logic.hsql-only-alter} table public."SNFClaimLines" drop constraint "SNFClaimLines_parentClaim_to_SNFClaims"; -${logic.hsql-only-alter} table public."SNFClaims" drop constraint "SNFClaims_beneficiaryId_to_Beneficiaries"; -${logic.hsql-only-alter} table public."LoadedBatches" drop constraint "loadedBatches_loadedFileId"; --- --- Drop primary key constraints for hsql; hsql does not support rename constraint --- --- ${logic.hsql-only-alter} --- psql: "-- alter" --- hsql: "alter" --- -${logic.hsql-only-alter} table public."BeneficiariesHistoryInvalidBeneficiaries" drop constraint "BeneficiariesHistoryInvalidBeneficiaries_pkey"; -${logic.hsql-only-alter} table public."BeneficiariesHistory" drop constraint "BeneficiariesHistory_pkey"; -${logic.hsql-only-alter} table public."Beneficiaries" drop constraint "Beneficiaries_pkey"; -${logic.hsql-only-alter} table public."BeneficiaryMonthly" drop constraint "BeneficiaryMonthly_pkey"; -${logic.hsql-only-alter} table public."CarrierClaimLines" drop constraint "CarrierClaimLines_pkey"; -${logic.hsql-only-alter} table public."CarrierClaims" drop constraint "CarrierClaims_pkey"; -${logic.hsql-only-alter} table public."DMEClaimLines" drop constraint "DMEClaimLines_pkey"; -${logic.hsql-only-alter} table public."DMEClaims" drop constraint "DMEClaims_pkey"; -${logic.hsql-only-alter} table public."HHAClaimLines" drop constraint "HHAClaimLines_pkey"; -${logic.hsql-only-alter} table public."HHAClaims" drop constraint "HHAClaims_pkey"; -${logic.hsql-only-alter} table public."HospiceClaimLines" drop constraint "HospiceClaimLines_pkey"; -${logic.hsql-only-alter} table public."HospiceClaims" drop constraint "HospiceClaims_pkey"; -${logic.hsql-only-alter} table public."InpatientClaimLines" drop constraint "InpatientClaimLines_pkey"; -${logic.hsql-only-alter} table public."InpatientClaims" drop constraint "InpatientClaims_pkey"; -${logic.hsql-only-alter} table public."MedicareBeneficiaryIdHistoryInvalidBeneficiaries" drop constraint "MedicareBeneficiaryIdHistoryInvalidBeneficiaries_pkey"; -${logic.hsql-only-alter} table public."MedicareBeneficiaryIdHistory" drop constraint "MedicareBeneficiaryIdHistory_pkey"; -${logic.hsql-only-alter} table public."OutpatientClaimLines" drop constraint "OutpatientClaimLines_pkey"; -${logic.hsql-only-alter} table public."OutpatientClaims" drop constraint "OutpatientClaims_pkey"; -${logic.hsql-only-alter} table public."PartDEvents" drop constraint "PartDEvents_pkey"; -${logic.hsql-only-alter} table public."SNFClaimLines" drop constraint "SNFClaimLines_pkey"; -${logic.hsql-only-alter} table public."SNFClaims" drop constraint "SNFClaims_pkey"; --- --- Rename tables and table columns --- --- psql: alter table public.beneficiaries rename column "beneficiaryId" to bene_id; --- hsql: alter table public.beneficiaries alter column "beneficiaryId" rename to bene_id; --- --- ${logic.alter-rename-column} --- psql: "rename column" --- hsql: "alter column" --- --- ${logic.rename-to} --- psql: "to" --- hsql: "rename to" --- --- Beneficiaries to beneficiaries --- -alter table public."Beneficiaries" rename to beneficiaries; -alter table public.beneficiaries ${logic.alter-rename-column} "beneficiaryId" ${logic.rename-to} bene_id; -alter table public.beneficiaries ${logic.alter-rename-column} lastupdated ${logic.rename-to} last_updated; -alter table public.beneficiaries ${logic.alter-rename-column} "birthDate" ${logic.rename-to} bene_birth_dt; -alter table public.beneficiaries ${logic.alter-rename-column} "endStageRenalDiseaseCode" ${logic.rename-to} bene_esrd_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "entitlementCodeCurrent" ${logic.rename-to} bene_entlmt_rsn_curr; -alter table public.beneficiaries ${logic.alter-rename-column} "entitlementCodeOriginal" ${logic.rename-to} bene_entlmt_rsn_orig; -alter table public.beneficiaries ${logic.alter-rename-column} "medicareEnrollmentStatusCode" ${logic.rename-to} bene_mdcr_status_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "nameGiven" ${logic.rename-to} bene_gvn_name; -alter table public.beneficiaries ${logic.alter-rename-column} "nameMiddleInitial" ${logic.rename-to} bene_mdl_name; -alter table public.beneficiaries ${logic.alter-rename-column} "nameSurname" ${logic.rename-to} bene_srnm_name; -alter table public.beneficiaries ${logic.alter-rename-column} "stateCode" ${logic.rename-to} state_code; -alter table public.beneficiaries ${logic.alter-rename-column} "countyCode" ${logic.rename-to} bene_county_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "postalCode" ${logic.rename-to} bene_zip_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "ageOfBeneficiary" ${logic.rename-to} age; -alter table public.beneficiaries ${logic.alter-rename-column} "race" ${logic.rename-to} bene_race_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "rtiRaceCode" ${logic.rename-to} rti_race_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "sex" ${logic.rename-to} bene_sex_ident_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "hicn" ${logic.rename-to} bene_crnt_hic_num; -alter table public.beneficiaries ${logic.alter-rename-column} "hicnUnhashed" ${logic.rename-to} hicn_unhashed; -alter table public.beneficiaries ${logic.alter-rename-column} "medicareBeneficiaryId" ${logic.rename-to} mbi_num; -alter table public.beneficiaries ${logic.alter-rename-column} "mbiHash" ${logic.rename-to} mbi_hash; -alter table public.beneficiaries ${logic.alter-rename-column} "mbiEffectiveDate" ${logic.rename-to} efctv_bgn_dt; -alter table public.beneficiaries ${logic.alter-rename-column} "mbiObsoleteDate" ${logic.rename-to} efctv_end_dt; -alter table public.beneficiaries ${logic.alter-rename-column} "beneficiaryDateOfDeath" ${logic.rename-to} death_dt; -alter table public.beneficiaries ${logic.alter-rename-column} "validDateOfDeathSw" ${logic.rename-to} v_dod_sw; -alter table public.beneficiaries ${logic.alter-rename-column} "beneEnrollmentReferenceYear" ${logic.rename-to} rfrnc_yr; -alter table public.beneficiaries ${logic.alter-rename-column} "partATerminationCode" ${logic.rename-to} bene_pta_trmntn_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partBTerminationCode" ${logic.rename-to} bene_ptb_trmntn_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partAMonthsCount" ${logic.rename-to} a_mo_cnt; -alter table public.beneficiaries ${logic.alter-rename-column} "partBMonthsCount" ${logic.rename-to} b_mo_cnt; -alter table public.beneficiaries ${logic.alter-rename-column} "stateBuyInCoverageCount" ${logic.rename-to} buyin_mo_cnt; -alter table public.beneficiaries ${logic.alter-rename-column} "hmoCoverageCount" ${logic.rename-to} hmo_mo_cnt; -alter table public.beneficiaries ${logic.alter-rename-column} "monthsRetireeDrugSubsidyCoverage" ${logic.rename-to} rds_mo_cnt; -alter table public.beneficiaries ${logic.alter-rename-column} "sourceOfEnrollmentData" ${logic.rename-to} enrl_src; -alter table public.beneficiaries ${logic.alter-rename-column} "sampleMedicareGroupIndicator" ${logic.rename-to} sample_group; -alter table public.beneficiaries ${logic.alter-rename-column} "enhancedMedicareSampleIndicator" ${logic.rename-to} efivepct; -alter table public.beneficiaries ${logic.alter-rename-column} "currentBeneficiaryIdCode" ${logic.rename-to} crnt_bic; -alter table public.beneficiaries ${logic.alter-rename-column} "medicareCoverageStartDate" ${logic.rename-to} covstart; -alter table public.beneficiaries ${logic.alter-rename-column} "monthsOfDualEligibility" ${logic.rename-to} dual_mo_cnt; -alter table public.beneficiaries ${logic.alter-rename-column} "fipsStateCntyJanCode" ${logic.rename-to} fips_state_cnty_jan_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "fipsStateCntyFebCode" ${logic.rename-to} fips_state_cnty_feb_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "fipsStateCntyMarCode" ${logic.rename-to} fips_state_cnty_mar_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "fipsStateCntyAprCode" ${logic.rename-to} fips_state_cnty_apr_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "fipsStateCntyMayCode" ${logic.rename-to} fips_state_cnty_may_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "fipsStateCntyJunCode" ${logic.rename-to} fips_state_cnty_jun_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "fipsStateCntyJulCode" ${logic.rename-to} fips_state_cnty_jul_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "fipsStateCntyAugCode" ${logic.rename-to} fips_state_cnty_aug_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "fipsStateCntySeptCode" ${logic.rename-to} fips_state_cnty_sept_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "fipsStateCntyOctCode" ${logic.rename-to} fips_state_cnty_oct_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "fipsStateCntyNovCode" ${logic.rename-to} fips_state_cnty_nov_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "fipsStateCntyDecCode" ${logic.rename-to} fips_state_cnty_dec_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicareStatusJanCode" ${logic.rename-to} mdcr_stus_jan_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicareStatusFebCode" ${logic.rename-to} mdcr_stus_feb_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicareStatusMarCode" ${logic.rename-to} mdcr_stus_mar_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicareStatusAprCode" ${logic.rename-to} mdcr_stus_apr_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicareStatusMayCode" ${logic.rename-to} mdcr_stus_may_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicareStatusJunCode" ${logic.rename-to} mdcr_stus_jun_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicareStatusJulCode" ${logic.rename-to} mdcr_stus_jul_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicareStatusAugCode" ${logic.rename-to} mdcr_stus_aug_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicareStatusSeptCode" ${logic.rename-to} mdcr_stus_sept_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicareStatusOctCode" ${logic.rename-to} mdcr_stus_oct_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicareStatusNovCode" ${logic.rename-to} mdcr_stus_nov_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicareStatusDecCode" ${logic.rename-to} mdcr_stus_dec_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partDMonthsCount" ${logic.rename-to} plan_cvrg_mo_cnt; -alter table public.beneficiaries ${logic.alter-rename-column} "entitlementBuyInJanInd" ${logic.rename-to} mdcr_entlmt_buyin_1_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "entitlementBuyInFebInd" ${logic.rename-to} mdcr_entlmt_buyin_2_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "entitlementBuyInMarInd" ${logic.rename-to} mdcr_entlmt_buyin_3_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "entitlementBuyInAprInd" ${logic.rename-to} mdcr_entlmt_buyin_4_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "entitlementBuyInMayInd" ${logic.rename-to} mdcr_entlmt_buyin_5_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "entitlementBuyInJunInd" ${logic.rename-to} mdcr_entlmt_buyin_6_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "entitlementBuyInJulInd" ${logic.rename-to} mdcr_entlmt_buyin_7_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "entitlementBuyInAugInd" ${logic.rename-to} mdcr_entlmt_buyin_8_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "entitlementBuyInSeptInd" ${logic.rename-to} mdcr_entlmt_buyin_9_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "entitlementBuyInOctInd" ${logic.rename-to} mdcr_entlmt_buyin_10_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "entitlementBuyInNovInd" ${logic.rename-to} mdcr_entlmt_buyin_11_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "entitlementBuyInDecInd" ${logic.rename-to} mdcr_entlmt_buyin_12_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "hmoIndicatorJanInd" ${logic.rename-to} hmo_1_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "hmoIndicatorFebInd" ${logic.rename-to} hmo_2_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "hmoIndicatorMarInd" ${logic.rename-to} hmo_3_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "hmoIndicatorAprInd" ${logic.rename-to} hmo_4_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "hmoIndicatorMayInd" ${logic.rename-to} hmo_5_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "hmoIndicatorJunInd" ${logic.rename-to} hmo_6_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "hmoIndicatorJulInd" ${logic.rename-to} hmo_7_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "hmoIndicatorAugInd" ${logic.rename-to} hmo_8_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "hmoIndicatorSeptInd" ${logic.rename-to} hmo_9_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "hmoIndicatorOctInd" ${logic.rename-to} hmo_10_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "hmoIndicatorNovInd" ${logic.rename-to} hmo_11_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "hmoIndicatorDecInd" ${logic.rename-to} hmo_12_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "partCContractNumberJanId" ${logic.rename-to} ptc_cntrct_jan_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCContractNumberFebId" ${logic.rename-to} ptc_cntrct_feb_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCContractNumberMarId" ${logic.rename-to} ptc_cntrct_mar_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCContractNumberAprId" ${logic.rename-to} ptc_cntrct_apr_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCContractNumberMayId" ${logic.rename-to} ptc_cntrct_may_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCContractNumberJunId" ${logic.rename-to} ptc_cntrct_jun_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCContractNumberJulId" ${logic.rename-to} ptc_cntrct_jul_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCContractNumberAugId" ${logic.rename-to} ptc_cntrct_aug_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCContractNumberSeptId" ${logic.rename-to} ptc_cntrct_sept_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCContractNumberOctId" ${logic.rename-to} ptc_cntrct_oct_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCContractNumberNovId" ${logic.rename-to} ptc_cntrct_nov_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCContractNumberDecId" ${logic.rename-to} ptc_cntrct_dec_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPbpNumberJanId" ${logic.rename-to} ptc_pbp_jan_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPbpNumberFebId" ${logic.rename-to} ptc_pbp_feb_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPbpNumberMarId" ${logic.rename-to} ptc_pbp_mar_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPbpNumberAprId" ${logic.rename-to} ptc_pbp_apr_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPbpNumberMayId" ${logic.rename-to} ptc_pbp_may_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPbpNumberJunId" ${logic.rename-to} ptc_pbp_jun_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPbpNumberJulId" ${logic.rename-to} ptc_pbp_jul_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPbpNumberAugId" ${logic.rename-to} ptc_pbp_aug_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPbpNumberSeptId" ${logic.rename-to} ptc_pbp_sept_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPbpNumberOctId" ${logic.rename-to} ptc_pbp_oct_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPbpNumberNovId" ${logic.rename-to} ptc_pbp_nov_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPbpNumberDecId" ${logic.rename-to} ptc_pbp_dec_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPlanTypeJanCode" ${logic.rename-to} ptc_plan_type_jan_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPlanTypeFebCode" ${logic.rename-to} ptc_plan_type_feb_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPlanTypeMarCode" ${logic.rename-to} ptc_plan_type_mar_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPlanTypeAprCode" ${logic.rename-to} ptc_plan_type_apr_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPlanTypeMayCode" ${logic.rename-to} ptc_plan_type_may_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPlanTypeJunCode" ${logic.rename-to} ptc_plan_type_jun_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPlanTypeJulCode" ${logic.rename-to} ptc_plan_type_jul_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPlanTypeAugCode" ${logic.rename-to} ptc_plan_type_aug_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPlanTypeSeptCode" ${logic.rename-to} ptc_plan_type_sept_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPlanTypeOctCode" ${logic.rename-to} ptc_plan_type_oct_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPlanTypeNovCode" ${logic.rename-to} ptc_plan_type_nov_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partCPlanTypeDecCode" ${logic.rename-to} ptc_plan_type_dec_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partDContractNumberJanId" ${logic.rename-to} ptd_cntrct_jan_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDContractNumberFebId" ${logic.rename-to} ptd_cntrct_feb_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDContractNumberMarId" ${logic.rename-to} ptd_cntrct_mar_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDContractNumberAprId" ${logic.rename-to} ptd_cntrct_apr_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDContractNumberMayId" ${logic.rename-to} ptd_cntrct_may_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDContractNumberJunId" ${logic.rename-to} ptd_cntrct_jun_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDContractNumberJulId" ${logic.rename-to} ptd_cntrct_jul_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDContractNumberAugId" ${logic.rename-to} ptd_cntrct_aug_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDContractNumberSeptId" ${logic.rename-to} ptd_cntrct_sept_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDContractNumberOctId" ${logic.rename-to} ptd_cntrct_oct_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDContractNumberNovId" ${logic.rename-to} ptd_cntrct_nov_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDContractNumberDecId" ${logic.rename-to} ptd_cntrct_dec_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDPbpNumberJanId" ${logic.rename-to} ptd_pbp_jan_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDPbpNumberFebId" ${logic.rename-to} ptd_pbp_feb_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDPbpNumberMarId" ${logic.rename-to} ptd_pbp_mar_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDPbpNumberAprId" ${logic.rename-to} ptd_pbp_apr_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDPbpNumberMayId" ${logic.rename-to} ptd_pbp_may_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDPbpNumberJunId" ${logic.rename-to} ptd_pbp_jun_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDPbpNumberJulId" ${logic.rename-to} ptd_pbp_jul_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDPbpNumberAugId" ${logic.rename-to} ptd_pbp_aug_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDPbpNumberSeptId" ${logic.rename-to} ptd_pbp_sept_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDPbpNumberOctId" ${logic.rename-to} ptd_pbp_oct_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDPbpNumberNovId" ${logic.rename-to} ptd_pbp_nov_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDPbpNumberDecId" ${logic.rename-to} ptd_pbp_dec_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDSegmentNumberJanId" ${logic.rename-to} ptd_sgmt_jan_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDSegmentNumberFebId" ${logic.rename-to} ptd_sgmt_feb_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDSegmentNumberMarId" ${logic.rename-to} ptd_sgmt_mar_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDSegmentNumberAprId" ${logic.rename-to} ptd_sgmt_apr_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDSegmentNumberMayId" ${logic.rename-to} ptd_sgmt_may_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDSegmentNumberJunId" ${logic.rename-to} ptd_sgmt_jun_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDSegmentNumberJulId" ${logic.rename-to} ptd_sgmt_jul_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDSegmentNumberAugId" ${logic.rename-to} ptd_sgmt_aug_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDSegmentNumberSeptId" ${logic.rename-to} ptd_sgmt_sept_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDSegmentNumberOctId" ${logic.rename-to} ptd_sgmt_oct_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDSegmentNumberNovId" ${logic.rename-to} ptd_sgmt_nov_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDSegmentNumberDecId" ${logic.rename-to} ptd_sgmt_dec_id; -alter table public.beneficiaries ${logic.alter-rename-column} "partDRetireeDrugSubsidyJanInd" ${logic.rename-to} rds_jan_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "partDRetireeDrugSubsidyFebInd" ${logic.rename-to} rds_feb_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "partDRetireeDrugSubsidyMarInd" ${logic.rename-to} rds_mar_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "partDRetireeDrugSubsidyAprInd" ${logic.rename-to} rds_apr_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "partDRetireeDrugSubsidyMayInd" ${logic.rename-to} rds_may_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "partDRetireeDrugSubsidyJunInd" ${logic.rename-to} rds_jun_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "partDRetireeDrugSubsidyJulInd" ${logic.rename-to} rds_jul_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "partDRetireeDrugSubsidyAugInd" ${logic.rename-to} rds_aug_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "partDRetireeDrugSubsidySeptInd" ${logic.rename-to} rds_sept_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "partDRetireeDrugSubsidyOctInd" ${logic.rename-to} rds_oct_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "partDRetireeDrugSubsidyNovInd" ${logic.rename-to} rds_nov_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "partDRetireeDrugSubsidyDecInd" ${logic.rename-to} rds_dec_ind; -alter table public.beneficiaries ${logic.alter-rename-column} "medicaidDualEligibilityJanCode" ${logic.rename-to} meta_dual_elgbl_stus_jan_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicaidDualEligibilityFebCode" ${logic.rename-to} meta_dual_elgbl_stus_feb_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicaidDualEligibilityMarCode" ${logic.rename-to} meta_dual_elgbl_stus_mar_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicaidDualEligibilityAprCode" ${logic.rename-to} meta_dual_elgbl_stus_apr_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicaidDualEligibilityMayCode" ${logic.rename-to} meta_dual_elgbl_stus_may_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicaidDualEligibilityJunCode" ${logic.rename-to} meta_dual_elgbl_stus_jun_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicaidDualEligibilityJulCode" ${logic.rename-to} meta_dual_elgbl_stus_jul_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicaidDualEligibilityAugCode" ${logic.rename-to} meta_dual_elgbl_stus_aug_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicaidDualEligibilitySeptCode" ${logic.rename-to} meta_dual_elgbl_stus_sept_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicaidDualEligibilityOctCode" ${logic.rename-to} meta_dual_elgbl_stus_oct_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicaidDualEligibilityNovCode" ${logic.rename-to} meta_dual_elgbl_stus_nov_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "medicaidDualEligibilityDecCode" ${logic.rename-to} meta_dual_elgbl_stus_dec_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partDLowIncomeCostShareGroupJanCode" ${logic.rename-to} cst_shr_grp_jan_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partDLowIncomeCostShareGroupFebCode" ${logic.rename-to} cst_shr_grp_feb_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partDLowIncomeCostShareGroupMarCode" ${logic.rename-to} cst_shr_grp_mar_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partDLowIncomeCostShareGroupAprCode" ${logic.rename-to} cst_shr_grp_apr_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partDLowIncomeCostShareGroupMayCode" ${logic.rename-to} cst_shr_grp_may_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partDLowIncomeCostShareGroupJunCode" ${logic.rename-to} cst_shr_grp_jun_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partDLowIncomeCostShareGroupJulCode" ${logic.rename-to} cst_shr_grp_jul_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partDLowIncomeCostShareGroupAugCode" ${logic.rename-to} cst_shr_grp_aug_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partDLowIncomeCostShareGroupSeptCode" ${logic.rename-to} cst_shr_grp_sept_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partDLowIncomeCostShareGroupOctCode" ${logic.rename-to} cst_shr_grp_oct_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partDLowIncomeCostShareGroupNovCode" ${logic.rename-to} cst_shr_grp_nov_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "partDLowIncomeCostShareGroupDecCode" ${logic.rename-to} cst_shr_grp_dec_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "derivedMailingAddress1" ${logic.rename-to} drvd_line_1_adr; -alter table public.beneficiaries ${logic.alter-rename-column} "derivedMailingAddress2" ${logic.rename-to} drvd_line_2_adr; -alter table public.beneficiaries ${logic.alter-rename-column} "derivedMailingAddress3" ${logic.rename-to} drvd_line_3_adr; -alter table public.beneficiaries ${logic.alter-rename-column} "derivedMailingAddress4" ${logic.rename-to} drvd_line_4_adr; -alter table public.beneficiaries ${logic.alter-rename-column} "derivedMailingAddress5" ${logic.rename-to} drvd_line_5_adr; -alter table public.beneficiaries ${logic.alter-rename-column} "derivedMailingAddress6" ${logic.rename-to} drvd_line_6_adr; -alter table public.beneficiaries ${logic.alter-rename-column} "derivedCityName" ${logic.rename-to} city_name; -alter table public.beneficiaries ${logic.alter-rename-column} "derivedStateCode" ${logic.rename-to} state_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "derivedZipCode" ${logic.rename-to} state_cnty_zip_cd; -alter table public.beneficiaries ${logic.alter-rename-column} "beneLinkKey" ${logic.rename-to} bene_link_key; - --- psql only -${logic.psql-only-alter} table public."Beneficiaries_pkey" rename to beneficiaries_pkey; - --- hsql only -${logic.hsql-only-alter} table public.beneficiaries add constraint beneficiaries_pkey primary key (bene_id); - --- both psql and hsql support non-primary key index renaming -ALTER INDEX "Beneficiaries_hicn_idx" RENAME TO beneficiaries_hicn_idx; -ALTER INDEX "Beneficiaries_mbi_hash_idx" RENAME TO beneficiaries_mbi_hash_idx; -ALTER INDEX "Beneficiaries_partd_contract_number_apr_id_idx" RENAME TO beneficiaries_partd_contract_number_apr_id_idx; -ALTER INDEX "Beneficiaries_partd_contract_number_aug_id_idx" RENAME TO beneficiaries_partd_contract_number_aug_id_idx; -ALTER INDEX "Beneficiaries_partd_contract_number_dec_id_idx" RENAME TO beneficiaries_partd_contract_number_dec_id_idx; -ALTER INDEX "Beneficiaries_partd_contract_number_feb_id_idx" RENAME TO beneficiaries_partd_contract_number_feb_id_idx; -ALTER INDEX "Beneficiaries_partd_contract_number_jan_id_idx" RENAME TO beneficiaries_partd_contract_number_jan_id_idx; -ALTER INDEX "Beneficiaries_partd_contract_number_jul_id_idx" RENAME TO beneficiaries_partd_contract_number_jul_id_idx; -ALTER INDEX "Beneficiaries_partd_contract_number_jun_id_idx" RENAME TO beneficiaries_partd_contract_number_jun_id_idx; -ALTER INDEX "Beneficiaries_partd_contract_number_mar_id_idx" RENAME TO beneficiaries_partd_contract_number_mar_id_idx; -ALTER INDEX "Beneficiaries_partd_contract_number_may_id_idx" RENAME TO beneficiaries_partd_contract_number_may_id_idx; -ALTER INDEX "Beneficiaries_partd_contract_number_nov_id_idx" RENAME TO beneficiaries_partd_contract_number_nov_id_idx; -ALTER INDEX "Beneficiaries_partd_contract_number_oct_id_idx" RENAME TO beneficiaries_partd_contract_number_oct_id_idx; -ALTER INDEX "Beneficiaries_partd_contract_number_sept_id_idx" RENAME TO beneficiaries_partd_contract_number_sept_id_idx; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V41__Table_column_rename_CarrierClaims.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V41__Table_column_rename_CarrierClaims.sql deleted file mode 100644 index 438b419b33..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V41__Table_column_rename_CarrierClaims.sql +++ /dev/null @@ -1,144 +0,0 @@ --- The V40 through V52 migrations rename our tables and columns for CCW-sourced data, such that: --- 1. We follow PostgreSQL's general snake_case naming conventions, to improve the developer experience: DB --- object names won't have to be quoted all over the place, anymore. --- 2. Column names match those in our upstream source system, the CCW, to improve traceability as data flows --- through our systems. --- 3. Rename the "parentXXX" foreign key columns to instead have names that match their target column. - --- Rename tables and table columns; syntax: --- --- psql: alter table public.beneficiaries rename column "beneficiaryId" to bene_id; --- hsql: alter table public.beneficiaries alter column "beneficiaryId" rename to bene_id; --- --- ${logic.alter-rename-column} --- psql: "rename column" --- hsql: "alter column" --- --- ${logic.rename-to} --- psql: "to" --- hsql: "rename to" --- --- CarrierClaims to carrier_claims --- -alter table public."CarrierClaims" rename to carrier_claims; -alter table public.carrier_claims ${logic.alter-rename-column} "claimId" ${logic.rename-to} clm_id; -alter table public.carrier_claims ${logic.alter-rename-column} "beneficiaryId" ${logic.rename-to} bene_id; -alter table public.carrier_claims ${logic.alter-rename-column} "claimGroupId" ${logic.rename-to} clm_grp_id; -alter table public.carrier_claims ${logic.alter-rename-column} lastupdated ${logic.rename-to} last_updated; -alter table public.carrier_claims ${logic.alter-rename-column} "dateFrom" ${logic.rename-to} clm_from_dt; -alter table public.carrier_claims ${logic.alter-rename-column} "dateThrough" ${logic.rename-to} clm_thru_dt; -alter table public.carrier_claims ${logic.alter-rename-column} "clinicalTrialNumber" ${logic.rename-to} clm_clncl_tril_num; -alter table public.carrier_claims ${logic.alter-rename-column} "claimDispositionCode" ${logic.rename-to} clm_disp_cd; -alter table public.carrier_claims ${logic.alter-rename-column} "paymentAmount" ${logic.rename-to} clm_pmt_amt; -alter table public.carrier_claims ${logic.alter-rename-column} "claimCarrierControlNumber" ${logic.rename-to} carr_clm_cntl_num; -alter table public.carrier_claims ${logic.alter-rename-column} "claimEntryCode" ${logic.rename-to} carr_clm_entry_cd; -alter table public.carrier_claims ${logic.alter-rename-column} "hcpcsYearCode" ${logic.rename-to} carr_clm_hcpcs_yr_cd; -alter table public.carrier_claims ${logic.alter-rename-column} "paymentDenialCode" ${logic.rename-to} carr_clm_pmt_dnl_cd; -alter table public.carrier_claims ${logic.alter-rename-column} "providerAssignmentIndicator" ${logic.rename-to} carr_clm_prvdr_asgnmt_ind_sw; -alter table public.carrier_claims ${logic.alter-rename-column} "referringProviderIdNumber" ${logic.rename-to} carr_clm_rfrng_pin_num; -alter table public.carrier_claims ${logic.alter-rename-column} "carrierNumber" ${logic.rename-to} carr_num; -alter table public.carrier_claims ${logic.alter-rename-column} "finalAction" ${logic.rename-to} final_action; -alter table public.carrier_claims ${logic.alter-rename-column} "allowedChargeAmount" ${logic.rename-to} nch_carr_clm_alowd_amt; -alter table public.carrier_claims ${logic.alter-rename-column} "submittedChargeAmount" ${logic.rename-to} nch_carr_clm_sbmtd_chrg_amt; -alter table public.carrier_claims ${logic.alter-rename-column} "beneficiaryPaymentAmount" ${logic.rename-to} nch_clm_bene_pmt_amt; -alter table public.carrier_claims ${logic.alter-rename-column} "providerPaymentAmount" ${logic.rename-to} nch_clm_prvdr_pmt_amt; -alter table public.carrier_claims ${logic.alter-rename-column} "beneficiaryPartBDeductAmount" ${logic.rename-to} carr_clm_cash_ddctbl_apld_amt; -alter table public.carrier_claims ${logic.alter-rename-column} "claimTypeCode" ${logic.rename-to} nch_clm_type_cd; -alter table public.carrier_claims ${logic.alter-rename-column} "nearLineRecordIdCode" ${logic.rename-to} nch_near_line_rec_ident_cd; -alter table public.carrier_claims ${logic.alter-rename-column} "primaryPayerPaidAmount" ${logic.rename-to} carr_clm_prmry_pyr_pd_amt; -alter table public.carrier_claims ${logic.alter-rename-column} "weeklyProcessDate" ${logic.rename-to} nch_wkly_proc_dt; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosisPrincipalCode" ${logic.rename-to} prncpal_dgns_cd; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosisPrincipalCodeVersion" ${logic.rename-to} prncpal_dgns_vrsn_cd; -alter table public.carrier_claims ${logic.alter-rename-column} "referringPhysicianNpi" ${logic.rename-to} rfr_physn_npi; -alter table public.carrier_claims ${logic.alter-rename-column} "referringPhysicianUpin" ${logic.rename-to} rfr_physn_upin; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis1Code" ${logic.rename-to} icd_dgns_cd1; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis2Code" ${logic.rename-to} icd_dgns_cd2; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis3Code" ${logic.rename-to} icd_dgns_cd3; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis4Code" ${logic.rename-to} icd_dgns_cd4; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis5Code" ${logic.rename-to} icd_dgns_cd5; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis6Code" ${logic.rename-to} icd_dgns_cd6; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis7Code" ${logic.rename-to} icd_dgns_cd7; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis8Code" ${logic.rename-to} icd_dgns_cd8; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis9Code" ${logic.rename-to} icd_dgns_cd9; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis10Code" ${logic.rename-to} icd_dgns_cd10; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis11Code" ${logic.rename-to} icd_dgns_cd11; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis12Code" ${logic.rename-to} icd_dgns_cd12; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis1CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd1; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis2CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd2; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis3CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd3; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis4CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd4; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis5CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd5; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis6CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd6; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis7CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd7; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis8CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd8; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis9CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd9; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis10CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd10; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis11CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd11; -alter table public.carrier_claims ${logic.alter-rename-column} "diagnosis12CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd12; --- --- CarrierClaimLines to carrier_claim_lines --- -alter table public."CarrierClaimLines" rename to carrier_claim_lines; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "parentClaim" ${logic.rename-to} clm_id; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "lineNumber" ${logic.rename-to} line_num; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "paymentAmount" ${logic.rename-to} line_nch_pmt_amt; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "firstExpenseDate" ${logic.rename-to} line_1st_expns_dt; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "allowedChargeAmount" ${logic.rename-to} line_alowd_chrg_amt; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "beneficiaryPaymentAmount" ${logic.rename-to} line_bene_pmt_amt; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "primaryPayerCode" ${logic.rename-to} line_bene_prmry_pyr_cd; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "primaryPayerPaidAmount" ${logic.rename-to} line_bene_prmry_pyr_pd_amt; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "beneficiaryPartBDeductAmount" ${logic.rename-to} line_bene_ptb_ddctbl_amt; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "cmsServiceTypeCode" ${logic.rename-to} line_cms_type_srvc_cd; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "coinsuranceAmount" ${logic.rename-to} line_coinsrnc_amt; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "hctHgbTestResult" ${logic.rename-to} line_hct_hgb_rslt_num; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "hctHgbTestTypeCode" ${logic.rename-to} line_hct_hgb_type_cd; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "diagnosisCode" ${logic.rename-to} line_icd_dgns_cd; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "diagnosisCodeVersion" ${logic.rename-to} line_icd_dgns_vrsn_cd; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "lastExpenseDate" ${logic.rename-to} line_last_expns_dt; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "nationalDrugCode" ${logic.rename-to} line_ndc_cd; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "placeOfServiceCode" ${logic.rename-to} line_place_of_srvc_cd; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "paymentCode" ${logic.rename-to} line_pmt_80_100_cd; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "processingIndicatorCode" ${logic.rename-to} line_prcsg_ind_cd; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "submittedChargeAmount" ${logic.rename-to} line_sbmtd_chrg_amt; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "serviceDeductibleCode" ${logic.rename-to} line_service_deductible; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "serviceCount" ${logic.rename-to} line_srvc_cnt; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "mtusCode" ${logic.rename-to} carr_line_mtus_cd; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "mtusCount" ${logic.rename-to} carr_line_mtus_cnt; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "betosCode" ${logic.rename-to} betos_cd; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "anesthesiaUnitCount" ${logic.rename-to} carr_line_ansthsa_unit_cnt; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "cliaLabNumber" ${logic.rename-to} carr_line_clia_lab_num; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "linePricingLocalityCode" ${logic.rename-to} carr_line_prcng_lclty_cd; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "providerTypeCode" ${logic.rename-to} carr_line_prvdr_type_cd; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "reducedPaymentPhysicianAsstCode" ${logic.rename-to} carr_line_rdcd_pmt_phys_astn_c; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "rxNumber" ${logic.rename-to} carr_line_rx_num; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "performingProviderIdNumber" ${logic.rename-to} carr_prfrng_pin_num; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "hcpcsInitialModifierCode" ${logic.rename-to} hcpcs_1st_mdfr_cd; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "hcpcsSecondModifierCode" ${logic.rename-to} hcpcs_2nd_mdfr_cd; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "hcpcsCode" ${logic.rename-to} hcpcs_cd; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "hpsaScarcityCode" ${logic.rename-to} hpsa_scrcty_ind_cd; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "organizationNpi" ${logic.rename-to} org_npi_num; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "performingPhysicianNpi" ${logic.rename-to} prf_physn_npi; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "performingPhysicianUpin" ${logic.rename-to} prf_physn_upin; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "providerParticipatingIndCode" ${logic.rename-to} prtcptng_ind_cd; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "providerSpecialityCode" ${logic.rename-to} prvdr_spclty; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "providerStateCode" ${logic.rename-to} prvdr_state_cd; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "providerZipCode" ${logic.rename-to} prvdr_zip; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "providerTaxNumber" ${logic.rename-to} tax_num; -alter table public.carrier_claim_lines ${logic.alter-rename-column} "providerPaymentAmount" ${logic.rename-to} line_prvdr_pmt_amt; - --- psql only -${logic.psql-only-alter} index if exists public."CarrierClaimLines_pkey" rename to carrier_claim_lines_pkey; -${logic.psql-only-alter} index if exists public."CarrierClaims_pkey" rename to carrier_claims_pkey; - -${logic.psql-only-alter} table public.carrier_claim_lines rename constraint "CarrierClaimLines_parentClaim_to_CarrierClaims" to carrier_claim_lines_clm_id_to_carrier_claims; -${logic.psql-only-alter} table public.carrier_claims rename constraint "CarrierClaims_beneficiaryId_to_Beneficiaries" to carrier_claims_bene_id_to_beneficiaries; - --- hsql only -${logic.hsql-only-alter} table public.carrier_claim_lines add constraint carrier_claim_lines_pkey primary key (clm_id, line_num); -${logic.hsql-only-alter} table public.carrier_claims add constraint carrier_claims_pkey primary key (clm_id); - -${logic.hsql-only-alter} table public.carrier_claim_lines ADD CONSTRAINT carrier_claim_lines_clm_id_to_carrier_claims FOREIGN KEY (clm_id) REFERENCES public.carrier_claims (clm_id); -${logic.hsql-only-alter} table public.carrier_claims ADD CONSTRAINT carrier_claims_bene_id_to_beneficiaries FOREIGN KEY (bene_id) REFERENCES public.beneficiaries (bene_id); - --- both psql and hsql support non-primary key index renaming -ALTER INDEX "CarrierClaims_beneficiaryId_idx" RENAME TO carrier_claims_bene_id_idx; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V42__Table_column_rename_DMEClaims.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V42__Table_column_rename_DMEClaims.sql deleted file mode 100644 index 0e6bc8c67b..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V42__Table_column_rename_DMEClaims.sql +++ /dev/null @@ -1,138 +0,0 @@ --- The V40 through V52 migrations rename our tables and columns for CCW-sourced data, such that: --- 1. We follow PostgreSQL's general snake_case naming conventions, to improve the developer experience: DB --- object names won't have to be quoted all over the place, anymore. --- 2. Column names match those in our upstream source system, the CCW, to improve traceability as data flows --- through our systems. --- 3. Rename the "parentXXX" foreign key columns to instead have names that match their target column. - --- Rename tables and table columns; syntax: --- --- psql: alter table public.beneficiaries rename column "beneficiaryId" to bene_id; --- hsql: alter table public.beneficiaries alter column "beneficiaryId" rename to bene_id; --- --- ${logic.alter-rename-column} --- psql: "rename column" --- hsql: "alter column" --- --- ${logic.rename-to} --- psql: "to" --- hsql: "rename to" --- --- DMEClaims to dme_claims --- -alter table public."DMEClaims" rename to dme_claims; -alter table public.dme_claims ${logic.alter-rename-column} "claimId" ${logic.rename-to} clm_id; -alter table public.dme_claims ${logic.alter-rename-column} "beneficiaryId" ${logic.rename-to} bene_id; -alter table public.dme_claims ${logic.alter-rename-column} "claimGroupId" ${logic.rename-to} clm_grp_id; -alter table public.dme_claims ${logic.alter-rename-column} lastupdated ${logic.rename-to} last_updated; -alter table public.dme_claims ${logic.alter-rename-column} "dateFrom" ${logic.rename-to} clm_from_dt; -alter table public.dme_claims ${logic.alter-rename-column} "dateThrough" ${logic.rename-to} clm_thru_dt; -alter table public.dme_claims ${logic.alter-rename-column} "claimDispositionCode" ${logic.rename-to} clm_disp_cd; -alter table public.dme_claims ${logic.alter-rename-column} "paymentAmount" ${logic.rename-to} clm_pmt_amt; -alter table public.dme_claims ${logic.alter-rename-column} "clinicalTrialNumber" ${logic.rename-to} clm_clncl_tril_num; -alter table public.dme_claims ${logic.alter-rename-column} "carrierNumber" ${logic.rename-to} carr_num; -alter table public.dme_claims ${logic.alter-rename-column} "claimCarrierControlNumber" ${logic.rename-to} carr_clm_cntl_num; -alter table public.dme_claims ${logic.alter-rename-column} "claimEntryCode" ${logic.rename-to} carr_clm_entry_cd; -alter table public.dme_claims ${logic.alter-rename-column} "providerAssignmentIndicator" ${logic.rename-to} carr_clm_prvdr_asgnmt_ind_sw; -alter table public.dme_claims ${logic.alter-rename-column} "hcpcsYearCode" ${logic.rename-to} carr_clm_hcpcs_yr_cd; -alter table public.dme_claims ${logic.alter-rename-column} "paymentDenialCode" ${logic.rename-to} carr_clm_pmt_dnl_cd; -alter table public.dme_claims ${logic.alter-rename-column} "allowedChargeAmount" ${logic.rename-to} nch_carr_clm_alowd_amt; -alter table public.dme_claims ${logic.alter-rename-column} "submittedChargeAmount" ${logic.rename-to} nch_carr_clm_sbmtd_chrg_amt; -alter table public.dme_claims ${logic.alter-rename-column} "beneficiaryPartBDeductAmount" ${logic.rename-to} carr_clm_cash_ddctbl_apld_amt; -alter table public.dme_claims ${logic.alter-rename-column} "beneficiaryPaymentAmount" ${logic.rename-to} nch_clm_bene_pmt_amt; -alter table public.dme_claims ${logic.alter-rename-column} "claimTypeCode" ${logic.rename-to} nch_clm_type_cd; -alter table public.dme_claims ${logic.alter-rename-column} "nearLineRecordIdCode" ${logic.rename-to} nch_near_line_rec_ident_cd; -alter table public.dme_claims ${logic.alter-rename-column} "weeklyProcessDate" ${logic.rename-to} nch_wkly_proc_dt; -alter table public.dme_claims ${logic.alter-rename-column} "primaryPayerPaidAmount" ${logic.rename-to} carr_clm_prmry_pyr_pd_amt; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosisPrincipalCode" ${logic.rename-to} prncpal_dgns_cd; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosisPrincipalCodeVersion" ${logic.rename-to} prncpal_dgns_vrsn_cd; -alter table public.dme_claims ${logic.alter-rename-column} "providerPaymentAmount" ${logic.rename-to} nch_clm_prvdr_pmt_amt; -alter table public.dme_claims ${logic.alter-rename-column} "referringPhysicianNpi" ${logic.rename-to} rfr_physn_npi; -alter table public.dme_claims ${logic.alter-rename-column} "referringPhysicianUpin" ${logic.rename-to} rfr_physn_upin; -alter table public.dme_claims ${logic.alter-rename-column} "finalAction" ${logic.rename-to} final_action; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis1Code" ${logic.rename-to} icd_dgns_cd1; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis2Code" ${logic.rename-to} icd_dgns_cd2; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis3Code" ${logic.rename-to} icd_dgns_cd3; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis4Code" ${logic.rename-to} icd_dgns_cd4; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis5Code" ${logic.rename-to} icd_dgns_cd5; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis6Code" ${logic.rename-to} icd_dgns_cd6; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis7Code" ${logic.rename-to} icd_dgns_cd7; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis8Code" ${logic.rename-to} icd_dgns_cd8; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis9Code" ${logic.rename-to} icd_dgns_cd9; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis10Code" ${logic.rename-to} icd_dgns_cd10; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis11Code" ${logic.rename-to} icd_dgns_cd11; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis12Code" ${logic.rename-to} icd_dgns_cd12; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis1CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd1; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis2CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd2; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis3CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd3; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis4CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd4; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis5CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd5; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis6CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd6; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis7CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd7; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis8CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd8; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis9CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd9; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis10CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd10; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis11CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd11; -alter table public.dme_claims ${logic.alter-rename-column} "diagnosis12CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd12; --- --- DMEClaimLines to dme_claim_lines --- -alter table public."DMEClaimLines" rename to dme_claim_lines; -alter table public.dme_claim_lines ${logic.alter-rename-column} "parentClaim" ${logic.rename-to} clm_id; -alter table public.dme_claim_lines ${logic.alter-rename-column} "lineNumber" ${logic.rename-to} line_num; -alter table public.dme_claim_lines ${logic.alter-rename-column} "paymentAmount" ${logic.rename-to} line_nch_pmt_amt; -alter table public.dme_claim_lines ${logic.alter-rename-column} "submittedChargeAmount" ${logic.rename-to} line_sbmtd_chrg_amt; -alter table public.dme_claim_lines ${logic.alter-rename-column} "allowedChargeAmount" ${logic.rename-to} line_alowd_chrg_amt; -alter table public.dme_claim_lines ${logic.alter-rename-column} "beneficiaryPartBDeductAmount" ${logic.rename-to} line_bene_ptb_ddctbl_amt; -alter table public.dme_claim_lines ${logic.alter-rename-column} "beneficiaryPaymentAmount" ${logic.rename-to} line_bene_pmt_amt; -alter table public.dme_claim_lines ${logic.alter-rename-column} "nationalDrugCode" ${logic.rename-to} line_ndc_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "cmsServiceTypeCode" ${logic.rename-to} line_cms_type_srvc_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "coinsuranceAmount" ${logic.rename-to} line_coinsrnc_amt; -alter table public.dme_claim_lines ${logic.alter-rename-column} "diagnosisCode" ${logic.rename-to} line_icd_dgns_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "diagnosisCodeVersion" ${logic.rename-to} line_icd_dgns_vrsn_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "firstExpenseDate" ${logic.rename-to} line_1st_expns_dt; -alter table public.dme_claim_lines ${logic.alter-rename-column} "hctHgbTestResult" ${logic.rename-to} line_hct_hgb_rslt_num; -alter table public.dme_claim_lines ${logic.alter-rename-column} "hctHgbTestTypeCode" ${logic.rename-to} line_hct_hgb_type_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "lastExpenseDate" ${logic.rename-to} line_last_expns_dt; -alter table public.dme_claim_lines ${logic.alter-rename-column} "paymentCode" ${logic.rename-to} line_pmt_80_100_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "placeOfServiceCode" ${logic.rename-to} line_place_of_srvc_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "primaryPayerAllowedChargeAmount" ${logic.rename-to} line_prmry_alowd_chrg_amt; -alter table public.dme_claim_lines ${logic.alter-rename-column} "primaryPayerCode" ${logic.rename-to} line_bene_prmry_pyr_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "processingIndicatorCode" ${logic.rename-to} line_prcsg_ind_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "purchasePriceAmount" ${logic.rename-to} line_dme_prchs_price_amt; -alter table public.dme_claim_lines ${logic.alter-rename-column} "serviceCount" ${logic.rename-to} line_srvc_cnt; -alter table public.dme_claim_lines ${logic.alter-rename-column} "serviceDeductibleCode" ${logic.rename-to} line_service_deductible; -alter table public.dme_claim_lines ${logic.alter-rename-column} "betosCode" ${logic.rename-to} betos_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "hcpcsCode" ${logic.rename-to} hcpcs_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "hcpcsFourthModifierCode" ${logic.rename-to} hcpcs_4th_mdfr_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "hcpcsInitialModifierCode" ${logic.rename-to} hcpcs_1st_mdfr_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "hcpcsSecondModifierCode" ${logic.rename-to} hcpcs_2nd_mdfr_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "hcpcsThirdModifierCode" ${logic.rename-to} hcpcs_3rd_mdfr_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "mtusCode" ${logic.rename-to} dmerc_line_mtus_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "mtusCount" ${logic.rename-to} dmerc_line_mtus_cnt; -alter table public.dme_claim_lines ${logic.alter-rename-column} "pricingStateCode" ${logic.rename-to} dmerc_line_prcng_state_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "screenSavingsAmount" ${logic.rename-to} dmerc_line_scrn_svgs_amt; -alter table public.dme_claim_lines ${logic.alter-rename-column} "supplierTypeCode" ${logic.rename-to} dmerc_line_supplr_type_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "primaryPayerPaidAmount" ${logic.rename-to} line_bene_prmry_pyr_pd_amt; -alter table public.dme_claim_lines ${logic.alter-rename-column} "providerBillingNumber" ${logic.rename-to} prvdr_num; -alter table public.dme_claim_lines ${logic.alter-rename-column} "providerNPI" ${logic.rename-to} prvdr_npi; -alter table public.dme_claim_lines ${logic.alter-rename-column} "providerSpecialityCode" ${logic.rename-to} prvdr_spclty; -alter table public.dme_claim_lines ${logic.alter-rename-column} "providerStateCode" ${logic.rename-to} prvdr_state_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "providerTaxNumber" ${logic.rename-to} tax_num; -alter table public.dme_claim_lines ${logic.alter-rename-column} "providerParticipatingIndCode" ${logic.rename-to} prtcptng_ind_cd; -alter table public.dme_claim_lines ${logic.alter-rename-column} "providerPaymentAmount" ${logic.rename-to} line_prvdr_pmt_amt; - -${logic.psql-only-alter} index if exists public."DMEClaimLines_pkey" rename to dme_claim_lines_pkey; -${logic.psql-only-alter} index if exists public."DMEClaims_pkey" rename to dme_claims_pkey; - -${logic.psql-only-alter} table public.dme_claim_lines rename constraint "DMEClaimLines_parentClaim_to_DMEClaims" to dme_claim_lines_clm_id_to_dme_claims; -${logic.psql-only-alter} table public.dme_claims rename constraint "DMEClaims_beneficiaryId_to_Beneficiaries" to dme_claims_bene_id_to_beneficiaries; - -${logic.hsql-only-alter} table public.dme_claim_lines add constraint dme_claim_lines_pkey primary key (clm_id, line_num); -${logic.hsql-only-alter} table public.dme_claims add constraint dme_claims_pkey primary key (clm_id); - -${logic.hsql-only-alter} table public.dme_claim_lines ADD CONSTRAINT dme_claim_lines_clm_id_to_dme_claims FOREIGN KEY (clm_id) REFERENCES public.dme_claims (clm_id); -${logic.hsql-only-alter} table public.dme_claims ADD CONSTRAINT dme_claims_bene_id_to_beneficiaries FOREIGN KEY (bene_id) REFERENCES public.beneficiaries(bene_id); - --- both psql and hsql support non-primary key index renaming -ALTER INDEX "DMEClaims_beneficiaryId_idx" RENAME TO dme_claims_bene_id_idx; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V43__Table_column_rename_HHAClaims.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V43__Table_column_rename_HHAClaims.sql deleted file mode 100644 index 58c5c2be3d..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V43__Table_column_rename_HHAClaims.sql +++ /dev/null @@ -1,176 +0,0 @@ --- The V40 through V52 migrations rename our tables and columns for CCW-sourced data, such that: --- 1. We follow PostgreSQL's general snake_case naming conventions, to improve the developer experience: DB --- object names won't have to be quoted all over the place, anymore. --- 2. Column names match those in our upstream source system, the CCW, to improve traceability as data flows --- through our systems. --- 3. Rename the "parentXXX" foreign key columns to instead have names that match their target column. - --- Rename tables and table columns; syntax: --- --- psql: alter table public.beneficiaries rename column "beneficiaryId" to bene_id; --- hsql: alter table public.beneficiaries alter column "beneficiaryId" rename to bene_id; --- --- ${logic.alter-rename-column} --- psql: "rename column" --- hsql: "alter column" --- --- ${logic.rename-to} --- psql: "to" --- hsql: "rename to" --- --- HHAClaims to hha_claims --- -alter table public."HHAClaims" rename to hha_claims; -alter table public.hha_claims ${logic.alter-rename-column} "claimId" ${logic.rename-to} clm_id; -alter table public.hha_claims ${logic.alter-rename-column} "beneficiaryId" ${logic.rename-to} bene_id; -alter table public.hha_claims ${logic.alter-rename-column} "claimGroupId" ${logic.rename-to} clm_grp_id; -alter table public.hha_claims ${logic.alter-rename-column} lastupdated ${logic.rename-to} last_updated; -alter table public.hha_claims ${logic.alter-rename-column} "dateFrom" ${logic.rename-to} clm_from_dt; -alter table public.hha_claims ${logic.alter-rename-column} "dateThrough" ${logic.rename-to} clm_thru_dt; -alter table public.hha_claims ${logic.alter-rename-column} "paymentAmount" ${logic.rename-to} clm_pmt_amt; -alter table public.hha_claims ${logic.alter-rename-column} "careStartDate" ${logic.rename-to} clm_admsn_dt; -alter table public.hha_claims ${logic.alter-rename-column} "claimFacilityTypeCode" ${logic.rename-to} clm_fac_type_cd; -alter table public.hha_claims ${logic.alter-rename-column} "claimFrequencyCode" ${logic.rename-to} clm_freq_cd; -alter table public.hha_claims ${logic.alter-rename-column} "claimLUPACode" ${logic.rename-to} clm_hha_lupa_ind_cd; -alter table public.hha_claims ${logic.alter-rename-column} "claimReferralCode" ${logic.rename-to} clm_hha_rfrl_cd; -alter table public.hha_claims ${logic.alter-rename-column} "totalVisitCount" ${logic.rename-to} clm_hha_tot_visit_cnt; -alter table public.hha_claims ${logic.alter-rename-column} "claimNonPaymentReasonCode" ${logic.rename-to} clm_mdcr_non_pmt_rsn_cd; -alter table public.hha_claims ${logic.alter-rename-column} "prospectivePaymentCode" ${logic.rename-to} clm_pps_ind_cd; -alter table public.hha_claims ${logic.alter-rename-column} "claimServiceClassificationTypeCode" ${logic.rename-to} clm_srvc_clsfctn_type_cd; -alter table public.hha_claims ${logic.alter-rename-column} "fiscalIntermediaryClaimProcessDate" ${logic.rename-to} fi_clm_proc_dt; -alter table public.hha_claims ${logic.alter-rename-column} "fiDocumentClaimControlNumber" ${logic.rename-to} fi_doc_clm_cntl_num; -alter table public.hha_claims ${logic.alter-rename-column} "fiscalIntermediaryNumber" ${logic.rename-to} fi_num; -alter table public.hha_claims ${logic.alter-rename-column} "fiOriginalClaimControlNumber" ${logic.rename-to} fi_orig_clm_cntl_num; -alter table public.hha_claims ${logic.alter-rename-column} "finalAction" ${logic.rename-to} final_action; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternalFirstCode" ${logic.rename-to} fst_dgns_e_cd; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternalFirstCodeVersion" ${logic.rename-to} fst_dgns_e_vrsn_cd; -alter table public.hha_claims ${logic.alter-rename-column} "claimTypeCode" ${logic.rename-to} nch_clm_type_cd; -alter table public.hha_claims ${logic.alter-rename-column} "nearLineRecordIdCode" ${logic.rename-to} nch_near_line_rec_ident_cd; -alter table public.hha_claims ${logic.alter-rename-column} "claimPrimaryPayerCode" ${logic.rename-to} nch_prmry_pyr_cd; -alter table public.hha_claims ${logic.alter-rename-column} "primaryPayerPaidAmount" ${logic.rename-to} nch_prmry_pyr_clm_pd_amt; -alter table public.hha_claims ${logic.alter-rename-column} "weeklyProcessDate" ${logic.rename-to} nch_wkly_proc_dt; -alter table public.hha_claims ${logic.alter-rename-column} "organizationNpi" ${logic.rename-to} org_npi_num; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisPrincipalCode" ${logic.rename-to} prncpal_dgns_cd; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisPrincipalCodeVersion" ${logic.rename-to} prncpal_dgns_vrsn_cd; -alter table public.hha_claims ${logic.alter-rename-column} "providerNumber" ${logic.rename-to} prvdr_num; -alter table public.hha_claims ${logic.alter-rename-column} "providerStateCode" ${logic.rename-to} prvdr_state_cd; -alter table public.hha_claims ${logic.alter-rename-column} "patientDischargeStatusCode" ${logic.rename-to} ptnt_dschrg_stus_cd; -alter table public.hha_claims ${logic.alter-rename-column} "totalChargeAmount" ${logic.rename-to} clm_tot_chrg_amt; -alter table public.hha_claims ${logic.alter-rename-column} "attendingPhysicianNpi" ${logic.rename-to} at_physn_npi; -alter table public.hha_claims ${logic.alter-rename-column} "attendingPhysicianUpin" ${logic.rename-to} at_physn_upin; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis1Code" ${logic.rename-to} icd_dgns_cd1; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis2Code" ${logic.rename-to} icd_dgns_cd2; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis3Code" ${logic.rename-to} icd_dgns_cd3; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis4Code" ${logic.rename-to} icd_dgns_cd4; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis5Code" ${logic.rename-to} icd_dgns_cd5; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis6Code" ${logic.rename-to} icd_dgns_cd6; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis7Code" ${logic.rename-to} icd_dgns_cd7; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis8Code" ${logic.rename-to} icd_dgns_cd8; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis9Code" ${logic.rename-to} icd_dgns_cd9; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis10Code" ${logic.rename-to} icd_dgns_cd10; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis11Code" ${logic.rename-to} icd_dgns_cd11; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis12Code" ${logic.rename-to} icd_dgns_cd12; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis13Code" ${logic.rename-to} icd_dgns_cd13; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis14Code" ${logic.rename-to} icd_dgns_cd14; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis15Code" ${logic.rename-to} icd_dgns_cd15; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis16Code" ${logic.rename-to} icd_dgns_cd16; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis17Code" ${logic.rename-to} icd_dgns_cd17; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis18Code" ${logic.rename-to} icd_dgns_cd18; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis19Code" ${logic.rename-to} icd_dgns_cd19; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis20Code" ${logic.rename-to} icd_dgns_cd20; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis21Code" ${logic.rename-to} icd_dgns_cd21; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis22Code" ${logic.rename-to} icd_dgns_cd22; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis23Code" ${logic.rename-to} icd_dgns_cd23; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis24Code" ${logic.rename-to} icd_dgns_cd24; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis25Code" ${logic.rename-to} icd_dgns_cd25; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal1Code" ${logic.rename-to} icd_dgns_e_cd1; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal2Code" ${logic.rename-to} icd_dgns_e_cd2; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal3Code" ${logic.rename-to} icd_dgns_e_cd3; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal4Code" ${logic.rename-to} icd_dgns_e_cd4; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal5Code" ${logic.rename-to} icd_dgns_e_cd5; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal6Code" ${logic.rename-to} icd_dgns_e_cd6; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal7Code" ${logic.rename-to} icd_dgns_e_cd7; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal8Code" ${logic.rename-to} icd_dgns_e_cd8; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal9Code" ${logic.rename-to} icd_dgns_e_cd9; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal10Code" ${logic.rename-to} icd_dgns_e_cd10; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal11Code" ${logic.rename-to} icd_dgns_e_cd11; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal12Code" ${logic.rename-to} icd_dgns_e_cd12; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal1CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd1; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal2CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd2; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal3CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd3; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal4CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd4; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal5CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd5; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal6CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd6; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal7CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd7; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal8CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd8; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal9CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd9; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal10CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd10; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal11CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd11; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosisExternal12CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd12; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis1CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd1; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis2CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd2; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis3CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd3; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis4CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd4; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis5CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd5; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis6CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd6; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis7CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd7; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis8CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd8; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis9CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd9; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis10CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd10; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis11CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd11; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis12CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd12; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis13CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd13; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis14CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd14; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis15CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd15; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis16CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd16; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis17CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd17; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis18CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd18; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis19CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd19; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis20CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd20; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis21CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd21; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis22CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd22; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis23CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd23; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis24CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd24; -alter table public.hha_claims ${logic.alter-rename-column} "diagnosis25CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd25; --- --- HHAClaimLines to hha_claim_lines --- -alter table public."HHAClaimLines" rename to hha_claim_lines; -alter table public.hha_claim_lines ${logic.alter-rename-column} "parentClaim" ${logic.rename-to} clm_id; -alter table public.hha_claim_lines ${logic.alter-rename-column} "lineNumber" ${logic.rename-to} clm_line_num; -alter table public.hha_claim_lines ${logic.alter-rename-column} "hcpcsCode" ${logic.rename-to} hcpcs_cd; -alter table public.hha_claim_lines ${logic.alter-rename-column} "hcpcsInitialModifierCode" ${logic.rename-to} hcpcs_1st_mdfr_cd; -alter table public.hha_claim_lines ${logic.alter-rename-column} "hcpcsSecondModifierCode" ${logic.rename-to} hcpcs_2nd_mdfr_cd; -alter table public.hha_claim_lines ${logic.alter-rename-column} "revenueCenterRenderingPhysicianNPI" ${logic.rename-to} rndrng_physn_npi; -alter table public.hha_claim_lines ${logic.alter-rename-column} "revenueCenterRenderingPhysicianUPIN" ${logic.rename-to} rndrng_physn_upin; -alter table public.hha_claim_lines ${logic.alter-rename-column} "revenueCenterCode" ${logic.rename-to} rev_cntr; -alter table public.hha_claim_lines ${logic.alter-rename-column} "revenueCenterDate" ${logic.rename-to} rev_cntr_dt; -alter table public.hha_claim_lines ${logic.alter-rename-column} "apcOrHippsCode" ${logic.rename-to} rev_cntr_apc_hipps_cd; -alter table public.hha_claim_lines ${logic.alter-rename-column} "deductibleCoinsuranceCd" ${logic.rename-to} rev_cntr_ddctbl_coinsrnc_cd; -alter table public.hha_claim_lines ${logic.alter-rename-column} "nationalDrugCodeQualifierCode" ${logic.rename-to} rev_cntr_ndc_qty_qlfr_cd; -alter table public.hha_claim_lines ${logic.alter-rename-column} "nationalDrugCodeQuantity" ${logic.rename-to} rev_cntr_ndc_qty; -alter table public.hha_claim_lines ${logic.alter-rename-column} "nonCoveredChargeAmount" ${logic.rename-to} rev_cntr_ncvrd_chrg_amt; -alter table public.hha_claim_lines ${logic.alter-rename-column} "paymentAmount" ${logic.rename-to} rev_cntr_pmt_amt_amt; -alter table public.hha_claim_lines ${logic.alter-rename-column} "paymentMethodCode" ${logic.rename-to} rev_cntr_pmt_mthd_ind_cd; -alter table public.hha_claim_lines ${logic.alter-rename-column} "rateAmount" ${logic.rename-to} rev_cntr_rate_amt; -alter table public.hha_claim_lines ${logic.alter-rename-column} "revCntr1stAnsiCd" ${logic.rename-to} rev_cntr_1st_ansi_cd; -alter table public.hha_claim_lines ${logic.alter-rename-column} "statusCode" ${logic.rename-to} rev_cntr_stus_ind_cd; -alter table public.hha_claim_lines ${logic.alter-rename-column} "totalChargeAmount" ${logic.rename-to} rev_cntr_tot_chrg_amt; -alter table public.hha_claim_lines ${logic.alter-rename-column} "unitCount" ${logic.rename-to} rev_cntr_unit_cnt; - --- psql only -${logic.psql-only-alter} index if exists public."HHAClaimLines_pkey" rename to hha_claim_lines_pkey; -${logic.psql-only-alter} index if exists public."HHAClaims_pkey" rename to hha_claims_pkey; - -${logic.psql-only-alter} table public.hha_claim_lines rename constraint "HHAClaimLines_parentClaim_to_HHAClaims" to hha_claim_lines_clm_id_to_hha_claims; -${logic.psql-only-alter} table public.hha_claims rename constraint "HHAClaims_beneficiaryId_to_Beneficiaries" to hha_claims_bene_id_to_beneficiaries; - --- hsql only -${logic.hsql-only-alter} table public.hha_claim_lines add constraint hha_claim_lines_pkey primary key (clm_id, clm_line_num); -${logic.hsql-only-alter} table public.hha_claims add constraint hha_claims_pkey primary key (clm_id); - -${logic.hsql-only-alter} table public.hha_claim_lines ADD CONSTRAINT hha_claim_lines_clm_id_to_hha_claims FOREIGN KEY (clm_id) REFERENCES public.hha_claims (clm_id); -${logic.hsql-only-alter} table public.hha_claims ADD CONSTRAINT hha_claims_bene_id_to_beneficiaries FOREIGN KEY (bene_id) REFERENCES public.beneficiaries(bene_id); - --- both psql and hsql support non-primary key index renaming -ALTER INDEX "HHAClaims_beneficiaryId_idx" RENAME TO hha_claims_bene_id_idx; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V44__Table_column_rename_HospiceClaims.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V44__Table_column_rename_HospiceClaims.sql deleted file mode 100644 index e70b7f6e5c..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V44__Table_column_rename_HospiceClaims.sql +++ /dev/null @@ -1,174 +0,0 @@ --- The V40 through V52 migrations rename our tables and columns for CCW-sourced data, such that: --- 1. We follow PostgreSQL's general snake_case naming conventions, to improve the developer experience: DB --- object names won't have to be quoted all over the place, anymore. --- 2. Column names match those in our upstream source system, the CCW, to improve traceability as data flows --- through our systems. --- 3. Rename the "parentXXX" foreign key columns to instead have names that match their target column. - --- Rename tables and table columns; syntax: --- --- psql: alter table public.beneficiaries rename column "beneficiaryId" to bene_id; --- hsql: alter table public.beneficiaries alter column "beneficiaryId" rename to bene_id; --- --- ${logic.alter-rename-column} --- psql: "rename column" --- hsql: "alter column" --- --- ${logic.rename-to} --- psql: "to" --- hsql: "rename to" --- --- HospiceClaims to hospice_claims --- -alter table public."HospiceClaims" rename to hospice_claims; -alter table public.hospice_claims ${logic.alter-rename-column} "claimId" ${logic.rename-to} clm_id; -alter table public.hospice_claims ${logic.alter-rename-column} "beneficiaryId" ${logic.rename-to} bene_id; -alter table public.hospice_claims ${logic.alter-rename-column} "claimGroupId" ${logic.rename-to} clm_grp_id; -alter table public.hospice_claims ${logic.alter-rename-column} lastupdated ${logic.rename-to} last_updated; -alter table public.hospice_claims ${logic.alter-rename-column} "dateFrom" ${logic.rename-to} clm_from_dt; -alter table public.hospice_claims ${logic.alter-rename-column} "dateThrough" ${logic.rename-to} clm_thru_dt; -alter table public.hospice_claims ${logic.alter-rename-column} "claimFacilityTypeCode" ${logic.rename-to} clm_fac_type_cd; -alter table public.hospice_claims ${logic.alter-rename-column} "claimFrequencyCode" ${logic.rename-to} clm_freq_cd; -alter table public.hospice_claims ${logic.alter-rename-column} "claimHospiceStartDate" ${logic.rename-to} clm_hospc_start_dt_id; -alter table public.hospice_claims ${logic.alter-rename-column} "claimNonPaymentReasonCode" ${logic.rename-to} clm_mdcr_non_pmt_rsn_cd; -alter table public.hospice_claims ${logic.alter-rename-column} "paymentAmount" ${logic.rename-to} clm_pmt_amt; -alter table public.hospice_claims ${logic.alter-rename-column} "claimServiceClassificationTypeCode" ${logic.rename-to} clm_srvc_clsfctn_type_cd; -alter table public.hospice_claims ${logic.alter-rename-column} "utilizationDayCount" ${logic.rename-to} clm_utlztn_day_cnt; -alter table public.hospice_claims ${logic.alter-rename-column} "attendingPhysicianNpi" ${logic.rename-to} at_physn_npi; -alter table public.hospice_claims ${logic.alter-rename-column} "attendingPhysicianUpin" ${logic.rename-to} at_physn_upin; -alter table public.hospice_claims ${logic.alter-rename-column} "hospicePeriodCount" ${logic.rename-to} bene_hospc_prd_cnt; -alter table public.hospice_claims ${logic.alter-rename-column} "fiscalIntermediaryClaimProcessDate" ${logic.rename-to} fi_clm_proc_dt; -alter table public.hospice_claims ${logic.alter-rename-column} "fiDocumentClaimControlNumber" ${logic.rename-to} fi_doc_clm_cntl_num; -alter table public.hospice_claims ${logic.alter-rename-column} "fiscalIntermediaryNumber" ${logic.rename-to} fi_num; -alter table public.hospice_claims ${logic.alter-rename-column} "fiOriginalClaimControlNumber" ${logic.rename-to} fi_orig_clm_cntl_num; -alter table public.hospice_claims ${logic.alter-rename-column} "finalAction" ${logic.rename-to} final_action; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternalFirstCode" ${logic.rename-to} fst_dgns_e_cd; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternalFirstCodeVersion" ${logic.rename-to} fst_dgns_e_vrsn_cd; -alter table public.hospice_claims ${logic.alter-rename-column} "beneficiaryDischargeDate" ${logic.rename-to} nch_bene_dschrg_dt; -alter table public.hospice_claims ${logic.alter-rename-column} "claimTypeCode" ${logic.rename-to} nch_clm_type_cd; -alter table public.hospice_claims ${logic.alter-rename-column} "nearLineRecordIdCode" ${logic.rename-to} nch_near_line_rec_ident_cd; -alter table public.hospice_claims ${logic.alter-rename-column} "claimPrimaryPayerCode" ${logic.rename-to} nch_prmry_pyr_cd; -alter table public.hospice_claims ${logic.alter-rename-column} "primaryPayerPaidAmount" ${logic.rename-to} nch_prmry_pyr_clm_pd_amt; -alter table public.hospice_claims ${logic.alter-rename-column} "patientStatusCd" ${logic.rename-to} nch_ptnt_status_ind_cd; -alter table public.hospice_claims ${logic.alter-rename-column} "weeklyProcessDate" ${logic.rename-to} nch_wkly_proc_dt; -alter table public.hospice_claims ${logic.alter-rename-column} "organizationNpi" ${logic.rename-to} org_npi_num; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisPrincipalCode" ${logic.rename-to} prncpal_dgns_cd; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisPrincipalCodeVersion" ${logic.rename-to} prncpal_dgns_vrsn_cd; -alter table public.hospice_claims ${logic.alter-rename-column} "providerNumber" ${logic.rename-to} prvdr_num; -alter table public.hospice_claims ${logic.alter-rename-column} "providerStateCode" ${logic.rename-to} prvdr_state_cd; -alter table public.hospice_claims ${logic.alter-rename-column} "patientDischargeStatusCode" ${logic.rename-to} ptnt_dschrg_stus_cd; -alter table public.hospice_claims ${logic.alter-rename-column} "totalChargeAmount" ${logic.rename-to} clm_tot_chrg_amt; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis1Code" ${logic.rename-to} icd_dgns_cd1; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis2Code" ${logic.rename-to} icd_dgns_cd2; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis3Code" ${logic.rename-to} icd_dgns_cd3; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis4Code" ${logic.rename-to} icd_dgns_cd4; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis5Code" ${logic.rename-to} icd_dgns_cd5; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis6Code" ${logic.rename-to} icd_dgns_cd6; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis7Code" ${logic.rename-to} icd_dgns_cd7; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis8Code" ${logic.rename-to} icd_dgns_cd8; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis9Code" ${logic.rename-to} icd_dgns_cd9; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis10Code" ${logic.rename-to} icd_dgns_cd10; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis11Code" ${logic.rename-to} icd_dgns_cd11; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis12Code" ${logic.rename-to} icd_dgns_cd12; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis13Code" ${logic.rename-to} icd_dgns_cd13; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis14Code" ${logic.rename-to} icd_dgns_cd14; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis15Code" ${logic.rename-to} icd_dgns_cd15; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis16Code" ${logic.rename-to} icd_dgns_cd16; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis17Code" ${logic.rename-to} icd_dgns_cd17; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis18Code" ${logic.rename-to} icd_dgns_cd18; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis19Code" ${logic.rename-to} icd_dgns_cd19; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis20Code" ${logic.rename-to} icd_dgns_cd20; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis21Code" ${logic.rename-to} icd_dgns_cd21; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis22Code" ${logic.rename-to} icd_dgns_cd22; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis23Code" ${logic.rename-to} icd_dgns_cd23; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis24Code" ${logic.rename-to} icd_dgns_cd24; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis25Code" ${logic.rename-to} icd_dgns_cd25; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal1Code" ${logic.rename-to} icd_dgns_e_cd1; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal2Code" ${logic.rename-to} icd_dgns_e_cd2; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal3Code" ${logic.rename-to} icd_dgns_e_cd3; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal4Code" ${logic.rename-to} icd_dgns_e_cd4; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal5Code" ${logic.rename-to} icd_dgns_e_cd5; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal6Code" ${logic.rename-to} icd_dgns_e_cd6; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal7Code" ${logic.rename-to} icd_dgns_e_cd7; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal8Code" ${logic.rename-to} icd_dgns_e_cd8; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal9Code" ${logic.rename-to} icd_dgns_e_cd9; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal10Code" ${logic.rename-to} icd_dgns_e_cd10; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal11Code" ${logic.rename-to} icd_dgns_e_cd11; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal12Code" ${logic.rename-to} icd_dgns_e_cd12; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal1CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd1; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal2CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd2; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal3CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd3; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal4CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd4; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal5CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd5; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal6CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd6; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal7CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd7; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal8CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd8; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal9CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd9; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal10CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd10; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal11CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd11; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosisExternal12CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd12; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis1CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd1; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis2CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd2; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis3CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd3; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis4CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd4; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis5CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd5; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis6CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd6; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis7CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd7; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis8CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd8; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis9CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd9; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis10CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd10; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis11CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd11; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis12CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd12; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis13CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd13; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis14CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd14; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis15CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd15; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis16CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd16; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis17CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd17; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis18CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd18; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis19CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd19; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis20CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd20; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis21CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd21; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis22CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd22; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis23CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd23; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis24CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd24; -alter table public.hospice_claims ${logic.alter-rename-column} "diagnosis25CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd25; --- --- HospiceClaimLines to hospice_claim_lines --- -alter table public."HospiceClaimLines" rename to hospice_claim_lines; -alter table public.hospice_claim_lines ${logic.alter-rename-column} "parentClaim" ${logic.rename-to} clm_id; -alter table public.hospice_claim_lines ${logic.alter-rename-column} "lineNumber" ${logic.rename-to} clm_line_num; -alter table public.hospice_claim_lines ${logic.alter-rename-column} "revenueCenterCode" ${logic.rename-to} rev_cntr; -alter table public.hospice_claim_lines ${logic.alter-rename-column} "paymentAmount" ${logic.rename-to} rev_cntr_pmt_amt_amt; -alter table public.hospice_claim_lines ${logic.alter-rename-column} "revenueCenterDate" ${logic.rename-to} rev_cntr_dt; -alter table public.hospice_claim_lines ${logic.alter-rename-column} "totalChargeAmount" ${logic.rename-to} rev_cntr_tot_chrg_amt; -alter table public.hospice_claim_lines ${logic.alter-rename-column} "unitCount" ${logic.rename-to} rev_cntr_unit_cnt; -alter table public.hospice_claim_lines ${logic.alter-rename-column} "benficiaryPaymentAmount" ${logic.rename-to} rev_cntr_bene_pmt_amt; -alter table public.hospice_claim_lines ${logic.alter-rename-column} "deductibleCoinsuranceCd" ${logic.rename-to} rev_cntr_ddctbl_coinsrnc_cd; -alter table public.hospice_claim_lines ${logic.alter-rename-column} "nationalDrugCodeQualifierCode" ${logic.rename-to} rev_cntr_ndc_qty_qlfr_cd; -alter table public.hospice_claim_lines ${logic.alter-rename-column} "nationalDrugCodeQuantity" ${logic.rename-to} rev_cntr_ndc_qty; -alter table public.hospice_claim_lines ${logic.alter-rename-column} "nonCoveredChargeAmount" ${logic.rename-to} rev_cntr_ncvrd_chrg_amt; -alter table public.hospice_claim_lines ${logic.alter-rename-column} "providerPaymentAmount" ${logic.rename-to} rev_cntr_prvdr_pmt_amt; -alter table public.hospice_claim_lines ${logic.alter-rename-column} "rateAmount" ${logic.rename-to} rev_cntr_rate_amt; -alter table public.hospice_claim_lines ${logic.alter-rename-column} "hcpcsCode" ${logic.rename-to} hcpcs_cd; -alter table public.hospice_claim_lines ${logic.alter-rename-column} "hcpcsInitialModifierCode" ${logic.rename-to} hcpcs_1st_mdfr_cd; -alter table public.hospice_claim_lines ${logic.alter-rename-column} "hcpcsSecondModifierCode" ${logic.rename-to} hcpcs_2nd_mdfr_cd; -alter table public.hospice_claim_lines ${logic.alter-rename-column} "revenueCenterRenderingPhysicianNPI" ${logic.rename-to} rndrng_physn_npi; -alter table public.hospice_claim_lines ${logic.alter-rename-column} "revenueCenterRenderingPhysicianUPIN" ${logic.rename-to} rndrng_physn_upin; - --- psql only -${logic.psql-only-alter} index if exists public."HospiceClaimLines_pkey" rename to hospice_claim_lines_pkey; -${logic.psql-only-alter} index if exists public."HospiceClaims_pkey" rename to hospice_claims_pkey; - -${logic.psql-only-alter} table public.hospice_claim_lines rename constraint "HospiceClaimLines_parentClaim_to_HospiceClaims" to hospice_claim_lines_clm_id_to_hospice_claims; -${logic.psql-only-alter} table public.hospice_claims rename constraint "HospiceClaims_beneficiaryId_to_Beneficiaries" to hospice_claims_bene_id_to_beneficiaries; - --- hsql onl -${logic.hsql-only-alter} table public.hospice_claim_lines add constraint hospice_claim_lines_pkey primary key (clm_id, clm_line_num); -${logic.hsql-only-alter} table public.hospice_claims add constraint hospice_claims_pkey primary key (clm_id); - -${logic.hsql-only-alter} table public.hospice_claim_lines ADD CONSTRAINT hospice_claim_lines_clm_id_to_hospice_claims FOREIGN KEY (clm_id) REFERENCES public.hospice_claims (clm_id); -${logic.hsql-only-alter} table public.hospice_claims ADD CONSTRAINT hospice_claims_bene_id_to_beneficiaries FOREIGN KEY (bene_id) REFERENCES public.beneficiaries (bene_id); - --- both psql and hsql support non-primary key index renaming -ALTER INDEX "HospiceClaims_beneficiaryId_idx" RENAME TO hospice_claims_bene_id_idx; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V45__Table_column_rename_InpatientClaims.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V45__Table_column_rename_InpatientClaims.sql deleted file mode 100644 index aff537aacf..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V45__Table_column_rename_InpatientClaims.sql +++ /dev/null @@ -1,318 +0,0 @@ --- The V40 through V52 migrations rename our tables and columns for CCW-sourced data, such that: --- 1. We follow PostgreSQL's general snake_case naming conventions, to improve the developer experience: DB --- object names won't have to be quoted all over the place, anymore. --- 2. Column names match those in our upstream source system, the CCW, to improve traceability as data flows --- through our systems. --- 3. Rename the "parentXXX" foreign key columns to instead have names that match their target column. - --- Rename tables and table columns; syntax: --- --- psql: alter table public.beneficiaries rename column "beneficiaryId" to bene_id; --- hsql: alter table public.beneficiaries alter column "beneficiaryId" rename to bene_id; --- --- ${logic.alter-rename-column} --- psql: "rename column" --- hsql: "alter column" --- --- ${logic.rename-to} --- psql: "to" --- hsql: "rename to" --- --- InpatientClaims to inpatient_claims --- -alter table public."InpatientClaims" rename to inpatient_claims; -alter table public.inpatient_claims ${logic.alter-rename-column} "claimId" ${logic.rename-to} clm_id; -alter table public.inpatient_claims ${logic.alter-rename-column} "beneficiaryId" ${logic.rename-to} bene_id; -alter table public.inpatient_claims ${logic.alter-rename-column} "claimGroupId" ${logic.rename-to} clm_grp_id; -alter table public.inpatient_claims ${logic.alter-rename-column} lastupdated ${logic.rename-to} last_updated; -alter table public.inpatient_claims ${logic.alter-rename-column} "dateFrom" ${logic.rename-to} clm_from_dt; -alter table public.inpatient_claims ${logic.alter-rename-column} "dateThrough" ${logic.rename-to} clm_thru_dt; -alter table public.inpatient_claims ${logic.alter-rename-column} "claimAdmissionDate" ${logic.rename-to} clm_admsn_dt; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisRelatedGroupCd" ${logic.rename-to} clm_drg_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisRelatedGroupOutlierStayCd" ${logic.rename-to} clm_drg_outlier_stay_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "claimFacilityTypeCode" ${logic.rename-to} clm_fac_type_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "claimFrequencyCode" ${logic.rename-to} clm_freq_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "paymentAmount" ${logic.rename-to} clm_pmt_amt; -alter table public.inpatient_claims ${logic.alter-rename-column} "admissionTypeCd" ${logic.rename-to} clm_ip_admsn_type_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "mcoPaidSw" ${logic.rename-to} clm_mco_pd_sw; -alter table public.inpatient_claims ${logic.alter-rename-column} "claimNonPaymentReasonCode" ${logic.rename-to} clm_mdcr_non_pmt_rsn_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "nonUtilizationDayCount" ${logic.rename-to} clm_non_utlztn_days_cnt; -alter table public.inpatient_claims ${logic.alter-rename-column} "passThruPerDiemAmount" ${logic.rename-to} clm_pass_thru_per_diem_amt; -alter table public.inpatient_claims ${logic.alter-rename-column} "claimPPSCapitalDrgWeightNumber" ${logic.rename-to} clm_pps_cptl_drg_wt_num; -alter table public.inpatient_claims ${logic.alter-rename-column} "claimPPSCapitalDisproportionateShareAmt" ${logic.rename-to} clm_pps_cptl_dsprprtnt_shr_amt; -alter table public.inpatient_claims ${logic.alter-rename-column} "claimPPSCapitalExceptionAmount" ${logic.rename-to} clm_pps_cptl_excptn_amt; -alter table public.inpatient_claims ${logic.alter-rename-column} "claimPPSCapitalFSPAmount" ${logic.rename-to} clm_pps_cptl_fsp_amt; -alter table public.inpatient_claims ${logic.alter-rename-column} "claimPPSCapitalIMEAmount" ${logic.rename-to} clm_pps_cptl_ime_amt; -alter table public.inpatient_claims ${logic.alter-rename-column} "claimPPSCapitalOutlierAmount" ${logic.rename-to} clm_pps_cptl_outlier_amt; -alter table public.inpatient_claims ${logic.alter-rename-column} "prospectivePaymentCode" ${logic.rename-to} clm_pps_ind_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "claimPPSOldCapitalHoldHarmlessAmount" ${logic.rename-to} clm_pps_old_cptl_hld_hrmls_amt; -alter table public.inpatient_claims ${logic.alter-rename-column} "sourceAdmissionCd" ${logic.rename-to} clm_src_ip_admsn_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "claimServiceClassificationTypeCode" ${logic.rename-to} clm_srvc_clsfctn_type_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "claimTotalPPSCapitalAmount" ${logic.rename-to} clm_tot_pps_cptl_amt; -alter table public.inpatient_claims ${logic.alter-rename-column} "claimUncompensatedCareAmount" ${logic.rename-to} clm_uncompd_care_pmt_amt; -alter table public.inpatient_claims ${logic.alter-rename-column} "utilizationDayCount" ${logic.rename-to} clm_utlztn_day_cnt; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisAdmittingCode" ${logic.rename-to} admtg_dgns_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisAdmittingCodeVersion" ${logic.rename-to} admtg_dgns_vrsn_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "attendingPhysicianNpi" ${logic.rename-to} at_physn_npi; -alter table public.inpatient_claims ${logic.alter-rename-column} "attendingPhysicianUpin" ${logic.rename-to} at_physn_upin; -alter table public.inpatient_claims ${logic.alter-rename-column} "lifetimeReservedDaysUsedCount" ${logic.rename-to} bene_lrd_used_cnt; -alter table public.inpatient_claims ${logic.alter-rename-column} "coinsuranceDayCount" ${logic.rename-to} bene_tot_coinsrnc_days_cnt; -alter table public.inpatient_claims ${logic.alter-rename-column} "claimQueryCode" ${logic.rename-to} claim_query_code; -alter table public.inpatient_claims ${logic.alter-rename-column} "disproportionateShareAmount" ${logic.rename-to} dsh_op_clm_val_amt; -alter table public.inpatient_claims ${logic.alter-rename-column} "fiscalIntermediaryClaimActionCode" ${logic.rename-to} fi_clm_actn_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "fiscalIntermediaryClaimProcessDate" ${logic.rename-to} fi_clm_proc_dt; -alter table public.inpatient_claims ${logic.alter-rename-column} "fiDocumentClaimControlNumber" ${logic.rename-to} fi_doc_clm_cntl_num; -alter table public.inpatient_claims ${logic.alter-rename-column} "fiscalIntermediaryNumber" ${logic.rename-to} fi_num; -alter table public.inpatient_claims ${logic.alter-rename-column} "fiOriginalClaimControlNumber" ${logic.rename-to} fi_orig_clm_cntl_num; -alter table public.inpatient_claims ${logic.alter-rename-column} "finalAction" ${logic.rename-to} final_action; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternalFirstCode" ${logic.rename-to} fst_dgns_e_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternalFirstCodeVersion" ${logic.rename-to} fst_dgns_e_vrsn_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "indirectMedicalEducationAmount" ${logic.rename-to} ime_op_clm_val_amt; -alter table public.inpatient_claims ${logic.alter-rename-column} "coveredCareThoughDate" ${logic.rename-to} nch_actv_or_cvrd_lvl_care_thru; -alter table public.inpatient_claims ${logic.alter-rename-column} "bloodDeductibleLiabilityAmount" ${logic.rename-to} nch_bene_blood_ddctbl_lblty_am; -alter table public.inpatient_claims ${logic.alter-rename-column} "beneficiaryDischargeDate" ${logic.rename-to} nch_bene_dschrg_dt; -alter table public.inpatient_claims ${logic.alter-rename-column} "deductibleAmount" ${logic.rename-to} nch_bene_ip_ddctbl_amt; -alter table public.inpatient_claims ${logic.alter-rename-column} "medicareBenefitsExhaustedDate" ${logic.rename-to} nch_bene_mdcr_bnfts_exhtd_dt_i; -alter table public.inpatient_claims ${logic.alter-rename-column} "partACoinsuranceLiabilityAmount" ${logic.rename-to} nch_bene_pta_coinsrnc_lblty_am; -alter table public.inpatient_claims ${logic.alter-rename-column} "bloodPintsFurnishedQty" ${logic.rename-to} nch_blood_pnts_frnshd_qty; -alter table public.inpatient_claims ${logic.alter-rename-column} "claimTypeCode" ${logic.rename-to} nch_clm_type_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "drgOutlierApprovedPaymentAmount" ${logic.rename-to} nch_drg_outlier_aprvd_pmt_amt; -alter table public.inpatient_claims ${logic.alter-rename-column} "noncoveredCharge" ${logic.rename-to} nch_ip_ncvrd_chrg_amt; -alter table public.inpatient_claims ${logic.alter-rename-column} "totalDeductionAmount" ${logic.rename-to} nch_ip_tot_ddctn_amt; -alter table public.inpatient_claims ${logic.alter-rename-column} "nearLineRecordIdCode" ${logic.rename-to} nch_near_line_rec_ident_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "claimPrimaryPayerCode" ${logic.rename-to} nch_prmry_pyr_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "primaryPayerPaidAmount" ${logic.rename-to} nch_prmry_pyr_clm_pd_amt; -alter table public.inpatient_claims ${logic.alter-rename-column} "professionalComponentCharge" ${logic.rename-to} nch_profnl_cmpnt_chrg_amt; -alter table public.inpatient_claims ${logic.alter-rename-column} "patientStatusCd" ${logic.rename-to} nch_ptnt_status_ind_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "noncoveredStayFromDate" ${logic.rename-to} nch_vrfd_ncvrd_stay_from_dt; -alter table public.inpatient_claims ${logic.alter-rename-column} "noncoveredStayThroughDate" ${logic.rename-to} nch_vrfd_ncvrd_stay_thru_dt; -alter table public.inpatient_claims ${logic.alter-rename-column} "weeklyProcessDate" ${logic.rename-to} nch_wkly_proc_dt; -alter table public.inpatient_claims ${logic.alter-rename-column} "operatingPhysicianNpi" ${logic.rename-to} op_physn_npi; -alter table public.inpatient_claims ${logic.alter-rename-column} "operatingPhysicianUpin" ${logic.rename-to} op_physn_upin; -alter table public.inpatient_claims ${logic.alter-rename-column} "organizationNpi" ${logic.rename-to} org_npi_num; -alter table public.inpatient_claims ${logic.alter-rename-column} "otherPhysicianNpi" ${logic.rename-to} ot_physn_npi; -alter table public.inpatient_claims ${logic.alter-rename-column} "otherPhysicianUpin" ${logic.rename-to} ot_physn_upin; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisPrincipalCode" ${logic.rename-to} prncpal_dgns_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisPrincipalCodeVersion" ${logic.rename-to} prncpal_dgns_vrsn_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "providerNumber" ${logic.rename-to} prvdr_num; -alter table public.inpatient_claims ${logic.alter-rename-column} "providerStateCode" ${logic.rename-to} prvdr_state_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "patientDischargeStatusCode" ${logic.rename-to} ptnt_dschrg_stus_cd; -alter table public.inpatient_claims ${logic.alter-rename-column} "totalChargeAmount" ${logic.rename-to} clm_tot_chrg_amt; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal1PresentOnAdmissionCode" ${logic.rename-to} clm_e_poa_ind_sw1; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal2PresentOnAdmissionCode" ${logic.rename-to} clm_e_poa_ind_sw2; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal3PresentOnAdmissionCode" ${logic.rename-to} clm_e_poa_ind_sw3; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal4PresentOnAdmissionCode" ${logic.rename-to} clm_e_poa_ind_sw4; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal5PresentOnAdmissionCode" ${logic.rename-to} clm_e_poa_ind_sw5; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal6PresentOnAdmissionCode" ${logic.rename-to} clm_e_poa_ind_sw6; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal7PresentOnAdmissionCode" ${logic.rename-to} clm_e_poa_ind_sw7; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal8PresentOnAdmissionCode" ${logic.rename-to} clm_e_poa_ind_sw8; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal9PresentOnAdmissionCode" ${logic.rename-to} clm_e_poa_ind_sw9; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal10PresentOnAdmissionCode" ${logic.rename-to} clm_e_poa_ind_sw10; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal11PresentOnAdmissionCode" ${logic.rename-to} clm_e_poa_ind_sw11; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal12PresentOnAdmissionCode" ${logic.rename-to} clm_e_poa_ind_sw12; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis1PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw1; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis2PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw2; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis3PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw3; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis4PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw4; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis5PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw5; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis6PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw6; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis7PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw7; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis8PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw8; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis9PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw9; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis10PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw10; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis11PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw11; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis12PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw12; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis13PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw13; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis14PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw14; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis15PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw15; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis16PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw16; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis17PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw17; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis18PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw18; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis19PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw19; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis20PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw20; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis21PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw21; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis22PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw22; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis23PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw23; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis24PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw24; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis25PresentOnAdmissionCode" ${logic.rename-to} clm_poa_ind_sw25; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis1Code" ${logic.rename-to} icd_dgns_cd1; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis2Code" ${logic.rename-to} icd_dgns_cd2; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis3Code" ${logic.rename-to} icd_dgns_cd3; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis4Code" ${logic.rename-to} icd_dgns_cd4; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis5Code" ${logic.rename-to} icd_dgns_cd5; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis6Code" ${logic.rename-to} icd_dgns_cd6; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis7Code" ${logic.rename-to} icd_dgns_cd7; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis8Code" ${logic.rename-to} icd_dgns_cd8; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis9Code" ${logic.rename-to} icd_dgns_cd9; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis10Code" ${logic.rename-to} icd_dgns_cd10; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis11Code" ${logic.rename-to} icd_dgns_cd11; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis12Code" ${logic.rename-to} icd_dgns_cd12; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis13Code" ${logic.rename-to} icd_dgns_cd13; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis14Code" ${logic.rename-to} icd_dgns_cd14; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis15Code" ${logic.rename-to} icd_dgns_cd15; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis16Code" ${logic.rename-to} icd_dgns_cd16; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis17Code" ${logic.rename-to} icd_dgns_cd17; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis18Code" ${logic.rename-to} icd_dgns_cd18; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis19Code" ${logic.rename-to} icd_dgns_cd19; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis20Code" ${logic.rename-to} icd_dgns_cd20; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis21Code" ${logic.rename-to} icd_dgns_cd21; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis22Code" ${logic.rename-to} icd_dgns_cd22; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis23Code" ${logic.rename-to} icd_dgns_cd23; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis24Code" ${logic.rename-to} icd_dgns_cd24; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis25Code" ${logic.rename-to} icd_dgns_cd25; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal1Code" ${logic.rename-to} icd_dgns_e_cd1; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal2Code" ${logic.rename-to} icd_dgns_e_cd2; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal3Code" ${logic.rename-to} icd_dgns_e_cd3; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal4Code" ${logic.rename-to} icd_dgns_e_cd4; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal5Code" ${logic.rename-to} icd_dgns_e_cd5; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal6Code" ${logic.rename-to} icd_dgns_e_cd6; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal7Code" ${logic.rename-to} icd_dgns_e_cd7; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal8Code" ${logic.rename-to} icd_dgns_e_cd8; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal9Code" ${logic.rename-to} icd_dgns_e_cd9; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal10Code" ${logic.rename-to} icd_dgns_e_cd10; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal11Code" ${logic.rename-to} icd_dgns_e_cd11; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal12Code" ${logic.rename-to} icd_dgns_e_cd12; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal1CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd1; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal2CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd2; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal3CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd3; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal4CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd4; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal5CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd5; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal6CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd6; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal7CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd7; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal8CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd8; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal9CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd9; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal10CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd10; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal11CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd11; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosisExternal12CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd12; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis1CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd1; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis2CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd2; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis3CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd3; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis4CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd4; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis5CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd5; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis6CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd6; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis7CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd7; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis8CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd8; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis9CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd9; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis10CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd10; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis11CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd11; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis12CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd12; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis13CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd13; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis14CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd14; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis15CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd15; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis16CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd16; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis17CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd17; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis18CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd18; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis19CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd19; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis20CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd20; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis21CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd21; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis22CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd22; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis23CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd23; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis24CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd24; -alter table public.inpatient_claims ${logic.alter-rename-column} "diagnosis25CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd25; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure1Code" ${logic.rename-to} icd_prcdr_cd1; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure2Code" ${logic.rename-to} icd_prcdr_cd2; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure3Code" ${logic.rename-to} icd_prcdr_cd3; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure4Code" ${logic.rename-to} icd_prcdr_cd4; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure5Code" ${logic.rename-to} icd_prcdr_cd5; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure6Code" ${logic.rename-to} icd_prcdr_cd6; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure7Code" ${logic.rename-to} icd_prcdr_cd7; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure8Code" ${logic.rename-to} icd_prcdr_cd8; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure9Code" ${logic.rename-to} icd_prcdr_cd9; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure10Code" ${logic.rename-to} icd_prcdr_cd10; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure11Code" ${logic.rename-to} icd_prcdr_cd11; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure12Code" ${logic.rename-to} icd_prcdr_cd12; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure13Code" ${logic.rename-to} icd_prcdr_cd13; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure14Code" ${logic.rename-to} icd_prcdr_cd14; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure15Code" ${logic.rename-to} icd_prcdr_cd15; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure16Code" ${logic.rename-to} icd_prcdr_cd16; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure17Code" ${logic.rename-to} icd_prcdr_cd17; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure18Code" ${logic.rename-to} icd_prcdr_cd18; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure19Code" ${logic.rename-to} icd_prcdr_cd19; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure20Code" ${logic.rename-to} icd_prcdr_cd20; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure21Code" ${logic.rename-to} icd_prcdr_cd21; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure22Code" ${logic.rename-to} icd_prcdr_cd22; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure23Code" ${logic.rename-to} icd_prcdr_cd23; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure24Code" ${logic.rename-to} icd_prcdr_cd24; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure25Code" ${logic.rename-to} icd_prcdr_cd25; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure1CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd1; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure2CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd2; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure3CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd3; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure4CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd4; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure5CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd5; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure6CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd6; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure7CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd7; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure8CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd8; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure9CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd9; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure10CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd10; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure11CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd11; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure12CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd12; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure13CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd13; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure14CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd14; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure15CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd15; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure16CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd16; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure17CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd17; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure18CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd18; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure19CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd19; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure20CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd20; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure21CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd21; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure22CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd22; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure23CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd23; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure24CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd24; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure25CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd25; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure1Date" ${logic.rename-to} prcdr_dt1; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure2Date" ${logic.rename-to} prcdr_dt2; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure3Date" ${logic.rename-to} prcdr_dt3; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure4Date" ${logic.rename-to} prcdr_dt4; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure5Date" ${logic.rename-to} prcdr_dt5; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure6Date" ${logic.rename-to} prcdr_dt6; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure7Date" ${logic.rename-to} prcdr_dt7; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure8Date" ${logic.rename-to} prcdr_dt8; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure9Date" ${logic.rename-to} prcdr_dt9; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure10Date" ${logic.rename-to} prcdr_dt10; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure11Date" ${logic.rename-to} prcdr_dt11; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure12Date" ${logic.rename-to} prcdr_dt12; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure13Date" ${logic.rename-to} prcdr_dt13; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure14Date" ${logic.rename-to} prcdr_dt14; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure15Date" ${logic.rename-to} prcdr_dt15; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure16Date" ${logic.rename-to} prcdr_dt16; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure17Date" ${logic.rename-to} prcdr_dt17; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure18Date" ${logic.rename-to} prcdr_dt18; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure19Date" ${logic.rename-to} prcdr_dt19; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure20Date" ${logic.rename-to} prcdr_dt20; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure21Date" ${logic.rename-to} prcdr_dt21; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure22Date" ${logic.rename-to} prcdr_dt22; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure23Date" ${logic.rename-to} prcdr_dt23; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure24Date" ${logic.rename-to} prcdr_dt24; -alter table public.inpatient_claims ${logic.alter-rename-column} "procedure25Date" ${logic.rename-to} prcdr_dt25; --- --- InpatientClaimLines to inpatient_claim_lines --- -alter table public."InpatientClaimLines" rename to inpatient_claim_lines; -alter table public.inpatient_claim_lines ${logic.alter-rename-column} "parentClaim" ${logic.rename-to} clm_id; -alter table public.inpatient_claim_lines ${logic.alter-rename-column} "lineNumber" ${logic.rename-to} clm_line_num; -alter table public.inpatient_claim_lines ${logic.alter-rename-column} "deductibleCoinsuranceCd" ${logic.rename-to} rev_cntr_ddctbl_coinsrnc_cd; -alter table public.inpatient_claim_lines ${logic.alter-rename-column} "nationalDrugCodeQualifierCode" ${logic.rename-to} rev_cntr_ndc_qty_qlfr_cd; -alter table public.inpatient_claim_lines ${logic.alter-rename-column} "nationalDrugCodeQuantity" ${logic.rename-to} rev_cntr_ndc_qty; -alter table public.inpatient_claim_lines ${logic.alter-rename-column} "nonCoveredChargeAmount" ${logic.rename-to} rev_cntr_ncvrd_chrg_amt; -alter table public.inpatient_claim_lines ${logic.alter-rename-column} "rateAmount" ${logic.rename-to} rev_cntr_rate_amt; -alter table public.inpatient_claim_lines ${logic.alter-rename-column} "revenueCenter" ${logic.rename-to} rev_cntr; -alter table public.inpatient_claim_lines ${logic.alter-rename-column} "totalChargeAmount" ${logic.rename-to} rev_cntr_tot_chrg_amt; -alter table public.inpatient_claim_lines ${logic.alter-rename-column} "unitCount" ${logic.rename-to} rev_cntr_unit_cnt; -alter table public.inpatient_claim_lines ${logic.alter-rename-column} "hcpcsCode" ${logic.rename-to} hcpcs_cd; -alter table public.inpatient_claim_lines ${logic.alter-rename-column} "revenueCenterRenderingPhysicianNPI" ${logic.rename-to} rndrng_physn_npi; -alter table public.inpatient_claim_lines ${logic.alter-rename-column} "revenueCenterRenderingPhysicianUPIN" ${logic.rename-to} rndrng_physn_upin; - -${logic.psql-only-alter} index if exists public."InpatientClaimLines_pkey" rename to inpatient_claim_lines_pkey; -${logic.psql-only-alter} index if exists public."InpatientClaims_pkey" rename to inpatient_claims_pkey; - -${logic.psql-only-alter} table public.inpatient_claim_lines rename constraint "InpatientClaimLines_parentClaim_to_InpatientClaims" to inpatient_claim_lines_clm_id_to_inpatient_claims; -${logic.psql-only-alter} table public.inpatient_claims rename constraint "InpatientClaims_beneficiaryId_to_Beneficiaries" to inpatient_claims_bene_id_to_beneficiaries; - -${logic.hsql-only-alter} table public.inpatient_claim_lines add constraint inpatient_claim_lines_pkey primary key (clm_id, clm_line_num); -${logic.hsql-only-alter} table public.inpatient_claims add constraint inpatient_claims_pkey primary key (clm_id); - -${logic.hsql-only-alter} table public.inpatient_claim_lines ADD CONSTRAINT inpatient_claim_lines_clm_id_to_inpatient_claims FOREIGN KEY (clm_id) REFERENCES public.inpatient_claims (clm_id); -${logic.hsql-only-alter} table public.inpatient_claims ADD CONSTRAINT inpatient_claims_bene_id_to_beneficiaries FOREIGN KEY (bene_id) REFERENCES public.beneficiaries (bene_id); - --- both psql and hsql support non-primary key index renaming -ALTER INDEX "InpatientClaims_beneficiaryId_idx" RENAME TO inpatient_claims_bene_id_idx; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V46__Table_column_rename_OutpatientClaims.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V46__Table_column_rename_OutpatientClaims.sql deleted file mode 100644 index 68e0ef981e..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V46__Table_column_rename_OutpatientClaims.sql +++ /dev/null @@ -1,279 +0,0 @@ --- The V40 through V52 migrations rename our tables and columns for CCW-sourced data, such that: --- 1. We follow PostgreSQL's general snake_case naming conventions, to improve the developer experience: DB --- object names won't have to be quoted all over the place, anymore. --- 2. Column names match those in our upstream source system, the CCW, to improve traceability as data flows --- through our systems. --- 3. Rename the "parentXXX" foreign key columns to instead have names that match their target column. - --- Rename tables and table columns; syntax: --- --- psql: alter table public.beneficiaries rename column "beneficiaryId" to bene_id; --- hsql: alter table public.beneficiaries alter column "beneficiaryId" rename to bene_id; --- --- ${logic.alter-rename-column} --- psql: "rename column" --- hsql: "alter column" --- --- ${logic.rename-to} --- psql: "to" --- hsql: "rename to" --- --- OutpatientClaims to outpatient_claims --- -alter table public."OutpatientClaims" rename to outpatient_claims; -alter table public.outpatient_claims ${logic.alter-rename-column} "claimId" ${logic.rename-to} clm_id; -alter table public.outpatient_claims ${logic.alter-rename-column} "beneficiaryId" ${logic.rename-to} bene_id; -alter table public.outpatient_claims ${logic.alter-rename-column} "claimGroupId" ${logic.rename-to} clm_grp_id; -alter table public.outpatient_claims ${logic.alter-rename-column} lastupdated ${logic.rename-to} last_updated; -alter table public.outpatient_claims ${logic.alter-rename-column} "dateFrom" ${logic.rename-to} clm_from_dt; -alter table public.outpatient_claims ${logic.alter-rename-column} "dateThrough" ${logic.rename-to} clm_thru_dt; -alter table public.outpatient_claims ${logic.alter-rename-column} "claimFacilityTypeCode" ${logic.rename-to} clm_fac_type_cd; -alter table public.outpatient_claims ${logic.alter-rename-column} "claimFrequencyCode" ${logic.rename-to} clm_freq_cd; -alter table public.outpatient_claims ${logic.alter-rename-column} "mcoPaidSw" ${logic.rename-to} clm_mco_pd_sw; -alter table public.outpatient_claims ${logic.alter-rename-column} "claimNonPaymentReasonCode" ${logic.rename-to} clm_mdcr_non_pmt_rsn_cd; -alter table public.outpatient_claims ${logic.alter-rename-column} "paymentAmount" ${logic.rename-to} clm_pmt_amt; -alter table public.outpatient_claims ${logic.alter-rename-column} "claimServiceClassificationTypeCode" ${logic.rename-to} clm_srvc_clsfctn_type_cd; -alter table public.outpatient_claims ${logic.alter-rename-column} "attendingPhysicianNpi" ${logic.rename-to} at_physn_npi; -alter table public.outpatient_claims ${logic.alter-rename-column} "attendingPhysicianUpin" ${logic.rename-to} at_physn_upin; -alter table public.outpatient_claims ${logic.alter-rename-column} "claimQueryCode" ${logic.rename-to} claim_query_code; -alter table public.outpatient_claims ${logic.alter-rename-column} "fiscalIntermediaryClaimProcessDate" ${logic.rename-to} fi_clm_proc_dt; -alter table public.outpatient_claims ${logic.alter-rename-column} "fiDocumentClaimControlNumber" ${logic.rename-to} fi_doc_clm_cntl_num; -alter table public.outpatient_claims ${logic.alter-rename-column} "fiscalIntermediaryNumber" ${logic.rename-to} fi_num; -alter table public.outpatient_claims ${logic.alter-rename-column} "fiOriginalClaimControlNumber" ${logic.rename-to} fi_orig_clm_cntl_num; -alter table public.outpatient_claims ${logic.alter-rename-column} "finalAction" ${logic.rename-to} final_action; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternalFirstCode" ${logic.rename-to} fst_dgns_e_cd; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternalFirstCodeVersion" ${logic.rename-to} fst_dgns_e_vrsn_cd; -alter table public.outpatient_claims ${logic.alter-rename-column} "beneficiaryPaymentAmount" ${logic.rename-to} clm_op_bene_pmt_amt; -alter table public.outpatient_claims ${logic.alter-rename-column} "coinsuranceAmount" ${logic.rename-to} nch_bene_ptb_coinsrnc_amt; -alter table public.outpatient_claims ${logic.alter-rename-column} "bloodDeductibleLiabilityAmount" ${logic.rename-to} nch_bene_blood_ddctbl_lblty_am; -alter table public.outpatient_claims ${logic.alter-rename-column} "deductibleAmount" ${logic.rename-to} nch_bene_ptb_ddctbl_amt; -alter table public.outpatient_claims ${logic.alter-rename-column} "claimTypeCode" ${logic.rename-to} nch_clm_type_cd; -alter table public.outpatient_claims ${logic.alter-rename-column} "nearLineRecordIdCode" ${logic.rename-to} nch_near_line_rec_ident_cd; -alter table public.outpatient_claims ${logic.alter-rename-column} "claimPrimaryPayerCode" ${logic.rename-to} nch_prmry_pyr_cd; -alter table public.outpatient_claims ${logic.alter-rename-column} "primaryPayerPaidAmount" ${logic.rename-to} nch_prmry_pyr_clm_pd_amt; -alter table public.outpatient_claims ${logic.alter-rename-column} "professionalComponentCharge" ${logic.rename-to} nch_profnl_cmpnt_chrg_amt; -alter table public.outpatient_claims ${logic.alter-rename-column} "weeklyProcessDate" ${logic.rename-to} nch_wkly_proc_dt; -alter table public.outpatient_claims ${logic.alter-rename-column} "operatingPhysicianNpi" ${logic.rename-to} op_physn_npi; -alter table public.outpatient_claims ${logic.alter-rename-column} "operatingPhysicianUpin" ${logic.rename-to} op_physn_upin; -alter table public.outpatient_claims ${logic.alter-rename-column} "organizationNpi" ${logic.rename-to} org_npi_num; -alter table public.outpatient_claims ${logic.alter-rename-column} "otherPhysicianNpi" ${logic.rename-to} ot_physn_npi; -alter table public.outpatient_claims ${logic.alter-rename-column} "otherPhysicianUpin" ${logic.rename-to} ot_physn_upin; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisPrincipalCode" ${logic.rename-to} prncpal_dgns_cd; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisPrincipalCodeVersion" ${logic.rename-to} prncpal_dgns_vrsn_cd; -alter table public.outpatient_claims ${logic.alter-rename-column} "providerNumber" ${logic.rename-to} prvdr_num; -alter table public.outpatient_claims ${logic.alter-rename-column} "providerStateCode" ${logic.rename-to} prvdr_state_cd; -alter table public.outpatient_claims ${logic.alter-rename-column} "patientDischargeStatusCode" ${logic.rename-to} ptnt_dschrg_stus_cd; -alter table public.outpatient_claims ${logic.alter-rename-column} "providerPaymentAmount" ${logic.rename-to} clm_op_prvdr_pmt_amt; -alter table public.outpatient_claims ${logic.alter-rename-column} "totalChargeAmount" ${logic.rename-to} clm_tot_chrg_amt; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisAdmission1Code" ${logic.rename-to} rsn_visit_cd1; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisAdmission1CodeVersion" ${logic.rename-to} rsn_visit_vrsn_cd1; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisAdmission2Code" ${logic.rename-to} rsn_visit_cd2; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisAdmission2CodeVersion" ${logic.rename-to} rsn_visit_vrsn_cd2; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisAdmission3Code" ${logic.rename-to} rsn_visit_cd3; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisAdmission3CodeVersion" ${logic.rename-to} rsn_visit_vrsn_cd3; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis1Code" ${logic.rename-to} icd_dgns_cd1; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis2Code" ${logic.rename-to} icd_dgns_cd2; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis3Code" ${logic.rename-to} icd_dgns_cd3; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis4Code" ${logic.rename-to} icd_dgns_cd4; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis5Code" ${logic.rename-to} icd_dgns_cd5; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis6Code" ${logic.rename-to} icd_dgns_cd6; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis7Code" ${logic.rename-to} icd_dgns_cd7; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis8Code" ${logic.rename-to} icd_dgns_cd8; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis9Code" ${logic.rename-to} icd_dgns_cd9; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis10Code" ${logic.rename-to} icd_dgns_cd10; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis11Code" ${logic.rename-to} icd_dgns_cd11; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis12Code" ${logic.rename-to} icd_dgns_cd12; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis13Code" ${logic.rename-to} icd_dgns_cd13; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis14Code" ${logic.rename-to} icd_dgns_cd14; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis15Code" ${logic.rename-to} icd_dgns_cd15; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis16Code" ${logic.rename-to} icd_dgns_cd16; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis17Code" ${logic.rename-to} icd_dgns_cd17; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis18Code" ${logic.rename-to} icd_dgns_cd18; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis19Code" ${logic.rename-to} icd_dgns_cd19; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis20Code" ${logic.rename-to} icd_dgns_cd20; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis21Code" ${logic.rename-to} icd_dgns_cd21; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis22Code" ${logic.rename-to} icd_dgns_cd22; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis23Code" ${logic.rename-to} icd_dgns_cd23; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis24Code" ${logic.rename-to} icd_dgns_cd24; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis25Code" ${logic.rename-to} icd_dgns_cd25; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal1Code" ${logic.rename-to} icd_dgns_e_cd1; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal2Code" ${logic.rename-to} icd_dgns_e_cd2; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal3Code" ${logic.rename-to} icd_dgns_e_cd3; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal4Code" ${logic.rename-to} icd_dgns_e_cd4; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal5Code" ${logic.rename-to} icd_dgns_e_cd5; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal6Code" ${logic.rename-to} icd_dgns_e_cd6; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal7Code" ${logic.rename-to} icd_dgns_e_cd7; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal8Code" ${logic.rename-to} icd_dgns_e_cd8; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal9Code" ${logic.rename-to} icd_dgns_e_cd9; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal10Code" ${logic.rename-to} icd_dgns_e_cd10; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal11Code" ${logic.rename-to} icd_dgns_e_cd11; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal12Code" ${logic.rename-to} icd_dgns_e_cd12; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal1CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd1; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal2CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd2; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal3CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd3; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal4CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd4; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal5CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd5; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal6CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd6; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal7CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd7; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal8CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd8; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal9CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd9; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal10CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd10; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal11CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd11; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosisExternal12CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd12; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis1CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd1; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis2CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd2; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis3CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd3; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis4CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd4; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis5CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd5; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis6CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd6; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis7CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd7; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis8CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd8; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis9CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd9; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis10CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd10; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis11CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd11; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis12CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd12; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis13CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd13; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis14CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd14; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis15CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd15; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis16CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd16; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis17CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd17; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis18CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd18; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis19CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd19; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis20CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd20; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis21CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd21; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis22CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd22; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis23CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd23; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis24CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd24; -alter table public.outpatient_claims ${logic.alter-rename-column} "diagnosis25CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd25; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure1Code" ${logic.rename-to} icd_prcdr_cd1; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure2Code" ${logic.rename-to} icd_prcdr_cd2; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure3Code" ${logic.rename-to} icd_prcdr_cd3; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure4Code" ${logic.rename-to} icd_prcdr_cd4; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure5Code" ${logic.rename-to} icd_prcdr_cd5; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure6Code" ${logic.rename-to} icd_prcdr_cd6; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure7Code" ${logic.rename-to} icd_prcdr_cd7; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure8Code" ${logic.rename-to} icd_prcdr_cd8; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure9Code" ${logic.rename-to} icd_prcdr_cd9; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure10Code" ${logic.rename-to} icd_prcdr_cd10; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure11Code" ${logic.rename-to} icd_prcdr_cd11; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure12Code" ${logic.rename-to} icd_prcdr_cd12; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure13Code" ${logic.rename-to} icd_prcdr_cd13; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure14Code" ${logic.rename-to} icd_prcdr_cd14; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure15Code" ${logic.rename-to} icd_prcdr_cd15; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure16Code" ${logic.rename-to} icd_prcdr_cd16; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure17Code" ${logic.rename-to} icd_prcdr_cd17; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure18Code" ${logic.rename-to} icd_prcdr_cd18; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure19Code" ${logic.rename-to} icd_prcdr_cd19; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure20Code" ${logic.rename-to} icd_prcdr_cd20; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure21Code" ${logic.rename-to} icd_prcdr_cd21; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure22Code" ${logic.rename-to} icd_prcdr_cd22; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure23Code" ${logic.rename-to} icd_prcdr_cd23; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure24Code" ${logic.rename-to} icd_prcdr_cd24; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure25Code" ${logic.rename-to} icd_prcdr_cd25; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure1CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd1; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure2CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd2; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure3CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd3; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure4CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd4; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure5CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd5; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure6CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd6; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure7CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd7; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure8CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd8; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure9CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd9; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure10CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd10; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure11CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd11; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure12CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd12; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure13CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd13; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure14CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd14; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure15CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd15; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure16CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd16; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure17CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd17; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure18CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd18; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure19CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd19; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure20CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd20; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure21CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd21; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure22CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd22; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure23CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd23; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure24CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd24; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure25CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd25; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure1Date" ${logic.rename-to} prcdr_dt1; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure2Date" ${logic.rename-to} prcdr_dt2; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure3Date" ${logic.rename-to} prcdr_dt3; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure4Date" ${logic.rename-to} prcdr_dt4; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure5Date" ${logic.rename-to} prcdr_dt5; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure6Date" ${logic.rename-to} prcdr_dt6; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure7Date" ${logic.rename-to} prcdr_dt7; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure8Date" ${logic.rename-to} prcdr_dt8; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure9Date" ${logic.rename-to} prcdr_dt9; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure10Date" ${logic.rename-to} prcdr_dt10; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure11Date" ${logic.rename-to} prcdr_dt11; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure12Date" ${logic.rename-to} prcdr_dt12; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure13Date" ${logic.rename-to} prcdr_dt13; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure14Date" ${logic.rename-to} prcdr_dt14; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure15Date" ${logic.rename-to} prcdr_dt15; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure16Date" ${logic.rename-to} prcdr_dt16; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure17Date" ${logic.rename-to} prcdr_dt17; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure18Date" ${logic.rename-to} prcdr_dt18; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure19Date" ${logic.rename-to} prcdr_dt19; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure20Date" ${logic.rename-to} prcdr_dt20; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure21Date" ${logic.rename-to} prcdr_dt21; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure22Date" ${logic.rename-to} prcdr_dt22; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure23Date" ${logic.rename-to} prcdr_dt23; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure24Date" ${logic.rename-to} prcdr_dt24; -alter table public.outpatient_claims ${logic.alter-rename-column} "procedure25Date" ${logic.rename-to} prcdr_dt25; --- --- OutpatientClaimLines to outpatient_claim_lines --- -alter table public."OutpatientClaimLines" rename to outpatient_claim_lines; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "parentClaim" ${logic.rename-to} clm_id; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "lineNumber" ${logic.rename-to} clm_line_num; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "nationalDrugCode" ${logic.rename-to} rev_cntr_ide_ndc_upc_num; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "hcpcsCode" ${logic.rename-to} hcpcs_cd; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "hcpcsInitialModifierCode" ${logic.rename-to} hcpcs_1st_mdfr_cd; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "hcpcsSecondModifierCode" ${logic.rename-to} hcpcs_2nd_mdfr_cd; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "revenueCenterRenderingPhysicianNPI" ${logic.rename-to} rndrng_physn_npi; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "revenueCenterRenderingPhysicianUPIN" ${logic.rename-to} rndrng_physn_upin; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "revenueCenterCode" ${logic.rename-to} rev_cntr; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "revenueCenterDate" ${logic.rename-to} rev_cntr_dt; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "paymentAmount" ${logic.rename-to} rev_cntr_pmt_amt_amt; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "apcOrHippsCode" ${logic.rename-to} rev_cntr_apc_hipps_cd; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "benficiaryPaymentAmount" ${logic.rename-to} rev_cntr_bene_pmt_amt; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "bloodDeductibleAmount" ${logic.rename-to} rev_cntr_blood_ddctbl_amt; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "cashDeductibleAmount" ${logic.rename-to} rev_cntr_cash_ddctbl_amt; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "discountCode" ${logic.rename-to} rev_cntr_dscnt_ind_cd; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "firstMspPaidAmount" ${logic.rename-to} rev_cntr_1st_msp_pd_amt; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "nationalDrugCodeQualifierCode" ${logic.rename-to} rev_cntr_ndc_qty_qlfr_cd; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "nationalDrugCodeQuantity" ${logic.rename-to} rev_cntr_ndc_qty; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "nonCoveredChargeAmount" ${logic.rename-to} rev_cntr_ncvrd_chrg_amt; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "obligationToAcceptAsFullPaymentCode" ${logic.rename-to} rev_cntr_otaf_pmt_cd; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "packagingCode" ${logic.rename-to} rev_cntr_packg_ind_cd; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "patientResponsibilityAmount" ${logic.rename-to} rev_cntr_ptnt_rspnsblty_pmt; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "paymentMethodCode" ${logic.rename-to} rev_cntr_pmt_mthd_ind_cd; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "providerPaymentAmount" ${logic.rename-to} rev_cntr_prvdr_pmt_amt; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "rateAmount" ${logic.rename-to} rev_cntr_rate_amt; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "reducedCoinsuranceAmount" ${logic.rename-to} rev_cntr_rdcd_coinsrnc_amt; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "revCntr1stAnsiCd" ${logic.rename-to} rev_cntr_1st_ansi_cd; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "revCntr2ndAnsiCd" ${logic.rename-to} rev_cntr_2nd_ansi_cd; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "revCntr3rdAnsiCd" ${logic.rename-to} rev_cntr_3rd_ansi_cd; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "revCntr4thAnsiCd" ${logic.rename-to} rev_cntr_4th_ansi_cd; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "secondMspPaidAmount" ${logic.rename-to} rev_cntr_2nd_msp_pd_amt; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "statusCode" ${logic.rename-to} rev_cntr_stus_ind_cd; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "totalChargeAmount" ${logic.rename-to} rev_cntr_tot_chrg_amt; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "unitCount" ${logic.rename-to} rev_cntr_unit_cnt; -alter table public.outpatient_claim_lines ${logic.alter-rename-column} "wageAdjustedCoinsuranceAmount" ${logic.rename-to} rev_cntr_coinsrnc_wge_adjstd_c; - --- psql only -${logic.psql-only-alter} index if exists public."OutpatientClaimLines_pkey" rename to outpatient_claim_lines_pkey; -${logic.psql-only-alter} index if exists public."OutpatientClaims_pkey" rename to outpatient_claims_pkey; - -${logic.psql-only-alter} table public.outpatient_claim_lines rename constraint "OutpatientClaimLines_parentClaim_to_OutpatientClaims" to outpatient_claim_lines_clm_id_to_outpatient_claims; -${logic.psql-only-alter} table public.outpatient_claims rename constraint "OutpatientClaims_beneficiaryId_to_Beneficiaries" to outpatient_claims_bene_id_to_beneficiaries; - --- hsql only -${logic.hsql-only-alter} table public.outpatient_claim_lines add constraint outpatient_claim_lines_pkey primary key (clm_id, clm_line_num); -${logic.hsql-only-alter} table public.outpatient_claims add constraint outpatient_claims_pkey primary key (clm_id); - -${logic.hsql-only-alter} table public.outpatient_claim_lines ADD CONSTRAINT outpatient_claim_lines_clm_id_to_outpatient_claims FOREIGN KEY (clm_id) REFERENCES public.outpatient_claims (clm_id); -${logic.hsql-only-alter} table public.outpatient_claims ADD CONSTRAINT outpatient_claims_bene_id_to_beneficiaries FOREIGN KEY (bene_id) REFERENCES public.beneficiaries (bene_id); - --- both psql and hsql support non-primary key index renaming -ALTER INDEX "OutpatientClaims_beneficiaryId_idx" RENAME TO outpatient_claims_bene_id_idx; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V47__Table_column_rename_PartDEvents.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V47__Table_column_rename_PartDEvents.sql deleted file mode 100644 index 74a516eb66..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V47__Table_column_rename_PartDEvents.sql +++ /dev/null @@ -1,75 +0,0 @@ --- The V40 through V52 migrations rename our tables and columns for CCW-sourced data, such that: --- 1. We follow PostgreSQL's general snake_case naming conventions, to improve the developer experience: DB --- object names won't have to be quoted all over the place, anymore. --- 2. Column names match those in our upstream source system, the CCW, to improve traceability as data flows --- through our systems. --- 3. Rename the "parentXXX" foreign key columns to instead have names that match their target column. - --- Rename tables and table columns; syntax: --- --- psql: alter table public.beneficiaries rename column "beneficiaryId" to bene_id; --- hsql: alter table public.beneficiaries alter column "beneficiaryId" rename to bene_id; --- --- ${logic.alter-rename-column} --- psql: "rename column" --- hsql: "alter column" --- --- ${logic.rename-to} --- psql: "to" --- hsql: "rename to" --- --- PartDEvents to partd_events --- -alter table public."PartDEvents" rename to partd_events; -alter table public.partd_events ${logic.alter-rename-column} "eventId" ${logic.rename-to} pde_id; -alter table public.partd_events ${logic.alter-rename-column} "beneficiaryId" ${logic.rename-to} bene_id; -alter table public.partd_events ${logic.alter-rename-column} "claimGroupId" ${logic.rename-to} clm_grp_id; -alter table public.partd_events ${logic.alter-rename-column} lastupdated ${logic.rename-to} last_updated; -alter table public.partd_events ${logic.alter-rename-column} "adjustmentDeletionCode" ${logic.rename-to} adjstmt_dltn_cd; -alter table public.partd_events ${logic.alter-rename-column} "brandGenericCode" ${logic.rename-to} brnd_gnrc_cd; -alter table public.partd_events ${logic.alter-rename-column} "compoundCode" ${logic.rename-to} cmpnd_cd; -alter table public.partd_events ${logic.alter-rename-column} "catastrophicCoverageCode" ${logic.rename-to} ctstrphc_cvrg_cd; -alter table public.partd_events ${logic.alter-rename-column} "partDPlanCoveredPaidAmount" ${logic.rename-to} cvrd_d_plan_pd_amt; -alter table public.partd_events ${logic.alter-rename-column} "dispenseAsWrittenProductSelectionCode" ${logic.rename-to} daw_prod_slctn_cd; -alter table public.partd_events ${logic.alter-rename-column} "daysSupply" ${logic.rename-to} days_suply_num; -alter table public.partd_events ${logic.alter-rename-column} "drugCoverageStatusCode" ${logic.rename-to} drug_cvrg_stus_cd; -alter table public.partd_events ${logic.alter-rename-column} "dispensingStatusCode" ${logic.rename-to} dspnsng_stus_cd; -alter table public.partd_events ${logic.alter-rename-column} "fillNumber" ${logic.rename-to} fill_num; -alter table public.partd_events ${logic.alter-rename-column} "finalAction" ${logic.rename-to} final_action; -alter table public.partd_events ${logic.alter-rename-column} "grossCostAboveOutOfPocketThreshold" ${logic.rename-to} gdc_abv_oopt_amt; -alter table public.partd_events ${logic.alter-rename-column} "grossCostBelowOutOfPocketThreshold" ${logic.rename-to} gdc_blw_oopt_amt; -alter table public.partd_events ${logic.alter-rename-column} "lowIncomeSubsidyPaidAmount" ${logic.rename-to} lics_amt; -alter table public.partd_events ${logic.alter-rename-column} "nationalDrugCode" ${logic.rename-to} prod_srvc_id; -alter table public.partd_events ${logic.alter-rename-column} "partDPlanNonCoveredPaidAmount" ${logic.rename-to} ncvrd_plan_pd_amt; -alter table public.partd_events ${logic.alter-rename-column} "nonstandardFormatCode" ${logic.rename-to} nstd_frmt_cd; -alter table public.partd_events ${logic.alter-rename-column} "otherTrueOutOfPocketPaidAmount" ${logic.rename-to} othr_troop_amt; -alter table public.partd_events ${logic.alter-rename-column} "paymentDate" ${logic.rename-to} pd_dt; -alter table public.partd_events ${logic.alter-rename-column} "pharmacyTypeCode" ${logic.rename-to} phrmcy_srvc_type_cd; -alter table public.partd_events ${logic.alter-rename-column} "planContractId" ${logic.rename-to} plan_cntrct_rec_id; -alter table public.partd_events ${logic.alter-rename-column} "planBenefitPackageId" ${logic.rename-to} plan_pbp_rec_num; -alter table public.partd_events ${logic.alter-rename-column} "patientLiabilityReductionOtherPaidAmount" ${logic.rename-to} plro_amt; -alter table public.partd_events ${logic.alter-rename-column} "pricingExceptionCode" ${logic.rename-to} prcng_excptn_cd; -alter table public.partd_events ${logic.alter-rename-column} "prescriberId" ${logic.rename-to} prscrbr_id; -alter table public.partd_events ${logic.alter-rename-column} "prescriberIdQualifierCode" ${logic.rename-to} prscrbr_id_qlfyr_cd; -alter table public.partd_events ${logic.alter-rename-column} "patientPaidAmount" ${logic.rename-to} ptnt_pay_amt; -alter table public.partd_events ${logic.alter-rename-column} "patientResidenceCode" ${logic.rename-to} ptnt_rsdnc_cd; -alter table public.partd_events ${logic.alter-rename-column} "quantityDispensed" ${logic.rename-to} qty_dspnsd_num; -alter table public.partd_events ${logic.alter-rename-column} "gapDiscountAmount" ${logic.rename-to} rptd_gap_dscnt_num; -alter table public.partd_events ${logic.alter-rename-column} "prescriptionOriginationCode" ${logic.rename-to} rx_orgn_cd; -alter table public.partd_events ${logic.alter-rename-column} "prescriptionReferenceNumber" ${logic.rename-to} rx_srvc_rfrnc_num; -alter table public.partd_events ${logic.alter-rename-column} "prescriptionFillDate" ${logic.rename-to} srvc_dt; -alter table public.partd_events ${logic.alter-rename-column} "serviceProviderId" ${logic.rename-to} srvc_prvdr_id; -alter table public.partd_events ${logic.alter-rename-column} "serviceProviderIdQualiferCode" ${logic.rename-to} srvc_prvdr_id_qlfyr_cd; -alter table public.partd_events ${logic.alter-rename-column} "submissionClarificationCode" ${logic.rename-to} submsn_clr_cd; -alter table public.partd_events ${logic.alter-rename-column} "totalPrescriptionCost" ${logic.rename-to} tot_rx_cst_amt; - --- psql only -${logic.psql-only-alter} index if exists public."PartDEvents_pkey" rename to partd_events_pkey; -${logic.psql-only-alter} table public.partd_events rename constraint "PartDEvents_beneficiaryId_to_Beneficiaries" to partd_events_bene_id_to_beneficiaries; - --- hsql only -${logic.hsql-only-alter} table public.partd_events add constraint partd_events_pkey primary key (pde_id); -${logic.hsql-only-alter} table public.partd_events add constraint partd_events_bene_id_to_beneficiaries FOREIGN KEY (bene_id) REFERENCES public.beneficiaries(bene_id); - --- both psql and hsql support non-primary key index renaming -ALTER INDEX "PartDEvents_beneficiaryId_idx" RENAME TO partd_events_bene_id_idx; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V48__Table_column_rename_SNFClaims.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V48__Table_column_rename_SNFClaims.sql deleted file mode 100644 index 059a8f98ca..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V48__Table_column_rename_SNFClaims.sql +++ /dev/null @@ -1,275 +0,0 @@ --- The V40 through V52 migrations rename our tables and columns for CCW-sourced data, such that: --- 1. We follow PostgreSQL's general snake_case naming conventions, to improve the developer experience: DB --- object names won't have to be quoted all over the place, anymore. --- 2. Column names match those in our upstream source system, the CCW, to improve traceability as data flows --- through our systems. --- 3. Rename the "parentXXX" foreign key columns to instead have names that match their target column. - --- Rename tables and table columns; syntax: --- --- psql: alter table public.beneficiaries rename column "beneficiaryId" to bene_id; --- hsql: alter table public.beneficiaries alter column "beneficiaryId" rename to bene_id; --- --- ${logic.alter-rename-column} --- psql: "rename column" --- hsql: "alter column" --- --- ${logic.rename-to} --- psql: "to" --- hsql: "rename to" --- --- SNFClaims to snf_claims --- -alter table public."SNFClaims" rename to snf_claims; -alter table public.snf_claims ${logic.alter-rename-column} "claimId" ${logic.rename-to} clm_id; -alter table public.snf_claims ${logic.alter-rename-column} "beneficiaryId" ${logic.rename-to} bene_id; -alter table public.snf_claims ${logic.alter-rename-column} "claimGroupId" ${logic.rename-to} clm_grp_id; -alter table public.snf_claims ${logic.alter-rename-column} lastupdated ${logic.rename-to} last_updated; -alter table public.snf_claims ${logic.alter-rename-column} "dateFrom" ${logic.rename-to} clm_from_dt; -alter table public.snf_claims ${logic.alter-rename-column} "dateThrough" ${logic.rename-to} clm_thru_dt; -alter table public.snf_claims ${logic.alter-rename-column} "claimAdmissionDate" ${logic.rename-to} clm_admsn_dt; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisRelatedGroupCd" ${logic.rename-to} clm_drg_cd; -alter table public.snf_claims ${logic.alter-rename-column} "claimFacilityTypeCode" ${logic.rename-to} clm_fac_type_cd; -alter table public.snf_claims ${logic.alter-rename-column} "claimFrequencyCode" ${logic.rename-to} clm_freq_cd; -alter table public.snf_claims ${logic.alter-rename-column} "admissionTypeCd" ${logic.rename-to} clm_ip_admsn_type_cd; -alter table public.snf_claims ${logic.alter-rename-column} "mcoPaidSw" ${logic.rename-to} clm_mco_pd_sw; -alter table public.snf_claims ${logic.alter-rename-column} "claimNonPaymentReasonCode" ${logic.rename-to} clm_mdcr_non_pmt_rsn_cd; -alter table public.snf_claims ${logic.alter-rename-column} "nonUtilizationDayCount" ${logic.rename-to} clm_non_utlztn_days_cnt; -alter table public.snf_claims ${logic.alter-rename-column} "paymentAmount" ${logic.rename-to} clm_pmt_amt; -alter table public.snf_claims ${logic.alter-rename-column} "claimPPSCapitalDisproportionateShareAmt" ${logic.rename-to} clm_pps_cptl_dsprprtnt_shr_amt; -alter table public.snf_claims ${logic.alter-rename-column} "claimPPSCapitalExceptionAmount" ${logic.rename-to} clm_pps_cptl_excptn_amt; -alter table public.snf_claims ${logic.alter-rename-column} "claimPPSCapitalFSPAmount" ${logic.rename-to} clm_pps_cptl_fsp_amt; -alter table public.snf_claims ${logic.alter-rename-column} "claimPPSCapitalIMEAmount" ${logic.rename-to} clm_pps_cptl_ime_amt; -alter table public.snf_claims ${logic.alter-rename-column} "claimPPSCapitalOutlierAmount" ${logic.rename-to} clm_pps_cptl_outlier_amt; -alter table public.snf_claims ${logic.alter-rename-column} "prospectivePaymentCode" ${logic.rename-to} clm_pps_ind_cd; -alter table public.snf_claims ${logic.alter-rename-column} "claimPPSOldCapitalHoldHarmlessAmount" ${logic.rename-to} clm_pps_old_cptl_hld_hrmls_amt; -alter table public.snf_claims ${logic.alter-rename-column} "sourceAdmissionCd" ${logic.rename-to} clm_src_ip_admsn_cd; -alter table public.snf_claims ${logic.alter-rename-column} "claimServiceClassificationTypeCode" ${logic.rename-to} clm_srvc_clsfctn_type_cd; -alter table public.snf_claims ${logic.alter-rename-column} "utilizationDayCount" ${logic.rename-to} clm_utlztn_day_cnt; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisAdmittingCode" ${logic.rename-to} admtg_dgns_cd; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisAdmittingCodeVersion" ${logic.rename-to} admtg_dgns_vrsn_cd; -alter table public.snf_claims ${logic.alter-rename-column} "attendingPhysicianNpi" ${logic.rename-to} at_physn_npi; -alter table public.snf_claims ${logic.alter-rename-column} "attendingPhysicianUpin" ${logic.rename-to} at_physn_upin; -alter table public.snf_claims ${logic.alter-rename-column} "coinsuranceDayCount" ${logic.rename-to} bene_tot_coinsrnc_days_cnt; -alter table public.snf_claims ${logic.alter-rename-column} "claimQueryCode" ${logic.rename-to} claim_query_code; -alter table public.snf_claims ${logic.alter-rename-column} "fiscalIntermediaryClaimActionCode" ${logic.rename-to} fi_clm_actn_cd; -alter table public.snf_claims ${logic.alter-rename-column} "fiscalIntermediaryClaimProcessDate" ${logic.rename-to} fi_clm_proc_dt; -alter table public.snf_claims ${logic.alter-rename-column} "fiDocumentClaimControlNumber" ${logic.rename-to} fi_doc_clm_cntl_num; -alter table public.snf_claims ${logic.alter-rename-column} "fiscalIntermediaryNumber" ${logic.rename-to} fi_num; -alter table public.snf_claims ${logic.alter-rename-column} "fiOriginalClaimControlNumber" ${logic.rename-to} fi_orig_clm_cntl_num; -alter table public.snf_claims ${logic.alter-rename-column} "finalAction" ${logic.rename-to} final_action; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternalFirstCode" ${logic.rename-to} fst_dgns_e_cd; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternalFirstCodeVersion" ${logic.rename-to} fst_dgns_e_vrsn_cd; -alter table public.snf_claims ${logic.alter-rename-column} "coveredCareThroughDate" ${logic.rename-to} nch_actv_or_cvrd_lvl_care_thru; -alter table public.snf_claims ${logic.alter-rename-column} "bloodDeductibleLiabilityAmount" ${logic.rename-to} nch_bene_blood_ddctbl_lblty_am; -alter table public.snf_claims ${logic.alter-rename-column} "beneficiaryDischargeDate" ${logic.rename-to} nch_bene_dschrg_dt; -alter table public.snf_claims ${logic.alter-rename-column} "deductibleAmount" ${logic.rename-to} nch_bene_ip_ddctbl_amt; -alter table public.snf_claims ${logic.alter-rename-column} "medicareBenefitsExhaustedDate" ${logic.rename-to} nch_bene_mdcr_bnfts_exhtd_dt_i; -alter table public.snf_claims ${logic.alter-rename-column} "partACoinsuranceLiabilityAmount" ${logic.rename-to} nch_bene_pta_coinsrnc_lblty_am; -alter table public.snf_claims ${logic.alter-rename-column} "bloodPintsFurnishedQty" ${logic.rename-to} nch_blood_pnts_frnshd_qty; -alter table public.snf_claims ${logic.alter-rename-column} "claimTypeCode" ${logic.rename-to} nch_clm_type_cd; -alter table public.snf_claims ${logic.alter-rename-column} "noncoveredCharge" ${logic.rename-to} nch_ip_ncvrd_chrg_amt; -alter table public.snf_claims ${logic.alter-rename-column} "totalDeductionAmount" ${logic.rename-to} nch_ip_tot_ddctn_amt; -alter table public.snf_claims ${logic.alter-rename-column} "nearLineRecordIdCode" ${logic.rename-to} nch_near_line_rec_ident_cd; -alter table public.snf_claims ${logic.alter-rename-column} "claimPrimaryPayerCode" ${logic.rename-to} nch_prmry_pyr_cd; -alter table public.snf_claims ${logic.alter-rename-column} "primaryPayerPaidAmount" ${logic.rename-to} nch_prmry_pyr_clm_pd_amt; -alter table public.snf_claims ${logic.alter-rename-column} "patientStatusCd" ${logic.rename-to} nch_ptnt_status_ind_cd; -alter table public.snf_claims ${logic.alter-rename-column} "qualifiedStayFromDate" ${logic.rename-to} nch_qlfyd_stay_from_dt; -alter table public.snf_claims ${logic.alter-rename-column} "qualifiedStayThroughDate" ${logic.rename-to} nch_qlfyd_stay_thru_dt; -alter table public.snf_claims ${logic.alter-rename-column} "noncoveredStayFromDate" ${logic.rename-to} nch_vrfd_ncvrd_stay_from_dt; -alter table public.snf_claims ${logic.alter-rename-column} "noncoveredStayThroughDate" ${logic.rename-to} nch_vrfd_ncvrd_stay_thru_dt; -alter table public.snf_claims ${logic.alter-rename-column} "weeklyProcessDate" ${logic.rename-to} nch_wkly_proc_dt; -alter table public.snf_claims ${logic.alter-rename-column} "operatingPhysicianNpi" ${logic.rename-to} op_physn_npi; -alter table public.snf_claims ${logic.alter-rename-column} "operatingPhysicianUpin" ${logic.rename-to} op_physn_upin; -alter table public.snf_claims ${logic.alter-rename-column} "organizationNpi" ${logic.rename-to} org_npi_num; -alter table public.snf_claims ${logic.alter-rename-column} "otherPhysicianNpi" ${logic.rename-to} ot_physn_npi; -alter table public.snf_claims ${logic.alter-rename-column} "otherPhysicianUpin" ${logic.rename-to} ot_physn_upin; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisPrincipalCode" ${logic.rename-to} prncpal_dgns_cd; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisPrincipalCodeVersion" ${logic.rename-to} prncpal_dgns_vrsn_cd; -alter table public.snf_claims ${logic.alter-rename-column} "providerNumber" ${logic.rename-to} prvdr_num; -alter table public.snf_claims ${logic.alter-rename-column} "providerStateCode" ${logic.rename-to} prvdr_state_cd; -alter table public.snf_claims ${logic.alter-rename-column} "patientDischargeStatusCode" ${logic.rename-to} ptnt_dschrg_stus_cd; -alter table public.snf_claims ${logic.alter-rename-column} "totalChargeAmount" ${logic.rename-to} clm_tot_chrg_amt; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis1Code" ${logic.rename-to} icd_dgns_cd1; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis2Code" ${logic.rename-to} icd_dgns_cd2; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis3Code" ${logic.rename-to} icd_dgns_cd3; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis4Code" ${logic.rename-to} icd_dgns_cd4; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis5Code" ${logic.rename-to} icd_dgns_cd5; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis6Code" ${logic.rename-to} icd_dgns_cd6; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis7Code" ${logic.rename-to} icd_dgns_cd7; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis8Code" ${logic.rename-to} icd_dgns_cd8; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis9Code" ${logic.rename-to} icd_dgns_cd9; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis10Code" ${logic.rename-to} icd_dgns_cd10; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis11Code" ${logic.rename-to} icd_dgns_cd11; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis12Code" ${logic.rename-to} icd_dgns_cd12; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis13Code" ${logic.rename-to} icd_dgns_cd13; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis14Code" ${logic.rename-to} icd_dgns_cd14; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis15Code" ${logic.rename-to} icd_dgns_cd15; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis16Code" ${logic.rename-to} icd_dgns_cd16; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis17Code" ${logic.rename-to} icd_dgns_cd17; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis18Code" ${logic.rename-to} icd_dgns_cd18; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis19Code" ${logic.rename-to} icd_dgns_cd19; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis20Code" ${logic.rename-to} icd_dgns_cd20; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis21Code" ${logic.rename-to} icd_dgns_cd21; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis22Code" ${logic.rename-to} icd_dgns_cd22; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis23Code" ${logic.rename-to} icd_dgns_cd23; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis24Code" ${logic.rename-to} icd_dgns_cd24; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis25Code" ${logic.rename-to} icd_dgns_cd25; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal1Code" ${logic.rename-to} icd_dgns_e_cd1; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal2Code" ${logic.rename-to} icd_dgns_e_cd2; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal3Code" ${logic.rename-to} icd_dgns_e_cd3; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal4Code" ${logic.rename-to} icd_dgns_e_cd4; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal5Code" ${logic.rename-to} icd_dgns_e_cd5; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal6Code" ${logic.rename-to} icd_dgns_e_cd6; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal7Code" ${logic.rename-to} icd_dgns_e_cd7; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal8Code" ${logic.rename-to} icd_dgns_e_cd8; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal9Code" ${logic.rename-to} icd_dgns_e_cd9; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal10Code" ${logic.rename-to} icd_dgns_e_cd10; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal11Code" ${logic.rename-to} icd_dgns_e_cd11; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal12Code" ${logic.rename-to} icd_dgns_e_cd12; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal1CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd1; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal2CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd2; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal3CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd3; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal4CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd4; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal5CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd5; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal6CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd6; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal7CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd7; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal8CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd8; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal9CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd9; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal10CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd10; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal11CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd11; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosisExternal12CodeVersion" ${logic.rename-to} icd_dgns_e_vrsn_cd12; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis1CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd1; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis2CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd2; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis3CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd3; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis4CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd4; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis5CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd5; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis6CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd6; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis7CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd7; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis8CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd8; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis9CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd9; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis10CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd10; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis11CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd11; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis12CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd12; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis13CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd13; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis14CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd14; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis15CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd15; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis16CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd16; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis17CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd17; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis18CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd18; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis19CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd19; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis20CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd20; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis21CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd21; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis22CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd22; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis23CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd23; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis24CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd24; -alter table public.snf_claims ${logic.alter-rename-column} "diagnosis25CodeVersion" ${logic.rename-to} icd_dgns_vrsn_cd25; -alter table public.snf_claims ${logic.alter-rename-column} "procedure1Code" ${logic.rename-to} icd_prcdr_cd1; -alter table public.snf_claims ${logic.alter-rename-column} "procedure2Code" ${logic.rename-to} icd_prcdr_cd2; -alter table public.snf_claims ${logic.alter-rename-column} "procedure3Code" ${logic.rename-to} icd_prcdr_cd3; -alter table public.snf_claims ${logic.alter-rename-column} "procedure4Code" ${logic.rename-to} icd_prcdr_cd4; -alter table public.snf_claims ${logic.alter-rename-column} "procedure5Code" ${logic.rename-to} icd_prcdr_cd5; -alter table public.snf_claims ${logic.alter-rename-column} "procedure6Code" ${logic.rename-to} icd_prcdr_cd6; -alter table public.snf_claims ${logic.alter-rename-column} "procedure7Code" ${logic.rename-to} icd_prcdr_cd7; -alter table public.snf_claims ${logic.alter-rename-column} "procedure8Code" ${logic.rename-to} icd_prcdr_cd8; -alter table public.snf_claims ${logic.alter-rename-column} "procedure9Code" ${logic.rename-to} icd_prcdr_cd9; -alter table public.snf_claims ${logic.alter-rename-column} "procedure10Code" ${logic.rename-to} icd_prcdr_cd10; -alter table public.snf_claims ${logic.alter-rename-column} "procedure11Code" ${logic.rename-to} icd_prcdr_cd11; -alter table public.snf_claims ${logic.alter-rename-column} "procedure12Code" ${logic.rename-to} icd_prcdr_cd12; -alter table public.snf_claims ${logic.alter-rename-column} "procedure13Code" ${logic.rename-to} icd_prcdr_cd13; -alter table public.snf_claims ${logic.alter-rename-column} "procedure14Code" ${logic.rename-to} icd_prcdr_cd14; -alter table public.snf_claims ${logic.alter-rename-column} "procedure15Code" ${logic.rename-to} icd_prcdr_cd15; -alter table public.snf_claims ${logic.alter-rename-column} "procedure16Code" ${logic.rename-to} icd_prcdr_cd16; -alter table public.snf_claims ${logic.alter-rename-column} "procedure17Code" ${logic.rename-to} icd_prcdr_cd17; -alter table public.snf_claims ${logic.alter-rename-column} "procedure18Code" ${logic.rename-to} icd_prcdr_cd18; -alter table public.snf_claims ${logic.alter-rename-column} "procedure19Code" ${logic.rename-to} icd_prcdr_cd19; -alter table public.snf_claims ${logic.alter-rename-column} "procedure20Code" ${logic.rename-to} icd_prcdr_cd20; -alter table public.snf_claims ${logic.alter-rename-column} "procedure21Code" ${logic.rename-to} icd_prcdr_cd21; -alter table public.snf_claims ${logic.alter-rename-column} "procedure22Code" ${logic.rename-to} icd_prcdr_cd22; -alter table public.snf_claims ${logic.alter-rename-column} "procedure23Code" ${logic.rename-to} icd_prcdr_cd23; -alter table public.snf_claims ${logic.alter-rename-column} "procedure24Code" ${logic.rename-to} icd_prcdr_cd24; -alter table public.snf_claims ${logic.alter-rename-column} "procedure25Code" ${logic.rename-to} icd_prcdr_cd25; -alter table public.snf_claims ${logic.alter-rename-column} "procedure1CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd1; -alter table public.snf_claims ${logic.alter-rename-column} "procedure2CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd2; -alter table public.snf_claims ${logic.alter-rename-column} "procedure3CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd3; -alter table public.snf_claims ${logic.alter-rename-column} "procedure4CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd4; -alter table public.snf_claims ${logic.alter-rename-column} "procedure5CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd5; -alter table public.snf_claims ${logic.alter-rename-column} "procedure6CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd6; -alter table public.snf_claims ${logic.alter-rename-column} "procedure7CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd7; -alter table public.snf_claims ${logic.alter-rename-column} "procedure8CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd8; -alter table public.snf_claims ${logic.alter-rename-column} "procedure9CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd9; -alter table public.snf_claims ${logic.alter-rename-column} "procedure10CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd10; -alter table public.snf_claims ${logic.alter-rename-column} "procedure11CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd11; -alter table public.snf_claims ${logic.alter-rename-column} "procedure12CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd12; -alter table public.snf_claims ${logic.alter-rename-column} "procedure13CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd13; -alter table public.snf_claims ${logic.alter-rename-column} "procedure14CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd14; -alter table public.snf_claims ${logic.alter-rename-column} "procedure15CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd15; -alter table public.snf_claims ${logic.alter-rename-column} "procedure16CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd16; -alter table public.snf_claims ${logic.alter-rename-column} "procedure17CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd17; -alter table public.snf_claims ${logic.alter-rename-column} "procedure18CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd18; -alter table public.snf_claims ${logic.alter-rename-column} "procedure19CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd19; -alter table public.snf_claims ${logic.alter-rename-column} "procedure20CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd20; -alter table public.snf_claims ${logic.alter-rename-column} "procedure21CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd21; -alter table public.snf_claims ${logic.alter-rename-column} "procedure22CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd22; -alter table public.snf_claims ${logic.alter-rename-column} "procedure23CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd23; -alter table public.snf_claims ${logic.alter-rename-column} "procedure24CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd24; -alter table public.snf_claims ${logic.alter-rename-column} "procedure25CodeVersion" ${logic.rename-to} icd_prcdr_vrsn_cd25; -alter table public.snf_claims ${logic.alter-rename-column} "procedure1Date" ${logic.rename-to} prcdr_dt1; -alter table public.snf_claims ${logic.alter-rename-column} "procedure2Date" ${logic.rename-to} prcdr_dt2; -alter table public.snf_claims ${logic.alter-rename-column} "procedure3Date" ${logic.rename-to} prcdr_dt3; -alter table public.snf_claims ${logic.alter-rename-column} "procedure4Date" ${logic.rename-to} prcdr_dt4; -alter table public.snf_claims ${logic.alter-rename-column} "procedure5Date" ${logic.rename-to} prcdr_dt5; -alter table public.snf_claims ${logic.alter-rename-column} "procedure6Date" ${logic.rename-to} prcdr_dt6; -alter table public.snf_claims ${logic.alter-rename-column} "procedure7Date" ${logic.rename-to} prcdr_dt7; -alter table public.snf_claims ${logic.alter-rename-column} "procedure8Date" ${logic.rename-to} prcdr_dt8; -alter table public.snf_claims ${logic.alter-rename-column} "procedure9Date" ${logic.rename-to} prcdr_dt9; -alter table public.snf_claims ${logic.alter-rename-column} "procedure10Date" ${logic.rename-to} prcdr_dt10; -alter table public.snf_claims ${logic.alter-rename-column} "procedure11Date" ${logic.rename-to} prcdr_dt11; -alter table public.snf_claims ${logic.alter-rename-column} "procedure12Date" ${logic.rename-to} prcdr_dt12; -alter table public.snf_claims ${logic.alter-rename-column} "procedure13Date" ${logic.rename-to} prcdr_dt13; -alter table public.snf_claims ${logic.alter-rename-column} "procedure14Date" ${logic.rename-to} prcdr_dt14; -alter table public.snf_claims ${logic.alter-rename-column} "procedure15Date" ${logic.rename-to} prcdr_dt15; -alter table public.snf_claims ${logic.alter-rename-column} "procedure16Date" ${logic.rename-to} prcdr_dt16; -alter table public.snf_claims ${logic.alter-rename-column} "procedure17Date" ${logic.rename-to} prcdr_dt17; -alter table public.snf_claims ${logic.alter-rename-column} "procedure18Date" ${logic.rename-to} prcdr_dt18; -alter table public.snf_claims ${logic.alter-rename-column} "procedure19Date" ${logic.rename-to} prcdr_dt19; -alter table public.snf_claims ${logic.alter-rename-column} "procedure20Date" ${logic.rename-to} prcdr_dt20; -alter table public.snf_claims ${logic.alter-rename-column} "procedure21Date" ${logic.rename-to} prcdr_dt21; -alter table public.snf_claims ${logic.alter-rename-column} "procedure22Date" ${logic.rename-to} prcdr_dt22; -alter table public.snf_claims ${logic.alter-rename-column} "procedure23Date" ${logic.rename-to} prcdr_dt23; -alter table public.snf_claims ${logic.alter-rename-column} "procedure24Date" ${logic.rename-to} prcdr_dt24; -alter table public.snf_claims ${logic.alter-rename-column} "procedure25Date" ${logic.rename-to} prcdr_dt25; --- --- SNFClaimLines to snf_claim_lines --- -alter table public."SNFClaimLines" rename to snf_claim_lines; -alter table public.snf_claim_lines ${logic.alter-rename-column} "parentClaim" ${logic.rename-to} clm_id; -alter table public.snf_claim_lines ${logic.alter-rename-column} "lineNumber" ${logic.rename-to} clm_line_num; -alter table public.snf_claim_lines ${logic.alter-rename-column} "hcpcsCode" ${logic.rename-to} hcpcs_cd; -alter table public.snf_claim_lines ${logic.alter-rename-column} "revenueCenter" ${logic.rename-to} rev_cntr; -alter table public.snf_claim_lines ${logic.alter-rename-column} "nationalDrugCodeQualifierCode" ${logic.rename-to} rev_cntr_ndc_qty_qlfr_cd; -alter table public.snf_claim_lines ${logic.alter-rename-column} "nationalDrugCodeQuantity" ${logic.rename-to} rev_cntr_ndc_qty; -alter table public.snf_claim_lines ${logic.alter-rename-column} "nonCoveredChargeAmount" ${logic.rename-to} rev_cntr_ncvrd_chrg_amt; -alter table public.snf_claim_lines ${logic.alter-rename-column} "rateAmount" ${logic.rename-to} rev_cntr_rate_amt; -alter table public.snf_claim_lines ${logic.alter-rename-column} "totalChargeAmount" ${logic.rename-to} rev_cntr_tot_chrg_amt; -alter table public.snf_claim_lines ${logic.alter-rename-column} "deductibleCoinsuranceCd" ${logic.rename-to} rev_cntr_ddctbl_coinsrnc_cd; -alter table public.snf_claim_lines ${logic.alter-rename-column} "unitCount" ${logic.rename-to} rev_cntr_unit_cnt; -alter table public.snf_claim_lines ${logic.alter-rename-column} "revenueCenterRenderingPhysicianNPI" ${logic.rename-to} rndrng_physn_npi; -alter table public.snf_claim_lines ${logic.alter-rename-column} "revenueCenterRenderingPhysicianUPIN" ${logic.rename-to} rndrng_physn_upin; - --- psql only -${logic.psql-only-alter} index if exists public."SNFClaimLines_pkey" rename to snf_claim_lines_pkey; -${logic.psql-only-alter} index if exists public."SNFClaims_pkey" rename to snf_claims_pkey; - -${logic.psql-only-alter} table public.snf_claim_lines rename constraint "SNFClaimLines_parentClaim_to_SNFClaims" to snf_claim_lines_clm_id_to_snf_claims; -${logic.psql-only-alter} table public.snf_claims rename constraint "SNFClaims_beneficiaryId_to_Beneficiaries" to snf_claims_bene_id_to_beneficiaries; - --- hsql only -${logic.hsql-only-alter} table public.snf_claim_lines add constraint snf_claim_lines_pkey primary key (clm_id, clm_line_num); -${logic.hsql-only-alter} table public.snf_claims add constraint snf_claims_pkey primary key (clm_id); - -${logic.hsql-only-alter} table public.snf_claim_lines ADD CONSTRAINT snf_claim_lines_clm_id_to_snf_claims FOREIGN KEY (clm_id) REFERENCES public.snf_claims (clm_id); -${logic.hsql-only-alter} table public.snf_claims ADD CONSTRAINT snf_claims_bene_id_to_beneficiaries FOREIGN KEY (bene_id) REFERENCES public.beneficiaries(bene_id); - --- both psql and hsql support non-primary key index renaming -ALTER INDEX "SNFClaims_beneficiaryId_idx" RENAME TO snf_claims_bene_id_idx; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V49__Table_column_rename_BeneHistory.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V49__Table_column_rename_BeneHistory.sql deleted file mode 100644 index 44568bc465..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V49__Table_column_rename_BeneHistory.sql +++ /dev/null @@ -1,62 +0,0 @@ --- The V40 through V52 migrations rename our tables and columns for CCW-sourced data, such that: --- 1. We follow PostgreSQL's general snake_case naming conventions, to improve the developer experience: DB --- object names won't have to be quoted all over the place, anymore. --- 2. Column names match those in our upstream source system, the CCW, to improve traceability as data flows --- through our systems. --- 3. Rename the "parentXXX" foreign key columns to instead have names that match their target column. - --- Rename tables and table columns; syntax: --- --- psql: alter table public.beneficiaries rename column "beneficiaryId" to bene_id; --- hsql: alter table public.beneficiaries alter column "beneficiaryId" rename to bene_id; --- --- ${logic.alter-rename-column} --- psql: "rename column" --- hsql: "alter column" --- --- ${logic.rename-to} --- psql: "to" --- hsql: "rename to" --- --- BeneficiariesHistory to beneficiaries_history --- -alter table public."BeneficiariesHistory" rename to beneficiaries_history; -alter table public.beneficiaries_history ${logic.alter-rename-column} "beneficiaryHistoryId" ${logic.rename-to} bene_history_id; -alter table public.beneficiaries_history ${logic.alter-rename-column} "beneficiaryId" ${logic.rename-to} bene_id; -alter table public.beneficiaries_history ${logic.alter-rename-column} "birthDate" ${logic.rename-to} bene_birth_dt; -alter table public.beneficiaries_history ${logic.alter-rename-column} "sex" ${logic.rename-to} bene_sex_ident_cd; -alter table public.beneficiaries_history ${logic.alter-rename-column} "hicn" ${logic.rename-to} bene_crnt_hic_num; -alter table public.beneficiaries_history ${logic.alter-rename-column} "medicareBeneficiaryId" ${logic.rename-to} mbi_num; -alter table public.beneficiaries_history ${logic.alter-rename-column} "hicnUnhashed" ${logic.rename-to} hicn_unhashed; -alter table public.beneficiaries_history ${logic.alter-rename-column} "mbiHash" ${logic.rename-to} mbi_hash; -alter table public.beneficiaries_history ${logic.alter-rename-column} "mbiEffectiveDate" ${logic.rename-to} efctv_bgn_dt; -alter table public.beneficiaries_history ${logic.alter-rename-column} "mbiObsoleteDate" ${logic.rename-to} efctv_end_dt; -alter table public.beneficiaries_history ${logic.alter-rename-column} lastupdated ${logic.rename-to} last_updated; --- --- BeneficiariesHistoryInvalidBeneficiaries to beneficiaries_history_invalid_beneficiaries --- -alter table public."BeneficiariesHistoryInvalidBeneficiaries" rename to beneficiaries_history_invalid_beneficiaries; -alter table public.beneficiaries_history_invalid_beneficiaries ${logic.alter-rename-column} "beneficiaryHistoryId" ${logic.rename-to} bene_history_id; -alter table public.beneficiaries_history_invalid_beneficiaries ${logic.alter-rename-column} "beneficiaryId" ${logic.rename-to} bene_id; -alter table public.beneficiaries_history_invalid_beneficiaries ${logic.alter-rename-column} "birthDate" ${logic.rename-to} bene_birth_dt; -alter table public.beneficiaries_history_invalid_beneficiaries ${logic.alter-rename-column} "sex" ${logic.rename-to} bene_sex_ident_cd; -alter table public.beneficiaries_history_invalid_beneficiaries ${logic.alter-rename-column} "hicn" ${logic.rename-to} bene_crnt_hic_num; -alter table public.beneficiaries_history_invalid_beneficiaries ${logic.alter-rename-column} "medicareBeneficiaryId" ${logic.rename-to} mbi_num; -alter table public.beneficiaries_history_invalid_beneficiaries ${logic.alter-rename-column} "hicnUnhashed" ${logic.rename-to} hicn_unhashed; - --- psql only -${logic.psql-only-alter} index if exists public."BeneficiariesHistoryInvalidBeneficiaries_pkey" rename to beneficiaries_history_invalid_beneficiaries_pkey; -${logic.psql-only-alter} index if exists public."BeneficiariesHistory_pkey" rename to beneficiaries_history_pkey; - -${logic.psql-only-alter} table public.beneficiaries_history rename constraint "BeneficiariesHistory_beneficiaryId_to_Beneficiary" to beneficiaries_history_bene_id_to_beneficiary; - --- hsql only -${logic.hsql-only-alter} table public.beneficiaries_history add constraint beneficiaries_history_pkey primary key (bene_history_id); -${logic.hsql-only-alter} table public.beneficiaries_history_invalid_beneficiaries add constraint beneficiaries_history_invalid_beneficiaries_pkey primary key (bene_history_id); - -${logic.hsql-only-alter} table public.beneficiaries_history ADD CONSTRAINT beneficiaries_history_bene_id_to_beneficiary FOREIGN KEY (bene_id) REFERENCES public.beneficiaries (bene_id); - --- both psql and hsql support non-primary key index renaming -ALTER INDEX "BeneficiariesHistory_beneficiaryId_idx" RENAME TO beneficiaries_history_bene_id_idx; -ALTER INDEX "BeneficiariesHistory_hicn_idx" RENAME TO beneficiaries_history_hicn_idx; -ALTER INDEX "Beneficiaries_history_mbi_hash_idx" RENAME TO beneficiaries_history_mbi_hash_idx; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V4__Correct_claim_line_index_ordering.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V4__Correct_claim_line_index_ordering.sql deleted file mode 100644 index 25cecf9b25..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V4__Correct_claim_line_index_ordering.sql +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Rebuilds the claim line tables' PK indexes to have the correct column order: - * `parentClaim` columns should always be the first index column, allowing for - * fast WHERE clauses using these searches. - * - * See http://issues.hhsdevcloud.us/browse/CBBD-297. - */ - -alter table "CarrierClaimLines" - drop constraint "CarrierClaimLines_pkey"; -alter table "CarrierClaimLines" - add constraint "CarrierClaimLines_pkey" - primary key ("parentClaim", "lineNumber"); - -alter table "DMEClaimLines" - drop constraint "DMEClaimLines_pkey"; -alter table "DMEClaimLines" - add constraint "DMEClaimLines_pkey" - primary key ("parentClaim", "lineNumber"); - -alter table "HHAClaimLines" - drop constraint "HHAClaimLines_pkey"; -alter table "HHAClaimLines" - add constraint "HHAClaimLines_pkey" - primary key ("parentClaim", "lineNumber"); - -alter table "HospiceClaimLines" - drop constraint "HospiceClaimLines_pkey"; -alter table "HospiceClaimLines" - add constraint "HospiceClaimLines_pkey" - primary key ("parentClaim", "lineNumber"); - -alter table "InpatientClaimLines" - drop constraint "InpatientClaimLines_pkey"; -alter table "InpatientClaimLines" - add constraint "InpatientClaimLines_pkey" - primary key ("parentClaim", "lineNumber"); - -alter table "OutpatientClaimLines" - drop constraint "OutpatientClaimLines_pkey"; -alter table "OutpatientClaimLines" - add constraint "OutpatientClaimLines_pkey" - primary key ("parentClaim", "lineNumber"); - -alter table "SNFClaimLines" - drop constraint "SNFClaimLines_pkey"; -alter table "SNFClaimLines" - add constraint "SNFClaimLines_pkey" - primary key ("parentClaim", "lineNumber"); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V50__Table_column_rename_BeneMonthly.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V50__Table_column_rename_BeneMonthly.sql deleted file mode 100644 index 8d364c5607..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V50__Table_column_rename_BeneMonthly.sql +++ /dev/null @@ -1,52 +0,0 @@ --- The V40 through V52 migrations rename our tables and columns for CCW-sourced data, such that: --- 1. We follow PostgreSQL's general snake_case naming conventions, to improve the developer experience: DB --- object names won't have to be quoted all over the place, anymore. --- 2. Column names match those in our upstream source system, the CCW, to improve traceability as data flows --- through our systems. --- 3. Rename the "parentXXX" foreign key columns to instead have names that match their target column. - --- Rename tables and table columns; syntax: --- --- psql: alter table public.beneficiaries rename column "beneficiaryId" to bene_id; --- hsql: alter table public.beneficiaries alter column "beneficiaryId" rename to bene_id; --- --- ${logic.alter-rename-column} --- psql: "rename column" --- hsql: "alter column" --- --- ${logic.rename-to} --- psql: "to" --- hsql: "rename to" --- --- BeneficiaryMonthly to beneficiary_monthly --- -alter table public."BeneficiaryMonthly" rename to beneficiary_monthly; -alter table public.beneficiary_monthly ${logic.alter-rename-column} "yearMonth" ${logic.rename-to} year_month; -alter table public.beneficiary_monthly ${logic.alter-rename-column} "parentBeneficiary" ${logic.rename-to} bene_id; -alter table public.beneficiary_monthly ${logic.alter-rename-column} "partDContractNumberId" ${logic.rename-to} partd_contract_number_id; -alter table public.beneficiary_monthly ${logic.alter-rename-column} "partCContractNumberId" ${logic.rename-to} partc_contract_number_id; -alter table public.beneficiary_monthly ${logic.alter-rename-column} "fipsStateCntyCode" ${logic.rename-to} fips_state_cnty_code; -alter table public.beneficiary_monthly ${logic.alter-rename-column} "medicareStatusCode" ${logic.rename-to} medicare_status_code; -alter table public.beneficiary_monthly ${logic.alter-rename-column} "entitlementBuyInInd" ${logic.rename-to} entitlement_buy_in_ind; -alter table public.beneficiary_monthly ${logic.alter-rename-column} "hmoIndicatorInd" ${logic.rename-to} hmo_indicator_ind; -alter table public.beneficiary_monthly ${logic.alter-rename-column} "partCPbpNumberId" ${logic.rename-to} partc_pbp_number_id; -alter table public.beneficiary_monthly ${logic.alter-rename-column} "partCPlanTypeCode" ${logic.rename-to} partc_plan_type_code; -alter table public.beneficiary_monthly ${logic.alter-rename-column} "partDPbpNumberId" ${logic.rename-to} partd_pbp_number_id; -alter table public.beneficiary_monthly ${logic.alter-rename-column} "partDSegmentNumberId" ${logic.rename-to} partd_segment_number_id; -alter table public.beneficiary_monthly ${logic.alter-rename-column} "partDRetireeDrugSubsidyInd" ${logic.rename-to} partd_retiree_drug_subsidy_ind; -alter table public.beneficiary_monthly ${logic.alter-rename-column} "partDLowIncomeCostShareGroupCode" ${logic.rename-to} partd_low_income_cost_share_group_code; -alter table public.beneficiary_monthly ${logic.alter-rename-column} "medicaidDualEligibilityCode" ${logic.rename-to} medicaid_dual_eligibility_code; - --- psql only -${logic.psql-only-alter} index if exists public."BeneficiaryMonthly_pkey" rename to beneficiary_monthly_pkey; - -${logic.psql-only-alter} table public.beneficiary_monthly rename constraint "BeneficiaryMonthly_parentBeneficiary_to_Beneficiary" to beneficiary_monthly_bene_id_to_beneficiary; - --- hsql only -${logic.hsql-only-alter} table public.beneficiary_monthly add constraint beneficiary_monthly_pkey primary key (bene_id, year_month); - -${logic.hsql-only-alter} table public.beneficiary_monthly ADD CONSTRAINT beneficiary_monthly_bene_id_to_beneficiary FOREIGN KEY (bene_id) REFERENCES public.beneficiaries (bene_id); - --- both psql and hsql support non-primary key index renaming -ALTER INDEX "BeneficiaryMonthly_partDContractNumId_yearMonth_parentBene_idx" RENAME TO beneficiary_monthly_year_month_partd_contract_bene_id_idx; -ALTER INDEX "BeneficiaryMonthly_partDContractNumberId_yearmonth_idx" RENAME TO beneficiary_monthly_partd_contract_number_year_month_idx; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V51__Table_column_rename_LoadedBatch.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V51__Table_column_rename_LoadedBatch.sql deleted file mode 100644 index 82debd885c..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V51__Table_column_rename_LoadedBatch.sql +++ /dev/null @@ -1,64 +0,0 @@ --- The V40 through V52 migrations rename our tables and columns for CCW-sourced data, such that: --- 1. We follow PostgreSQL's general snake_case naming conventions, to improve the developer experience: DB --- object names won't have to be quoted all over the place, anymore. --- 2. Column names match those in our upstream source system, the CCW, to improve traceability as data flows --- through our systems. --- 3. Rename the "parentXXX" foreign key columns to instead have names that match their target column. - --- Rename tables and table columns; syntax: --- --- psql: alter table public.beneficiaries rename column "beneficiaryId" to bene_id; --- hsql: alter table public.beneficiaries alter column "beneficiaryId" rename to bene_id; --- --- ${logic.alter-rename-column} --- psql: "rename column" --- hsql: "alter column" --- --- ${logic.rename-to} --- psql: "to" --- hsql: "rename to" --- --- LoadedFiles to loaded_files --- --- We have a bit of a funky condition between psql and hsql; for both loaded_files and loaded_batches --- there is a column called "created". For psql there is no need to do a rename; in fact if we tried --- to do something like: --- --- psql: alter table public.loaded_files rename column "created" to created --- --- we'd get an error. So in theory, maybe we don't even need to do a rename for that type of condition. --- However, in hsql, if we don't do a rename, we end up with a column called "created" (literally, --- meaning the double-quotes are an integral part of the column name). So for hsql we do need to --- perform the rename so we can rid the column name of the double-quotes. --- --- ${logic.hsql-only-alter} --- psql: "--" --- hsql: "alter" --- -alter table public."LoadedFiles" rename to loaded_files; -alter table public.loaded_files ${logic.alter-rename-column} "loadedFileId" ${logic.rename-to} loaded_file_id; -alter table public.loaded_files ${logic.alter-rename-column} "rifType" ${logic.rename-to} rif_type; -${logic.hsql-only-alter} table public.loaded_files ${logic.alter-rename-column} "created" ${logic.rename-to} created; --- --- LoadedBatches to loaded_batches --- -alter table public."LoadedBatches" rename to loaded_batches; -alter table public.loaded_batches ${logic.alter-rename-column} "loadedBatchId" ${logic.rename-to} loaded_batch_id; -alter table public.loaded_batches ${logic.alter-rename-column} "loadedFileId" ${logic.rename-to} loaded_file_id; -${logic.hsql-only-alter} table public.loaded_batches ${logic.alter-rename-column} "beneficiaries" ${logic.rename-to} beneficiaries; -${logic.hsql-only-alter} table public.loaded_batches ${logic.alter-rename-column} "created" ${logic.rename-to} created; - --- psql only -${logic.psql-only-alter} index if exists public."LoadedBatches_pkey" rename to loaded_batches_pkey; -${logic.psql-only-alter} index if exists public."LoadedFiles_pkey" rename to loaded_files_pkey; - -${logic.psql-only-alter} table public.loaded_batches rename constraint "loadedBatches_loadedFileId" to loaded_batches_loaded_file_id; - --- hsql only - primary key names already exist --- loaded_batches_pkey already exists --- loaded_files_pkey already exists - -${logic.hsql-only-alter} table public.loaded_batches ADD CONSTRAINT loaded_batches_loaded_file_id FOREIGN KEY (loaded_file_id) REFERENCES public.loaded_files (loaded_file_id); - --- both psql and hsql support non-primary key index renaming -ALTER INDEX "LoadedBatches_created_index" RENAME TO loaded_batches_created_idx; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V52__Table_column_rename_MediBeneHistory.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V52__Table_column_rename_MediBeneHistory.sql deleted file mode 100644 index 2a771069a8..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V52__Table_column_rename_MediBeneHistory.sql +++ /dev/null @@ -1,75 +0,0 @@ --- The V40 through V52 migrations rename our tables and columns for CCW-sourced data, such that: --- 1. We follow PostgreSQL's general snake_case naming conventions, to improve the developer experience: DB --- object names won't have to be quoted all over the place, anymore. --- 2. Column names match those in our upstream source system, the CCW, to improve traceability as data flows --- through our systems. --- 3. Rename the "parentXXX" foreign key columns to instead have names that match their target column. - --- Rename tables and table columns; syntax: --- --- psql: alter table public.beneficiaries rename column "beneficiaryId" to bene_id; --- hsql: alter table public.beneficiaries alter column "beneficiaryId" rename to bene_id; --- --- ${logic.alter-rename-column} --- psql: "rename column" --- hsql: "alter column" --- --- ${logic.rename-to} --- psql: "to" --- hsql: "rename to" --- --- MedicareBeneficiaryIdHistory to medicare_beneficiaryid_history --- -alter table public."MedicareBeneficiaryIdHistory" rename to medicare_beneficiaryid_history; -alter table public.medicare_beneficiaryid_history ${logic.alter-rename-column} "medicareBeneficiaryIdKey" ${logic.rename-to} bene_mbi_id; -alter table public.medicare_beneficiaryid_history ${logic.alter-rename-column} "beneficiaryId" ${logic.rename-to} bene_id; -alter table public.medicare_beneficiaryid_history ${logic.alter-rename-column} lastupdated ${logic.rename-to} last_updated; -alter table public.medicare_beneficiaryid_history ${logic.alter-rename-column} "claimAccountNumber" ${logic.rename-to} bene_clm_acnt_num; -alter table public.medicare_beneficiaryid_history ${logic.alter-rename-column} "beneficiaryIdCode" ${logic.rename-to} bene_ident_cd; -alter table public.medicare_beneficiaryid_history ${logic.alter-rename-column} "mbiCrntRecIndId" ${logic.rename-to} bene_crnt_rec_ind_id; -alter table public.medicare_beneficiaryid_history ${logic.alter-rename-column} "mbiSequenceNumber" ${logic.rename-to} mbi_sqnc_num; -alter table public.medicare_beneficiaryid_history ${logic.alter-rename-column} "medicareBeneficiaryId" ${logic.rename-to} mbi_num; -alter table public.medicare_beneficiaryid_history ${logic.alter-rename-column} "mbiEffectiveDate" ${logic.rename-to} mbi_efctv_bgn_dt; -alter table public.medicare_beneficiaryid_history ${logic.alter-rename-column} "mbiEndDate" ${logic.rename-to} mbi_efctv_end_dt; -alter table public.medicare_beneficiaryid_history ${logic.alter-rename-column} "mbiEffectiveReasonCode" ${logic.rename-to} mbi_bgn_rsn_cd; -alter table public.medicare_beneficiaryid_history ${logic.alter-rename-column} "mbiEndReasonCode" ${logic.rename-to} mbi_end_rsn_cd; -alter table public.medicare_beneficiaryid_history ${logic.alter-rename-column} "mbiCardRequestDate" ${logic.rename-to} mbi_card_rqst_dt; -alter table public.medicare_beneficiaryid_history ${logic.alter-rename-column} "mbiAddUser" ${logic.rename-to} creat_user_id; -alter table public.medicare_beneficiaryid_history ${logic.alter-rename-column} "mbiAddDate" ${logic.rename-to} creat_ts; -alter table public.medicare_beneficiaryid_history ${logic.alter-rename-column} "mbiUpdateUser" ${logic.rename-to} updt_user_id; -alter table public.medicare_beneficiaryid_history ${logic.alter-rename-column} "mbiUpdateDate" ${logic.rename-to} updt_ts; --- --- MedicareBeneficiaryIdHistoryInvalidBeneficiaries to medicare_beneficiaryid_history_invalid_beneficiaries --- -alter table public."MedicareBeneficiaryIdHistoryInvalidBeneficiaries" rename to medicare_beneficiaryid_history_invalid_beneficiaries; -alter table public.medicare_beneficiaryid_history_invalid_beneficiaries ${logic.alter-rename-column} "medicareBeneficiaryIdKey" ${logic.rename-to} bene_mbi_id; -alter table public.medicare_beneficiaryid_history_invalid_beneficiaries ${logic.alter-rename-column} "beneficiaryId" ${logic.rename-to} bene_id; -alter table public.medicare_beneficiaryid_history_invalid_beneficiaries ${logic.alter-rename-column} "claimAccountNumber" ${logic.rename-to} bene_clm_acnt_num; -alter table public.medicare_beneficiaryid_history_invalid_beneficiaries ${logic.alter-rename-column} "beneficiaryIdCode" ${logic.rename-to} bene_ident_cd; -alter table public.medicare_beneficiaryid_history_invalid_beneficiaries ${logic.alter-rename-column} "mbiCrntRecIndId" ${logic.rename-to} bene_crnt_rec_ind_id; -alter table public.medicare_beneficiaryid_history_invalid_beneficiaries ${logic.alter-rename-column} "mbiSequenceNumber" ${logic.rename-to} mbi_sqnc_num; -alter table public.medicare_beneficiaryid_history_invalid_beneficiaries ${logic.alter-rename-column} "medicareBeneficiaryId" ${logic.rename-to} mbi_num; -alter table public.medicare_beneficiaryid_history_invalid_beneficiaries ${logic.alter-rename-column} "mbiEffectiveDate" ${logic.rename-to} mbi_efctv_bgn_dt; -alter table public.medicare_beneficiaryid_history_invalid_beneficiaries ${logic.alter-rename-column} "mbiEndDate" ${logic.rename-to} mbi_efctv_end_dt; -alter table public.medicare_beneficiaryid_history_invalid_beneficiaries ${logic.alter-rename-column} "mbiEffectiveReasonCode" ${logic.rename-to} mbi_bgn_rsn_cd; -alter table public.medicare_beneficiaryid_history_invalid_beneficiaries ${logic.alter-rename-column} "mbiEndReasonCode" ${logic.rename-to} mbi_end_rsn_cd; -alter table public.medicare_beneficiaryid_history_invalid_beneficiaries ${logic.alter-rename-column} "mbiCardRequestDate" ${logic.rename-to} mbi_card_rqst_dt; -alter table public.medicare_beneficiaryid_history_invalid_beneficiaries ${logic.alter-rename-column} "mbiAddUser" ${logic.rename-to} creat_user_id; -alter table public.medicare_beneficiaryid_history_invalid_beneficiaries ${logic.alter-rename-column} "mbiAddDate" ${logic.rename-to} creat_ts; -alter table public.medicare_beneficiaryid_history_invalid_beneficiaries ${logic.alter-rename-column} "mbiUpdateUser" ${logic.rename-to} updt_user_id; -alter table public.medicare_beneficiaryid_history_invalid_beneficiaries ${logic.alter-rename-column} "mbiUpdateDate" ${logic.rename-to} updt_ts; - --- psql only -${logic.psql-only-alter} index if exists public."MedicareBeneficiaryIdHistoryInvalidBeneficiaries_pkey" rename to medicare_beneficiaryid_history_invalid_beneficiaries_pkey; -${logic.psql-only-alter} index if exists public."MedicareBeneficiaryIdHistory_pkey" rename to medicare_beneficiaryid_history_pkey; - -${logic.psql-only-alter} table public.medicare_beneficiaryid_history rename constraint "MedicareBeneficiaryIdHistory_beneficiaryId_to_Beneficiary" to medicare_beneficiaryid_history_bene_id_to_beneficiaries; - --- hsql only -${logic.hsql-only-alter} table public.medicare_beneficiaryid_history_invalid_beneficiaries add constraint medicare_beneficiaryid_history_invalid_beneficiaries_pkey primary key (bene_mbi_id); -${logic.hsql-only-alter} table public.medicare_beneficiaryid_history add constraint medicare_beneficiaryid_history_pkey primary key (bene_mbi_id); - -${logic.hsql-only-alter} table public.medicare_beneficiaryid_history ADD CONSTRAINT medicare_beneficiaryid_history_bene_id_to_beneficiaries FOREIGN KEY (bene_id) REFERENCES public.beneficiaries (bene_id); - --- both psql and hsql support non-primary key index renaming -ALTER INDEX "MedicareBeneficiaryIdHistory_beneficiaryId_idx" RENAME TO medicare_beneficiaryid_history_bene_id_idx; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V53__Remove_unused_db_objects.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V53__Remove_unused_db_objects.sql deleted file mode 100644 index c6ae22f4f0..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V53__Remove_unused_db_objects.sql +++ /dev/null @@ -1,10 +0,0 @@ --- both psql and hsql support non-primary key index renaming -ALTER INDEX beneficiary_monthly_year_month_partd_contract_bene_id_idx RENAME TO beneficiary_monthly_partd_contract_year_month_bene_id_idx; - --- to check if an index is not used in postgres: --- select * from pg_stat_all_indexes where schemaname = 'public' and relname = 'beneficiary_monthly' -DROP INDEX IF EXISTS beneficiary_monthly_partd_contract_number_year_month_idx; - -DROP SEQUENCE IF EXISTS loaded_batches_loaded_batchid_seq restrict; -DROP SEQUENCE IF EXISTS loaded_files_loaded_fileid_seq restrict; -DROP SEQUENCE IF EXISTS beneficiaryhistory_bene_history_id_seq restrict; \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V54__preadj_mbi_caching_create_table.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V54__preadj_mbi_caching_create_table.sql deleted file mode 100644 index 9cf5cfff53..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V54__preadj_mbi_caching_create_table.sql +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Table to hold known MBI and their hashed equivalents. - */ -CREATE TABLE "pre_adj"."MbiCache" ( - "mbiId" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, - "mbi" VARCHAR(11) NOT NULL, - "hash" VARCHAR(64) NOT NULL, - "oldHash" VARCHAR(64), - "lastUpdated" timestamp with time zone -); - -/* - * We need these indexes to support queries by mbi, hash, and oldHash. - */ -CREATE UNIQUE INDEX "MbiCache_mbi_idx" on "pre_adj"."MbiCache"("mbi"); -CREATE UNIQUE INDEX "MbiCache_hash_idx" on "pre_adj"."MbiCache"("hash"); -CREATE INDEX "MbiCache_oldHash_idx" on "pre_adj"."MbiCache"("oldHash"); - -/* - * Add foreign key to reference MbiCache in claims tables. - */ -ALTER TABLE "pre_adj"."FissClaims" - ADD "mbiId" bigint; -ALTER TABLE "pre_adj"."FissClaims" - ADD CONSTRAINT "FK_FissClaims_mbiId" FOREIGN KEY ("mbiId") REFERENCES "pre_adj"."MbiCache"("mbiId"); - -ALTER TABLE "pre_adj"."McsClaims" - ADD "mbiId" bigint; -ALTER TABLE "pre_adj"."McsClaims" - ADD CONSTRAINT "FK_McsClaims_mbiId" FOREIGN KEY ("mbiId") REFERENCES "pre_adj"."MbiCache"("mbiId"); - -/* - * We need these indexes to efficiently find claims using join from MbiCache. - */ -CREATE INDEX "FissClaims_mbiId_idx" on "pre_adj"."FissClaims"("mbiId"); -CREATE INDEX "McsClaims_mbiId_idx" on "pre_adj"."McsClaims"("mbiId"); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V55__preadj_mbi_caching_populate_table.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V55__preadj_mbi_caching_populate_table.sql deleted file mode 100644 index 2e91947f58..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V55__preadj_mbi_caching_populate_table.sql +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Migrate all existing MBI values into the MbiCache table. - */ -INSERT INTO "pre_adj"."MbiCache"("mbi", "hash", "lastUpdated") -SELECT "mbi", "mbiHash" as "hash", CURRENT_TIMESTAMP as "lastUpdated" -FROM ( - SELECT DISTINCT "mbi", "mbiHash" - FROM "pre_adj"."FissClaims" - UNION - SELECT DISTINCT "idrClaimMbi" AS "mbi", "idrClaimMbiHash" AS "mbiHash" - FROM "pre_adj"."McsClaims" -) x -WHERE "mbi" IS NOT NULL AND "mbiHash" IS NOT NULL; - -/* - * Update the mbiId foreign key column. - */ -UPDATE "pre_adj"."FissClaims" -SET "mbiId"=(SELECT "mbiId" FROM "pre_adj"."MbiCache" WHERE "hash" = "mbiHash"); - -UPDATE "pre_adj"."McsClaims" -SET "mbiId"=(SELECT "mbiId" FROM "pre_adj"."MbiCache" WHERE "hash" = "idrClaimMbiHash"); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V56__preadj_mbi_caching_drop_old_columns.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V56__preadj_mbi_caching_drop_old_columns.sql deleted file mode 100644 index 3877aba9de..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V56__preadj_mbi_caching_drop_old_columns.sql +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Drop the now obsolete mbi and hash columns from claims tables. - */ - -ALTER TABLE "pre_adj"."FissClaims" DROP "mbi"; -ALTER TABLE "pre_adj"."FissClaims" DROP "mbiHash"; - -ALTER TABLE "pre_adj"."McsClaims" DROP "idrClaimMbi"; -ALTER TABLE "pre_adj"."McsClaims" DROP "idrClaimMbiHash"; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V57__rda_message_metadata.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V57__rda_message_metadata.sql deleted file mode 100644 index 5ec0e80fc5..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V57__rda_message_metadata.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE "pre_adj"."RdaApiClaimMessageMetaData" ( - "metaDataId" bigint NOT NULL PRIMARY KEY, - "claimType" char(1) NOT NULL, - "sequenceNumber" bigint NOT NULL, - "claimId" varchar(25) NOT NULL, - "mbiId" bigint, - "claimState" varchar(1), - "receivedDate" timestamp with time zone NOT NULL, - CONSTRAINT "RdaApiClaimMessageMetaData_mbi" FOREIGN KEY ("mbiId") REFERENCES "pre_adj"."MbiCache"("mbiId") -); - -create sequence "pre_adj"."rda_api_claim_message_meta_data_meta_data_id_seq" as bigint ${logic.sequence-start} 1 ${logic.sequence-increment} 25 no cycle; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V58__Add_rif_records_skipped_Table.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V58__Add_rif_records_skipped_Table.sql deleted file mode 100644 index 38c5f24541..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V58__Add_rif_records_skipped_Table.sql +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Adds a new table for storing CCW RIF records that have been temporarily skipped. - * - * Please note that every record in this table is a piece of as-yet-unaddressed technical debt, with an - * exorbitantly high "interest rate": the older these records get, the harder it will be to figure out what - * to do with them, and the harder it will be to implement any such process. Ideally, this table is only ever - * populated for VERY brief periods of time. - * - * Added as part of . - */ - -CREATE TABLE skipped_rif_records ( - -- Sequence-generated PK for these records, as no natural PK is feasible. - record_id bigint NOT NULL PRIMARY KEY, - - -- A code indicating why this particular RIF record(s) were skipped. - skip_reason varchar(50) NOT NULL, - - -- The timestamp associated with the CCW data set manifest that this record(s) is from. - rif_file_timestamp timestamp with time zone NOT NULL, - - -- The `RifFileType` (e.g. `BENEFICIARY`, `CARRIER`, etc.) of the RIF file that this record(s) is from. - rif_file_type varchar(48) NOT NULL, - - -- The `DML_IND` of the RIF record(s). - dml_ind varchar(6) NOT NULL, - - -- The `bene_id` of the beneficiary that this record(s) is of / associated with. - bene_id varchar(15) NOT NULL, - - -- The RIF/CSV row or rows representing the record(s) (i.e. beneficiary or claim) that was skipped. - rif_data ${type.text} NOT NULL -); - --- The sequence used for the `skipped_rif_records.record_id` column. -CREATE SEQUENCE skipped_rif_records_record_id_seq - AS bigint ${logic.sequence-start} 1 ${logic.sequence-increment} 1 - NO CYCLE; - --- This index will allow for fast queries to determine whether or not a given `beneficiaries` record has been --- impacted by the new load filtering. This will allow the BFD Server to report that status in its `Patient` --- responses. -CREATE INDEX skipped_rif_records_bene_id_idx on skipped_rif_records (bene_id); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V59__fiss_claims_prov_fields.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V59__fiss_claims_prov_fields.sql deleted file mode 100644 index 781442d0cc..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V59__fiss_claims_prov_fields.sql +++ /dev/null @@ -1,4 +0,0 @@ -alter table "pre_adj"."FissClaims" add "provStateCd" varchar(2); -alter table "pre_adj"."FissClaims" add "provTypFacilCd" varchar(1); -alter table "pre_adj"."FissClaims" add "provEmerInd" varchar(1); -alter table "pre_adj"."FissClaims" add "provDeptId" varchar(3); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V5__Fix_claim_line_parentClaim_widths.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V5__Fix_claim_line_parentClaim_widths.sql deleted file mode 100644 index 3a6b788ca8..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V5__Fix_claim_line_parentClaim_widths.sql +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Alters the claim line tables' `parentClaim` columns to have the correct - * width: 15, instead of 255. - * - * See http://issues.hhsdevcloud.us/browse/CBBD-306. - */ - -alter table "CarrierClaimLines" - alter column "parentClaim" ${logic.alter-column-type} varchar(15); - -alter table "DMEClaimLines" - alter column "parentClaim" ${logic.alter-column-type} varchar(15); - -alter table "HHAClaimLines" - alter column "parentClaim" ${logic.alter-column-type} varchar(15); - -alter table "HospiceClaimLines" - alter column "parentClaim" ${logic.alter-column-type} varchar(15); - -alter table "InpatientClaimLines" - alter column "parentClaim" ${logic.alter-column-type} varchar(15); - -alter table "OutpatientClaimLines" - alter column "parentClaim" ${logic.alter-column-type} varchar(15); - -alter table "SNFClaimLines" - alter column "parentClaim" ${logic.alter-column-type} varchar(15); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V60__Alter_beneficiaries_bene_id_numeric.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V60__Alter_beneficiaries_bene_id_numeric.sql deleted file mode 100644 index b8dc51ebf1..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V60__Alter_beneficiaries_bene_id_numeric.sql +++ /dev/null @@ -1,34 +0,0 @@ --- add a column to beneficiaries table; an ALTER TABLE by definition --- creates an 'access exclusive' lock on the table. -ALTER TABLE public.beneficiaries ADD bene_id_numeric bigint; - --- create a database trigger which will be used to imbue a bigint value --- into the bene_id_numeric column during a table record INSERT operation. --- The trigger is defined as a pre-insert trigger, which means that prior to --- new record being written, the database engine will execute the trigger, --- which in turn, fills the bene_id_numeric with a value based on a 'cast' --- of the bene_id (varchar). - --- HSQL always gets created/initialized from scratch so no need to drop trigger -${logic.hsql-only} CREATE TRIGGER beneficiaries_insert_trigger BEFORE INSERT ON public.beneficiaries -${logic.hsql-only} REFERENCING NEW as newrow FOR EACH ROW -${logic.hsql-only} BEGIN ATOMIC -${logic.hsql-only} SET newrow.bene_id_numeric = convert(newrow.bene_id, SQL_BIGINT); -${logic.hsql-only} END; - -${logic.psql-only} CREATE OR REPLACE FUNCTION public.beneficiaries_pre_insert() -${logic.psql-only} RETURNS trigger -${logic.psql-only} LANGUAGE 'plpgsql' -${logic.psql-only} VOLATILE NOT LEAKPROOF -${logic.psql-only} AS $BODY$ -${logic.psql-only} BEGIN -${logic.psql-only} NEW.bene_id_numeric = NEW.bene_id::bigint; -${logic.psql-only} RETURN NEW; -${logic.psql-only} END; -${logic.psql-only} $BODY$; - -${logic.psql-only} DROP TRIGGER IF EXISTS beneficiaries_insert_trigger ON public.beneficiaries; -${logic.psql-only} CREATE TRIGGER beneficiaries_insert_trigger -${logic.psql-only} BEFORE INSERT ON public.beneficiaries -${logic.psql-only} FOR EACH ROW -${logic.psql-only} EXECUTE FUNCTION public.beneficiaries_pre_insert(); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V61__populate_bene_id_numeric.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V61__populate_bene_id_numeric.sql deleted file mode 100644 index c63af94c74..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V61__populate_bene_id_numeric.sql +++ /dev/null @@ -1,35 +0,0 @@ --- POPULATE_BENE_ID_NUMERIC.SQL --- This script will populate a column, bene_id_numeric, in the --- beneficiaries table, by casting each record's current varchar --- value of its bene_id column. Once the entire table has been updated, --- then a unique index will be built referencing bene_id_numeric. - --- Try to get a lock on the beneficiaries table; while in theory, we --- could depend on row-level locking of the UPDATE, we acquire a SHARED --- UPDATE EXCLUSIVE which by definition assures us that no other update --- operations can run while we are doing the updates in this script. - --- Wrap in a transaction; acquiring a lock can only be done inside a transaction. -${logic.psql-only} BEGIN; - --- Set a short lock timeout...no one should be updating table (yet); --- lock requests are queued, so we don't want to hang around if some other --- process currently has a lock. If we don't get the requested lock in less --- than 100ms, then the script will exit/fail. -${logic.psql-only} set lock_timeout = 100; - --- try to grab a lock on the table -${logic.psql-only} LOCK TABLE ONLY public.beneficiaries IN SHARE UPDATE EXCLUSIVE MODE; - --- update will be fairly long running; our acquired lock does not impact readers (select) -UPDATE public.beneficiaries -${logic.hsql-only} SET bene_id_numeric = convert(bene_id, SQL_BIGINT) -${logic.psql-only} SET bene_id_numeric = bene_id::bigint -WHERE bene_id is not null; - --- building index on bene_id_numeric will also take some time; readers still OK -CREATE UNIQUE INDEX beneficiaries_bene_id_numeric_idx - ON public.beneficiaries (bene_id_numeric); - --- release the lock -${logic.psql-only} COMMIT; \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V61__populate_bene_id_numeric.sql.conf b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V61__populate_bene_id_numeric.sql.conf deleted file mode 100644 index 5f4cd716a7..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V61__populate_bene_id_numeric.sql.conf +++ /dev/null @@ -1,7 +0,0 @@ -# POPULATE_BENE_ID_NUMERIC.SQL.CONF -# This config will only be executed in a PSQL environment; it explicitly turns -# off Flyway transaction so thatwe can specify how how the transaction will operate. - -# Manually determine whether or not to execute this migration in a transaction. This is useful for -# databases like PostgreSQL where we specify that we want the lock update to allow sharing. -executeInTransaction=false \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V62__create_rda_schema.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V62__create_rda_schema.sql deleted file mode 100644 index aa2526b4c5..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V62__create_rda_schema.sql +++ /dev/null @@ -1,354 +0,0 @@ -/* - * This migration creates a new schema to hold partially adjudicated claims data sourced from the RDA API. - * The primary motivation of the change is to rename the schema to more generally reflect the data source - * and to rename all tables, indexes, and columns to follow the snake case naming convention used - * in the public schema. - * - * Because the production database is not yet populated the simplest approach is to create a new schema - * and reload data into that new schema. A later migration will drop the old pre_adj schema completely. - */ - -create schema if not exists rda; - -create table rda.rda_api_progress ( - claim_type varchar(20) not null primary key, - last_sequence_number bigint not null, - last_updated timestamp with time zone -); - -create table rda.mbi_cache ( - mbi_id bigint generated by default as identity primary key, - mbi varchar(11) not null, - hash varchar(64) not null, - old_hash varchar(64), - last_updated timestamp with time zone -); - -create unique index mbi_cache_mbi_idx on rda.mbi_cache(mbi); - -create unique index mbi_cache_hash_idx on rda.mbi_cache(hash); - -create index mbi_cache_old_hash_idx on rda.mbi_cache(old_hash); - -create sequence rda.rda_api_claim_message_meta_data_meta_data_id_seq as bigint ${logic.sequence-start} 1 ${logic.sequence-increment} 25 no cycle; - -create table rda.rda_api_claim_message_meta_data ( - meta_data_id bigint not null primary key, - claim_type char not null, - sequence_number bigint not null, - claim_id varchar(25) not null, - mbi_id bigint, - claim_state varchar(1), - received_date timestamp with time zone not null, - foreign key (mbi_id) references rda.mbi_cache(mbi_id) -); - - -create table rda.fiss_claims ( - dcn varchar(23) not null primary key, - hic_no varchar(12) not null, - curr_status char not null, - curr_loc1 char not null, - curr_loc2 varchar(5) not null, - meda_prov_id varchar(13), - total_charge_amount numeric(11, 2), - received_date date, - curr_tran_date date, - admit_diag_code varchar(7), - principle_diag varchar(7), - npi_number varchar(10), - fed_tax_number varchar(10), - last_updated timestamp with time zone, - prac_loc_addr1 ${type.text}, - prac_loc_addr2 ${type.text}, - prac_loc_city ${type.text}, - prac_loc_state varchar(2), - prac_loc_zip varchar(15), - meda_prov_6 varchar(6), - stmt_cov_from_date date, - stmt_cov_to_date date, - lob_cd varchar(1), - serv_type_cd_mapping varchar(20), - serv_type_cd varchar(1), - freq_cd varchar(1), - bill_typ_cd varchar(3), - sequence_number bigint not null, - api_source varchar(24), - reject_cd varchar(5), - full_part_den_ind varchar(1), - non_pay_ind varchar(2), - xref_dcn_nbr varchar(23), - adj_req_cd varchar(1), - adj_reas_cd varchar(2), - cancel_xref_dcn varchar(23), - cancel_date date, - canc_adj_cd varchar(1), - original_xref_dcn varchar(23), - paid_dt date, - adm_date date, - adm_source varchar(1), - primary_payer_code varchar(1), - attend_phys_id varchar(16), - attend_phys_lname varchar(17), - attend_phys_fname varchar(18), - attend_phys_mint varchar(1), - attend_phys_flag varchar(1), - operating_phys_id varchar(16), - oper_phys_lname varchar(17), - oper_phys_fname varchar(18), - oper_phys_mint varchar(1), - oper_phys_flag varchar(1), - oth_phys_id varchar(16), - oth_phys_lname varchar(17), - oth_phys_fname varchar(18), - oth_phys_mint varchar(1), - oth_phys_flag varchar(1), - xref_hic_nbr varchar(12), - proc_new_hic_ind varchar(1), - new_hic varchar(12), - repos_ind varchar(1), - repos_hic varchar(12), - mbi_subm_bene_ind varchar(1), - adj_mbi_ind varchar(1), - adj_mbi varchar(11), - medical_record_no varchar(17), - prov_state_cd varchar(2), - prov_typ_facil_cd varchar(1), - prov_emer_ind varchar(1), - prov_dept_id varchar(3), - mbi_id bigint, - foreign key (mbi_id) references rda.mbi_cache(mbi_id) -); - -create index fiss_claims_last_updated_idx - on rda.fiss_claims(last_updated); - -create index fiss_claims_mbi_id_idx - on rda.fiss_claims(mbi_id); - -create table rda.fiss_audit_trails ( - dcn varchar(23) not null, - priority smallint not null, - last_updated timestamp with time zone, - badt_status varchar(1), - badt_loc varchar(5), - badt_oper_id varchar(9), - badt_reas varchar(5), - badt_curr_date date, - primary key (dcn, priority), - foreign key (dcn) references rda.fiss_claims(dcn) -); - -create table rda.fiss_diagnosis_codes ( - dcn varchar(23) not null, - priority smallint not null, - diag_cd2 varchar(7) not null, - diag_poa_ind varchar(1), - bit_flags varchar(4), - last_updated timestamp with time zone, - primary key (dcn, priority), - foreign key (dcn) references rda.fiss_claims(dcn) -); - -create table rda.fiss_proc_codes ( - dcn varchar(23) not null, - priority smallint not null, - proc_code varchar(10) not null, - proc_flag varchar(4), - proc_date date, - last_updated timestamp with time zone, - primary key (dcn, priority), - foreign key (dcn) references rda.fiss_claims(dcn) -); - -create table rda.fiss_payers ( - dcn varchar(23) not null, - priority smallint not null, - payer_type varchar(20), - payers_id varchar(1), - payers_name varchar(32), - rel_ind varchar(1), - assign_ind varchar(1), - provider_number varchar(13), - adj_dcn_icn varchar(23), - prior_pmt numeric(11, 2), - est_amt_due numeric(11, 2), - bene_rel varchar(2), - bene_last_name varchar(15), - bene_first_name varchar(10), - bene_mid_init varchar(1), - bene_ssn_hic varchar(19), - insured_rel varchar(2), - insured_name varchar(25), - insured_ssn_hic varchar(19), - insured_group_name varchar(17), - insured_group_nbr varchar(20), - bene_dob date, - bene_sex varchar(1), - treat_auth_cd varchar(18), - insured_sex varchar(1), - insured_rel_x12 varchar(2), - insured_dob date, - insured_dob_text varchar(9), - last_updated timestamp with time zone, - primary key (dcn, priority), - foreign key (dcn) references rda.fiss_claims(dcn) -); - - - -create table rda.mcs_claims ( - idr_clm_hd_icn varchar(15) not null primary key, - idr_contr_id varchar(5) not null, - idr_hic varchar(12), - idr_claim_type varchar(1) not null, - idr_dtl_cnt integer, - idr_bene_last_1_6 varchar(6), - idr_bene_first_init varchar(1), - idr_bene_mid_init varchar(1), - idr_bene_sex varchar(1), - idr_status_code varchar(1), - idr_status_date date, - idr_bill_prov_npi varchar(10), - idr_bill_prov_num varchar(10), - idr_bill_prov_ein varchar(10), - idr_bill_prov_type varchar(2), - idr_bill_prov_spec varchar(2), - idr_bill_prov_group_ind varchar(1), - idr_bill_prov_price_spec varchar(2), - idr_bill_prov_county varchar(2), - idr_bill_prov_loc varchar(2), - idr_tot_allowed numeric(7, 2), - idr_coinsurance numeric(7, 2), - idr_deductible numeric(7, 2), - idr_bill_prov_status_cd varchar(1), - idr_tot_billed_amt numeric(7, 2), - idr_claim_receipt_date date, - idr_hdr_from_date_of_svc date, - idr_hdr_to_date_of_svc date, - last_updated timestamp with time zone, - sequence_number bigint not null, - api_source varchar(24), - idr_assignment varchar(1), - idr_clm_level_ind varchar(1), - idr_hdr_audit integer, - idr_hdr_audit_ind varchar(1), - idr_u_split_reason varchar(1), - idr_j_referring_prov_npi varchar(10), - idr_j_fac_prov_npi varchar(10), - idr_u_demo_prov_npi varchar(10), - idr_u_super_npi varchar(10), - idr_u_fcadj_bil_npi varchar(10), - idr_amb_pickup_addres_line1 varchar(25), - idr_amb_pickup_addres_line2 varchar(20), - idr_amb_pickup_city varchar(20), - idr_amb_pickup_state varchar(2), - idr_amb_pickup_zipcode varchar(9), - idr_amb_dropoff_name varchar(24), - idr_amb_dropoff_addr_line1 varchar(25), - idr_amb_dropoff_addr_line2 varchar(20), - idr_amb_dropoff_city varchar(20), - idr_amb_dropoff_state varchar(2), - idr_amb_dropoff_zipcode varchar(9), - mbi_id bigint, - foreign key (mbi_id) references rda.mbi_cache(mbi_id) -); - -create index mcs_claims_last_updated_idx - on rda.mcs_claims(last_updated); - -create index mcs_claims_mbi_id_idx - on rda.mcs_claims(mbi_id); - -create table rda.mcs_adjustments ( - idr_clm_hd_icn varchar(15) not null, - priority smallint not null, - last_updated timestamp with time zone, - idr_adj_date date, - idr_xref_icn varchar(15), - idr_adj_clerk varchar(4), - idr_init_ccn varchar(15), - idr_adj_chk_wrt_dt date, - idr_adj_b_eomb_amt numeric(7, 2), - idr_adj_p_eomb_amt numeric(7, 2), - primary key (idr_clm_hd_icn, priority), - foreign key (idr_clm_hd_icn) references rda.mcs_claims(idr_clm_hd_icn) -); - -create table rda.mcs_audits ( - idr_clm_hd_icn varchar(15) not null, - priority smallint not null, - last_updated timestamp with time zone, - idr_j_audit_num integer, - idr_j_audit_ind varchar(1), - idr_j_audit_disp varchar(1), - primary key (idr_clm_hd_icn, priority), - foreign key (idr_clm_hd_icn) references rda.mcs_claims(idr_clm_hd_icn) -); - -create table rda.mcs_details ( - idr_clm_hd_icn varchar(15) not null, - priority smallint not null, - idr_dtl_status varchar(1), - idr_dtl_from_date date, - idr_dtl_to_date date, - idr_proc_code varchar(5), - idr_mod_one varchar(2), - idr_mod_two varchar(2), - idr_mod_three varchar(2), - idr_mod_four varchar(2), - idr_dtl_diag_icd_type varchar(1), - idr_dtl_primary_diag_code varchar(7), - idr_k_pos_lname_org varchar(60), - idr_k_pos_fname varchar(35), - idr_k_pos_mname varchar(25), - idr_k_pos_addr1 varchar(55), - idr_k_pos_addr2_1st varchar(30), - idr_k_pos_addr2_2nd varchar(25), - idr_k_pos_city varchar(30), - idr_k_pos_state varchar(2), - idr_k_pos_zip varchar(15), - last_updated timestamp with time zone, - idr_tos varchar(1), - idr_two_digit_pos varchar(2), - idr_dtl_rend_type varchar(2), - idr_dtl_rend_spec varchar(2), - idr_dtl_rend_npi varchar(10), - idr_dtl_rend_prov varchar(10), - idr_k_dtl_fac_prov_npi varchar(10), - idr_dtl_amb_pickup_addres1 varchar(25), - idr_dtl_amb_pickup_addres2 varchar(20), - idr_dtl_amb_pickup_city varchar(20), - idr_dtl_amb_pickup_state varchar(2), - idr_dtl_amb_pickup_zipcode varchar(9), - idr_dtl_amb_dropoff_name varchar(24), - idr_dtl_amb_dropoff_addr_l1 varchar(25), - idr_dtl_amb_dropoff_addr_l2 varchar(20), - idr_dtl_amb_dropoff_city varchar(20), - idr_dtl_amb_dropoff_state varchar(2), - idr_dtl_amb_dropoff_zipcode varchar(9), - primary key (idr_clm_hd_icn, priority), - foreign key (idr_clm_hd_icn) references rda.mcs_claims(idr_clm_hd_icn) -); - -create table rda.mcs_diagnosis_codes ( - idr_clm_hd_icn varchar(15) not null, - priority smallint not null, - idr_diag_icd_type varchar(1), - idr_diag_code varchar(7) not null, - last_updated timestamp with time zone, - primary key (idr_clm_hd_icn, priority), - foreign key (idr_clm_hd_icn) references rda.mcs_claims(idr_clm_hd_icn) -); - -create table rda.mcs_locations ( - idr_clm_hd_icn varchar(15) not null, - priority smallint not null, - last_updated timestamp with time zone, - idr_loc_clerk varchar(4), - idr_loc_code varchar(3), - idr_loc_date date, - idr_loc_actv_code varchar(1), - primary key (idr_clm_hd_icn, priority), - foreign key (idr_clm_hd_icn) references rda.mcs_claims(idr_clm_hd_icn) -); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V63__new_schema_snf_claims.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V63__new_schema_snf_claims.sql deleted file mode 100644 index 2a16c6da40..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V63__new_schema_snf_claims.sql +++ /dev/null @@ -1,854 +0,0 @@ --- NEW_SCHEMA_SNF_CLAIMS.SQL --- flyway migration for SNF_CLAIMS and SNF_CLAIM_LINES tables into --- a new schema structure that: --- 1) changes data type of CLM_ID, BENE_ID from varchar to BIGINT. --- 2) change data type of CLM_GROUP_ID from numeric to BIGINT --- 3) organizes parent claim table (SNF_CLAIMS) such that common --- claims data columns are organized at top of table structure. --- 4) replace previously defined numeric types that can only hold integer --- values (i.e, no decimal point) as either smallint or integer. --- --- Per Postgres documentaion: --- ========================== --- The type integer is the usual choice, as it offers the best balance between --- range, storage size, and performance. The smallint type is used if disk --- space is at a premium; bigint type should only be used if the integer --- range is not sufficient. --- --- smallint was used where appropriate because saving 2 bytes of storage space --- per reord column * (in some cases) hundreds of millions rows, can result in --- both efficiency (smaller index sizes) as well as storage space savings. --- --- numeric vs. integer (or smallint): --- --- The type numeric can store numbers with up to 1000 digits of precision and --- perform calculations exactly. It is especially recommended for storing monetary --- amounts and other quantities where exactness or fractional values are required. --- However, arithmetic on numeric values is very slow compared to the integer types. --- --- The following db columns were redefined from NUMERIC to more appropriate integral --- data type(s): --- --- nch_blood_pnts_frnshd_qty --- clm_line_num --- rev_cntr_ndc_qty --- --- Once current table data is migrated to new table name/strucutre, --- a subsequent PR will be deployed that changes the ORM model(s) --- for SNF table(s). --- --- HSQL differs from PSQL (postgres) in that the table defintion --- must be explicitly declared prior to loading data into the --- target table. PSQL can derive the table structure based on --- the data input (i.e., column name, data type). Thus, for HSQL, --- we need to explicitly define the table structure prior to loading data. --- --- For HSQL, explicitly define/create a new SNF_CLAIMS_NEW table in --- the current PUBLIC schema - -${logic.hsql-only} create table public.snf_claims_new ( -${logic.hsql-only} clm_id bigint NOT NULL, -${logic.hsql-only} bene_id bigint NOT NULL, -${logic.hsql-only} clm_grp_id bigint NOT NULL, -${logic.hsql-only} last_updated timestamp with time zone, -${logic.hsql-only} clm_from_dt date NOT NULL, -${logic.hsql-only} clm_thru_dt date NOT NULL, -${logic.hsql-only} claim_query_code char(1) NOT NULL, -${logic.hsql-only} clm_admsn_dt date, -${logic.hsql-only} clm_fac_type_cd char(1) NOT NULL, -${logic.hsql-only} clm_freq_cd char(1) NOT NULL, -${logic.hsql-only} clm_ip_admsn_type_cd char(1) NOT NULL, -${logic.hsql-only} clm_non_utlztn_days_cnt smallint NOT NULL, -${logic.hsql-only} clm_utlztn_day_cnt smallint NOT NULL, -${logic.hsql-only} bene_tot_coinsrnc_days_cnt smallint NOT NULL, -${logic.hsql-only} clm_srvc_clsfctn_type_cd char(1) NOT NULL, -${logic.hsql-only} final_action char(1) NOT NULL, -${logic.hsql-only} clm_tot_chrg_amt numeric(12,2) NOT NULL, -${logic.hsql-only} clm_pmt_amt numeric(12,2) NOT NULL, -${logic.hsql-only} clm_pps_ind_cd char(1), -${logic.hsql-only} clm_pps_cptl_dsprprtnt_shr_amt numeric(12,2), -${logic.hsql-only} clm_pps_cptl_excptn_amt numeric(12,2), -${logic.hsql-only} clm_pps_cptl_fsp_amt numeric(12,2), -${logic.hsql-only} clm_pps_cptl_ime_amt numeric(12,2), -${logic.hsql-only} clm_pps_cptl_outlier_amt numeric(12,2), -${logic.hsql-only} clm_pps_old_cptl_hld_hrmls_amt numeric(12,2), -${logic.hsql-only} nch_clm_type_cd varchar(2) NOT NULL, -${logic.hsql-only} nch_near_line_rec_ident_cd char(1) NOT NULL, -${logic.hsql-only} nch_wkly_proc_dt date NOT NULL, -${logic.hsql-only} nch_blood_pnts_frnshd_qty integer NOT NULL, -${logic.hsql-only} nch_prmry_pyr_cd char(1), -${logic.hsql-only} nch_prmry_pyr_clm_pd_amt numeric(12,2) NOT NULL, -${logic.hsql-only} nch_bene_blood_ddctbl_lblty_am numeric(12,2) NOT NULL, -${logic.hsql-only} nch_bene_ip_ddctbl_amt numeric(12,2) NOT NULL, -${logic.hsql-only} nch_bene_pta_coinsrnc_lblty_am numeric(12,2) NOT NULL, -${logic.hsql-only} nch_ip_ncvrd_chrg_amt numeric(12,2) NOT NULL, -${logic.hsql-only} nch_ip_tot_ddctn_amt numeric(12,2) NOT NULL, -${logic.hsql-only} nch_vrfd_ncvrd_stay_from_dt date, -${logic.hsql-only} nch_vrfd_ncvrd_stay_thru_dt date, -${logic.hsql-only} nch_qlfyd_stay_from_dt date, -${logic.hsql-only} nch_qlfyd_stay_thru_dt date, -${logic.hsql-only} nch_actv_or_cvrd_lvl_care_thru date, -${logic.hsql-only} nch_bene_dschrg_dt date, -${logic.hsql-only} nch_bene_mdcr_bnfts_exhtd_dt_i date, -${logic.hsql-only} nch_ptnt_status_ind_cd char(1), -${logic.hsql-only} clm_drg_cd varchar(3), -${logic.hsql-only} clm_mco_pd_sw char(1), -${logic.hsql-only} clm_mdcr_non_pmt_rsn_cd varchar(2), -${logic.hsql-only} clm_src_ip_admsn_cd char(1), -${logic.hsql-only} admtg_dgns_cd varchar(7), -${logic.hsql-only} admtg_dgns_vrsn_cd char(1), -${logic.hsql-only} at_physn_npi varchar(10), -${logic.hsql-only} at_physn_upin varchar(9), -${logic.hsql-only} op_physn_npi varchar(10), -${logic.hsql-only} op_physn_upin varchar(9), -${logic.hsql-only} org_npi_num varchar(10), -${logic.hsql-only} ot_physn_npi varchar(10), -${logic.hsql-only} ot_physn_upin varchar(9), -${logic.hsql-only} prncpal_dgns_cd varchar(7), -${logic.hsql-only} prncpal_dgns_vrsn_cd char(1), -${logic.hsql-only} prvdr_num varchar(9) NOT NULL, -${logic.hsql-only} prvdr_state_cd varchar(2) NOT NULL, -${logic.hsql-only} ptnt_dschrg_stus_cd varchar(2) NOT NULL, -${logic.hsql-only} fi_num varchar(5), -${logic.hsql-only} fi_clm_actn_cd char(1), -${logic.hsql-only} fi_clm_proc_dt date, -${logic.hsql-only} fi_doc_clm_cntl_num varchar(23), -${logic.hsql-only} fi_orig_clm_cntl_num varchar(23), -${logic.hsql-only} fst_dgns_e_cd varchar(7), -${logic.hsql-only} fst_dgns_e_vrsn_cd char(1), -${logic.hsql-only} icd_dgns_cd1 varchar(7), -${logic.hsql-only} icd_dgns_cd2 varchar(7), -${logic.hsql-only} icd_dgns_cd3 varchar(7), -${logic.hsql-only} icd_dgns_cd4 varchar(7), -${logic.hsql-only} icd_dgns_cd5 varchar(7), -${logic.hsql-only} icd_dgns_cd6 varchar(7), -${logic.hsql-only} icd_dgns_cd7 varchar(7), -${logic.hsql-only} icd_dgns_cd8 varchar(7), -${logic.hsql-only} icd_dgns_cd9 varchar(7), -${logic.hsql-only} icd_dgns_cd10 varchar(7), -${logic.hsql-only} icd_dgns_cd11 varchar(7), -${logic.hsql-only} icd_dgns_cd12 varchar(7), -${logic.hsql-only} icd_dgns_cd13 varchar(7), -${logic.hsql-only} icd_dgns_cd14 varchar(7), -${logic.hsql-only} icd_dgns_cd15 varchar(7), -${logic.hsql-only} icd_dgns_cd16 varchar(7), -${logic.hsql-only} icd_dgns_cd17 varchar(7), -${logic.hsql-only} icd_dgns_cd18 varchar(7), -${logic.hsql-only} icd_dgns_cd19 varchar(7), -${logic.hsql-only} icd_dgns_cd20 varchar(7), -${logic.hsql-only} icd_dgns_cd21 varchar(7), -${logic.hsql-only} icd_dgns_cd22 varchar(7), -${logic.hsql-only} icd_dgns_cd23 varchar(7), -${logic.hsql-only} icd_dgns_cd24 varchar(7), -${logic.hsql-only} icd_dgns_cd25 varchar(7), -${logic.hsql-only} icd_dgns_e_cd1 varchar(7), -${logic.hsql-only} icd_dgns_e_cd2 varchar(7), -${logic.hsql-only} icd_dgns_e_cd3 varchar(7), -${logic.hsql-only} icd_dgns_e_cd4 varchar(7), -${logic.hsql-only} icd_dgns_e_cd5 varchar(7), -${logic.hsql-only} icd_dgns_e_cd6 varchar(7), -${logic.hsql-only} icd_dgns_e_cd7 varchar(7), -${logic.hsql-only} icd_dgns_e_cd8 varchar(7), -${logic.hsql-only} icd_dgns_e_cd9 varchar(7), -${logic.hsql-only} icd_dgns_e_cd10 varchar(7), -${logic.hsql-only} icd_dgns_e_cd11 varchar(7), -${logic.hsql-only} icd_dgns_e_cd12 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd1 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd2 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd3 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd4 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd5 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd6 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd7 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd8 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd9 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd10 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd11 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd12 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd1 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd2 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd3 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd4 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd5 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd6 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd7 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd8 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd9 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd10 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd11 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd12 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd13 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd14 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd15 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd16 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd17 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd18 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd19 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd20 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd21 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd22 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd23 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd24 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd25 char(1), -${logic.hsql-only} icd_prcdr_cd1 varchar(7), -${logic.hsql-only} icd_prcdr_cd2 varchar(7), -${logic.hsql-only} icd_prcdr_cd3 varchar(7), -${logic.hsql-only} icd_prcdr_cd4 varchar(7), -${logic.hsql-only} icd_prcdr_cd5 varchar(7), -${logic.hsql-only} icd_prcdr_cd6 varchar(7), -${logic.hsql-only} icd_prcdr_cd7 varchar(7), -${logic.hsql-only} icd_prcdr_cd8 varchar(7), -${logic.hsql-only} icd_prcdr_cd9 varchar(7), -${logic.hsql-only} icd_prcdr_cd10 varchar(7), -${logic.hsql-only} icd_prcdr_cd11 varchar(7), -${logic.hsql-only} icd_prcdr_cd12 varchar(7), -${logic.hsql-only} icd_prcdr_cd13 varchar(7), -${logic.hsql-only} icd_prcdr_cd14 varchar(7), -${logic.hsql-only} icd_prcdr_cd15 varchar(7), -${logic.hsql-only} icd_prcdr_cd16 varchar(7), -${logic.hsql-only} icd_prcdr_cd17 varchar(7), -${logic.hsql-only} icd_prcdr_cd18 varchar(7), -${logic.hsql-only} icd_prcdr_cd19 varchar(7), -${logic.hsql-only} icd_prcdr_cd20 varchar(7), -${logic.hsql-only} icd_prcdr_cd21 varchar(7), -${logic.hsql-only} icd_prcdr_cd22 varchar(7), -${logic.hsql-only} icd_prcdr_cd23 varchar(7), -${logic.hsql-only} icd_prcdr_cd24 varchar(7), -${logic.hsql-only} icd_prcdr_cd25 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd1 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd2 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd3 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd4 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd5 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd6 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd7 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd8 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd9 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd10 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd11 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd12 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd13 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd14 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd15 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd16 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd17 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd18 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd19 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd20 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd21 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd22 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd23 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd24 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd25 char(1), -${logic.hsql-only} prcdr_dt1 date, -${logic.hsql-only} prcdr_dt2 date, -${logic.hsql-only} prcdr_dt3 date, -${logic.hsql-only} prcdr_dt4 date, -${logic.hsql-only} prcdr_dt5 date, -${logic.hsql-only} prcdr_dt6 date, -${logic.hsql-only} prcdr_dt7 date, -${logic.hsql-only} prcdr_dt8 date, -${logic.hsql-only} prcdr_dt9 date, -${logic.hsql-only} prcdr_dt10 date, -${logic.hsql-only} prcdr_dt11 date, -${logic.hsql-only} prcdr_dt12 date, -${logic.hsql-only} prcdr_dt13 date, -${logic.hsql-only} prcdr_dt14 date, -${logic.hsql-only} prcdr_dt15 date, -${logic.hsql-only} prcdr_dt16 date, -${logic.hsql-only} prcdr_dt17 date, -${logic.hsql-only} prcdr_dt18 date, -${logic.hsql-only} prcdr_dt19 date, -${logic.hsql-only} prcdr_dt20 date, -${logic.hsql-only} prcdr_dt21 date, -${logic.hsql-only} prcdr_dt22 date, -${logic.hsql-only} prcdr_dt23 date, -${logic.hsql-only} prcdr_dt24 date, -${logic.hsql-only} prcdr_dt25 date, -${logic.hsql-only} constraint public.snf_claims_new_pkey -${logic.hsql-only} primary key (clm_id) ); - --- create a new SNF_CLAIM_LINES_NEW table in the current PUBLIC schema --- -${logic.hsql-only} CREATE TABLE IF NOT EXISTS public.snf_claim_lines_new ( -${logic.hsql-only} clm_id bigint NOT NULL, -${logic.hsql-only} clm_line_num smallint NOT NULL, -${logic.hsql-only} rev_cntr varchar(4) NOT NULL, -${logic.hsql-only} rev_cntr_unit_cnt integer NOT NULL, -${logic.hsql-only} rev_cntr_tot_chrg_amt numeric(12,2) NOT NULL, -${logic.hsql-only} rev_cntr_rate_amt numeric(12,2) NOT NULL, -${logic.hsql-only} rev_cntr_ncvrd_chrg_amt numeric(12,2) NOT NULL, -${logic.hsql-only} rev_cntr_ddctbl_coinsrnc_cd char(1), -${logic.hsql-only} rev_cntr_ndc_qty_qlfr_cd varchar(2), -${logic.hsql-only} rev_cntr_ndc_qty integer, -${logic.hsql-only} hcpcs_cd varchar(5), -${logic.hsql-only} rndrng_physn_npi varchar(12), -${logic.hsql-only} rndrng_physn_upin varchar(12), -${logic.hsql-only} CONSTRAINT snf_claim_lines_new_pkey -${logic.hsql-only} PRIMARY KEY (clm_id, clm_line_num) ); - --- migrate data via INSERT from current SNF_CLAIMS table to SNF_CLAIMS_NEW table --- -${logic.hsql-only} insert into public.snf_claims_new ( -${logic.hsql-only} clm_id, -${logic.hsql-only} bene_id, -${logic.hsql-only} clm_grp_id, -${logic.hsql-only} last_updated, -${logic.hsql-only} clm_from_dt, -${logic.hsql-only} clm_thru_dt, -${logic.hsql-only} claim_query_code, -${logic.hsql-only} clm_admsn_dt, -${logic.hsql-only} clm_fac_type_cd, -${logic.hsql-only} clm_freq_cd, -${logic.hsql-only} clm_ip_admsn_type_cd, -${logic.hsql-only} clm_non_utlztn_days_cnt, -${logic.hsql-only} clm_utlztn_day_cnt, -${logic.hsql-only} bene_tot_coinsrnc_days_cnt, -${logic.hsql-only} clm_srvc_clsfctn_type_cd, -${logic.hsql-only} final_action, -${logic.hsql-only} clm_tot_chrg_amt, -${logic.hsql-only} clm_pmt_amt, -${logic.hsql-only} clm_pps_ind_cd, -${logic.hsql-only} clm_pps_cptl_dsprprtnt_shr_amt, -${logic.hsql-only} clm_pps_cptl_excptn_amt, -${logic.hsql-only} clm_pps_cptl_fsp_amt, -${logic.hsql-only} clm_pps_cptl_ime_amt, -${logic.hsql-only} clm_pps_cptl_outlier_amt, -${logic.hsql-only} clm_pps_old_cptl_hld_hrmls_amt, -${logic.hsql-only} nch_clm_type_cd, -${logic.hsql-only} nch_near_line_rec_ident_cd, -${logic.hsql-only} nch_wkly_proc_dt, -${logic.hsql-only} nch_blood_pnts_frnshd_qty, -${logic.hsql-only} nch_prmry_pyr_cd, -${logic.hsql-only} nch_prmry_pyr_clm_pd_amt, -${logic.hsql-only} nch_bene_blood_ddctbl_lblty_am, -${logic.hsql-only} nch_bene_ip_ddctbl_amt, -${logic.hsql-only} nch_bene_pta_coinsrnc_lblty_am, -${logic.hsql-only} nch_ip_ncvrd_chrg_amt, -${logic.hsql-only} nch_ip_tot_ddctn_amt, -${logic.hsql-only} nch_vrfd_ncvrd_stay_from_dt, -${logic.hsql-only} nch_vrfd_ncvrd_stay_thru_dt, -${logic.hsql-only} nch_qlfyd_stay_from_dt, -${logic.hsql-only} nch_qlfyd_stay_thru_dt, -${logic.hsql-only} nch_actv_or_cvrd_lvl_care_thru, -${logic.hsql-only} nch_bene_dschrg_dt, -${logic.hsql-only} nch_bene_mdcr_bnfts_exhtd_dt_i, -${logic.hsql-only} nch_ptnt_status_ind_cd, -${logic.hsql-only} clm_drg_cd, -${logic.hsql-only} clm_mco_pd_sw, -${logic.hsql-only} clm_mdcr_non_pmt_rsn_cd, -${logic.hsql-only} clm_src_ip_admsn_cd, -${logic.hsql-only} admtg_dgns_cd, -${logic.hsql-only} admtg_dgns_vrsn_cd, -${logic.hsql-only} at_physn_npi, -${logic.hsql-only} at_physn_upin, -${logic.hsql-only} op_physn_npi, -${logic.hsql-only} op_physn_upin, -${logic.hsql-only} org_npi_num, -${logic.hsql-only} ot_physn_npi, -${logic.hsql-only} ot_physn_upin, -${logic.hsql-only} prncpal_dgns_cd, -${logic.hsql-only} prncpal_dgns_vrsn_cd, -${logic.hsql-only} prvdr_num, -${logic.hsql-only} prvdr_state_cd, -${logic.hsql-only} ptnt_dschrg_stus_cd, -${logic.hsql-only} fi_clm_actn_cd, -${logic.hsql-only} fi_clm_proc_dt, -${logic.hsql-only} fi_doc_clm_cntl_num, -${logic.hsql-only} fi_num, -${logic.hsql-only} fi_orig_clm_cntl_num, -${logic.hsql-only} fst_dgns_e_cd, -${logic.hsql-only} fst_dgns_e_vrsn_cd, -${logic.hsql-only} icd_dgns_cd1, -${logic.hsql-only} icd_dgns_cd2, -${logic.hsql-only} icd_dgns_cd3, -${logic.hsql-only} icd_dgns_cd4, -${logic.hsql-only} icd_dgns_cd5, -${logic.hsql-only} icd_dgns_cd6, -${logic.hsql-only} icd_dgns_cd7, -${logic.hsql-only} icd_dgns_cd8, -${logic.hsql-only} icd_dgns_cd9, -${logic.hsql-only} icd_dgns_cd10, -${logic.hsql-only} icd_dgns_cd11, -${logic.hsql-only} icd_dgns_cd12, -${logic.hsql-only} icd_dgns_cd13, -${logic.hsql-only} icd_dgns_cd14, -${logic.hsql-only} icd_dgns_cd15, -${logic.hsql-only} icd_dgns_cd16, -${logic.hsql-only} icd_dgns_cd17, -${logic.hsql-only} icd_dgns_cd18, -${logic.hsql-only} icd_dgns_cd19, -${logic.hsql-only} icd_dgns_cd20, -${logic.hsql-only} icd_dgns_cd21, -${logic.hsql-only} icd_dgns_cd22, -${logic.hsql-only} icd_dgns_cd23, -${logic.hsql-only} icd_dgns_cd24, -${logic.hsql-only} icd_dgns_cd25, -${logic.hsql-only} icd_dgns_e_cd1, -${logic.hsql-only} icd_dgns_e_cd2, -${logic.hsql-only} icd_dgns_e_cd3, -${logic.hsql-only} icd_dgns_e_cd4, -${logic.hsql-only} icd_dgns_e_cd5, -${logic.hsql-only} icd_dgns_e_cd6, -${logic.hsql-only} icd_dgns_e_cd7, -${logic.hsql-only} icd_dgns_e_cd8, -${logic.hsql-only} icd_dgns_e_cd9, -${logic.hsql-only} icd_dgns_e_cd10, -${logic.hsql-only} icd_dgns_e_cd11, -${logic.hsql-only} icd_dgns_e_cd12, -${logic.hsql-only} icd_dgns_e_vrsn_cd1, -${logic.hsql-only} icd_dgns_e_vrsn_cd2, -${logic.hsql-only} icd_dgns_e_vrsn_cd3, -${logic.hsql-only} icd_dgns_e_vrsn_cd4, -${logic.hsql-only} icd_dgns_e_vrsn_cd5, -${logic.hsql-only} icd_dgns_e_vrsn_cd6, -${logic.hsql-only} icd_dgns_e_vrsn_cd7, -${logic.hsql-only} icd_dgns_e_vrsn_cd8, -${logic.hsql-only} icd_dgns_e_vrsn_cd9, -${logic.hsql-only} icd_dgns_e_vrsn_cd10, -${logic.hsql-only} icd_dgns_e_vrsn_cd11, -${logic.hsql-only} icd_dgns_e_vrsn_cd12, -${logic.hsql-only} icd_dgns_vrsn_cd1, -${logic.hsql-only} icd_dgns_vrsn_cd2, -${logic.hsql-only} icd_dgns_vrsn_cd3, -${logic.hsql-only} icd_dgns_vrsn_cd4, -${logic.hsql-only} icd_dgns_vrsn_cd5, -${logic.hsql-only} icd_dgns_vrsn_cd6, -${logic.hsql-only} icd_dgns_vrsn_cd7, -${logic.hsql-only} icd_dgns_vrsn_cd8, -${logic.hsql-only} icd_dgns_vrsn_cd9, -${logic.hsql-only} icd_dgns_vrsn_cd10, -${logic.hsql-only} icd_dgns_vrsn_cd11, -${logic.hsql-only} icd_dgns_vrsn_cd12, -${logic.hsql-only} icd_dgns_vrsn_cd13, -${logic.hsql-only} icd_dgns_vrsn_cd14, -${logic.hsql-only} icd_dgns_vrsn_cd15, -${logic.hsql-only} icd_dgns_vrsn_cd16, -${logic.hsql-only} icd_dgns_vrsn_cd17, -${logic.hsql-only} icd_dgns_vrsn_cd18, -${logic.hsql-only} icd_dgns_vrsn_cd19, -${logic.hsql-only} icd_dgns_vrsn_cd20, -${logic.hsql-only} icd_dgns_vrsn_cd21, -${logic.hsql-only} icd_dgns_vrsn_cd22, -${logic.hsql-only} icd_dgns_vrsn_cd23, -${logic.hsql-only} icd_dgns_vrsn_cd24, -${logic.hsql-only} icd_dgns_vrsn_cd25, -${logic.hsql-only} icd_prcdr_cd1, -${logic.hsql-only} icd_prcdr_cd2, -${logic.hsql-only} icd_prcdr_cd3, -${logic.hsql-only} icd_prcdr_cd4, -${logic.hsql-only} icd_prcdr_cd5, -${logic.hsql-only} icd_prcdr_cd6, -${logic.hsql-only} icd_prcdr_cd7, -${logic.hsql-only} icd_prcdr_cd8, -${logic.hsql-only} icd_prcdr_cd9, -${logic.hsql-only} icd_prcdr_cd10, -${logic.hsql-only} icd_prcdr_cd11, -${logic.hsql-only} icd_prcdr_cd12, -${logic.hsql-only} icd_prcdr_cd13, -${logic.hsql-only} icd_prcdr_cd14, -${logic.hsql-only} icd_prcdr_cd15, -${logic.hsql-only} icd_prcdr_cd16, -${logic.hsql-only} icd_prcdr_cd17, -${logic.hsql-only} icd_prcdr_cd18, -${logic.hsql-only} icd_prcdr_cd19, -${logic.hsql-only} icd_prcdr_cd20, -${logic.hsql-only} icd_prcdr_cd21, -${logic.hsql-only} icd_prcdr_cd22, -${logic.hsql-only} icd_prcdr_cd23, -${logic.hsql-only} icd_prcdr_cd24, -${logic.hsql-only} icd_prcdr_cd25, -${logic.hsql-only} icd_prcdr_vrsn_cd1, -${logic.hsql-only} icd_prcdr_vrsn_cd2, -${logic.hsql-only} icd_prcdr_vrsn_cd3, -${logic.hsql-only} icd_prcdr_vrsn_cd4, -${logic.hsql-only} icd_prcdr_vrsn_cd5, -${logic.hsql-only} icd_prcdr_vrsn_cd6, -${logic.hsql-only} icd_prcdr_vrsn_cd7, -${logic.hsql-only} icd_prcdr_vrsn_cd8, -${logic.hsql-only} icd_prcdr_vrsn_cd9, -${logic.hsql-only} icd_prcdr_vrsn_cd10, -${logic.hsql-only} icd_prcdr_vrsn_cd11, -${logic.hsql-only} icd_prcdr_vrsn_cd12, -${logic.hsql-only} icd_prcdr_vrsn_cd13, -${logic.hsql-only} icd_prcdr_vrsn_cd14, -${logic.hsql-only} icd_prcdr_vrsn_cd15, -${logic.hsql-only} icd_prcdr_vrsn_cd16, -${logic.hsql-only} icd_prcdr_vrsn_cd17, -${logic.hsql-only} icd_prcdr_vrsn_cd18, -${logic.hsql-only} icd_prcdr_vrsn_cd19, -${logic.hsql-only} icd_prcdr_vrsn_cd20, -${logic.hsql-only} icd_prcdr_vrsn_cd21, -${logic.hsql-only} icd_prcdr_vrsn_cd22, -${logic.hsql-only} icd_prcdr_vrsn_cd23, -${logic.hsql-only} icd_prcdr_vrsn_cd24, -${logic.hsql-only} icd_prcdr_vrsn_cd25, -${logic.hsql-only} prcdr_dt1, -${logic.hsql-only} prcdr_dt2, -${logic.hsql-only} prcdr_dt3, -${logic.hsql-only} prcdr_dt4, -${logic.hsql-only} prcdr_dt5, -${logic.hsql-only} prcdr_dt6, -${logic.hsql-only} prcdr_dt7, -${logic.hsql-only} prcdr_dt8, -${logic.hsql-only} prcdr_dt9, -${logic.hsql-only} prcdr_dt10, -${logic.hsql-only} prcdr_dt11, -${logic.hsql-only} prcdr_dt12, -${logic.hsql-only} prcdr_dt13, -${logic.hsql-only} prcdr_dt14, -${logic.hsql-only} prcdr_dt15, -${logic.hsql-only} prcdr_dt16, -${logic.hsql-only} prcdr_dt17, -${logic.hsql-only} prcdr_dt18, -${logic.hsql-only} prcdr_dt19, -${logic.hsql-only} prcdr_dt20, -${logic.hsql-only} prcdr_dt21, -${logic.hsql-only} prcdr_dt22, -${logic.hsql-only} prcdr_dt23, -${logic.hsql-only} prcdr_dt24, -${logic.hsql-only} prcdr_dt25 ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} SET max_parallel_workers = 24; -${logic.psql-only} SET max_parallel_workers_per_gather = 20; -${logic.psql-only} SET parallel_leader_participation = off; -${logic.psql-only} SET parallel_tuple_cost = 0; -${logic.psql-only} SET parallel_setup_cost = 0; - -${logic.psql-only} create table public.snf_claims_new as -select -${logic.psql-only} cast(clm_id as bigint), -${logic.psql-only} cast(bene_id as bigint), -${logic.psql-only} cast(clm_grp_id as bigint), -${logic.hsql-only} convert(clm_id, SQL_BIGINT), -${logic.hsql-only} convert(bene_id, SQL_BIGINT), -${logic.hsql-only} convert(clm_grp_id, SQL_BIGINT), - last_updated, - clm_from_dt, - clm_thru_dt, - claim_query_code, - clm_admsn_dt, - clm_fac_type_cd, - clm_freq_cd, - clm_ip_admsn_type_cd, - ${logic.hsql-only} clm_non_utlztn_days_cnt, - ${logic.psql-only} cast(clm_non_utlztn_days_cnt as smallint), - ${logic.hsql-only} clm_utlztn_day_cnt, - ${logic.psql-only} cast(clm_utlztn_day_cnt as smallint), - ${logic.hsql-only} bene_tot_coinsrnc_days_cnt, - ${logic.psql-only} cast(bene_tot_coinsrnc_days_cnt as smallint), - clm_srvc_clsfctn_type_cd, - final_action, - clm_tot_chrg_amt, - clm_pmt_amt, - clm_pps_ind_cd, - clm_pps_cptl_dsprprtnt_shr_amt, - clm_pps_cptl_excptn_amt, - clm_pps_cptl_fsp_amt, - clm_pps_cptl_ime_amt, - clm_pps_cptl_outlier_amt, - clm_pps_old_cptl_hld_hrmls_amt, - nch_clm_type_cd, - nch_near_line_rec_ident_cd, - nch_wkly_proc_dt, -${logic.hsql-only} nch_blood_pnts_frnshd_qty, -${logic.psql-only} cast(nch_blood_pnts_frnshd_qty as integer), - nch_prmry_pyr_cd, - nch_prmry_pyr_clm_pd_amt, - nch_bene_blood_ddctbl_lblty_am, - nch_bene_ip_ddctbl_amt, - nch_bene_pta_coinsrnc_lblty_am, - nch_ip_ncvrd_chrg_amt, - nch_ip_tot_ddctn_amt, - nch_vrfd_ncvrd_stay_from_dt, - nch_vrfd_ncvrd_stay_thru_dt, - nch_qlfyd_stay_from_dt, - nch_qlfyd_stay_thru_dt, - nch_actv_or_cvrd_lvl_care_thru, - nch_bene_dschrg_dt, - nch_bene_mdcr_bnfts_exhtd_dt_i, - nch_ptnt_status_ind_cd, - clm_drg_cd, - clm_mco_pd_sw, - clm_mdcr_non_pmt_rsn_cd, - clm_src_ip_admsn_cd, - admtg_dgns_cd, - admtg_dgns_vrsn_cd, - at_physn_npi, - at_physn_upin, - op_physn_npi, - op_physn_upin, - org_npi_num, - ot_physn_npi, - ot_physn_upin, - prncpal_dgns_cd, - prncpal_dgns_vrsn_cd, - prvdr_num, - prvdr_state_cd, - ptnt_dschrg_stus_cd, - fi_clm_actn_cd, - fi_clm_proc_dt, - fi_doc_clm_cntl_num, - fi_num, - fi_orig_clm_cntl_num, - fst_dgns_e_cd, - fst_dgns_e_vrsn_cd, - icd_dgns_cd1, - icd_dgns_cd2, - icd_dgns_cd3, - icd_dgns_cd4, - icd_dgns_cd5, - icd_dgns_cd6, - icd_dgns_cd7, - icd_dgns_cd8, - icd_dgns_cd9, - icd_dgns_cd10, - icd_dgns_cd11, - icd_dgns_cd12, - icd_dgns_cd13, - icd_dgns_cd14, - icd_dgns_cd15, - icd_dgns_cd16, - icd_dgns_cd17, - icd_dgns_cd18, - icd_dgns_cd19, - icd_dgns_cd20, - icd_dgns_cd21, - icd_dgns_cd22, - icd_dgns_cd23, - icd_dgns_cd24, - icd_dgns_cd25, - icd_dgns_e_cd1, - icd_dgns_e_cd2, - icd_dgns_e_cd3, - icd_dgns_e_cd4, - icd_dgns_e_cd5, - icd_dgns_e_cd6, - icd_dgns_e_cd7, - icd_dgns_e_cd8, - icd_dgns_e_cd9, - icd_dgns_e_cd10, - icd_dgns_e_cd11, - icd_dgns_e_cd12, - icd_dgns_e_vrsn_cd1, - icd_dgns_e_vrsn_cd2, - icd_dgns_e_vrsn_cd3, - icd_dgns_e_vrsn_cd4, - icd_dgns_e_vrsn_cd5, - icd_dgns_e_vrsn_cd6, - icd_dgns_e_vrsn_cd7, - icd_dgns_e_vrsn_cd8, - icd_dgns_e_vrsn_cd9, - icd_dgns_e_vrsn_cd10, - icd_dgns_e_vrsn_cd11, - icd_dgns_e_vrsn_cd12, - icd_dgns_vrsn_cd1, - icd_dgns_vrsn_cd2, - icd_dgns_vrsn_cd3, - icd_dgns_vrsn_cd4, - icd_dgns_vrsn_cd5, - icd_dgns_vrsn_cd6, - icd_dgns_vrsn_cd7, - icd_dgns_vrsn_cd8, - icd_dgns_vrsn_cd9, - icd_dgns_vrsn_cd10, - icd_dgns_vrsn_cd11, - icd_dgns_vrsn_cd12, - icd_dgns_vrsn_cd13, - icd_dgns_vrsn_cd14, - icd_dgns_vrsn_cd15, - icd_dgns_vrsn_cd16, - icd_dgns_vrsn_cd17, - icd_dgns_vrsn_cd18, - icd_dgns_vrsn_cd19, - icd_dgns_vrsn_cd20, - icd_dgns_vrsn_cd21, - icd_dgns_vrsn_cd22, - icd_dgns_vrsn_cd23, - icd_dgns_vrsn_cd24, - icd_dgns_vrsn_cd25, - icd_prcdr_cd1, - icd_prcdr_cd2, - icd_prcdr_cd3, - icd_prcdr_cd4, - icd_prcdr_cd5, - icd_prcdr_cd6, - icd_prcdr_cd7, - icd_prcdr_cd8, - icd_prcdr_cd9, - icd_prcdr_cd10, - icd_prcdr_cd11, - icd_prcdr_cd12, - icd_prcdr_cd13, - icd_prcdr_cd14, - icd_prcdr_cd15, - icd_prcdr_cd16, - icd_prcdr_cd17, - icd_prcdr_cd18, - icd_prcdr_cd19, - icd_prcdr_cd20, - icd_prcdr_cd21, - icd_prcdr_cd22, - icd_prcdr_cd23, - icd_prcdr_cd24, - icd_prcdr_cd25, - icd_prcdr_vrsn_cd1, - icd_prcdr_vrsn_cd2, - icd_prcdr_vrsn_cd3, - icd_prcdr_vrsn_cd4, - icd_prcdr_vrsn_cd5, - icd_prcdr_vrsn_cd6, - icd_prcdr_vrsn_cd7, - icd_prcdr_vrsn_cd8, - icd_prcdr_vrsn_cd9, - icd_prcdr_vrsn_cd10, - icd_prcdr_vrsn_cd11, - icd_prcdr_vrsn_cd12, - icd_prcdr_vrsn_cd13, - icd_prcdr_vrsn_cd14, - icd_prcdr_vrsn_cd15, - icd_prcdr_vrsn_cd16, - icd_prcdr_vrsn_cd17, - icd_prcdr_vrsn_cd18, - icd_prcdr_vrsn_cd19, - icd_prcdr_vrsn_cd20, - icd_prcdr_vrsn_cd21, - icd_prcdr_vrsn_cd22, - icd_prcdr_vrsn_cd23, - icd_prcdr_vrsn_cd24, - icd_prcdr_vrsn_cd25, - prcdr_dt1, - prcdr_dt2, - prcdr_dt3, - prcdr_dt4, - prcdr_dt5, - prcdr_dt6, - prcdr_dt7, - prcdr_dt8, - prcdr_dt9, - prcdr_dt10, - prcdr_dt11, - prcdr_dt12, - prcdr_dt13, - prcdr_dt14, - prcdr_dt15, - prcdr_dt16, - prcdr_dt17, - prcdr_dt18, - prcdr_dt19, - prcdr_dt20, - prcdr_dt21, - prcdr_dt22, - prcdr_dt23, - prcdr_dt24, - prcdr_dt25 -from - public.snf_claims; - --- for PSQL need to define our not null constraints; for HSQL, --- we explicitly defined a table structure before migrating data. --- -${logic.psql-only} alter table public.snf_claims_new -${logic.psql-only} alter column clm_id SET NOT NULL, -${logic.psql-only} alter column bene_id SET NOT NULL, -${logic.psql-only} alter column clm_grp_id SET NOT NULL, -${logic.psql-only} alter column clm_from_dt SET NOT NULL, -${logic.psql-only} alter column clm_thru_dt SET NOT NULL, -${logic.psql-only} alter column claim_query_code SET NOT NULL, -${logic.psql-only} alter column clm_fac_type_cd SET NOT NULL, -${logic.psql-only} alter column clm_freq_cd SET NOT NULL, -${logic.psql-only} alter column clm_ip_admsn_type_cd SET NOT NULL, -${logic.psql-only} alter column clm_non_utlztn_days_cnt SET NOT NULL, -${logic.psql-only} alter column clm_utlztn_day_cnt SET NOT NULL, -${logic.psql-only} alter column bene_tot_coinsrnc_days_cnt SET NOT NULL, -${logic.psql-only} alter column clm_srvc_clsfctn_type_cd SET NOT NULL, -${logic.psql-only} alter column final_action SET NOT NULL, -${logic.psql-only} alter column clm_tot_chrg_amt SET NOT NULL, -${logic.psql-only} alter column clm_pmt_amt SET NOT NULL, -${logic.psql-only} alter column nch_clm_type_cd SET NOT NULL, -${logic.psql-only} alter column nch_near_line_rec_ident_cd SET NOT NULL, -${logic.psql-only} alter column nch_wkly_proc_dt SET NOT NULL, -${logic.psql-only} alter column nch_blood_pnts_frnshd_qty SET NOT NULL, -${logic.psql-only} alter column nch_prmry_pyr_clm_pd_amt SET NOT NULL, -${logic.psql-only} alter column nch_bene_blood_ddctbl_lblty_am SET NOT NULL, -${logic.psql-only} alter column nch_bene_ip_ddctbl_amt SET NOT NULL, -${logic.psql-only} alter column nch_bene_pta_coinsrnc_lblty_am SET NOT NULL, -${logic.psql-only} alter column nch_ip_ncvrd_chrg_amt SET NOT NULL, -${logic.psql-only} alter column nch_ip_tot_ddctn_amt SET NOT NULL, -${logic.psql-only} alter column prvdr_num SET NOT NULL, -${logic.psql-only} alter column prvdr_state_cd SET NOT NULL, -${logic.psql-only} alter column ptnt_dschrg_stus_cd SET NOT NULL; - --- migrate data via INSERT from current SNF_CLAIM_LINES table to SNF_CLAIM_LINES_NEW table --- -${logic.hsql-only} insert into public.snf_claim_lines_new ( -${logic.hsql-only} clm_id, -${logic.hsql-only} clm_line_num, -${logic.hsql-only} rev_cntr, -${logic.hsql-only} rev_cntr_unit_cnt, -${logic.hsql-only} rev_cntr_tot_chrg_amt, -${logic.hsql-only} rev_cntr_rate_amt, -${logic.hsql-only} rev_cntr_ncvrd_chrg_amt, -${logic.hsql-only} rev_cntr_ddctbl_coinsrnc_cd, -${logic.hsql-only} rev_cntr_ndc_qty_qlfr_cd, -${logic.hsql-only} rev_cntr_ndc_qty, -${logic.hsql-only} hcpcs_cd, -${logic.hsql-only} rndrng_physn_npi, -${logic.hsql-only} rndrng_physn_upin ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} create table public.snf_claim_lines_new as -select -${logic.psql-only} cast(clm_id as bigint), -${logic.hsql-only} convert(clm_id, SQL_BIGINT), -${logic.psql-only} cast(clm_line_num as smallint), -${logic.hsql-only} convert(clm_line_num, SQL_SMALLINT), - rev_cntr, -${logic.psql-only} cast(rev_cntr_unit_cnt as integer), -${logic.hsql-only} rev_cntr_unit_cnt, - rev_cntr_tot_chrg_amt, - rev_cntr_rate_amt, - rev_cntr_ncvrd_chrg_amt, - rev_cntr_ddctbl_coinsrnc_cd, - rev_cntr_ndc_qty_qlfr_cd, -${logic.psql-only} cast(rev_cntr_ndc_qty as integer), -${logic.hsql-only} convert(rev_cntr_ndc_qty, SQL_INTEGER), - hcpcs_cd, - rndrng_physn_npi, - rndrng_physn_upin -from - public.snf_claim_lines; - --- for PSQL need to define our not null constraints; for HSQL, --- we explicitly defined a table structure before migrating data. --- -${logic.psql-only} alter table public.snf_claim_lines_new -${logic.psql-only} alter column clm_id SET NOT NULL, -${logic.psql-only} alter column clm_line_num SET NOT NULL, -${logic.psql-only} alter column rev_cntr SET NOT NULL, -${logic.psql-only} alter column rev_cntr_unit_cnt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_tot_chrg_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_rate_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_ncvrd_chrg_amt SET NOT NULL; - --- for PSQL need to define our primary key -${logic.psql-only} alter table public.snf_claims_new -${logic.psql-only} add CONSTRAINT snf_claims_new_pkey PRIMARY KEY (clm_id); - --- for PSQL need to define our primary key -${logic.psql-only} ALTER TABLE public.snf_claim_lines_new -${logic.psql-only} ADD CONSTRAINT snf_claim_lines_new_pkey PRIMARY KEY (clm_id, clm_line_num); - --- define foreign key constraints between claim lineitems and a parent claims table. -ALTER TABLE IF EXISTS public.snf_claim_lines_new - ADD CONSTRAINT snf_claim_lines_clm_id_to_snf_claims_new FOREIGN KEY (clm_id) - REFERENCES public.snf_claims_new (clm_id); - --- create an index of the BENE_ID in parent claims table -CREATE INDEX IF NOT EXISTS snf_claims_new_bene_id_idx - ON public.snf_claims_new (bene_id); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V64__drop_pre_adj_schema.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V64__drop_pre_adj_schema.sql deleted file mode 100644 index 177a2029ed..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V64__drop_pre_adj_schema.sql +++ /dev/null @@ -1,6 +0,0 @@ -/* - * The pre_adj schema has been replaced by the rda schema. This migration drops the old schema and all - * of its contents since they are now redundant. - */ - -drop schema if exists "pre_adj" cascade; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V65__Add_PreUpdate_Trigger_Beneficiaries.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V65__Add_PreUpdate_Trigger_Beneficiaries.sql deleted file mode 100644 index 386b786cdb..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V65__Add_PreUpdate_Trigger_Beneficiaries.sql +++ /dev/null @@ -1,40 +0,0 @@ --- Add a pre-[insert|update] trigger to the beneficiaries table to populate --- bene_id_numeric on a record update. We need both pre-insert and --- pre-update trigger to fire since the Beneficiary.java ORM object will --- initialize the native data type to 0 (zero) when the object is instantiated. - --- The database trigger will be used to imbue a bigint value into the bene_id_numeric --- column during a table record INSERT or UPDATE operation what this means is that --- prior to a record being written, the database engine will execute the trigger, causing --- the bene_id_numeric to be populated with a value based on a 'cast' of the bene_id (varchar). - --- Unfortunately HSQL doesn't support 'insert or update' directive so we have to --- have a separate trigger for the update. -${logic.hsql-only} CREATE TRIGGER beneficiaries_pre_update_trigger BEFORE UPDATE ON public.beneficiaries -${logic.hsql-only} REFERENCING NEW as newrow FOR EACH ROW -${logic.hsql-only} BEGIN ATOMIC -${logic.hsql-only} SET newrow.bene_id_numeric = convert(newrow.bene_id, SQL_BIGINT); -${logic.hsql-only} END; - --- for psql, completely clean out previous trigger and function created in V60 flyway script -${logic.psql-only} DROP TRIGGER IF EXISTS beneficiaries_insert_trigger ON public.beneficiaries CASCADE; -${logic.psql-only} DROP FUNCTION IF EXISTS public.beneficiaries_pre_insert() CASCADE; - --- create a trigger function that can be invoked to populate the bene_id_numeric -${logic.psql-only} CREATE OR REPLACE FUNCTION public.beneficiaries_populate_bene_id_numeric() -${logic.psql-only} RETURNS trigger -${logic.psql-only} LANGUAGE 'plpgsql' -${logic.psql-only} VOLATILE NOT LEAKPROOF -${logic.psql-only} AS $BODY$ -${logic.psql-only} BEGIN -${logic.psql-only} NEW.bene_id_numeric = NEW.bene_id::bigint; -${logic.psql-only} RETURN NEW; -${logic.psql-only} END; -${logic.psql-only} $BODY$; - --- for Postgres, we can combine the directive using "INSERT OR UPDATE" -${logic.psql-only} DROP TRIGGER IF EXISTS beneficiaries_pre_insert_update_trigger ON public.beneficiaries CASCADE; -${logic.psql-only} CREATE TRIGGER beneficiaries_pre_insert_update_trigger -${logic.psql-only} BEFORE INSERT OR UPDATE ON public.beneficiaries -${logic.psql-only} FOR EACH ROW -${logic.psql-only} EXECUTE FUNCTION public.beneficiaries_populate_bene_id_numeric(); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V66__new_schema_snf_claims_fix.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V66__new_schema_snf_claims_fix.sql deleted file mode 100644 index b8ff24eaab..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V66__new_schema_snf_claims_fix.sql +++ /dev/null @@ -1,821 +0,0 @@ --- NEW_SCHEMA_SNF_CLAIMS_FIX.SQL --- flyway migration for SNF_CLAIMS_NEW and SNF_CLAIM_LINES_NEW tables into --- a new schema structure; previous flyway script, V63__new_schema_snf_claims.sql, --- which erroneously defined columns in the snf_claim_lines_new table --- as an integer. This script fixes that mistake and does a complete data --- migration of SNF claims data because the _new tables would have missed --- the previous weekend's ETL processing. --- --- Once current table data is migrated to new table name/structure, --- a subsequent PR will be deployed that changes the ORM model(s) --- for SNF table(s). - --- drop _new SNF claims tables in order to reload -drop table if exists public.snf_claim_lines_new cascade; -drop table if exists public.snf_claims_new cascade; - --- For HSQL, explicitly define/create a new SNF_CLAIMS_NEW table in --- the current PUBLIC schema - -${logic.hsql-only} create table public.snf_claims_new ( -${logic.hsql-only} clm_id bigint NOT NULL, -${logic.hsql-only} bene_id bigint NOT NULL, -${logic.hsql-only} clm_grp_id bigint NOT NULL, -${logic.hsql-only} last_updated timestamp with time zone, -${logic.hsql-only} clm_from_dt date NOT NULL, -${logic.hsql-only} clm_thru_dt date NOT NULL, -${logic.hsql-only} claim_query_code char(1) NOT NULL, -${logic.hsql-only} clm_admsn_dt date, -${logic.hsql-only} clm_fac_type_cd char(1) NOT NULL, -${logic.hsql-only} clm_freq_cd char(1) NOT NULL, -${logic.hsql-only} clm_ip_admsn_type_cd char(1) NOT NULL, -${logic.hsql-only} clm_non_utlztn_days_cnt numeric NOT NULL, -${logic.hsql-only} clm_utlztn_day_cnt numeric NOT NULL, -${logic.hsql-only} bene_tot_coinsrnc_days_cnt numeric NOT NULL, -${logic.hsql-only} clm_srvc_clsfctn_type_cd char(1) NOT NULL, -${logic.hsql-only} final_action char(1) NOT NULL, -${logic.hsql-only} clm_tot_chrg_amt numeric(12,2) NOT NULL, -${logic.hsql-only} clm_pmt_amt numeric(12,2) NOT NULL, -${logic.hsql-only} clm_pps_ind_cd char(1), -${logic.hsql-only} clm_pps_cptl_dsprprtnt_shr_amt numeric(12,2), -${logic.hsql-only} clm_pps_cptl_excptn_amt numeric(12,2), -${logic.hsql-only} clm_pps_cptl_fsp_amt numeric(12,2), -${logic.hsql-only} clm_pps_cptl_ime_amt numeric(12,2), -${logic.hsql-only} clm_pps_cptl_outlier_amt numeric(12,2), -${logic.hsql-only} clm_pps_old_cptl_hld_hrmls_amt numeric(12,2), -${logic.hsql-only} nch_clm_type_cd varchar(2) NOT NULL, -${logic.hsql-only} nch_near_line_rec_ident_cd char(1) NOT NULL, -${logic.hsql-only} nch_wkly_proc_dt date NOT NULL, -${logic.hsql-only} nch_blood_pnts_frnshd_qty numeric NOT NULL, -${logic.hsql-only} nch_prmry_pyr_cd char(1), -${logic.hsql-only} nch_prmry_pyr_clm_pd_amt numeric(12,2) NOT NULL, -${logic.hsql-only} nch_bene_blood_ddctbl_lblty_am numeric(12,2) NOT NULL, -${logic.hsql-only} nch_bene_ip_ddctbl_amt numeric(12,2) NOT NULL, -${logic.hsql-only} nch_bene_pta_coinsrnc_lblty_am numeric(12,2) NOT NULL, -${logic.hsql-only} nch_ip_ncvrd_chrg_amt numeric(12,2) NOT NULL, -${logic.hsql-only} nch_ip_tot_ddctn_amt numeric(12,2) NOT NULL, -${logic.hsql-only} nch_vrfd_ncvrd_stay_from_dt date, -${logic.hsql-only} nch_vrfd_ncvrd_stay_thru_dt date, -${logic.hsql-only} nch_qlfyd_stay_from_dt date, -${logic.hsql-only} nch_qlfyd_stay_thru_dt date, -${logic.hsql-only} nch_actv_or_cvrd_lvl_care_thru date, -${logic.hsql-only} nch_bene_dschrg_dt date, -${logic.hsql-only} nch_bene_mdcr_bnfts_exhtd_dt_i date, -${logic.hsql-only} nch_ptnt_status_ind_cd char(1), -${logic.hsql-only} clm_drg_cd varchar(3), -${logic.hsql-only} clm_mco_pd_sw char(1), -${logic.hsql-only} clm_mdcr_non_pmt_rsn_cd varchar(2), -${logic.hsql-only} clm_src_ip_admsn_cd char(1), -${logic.hsql-only} admtg_dgns_cd varchar(7), -${logic.hsql-only} admtg_dgns_vrsn_cd char(1), -${logic.hsql-only} at_physn_npi varchar(10), -${logic.hsql-only} at_physn_upin varchar(9), -${logic.hsql-only} op_physn_npi varchar(10), -${logic.hsql-only} op_physn_upin varchar(9), -${logic.hsql-only} org_npi_num varchar(10), -${logic.hsql-only} ot_physn_npi varchar(10), -${logic.hsql-only} ot_physn_upin varchar(9), -${logic.hsql-only} prncpal_dgns_cd varchar(7), -${logic.hsql-only} prncpal_dgns_vrsn_cd char(1), -${logic.hsql-only} prvdr_num varchar(9) NOT NULL, -${logic.hsql-only} prvdr_state_cd varchar(2) NOT NULL, -${logic.hsql-only} ptnt_dschrg_stus_cd varchar(2) NOT NULL, -${logic.hsql-only} fi_num varchar(5), -${logic.hsql-only} fi_clm_actn_cd char(1), -${logic.hsql-only} fi_clm_proc_dt date, -${logic.hsql-only} fi_doc_clm_cntl_num varchar(23), -${logic.hsql-only} fi_orig_clm_cntl_num varchar(23), -${logic.hsql-only} fst_dgns_e_cd varchar(7), -${logic.hsql-only} fst_dgns_e_vrsn_cd char(1), -${logic.hsql-only} icd_dgns_cd1 varchar(7), -${logic.hsql-only} icd_dgns_cd2 varchar(7), -${logic.hsql-only} icd_dgns_cd3 varchar(7), -${logic.hsql-only} icd_dgns_cd4 varchar(7), -${logic.hsql-only} icd_dgns_cd5 varchar(7), -${logic.hsql-only} icd_dgns_cd6 varchar(7), -${logic.hsql-only} icd_dgns_cd7 varchar(7), -${logic.hsql-only} icd_dgns_cd8 varchar(7), -${logic.hsql-only} icd_dgns_cd9 varchar(7), -${logic.hsql-only} icd_dgns_cd10 varchar(7), -${logic.hsql-only} icd_dgns_cd11 varchar(7), -${logic.hsql-only} icd_dgns_cd12 varchar(7), -${logic.hsql-only} icd_dgns_cd13 varchar(7), -${logic.hsql-only} icd_dgns_cd14 varchar(7), -${logic.hsql-only} icd_dgns_cd15 varchar(7), -${logic.hsql-only} icd_dgns_cd16 varchar(7), -${logic.hsql-only} icd_dgns_cd17 varchar(7), -${logic.hsql-only} icd_dgns_cd18 varchar(7), -${logic.hsql-only} icd_dgns_cd19 varchar(7), -${logic.hsql-only} icd_dgns_cd20 varchar(7), -${logic.hsql-only} icd_dgns_cd21 varchar(7), -${logic.hsql-only} icd_dgns_cd22 varchar(7), -${logic.hsql-only} icd_dgns_cd23 varchar(7), -${logic.hsql-only} icd_dgns_cd24 varchar(7), -${logic.hsql-only} icd_dgns_cd25 varchar(7), -${logic.hsql-only} icd_dgns_e_cd1 varchar(7), -${logic.hsql-only} icd_dgns_e_cd2 varchar(7), -${logic.hsql-only} icd_dgns_e_cd3 varchar(7), -${logic.hsql-only} icd_dgns_e_cd4 varchar(7), -${logic.hsql-only} icd_dgns_e_cd5 varchar(7), -${logic.hsql-only} icd_dgns_e_cd6 varchar(7), -${logic.hsql-only} icd_dgns_e_cd7 varchar(7), -${logic.hsql-only} icd_dgns_e_cd8 varchar(7), -${logic.hsql-only} icd_dgns_e_cd9 varchar(7), -${logic.hsql-only} icd_dgns_e_cd10 varchar(7), -${logic.hsql-only} icd_dgns_e_cd11 varchar(7), -${logic.hsql-only} icd_dgns_e_cd12 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd1 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd2 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd3 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd4 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd5 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd6 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd7 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd8 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd9 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd10 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd11 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd12 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd1 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd2 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd3 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd4 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd5 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd6 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd7 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd8 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd9 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd10 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd11 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd12 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd13 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd14 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd15 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd16 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd17 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd18 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd19 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd20 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd21 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd22 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd23 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd24 char(1), -${logic.hsql-only} icd_dgns_vrsn_cd25 char(1), -${logic.hsql-only} icd_prcdr_cd1 varchar(7), -${logic.hsql-only} icd_prcdr_cd2 varchar(7), -${logic.hsql-only} icd_prcdr_cd3 varchar(7), -${logic.hsql-only} icd_prcdr_cd4 varchar(7), -${logic.hsql-only} icd_prcdr_cd5 varchar(7), -${logic.hsql-only} icd_prcdr_cd6 varchar(7), -${logic.hsql-only} icd_prcdr_cd7 varchar(7), -${logic.hsql-only} icd_prcdr_cd8 varchar(7), -${logic.hsql-only} icd_prcdr_cd9 varchar(7), -${logic.hsql-only} icd_prcdr_cd10 varchar(7), -${logic.hsql-only} icd_prcdr_cd11 varchar(7), -${logic.hsql-only} icd_prcdr_cd12 varchar(7), -${logic.hsql-only} icd_prcdr_cd13 varchar(7), -${logic.hsql-only} icd_prcdr_cd14 varchar(7), -${logic.hsql-only} icd_prcdr_cd15 varchar(7), -${logic.hsql-only} icd_prcdr_cd16 varchar(7), -${logic.hsql-only} icd_prcdr_cd17 varchar(7), -${logic.hsql-only} icd_prcdr_cd18 varchar(7), -${logic.hsql-only} icd_prcdr_cd19 varchar(7), -${logic.hsql-only} icd_prcdr_cd20 varchar(7), -${logic.hsql-only} icd_prcdr_cd21 varchar(7), -${logic.hsql-only} icd_prcdr_cd22 varchar(7), -${logic.hsql-only} icd_prcdr_cd23 varchar(7), -${logic.hsql-only} icd_prcdr_cd24 varchar(7), -${logic.hsql-only} icd_prcdr_cd25 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd1 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd2 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd3 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd4 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd5 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd6 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd7 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd8 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd9 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd10 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd11 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd12 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd13 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd14 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd15 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd16 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd17 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd18 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd19 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd20 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd21 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd22 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd23 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd24 char(1), -${logic.hsql-only} icd_prcdr_vrsn_cd25 char(1), -${logic.hsql-only} prcdr_dt1 date, -${logic.hsql-only} prcdr_dt2 date, -${logic.hsql-only} prcdr_dt3 date, -${logic.hsql-only} prcdr_dt4 date, -${logic.hsql-only} prcdr_dt5 date, -${logic.hsql-only} prcdr_dt6 date, -${logic.hsql-only} prcdr_dt7 date, -${logic.hsql-only} prcdr_dt8 date, -${logic.hsql-only} prcdr_dt9 date, -${logic.hsql-only} prcdr_dt10 date, -${logic.hsql-only} prcdr_dt11 date, -${logic.hsql-only} prcdr_dt12 date, -${logic.hsql-only} prcdr_dt13 date, -${logic.hsql-only} prcdr_dt14 date, -${logic.hsql-only} prcdr_dt15 date, -${logic.hsql-only} prcdr_dt16 date, -${logic.hsql-only} prcdr_dt17 date, -${logic.hsql-only} prcdr_dt18 date, -${logic.hsql-only} prcdr_dt19 date, -${logic.hsql-only} prcdr_dt20 date, -${logic.hsql-only} prcdr_dt21 date, -${logic.hsql-only} prcdr_dt22 date, -${logic.hsql-only} prcdr_dt23 date, -${logic.hsql-only} prcdr_dt24 date, -${logic.hsql-only} prcdr_dt25 date, -${logic.hsql-only} constraint public.snf_claims_new_pkey -${logic.hsql-only} primary key (clm_id) ); - --- create a new SNF_CLAIM_LINES_NEW table in the current PUBLIC schema --- -${logic.hsql-only} CREATE TABLE IF NOT EXISTS public.snf_claim_lines_new ( -${logic.hsql-only} clm_id bigint NOT NULL, -${logic.hsql-only} clm_line_num smallint NOT NULL, -${logic.hsql-only} rev_cntr varchar(4) NOT NULL, -${logic.hsql-only} rev_cntr_unit_cnt integer NOT NULL, -${logic.hsql-only} rev_cntr_tot_chrg_amt numeric(12,2) NOT NULL, -${logic.hsql-only} rev_cntr_rate_amt numeric(12,2) NOT NULL, -${logic.hsql-only} rev_cntr_ncvrd_chrg_amt numeric(12,2) NOT NULL, -${logic.hsql-only} rev_cntr_ddctbl_coinsrnc_cd char(1), -${logic.hsql-only} rev_cntr_ndc_qty_qlfr_cd varchar(2), -${logic.hsql-only} rev_cntr_ndc_qty numeric(12,3), -${logic.hsql-only} hcpcs_cd varchar(5), -${logic.hsql-only} rndrng_physn_npi varchar(12), -${logic.hsql-only} rndrng_physn_upin varchar(12), -${logic.hsql-only} CONSTRAINT snf_claim_lines_new_pkey -${logic.hsql-only} PRIMARY KEY (clm_id, clm_line_num) ); - --- attempt to leverage parallell processing for PSQL inserts -${logic.psql-only} SET max_parallel_workers = 24; -${logic.psql-only} SET max_parallel_workers_per_gather = 20; -${logic.psql-only} SET parallel_leader_participation = off; -${logic.psql-only} SET parallel_tuple_cost = 0; -${logic.psql-only} SET parallel_setup_cost = 0; - --- migrate data via INSERT from current SNF_CLAIMS table to SNF_CLAIMS_NEW table --- -${logic.hsql-only} insert into public.snf_claims_new ( -${logic.hsql-only} clm_id, -${logic.hsql-only} bene_id, -${logic.hsql-only} clm_grp_id, -${logic.hsql-only} last_updated, -${logic.hsql-only} clm_from_dt, -${logic.hsql-only} clm_thru_dt, -${logic.hsql-only} claim_query_code, -${logic.hsql-only} clm_admsn_dt, -${logic.hsql-only} clm_fac_type_cd, -${logic.hsql-only} clm_freq_cd, -${logic.hsql-only} clm_ip_admsn_type_cd, -${logic.hsql-only} clm_non_utlztn_days_cnt, -${logic.hsql-only} clm_utlztn_day_cnt, -${logic.hsql-only} bene_tot_coinsrnc_days_cnt, -${logic.hsql-only} clm_srvc_clsfctn_type_cd, -${logic.hsql-only} final_action, -${logic.hsql-only} clm_tot_chrg_amt, -${logic.hsql-only} clm_pmt_amt, -${logic.hsql-only} clm_pps_ind_cd, -${logic.hsql-only} clm_pps_cptl_dsprprtnt_shr_amt, -${logic.hsql-only} clm_pps_cptl_excptn_amt, -${logic.hsql-only} clm_pps_cptl_fsp_amt, -${logic.hsql-only} clm_pps_cptl_ime_amt, -${logic.hsql-only} clm_pps_cptl_outlier_amt, -${logic.hsql-only} clm_pps_old_cptl_hld_hrmls_amt, -${logic.hsql-only} nch_clm_type_cd, -${logic.hsql-only} nch_near_line_rec_ident_cd, -${logic.hsql-only} nch_wkly_proc_dt, -${logic.hsql-only} nch_blood_pnts_frnshd_qty, -${logic.hsql-only} nch_prmry_pyr_cd, -${logic.hsql-only} nch_prmry_pyr_clm_pd_amt, -${logic.hsql-only} nch_bene_blood_ddctbl_lblty_am, -${logic.hsql-only} nch_bene_ip_ddctbl_amt, -${logic.hsql-only} nch_bene_pta_coinsrnc_lblty_am, -${logic.hsql-only} nch_ip_ncvrd_chrg_amt, -${logic.hsql-only} nch_ip_tot_ddctn_amt, -${logic.hsql-only} nch_vrfd_ncvrd_stay_from_dt, -${logic.hsql-only} nch_vrfd_ncvrd_stay_thru_dt, -${logic.hsql-only} nch_qlfyd_stay_from_dt, -${logic.hsql-only} nch_qlfyd_stay_thru_dt, -${logic.hsql-only} nch_actv_or_cvrd_lvl_care_thru, -${logic.hsql-only} nch_bene_dschrg_dt, -${logic.hsql-only} nch_bene_mdcr_bnfts_exhtd_dt_i, -${logic.hsql-only} nch_ptnt_status_ind_cd, -${logic.hsql-only} clm_drg_cd, -${logic.hsql-only} clm_mco_pd_sw, -${logic.hsql-only} clm_mdcr_non_pmt_rsn_cd, -${logic.hsql-only} clm_src_ip_admsn_cd, -${logic.hsql-only} admtg_dgns_cd, -${logic.hsql-only} admtg_dgns_vrsn_cd, -${logic.hsql-only} at_physn_npi, -${logic.hsql-only} at_physn_upin, -${logic.hsql-only} op_physn_npi, -${logic.hsql-only} op_physn_upin, -${logic.hsql-only} org_npi_num, -${logic.hsql-only} ot_physn_npi, -${logic.hsql-only} ot_physn_upin, -${logic.hsql-only} prncpal_dgns_cd, -${logic.hsql-only} prncpal_dgns_vrsn_cd, -${logic.hsql-only} prvdr_num, -${logic.hsql-only} prvdr_state_cd, -${logic.hsql-only} ptnt_dschrg_stus_cd, -${logic.hsql-only} fi_clm_actn_cd, -${logic.hsql-only} fi_clm_proc_dt, -${logic.hsql-only} fi_doc_clm_cntl_num, -${logic.hsql-only} fi_num, -${logic.hsql-only} fi_orig_clm_cntl_num, -${logic.hsql-only} fst_dgns_e_cd, -${logic.hsql-only} fst_dgns_e_vrsn_cd, -${logic.hsql-only} icd_dgns_cd1, -${logic.hsql-only} icd_dgns_cd2, -${logic.hsql-only} icd_dgns_cd3, -${logic.hsql-only} icd_dgns_cd4, -${logic.hsql-only} icd_dgns_cd5, -${logic.hsql-only} icd_dgns_cd6, -${logic.hsql-only} icd_dgns_cd7, -${logic.hsql-only} icd_dgns_cd8, -${logic.hsql-only} icd_dgns_cd9, -${logic.hsql-only} icd_dgns_cd10, -${logic.hsql-only} icd_dgns_cd11, -${logic.hsql-only} icd_dgns_cd12, -${logic.hsql-only} icd_dgns_cd13, -${logic.hsql-only} icd_dgns_cd14, -${logic.hsql-only} icd_dgns_cd15, -${logic.hsql-only} icd_dgns_cd16, -${logic.hsql-only} icd_dgns_cd17, -${logic.hsql-only} icd_dgns_cd18, -${logic.hsql-only} icd_dgns_cd19, -${logic.hsql-only} icd_dgns_cd20, -${logic.hsql-only} icd_dgns_cd21, -${logic.hsql-only} icd_dgns_cd22, -${logic.hsql-only} icd_dgns_cd23, -${logic.hsql-only} icd_dgns_cd24, -${logic.hsql-only} icd_dgns_cd25, -${logic.hsql-only} icd_dgns_e_cd1, -${logic.hsql-only} icd_dgns_e_cd2, -${logic.hsql-only} icd_dgns_e_cd3, -${logic.hsql-only} icd_dgns_e_cd4, -${logic.hsql-only} icd_dgns_e_cd5, -${logic.hsql-only} icd_dgns_e_cd6, -${logic.hsql-only} icd_dgns_e_cd7, -${logic.hsql-only} icd_dgns_e_cd8, -${logic.hsql-only} icd_dgns_e_cd9, -${logic.hsql-only} icd_dgns_e_cd10, -${logic.hsql-only} icd_dgns_e_cd11, -${logic.hsql-only} icd_dgns_e_cd12, -${logic.hsql-only} icd_dgns_e_vrsn_cd1, -${logic.hsql-only} icd_dgns_e_vrsn_cd2, -${logic.hsql-only} icd_dgns_e_vrsn_cd3, -${logic.hsql-only} icd_dgns_e_vrsn_cd4, -${logic.hsql-only} icd_dgns_e_vrsn_cd5, -${logic.hsql-only} icd_dgns_e_vrsn_cd6, -${logic.hsql-only} icd_dgns_e_vrsn_cd7, -${logic.hsql-only} icd_dgns_e_vrsn_cd8, -${logic.hsql-only} icd_dgns_e_vrsn_cd9, -${logic.hsql-only} icd_dgns_e_vrsn_cd10, -${logic.hsql-only} icd_dgns_e_vrsn_cd11, -${logic.hsql-only} icd_dgns_e_vrsn_cd12, -${logic.hsql-only} icd_dgns_vrsn_cd1, -${logic.hsql-only} icd_dgns_vrsn_cd2, -${logic.hsql-only} icd_dgns_vrsn_cd3, -${logic.hsql-only} icd_dgns_vrsn_cd4, -${logic.hsql-only} icd_dgns_vrsn_cd5, -${logic.hsql-only} icd_dgns_vrsn_cd6, -${logic.hsql-only} icd_dgns_vrsn_cd7, -${logic.hsql-only} icd_dgns_vrsn_cd8, -${logic.hsql-only} icd_dgns_vrsn_cd9, -${logic.hsql-only} icd_dgns_vrsn_cd10, -${logic.hsql-only} icd_dgns_vrsn_cd11, -${logic.hsql-only} icd_dgns_vrsn_cd12, -${logic.hsql-only} icd_dgns_vrsn_cd13, -${logic.hsql-only} icd_dgns_vrsn_cd14, -${logic.hsql-only} icd_dgns_vrsn_cd15, -${logic.hsql-only} icd_dgns_vrsn_cd16, -${logic.hsql-only} icd_dgns_vrsn_cd17, -${logic.hsql-only} icd_dgns_vrsn_cd18, -${logic.hsql-only} icd_dgns_vrsn_cd19, -${logic.hsql-only} icd_dgns_vrsn_cd20, -${logic.hsql-only} icd_dgns_vrsn_cd21, -${logic.hsql-only} icd_dgns_vrsn_cd22, -${logic.hsql-only} icd_dgns_vrsn_cd23, -${logic.hsql-only} icd_dgns_vrsn_cd24, -${logic.hsql-only} icd_dgns_vrsn_cd25, -${logic.hsql-only} icd_prcdr_cd1, -${logic.hsql-only} icd_prcdr_cd2, -${logic.hsql-only} icd_prcdr_cd3, -${logic.hsql-only} icd_prcdr_cd4, -${logic.hsql-only} icd_prcdr_cd5, -${logic.hsql-only} icd_prcdr_cd6, -${logic.hsql-only} icd_prcdr_cd7, -${logic.hsql-only} icd_prcdr_cd8, -${logic.hsql-only} icd_prcdr_cd9, -${logic.hsql-only} icd_prcdr_cd10, -${logic.hsql-only} icd_prcdr_cd11, -${logic.hsql-only} icd_prcdr_cd12, -${logic.hsql-only} icd_prcdr_cd13, -${logic.hsql-only} icd_prcdr_cd14, -${logic.hsql-only} icd_prcdr_cd15, -${logic.hsql-only} icd_prcdr_cd16, -${logic.hsql-only} icd_prcdr_cd17, -${logic.hsql-only} icd_prcdr_cd18, -${logic.hsql-only} icd_prcdr_cd19, -${logic.hsql-only} icd_prcdr_cd20, -${logic.hsql-only} icd_prcdr_cd21, -${logic.hsql-only} icd_prcdr_cd22, -${logic.hsql-only} icd_prcdr_cd23, -${logic.hsql-only} icd_prcdr_cd24, -${logic.hsql-only} icd_prcdr_cd25, -${logic.hsql-only} icd_prcdr_vrsn_cd1, -${logic.hsql-only} icd_prcdr_vrsn_cd2, -${logic.hsql-only} icd_prcdr_vrsn_cd3, -${logic.hsql-only} icd_prcdr_vrsn_cd4, -${logic.hsql-only} icd_prcdr_vrsn_cd5, -${logic.hsql-only} icd_prcdr_vrsn_cd6, -${logic.hsql-only} icd_prcdr_vrsn_cd7, -${logic.hsql-only} icd_prcdr_vrsn_cd8, -${logic.hsql-only} icd_prcdr_vrsn_cd9, -${logic.hsql-only} icd_prcdr_vrsn_cd10, -${logic.hsql-only} icd_prcdr_vrsn_cd11, -${logic.hsql-only} icd_prcdr_vrsn_cd12, -${logic.hsql-only} icd_prcdr_vrsn_cd13, -${logic.hsql-only} icd_prcdr_vrsn_cd14, -${logic.hsql-only} icd_prcdr_vrsn_cd15, -${logic.hsql-only} icd_prcdr_vrsn_cd16, -${logic.hsql-only} icd_prcdr_vrsn_cd17, -${logic.hsql-only} icd_prcdr_vrsn_cd18, -${logic.hsql-only} icd_prcdr_vrsn_cd19, -${logic.hsql-only} icd_prcdr_vrsn_cd20, -${logic.hsql-only} icd_prcdr_vrsn_cd21, -${logic.hsql-only} icd_prcdr_vrsn_cd22, -${logic.hsql-only} icd_prcdr_vrsn_cd23, -${logic.hsql-only} icd_prcdr_vrsn_cd24, -${logic.hsql-only} icd_prcdr_vrsn_cd25, -${logic.hsql-only} prcdr_dt1, -${logic.hsql-only} prcdr_dt2, -${logic.hsql-only} prcdr_dt3, -${logic.hsql-only} prcdr_dt4, -${logic.hsql-only} prcdr_dt5, -${logic.hsql-only} prcdr_dt6, -${logic.hsql-only} prcdr_dt7, -${logic.hsql-only} prcdr_dt8, -${logic.hsql-only} prcdr_dt9, -${logic.hsql-only} prcdr_dt10, -${logic.hsql-only} prcdr_dt11, -${logic.hsql-only} prcdr_dt12, -${logic.hsql-only} prcdr_dt13, -${logic.hsql-only} prcdr_dt14, -${logic.hsql-only} prcdr_dt15, -${logic.hsql-only} prcdr_dt16, -${logic.hsql-only} prcdr_dt17, -${logic.hsql-only} prcdr_dt18, -${logic.hsql-only} prcdr_dt19, -${logic.hsql-only} prcdr_dt20, -${logic.hsql-only} prcdr_dt21, -${logic.hsql-only} prcdr_dt22, -${logic.hsql-only} prcdr_dt23, -${logic.hsql-only} prcdr_dt24, -${logic.hsql-only} prcdr_dt25 ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} create table public.snf_claims_new as -select -${logic.hsql-only} convert(clm_id, SQL_BIGINT), -${logic.hsql-only} convert(bene_id, SQL_BIGINT), -${logic.hsql-only} convert(clm_grp_id, SQL_BIGINT), -${logic.psql-only} cast(clm_id as bigint), -${logic.psql-only} cast(bene_id as bigint), -${logic.psql-only} cast(clm_grp_id as bigint), - last_updated, - clm_from_dt, - clm_thru_dt, - claim_query_code, - clm_admsn_dt, - clm_fac_type_cd, - clm_freq_cd, - clm_ip_admsn_type_cd, - clm_non_utlztn_days_cnt, - clm_utlztn_day_cnt, - bene_tot_coinsrnc_days_cnt, - clm_srvc_clsfctn_type_cd, - final_action, - clm_tot_chrg_amt, - clm_pmt_amt, - clm_pps_ind_cd, - clm_pps_cptl_dsprprtnt_shr_amt, - clm_pps_cptl_excptn_amt, - clm_pps_cptl_fsp_amt, - clm_pps_cptl_ime_amt, - clm_pps_cptl_outlier_amt, - clm_pps_old_cptl_hld_hrmls_amt, - nch_clm_type_cd, - nch_near_line_rec_ident_cd, - nch_wkly_proc_dt, - nch_blood_pnts_frnshd_qty, - nch_prmry_pyr_cd, - nch_prmry_pyr_clm_pd_amt, - nch_bene_blood_ddctbl_lblty_am, - nch_bene_ip_ddctbl_amt, - nch_bene_pta_coinsrnc_lblty_am, - nch_ip_ncvrd_chrg_amt, - nch_ip_tot_ddctn_amt, - nch_vrfd_ncvrd_stay_from_dt, - nch_vrfd_ncvrd_stay_thru_dt, - nch_qlfyd_stay_from_dt, - nch_qlfyd_stay_thru_dt, - nch_actv_or_cvrd_lvl_care_thru, - nch_bene_dschrg_dt, - nch_bene_mdcr_bnfts_exhtd_dt_i, - nch_ptnt_status_ind_cd, - clm_drg_cd, - clm_mco_pd_sw, - clm_mdcr_non_pmt_rsn_cd, - clm_src_ip_admsn_cd, - admtg_dgns_cd, - admtg_dgns_vrsn_cd, - at_physn_npi, - at_physn_upin, - op_physn_npi, - op_physn_upin, - org_npi_num, - ot_physn_npi, - ot_physn_upin, - prncpal_dgns_cd, - prncpal_dgns_vrsn_cd, - prvdr_num, - prvdr_state_cd, - ptnt_dschrg_stus_cd, - fi_clm_actn_cd, - fi_clm_proc_dt, - fi_doc_clm_cntl_num, - fi_num, - fi_orig_clm_cntl_num, - fst_dgns_e_cd, - fst_dgns_e_vrsn_cd, - icd_dgns_cd1, - icd_dgns_cd2, - icd_dgns_cd3, - icd_dgns_cd4, - icd_dgns_cd5, - icd_dgns_cd6, - icd_dgns_cd7, - icd_dgns_cd8, - icd_dgns_cd9, - icd_dgns_cd10, - icd_dgns_cd11, - icd_dgns_cd12, - icd_dgns_cd13, - icd_dgns_cd14, - icd_dgns_cd15, - icd_dgns_cd16, - icd_dgns_cd17, - icd_dgns_cd18, - icd_dgns_cd19, - icd_dgns_cd20, - icd_dgns_cd21, - icd_dgns_cd22, - icd_dgns_cd23, - icd_dgns_cd24, - icd_dgns_cd25, - icd_dgns_e_cd1, - icd_dgns_e_cd2, - icd_dgns_e_cd3, - icd_dgns_e_cd4, - icd_dgns_e_cd5, - icd_dgns_e_cd6, - icd_dgns_e_cd7, - icd_dgns_e_cd8, - icd_dgns_e_cd9, - icd_dgns_e_cd10, - icd_dgns_e_cd11, - icd_dgns_e_cd12, - icd_dgns_e_vrsn_cd1, - icd_dgns_e_vrsn_cd2, - icd_dgns_e_vrsn_cd3, - icd_dgns_e_vrsn_cd4, - icd_dgns_e_vrsn_cd5, - icd_dgns_e_vrsn_cd6, - icd_dgns_e_vrsn_cd7, - icd_dgns_e_vrsn_cd8, - icd_dgns_e_vrsn_cd9, - icd_dgns_e_vrsn_cd10, - icd_dgns_e_vrsn_cd11, - icd_dgns_e_vrsn_cd12, - icd_dgns_vrsn_cd1, - icd_dgns_vrsn_cd2, - icd_dgns_vrsn_cd3, - icd_dgns_vrsn_cd4, - icd_dgns_vrsn_cd5, - icd_dgns_vrsn_cd6, - icd_dgns_vrsn_cd7, - icd_dgns_vrsn_cd8, - icd_dgns_vrsn_cd9, - icd_dgns_vrsn_cd10, - icd_dgns_vrsn_cd11, - icd_dgns_vrsn_cd12, - icd_dgns_vrsn_cd13, - icd_dgns_vrsn_cd14, - icd_dgns_vrsn_cd15, - icd_dgns_vrsn_cd16, - icd_dgns_vrsn_cd17, - icd_dgns_vrsn_cd18, - icd_dgns_vrsn_cd19, - icd_dgns_vrsn_cd20, - icd_dgns_vrsn_cd21, - icd_dgns_vrsn_cd22, - icd_dgns_vrsn_cd23, - icd_dgns_vrsn_cd24, - icd_dgns_vrsn_cd25, - icd_prcdr_cd1, - icd_prcdr_cd2, - icd_prcdr_cd3, - icd_prcdr_cd4, - icd_prcdr_cd5, - icd_prcdr_cd6, - icd_prcdr_cd7, - icd_prcdr_cd8, - icd_prcdr_cd9, - icd_prcdr_cd10, - icd_prcdr_cd11, - icd_prcdr_cd12, - icd_prcdr_cd13, - icd_prcdr_cd14, - icd_prcdr_cd15, - icd_prcdr_cd16, - icd_prcdr_cd17, - icd_prcdr_cd18, - icd_prcdr_cd19, - icd_prcdr_cd20, - icd_prcdr_cd21, - icd_prcdr_cd22, - icd_prcdr_cd23, - icd_prcdr_cd24, - icd_prcdr_cd25, - icd_prcdr_vrsn_cd1, - icd_prcdr_vrsn_cd2, - icd_prcdr_vrsn_cd3, - icd_prcdr_vrsn_cd4, - icd_prcdr_vrsn_cd5, - icd_prcdr_vrsn_cd6, - icd_prcdr_vrsn_cd7, - icd_prcdr_vrsn_cd8, - icd_prcdr_vrsn_cd9, - icd_prcdr_vrsn_cd10, - icd_prcdr_vrsn_cd11, - icd_prcdr_vrsn_cd12, - icd_prcdr_vrsn_cd13, - icd_prcdr_vrsn_cd14, - icd_prcdr_vrsn_cd15, - icd_prcdr_vrsn_cd16, - icd_prcdr_vrsn_cd17, - icd_prcdr_vrsn_cd18, - icd_prcdr_vrsn_cd19, - icd_prcdr_vrsn_cd20, - icd_prcdr_vrsn_cd21, - icd_prcdr_vrsn_cd22, - icd_prcdr_vrsn_cd23, - icd_prcdr_vrsn_cd24, - icd_prcdr_vrsn_cd25, - prcdr_dt1, - prcdr_dt2, - prcdr_dt3, - prcdr_dt4, - prcdr_dt5, - prcdr_dt6, - prcdr_dt7, - prcdr_dt8, - prcdr_dt9, - prcdr_dt10, - prcdr_dt11, - prcdr_dt12, - prcdr_dt13, - prcdr_dt14, - prcdr_dt15, - prcdr_dt16, - prcdr_dt17, - prcdr_dt18, - prcdr_dt19, - prcdr_dt20, - prcdr_dt21, - prcdr_dt22, - prcdr_dt23, - prcdr_dt24, - prcdr_dt25 -from - public.snf_claims; - --- for PSQL need to define our not null constraints; for HSQL, --- we explicitly defined a table structure before migrating data. --- -${logic.psql-only} alter table public.snf_claims_new -${logic.psql-only} alter column clm_id SET NOT NULL, -${logic.psql-only} alter column bene_id SET NOT NULL, -${logic.psql-only} alter column clm_grp_id SET NOT NULL, -${logic.psql-only} alter column clm_from_dt SET NOT NULL, -${logic.psql-only} alter column clm_thru_dt SET NOT NULL, -${logic.psql-only} alter column claim_query_code SET NOT NULL, -${logic.psql-only} alter column clm_fac_type_cd SET NOT NULL, -${logic.psql-only} alter column clm_freq_cd SET NOT NULL, -${logic.psql-only} alter column clm_ip_admsn_type_cd SET NOT NULL, -${logic.psql-only} alter column clm_non_utlztn_days_cnt SET NOT NULL, -${logic.psql-only} alter column clm_utlztn_day_cnt SET NOT NULL, -${logic.psql-only} alter column bene_tot_coinsrnc_days_cnt SET NOT NULL, -${logic.psql-only} alter column clm_srvc_clsfctn_type_cd SET NOT NULL, -${logic.psql-only} alter column final_action SET NOT NULL, -${logic.psql-only} alter column clm_tot_chrg_amt SET NOT NULL, -${logic.psql-only} alter column clm_pmt_amt SET NOT NULL, -${logic.psql-only} alter column nch_clm_type_cd SET NOT NULL, -${logic.psql-only} alter column nch_near_line_rec_ident_cd SET NOT NULL, -${logic.psql-only} alter column nch_wkly_proc_dt SET NOT NULL, -${logic.psql-only} alter column nch_blood_pnts_frnshd_qty SET NOT NULL, -${logic.psql-only} alter column nch_prmry_pyr_clm_pd_amt SET NOT NULL, -${logic.psql-only} alter column nch_bene_blood_ddctbl_lblty_am SET NOT NULL, -${logic.psql-only} alter column nch_bene_ip_ddctbl_amt SET NOT NULL, -${logic.psql-only} alter column nch_bene_pta_coinsrnc_lblty_am SET NOT NULL, -${logic.psql-only} alter column nch_ip_ncvrd_chrg_amt SET NOT NULL, -${logic.psql-only} alter column nch_ip_tot_ddctn_amt SET NOT NULL, -${logic.psql-only} alter column prvdr_num SET NOT NULL, -${logic.psql-only} alter column prvdr_state_cd SET NOT NULL, -${logic.psql-only} alter column ptnt_dschrg_stus_cd SET NOT NULL; - --- migrate data via INSERT from current SNF_CLAIM_LINES table to SNF_CLAIM_LINES_NEW table --- -${logic.hsql-only} insert into public.snf_claim_lines_new ( -${logic.hsql-only} clm_id, -${logic.hsql-only} clm_line_num, -${logic.hsql-only} rev_cntr, -${logic.hsql-only} rev_cntr_unit_cnt, -${logic.hsql-only} rev_cntr_tot_chrg_amt, -${logic.hsql-only} rev_cntr_rate_amt, -${logic.hsql-only} rev_cntr_ncvrd_chrg_amt, -${logic.hsql-only} rev_cntr_ddctbl_coinsrnc_cd, -${logic.hsql-only} rev_cntr_ndc_qty_qlfr_cd, -${logic.hsql-only} rev_cntr_ndc_qty, -${logic.hsql-only} hcpcs_cd, -${logic.hsql-only} rndrng_physn_npi, -${logic.hsql-only} rndrng_physn_upin ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} create table public.snf_claim_lines_new as -select -${logic.hsql-only} convert(clm_id, SQL_BIGINT), -${logic.hsql-only} convert(clm_line_num, SQL_SMALLINT), -${logic.psql-only} cast(clm_id as bigint), -${logic.psql-only} cast(clm_line_num as smallint), - rev_cntr, - rev_cntr_unit_cnt, - rev_cntr_tot_chrg_amt, - rev_cntr_rate_amt, - rev_cntr_ncvrd_chrg_amt, - rev_cntr_ddctbl_coinsrnc_cd, - rev_cntr_ndc_qty_qlfr_cd, - rev_cntr_ndc_qty, - hcpcs_cd, - rndrng_physn_npi, - rndrng_physn_upin -from - public.snf_claim_lines; - --- for PSQL need to define our not null constraints; for HSQL, --- we explicitly defined a table structure before migrating data. --- -${logic.psql-only} alter table public.snf_claim_lines_new -${logic.psql-only} alter column clm_id SET NOT NULL, -${logic.psql-only} alter column clm_line_num SET NOT NULL, -${logic.psql-only} alter column rev_cntr SET NOT NULL, -${logic.psql-only} alter column rev_cntr_unit_cnt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_tot_chrg_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_rate_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_ncvrd_chrg_amt SET NOT NULL; - --- for PSQL need to define our primary key -${logic.psql-only} alter table public.snf_claims_new -${logic.psql-only} add CONSTRAINT snf_claims_new_pkey PRIMARY KEY (clm_id); - --- for PSQL need to define our primary key -${logic.psql-only} ALTER TABLE public.snf_claim_lines_new -${logic.psql-only} ADD CONSTRAINT snf_claim_lines_new_pkey PRIMARY KEY (clm_id, clm_line_num); - --- define foreign key constraints between claim lineitems and a parent claims table. -ALTER TABLE IF EXISTS public.snf_claim_lines_new - ADD CONSTRAINT snf_claim_lines_clm_id_to_snf_claims_new FOREIGN KEY (clm_id) - REFERENCES public.snf_claims_new (clm_id); - --- create an index of the BENE_ID in parent claims table -CREATE INDEX IF NOT EXISTS snf_claims_new_bene_id_idx - ON public.snf_claims_new (bene_id); - \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V67__new_schema_dme_claims.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V67__new_schema_dme_claims.sql deleted file mode 100644 index 0078227b15..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V67__new_schema_dme_claims.sql +++ /dev/null @@ -1,427 +0,0 @@ --- NEW_SCHEMA_DME_CLAIMS.SQL --- flyway migration for DME_CLAIMS and DME_CLAIM_LINES tables into --- a new schema structure that: --- 1) changes data type of CLM_ID, BENE_ID from varchar to BIGINT. --- 2) change data type of CLM_GROUP_ID from numeric to BIGINT --- 3) organizes parent claim table (DME_CLAIMS_NEW) such that common --- claims data columns are organized at top of table structure. --- --- The following db columns were redefined from NUMERIC to more --- appropriate data type(s): --- --- line_num - changed to smallint --- --- Once current table data is migrated to new table name/structure, a --- subsequent PR will be deployed that changes the ORM model(s) and --- operational code for DME Claims table(s). --- --- HSQL differs from PSQL (postgres) in that the table defintion --- must be explicitly declared prior to loading data into the --- target table. PSQL can derive the table structure based on --- the data input (i.e., column name, data type). Thus, for HSQL, --- we need to explicitly define the table structure prior to loading data. --- --- For HSQL, explicitly define/create a new DME_CLAIMS_NEW table in --- the current PUBLIC schema - -${logic.hsql-only} create table public.dme_claims_new ( -${logic.hsql-only} clm_id bigint not null, -${logic.hsql-only} bene_id bigint not null, -${logic.hsql-only} clm_grp_id bigint not null, -${logic.hsql-only} last_updated timestamp with time zone, -${logic.hsql-only} clm_from_dt date not null, -${logic.hsql-only} clm_thru_dt date not null, -${logic.hsql-only} clm_disp_cd varchar(2) not null, -${logic.hsql-only} final_action char(1) not null, -${logic.hsql-only} clm_pmt_amt numeric(12,2) not null, -${logic.hsql-only} carr_num varchar(5) not null, -${logic.hsql-only} carr_clm_cntl_num varchar(23), -${logic.hsql-only} carr_clm_prvdr_asgnmt_ind_sw char(1) not null, -${logic.hsql-only} carr_clm_entry_cd char(1) not null, -${logic.hsql-only} carr_clm_prmry_pyr_pd_amt numeric(12,2) not null, -${logic.hsql-only} carr_clm_cash_ddctbl_apld_amt numeric(12,2) not null, -${logic.hsql-only} carr_clm_pmt_dnl_cd varchar(2) not null, -${logic.hsql-only} carr_clm_hcpcs_yr_cd char(1), -${logic.hsql-only} nch_clm_type_cd varchar(2) not null, -${logic.hsql-only} nch_near_line_rec_ident_cd char(1) not null, -${logic.hsql-only} nch_wkly_proc_dt date not null, -${logic.hsql-only} nch_carr_clm_alowd_amt numeric(12,2) not null, -${logic.hsql-only} nch_carr_clm_sbmtd_chrg_amt numeric(12,2) not null, -${logic.hsql-only} nch_clm_bene_pmt_amt numeric(12,2) not null, -${logic.hsql-only} nch_clm_prvdr_pmt_amt numeric(12,2) not null, -${logic.hsql-only} prncpal_dgns_cd varchar(7), -${logic.hsql-only} prncpal_dgns_vrsn_cd char(1), -${logic.hsql-only} rfr_physn_npi varchar(12), -${logic.hsql-only} rfr_physn_upin varchar(12), -${logic.hsql-only} clm_clncl_tril_num varchar(8), -${logic.hsql-only} icd_dgns_cd1 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd1 char(1), -${logic.hsql-only} icd_dgns_cd2 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd2 char(1), -${logic.hsql-only} icd_dgns_cd3 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd3 char(1), -${logic.hsql-only} icd_dgns_cd4 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd4 char(1), -${logic.hsql-only} icd_dgns_cd5 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd5 char(1), -${logic.hsql-only} icd_dgns_cd6 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd6 char(1), -${logic.hsql-only} icd_dgns_cd7 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd7 char(1), -${logic.hsql-only} icd_dgns_cd8 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd8 char(1), -${logic.hsql-only} icd_dgns_cd9 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd9 char(1), -${logic.hsql-only} icd_dgns_cd10 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd10 char(1), -${logic.hsql-only} icd_dgns_cd11 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd11 char(1), -${logic.hsql-only} icd_dgns_cd12 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd12 char(1), -${logic.hsql-only} constraint public.dme_claims_new_pkey -${logic.hsql-only} primary key (clm_id) ); - --- create a new DME_CLAIM_LINES_NEW table in the current PUBLIC schema --- -${logic.hsql-only} CREATE TABLE IF NOT EXISTS public.dme_claim_lines_new ( -${logic.hsql-only} clm_id bigint not null, -${logic.hsql-only} line_num smallint not null, -${logic.hsql-only} line_1st_expns_dt date, -${logic.hsql-only} line_last_expns_dt date, -${logic.hsql-only} line_alowd_chrg_amt numeric(12,2) not null, -${logic.hsql-only} line_coinsrnc_amt numeric(12,2) not null, -${logic.hsql-only} line_sbmtd_chrg_amt numeric(12,2) not null, -${logic.hsql-only} line_bene_pmt_amt numeric(12,2) not null, -${logic.hsql-only} line_prvdr_pmt_amt numeric(12,2) not null, -${logic.hsql-only} line_bene_prmry_pyr_cd char(1), -${logic.hsql-only} line_bene_prmry_pyr_pd_amt numeric(12,2) not null, -${logic.hsql-only} line_bene_ptb_ddctbl_amt numeric(12,2) not null, -${logic.hsql-only} line_place_of_srvc_cd varchar(2) not null, -${logic.hsql-only} line_pmt_80_100_cd char(1), -${logic.hsql-only} line_srvc_cnt numeric not null, -${logic.hsql-only} line_cms_type_srvc_cd char(1) not null, -${logic.hsql-only} line_hct_hgb_type_cd varchar(2), -${logic.hsql-only} line_hct_hgb_rslt_num numeric(3,1) not null, -${logic.hsql-only} line_ndc_cd varchar(11), -${logic.hsql-only} line_nch_pmt_amt numeric(12,2) not null, -${logic.hsql-only} line_icd_dgns_cd varchar(7), -${logic.hsql-only} line_icd_dgns_vrsn_cd char(1), -${logic.hsql-only} line_dme_prchs_price_amt numeric(12,2) not null, -${logic.hsql-only} line_prmry_alowd_chrg_amt numeric(12,2) not null, -${logic.hsql-only} line_prcsg_ind_cd varchar(2), -${logic.hsql-only} line_service_deductible char(1), -${logic.hsql-only} betos_cd varchar(3), -${logic.hsql-only} hcpcs_cd varchar(5), -${logic.hsql-only} hcpcs_1st_mdfr_cd varchar(5), -${logic.hsql-only} hcpcs_2nd_mdfr_cd varchar(5), -${logic.hsql-only} hcpcs_3rd_mdfr_cd varchar(5), -${logic.hsql-only} hcpcs_4th_mdfr_cd varchar(5), -${logic.hsql-only} dmerc_line_mtus_cd char(1), -${logic.hsql-only} dmerc_line_mtus_cnt numeric(12,3) not null, -${logic.hsql-only} dmerc_line_prcng_state_cd varchar(2), -${logic.hsql-only} dmerc_line_scrn_svgs_amt numeric(12,2), -${logic.hsql-only} dmerc_line_supplr_type_cd char(1), -${logic.hsql-only} prtcptng_ind_cd char(1), -${logic.hsql-only} prvdr_npi varchar(12), -${logic.hsql-only} prvdr_num varchar(10), -${logic.hsql-only} prvdr_spclty varchar(3), -${logic.hsql-only} prvdr_state_cd varchar(2) not null, -${logic.hsql-only} tax_num varchar(10) not null, -${logic.hsql-only} constraint public.dme_claim_lines_new_pkey -${logic.hsql-only} primary key (clm_id, line_num) ); - -${logic.psql-only} SET max_parallel_workers = 24; -${logic.psql-only} SET max_parallel_workers_per_gather = 20; -${logic.psql-only} SET parallel_leader_participation = off; -${logic.psql-only} SET parallel_tuple_cost = 0; -${logic.psql-only} SET parallel_setup_cost = 0; - --- migrate data via INSERT from current DME_CLAIMS table to DME_CLAIMS_NEW table --- -${logic.hsql-only} insert into public.dme_claims_new ( -${logic.hsql-only} clm_id, -${logic.hsql-only} bene_id, -${logic.hsql-only} clm_grp_id, -${logic.hsql-only} last_updated, -${logic.hsql-only} clm_from_dt, -${logic.hsql-only} clm_thru_dt, -${logic.hsql-only} clm_disp_cd, -${logic.hsql-only} final_action, -${logic.hsql-only} clm_pmt_amt, -${logic.hsql-only} carr_num, -${logic.hsql-only} carr_clm_cntl_num, -${logic.hsql-only} carr_clm_prvdr_asgnmt_ind_sw, -${logic.hsql-only} carr_clm_entry_cd, -${logic.hsql-only} carr_clm_prmry_pyr_pd_amt, -${logic.hsql-only} carr_clm_cash_ddctbl_apld_amt, -${logic.hsql-only} carr_clm_pmt_dnl_cd, -${logic.hsql-only} carr_clm_hcpcs_yr_cd, -${logic.hsql-only} nch_clm_type_cd, -${logic.hsql-only} nch_near_line_rec_ident_cd, -${logic.hsql-only} nch_wkly_proc_dt, -${logic.hsql-only} nch_carr_clm_alowd_amt, -${logic.hsql-only} nch_carr_clm_sbmtd_chrg_amt, -${logic.hsql-only} nch_clm_bene_pmt_amt, -${logic.hsql-only} nch_clm_prvdr_pmt_amt, -${logic.hsql-only} prncpal_dgns_cd, -${logic.hsql-only} prncpal_dgns_vrsn_cd, -${logic.hsql-only} rfr_physn_npi, -${logic.hsql-only} rfr_physn_upin, -${logic.hsql-only} clm_clncl_tril_num, -${logic.hsql-only} icd_dgns_cd1, -${logic.hsql-only} icd_dgns_vrsn_cd1, -${logic.hsql-only} icd_dgns_cd2, -${logic.hsql-only} icd_dgns_vrsn_cd2, -${logic.hsql-only} icd_dgns_cd3, -${logic.hsql-only} icd_dgns_vrsn_cd3, -${logic.hsql-only} icd_dgns_cd4, -${logic.hsql-only} icd_dgns_vrsn_cd4, -${logic.hsql-only} icd_dgns_cd5, -${logic.hsql-only} icd_dgns_vrsn_cd5, -${logic.hsql-only} icd_dgns_cd6, -${logic.hsql-only} icd_dgns_vrsn_cd6, -${logic.hsql-only} icd_dgns_cd7, -${logic.hsql-only} icd_dgns_vrsn_cd7, -${logic.hsql-only} icd_dgns_cd8, -${logic.hsql-only} icd_dgns_vrsn_cd8, -${logic.hsql-only} icd_dgns_cd9, -${logic.hsql-only} icd_dgns_vrsn_cd9, -${logic.hsql-only} icd_dgns_cd10, -${logic.hsql-only} icd_dgns_vrsn_cd10, -${logic.hsql-only} icd_dgns_cd11, -${logic.hsql-only} icd_dgns_vrsn_cd11, -${logic.hsql-only} icd_dgns_cd12, -${logic.hsql-only} icd_dgns_vrsn_cd12 ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} create table public.dme_claims_new as -select -${logic.hsql-only} convert(clm_id, SQL_BIGINT), -${logic.hsql-only} convert(bene_id, SQL_BIGINT), -${logic.hsql-only} convert(clm_grp_id, SQL_BIGINT), -${logic.psql-only} cast(clm_id as bigint), -${logic.psql-only} cast(bene_id as bigint), -${logic.psql-only} cast(clm_grp_id as bigint), - last_updated, - clm_from_dt, - clm_thru_dt, - clm_disp_cd, - final_action, - clm_pmt_amt, - carr_num, - carr_clm_cntl_num, - carr_clm_prvdr_asgnmt_ind_sw, - carr_clm_entry_cd, - carr_clm_prmry_pyr_pd_amt, - carr_clm_cash_ddctbl_apld_amt, - carr_clm_pmt_dnl_cd, - carr_clm_hcpcs_yr_cd, - nch_clm_type_cd, - nch_near_line_rec_ident_cd, - nch_wkly_proc_dt, - nch_carr_clm_alowd_amt, - nch_carr_clm_sbmtd_chrg_amt, - nch_clm_bene_pmt_amt, - nch_clm_prvdr_pmt_amt, - prncpal_dgns_cd, - prncpal_dgns_vrsn_cd, - rfr_physn_npi, - rfr_physn_upin, - clm_clncl_tril_num, - icd_dgns_cd1, - icd_dgns_vrsn_cd1, - icd_dgns_cd2, - icd_dgns_vrsn_cd2, - icd_dgns_cd3, - icd_dgns_vrsn_cd3, - icd_dgns_cd4, - icd_dgns_vrsn_cd4, - icd_dgns_cd5, - icd_dgns_vrsn_cd5, - icd_dgns_cd6, - icd_dgns_vrsn_cd6, - icd_dgns_cd7, - icd_dgns_vrsn_cd7, - icd_dgns_cd8, - icd_dgns_vrsn_cd8, - icd_dgns_cd9, - icd_dgns_vrsn_cd9, - icd_dgns_cd10, - icd_dgns_vrsn_cd10, - icd_dgns_cd11, - icd_dgns_vrsn_cd11, - icd_dgns_cd12, - icd_dgns_vrsn_cd12 -from - public.dme_claims; - - --- for PSQL need to define our not null constraints; for HSQL, --- we explicitly defined a table structure before migrating data. --- -${logic.psql-only} alter table public.dme_claims_new -${logic.psql-only} alter column clm_id SET NOT NULL, -${logic.psql-only} alter column bene_id SET NOT NULL, -${logic.psql-only} alter column clm_grp_id SET NOT NULL, -${logic.psql-only} alter column clm_from_dt SET NOT NULL, -${logic.psql-only} alter column clm_thru_dt SET NOT NULL, -${logic.psql-only} alter column clm_disp_cd SET NOT NULL, -${logic.psql-only} alter column final_action SET NOT NULL, -${logic.psql-only} alter column clm_pmt_amt SET NOT NULL, -${logic.psql-only} alter column carr_num SET NOT NULL, -${logic.psql-only} alter column carr_clm_prvdr_asgnmt_ind_sw SET NOT NULL, -${logic.psql-only} alter column carr_clm_entry_cd SET NOT NULL, -${logic.psql-only} alter column carr_clm_prmry_pyr_pd_amt SET NOT NULL, -${logic.psql-only} alter column carr_clm_cash_ddctbl_apld_amt SET NOT NULL, -${logic.psql-only} alter column carr_clm_pmt_dnl_cd SET NOT NULL, -${logic.psql-only} alter column nch_clm_type_cd SET NOT NULL, -${logic.psql-only} alter column nch_near_line_rec_ident_cd SET NOT NULL, -${logic.psql-only} alter column nch_wkly_proc_dt SET NOT NULL, -${logic.psql-only} alter column nch_carr_clm_alowd_amt SET NOT NULL, -${logic.psql-only} alter column nch_carr_clm_sbmtd_chrg_amt SET NOT NULL, -${logic.psql-only} alter column nch_clm_bene_pmt_amt SET NOT NULL, -${logic.psql-only} alter column nch_clm_prvdr_pmt_amt SET NOT NULL; - --- migrate data via INSERT from current DME_CLAIM_LINES table to DME_CLAIM_LINES_NEW table --- - -${logic.hsql-only} insert into public.dme_claim_lines_new ( -${logic.hsql-only} clm_id, -${logic.hsql-only} line_num, -${logic.hsql-only} line_1st_expns_dt, -${logic.hsql-only} line_last_expns_dt, -${logic.hsql-only} line_alowd_chrg_amt, -${logic.hsql-only} line_coinsrnc_amt, -${logic.hsql-only} line_sbmtd_chrg_amt, -${logic.hsql-only} line_bene_pmt_amt, -${logic.hsql-only} line_prvdr_pmt_amt, -${logic.hsql-only} line_bene_prmry_pyr_cd, -${logic.hsql-only} line_bene_prmry_pyr_pd_amt, -${logic.hsql-only} line_bene_ptb_ddctbl_amt, -${logic.hsql-only} line_place_of_srvc_cd, -${logic.hsql-only} line_pmt_80_100_cd, -${logic.hsql-only} line_srvc_cnt, -${logic.hsql-only} line_cms_type_srvc_cd, -${logic.hsql-only} line_hct_hgb_type_cd, -${logic.hsql-only} line_hct_hgb_rslt_num, -${logic.hsql-only} line_ndc_cd, -${logic.hsql-only} line_nch_pmt_amt, -${logic.hsql-only} line_icd_dgns_cd, -${logic.hsql-only} line_icd_dgns_vrsn_cd, -${logic.hsql-only} line_dme_prchs_price_amt, -${logic.hsql-only} line_prmry_alowd_chrg_amt, -${logic.hsql-only} line_prcsg_ind_cd, -${logic.hsql-only} line_service_deductible, -${logic.hsql-only} betos_cd, -${logic.hsql-only} hcpcs_cd, -${logic.hsql-only} hcpcs_1st_mdfr_cd, -${logic.hsql-only} hcpcs_2nd_mdfr_cd, -${logic.hsql-only} hcpcs_3rd_mdfr_cd, -${logic.hsql-only} hcpcs_4th_mdfr_cd, -${logic.hsql-only} dmerc_line_mtus_cd, -${logic.hsql-only} dmerc_line_mtus_cnt, -${logic.hsql-only} dmerc_line_prcng_state_cd, -${logic.hsql-only} dmerc_line_scrn_svgs_amt, -${logic.hsql-only} dmerc_line_supplr_type_cd, -${logic.hsql-only} prtcptng_ind_cd, -${logic.hsql-only} prvdr_npi, -${logic.hsql-only} prvdr_num, -${logic.hsql-only} prvdr_spclty, -${logic.hsql-only} prvdr_state_cd, -${logic.hsql-only} tax_num ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} create table public.dme_claim_lines_new as -select -${logic.hsql-only} convert(clm_id, SQL_BIGINT), -${logic.hsql-only} convert(line_num, SQL_SMALLINT), -${logic.psql-only} cast(clm_id as bigint), -${logic.psql-only} cast(line_num as smallint), - line_1st_expns_dt, - line_last_expns_dt, - line_alowd_chrg_amt, - line_coinsrnc_amt, - line_sbmtd_chrg_amt, - line_bene_pmt_amt, - line_prvdr_pmt_amt, - line_bene_prmry_pyr_cd, - line_bene_prmry_pyr_pd_amt, - line_bene_ptb_ddctbl_amt, - line_place_of_srvc_cd, - line_pmt_80_100_cd, - line_srvc_cnt, - line_cms_type_srvc_cd, - line_hct_hgb_type_cd, - line_hct_hgb_rslt_num, - line_ndc_cd, - line_nch_pmt_amt, - line_icd_dgns_cd, - line_icd_dgns_vrsn_cd, - line_dme_prchs_price_amt, - line_prmry_alowd_chrg_amt, - line_prcsg_ind_cd, - line_service_deductible, - betos_cd, - hcpcs_cd, - hcpcs_1st_mdfr_cd, - hcpcs_2nd_mdfr_cd, - hcpcs_3rd_mdfr_cd, - hcpcs_4th_mdfr_cd, - dmerc_line_mtus_cd, - dmerc_line_mtus_cnt, - dmerc_line_prcng_state_cd, - dmerc_line_scrn_svgs_amt, - dmerc_line_supplr_type_cd, - prtcptng_ind_cd, - prvdr_npi, - prvdr_num, - prvdr_spclty, - prvdr_state_cd, - tax_num -from - public.dme_claim_lines; - --- for PSQL need to define our not null constraints; for HSQL, --- we explicitly defined a table structure before migrating data. --- -${logic.psql-only} alter table public.dme_claim_lines_new -${logic.psql-only} alter column clm_id SET NOT NULL, -${logic.psql-only} alter column line_num SET NOT NULL, -${logic.psql-only} alter column line_alowd_chrg_amt SET NOT NULL, -${logic.psql-only} alter column line_coinsrnc_amt SET NOT NULL, -${logic.psql-only} alter column line_sbmtd_chrg_amt SET NOT NULL, -${logic.psql-only} alter column line_bene_pmt_amt SET NOT NULL, -${logic.psql-only} alter column line_prvdr_pmt_amt SET NOT NULL, -${logic.psql-only} alter column line_bene_prmry_pyr_pd_amt SET NOT NULL, -${logic.psql-only} alter column line_bene_ptb_ddctbl_amt SET NOT NULL, -${logic.psql-only} alter column line_place_of_srvc_cd SET NOT NULL, -${logic.psql-only} alter column line_srvc_cnt SET NOT NULL, -${logic.psql-only} alter column line_cms_type_srvc_cd SET NOT NULL, -${logic.psql-only} alter column line_hct_hgb_rslt_num SET NOT NULL, -${logic.psql-only} alter column line_nch_pmt_amt SET NOT NULL, -${logic.psql-only} alter column line_dme_prchs_price_amt SET NOT NULL, -${logic.psql-only} alter column line_prmry_alowd_chrg_amt SET NOT NULL, -${logic.psql-only} alter column dmerc_line_mtus_cnt SET NOT NULL, -${logic.psql-only} alter column prvdr_state_cd SET NOT NULL, -${logic.psql-only} alter column tax_num SET NOT NULL; - --- for PSQL need to define our primary key -${logic.psql-only} alter table public.dme_claims_new -${logic.psql-only} add CONSTRAINT dme_claims_new_pkey PRIMARY KEY (clm_id); - --- for PSQL need to define our primary key -${logic.psql-only} ALTER TABLE public.dme_claim_lines_new -${logic.psql-only} ADD CONSTRAINT dme_claim_lines_new_pkey PRIMARY KEY (clm_id, line_num); - --- define foreign key constraints between claim lineitems and a parent claims table. -ALTER TABLE IF EXISTS public.dme_claim_lines_new - ADD CONSTRAINT dme_claim_lines_clm_id_to_dme_claims_new FOREIGN KEY (clm_id) - REFERENCES public.dme_claims_new (clm_id); - --- create an index of the BENE_ID in parent claims table -CREATE INDEX IF NOT EXISTS dme_claims_new_bene_id_idx - ON public.dme_claims_new (bene_id); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V68__rda_dead_letter_table.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V68__rda_dead_letter_table.sql deleted file mode 100644 index 8b7c4b3bab..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V68__rda_dead_letter_table.sql +++ /dev/null @@ -1,23 +0,0 @@ -/* - * This migration adds a message_errors table for tracking messages that resulted in - * an error during the message ingestion process via the gRPC pipeline job. This table will - * provide a means to store the instigating data so it can be reviewed and troubleshooted. - * - * Keeping messages that generated errors in a separate persistent table will prevent it - * from being lost due to subsequent claim updates that may clear the error, thus - * making it more challenging to resolve the original issue. - */ - -${logic.hsql-only} CREATE TYPE jsonb AS longvarchar; - -CREATE TABLE rda.message_errors ( - sequence_number bigint not null, - claim_type varchar(20) not null, - claim_id varchar(25) not null, - api_source varchar(24) not null, - created_date timestamp with time zone not null, - updated_date timestamp with time zone not null, - errors jsonb not null, - message jsonb not null, - primary key (sequence_number, claim_type) -); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V69__new_schema_hospice_claims_migration.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V69__new_schema_hospice_claims_migration.sql deleted file mode 100644 index abb191862e..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V69__new_schema_hospice_claims_migration.sql +++ /dev/null @@ -1,519 +0,0 @@ --- NEW_SCHEMA_HOSPICE_CLAIMS.SQL --- flyway migration for HOSPICE_CLAIMS and HOSPICE_CLAIM_LINES tables into --- a new schema structure that: --- 1) changes data type of CLM_ID, BENE_ID from varchar to BIGINT. --- 2) change data type of CLM_GROUP_ID from numeric to BIGINT --- 3) organizes parent claim table (HOSPICE_CLAIMS_NEW) such that common --- claims data columns are organized at top of table structure. --- --- The following db columns were redefined from NUMERIC to more --- appropriate data type(s): --- --- from: clm_line_num numeric : changed to smallint --- --- Current db data values for changed columns --- +-----------------------+--------+------+-------+ --- | db Column | Max | Min | Scale | --- +-----------------------+--------+------+-------+ --- | CLM_LINE_NUM | 450 | 1 | 0 | --- +-----------------------+--------+------+-------+ --- --- Once current table data is migrated to new table name/structure, a --- subsequent PR will be deployed that changes the ORM model(s) and --- operational code for Hospice Claims table(s). --- --- HSQL differs from PSQL (postgres) in that the table defintion --- must be explicitly declared prior to loading data into the --- target table. PSQL can derive the table structure based on --- the data input (i.e., column name, data type). Thus, for HSQL, --- we need to explicitly define the table structure prior to loading data. --- --- For HSQL, explicitly define/create a new HOSPICE_CLAIMS_NEW table in --- the current PUBLIC schema - -${logic.hsql-only} create table public.hospice_claims_new ( -${logic.hsql-only} clm_id bigint NOT NULL, -${logic.hsql-only} bene_id bigint NOT NULL, -${logic.hsql-only} clm_grp_id bigint NOT NULL, -${logic.hsql-only} last_updated timestamp with time zone, -${logic.hsql-only} clm_from_dt date NOT NULL, -${logic.hsql-only} clm_thru_dt date NOT NULL, -${logic.hsql-only} final_action char(1) NOT NULL, -${logic.hsql-only} clm_pmt_amt numeric(12,2) NOT NULL, -${logic.hsql-only} clm_fac_type_cd char(1) NOT NULL, -${logic.hsql-only} clm_freq_cd char(1) NOT NULL, -${logic.hsql-only} clm_srvc_clsfctn_type_cd char(1) NOT NULL, -${logic.hsql-only} clm_tot_chrg_amt numeric(12,2) NOT NULL, -${logic.hsql-only} clm_utlztn_day_cnt numeric NOT NULL, -${logic.hsql-only} clm_hospc_start_dt_id date, -${logic.hsql-only} clm_mdcr_non_pmt_rsn_cd varchar(2), -${logic.hsql-only} nch_clm_type_cd varchar(2) NOT NULL, -${logic.hsql-only} nch_near_line_rec_ident_cd char(1) NOT NULL, -${logic.hsql-only} nch_wkly_proc_dt date NOT NULL, -${logic.hsql-only} nch_prmry_pyr_clm_pd_amt numeric(12,2) NOT NULL, -${logic.hsql-only} nch_prmry_pyr_cd char(1), -${logic.hsql-only} nch_ptnt_status_ind_cd char(1), -${logic.hsql-only} nch_bene_dschrg_dt date, -${logic.hsql-only} prvdr_num varchar(9) NOT NULL, -${logic.hsql-only} prvdr_state_cd varchar(2) NOT NULL, -${logic.hsql-only} ptnt_dschrg_stus_cd varchar(2) NOT NULL, -${logic.hsql-only} fi_num varchar(5), -${logic.hsql-only} fi_orig_clm_cntl_num varchar(23), -${logic.hsql-only} fi_clm_proc_dt date, -${logic.hsql-only} fi_doc_clm_cntl_num varchar(23), -${logic.hsql-only} at_physn_npi varchar(10), -${logic.hsql-only} at_physn_upin varchar(9), -${logic.hsql-only} org_npi_num varchar(10), -${logic.hsql-only} prncpal_dgns_cd varchar(7), -${logic.hsql-only} prncpal_dgns_vrsn_cd char(1), -${logic.hsql-only} bene_hospc_prd_cnt numeric(2,0), -${logic.hsql-only} fst_dgns_e_cd varchar(7), -${logic.hsql-only} fst_dgns_e_vrsn_cd char(1), -${logic.hsql-only} icd_dgns_cd1 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd1 char(1), -${logic.hsql-only} icd_dgns_e_cd1 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd1 char(1), -${logic.hsql-only} icd_dgns_cd2 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd2 char(1), -${logic.hsql-only} icd_dgns_e_cd2 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd2 char(1), -${logic.hsql-only} icd_dgns_cd3 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd3 char(1), -${logic.hsql-only} icd_dgns_e_cd3 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd3 char(1), -${logic.hsql-only} icd_dgns_cd4 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd4 char(1), -${logic.hsql-only} icd_dgns_e_cd4 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd4 char(1), -${logic.hsql-only} icd_dgns_cd5 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd5 char(1), -${logic.hsql-only} icd_dgns_e_cd5 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd5 char(1), -${logic.hsql-only} icd_dgns_cd6 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd6 char(1), -${logic.hsql-only} icd_dgns_e_cd6 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd6 char(1), -${logic.hsql-only} icd_dgns_cd7 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd7 char(1), -${logic.hsql-only} icd_dgns_e_cd7 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd7 char(1), -${logic.hsql-only} icd_dgns_cd8 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd8 char(1), -${logic.hsql-only} icd_dgns_e_cd8 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd8 char(1), -${logic.hsql-only} icd_dgns_cd9 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd9 char(1), -${logic.hsql-only} icd_dgns_e_cd9 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd9 char(1), -${logic.hsql-only} icd_dgns_cd10 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd10 char(1), -${logic.hsql-only} icd_dgns_e_cd10 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd10 char(1), -${logic.hsql-only} icd_dgns_cd11 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd11 char(1), -${logic.hsql-only} icd_dgns_e_cd11 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd11 char(1), -${logic.hsql-only} icd_dgns_cd12 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd12 char(1), -${logic.hsql-only} icd_dgns_e_cd12 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd12 char(1), -${logic.hsql-only} icd_dgns_cd13 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd13 char(1), -${logic.hsql-only} icd_dgns_cd14 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd14 char(1), -${logic.hsql-only} icd_dgns_cd15 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd15 char(1), -${logic.hsql-only} icd_dgns_cd16 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd16 char(1), -${logic.hsql-only} icd_dgns_cd17 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd17 char(1), -${logic.hsql-only} icd_dgns_cd18 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd18 char(1), -${logic.hsql-only} icd_dgns_cd19 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd19 char(1), -${logic.hsql-only} icd_dgns_cd20 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd20 char(1), -${logic.hsql-only} icd_dgns_cd21 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd21 char(1), -${logic.hsql-only} icd_dgns_cd22 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd22 char(1), -${logic.hsql-only} icd_dgns_cd23 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd23 char(1), -${logic.hsql-only} icd_dgns_cd24 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd24 char(1), -${logic.hsql-only} icd_dgns_cd25 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd25 char(1), -${logic.hsql-only} constraint public.hospice_claims_new_pkey -${logic.hsql-only} primary key (clm_id) ); - --- create a new HOSPICE_CLAIM_LINES_NEW table in the current PUBLIC schema --- -${logic.hsql-only} create table public.hospice_claim_lines_new ( -${logic.hsql-only} clm_id bigint NOT NULL, -${logic.hsql-only} clm_line_num smallint not null, -${logic.hsql-only} rev_cntr varchar(4) not null, -${logic.hsql-only} rev_cntr_unit_cnt numeric not null, -${logic.hsql-only} rev_cntr_tot_chrg_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_rate_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_ncvrd_chrg_amt numeric(12,2), -${logic.hsql-only} rev_cntr_ddctbl_coinsrnc_cd character(1), -${logic.hsql-only} rev_cntr_bene_pmt_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_pmt_amt_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_prvdr_pmt_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_dt date, -${logic.hsql-only} rev_cntr_ndc_qty_qlfr_cd varchar(2), -${logic.hsql-only} rev_cntr_ndc_qty numeric, -${logic.hsql-only} hcpcs_cd varchar(5), -${logic.hsql-only} hcpcs_1st_mdfr_cd varchar(5), -${logic.hsql-only} hcpcs_2nd_mdfr_cd varchar(5), -${logic.hsql-only} rndrng_physn_npi varchar(12), -${logic.hsql-only} rndrng_physn_upin varchar(12), -${logic.hsql-only} constraint public.hospice_claim_lines_new_pkey -${logic.hsql-only} primary key (clm_id, clm_line_num) ); - -${logic.psql-only} SET max_parallel_workers = 24; -${logic.psql-only} SET max_parallel_workers_per_gather = 20; -${logic.psql-only} SET parallel_leader_participation = off; -${logic.psql-only} SET parallel_tuple_cost = 0; -${logic.psql-only} SET parallel_setup_cost = 0; - --- migrate data via INSERT from current HOSPICE_CLAIMS table to HOSPICE_CLAIMS_NEW table --- -${logic.hsql-only} insert into public.hospice_claims_new ( -${logic.hsql-only} clm_id, -${logic.hsql-only} bene_id, -${logic.hsql-only} clm_grp_id, -${logic.hsql-only} last_updated, -${logic.hsql-only} clm_from_dt, -${logic.hsql-only} clm_thru_dt, -${logic.hsql-only} final_action, -${logic.hsql-only} clm_pmt_amt, -${logic.hsql-only} clm_fac_type_cd, -${logic.hsql-only} clm_freq_cd, -${logic.hsql-only} clm_srvc_clsfctn_type_cd, -${logic.hsql-only} clm_tot_chrg_amt, -${logic.hsql-only} clm_utlztn_day_cnt, -${logic.hsql-only} clm_hospc_start_dt_id, -${logic.hsql-only} clm_mdcr_non_pmt_rsn_cd, -${logic.hsql-only} nch_clm_type_cd, -${logic.hsql-only} nch_near_line_rec_ident_cd, -${logic.hsql-only} nch_wkly_proc_dt, -${logic.hsql-only} nch_prmry_pyr_clm_pd_amt, -${logic.hsql-only} nch_prmry_pyr_cd, -${logic.hsql-only} nch_ptnt_status_ind_cd, -${logic.hsql-only} nch_bene_dschrg_dt, -${logic.hsql-only} prvdr_num, -${logic.hsql-only} prvdr_state_cd, -${logic.hsql-only} ptnt_dschrg_stus_cd, -${logic.hsql-only} fi_num, -${logic.hsql-only} fi_orig_clm_cntl_num, -${logic.hsql-only} fi_clm_proc_dt, -${logic.hsql-only} fi_doc_clm_cntl_num, -${logic.hsql-only} at_physn_npi, -${logic.hsql-only} at_physn_upin, -${logic.hsql-only} org_npi_num, -${logic.hsql-only} prncpal_dgns_cd, -${logic.hsql-only} prncpal_dgns_vrsn_cd, -${logic.hsql-only} bene_hospc_prd_cnt, -${logic.hsql-only} fst_dgns_e_cd, -${logic.hsql-only} fst_dgns_e_vrsn_cd, -${logic.hsql-only} icd_dgns_cd1, -${logic.hsql-only} icd_dgns_vrsn_cd1, -${logic.hsql-only} icd_dgns_e_cd1, -${logic.hsql-only} icd_dgns_e_vrsn_cd1, -${logic.hsql-only} icd_dgns_cd2, -${logic.hsql-only} icd_dgns_vrsn_cd2, -${logic.hsql-only} icd_dgns_e_cd2, -${logic.hsql-only} icd_dgns_e_vrsn_cd2, -${logic.hsql-only} icd_dgns_cd3, -${logic.hsql-only} icd_dgns_vrsn_cd3, -${logic.hsql-only} icd_dgns_e_cd3, -${logic.hsql-only} icd_dgns_e_vrsn_cd3, -${logic.hsql-only} icd_dgns_cd4, -${logic.hsql-only} icd_dgns_vrsn_cd4, -${logic.hsql-only} icd_dgns_e_cd4, -${logic.hsql-only} icd_dgns_e_vrsn_cd4, -${logic.hsql-only} icd_dgns_cd5, -${logic.hsql-only} icd_dgns_vrsn_cd5, -${logic.hsql-only} icd_dgns_e_cd5, -${logic.hsql-only} icd_dgns_e_vrsn_cd5, -${logic.hsql-only} icd_dgns_cd6, -${logic.hsql-only} icd_dgns_vrsn_cd6, -${logic.hsql-only} icd_dgns_e_cd6, -${logic.hsql-only} icd_dgns_e_vrsn_cd6, -${logic.hsql-only} icd_dgns_cd7, -${logic.hsql-only} icd_dgns_vrsn_cd7, -${logic.hsql-only} icd_dgns_e_cd7, -${logic.hsql-only} icd_dgns_e_vrsn_cd7, -${logic.hsql-only} icd_dgns_cd8, -${logic.hsql-only} icd_dgns_vrsn_cd8, -${logic.hsql-only} icd_dgns_e_cd8, -${logic.hsql-only} icd_dgns_e_vrsn_cd8, -${logic.hsql-only} icd_dgns_cd9, -${logic.hsql-only} icd_dgns_vrsn_cd9, -${logic.hsql-only} icd_dgns_e_cd9, -${logic.hsql-only} icd_dgns_e_vrsn_cd9, -${logic.hsql-only} icd_dgns_cd10, -${logic.hsql-only} icd_dgns_vrsn_cd10, -${logic.hsql-only} icd_dgns_e_cd10, -${logic.hsql-only} icd_dgns_e_vrsn_cd10, -${logic.hsql-only} icd_dgns_cd11, -${logic.hsql-only} icd_dgns_vrsn_cd11, -${logic.hsql-only} icd_dgns_e_cd11, -${logic.hsql-only} icd_dgns_e_vrsn_cd11, -${logic.hsql-only} icd_dgns_cd12, -${logic.hsql-only} icd_dgns_vrsn_cd12, -${logic.hsql-only} icd_dgns_e_cd12, -${logic.hsql-only} icd_dgns_e_vrsn_cd12, -${logic.hsql-only} icd_dgns_cd13, -${logic.hsql-only} icd_dgns_vrsn_cd13, -${logic.hsql-only} icd_dgns_cd14, -${logic.hsql-only} icd_dgns_vrsn_cd14, -${logic.hsql-only} icd_dgns_cd15, -${logic.hsql-only} icd_dgns_vrsn_cd15, -${logic.hsql-only} icd_dgns_cd16, -${logic.hsql-only} icd_dgns_vrsn_cd16, -${logic.hsql-only} icd_dgns_cd17, -${logic.hsql-only} icd_dgns_vrsn_cd17, -${logic.hsql-only} icd_dgns_cd18, -${logic.hsql-only} icd_dgns_vrsn_cd18, -${logic.hsql-only} icd_dgns_cd19, -${logic.hsql-only} icd_dgns_vrsn_cd19, -${logic.hsql-only} icd_dgns_cd20, -${logic.hsql-only} icd_dgns_vrsn_cd20, -${logic.hsql-only} icd_dgns_cd21, -${logic.hsql-only} icd_dgns_vrsn_cd21, -${logic.hsql-only} icd_dgns_cd22, -${logic.hsql-only} icd_dgns_vrsn_cd22, -${logic.hsql-only} icd_dgns_cd23, -${logic.hsql-only} icd_dgns_vrsn_cd23, -${logic.hsql-only} icd_dgns_cd24, -${logic.hsql-only} icd_dgns_vrsn_cd24, -${logic.hsql-only} icd_dgns_cd25, -${logic.hsql-only} icd_dgns_vrsn_cd25 ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} create table public.hospice_claims_new as -select -${logic.hsql-only} convert(clm_id, SQL_BIGINT), -${logic.hsql-only} convert(bene_id, SQL_BIGINT), -${logic.hsql-only} convert(clm_grp_id, SQL_BIGINT), -${logic.psql-only} cast(clm_id as bigint), -${logic.psql-only} cast(bene_id as bigint), -${logic.psql-only} cast(clm_grp_id as bigint), - last_updated, - clm_from_dt, - clm_thru_dt, - final_action, - clm_pmt_amt, - clm_fac_type_cd, - clm_freq_cd, - clm_srvc_clsfctn_type_cd, - clm_tot_chrg_amt, - clm_utlztn_day_cnt, - clm_hospc_start_dt_id, - clm_mdcr_non_pmt_rsn_cd, - nch_clm_type_cd, - nch_near_line_rec_ident_cd, - nch_wkly_proc_dt, - nch_prmry_pyr_clm_pd_amt, - nch_prmry_pyr_cd, - nch_ptnt_status_ind_cd, - nch_bene_dschrg_dt, - prvdr_num, - prvdr_state_cd, - ptnt_dschrg_stus_cd, - fi_num, - fi_orig_clm_cntl_num, - fi_clm_proc_dt, - fi_doc_clm_cntl_num, - at_physn_npi, - at_physn_upin, - org_npi_num, - prncpal_dgns_cd, - prncpal_dgns_vrsn_cd, - bene_hospc_prd_cnt, - fst_dgns_e_cd, - fst_dgns_e_vrsn_cd, - icd_dgns_cd1, - icd_dgns_vrsn_cd1, - icd_dgns_e_cd1, - icd_dgns_e_vrsn_cd1, - icd_dgns_cd2, - icd_dgns_vrsn_cd2, - icd_dgns_e_cd2, - icd_dgns_e_vrsn_cd2, - icd_dgns_cd3, - icd_dgns_vrsn_cd3, - icd_dgns_e_cd3, - icd_dgns_e_vrsn_cd3, - icd_dgns_cd4, - icd_dgns_vrsn_cd4, - icd_dgns_e_cd4, - icd_dgns_e_vrsn_cd4, - icd_dgns_cd5, - icd_dgns_vrsn_cd5, - icd_dgns_e_cd5, - icd_dgns_e_vrsn_cd5, - icd_dgns_cd6, - icd_dgns_vrsn_cd6, - icd_dgns_e_cd6, - icd_dgns_e_vrsn_cd6, - icd_dgns_cd7, - icd_dgns_vrsn_cd7, - icd_dgns_e_cd7, - icd_dgns_e_vrsn_cd7, - icd_dgns_cd8, - icd_dgns_vrsn_cd8, - icd_dgns_e_cd8, - icd_dgns_e_vrsn_cd8, - icd_dgns_cd9, - icd_dgns_vrsn_cd9, - icd_dgns_e_cd9, - icd_dgns_e_vrsn_cd9, - icd_dgns_cd10, - icd_dgns_vrsn_cd10, - icd_dgns_e_cd10, - icd_dgns_e_vrsn_cd10, - icd_dgns_cd11, - icd_dgns_vrsn_cd11, - icd_dgns_e_cd11, - icd_dgns_e_vrsn_cd11, - icd_dgns_cd12, - icd_dgns_vrsn_cd12, - icd_dgns_e_cd12, - icd_dgns_e_vrsn_cd12, - icd_dgns_cd13, - icd_dgns_vrsn_cd13, - icd_dgns_cd14, - icd_dgns_vrsn_cd14, - icd_dgns_cd15, - icd_dgns_vrsn_cd15, - icd_dgns_cd16, - icd_dgns_vrsn_cd16, - icd_dgns_cd17, - icd_dgns_vrsn_cd17, - icd_dgns_cd18, - icd_dgns_vrsn_cd18, - icd_dgns_cd19, - icd_dgns_vrsn_cd19, - icd_dgns_cd20, - icd_dgns_vrsn_cd20, - icd_dgns_cd21, - icd_dgns_vrsn_cd21, - icd_dgns_cd22, - icd_dgns_vrsn_cd22, - icd_dgns_cd23, - icd_dgns_vrsn_cd23, - icd_dgns_cd24, - icd_dgns_vrsn_cd24, - icd_dgns_cd25, - icd_dgns_vrsn_cd25 -from - public.hospice_claims; - --- migrate data via INSERT from current HOSPICE_CLAIM_LINES table to HOSPICE_CLAIM_LINES_NEW table --- -${logic.hsql-only} insert into public.hospice_claim_lines_new ( -${logic.hsql-only} clm_id, -${logic.hsql-only} clm_line_num, -${logic.hsql-only} rev_cntr, -${logic.hsql-only} rev_cntr_unit_cnt, -${logic.hsql-only} rev_cntr_tot_chrg_amt, -${logic.hsql-only} rev_cntr_rate_amt, -${logic.hsql-only} rev_cntr_ncvrd_chrg_amt, -${logic.hsql-only} rev_cntr_ddctbl_coinsrnc_cd, -${logic.hsql-only} rev_cntr_bene_pmt_amt, -${logic.hsql-only} rev_cntr_pmt_amt_amt, -${logic.hsql-only} rev_cntr_prvdr_pmt_amt, -${logic.hsql-only} rev_cntr_dt, -${logic.hsql-only} rev_cntr_ndc_qty_qlfr_cd, -${logic.hsql-only} rev_cntr_ndc_qty, -${logic.hsql-only} hcpcs_cd, -${logic.hsql-only} hcpcs_1st_mdfr_cd, -${logic.hsql-only} hcpcs_2nd_mdfr_cd, -${logic.hsql-only} rndrng_physn_npi, -${logic.hsql-only} rndrng_physn_upin ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} create table public.hospice_claim_lines_new as -select -${logic.hsql-only} convert(clm_id, SQL_BIGINT), -${logic.hsql-only} convert(clm_line_num, SQL_SMALLINT), -${logic.psql-only} cast(clm_id as bigint), -${logic.psql-only} cast(clm_line_num as smallint), - rev_cntr, - rev_cntr_unit_cnt, - rev_cntr_tot_chrg_amt, - rev_cntr_rate_amt, - rev_cntr_ncvrd_chrg_amt, - rev_cntr_ddctbl_coinsrnc_cd, - rev_cntr_bene_pmt_amt, - rev_cntr_pmt_amt_amt, - rev_cntr_prvdr_pmt_amt, - rev_cntr_dt, - rev_cntr_ndc_qty_qlfr_cd, - rev_cntr_ndc_qty, - hcpcs_cd, - hcpcs_1st_mdfr_cd, - hcpcs_2nd_mdfr_cd, - rndrng_physn_npi, - rndrng_physn_upin -from - public.hospice_claim_lines; - --- for PSQL need to define our not null constraints; for HSQL, --- we explicitly defined a table structure before migrating data. --- -${logic.psql-only} alter table public.hospice_claims_new -${logic.psql-only} alter column clm_id SET NOT NULL, -${logic.psql-only} alter column bene_id SET NOT NULL, -${logic.psql-only} alter column clm_grp_id SET NOT NULL, -${logic.psql-only} alter column clm_from_dt SET NOT NULL, -${logic.psql-only} alter column clm_thru_dt SET NOT NULL, -${logic.psql-only} alter column final_action SET NOT NULL, -${logic.psql-only} alter column clm_pmt_amt SET NOT NULL, -${logic.psql-only} alter column clm_fac_type_cd SET NOT NULL, -${logic.psql-only} alter column clm_freq_cd SET NOT NULL, -${logic.psql-only} alter column clm_srvc_clsfctn_type_cd SET NOT NULL, -${logic.psql-only} alter column clm_tot_chrg_amt SET NOT NULL, -${logic.psql-only} alter column clm_utlztn_day_cnt SET NOT NULL, -${logic.psql-only} alter column nch_clm_type_cd SET NOT NULL, -${logic.psql-only} alter column nch_near_line_rec_ident_cd SET NOT NULL, -${logic.psql-only} alter column nch_wkly_proc_dt SET NOT NULL, -${logic.psql-only} alter column nch_prmry_pyr_clm_pd_amt SET NOT NULL, -${logic.psql-only} alter column prvdr_num SET NOT NULL, -${logic.psql-only} alter column prvdr_state_cd SET NOT NULL, -${logic.psql-only} alter column ptnt_dschrg_stus_cd SET NOT NULL; - -${logic.psql-only} alter table public.hospice_claim_lines_new -${logic.psql-only} alter column clm_id SET NOT NULL, -${logic.psql-only} alter column clm_line_num SET NOT NULL, -${logic.psql-only} alter column rev_cntr SET NOT NULL, -${logic.psql-only} alter column rev_cntr_unit_cnt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_tot_chrg_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_rate_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_bene_pmt_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_pmt_amt_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_prvdr_pmt_amt SET NOT NULL; - --- for PSQL need to define our primary key -${logic.psql-only} alter table public.hospice_claims_new -${logic.psql-only} add CONSTRAINT hospice_claims_new_pkey PRIMARY KEY (clm_id); - --- for PSQL need to define our primary key -${logic.psql-only} ALTER TABLE public.hospice_claim_lines_new -${logic.psql-only} ADD CONSTRAINT hospice_claim_lines_new_pkey PRIMARY KEY (clm_id, clm_line_num); - --- define foreign key constraints between claim lineitems and a parent claims table. -ALTER TABLE IF EXISTS public.hospice_claim_lines_new - ADD CONSTRAINT hospice_claim_lines_clm_id_to_hospice_claims_new FOREIGN KEY (clm_id) - REFERENCES public.hospice_claims_new (clm_id); - --- create an index of the BENE_ID in parent claims table -CREATE INDEX IF NOT EXISTS hospice_claims_new_bene_id_idx - ON public.hospice_claims_new (bene_id); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V6__Add_final_action_status_columns.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V6__Add_final_action_status_columns.sql deleted file mode 100644 index 185f4a6425..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V6__Add_final_action_status_columns.sql +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Alters the claim tables to add `finalAction` columns to each, backfilling - * existing rows with the value 'F'. - * - * See: - * * http://issues.hhsdevcloud.us/browse/CBBD-301 - * * http://issues.hhsdevcloud.us/browse/CBBD-361 - */ - -alter table "CarrierClaims" add column "finalAction" char(1); -update "CarrierClaims" set "finalAction" = 'F'; -alter table "CarrierClaims" alter column "finalAction" set not null; - -alter table "DMEClaims" add column "finalAction" char(1); -update "DMEClaims" set "finalAction" = 'F'; -alter table "DMEClaims" alter column "finalAction" set not null; - -alter table "HHAClaims" add column "finalAction" char(1); -update "HHAClaims" set "finalAction" = 'F'; -alter table "HHAClaims" alter column "finalAction" set not null; - -alter table "HospiceClaims" add column "finalAction" char(1); -update "HospiceClaims" set "finalAction" = 'F'; -alter table "HospiceClaims" alter column "finalAction" set not null; - -alter table "InpatientClaims" add column "finalAction" char(1); -update "InpatientClaims" set "finalAction" = 'F'; -alter table "InpatientClaims" alter column "finalAction" set not null; - -alter table "OutpatientClaims" add column "finalAction" char(1); -update "OutpatientClaims" set "finalAction" = 'F'; -alter table "OutpatientClaims" alter column "finalAction" set not null; - -alter table "PartDEvents" add column "finalAction" char(1); -update "PartDEvents" set "finalAction" = 'F'; -alter table "PartDEvents" alter column "finalAction" set not null; - -alter table "SNFClaims" add column "finalAction" char(1); -update "SNFClaims" set "finalAction" = 'F'; -alter table "SNFClaims" alter column "finalAction" set not null; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V70__new_schema_hha_claims.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V70__new_schema_hha_claims.sql deleted file mode 100644 index 40271d3572..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V70__new_schema_hha_claims.sql +++ /dev/null @@ -1,525 +0,0 @@ --- NEW_SCHEMA_HHA_CLAIMS.SQL --- flyway migration for HHA_CLAIMS and HHA_CLAIM_LINES tables into --- a new schema structure that: --- 1) changes data type of CLM_ID, BENE_ID from varchar to BIGINT. --- 2) change data type of CLM_GROUP_ID from numeric to BIGINT --- 3) organizes parent claim table (HHA_CLAIMS_NEW) such that common --- claims data columns are organized at top of table structure. --- --- The following db columns were redefined from NUMERIC to more --- appropriate data type(s): --- --- from: clm_line_num numeric : changed to smallint --- --- Current db data values for changed columns --- +-----------------------+--------+------+-------+ --- | db Column | Max | Min | Scale | --- +-----------------------+--------+------+-------+ --- | CLM_LINE_NUM | 446 | 1 | 0 | --- +-----------------------+--------+------+-------+ --- --- Once current table data is migrated to new table name/structure, a --- subsequent PR will be deployed that changes the ORM model(s) and --- operational code for HHA Claims table(s). --- --- HSQL differs from PSQL (postgres) in that the table defintion --- must be explicitly declared prior to loading data into the --- target table. PSQL can derive the table structure based on --- the data input (i.e., column name, data type). Thus, for HSQL, --- we need to explicitly define the table structure prior to loading data. --- --- For HSQL, explicitly define/create a new HHA_CLAIMS_NEW table in --- the current PUBLIC schema - -${logic.hsql-only} create table public.hha_claims_new ( -${logic.hsql-only} clm_id bigint not null, -${logic.hsql-only} bene_id bigint not null, -${logic.hsql-only} clm_grp_id bigint not null, -${logic.hsql-only} last_updated timestamp with time zone, -${logic.hsql-only} clm_from_dt date not null, -${logic.hsql-only} clm_thru_dt date not null, -${logic.hsql-only} final_action char(1) not null, -${logic.hsql-only} clm_pmt_amt numeric(12,2) not null, -${logic.hsql-only} clm_fac_type_cd char(1) not null, -${logic.hsql-only} clm_freq_cd char(1) not null, -${logic.hsql-only} clm_srvc_clsfctn_type_cd char(1) not null, -${logic.hsql-only} clm_tot_chrg_amt numeric(12,2) not null, -${logic.hsql-only} clm_hha_tot_visit_cnt numeric not null, -${logic.hsql-only} clm_admsn_dt date, -${logic.hsql-only} clm_pps_ind_cd char(1) not null, -${logic.hsql-only} clm_hha_lupa_ind_cd char(1), -${logic.hsql-only} clm_hha_rfrl_cd char(1), -${logic.hsql-only} clm_mdcr_non_pmt_rsn_cd varchar(2), -${logic.hsql-only} nch_clm_type_cd varchar(2) not null, -${logic.hsql-only} nch_near_line_rec_ident_cd char(1) not null, -${logic.hsql-only} nch_wkly_proc_dt date not null, -${logic.hsql-only} nch_prmry_pyr_cd char(1), -${logic.hsql-only} nch_prmry_pyr_clm_pd_amt numeric(12,2) not null, -${logic.hsql-only} prvdr_num varchar(9) not null, -${logic.hsql-only} prvdr_state_cd varchar(2) not null, -${logic.hsql-only} fi_num varchar(5), -${logic.hsql-only} fi_orig_clm_cntl_num varchar(23), -${logic.hsql-only} fi_clm_proc_dt date, -${logic.hsql-only} fi_doc_clm_cntl_num varchar(23), -${logic.hsql-only} at_physn_npi varchar(10), -${logic.hsql-only} org_npi_num varchar(10), -${logic.hsql-only} at_physn_upin varchar(9), -${logic.hsql-only} prncpal_dgns_cd varchar(7), -${logic.hsql-only} prncpal_dgns_vrsn_cd char(1), -${logic.hsql-only} ptnt_dschrg_stus_cd varchar(2) not null, -${logic.hsql-only} fst_dgns_e_cd varchar(7), -${logic.hsql-only} fst_dgns_e_vrsn_cd char(1), -${logic.hsql-only} icd_dgns_cd1 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd1 char(1), -${logic.hsql-only} icd_dgns_e_cd1 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd1 char(1), -${logic.hsql-only} icd_dgns_cd2 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd2 char(1), -${logic.hsql-only} icd_dgns_e_cd2 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd2 char(1), -${logic.hsql-only} icd_dgns_cd3 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd3 char(1), -${logic.hsql-only} icd_dgns_e_cd3 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd3 char(1), -${logic.hsql-only} icd_dgns_cd4 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd4 char(1), -${logic.hsql-only} icd_dgns_e_cd4 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd4 char(1), -${logic.hsql-only} icd_dgns_cd5 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd5 char(1), -${logic.hsql-only} icd_dgns_e_cd5 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd5 char(1), -${logic.hsql-only} icd_dgns_cd6 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd6 char(1), -${logic.hsql-only} icd_dgns_e_cd6 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd6 char(1), -${logic.hsql-only} icd_dgns_cd7 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd7 char(1), -${logic.hsql-only} icd_dgns_e_cd7 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd7 char(1), -${logic.hsql-only} icd_dgns_cd8 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd8 char(1), -${logic.hsql-only} icd_dgns_e_cd8 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd8 char(1), -${logic.hsql-only} icd_dgns_cd9 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd9 char(1), -${logic.hsql-only} icd_dgns_e_cd9 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd9 char(1), -${logic.hsql-only} icd_dgns_cd10 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd10 char(1), -${logic.hsql-only} icd_dgns_e_cd10 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd10 char(1), -${logic.hsql-only} icd_dgns_cd11 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd11 char(1), -${logic.hsql-only} icd_dgns_e_cd11 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd11 char(1), -${logic.hsql-only} icd_dgns_cd12 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd12 char(1), -${logic.hsql-only} icd_dgns_e_cd12 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd12 char(1), -${logic.hsql-only} icd_dgns_cd13 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd13 char(1), -${logic.hsql-only} icd_dgns_cd14 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd14 char(1), -${logic.hsql-only} icd_dgns_cd15 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd15 char(1), -${logic.hsql-only} icd_dgns_cd16 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd16 char(1), -${logic.hsql-only} icd_dgns_cd17 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd17 char(1), -${logic.hsql-only} icd_dgns_cd18 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd18 char(1), -${logic.hsql-only} icd_dgns_cd19 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd19 char(1), -${logic.hsql-only} icd_dgns_cd20 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd20 char(1), -${logic.hsql-only} icd_dgns_cd21 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd21 char(1), -${logic.hsql-only} icd_dgns_cd22 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd22 char(1), -${logic.hsql-only} icd_dgns_cd23 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd23 char(1), -${logic.hsql-only} icd_dgns_cd24 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd24 char(1), -${logic.hsql-only} icd_dgns_cd25 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd25 char(1), -${logic.hsql-only} constraint hha_claims_new_pkey -${logic.hsql-only} primary key (clm_id) ); - --- create a new HHA_CLAIM_LINES_NEW table in the current PUBLIC schema --- -${logic.hsql-only} create table public.hha_claim_lines_new ( -${logic.hsql-only} clm_id bigint NOT NULL, -${logic.hsql-only} clm_line_num smallint not null, -${logic.hsql-only} rev_cntr varchar(4) not null, -${logic.hsql-only} rev_cntr_unit_cnt numeric not null, -${logic.hsql-only} rev_cntr_tot_chrg_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_rate_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_ncvrd_chrg_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_ddctbl_coinsrnc_cd character(1), -${logic.hsql-only} rev_cntr_pmt_amt_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_dt date, -${logic.hsql-only} rev_cntr_ndc_qty_qlfr_cd varchar(2), -${logic.hsql-only} rev_cntr_ndc_qty numeric, -${logic.hsql-only} rev_cntr_1st_ansi_cd varchar(5), -${logic.hsql-only} rev_cntr_apc_hipps_cd varchar(5), -${logic.hsql-only} rev_cntr_pmt_mthd_ind_cd varchar(2), -${logic.hsql-only} rev_cntr_stus_ind_cd varchar(2), -${logic.hsql-only} hcpcs_cd varchar(5), -${logic.hsql-only} hcpcs_1st_mdfr_cd varchar(5), -${logic.hsql-only} hcpcs_2nd_mdfr_cd varchar(5), -${logic.hsql-only} rndrng_physn_npi varchar(12), -${logic.hsql-only} rndrng_physn_upin varchar(12), -${logic.hsql-only} constraint hha_claim_lines_new_pkey -${logic.hsql-only} primary key (clm_id, clm_line_num) ); - -${logic.psql-only} SET max_parallel_workers = 24; -${logic.psql-only} SET max_parallel_workers_per_gather = 20; -${logic.psql-only} SET parallel_leader_participation = off; -${logic.psql-only} SET parallel_tuple_cost = 0; -${logic.psql-only} SET parallel_setup_cost = 0; - --- migrate data via INSERT from current HHA_CLAIMS table to HHA_CLAIMS_NEW table --- -${logic.hsql-only} insert into public.hha_claims_new ( -${logic.hsql-only} clm_id, -${logic.hsql-only} bene_id, -${logic.hsql-only} clm_grp_id, -${logic.hsql-only} last_updated, -${logic.hsql-only} clm_from_dt, -${logic.hsql-only} clm_thru_dt, -${logic.hsql-only} final_action, -${logic.hsql-only} clm_pmt_amt, -${logic.hsql-only} clm_fac_type_cd, -${logic.hsql-only} clm_freq_cd, -${logic.hsql-only} clm_srvc_clsfctn_type_cd, -${logic.hsql-only} clm_tot_chrg_amt, -${logic.hsql-only} clm_hha_tot_visit_cnt, -${logic.hsql-only} clm_admsn_dt, -${logic.hsql-only} clm_pps_ind_cd, -${logic.hsql-only} clm_hha_lupa_ind_cd, -${logic.hsql-only} clm_hha_rfrl_cd, -${logic.hsql-only} clm_mdcr_non_pmt_rsn_cd, -${logic.hsql-only} nch_clm_type_cd, -${logic.hsql-only} nch_near_line_rec_ident_cd, -${logic.hsql-only} nch_wkly_proc_dt, -${logic.hsql-only} nch_prmry_pyr_cd, -${logic.hsql-only} nch_prmry_pyr_clm_pd_amt, -${logic.hsql-only} prvdr_num, -${logic.hsql-only} prvdr_state_cd, -${logic.hsql-only} fi_num, -${logic.hsql-only} fi_orig_clm_cntl_num, -${logic.hsql-only} fi_clm_proc_dt, -${logic.hsql-only} fi_doc_clm_cntl_num, -${logic.hsql-only} at_physn_npi, -${logic.hsql-only} org_npi_num, -${logic.hsql-only} at_physn_upin, -${logic.hsql-only} prncpal_dgns_cd, -${logic.hsql-only} prncpal_dgns_vrsn_cd, -${logic.hsql-only} ptnt_dschrg_stus_cd, -${logic.hsql-only} fst_dgns_e_cd, -${logic.hsql-only} fst_dgns_e_vrsn_cd, -${logic.hsql-only} icd_dgns_cd1, -${logic.hsql-only} icd_dgns_vrsn_cd1, -${logic.hsql-only} icd_dgns_e_cd1, -${logic.hsql-only} icd_dgns_e_vrsn_cd1, -${logic.hsql-only} icd_dgns_cd2, -${logic.hsql-only} icd_dgns_vrsn_cd2, -${logic.hsql-only} icd_dgns_e_cd2, -${logic.hsql-only} icd_dgns_e_vrsn_cd2, -${logic.hsql-only} icd_dgns_cd3, -${logic.hsql-only} icd_dgns_vrsn_cd3, -${logic.hsql-only} icd_dgns_e_cd3, -${logic.hsql-only} icd_dgns_e_vrsn_cd3, -${logic.hsql-only} icd_dgns_cd4, -${logic.hsql-only} icd_dgns_vrsn_cd4, -${logic.hsql-only} icd_dgns_e_cd4, -${logic.hsql-only} icd_dgns_e_vrsn_cd4, -${logic.hsql-only} icd_dgns_cd5, -${logic.hsql-only} icd_dgns_vrsn_cd5, -${logic.hsql-only} icd_dgns_e_cd5, -${logic.hsql-only} icd_dgns_e_vrsn_cd5, -${logic.hsql-only} icd_dgns_cd6, -${logic.hsql-only} icd_dgns_vrsn_cd6, -${logic.hsql-only} icd_dgns_e_cd6, -${logic.hsql-only} icd_dgns_e_vrsn_cd6, -${logic.hsql-only} icd_dgns_cd7, -${logic.hsql-only} icd_dgns_vrsn_cd7, -${logic.hsql-only} icd_dgns_e_cd7, -${logic.hsql-only} icd_dgns_e_vrsn_cd7, -${logic.hsql-only} icd_dgns_cd8, -${logic.hsql-only} icd_dgns_vrsn_cd8, -${logic.hsql-only} icd_dgns_e_cd8, -${logic.hsql-only} icd_dgns_e_vrsn_cd8, -${logic.hsql-only} icd_dgns_cd9, -${logic.hsql-only} icd_dgns_vrsn_cd9, -${logic.hsql-only} icd_dgns_e_cd9, -${logic.hsql-only} icd_dgns_e_vrsn_cd9, -${logic.hsql-only} icd_dgns_cd10, -${logic.hsql-only} icd_dgns_vrsn_cd10, -${logic.hsql-only} icd_dgns_e_cd10, -${logic.hsql-only} icd_dgns_e_vrsn_cd10, -${logic.hsql-only} icd_dgns_cd11, -${logic.hsql-only} icd_dgns_vrsn_cd11, -${logic.hsql-only} icd_dgns_e_cd11, -${logic.hsql-only} icd_dgns_e_vrsn_cd11, -${logic.hsql-only} icd_dgns_cd12, -${logic.hsql-only} icd_dgns_vrsn_cd12 , -${logic.hsql-only} icd_dgns_e_cd12, -${logic.hsql-only} icd_dgns_e_vrsn_cd12, -${logic.hsql-only} icd_dgns_cd13, -${logic.hsql-only} icd_dgns_vrsn_cd13 , -${logic.hsql-only} icd_dgns_cd14, -${logic.hsql-only} icd_dgns_vrsn_cd14 , -${logic.hsql-only} icd_dgns_cd15, -${logic.hsql-only} icd_dgns_vrsn_cd15, -${logic.hsql-only} icd_dgns_cd16, -${logic.hsql-only} icd_dgns_vrsn_cd16, -${logic.hsql-only} icd_dgns_cd17, -${logic.hsql-only} icd_dgns_vrsn_cd17, -${logic.hsql-only} icd_dgns_cd18, -${logic.hsql-only} icd_dgns_vrsn_cd18, -${logic.hsql-only} icd_dgns_cd19, -${logic.hsql-only} icd_dgns_vrsn_cd19, -${logic.hsql-only} icd_dgns_cd20, -${logic.hsql-only} icd_dgns_vrsn_cd20, -${logic.hsql-only} icd_dgns_cd21, -${logic.hsql-only} icd_dgns_vrsn_cd21, -${logic.hsql-only} icd_dgns_cd22, -${logic.hsql-only} icd_dgns_vrsn_cd22, -${logic.hsql-only} icd_dgns_cd23, -${logic.hsql-only} icd_dgns_vrsn_cd23, -${logic.hsql-only} icd_dgns_cd24, -${logic.hsql-only} icd_dgns_vrsn_cd24, -${logic.hsql-only} icd_dgns_cd25, -${logic.hsql-only} icd_dgns_vrsn_cd25 ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} create table public.hha_claims_new as -select -${logic.hsql-only} convert(clm_id, SQL_BIGINT), -${logic.hsql-only} convert(bene_id, SQL_BIGINT), -${logic.hsql-only} convert(clm_grp_id, SQL_BIGINT), -${logic.psql-only} cast(clm_id as bigint), -${logic.psql-only} cast(bene_id as bigint), -${logic.psql-only} cast(clm_grp_id as bigint), - last_updated, - clm_from_dt, - clm_thru_dt, - final_action, - clm_pmt_amt, - clm_fac_type_cd, - clm_freq_cd, - clm_srvc_clsfctn_type_cd, - clm_tot_chrg_amt, - clm_hha_tot_visit_cnt, - clm_admsn_dt, - clm_pps_ind_cd, - clm_hha_lupa_ind_cd, - clm_hha_rfrl_cd, - clm_mdcr_non_pmt_rsn_cd, - nch_clm_type_cd, - nch_near_line_rec_ident_cd, - nch_wkly_proc_dt, - nch_prmry_pyr_cd, - nch_prmry_pyr_clm_pd_amt, - prvdr_num, - prvdr_state_cd, - fi_num, - fi_orig_clm_cntl_num, - fi_clm_proc_dt, - fi_doc_clm_cntl_num, - at_physn_npi, - org_npi_num, - at_physn_upin, - prncpal_dgns_cd, - prncpal_dgns_vrsn_cd, - ptnt_dschrg_stus_cd, - fst_dgns_e_cd, - fst_dgns_e_vrsn_cd, - icd_dgns_cd1, - icd_dgns_vrsn_cd1, - icd_dgns_e_cd1, - icd_dgns_e_vrsn_cd1, - icd_dgns_cd2, - icd_dgns_vrsn_cd2, - icd_dgns_e_cd2, - icd_dgns_e_vrsn_cd2, - icd_dgns_cd3, - icd_dgns_vrsn_cd3, - icd_dgns_e_cd3, - icd_dgns_e_vrsn_cd3, - icd_dgns_cd4, - icd_dgns_vrsn_cd4, - icd_dgns_e_cd4, - icd_dgns_e_vrsn_cd4, - icd_dgns_cd5, - icd_dgns_vrsn_cd5, - icd_dgns_e_cd5, - icd_dgns_e_vrsn_cd5, - icd_dgns_cd6, - icd_dgns_vrsn_cd6, - icd_dgns_e_cd6, - icd_dgns_e_vrsn_cd6, - icd_dgns_cd7, - icd_dgns_vrsn_cd7, - icd_dgns_e_cd7, - icd_dgns_e_vrsn_cd7, - icd_dgns_cd8, - icd_dgns_vrsn_cd8, - icd_dgns_e_cd8, - icd_dgns_e_vrsn_cd8, - icd_dgns_cd9, - icd_dgns_vrsn_cd9, - icd_dgns_e_cd9, - icd_dgns_e_vrsn_cd9, - icd_dgns_cd10, - icd_dgns_vrsn_cd10, - icd_dgns_e_cd10, - icd_dgns_e_vrsn_cd10, - icd_dgns_cd11, - icd_dgns_vrsn_cd11, - icd_dgns_e_cd11, - icd_dgns_e_vrsn_cd11, - icd_dgns_cd12, - icd_dgns_vrsn_cd12 , - icd_dgns_e_cd12, - icd_dgns_e_vrsn_cd12, - icd_dgns_cd13, - icd_dgns_vrsn_cd13 , - icd_dgns_cd14, - icd_dgns_vrsn_cd14 , - icd_dgns_cd15, - icd_dgns_vrsn_cd15, - icd_dgns_cd16, - icd_dgns_vrsn_cd16, - icd_dgns_cd17, - icd_dgns_vrsn_cd17, - icd_dgns_cd18, - icd_dgns_vrsn_cd18, - icd_dgns_cd19, - icd_dgns_vrsn_cd19, - icd_dgns_cd20, - icd_dgns_vrsn_cd20, - icd_dgns_cd21, - icd_dgns_vrsn_cd21, - icd_dgns_cd22, - icd_dgns_vrsn_cd22, - icd_dgns_cd23, - icd_dgns_vrsn_cd23, - icd_dgns_cd24, - icd_dgns_vrsn_cd24, - icd_dgns_cd25, - icd_dgns_vrsn_cd25 -from - public.hha_claims; - --- migrate data via INSERT from current HHA_CLAIM_LINES table to HHA_CLAIM_LINES_NEW table --- -${logic.hsql-only} insert into public.hha_claim_lines_new ( -${logic.hsql-only} clm_id, -${logic.hsql-only} clm_line_num, -${logic.hsql-only} rev_cntr, -${logic.hsql-only} rev_cntr_unit_cnt, -${logic.hsql-only} rev_cntr_tot_chrg_amt, -${logic.hsql-only} rev_cntr_rate_amt, -${logic.hsql-only} rev_cntr_ncvrd_chrg_amt, -${logic.hsql-only} rev_cntr_ddctbl_coinsrnc_cd, -${logic.hsql-only} rev_cntr_pmt_amt_amt, -${logic.hsql-only} rev_cntr_dt, -${logic.hsql-only} rev_cntr_ndc_qty_qlfr_cd, -${logic.hsql-only} rev_cntr_ndc_qty, -${logic.hsql-only} rev_cntr_1st_ansi_cd, -${logic.hsql-only} rev_cntr_apc_hipps_cd, -${logic.hsql-only} rev_cntr_pmt_mthd_ind_cd, -${logic.hsql-only} rev_cntr_stus_ind_cd, -${logic.hsql-only} hcpcs_cd, -${logic.hsql-only} hcpcs_1st_mdfr_cd, -${logic.hsql-only} hcpcs_2nd_mdfr_cd, -${logic.hsql-only} rndrng_physn_npi, -${logic.hsql-only} rndrng_physn_upin ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} create table public.hha_claim_lines_new as -select -${logic.hsql-only} convert(clm_id, sql_bigint), -${logic.hsql-only} convert(clm_line_num, sql_smallint), -${logic.psql-only} cast(clm_id as bigint), -${logic.psql-only} cast(clm_line_num as smallint), - rev_cntr, - rev_cntr_unit_cnt, - rev_cntr_tot_chrg_amt, - rev_cntr_rate_amt, - rev_cntr_ncvrd_chrg_amt, - rev_cntr_ddctbl_coinsrnc_cd, - rev_cntr_pmt_amt_amt, - rev_cntr_dt, - rev_cntr_ndc_qty_qlfr_cd, - rev_cntr_ndc_qty, - rev_cntr_1st_ansi_cd, - rev_cntr_apc_hipps_cd, - rev_cntr_pmt_mthd_ind_cd, - rev_cntr_stus_ind_cd, - hcpcs_cd, - hcpcs_1st_mdfr_cd, - hcpcs_2nd_mdfr_cd, - rndrng_physn_npi, - rndrng_physn_upin -from - public.hha_claim_lines; - --- for PSQL need to define our not null constraints; for HSQL, --- we explicitly defined a table structure before migrating data. --- -${logic.psql-only} alter table public.hha_claims_new -${logic.psql-only} alter column clm_id SET NOT NULL, -${logic.psql-only} alter column bene_id SET NOT NULL, -${logic.psql-only} alter column clm_grp_id SET NOT NULL, -${logic.psql-only} alter column clm_from_dt SET NOT NULL, -${logic.psql-only} alter column clm_thru_dt SET NOT NULL, -${logic.psql-only} alter column final_action SET NOT NULL, -${logic.psql-only} alter column clm_pmt_amt SET NOT NULL, -${logic.psql-only} alter column clm_fac_type_cd SET NOT NULL, -${logic.psql-only} alter column clm_freq_cd SET NOT NULL, -${logic.psql-only} alter column clm_srvc_clsfctn_type_cd SET NOT NULL, -${logic.psql-only} alter column clm_tot_chrg_amt SET NOT NULL, -${logic.psql-only} alter column clm_hha_tot_visit_cnt SET NOT NULL, -${logic.psql-only} alter column clm_pps_ind_cd SET NOT NULL, -${logic.psql-only} alter column nch_clm_type_cd SET NOT NULL, -${logic.psql-only} alter column nch_near_line_rec_ident_cd SET NOT NULL, -${logic.psql-only} alter column nch_wkly_proc_dt SET NOT NULL, -${logic.psql-only} alter column nch_prmry_pyr_clm_pd_amt SET NOT NULL, -${logic.psql-only} alter column prvdr_num SET NOT NULL, -${logic.psql-only} alter column prvdr_state_cd SET NOT NULL, -${logic.psql-only} alter column ptnt_dschrg_stus_cd SET NOT NULL; - -${logic.psql-only} alter table public.hha_claim_lines_new -${logic.psql-only} alter column clm_id SET NOT NULL, -${logic.psql-only} alter column clm_line_num SET NOT NULL, -${logic.psql-only} alter column rev_cntr SET NOT NULL, -${logic.psql-only} alter column rev_cntr_unit_cnt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_tot_chrg_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_rate_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_ncvrd_chrg_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_pmt_amt_amt SET NOT NULL; - --- for PSQL need to define our primary key -${logic.psql-only} alter table public.hha_claims_new -${logic.psql-only} add CONSTRAINT hha_claims_new_pkey PRIMARY KEY (clm_id); - --- for PSQL need to define our primary key -${logic.psql-only} ALTER TABLE public.hha_claim_lines_new -${logic.psql-only} ADD CONSTRAINT hha_claim_lines_new_pkey PRIMARY KEY (clm_id, clm_line_num); - --- define foreign key constraints between claim lineitems and a parent claims table. -ALTER TABLE IF EXISTS public.hha_claim_lines_new - ADD CONSTRAINT hha_claim_lines_clm_id_to_hha_claims_new FOREIGN KEY (clm_id) - REFERENCES public.hha_claims_new (clm_id); - --- create an index of the BENE_ID in parent claims table -CREATE INDEX IF NOT EXISTS hha_claims_new_bene_id_idx - ON public.hha_claims_new (bene_id); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V71__new_schema_carrier_claims.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V71__new_schema_carrier_claims.sql deleted file mode 100644 index 3dea04dc74..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V71__new_schema_carrier_claims.sql +++ /dev/null @@ -1,440 +0,0 @@ --- NEW_SCHEMA_CARRIER_CLAIMS.SQL --- flyway migration for CARRIER_CLAIMS and CARRIER_CLAIM_LINES tables into --- a new schema structure that: --- 1) changes data type of CLM_ID, BENE_ID from varchar to BIGINT. --- 2) change data type of CLM_GROUP_ID from numeric to BIGINT --- 3) organizes parent claim table (CARRIER_CLAIMS) such that common --- claims data columns are organized at top of table structure. --- --- The following db columns were redefined from NUMERIC to more --- appropriate data type(s): --- --- line_num - changed to smallint --- --- Once current table data is migrated to new table name/structure, a --- subsequent PR will be deployed that changes the ORM model(s) and --- operational code for Carrier Claims table(s). --- --- HSQL differs from PSQL (postgres) in that the table defintion --- must be explicitly declared prior to loading data into the --- target table. PSQL can derive the table structure based on --- the data input (i.e., column name, data type). Thus, for HSQL, --- we need to explicitly define the table structure prior to loading data. --- --- For HSQL, explicitly define/create a new CARRIER_CLAIMS_NEW table in --- the current PUBLIC schema - -${logic.hsql-only} create table public.carrier_claims_new ( -${logic.hsql-only} clm_id bigint NOT NULL, -${logic.hsql-only} bene_id bigint NOT NULL, -${logic.hsql-only} clm_grp_id bigint NOT NULL, -${logic.hsql-only} last_updated timestamp with time zone, -${logic.hsql-only} clm_from_dt date NOT NULL, -${logic.hsql-only} clm_thru_dt date NOT NULL, -${logic.hsql-only} clm_disp_cd varchar(2) NOT NULL, -${logic.hsql-only} final_action char(1) NOT NULL, -${logic.hsql-only} clm_pmt_amt numeric(12,2) NOT NULL, -${logic.hsql-only} carr_num varchar(5) NOT NULL, -${logic.hsql-only} carr_clm_rfrng_pin_num varchar(14) NOT NULL, -${logic.hsql-only} carr_clm_cntl_num varchar(23), -${logic.hsql-only} carr_clm_entry_cd char(1) NOT NULL, -${logic.hsql-only} carr_clm_prmry_pyr_pd_amt numeric(12,2) NOT NULL, -${logic.hsql-only} carr_clm_cash_ddctbl_apld_amt numeric(12,2) NOT NULL, -${logic.hsql-only} carr_clm_pmt_dnl_cd varchar(2) NOT NULL, -${logic.hsql-only} carr_clm_hcpcs_yr_cd char(1), -${logic.hsql-only} carr_clm_prvdr_asgnmt_ind_sw char(1), -${logic.hsql-only} nch_clm_type_cd varchar(2) NOT NULL, -${logic.hsql-only} nch_near_line_rec_ident_cd char(1) NOT NULL, -${logic.hsql-only} nch_wkly_proc_dt date NOT NULL, -${logic.hsql-only} nch_carr_clm_sbmtd_chrg_amt numeric(12,2) NOT NULL, -${logic.hsql-only} nch_carr_clm_alowd_amt numeric(12,2) NOT NULL, -${logic.hsql-only} nch_clm_bene_pmt_amt numeric(12,2) NOT NULL, -${logic.hsql-only} nch_clm_prvdr_pmt_amt numeric(12,2) NOT NULL, -${logic.hsql-only} clm_clncl_tril_num varchar(8), -${logic.hsql-only} prncpal_dgns_cd varchar(7), -${logic.hsql-only} prncpal_dgns_vrsn_cd char(1), -${logic.hsql-only} rfr_physn_npi varchar(12), -${logic.hsql-only} rfr_physn_upin varchar(12), -${logic.hsql-only} icd_dgns_cd1 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd1 char(1), -${logic.hsql-only} icd_dgns_cd2 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd2 char(1), -${logic.hsql-only} icd_dgns_cd3 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd3 char(1), -${logic.hsql-only} icd_dgns_cd4 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd4 char(1), -${logic.hsql-only} icd_dgns_cd5 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd5 char(1), -${logic.hsql-only} icd_dgns_cd6 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd6 char(1), -${logic.hsql-only} icd_dgns_cd7 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd7 char(1), -${logic.hsql-only} icd_dgns_cd8 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd8 char(1), -${logic.hsql-only} icd_dgns_cd9 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd9 char(1), -${logic.hsql-only} icd_dgns_cd10 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd10 char(1), -${logic.hsql-only} icd_dgns_cd11 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd11 char(1), -${logic.hsql-only} icd_dgns_cd12 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd12 char(1), -${logic.hsql-only} constraint public.carrier_claims_new_pkey -${logic.hsql-only} primary key (clm_id) ); - --- create a new CARRIER_CLAIM_LINES_NEW table in the current PUBLIC schema --- -${logic.hsql-only} CREATE TABLE IF NOT EXISTS public.carrier_claim_lines_new ( -${logic.hsql-only} clm_id bigint not null, -${logic.hsql-only} line_num smallint not null, -${logic.hsql-only} carr_line_rdcd_pmt_phys_astn_c char(1) not null, -${logic.hsql-only} carr_line_prvdr_type_cd char(1) not null, -${logic.hsql-only} carr_line_prcng_lclty_cd varchar(2) not null, -${logic.hsql-only} carr_line_mtus_cnt numeric not null, -${logic.hsql-only} carr_line_ansthsa_unit_cnt numeric not null, -${logic.hsql-only} carr_prfrng_pin_num varchar(15) not null, -${logic.hsql-only} carr_line_mtus_cd char(1), -${logic.hsql-only} carr_line_rx_num varchar(30), -${logic.hsql-only} carr_line_clia_lab_num varchar(10), -${logic.hsql-only} line_1st_expns_dt date, -${logic.hsql-only} line_last_expns_dt date, -${logic.hsql-only} line_alowd_chrg_amt numeric(12,2) not null, -${logic.hsql-only} line_coinsrnc_amt numeric(12,2) not null, -${logic.hsql-only} line_sbmtd_chrg_amt numeric(12,2) not null, -${logic.hsql-only} line_bene_pmt_amt numeric(12,2) not null, -${logic.hsql-only} line_prvdr_pmt_amt numeric(12,2) not null, -${logic.hsql-only} line_bene_prmry_pyr_cd char(1), -${logic.hsql-only} line_bene_prmry_pyr_pd_amt numeric(12,2) not null, -${logic.hsql-only} line_bene_ptb_ddctbl_amt numeric(12,2) not null, -${logic.hsql-only} line_place_of_srvc_cd varchar(2) not null, -${logic.hsql-only} line_pmt_80_100_cd char(1), -${logic.hsql-only} line_srvc_cnt numeric(8,1) not null, -${logic.hsql-only} line_cms_type_srvc_cd char(1) not null, -${logic.hsql-only} line_hct_hgb_type_cd varchar(2), -${logic.hsql-only} line_hct_hgb_rslt_num numeric(4,1) not null, -${logic.hsql-only} line_ndc_cd varchar(11), -${logic.hsql-only} line_nch_pmt_amt numeric(12,2) not null, -${logic.hsql-only} line_icd_dgns_cd varchar(7), -${logic.hsql-only} line_icd_dgns_vrsn_cd char(1), -${logic.hsql-only} line_prcsg_ind_cd varchar(2), -${logic.hsql-only} line_service_deductible char(1), -${logic.hsql-only} betos_cd varchar(3), -${logic.hsql-only} hcpcs_cd varchar(5), -${logic.hsql-only} hcpcs_1st_mdfr_cd varchar(5), -${logic.hsql-only} hcpcs_2nd_mdfr_cd varchar(5), -${logic.hsql-only} hpsa_scrcty_ind_cd char(1), -${logic.hsql-only} prvdr_state_cd varchar(2), -${logic.hsql-only} prvdr_spclty varchar(3), -${logic.hsql-only} prvdr_zip varchar(9), -${logic.hsql-only} tax_num varchar(10) not null, -${logic.hsql-only} org_npi_num varchar(10), -${logic.hsql-only} prf_physn_npi varchar(12), -${logic.hsql-only} prf_physn_upin varchar(12), -${logic.hsql-only} prtcptng_ind_cd char(1), -${logic.hsql-only} CONSTRAINT carrier_claim_lines_new_pkey -${logic.hsql-only} PRIMARY KEY (clm_id, line_num) ); - -${logic.psql-only} SET max_parallel_workers = 24; -${logic.psql-only} SET max_parallel_workers_per_gather = 20; -${logic.psql-only} SET parallel_leader_participation = off; -${logic.psql-only} SET parallel_tuple_cost = 0; -${logic.psql-only} SET parallel_setup_cost = 0; - --- migrate data via INSERT from current CARRIER_CLAIMS table to carrier_CLAIMS_NEW table --- -${logic.hsql-only} insert into public.carrier_claims_new ( -${logic.hsql-only} clm_id, -${logic.hsql-only} bene_id, -${logic.hsql-only} clm_grp_id, -${logic.hsql-only} last_updated, -${logic.hsql-only} clm_from_dt, -${logic.hsql-only} clm_thru_dt, -${logic.hsql-only} clm_disp_cd, -${logic.hsql-only} final_action, -${logic.hsql-only} clm_pmt_amt, -${logic.hsql-only} carr_num, -${logic.hsql-only} carr_clm_rfrng_pin_num, -${logic.hsql-only} carr_clm_cntl_num, -${logic.hsql-only} carr_clm_entry_cd, -${logic.hsql-only} carr_clm_prmry_pyr_pd_amt, -${logic.hsql-only} carr_clm_cash_ddctbl_apld_amt, -${logic.hsql-only} carr_clm_pmt_dnl_cd, -${logic.hsql-only} carr_clm_hcpcs_yr_cd, -${logic.hsql-only} carr_clm_prvdr_asgnmt_ind_sw, -${logic.hsql-only} nch_clm_type_cd, -${logic.hsql-only} nch_near_line_rec_ident_cd, -${logic.hsql-only} nch_wkly_proc_dt, -${logic.hsql-only} nch_carr_clm_sbmtd_chrg_amt, -${logic.hsql-only} nch_carr_clm_alowd_amt, -${logic.hsql-only} nch_clm_bene_pmt_amt, -${logic.hsql-only} nch_clm_prvdr_pmt_amt, -${logic.hsql-only} clm_clncl_tril_num, -${logic.hsql-only} prncpal_dgns_cd, -${logic.hsql-only} prncpal_dgns_vrsn_cd, -${logic.hsql-only} rfr_physn_npi, -${logic.hsql-only} rfr_physn_upin, -${logic.hsql-only} icd_dgns_cd1, -${logic.hsql-only} icd_dgns_vrsn_cd1, -${logic.hsql-only} icd_dgns_cd2, -${logic.hsql-only} icd_dgns_vrsn_cd2, -${logic.hsql-only} icd_dgns_cd3, -${logic.hsql-only} icd_dgns_vrsn_cd3, -${logic.hsql-only} icd_dgns_cd4, -${logic.hsql-only} icd_dgns_vrsn_cd4, -${logic.hsql-only} icd_dgns_cd5, -${logic.hsql-only} icd_dgns_vrsn_cd5, -${logic.hsql-only} icd_dgns_cd6, -${logic.hsql-only} icd_dgns_vrsn_cd6, -${logic.hsql-only} icd_dgns_cd7, -${logic.hsql-only} icd_dgns_vrsn_cd7, -${logic.hsql-only} icd_dgns_cd8, -${logic.hsql-only} icd_dgns_vrsn_cd8, -${logic.hsql-only} icd_dgns_cd9, -${logic.hsql-only} icd_dgns_vrsn_cd9, -${logic.hsql-only} icd_dgns_cd10, -${logic.hsql-only} icd_dgns_vrsn_cd10, -${logic.hsql-only} icd_dgns_cd11, -${logic.hsql-only} icd_dgns_vrsn_cd11, -${logic.hsql-only} icd_dgns_cd12, -${logic.hsql-only} icd_dgns_vrsn_cd12 ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} create table public.carrier_claims_new as -select -${logic.hsql-only} convert(clm_id, SQL_BIGINT), -${logic.hsql-only} convert(bene_id, SQL_BIGINT), -${logic.hsql-only} convert(clm_grp_id, SQL_BIGINT), -${logic.psql-only} cast(clm_id as bigint), -${logic.psql-only} cast(bene_id as bigint), -${logic.psql-only} cast(clm_grp_id as bigint), - last_updated, - clm_from_dt, - clm_thru_dt, - clm_disp_cd, - final_action, - clm_pmt_amt, - carr_num, - carr_clm_rfrng_pin_num, - carr_clm_cntl_num, - carr_clm_entry_cd, - carr_clm_prmry_pyr_pd_amt, - carr_clm_cash_ddctbl_apld_amt, - carr_clm_pmt_dnl_cd, - carr_clm_hcpcs_yr_cd, - carr_clm_prvdr_asgnmt_ind_sw, - nch_clm_type_cd, - nch_near_line_rec_ident_cd, - nch_wkly_proc_dt, - nch_carr_clm_sbmtd_chrg_amt, - nch_carr_clm_alowd_amt, - nch_clm_bene_pmt_amt, - nch_clm_prvdr_pmt_amt, - clm_clncl_tril_num, - prncpal_dgns_cd, - prncpal_dgns_vrsn_cd, - rfr_physn_npi, - rfr_physn_upin, - icd_dgns_cd1, - icd_dgns_vrsn_cd1, - icd_dgns_cd2, - icd_dgns_vrsn_cd2, - icd_dgns_cd3, - icd_dgns_vrsn_cd3, - icd_dgns_cd4, - icd_dgns_vrsn_cd4, - icd_dgns_cd5, - icd_dgns_vrsn_cd5, - icd_dgns_cd6, - icd_dgns_vrsn_cd6, - icd_dgns_cd7, - icd_dgns_vrsn_cd7, - icd_dgns_cd8, - icd_dgns_vrsn_cd8, - icd_dgns_cd9, - icd_dgns_vrsn_cd9, - icd_dgns_cd10, - icd_dgns_vrsn_cd10, - icd_dgns_cd11, - icd_dgns_vrsn_cd11, - icd_dgns_cd12, - icd_dgns_vrsn_cd12 -from - public.carrier_claims; - - --- for PSQL need to define our not null constraints; for HSQL, --- we explicitly defined a table structure before migrating data. --- -${logic.psql-only} alter table public.carrier_claims_new -${logic.psql-only} alter column clm_id SET NOT NULL, -${logic.psql-only} alter column bene_id SET NOT NULL, -${logic.psql-only} alter column clm_grp_id SET NOT NULL, -${logic.psql-only} alter column clm_from_dt SET NOT NULL, -${logic.psql-only} alter column clm_thru_dt SET NOT NULL, -${logic.psql-only} alter column clm_disp_cd SET NOT NULL, -${logic.psql-only} alter column final_action SET NOT NULL, -${logic.psql-only} alter column clm_pmt_amt SET NOT NULL, -${logic.psql-only} alter column carr_num SET NOT NULL, -${logic.psql-only} alter column carr_clm_rfrng_pin_num SET NOT NULL, -${logic.psql-only} alter column carr_clm_entry_cd SET NOT NULL, -${logic.psql-only} alter column carr_clm_prmry_pyr_pd_amt SET NOT NULL, -${logic.psql-only} alter column carr_clm_cash_ddctbl_apld_amt SET NOT NULL, -${logic.psql-only} alter column carr_clm_pmt_dnl_cd SET NOT NULL, -${logic.psql-only} alter column nch_clm_type_cd SET NOT NULL, -${logic.psql-only} alter column nch_near_line_rec_ident_cd SET NOT NULL, -${logic.psql-only} alter column nch_wkly_proc_dt SET NOT NULL, -${logic.psql-only} alter column nch_carr_clm_sbmtd_chrg_amt SET NOT NULL, -${logic.psql-only} alter column nch_carr_clm_alowd_amt SET NOT NULL, -${logic.psql-only} alter column nch_clm_bene_pmt_amt SET NOT NULL, -${logic.psql-only} alter column nch_clm_prvdr_pmt_amt SET NOT NULL; - --- migrate data via INSERT from current carrier_CLAIM_LINES table to carrier_CLAIM_LINES_NEW table --- -${logic.hsql-only} insert into public.carrier_claim_lines_new ( -${logic.hsql-only} clm_id, -${logic.hsql-only} line_num, -${logic.hsql-only} carr_line_rdcd_pmt_phys_astn_c, -${logic.hsql-only} carr_line_prvdr_type_cd, -${logic.hsql-only} carr_line_prcng_lclty_cd, -${logic.hsql-only} carr_line_mtus_cnt, -${logic.hsql-only} carr_line_ansthsa_unit_cnt, -${logic.hsql-only} carr_prfrng_pin_num, -${logic.hsql-only} carr_line_mtus_cd, -${logic.hsql-only} carr_line_rx_num, -${logic.hsql-only} carr_line_clia_lab_num, -${logic.hsql-only} line_1st_expns_dt, -${logic.hsql-only} line_last_expns_dt, -${logic.hsql-only} line_alowd_chrg_amt, -${logic.hsql-only} line_coinsrnc_amt, -${logic.hsql-only} line_sbmtd_chrg_amt, -${logic.hsql-only} line_bene_pmt_amt, -${logic.hsql-only} line_prvdr_pmt_amt, -${logic.hsql-only} line_bene_prmry_pyr_cd, -${logic.hsql-only} line_bene_prmry_pyr_pd_amt, -${logic.hsql-only} line_bene_ptb_ddctbl_amt, -${logic.hsql-only} line_place_of_srvc_cd, -${logic.hsql-only} line_pmt_80_100_cd, -${logic.hsql-only} line_srvc_cnt, -${logic.hsql-only} line_cms_type_srvc_cd, -${logic.hsql-only} line_hct_hgb_type_cd, -${logic.hsql-only} line_hct_hgb_rslt_num, -${logic.hsql-only} line_ndc_cd, -${logic.hsql-only} line_nch_pmt_amt, -${logic.hsql-only} line_icd_dgns_cd, -${logic.hsql-only} line_icd_dgns_vrsn_cd, -${logic.hsql-only} line_prcsg_ind_cd, -${logic.hsql-only} line_service_deductible, -${logic.hsql-only} betos_cd, -${logic.hsql-only} hcpcs_cd, -${logic.hsql-only} hcpcs_1st_mdfr_cd, -${logic.hsql-only} hcpcs_2nd_mdfr_cd, -${logic.hsql-only} hpsa_scrcty_ind_cd, -${logic.hsql-only} prvdr_state_cd, -${logic.hsql-only} prvdr_spclty, -${logic.hsql-only} prvdr_zip, -${logic.hsql-only} tax_num, -${logic.hsql-only} org_npi_num, -${logic.hsql-only} prf_physn_npi, -${logic.hsql-only} prf_physn_upin, -${logic.hsql-only} prtcptng_ind_cd ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} create table public.carrier_claim_lines_new as -select -${logic.hsql-only} convert(clm_id, SQL_BIGINT), -${logic.hsql-only} convert(line_num, SQL_SMALLINT), -${logic.psql-only} cast(clm_id as bigint), -${logic.psql-only} cast(line_num as smallint), - carr_line_rdcd_pmt_phys_astn_c, - carr_line_prvdr_type_cd, - carr_line_prcng_lclty_cd, - carr_line_mtus_cnt, - carr_line_ansthsa_unit_cnt, - carr_prfrng_pin_num, - carr_line_mtus_cd, - carr_line_rx_num, - carr_line_clia_lab_num, - line_1st_expns_dt, - line_last_expns_dt, - line_alowd_chrg_amt, - line_coinsrnc_amt, - line_sbmtd_chrg_amt, - line_bene_pmt_amt, - line_prvdr_pmt_amt, - line_bene_prmry_pyr_cd, - line_bene_prmry_pyr_pd_amt, - line_bene_ptb_ddctbl_amt, - line_place_of_srvc_cd, - line_pmt_80_100_cd, - line_srvc_cnt, - line_cms_type_srvc_cd, - line_hct_hgb_type_cd, - line_hct_hgb_rslt_num, - line_ndc_cd, - line_nch_pmt_amt, - line_icd_dgns_cd, - line_icd_dgns_vrsn_cd, - line_prcsg_ind_cd, - line_service_deductible, - betos_cd, - hcpcs_cd, - hcpcs_1st_mdfr_cd, - hcpcs_2nd_mdfr_cd, - hpsa_scrcty_ind_cd, - prvdr_state_cd, - prvdr_spclty, - prvdr_zip, - tax_num, - org_npi_num, - prf_physn_npi, - prf_physn_upin, - prtcptng_ind_cd -from - public.carrier_claim_lines; - --- for PSQL need to define our not null constraints; for HSQL, --- we explicitly defined a table structure before migrating data. --- -${logic.psql-only} alter table public.carrier_claim_lines_new -${logic.psql-only} alter column clm_id SET NOT NULL, -${logic.psql-only} alter column line_num SET NOT NULL, -${logic.psql-only} alter column carr_line_rdcd_pmt_phys_astn_c SET NOT NULL, -${logic.psql-only} alter column carr_line_prvdr_type_cd SET NOT NULL, -${logic.psql-only} alter column carr_line_prcng_lclty_cd SET NOT NULL, -${logic.psql-only} alter column carr_line_mtus_cnt SET NOT NULL, -${logic.psql-only} alter column carr_line_ansthsa_unit_cnt SET NOT NULL, -${logic.psql-only} alter column carr_prfrng_pin_num SET NOT NULL, -${logic.psql-only} alter column line_alowd_chrg_amt SET NOT NULL, -${logic.psql-only} alter column line_coinsrnc_amt SET NOT NULL, -${logic.psql-only} alter column line_sbmtd_chrg_amt SET NOT NULL, -${logic.psql-only} alter column line_bene_pmt_amt SET NOT NULL, -${logic.psql-only} alter column line_prvdr_pmt_amt SET NOT NULL, -${logic.psql-only} alter column line_bene_prmry_pyr_pd_amt SET NOT NULL, -${logic.psql-only} alter column line_bene_ptb_ddctbl_amt SET NOT NULL, -${logic.psql-only} alter column line_place_of_srvc_cd SET NOT NULL, -${logic.psql-only} alter column line_srvc_cnt SET NOT NULL, -${logic.psql-only} alter column line_cms_type_srvc_cd SET NOT NULL, -${logic.psql-only} alter column line_hct_hgb_rslt_num SET NOT NULL, -${logic.psql-only} alter column line_nch_pmt_amt SET NOT NULL, -${logic.psql-only} alter column tax_num SET NOT NULL; - --- for PSQL need to define our primary key -${logic.psql-only} alter table public.carrier_claims_new -${logic.psql-only} add CONSTRAINT carrier_claims_new_pkey PRIMARY KEY (clm_id); - --- for PSQL need to define our primary key -${logic.psql-only} ALTER TABLE public.carrier_claim_lines_new -${logic.psql-only} ADD CONSTRAINT carrier_claim_lines_new_pkey PRIMARY KEY (clm_id, line_num); - --- define foreign key constraints between claim lineitems and a parent claims table. -ALTER TABLE IF EXISTS public.carrier_claim_lines_new - ADD CONSTRAINT carrier_claim_lines_clm_id_to_carrier_claims_new FOREIGN KEY (clm_id) - REFERENCES public.carrier_claims_new (clm_id); - --- create an index of the BENE_ID in parent claims table -CREATE INDEX IF NOT EXISTS carrier_claims_new_bene_id_idx - ON public.carrier_claims_new (bene_id); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V72__new_schema_inpatient_claims.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V72__new_schema_inpatient_claims.sql deleted file mode 100644 index 436c9cf14d..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V72__new_schema_inpatient_claims.sql +++ /dev/null @@ -1,965 +0,0 @@ --- NEW_SCHEMA_INPATIENT_CLAIMS.SQL --- flyway migration for INPATIENT_CLAIMS and INPATIENT_CLAIM_LINES tables into --- a new schema structure that: --- 1) changes data type of CLM_ID, BENE_ID from varchar to BIGINT. --- 2) change data type of CLM_GRP_ID from numeric to BIGINT --- 3) organizes parent claim table (INPATIENT_CLAIMS) such that common --- claims data columns are organized at top of table structure. --- --- The following db columns were redefined from NUMERIC to more --- appropriate data type(s): --- --- clm_line_num - changed to smallint --- --- Once current table data is migrated to new table name/structure, a --- subsequent PR will be deployed that changes the ORM model(s) and --- operational code for Inpatient Claims table(s). --- --- HSQL differs from PSQL (postgres) in that the table defintion --- must be explicitly declared prior to loading data into the --- target table. PSQL can derive the table structure based on --- the data input (i.e., column name, data type). Thus, for HSQL, --- we need to explicitly define the table structure prior to loading data. --- --- For HSQL, explicitly define/create a new INPATIENT_CLAIMS_NEW table in --- the current PUBLIC schema - -${logic.hsql-only} create table public.inpatient_claims_new ( -${logic.hsql-only} clm_id bigint not null, -${logic.hsql-only} bene_id bigint not null, -${logic.hsql-only} clm_grp_id bigint not null, -${logic.hsql-only} last_updated timestamp with time zone, -${logic.hsql-only} clm_from_dt date not null, -${logic.hsql-only} clm_thru_dt date not null, -${logic.hsql-only} clm_fac_type_cd char(1) not null, -${logic.hsql-only} clm_freq_cd char(1) not null, -${logic.hsql-only} final_action char(1) not null, -${logic.hsql-only} clm_tot_chrg_amt numeric(12,2) not null, -${logic.hsql-only} clm_pmt_amt numeric(12,2) not null, -${logic.hsql-only} clm_pass_thru_per_diem_amt numeric(12,2) not null, -${logic.hsql-only} clm_admsn_dt date, -${logic.hsql-only} clm_drg_cd varchar(3), -${logic.hsql-only} clm_ip_admsn_type_cd char(1) not null, -${logic.hsql-only} clm_mco_pd_sw char(1), -${logic.hsql-only} clm_mdcr_non_pmt_rsn_cd varchar(2), -${logic.hsql-only} clm_non_utlztn_days_cnt numeric not null, -${logic.hsql-only} clm_utlztn_day_cnt numeric not null, -${logic.hsql-only} clm_drg_outlier_stay_cd char(1) not null, -${logic.hsql-only} claim_query_code char(1) not null, -${logic.hsql-only} clm_srvc_clsfctn_type_cd char(1) not null, -${logic.hsql-only} clm_pps_ind_cd char(1), -${logic.hsql-only} clm_pps_cptl_drg_wt_num numeric(7,4), -${logic.hsql-only} clm_pps_cptl_dsprprtnt_shr_amt numeric(12,2), -${logic.hsql-only} clm_pps_cptl_excptn_amt numeric(12,2), -${logic.hsql-only} clm_pps_cptl_fsp_amt numeric(12,2), -${logic.hsql-only} clm_pps_cptl_ime_amt numeric(12,2), -${logic.hsql-only} clm_pps_cptl_outlier_amt numeric(12,2), -${logic.hsql-only} clm_pps_old_cptl_hld_hrmls_amt numeric(12,2), -${logic.hsql-only} clm_uncompd_care_pmt_amt numeric(12,2), -${logic.hsql-only} clm_tot_pps_cptl_amt numeric(12,2), -${logic.hsql-only} clm_src_ip_admsn_cd char(1), -${logic.hsql-only} bene_lrd_used_cnt numeric, -${logic.hsql-only} prncpal_dgns_cd varchar(7), -${logic.hsql-only} prncpal_dgns_vrsn_cd char(1), -${logic.hsql-only} prvdr_num varchar(9) not null, -${logic.hsql-only} prvdr_state_cd varchar(2) not null, -${logic.hsql-only} ptnt_dschrg_stus_cd varchar(2) not null, -${logic.hsql-only} bene_tot_coinsrnc_days_cnt numeric not null, -${logic.hsql-only} admtg_dgns_cd varchar(7), -${logic.hsql-only} admtg_dgns_vrsn_cd char(1), -${logic.hsql-only} at_physn_npi varchar(10), -${logic.hsql-only} at_physn_upin varchar(9), -${logic.hsql-only} fi_clm_actn_cd char(1), -${logic.hsql-only} fi_clm_proc_dt date, -${logic.hsql-only} fi_doc_clm_cntl_num varchar(23), -${logic.hsql-only} fi_num varchar(5), -${logic.hsql-only} fi_orig_clm_cntl_num varchar(23), -${logic.hsql-only} nch_clm_type_cd varchar(2) not null, -${logic.hsql-only} nch_near_line_rec_ident_cd char(1) not null, -${logic.hsql-only} nch_actv_or_cvrd_lvl_care_thru date, -${logic.hsql-only} nch_bene_dschrg_dt date, -${logic.hsql-only} nch_blood_pnts_frnshd_qty numeric not null, -${logic.hsql-only} nch_bene_blood_ddctbl_lblty_am numeric(12,2) not null, -${logic.hsql-only} nch_bene_ip_ddctbl_amt numeric(12,2) not null, -${logic.hsql-only} nch_bene_pta_coinsrnc_lblty_am numeric(12,2) not null, -${logic.hsql-only} nch_ip_ncvrd_chrg_amt numeric(12,2) not null, -${logic.hsql-only} nch_ip_tot_ddctn_amt numeric(12,2) not null, -${logic.hsql-only} nch_prmry_pyr_cd char(1), -${logic.hsql-only} nch_prmry_pyr_clm_pd_amt numeric(12,2) not null, -${logic.hsql-only} nch_profnl_cmpnt_chrg_amt numeric(12,2) not null, -${logic.hsql-only} nch_drg_outlier_aprvd_pmt_amt numeric(12,2), -${logic.hsql-only} nch_bene_mdcr_bnfts_exhtd_dt_i date, -${logic.hsql-only} nch_ptnt_status_ind_cd char(1), -${logic.hsql-only} nch_wkly_proc_dt date not null, -${logic.hsql-only} nch_vrfd_ncvrd_stay_from_dt date, -${logic.hsql-only} nch_vrfd_ncvrd_stay_thru_dt date, -${logic.hsql-only} dsh_op_clm_val_amt numeric(12,2), -${logic.hsql-only} ime_op_clm_val_amt numeric(12,2), -${logic.hsql-only} op_physn_npi varchar(10), -${logic.hsql-only} op_physn_upin varchar(9), -${logic.hsql-only} org_npi_num varchar(10), -${logic.hsql-only} ot_physn_npi varchar(10), -${logic.hsql-only} ot_physn_upin varchar(9), -${logic.hsql-only} fst_dgns_e_cd varchar(7), -${logic.hsql-only} fst_dgns_e_vrsn_cd char(1), -${logic.hsql-only} prcdr_dt1 date, -${logic.hsql-only} icd_prcdr_cd1 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd1 char(1), -${logic.hsql-only} icd_dgns_cd1 varchar(7), -${logic.hsql-only} icd_dgns_e_cd1 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd1 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd1 char(1), -${logic.hsql-only} clm_poa_ind_sw1 char(1), -${logic.hsql-only} clm_e_poa_ind_sw1 char(1), -${logic.hsql-only} prcdr_dt2 date, -${logic.hsql-only} icd_prcdr_cd2 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd2 char(1), -${logic.hsql-only} icd_dgns_cd2 varchar(7), -${logic.hsql-only} icd_dgns_e_cd2 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd2 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd2 char(1), -${logic.hsql-only} clm_poa_ind_sw2 char(1), -${logic.hsql-only} clm_e_poa_ind_sw2 char(1), -${logic.hsql-only} prcdr_dt3 date, -${logic.hsql-only} icd_prcdr_cd3 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd3 char(1), -${logic.hsql-only} icd_dgns_cd3 varchar(7), -${logic.hsql-only} icd_dgns_e_cd3 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd3 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd3 char(1), -${logic.hsql-only} clm_poa_ind_sw3 char(1), -${logic.hsql-only} clm_e_poa_ind_sw3 char(1), -${logic.hsql-only} prcdr_dt4 date, -${logic.hsql-only} icd_prcdr_cd4 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd4 char(1), -${logic.hsql-only} icd_dgns_cd4 varchar(7), -${logic.hsql-only} icd_dgns_e_cd4 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd4 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd4 char(1), -${logic.hsql-only} clm_poa_ind_sw4 char(1), -${logic.hsql-only} clm_e_poa_ind_sw4 char(1), -${logic.hsql-only} prcdr_dt5 date, -${logic.hsql-only} icd_prcdr_cd5 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd5 char(1), -${logic.hsql-only} icd_dgns_cd5 varchar(7), -${logic.hsql-only} icd_dgns_e_cd5 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd5 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd5 char(1), -${logic.hsql-only} clm_poa_ind_sw5 char(1), -${logic.hsql-only} clm_e_poa_ind_sw5 char(1), -${logic.hsql-only} prcdr_dt6 date, -${logic.hsql-only} icd_prcdr_cd6 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd6 char(1), -${logic.hsql-only} icd_dgns_cd6 varchar(7), -${logic.hsql-only} icd_dgns_e_cd6 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd6 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd6 char(1), -${logic.hsql-only} clm_poa_ind_sw6 char(1), -${logic.hsql-only} clm_e_poa_ind_sw6 char(1), -${logic.hsql-only} prcdr_dt7 date, -${logic.hsql-only} icd_prcdr_cd7 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd7 char(1), -${logic.hsql-only} icd_dgns_cd7 varchar(7), -${logic.hsql-only} icd_dgns_e_cd7 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd7 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd7 char(1), -${logic.hsql-only} clm_poa_ind_sw7 char(1), -${logic.hsql-only} clm_e_poa_ind_sw7 char(1), -${logic.hsql-only} prcdr_dt8 date, -${logic.hsql-only} icd_prcdr_cd8 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd8 char(1), -${logic.hsql-only} icd_dgns_cd8 varchar(7), -${logic.hsql-only} icd_dgns_e_cd8 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd8 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd8 char(1), -${logic.hsql-only} clm_poa_ind_sw8 char(1), -${logic.hsql-only} clm_e_poa_ind_sw8 char(1), -${logic.hsql-only} prcdr_dt9 date, -${logic.hsql-only} icd_prcdr_cd9 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd9 char(1), -${logic.hsql-only} icd_dgns_cd9 varchar(7), -${logic.hsql-only} icd_dgns_e_cd9 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd9 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd9 char(1), -${logic.hsql-only} clm_poa_ind_sw9 char(1), -${logic.hsql-only} clm_e_poa_ind_sw9 char(1), -${logic.hsql-only} prcdr_dt10 date, -${logic.hsql-only} icd_prcdr_cd10 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd10 char(1), -${logic.hsql-only} icd_dgns_cd10 varchar(7), -${logic.hsql-only} icd_dgns_e_cd10 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd10 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd10 char(1), -${logic.hsql-only} clm_poa_ind_sw10 char(1), -${logic.hsql-only} clm_e_poa_ind_sw10 char(1), -${logic.hsql-only} prcdr_dt11 date, -${logic.hsql-only} icd_prcdr_cd11 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd11 char(1), -${logic.hsql-only} icd_dgns_cd11 varchar(7), -${logic.hsql-only} icd_dgns_e_cd11 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd11 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd11 char(1), -${logic.hsql-only} clm_poa_ind_sw11 char(1), -${logic.hsql-only} clm_e_poa_ind_sw11 char(1), -${logic.hsql-only} prcdr_dt12 date, -${logic.hsql-only} icd_prcdr_cd12 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd12 char(1), -${logic.hsql-only} icd_dgns_cd12 varchar(7), -${logic.hsql-only} icd_dgns_e_cd12 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd12 char(1), -${logic.hsql-only} icd_dgns_e_vrsn_cd12 char(1), -${logic.hsql-only} clm_poa_ind_sw12 char(1), -${logic.hsql-only} clm_e_poa_ind_sw12 char(1), -${logic.hsql-only} prcdr_dt13 date, -${logic.hsql-only} icd_prcdr_cd13 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd13 char(1), -${logic.hsql-only} icd_dgns_cd13 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd13 char(1), -${logic.hsql-only} clm_poa_ind_sw13 char(1), -${logic.hsql-only} prcdr_dt14 date, -${logic.hsql-only} icd_prcdr_cd14 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd14 char(1), -${logic.hsql-only} icd_dgns_cd14 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd14 char(1), -${logic.hsql-only} clm_poa_ind_sw14 char(1), -${logic.hsql-only} prcdr_dt15 date, -${logic.hsql-only} icd_prcdr_cd15 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd15 char(1), -${logic.hsql-only} icd_dgns_cd15 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd15 char(1), -${logic.hsql-only} clm_poa_ind_sw15 char(1), -${logic.hsql-only} prcdr_dt16 date, -${logic.hsql-only} icd_prcdr_cd16 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd16 char(1), -${logic.hsql-only} icd_dgns_cd16 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd16 char(1), -${logic.hsql-only} clm_poa_ind_sw16 char(1), -${logic.hsql-only} prcdr_dt17 date, -${logic.hsql-only} icd_prcdr_cd17 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd17 char(1), -${logic.hsql-only} icd_dgns_cd17 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd17 char(1), -${logic.hsql-only} clm_poa_ind_sw17 char(1), -${logic.hsql-only} prcdr_dt18 date, -${logic.hsql-only} icd_prcdr_cd18 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd18 char(1), -${logic.hsql-only} icd_dgns_cd18 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd18 char(1), -${logic.hsql-only} clm_poa_ind_sw18 char(1), -${logic.hsql-only} prcdr_dt19 date, -${logic.hsql-only} icd_prcdr_cd19 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd19 char(1), -${logic.hsql-only} icd_dgns_cd19 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd19 char(1), -${logic.hsql-only} clm_poa_ind_sw19 char(1), -${logic.hsql-only} prcdr_dt20 date, -${logic.hsql-only} icd_prcdr_cd20 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd20 char(1), -${logic.hsql-only} icd_dgns_cd20 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd20 char(1), -${logic.hsql-only} clm_poa_ind_sw20 char(1), -${logic.hsql-only} prcdr_dt21 date, -${logic.hsql-only} icd_prcdr_cd21 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd21 char(1), -${logic.hsql-only} icd_dgns_cd21 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd21 char(1), -${logic.hsql-only} clm_poa_ind_sw21 char(1), -${logic.hsql-only} prcdr_dt22 date, -${logic.hsql-only} icd_prcdr_cd22 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd22 char(1), -${logic.hsql-only} icd_dgns_cd22 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd22 char(1), -${logic.hsql-only} clm_poa_ind_sw22 char(1), -${logic.hsql-only} prcdr_dt23 date, -${logic.hsql-only} icd_prcdr_cd23 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd23 char(1), -${logic.hsql-only} icd_dgns_cd23 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd23 char(1), -${logic.hsql-only} clm_poa_ind_sw23 char(1), -${logic.hsql-only} prcdr_dt24 date, -${logic.hsql-only} icd_prcdr_cd24 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd24 char(1), -${logic.hsql-only} icd_dgns_cd24 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd24 char(1), -${logic.hsql-only} clm_poa_ind_sw24 char(1), -${logic.hsql-only} prcdr_dt25 date, -${logic.hsql-only} icd_prcdr_cd25 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd25 char(1), -${logic.hsql-only} icd_dgns_cd25 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd25 char(1), -${logic.hsql-only} clm_poa_ind_sw25 char(1), -${logic.hsql-only} constraint public.inpatient_claims_new_pkey -${logic.hsql-only} primary key (clm_id) ); - --- create a new INPATIENT_CLAIM_LINES_NEW table in the current PUBLIC schema --- -${logic.hsql-only} CREATE TABLE IF NOT EXISTS public.inpatient_claim_lines_new ( -${logic.hsql-only} clm_id bigint NOT NULL, -${logic.hsql-only} clm_line_num smallint NOT NULL, -${logic.hsql-only} rev_cntr varchar(4) NOT NULL, -${logic.hsql-only} rev_cntr_unit_cnt numeric NOT NULL, -${logic.hsql-only} rev_cntr_rate_amt numeric(12,2) NOT NULL, -${logic.hsql-only} rev_cntr_tot_chrg_amt numeric(12,2) NOT NULL, -${logic.hsql-only} rev_cntr_ncvrd_chrg_amt numeric(12,2) NOT NULL, -${logic.hsql-only} rev_cntr_ddctbl_coinsrnc_cd char(1), -${logic.hsql-only} rev_cntr_ndc_qty_qlfr_cd varchar(2), -${logic.hsql-only} rev_cntr_ndc_qty numeric, -${logic.hsql-only} hcpcs_cd varchar(5), -${logic.hsql-only} rndrng_physn_npi varchar(12), -${logic.hsql-only} rndrng_physn_upin varchar(12), -${logic.hsql-only} CONSTRAINT inpatient_claim_lines_new_pkey -${logic.hsql-only} PRIMARY KEY (clm_id, clm_line_num) ); - --- migrate data via INSERT from current INPATIENT_CLAIMS table to INPATIENT_CLAIMS_NEW table --- -${logic.hsql-only} insert into public.inpatient_claims_new ( -${logic.hsql-only} clm_id, -${logic.hsql-only} bene_id, -${logic.hsql-only} clm_grp_id, -${logic.hsql-only} last_updated, -${logic.hsql-only} clm_from_dt, -${logic.hsql-only} clm_thru_dt, -${logic.hsql-only} clm_fac_type_cd, -${logic.hsql-only} clm_freq_cd, -${logic.hsql-only} final_action, -${logic.hsql-only} clm_tot_chrg_amt, -${logic.hsql-only} clm_pmt_amt, -${logic.hsql-only} clm_pass_thru_per_diem_amt, -${logic.hsql-only} clm_admsn_dt, -${logic.hsql-only} clm_drg_cd, -${logic.hsql-only} clm_ip_admsn_type_cd, -${logic.hsql-only} clm_mco_pd_sw, -${logic.hsql-only} clm_mdcr_non_pmt_rsn_cd, -${logic.hsql-only} clm_non_utlztn_days_cnt, -${logic.hsql-only} clm_utlztn_day_cnt, -${logic.hsql-only} clm_drg_outlier_stay_cd, -${logic.hsql-only} claim_query_code, -${logic.hsql-only} clm_srvc_clsfctn_type_cd, -${logic.hsql-only} clm_pps_ind_cd, -${logic.hsql-only} clm_pps_cptl_drg_wt_num, -${logic.hsql-only} clm_pps_cptl_dsprprtnt_shr_amt, -${logic.hsql-only} clm_pps_cptl_excptn_amt, -${logic.hsql-only} clm_pps_cptl_fsp_amt, -${logic.hsql-only} clm_pps_cptl_ime_amt, -${logic.hsql-only} clm_pps_cptl_outlier_amt, -${logic.hsql-only} clm_pps_old_cptl_hld_hrmls_amt, -${logic.hsql-only} clm_uncompd_care_pmt_amt, -${logic.hsql-only} clm_tot_pps_cptl_amt, -${logic.hsql-only} clm_src_ip_admsn_cd, -${logic.hsql-only} bene_lrd_used_cnt, -${logic.hsql-only} prncpal_dgns_cd, -${logic.hsql-only} prncpal_dgns_vrsn_cd, -${logic.hsql-only} prvdr_num, -${logic.hsql-only} prvdr_state_cd, -${logic.hsql-only} ptnt_dschrg_stus_cd, -${logic.hsql-only} bene_tot_coinsrnc_days_cnt, -${logic.hsql-only} admtg_dgns_cd, -${logic.hsql-only} admtg_dgns_vrsn_cd, -${logic.hsql-only} at_physn_npi, -${logic.hsql-only} at_physn_upin, -${logic.hsql-only} fi_clm_actn_cd, -${logic.hsql-only} fi_clm_proc_dt, -${logic.hsql-only} fi_doc_clm_cntl_num, -${logic.hsql-only} fi_num, -${logic.hsql-only} fi_orig_clm_cntl_num, -${logic.hsql-only} nch_clm_type_cd, -${logic.hsql-only} nch_near_line_rec_ident_cd, -${logic.hsql-only} nch_actv_or_cvrd_lvl_care_thru, -${logic.hsql-only} nch_bene_dschrg_dt, -${logic.hsql-only} nch_blood_pnts_frnshd_qty, -${logic.hsql-only} nch_bene_blood_ddctbl_lblty_am, -${logic.hsql-only} nch_bene_ip_ddctbl_amt, -${logic.hsql-only} nch_bene_pta_coinsrnc_lblty_am, -${logic.hsql-only} nch_ip_ncvrd_chrg_amt, -${logic.hsql-only} nch_ip_tot_ddctn_amt, -${logic.hsql-only} nch_prmry_pyr_cd, -${logic.hsql-only} nch_prmry_pyr_clm_pd_amt, -${logic.hsql-only} nch_profnl_cmpnt_chrg_amt, -${logic.hsql-only} nch_drg_outlier_aprvd_pmt_amt, -${logic.hsql-only} nch_bene_mdcr_bnfts_exhtd_dt_i, -${logic.hsql-only} nch_ptnt_status_ind_cd, -${logic.hsql-only} nch_wkly_proc_dt, -${logic.hsql-only} nch_vrfd_ncvrd_stay_from_dt, -${logic.hsql-only} nch_vrfd_ncvrd_stay_thru_dt, -${logic.hsql-only} dsh_op_clm_val_amt, -${logic.hsql-only} ime_op_clm_val_amt, -${logic.hsql-only} op_physn_npi, -${logic.hsql-only} op_physn_upin, -${logic.hsql-only} org_npi_num, -${logic.hsql-only} ot_physn_npi, -${logic.hsql-only} ot_physn_upin, -${logic.hsql-only} fst_dgns_e_cd, -${logic.hsql-only} fst_dgns_e_vrsn_cd, -${logic.hsql-only} prcdr_dt1, -${logic.hsql-only} icd_prcdr_cd1, -${logic.hsql-only} icd_prcdr_vrsn_cd1, -${logic.hsql-only} icd_dgns_cd1, -${logic.hsql-only} icd_dgns_e_cd1, -${logic.hsql-only} icd_dgns_vrsn_cd1, -${logic.hsql-only} icd_dgns_e_vrsn_cd1, -${logic.hsql-only} clm_poa_ind_sw1, -${logic.hsql-only} clm_e_poa_ind_sw1, -${logic.hsql-only} prcdr_dt2, -${logic.hsql-only} icd_prcdr_cd2, -${logic.hsql-only} icd_prcdr_vrsn_cd2, -${logic.hsql-only} icd_dgns_cd2, -${logic.hsql-only} icd_dgns_e_cd2, -${logic.hsql-only} icd_dgns_vrsn_cd2, -${logic.hsql-only} icd_dgns_e_vrsn_cd2, -${logic.hsql-only} clm_poa_ind_sw2, -${logic.hsql-only} clm_e_poa_ind_sw2, -${logic.hsql-only} prcdr_dt3, -${logic.hsql-only} icd_prcdr_cd3, -${logic.hsql-only} icd_prcdr_vrsn_cd3, -${logic.hsql-only} icd_dgns_cd3, -${logic.hsql-only} icd_dgns_e_cd3, -${logic.hsql-only} icd_dgns_vrsn_cd3, -${logic.hsql-only} icd_dgns_e_vrsn_cd3, -${logic.hsql-only} clm_poa_ind_sw3, -${logic.hsql-only} clm_e_poa_ind_sw3, -${logic.hsql-only} prcdr_dt4, -${logic.hsql-only} icd_prcdr_cd4, -${logic.hsql-only} icd_prcdr_vrsn_cd4, -${logic.hsql-only} icd_dgns_cd4, -${logic.hsql-only} icd_dgns_e_cd4, -${logic.hsql-only} icd_dgns_vrsn_cd4, -${logic.hsql-only} icd_dgns_e_vrsn_cd4, -${logic.hsql-only} clm_poa_ind_sw4, -${logic.hsql-only} clm_e_poa_ind_sw4, -${logic.hsql-only} prcdr_dt5, -${logic.hsql-only} icd_prcdr_cd5, -${logic.hsql-only} icd_prcdr_vrsn_cd5, -${logic.hsql-only} icd_dgns_cd5, -${logic.hsql-only} icd_dgns_e_cd5, -${logic.hsql-only} icd_dgns_vrsn_cd5, -${logic.hsql-only} icd_dgns_e_vrsn_cd5, -${logic.hsql-only} clm_poa_ind_sw5, -${logic.hsql-only} clm_e_poa_ind_sw5, -${logic.hsql-only} prcdr_dt6, -${logic.hsql-only} icd_prcdr_cd6, -${logic.hsql-only} icd_prcdr_vrsn_cd6, -${logic.hsql-only} icd_dgns_cd6, -${logic.hsql-only} icd_dgns_e_cd6, -${logic.hsql-only} icd_dgns_vrsn_cd6, -${logic.hsql-only} icd_dgns_e_vrsn_cd6, -${logic.hsql-only} clm_poa_ind_sw6, -${logic.hsql-only} clm_e_poa_ind_sw6, -${logic.hsql-only} prcdr_dt7, -${logic.hsql-only} icd_prcdr_cd7, -${logic.hsql-only} icd_prcdr_vrsn_cd7, -${logic.hsql-only} icd_dgns_cd7, -${logic.hsql-only} icd_dgns_e_cd7, -${logic.hsql-only} icd_dgns_vrsn_cd7, -${logic.hsql-only} icd_dgns_e_vrsn_cd7, -${logic.hsql-only} clm_poa_ind_sw7, -${logic.hsql-only} clm_e_poa_ind_sw7, -${logic.hsql-only} prcdr_dt8, -${logic.hsql-only} icd_prcdr_cd8, -${logic.hsql-only} icd_prcdr_vrsn_cd8, -${logic.hsql-only} icd_dgns_cd8, -${logic.hsql-only} icd_dgns_e_cd8, -${logic.hsql-only} icd_dgns_vrsn_cd8, -${logic.hsql-only} icd_dgns_e_vrsn_cd8, -${logic.hsql-only} clm_poa_ind_sw8, -${logic.hsql-only} clm_e_poa_ind_sw8, -${logic.hsql-only} prcdr_dt9, -${logic.hsql-only} icd_prcdr_cd9, -${logic.hsql-only} icd_prcdr_vrsn_cd9, -${logic.hsql-only} icd_dgns_cd9, -${logic.hsql-only} icd_dgns_e_cd9, -${logic.hsql-only} icd_dgns_vrsn_cd9, -${logic.hsql-only} icd_dgns_e_vrsn_cd9, -${logic.hsql-only} clm_poa_ind_sw9, -${logic.hsql-only} clm_e_poa_ind_sw9, -${logic.hsql-only} prcdr_dt10, -${logic.hsql-only} icd_prcdr_cd10, -${logic.hsql-only} icd_prcdr_vrsn_cd10, -${logic.hsql-only} icd_dgns_cd10, -${logic.hsql-only} icd_dgns_e_cd10, -${logic.hsql-only} icd_dgns_vrsn_cd10, -${logic.hsql-only} icd_dgns_e_vrsn_cd10, -${logic.hsql-only} clm_poa_ind_sw10, -${logic.hsql-only} clm_e_poa_ind_sw10, -${logic.hsql-only} prcdr_dt11, -${logic.hsql-only} icd_prcdr_cd11, -${logic.hsql-only} icd_prcdr_vrsn_cd11, -${logic.hsql-only} icd_dgns_cd11, -${logic.hsql-only} icd_dgns_e_cd11, -${logic.hsql-only} icd_dgns_vrsn_cd11, -${logic.hsql-only} icd_dgns_e_vrsn_cd11, -${logic.hsql-only} clm_poa_ind_sw11, -${logic.hsql-only} clm_e_poa_ind_sw11, -${logic.hsql-only} prcdr_dt12, -${logic.hsql-only} icd_prcdr_cd12, -${logic.hsql-only} icd_prcdr_vrsn_cd12, -${logic.hsql-only} icd_dgns_cd12, -${logic.hsql-only} icd_dgns_e_cd12, -${logic.hsql-only} icd_dgns_vrsn_cd12, -${logic.hsql-only} icd_dgns_e_vrsn_cd12, -${logic.hsql-only} clm_poa_ind_sw12, -${logic.hsql-only} clm_e_poa_ind_sw12, -${logic.hsql-only} prcdr_dt13, -${logic.hsql-only} icd_prcdr_cd13, -${logic.hsql-only} icd_prcdr_vrsn_cd13, -${logic.hsql-only} icd_dgns_cd13, -${logic.hsql-only} icd_dgns_vrsn_cd13, -${logic.hsql-only} clm_poa_ind_sw13, -${logic.hsql-only} prcdr_dt14, -${logic.hsql-only} icd_prcdr_cd14, -${logic.hsql-only} icd_prcdr_vrsn_cd14, -${logic.hsql-only} icd_dgns_cd14, -${logic.hsql-only} icd_dgns_vrsn_cd14, -${logic.hsql-only} clm_poa_ind_sw14, -${logic.hsql-only} prcdr_dt15, -${logic.hsql-only} icd_prcdr_cd15, -${logic.hsql-only} icd_prcdr_vrsn_cd15, -${logic.hsql-only} icd_dgns_cd15, -${logic.hsql-only} icd_dgns_vrsn_cd15, -${logic.hsql-only} clm_poa_ind_sw15, -${logic.hsql-only} prcdr_dt16, -${logic.hsql-only} icd_prcdr_cd16, -${logic.hsql-only} icd_prcdr_vrsn_cd16, -${logic.hsql-only} icd_dgns_cd16, -${logic.hsql-only} icd_dgns_vrsn_cd16, -${logic.hsql-only} clm_poa_ind_sw16, -${logic.hsql-only} prcdr_dt17, -${logic.hsql-only} icd_prcdr_cd17, -${logic.hsql-only} icd_prcdr_vrsn_cd17, -${logic.hsql-only} icd_dgns_cd17, -${logic.hsql-only} icd_dgns_vrsn_cd17, -${logic.hsql-only} clm_poa_ind_sw17, -${logic.hsql-only} prcdr_dt18, -${logic.hsql-only} icd_prcdr_cd18, -${logic.hsql-only} icd_prcdr_vrsn_cd18, -${logic.hsql-only} icd_dgns_cd18, -${logic.hsql-only} icd_dgns_vrsn_cd18, -${logic.hsql-only} clm_poa_ind_sw18, -${logic.hsql-only} prcdr_dt19, -${logic.hsql-only} icd_prcdr_cd19, -${logic.hsql-only} icd_prcdr_vrsn_cd19, -${logic.hsql-only} icd_dgns_cd19, -${logic.hsql-only} icd_dgns_vrsn_cd19, -${logic.hsql-only} clm_poa_ind_sw19, -${logic.hsql-only} prcdr_dt20, -${logic.hsql-only} icd_prcdr_cd20, -${logic.hsql-only} icd_prcdr_vrsn_cd20, -${logic.hsql-only} icd_dgns_cd20, -${logic.hsql-only} icd_dgns_vrsn_cd20, -${logic.hsql-only} clm_poa_ind_sw20, -${logic.hsql-only} prcdr_dt21, -${logic.hsql-only} icd_prcdr_cd21, -${logic.hsql-only} icd_prcdr_vrsn_cd21, -${logic.hsql-only} icd_dgns_cd21, -${logic.hsql-only} icd_dgns_vrsn_cd21, -${logic.hsql-only} clm_poa_ind_sw21, -${logic.hsql-only} prcdr_dt22, -${logic.hsql-only} icd_prcdr_cd22, -${logic.hsql-only} icd_prcdr_vrsn_cd22, -${logic.hsql-only} icd_dgns_cd22, -${logic.hsql-only} icd_dgns_vrsn_cd22, -${logic.hsql-only} clm_poa_ind_sw22, -${logic.hsql-only} prcdr_dt23, -${logic.hsql-only} icd_prcdr_cd23, -${logic.hsql-only} icd_prcdr_vrsn_cd23, -${logic.hsql-only} icd_dgns_cd23, -${logic.hsql-only} icd_dgns_vrsn_cd23, -${logic.hsql-only} clm_poa_ind_sw23, -${logic.hsql-only} prcdr_dt24, -${logic.hsql-only} icd_prcdr_cd24, -${logic.hsql-only} icd_prcdr_vrsn_cd24, -${logic.hsql-only} icd_dgns_cd24, -${logic.hsql-only} icd_dgns_vrsn_cd24, -${logic.hsql-only} clm_poa_ind_sw24, -${logic.hsql-only} prcdr_dt25, -${logic.hsql-only} icd_prcdr_cd25, -${logic.hsql-only} icd_prcdr_vrsn_cd25, -${logic.hsql-only} icd_dgns_cd25, -${logic.hsql-only} icd_dgns_vrsn_cd25, -${logic.hsql-only} clm_poa_ind_sw25 ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} SET max_parallel_workers = 24; -${logic.psql-only} SET max_parallel_workers_per_gather = 20; -${logic.psql-only} SET parallel_leader_participation = off; -${logic.psql-only} SET parallel_tuple_cost = 0; -${logic.psql-only} SET parallel_setup_cost = 0; - -${logic.psql-only} create table public.inpatient_claims_new as -select -${logic.hsql-only} convert(clm_id, SQL_BIGINT), -${logic.hsql-only} convert(bene_id, SQL_BIGINT), -${logic.hsql-only} convert(clm_grp_id, SQL_BIGINT), -${logic.psql-only} clm_id::bigint, -${logic.psql-only} bene_id::bigint, -${logic.psql-only} clm_grp_id::bigint, - last_updated, - clm_from_dt, - clm_thru_dt, - clm_fac_type_cd, - clm_freq_cd, - final_action, - clm_tot_chrg_amt, - clm_pmt_amt, - clm_pass_thru_per_diem_amt, - clm_admsn_dt, - clm_drg_cd, - clm_ip_admsn_type_cd, - clm_mco_pd_sw, - clm_mdcr_non_pmt_rsn_cd, - clm_non_utlztn_days_cnt, - clm_utlztn_day_cnt, - clm_drg_outlier_stay_cd, - claim_query_code, - clm_srvc_clsfctn_type_cd, - clm_pps_ind_cd, - clm_pps_cptl_drg_wt_num, - clm_pps_cptl_dsprprtnt_shr_amt, - clm_pps_cptl_excptn_amt, - clm_pps_cptl_fsp_amt, - clm_pps_cptl_ime_amt, - clm_pps_cptl_outlier_amt, - clm_pps_old_cptl_hld_hrmls_amt, - clm_uncompd_care_pmt_amt, - clm_tot_pps_cptl_amt, - clm_src_ip_admsn_cd, - bene_lrd_used_cnt, - prncpal_dgns_cd, - prncpal_dgns_vrsn_cd, - prvdr_num, - prvdr_state_cd, - ptnt_dschrg_stus_cd, - bene_tot_coinsrnc_days_cnt, - admtg_dgns_cd, - admtg_dgns_vrsn_cd, - at_physn_npi, - at_physn_upin, - fi_clm_actn_cd, - fi_clm_proc_dt, - fi_doc_clm_cntl_num, - fi_num, - fi_orig_clm_cntl_num, - nch_clm_type_cd, - nch_near_line_rec_ident_cd, - nch_actv_or_cvrd_lvl_care_thru, - nch_bene_dschrg_dt, - nch_blood_pnts_frnshd_qty, - nch_bene_blood_ddctbl_lblty_am, - nch_bene_ip_ddctbl_amt, - nch_bene_pta_coinsrnc_lblty_am, - nch_ip_ncvrd_chrg_amt, - nch_ip_tot_ddctn_amt, - nch_prmry_pyr_cd, - nch_prmry_pyr_clm_pd_amt, - nch_profnl_cmpnt_chrg_amt, - nch_drg_outlier_aprvd_pmt_amt, - nch_bene_mdcr_bnfts_exhtd_dt_i, - nch_ptnt_status_ind_cd, - nch_wkly_proc_dt, - nch_vrfd_ncvrd_stay_from_dt, - nch_vrfd_ncvrd_stay_thru_dt, - dsh_op_clm_val_amt, - ime_op_clm_val_amt, - op_physn_npi, - op_physn_upin, - org_npi_num, - ot_physn_npi, - ot_physn_upin, - fst_dgns_e_cd, - fst_dgns_e_vrsn_cd, - prcdr_dt1, - icd_prcdr_cd1, - icd_prcdr_vrsn_cd1, - icd_dgns_cd1, - icd_dgns_e_cd1, - icd_dgns_vrsn_cd1, - icd_dgns_e_vrsn_cd1, - clm_poa_ind_sw1, - clm_e_poa_ind_sw1, - prcdr_dt2, - icd_prcdr_cd2, - icd_prcdr_vrsn_cd2, - icd_dgns_cd2, - icd_dgns_e_cd2, - icd_dgns_vrsn_cd2, - icd_dgns_e_vrsn_cd2, - clm_poa_ind_sw2, - clm_e_poa_ind_sw2, - prcdr_dt3, - icd_prcdr_cd3, - icd_prcdr_vrsn_cd3, - icd_dgns_cd3, - icd_dgns_e_cd3, - icd_dgns_vrsn_cd3, - icd_dgns_e_vrsn_cd3, - clm_poa_ind_sw3, - clm_e_poa_ind_sw3, - prcdr_dt4, - icd_prcdr_cd4, - icd_prcdr_vrsn_cd4, - icd_dgns_cd4, - icd_dgns_e_cd4, - icd_dgns_vrsn_cd4, - icd_dgns_e_vrsn_cd4, - clm_poa_ind_sw4, - clm_e_poa_ind_sw4, - prcdr_dt5, - icd_prcdr_cd5, - icd_prcdr_vrsn_cd5, - icd_dgns_cd5, - icd_dgns_e_cd5, - icd_dgns_vrsn_cd5, - icd_dgns_e_vrsn_cd5, - clm_poa_ind_sw5, - clm_e_poa_ind_sw5, - prcdr_dt6, - icd_prcdr_cd6, - icd_prcdr_vrsn_cd6, - icd_dgns_cd6, - icd_dgns_e_cd6, - icd_dgns_vrsn_cd6, - icd_dgns_e_vrsn_cd6, - clm_poa_ind_sw6, - clm_e_poa_ind_sw6, - prcdr_dt7, - icd_prcdr_cd7, - icd_prcdr_vrsn_cd7, - icd_dgns_cd7, - icd_dgns_e_cd7, - icd_dgns_vrsn_cd7, - icd_dgns_e_vrsn_cd7, - clm_poa_ind_sw7, - clm_e_poa_ind_sw7, - prcdr_dt8, - icd_prcdr_cd8, - icd_prcdr_vrsn_cd8, - icd_dgns_cd8, - icd_dgns_e_cd8, - icd_dgns_vrsn_cd8, - icd_dgns_e_vrsn_cd8, - clm_poa_ind_sw8, - clm_e_poa_ind_sw8, - prcdr_dt9, - icd_prcdr_cd9, - icd_prcdr_vrsn_cd9, - icd_dgns_cd9, - icd_dgns_e_cd9, - icd_dgns_vrsn_cd9, - icd_dgns_e_vrsn_cd9, - clm_poa_ind_sw9, - clm_e_poa_ind_sw9, - prcdr_dt10, - icd_prcdr_cd10, - icd_prcdr_vrsn_cd10, - icd_dgns_cd10, - icd_dgns_e_cd10, - icd_dgns_vrsn_cd10, - icd_dgns_e_vrsn_cd10, - clm_poa_ind_sw10, - clm_e_poa_ind_sw10, - prcdr_dt11, - icd_prcdr_cd11, - icd_prcdr_vrsn_cd11, - icd_dgns_cd11, - icd_dgns_e_cd11, - icd_dgns_vrsn_cd11, - icd_dgns_e_vrsn_cd11, - clm_poa_ind_sw11, - clm_e_poa_ind_sw11, - prcdr_dt12, - icd_prcdr_cd12, - icd_prcdr_vrsn_cd12, - icd_dgns_cd12, - icd_dgns_e_cd12, - icd_dgns_vrsn_cd12, - icd_dgns_e_vrsn_cd12, - clm_poa_ind_sw12, - clm_e_poa_ind_sw12, - prcdr_dt13, - icd_prcdr_cd13, - icd_prcdr_vrsn_cd13, - icd_dgns_cd13, - icd_dgns_vrsn_cd13, - clm_poa_ind_sw13, - prcdr_dt14, - icd_prcdr_cd14, - icd_prcdr_vrsn_cd14, - icd_dgns_cd14, - icd_dgns_vrsn_cd14, - clm_poa_ind_sw14, - prcdr_dt15, - icd_prcdr_cd15, - icd_prcdr_vrsn_cd15, - icd_dgns_cd15, - icd_dgns_vrsn_cd15, - clm_poa_ind_sw15, - prcdr_dt16, - icd_prcdr_cd16, - icd_prcdr_vrsn_cd16, - icd_dgns_cd16, - icd_dgns_vrsn_cd16, - clm_poa_ind_sw16, - prcdr_dt17, - icd_prcdr_cd17, - icd_prcdr_vrsn_cd17, - icd_dgns_cd17, - icd_dgns_vrsn_cd17, - clm_poa_ind_sw17, - prcdr_dt18, - icd_prcdr_cd18, - icd_prcdr_vrsn_cd18, - icd_dgns_cd18, - icd_dgns_vrsn_cd18, - clm_poa_ind_sw18, - prcdr_dt19, - icd_prcdr_cd19, - icd_prcdr_vrsn_cd19, - icd_dgns_cd19, - icd_dgns_vrsn_cd19, - clm_poa_ind_sw19, - prcdr_dt20, - icd_prcdr_cd20, - icd_prcdr_vrsn_cd20, - icd_dgns_cd20, - icd_dgns_vrsn_cd20, - clm_poa_ind_sw20, - prcdr_dt21, - icd_prcdr_cd21, - icd_prcdr_vrsn_cd21, - icd_dgns_cd21, - icd_dgns_vrsn_cd21, - clm_poa_ind_sw21, - prcdr_dt22, - icd_prcdr_cd22, - icd_prcdr_vrsn_cd22, - icd_dgns_cd22, - icd_dgns_vrsn_cd22, - clm_poa_ind_sw22, - prcdr_dt23, - icd_prcdr_cd23, - icd_prcdr_vrsn_cd23, - icd_dgns_cd23, - icd_dgns_vrsn_cd23, - clm_poa_ind_sw23, - prcdr_dt24, - icd_prcdr_cd24, - icd_prcdr_vrsn_cd24, - icd_dgns_cd24, - icd_dgns_vrsn_cd24, - clm_poa_ind_sw24, - prcdr_dt25, - icd_prcdr_cd25, - icd_prcdr_vrsn_cd25, - icd_dgns_cd25, - icd_dgns_vrsn_cd25, - clm_poa_ind_sw25 -from - public.inpatient_claims; - - --- for PSQL need to define our not null constraints; for HSQL, --- we explicitly defined a table structure before migrating data. --- -${logic.psql-only} alter table public.inpatient_claims_new -${logic.psql-only} alter column clm_id SET NOT NULL, -${logic.psql-only} alter column bene_id SET NOT NULL, -${logic.psql-only} alter column clm_grp_id SET NOT NULL, -${logic.psql-only} alter column clm_from_dt SET NOT NULL, -${logic.psql-only} alter column clm_thru_dt SET NOT NULL, -${logic.psql-only} alter column clm_fac_type_cd SET NOT NULL, -${logic.psql-only} alter column clm_freq_cd SET NOT NULL, -${logic.psql-only} alter column final_action SET NOT NULL, -${logic.psql-only} alter column clm_tot_chrg_amt SET NOT NULL, -${logic.psql-only} alter column clm_pmt_amt SET NOT NULL, -${logic.psql-only} alter column clm_pass_thru_per_diem_amt SET NOT NULL, -${logic.psql-only} alter column clm_ip_admsn_type_cd SET NOT NULL, -${logic.psql-only} alter column clm_non_utlztn_days_cnt SET NOT NULL, -${logic.psql-only} alter column clm_utlztn_day_cnt SET NOT NULL, -${logic.psql-only} alter column clm_drg_outlier_stay_cd SET NOT NULL, -${logic.psql-only} alter column claim_query_code SET NOT NULL, -${logic.psql-only} alter column clm_srvc_clsfctn_type_cd SET NOT NULL, -${logic.psql-only} alter column prvdr_num SET NOT NULL, -${logic.psql-only} alter column prvdr_state_cd SET NOT NULL, -${logic.psql-only} alter column ptnt_dschrg_stus_cd SET NOT NULL, -${logic.psql-only} alter column bene_tot_coinsrnc_days_cnt SET NOT NULL, -${logic.psql-only} alter column nch_clm_type_cd SET NOT NULL, -${logic.psql-only} alter column nch_near_line_rec_ident_cd SET NOT NULL, -${logic.psql-only} alter column nch_blood_pnts_frnshd_qty SET NOT NULL, -${logic.psql-only} alter column nch_bene_blood_ddctbl_lblty_am SET NOT NULL, -${logic.psql-only} alter column nch_bene_ip_ddctbl_amt SET NOT NULL, -${logic.psql-only} alter column nch_bene_pta_coinsrnc_lblty_am SET NOT NULL, -${logic.psql-only} alter column nch_ip_ncvrd_chrg_amt SET NOT NULL, -${logic.psql-only} alter column nch_ip_tot_ddctn_amt SET NOT NULL, -${logic.psql-only} alter column nch_prmry_pyr_clm_pd_amt SET NOT NULL, -${logic.psql-only} alter column nch_profnl_cmpnt_chrg_amt SET NOT NULL, -${logic.psql-only} alter column nch_wkly_proc_dt SET NOT NULL; - --- migrate data via INSERT from current INPATIENT_CLAIM_LINES table to INPATIENT_CLAIM_LINES_NEW table --- -${logic.hsql-only} insert into public.inpatient_claim_lines_new ( -${logic.hsql-only} clm_id, -${logic.hsql-only} clm_line_num, -${logic.hsql-only} rev_cntr, -${logic.hsql-only} rev_cntr_unit_cnt, -${logic.hsql-only} rev_cntr_rate_amt, -${logic.hsql-only} rev_cntr_tot_chrg_amt, -${logic.hsql-only} rev_cntr_ncvrd_chrg_amt, -${logic.hsql-only} rev_cntr_ddctbl_coinsrnc_cd, -${logic.hsql-only} rev_cntr_ndc_qty_qlfr_cd, -${logic.hsql-only} rev_cntr_ndc_qty, -${logic.hsql-only} hcpcs_cd, -${logic.hsql-only} rndrng_physn_npi, -${logic.hsql-only} rndrng_physn_upin ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} create table public.inpatient_claim_lines_new as -select -${logic.hsql-only} convert(clm_id, SQL_BIGINT), -${logic.hsql-only} convert(clm_line_num, SQL_SMALLINT), -${logic.psql-only} clm_id::bigint, -${logic.psql-only} clm_line_num::smallint, - rev_cntr, - rev_cntr_unit_cnt, - rev_cntr_rate_amt, - rev_cntr_tot_chrg_amt, - rev_cntr_ncvrd_chrg_amt, - rev_cntr_ddctbl_coinsrnc_cd, - rev_cntr_ndc_qty_qlfr_cd, - rev_cntr_ndc_qty, - hcpcs_cd, - rndrng_physn_npi, - rndrng_physn_upin -from - public.inpatient_claim_lines; - --- for PSQL need to define our not null constraints; for HSQL, --- we explicitly defined a table structure before migrating data. --- -${logic.psql-only} alter table public.inpatient_claim_lines_new -${logic.psql-only} alter column clm_id SET NOT NULL, -${logic.psql-only} alter column clm_line_num SET NOT NULL, -${logic.psql-only} alter column rev_cntr SET NOT NULL, -${logic.psql-only} alter column rev_cntr_unit_cnt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_rate_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_tot_chrg_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_ncvrd_chrg_amt SET NOT NULL; - --- for PSQL need to define our primary key -${logic.psql-only} alter table public.inpatient_claims_new -${logic.psql-only} add CONSTRAINT inpatient_claims_new_pkey PRIMARY KEY (clm_id); - --- for PSQL need to define our primary key -${logic.psql-only} ALTER TABLE public.inpatient_claim_lines_new -${logic.psql-only} ADD CONSTRAINT inpatient_claim_lines_new_pkey PRIMARY KEY (clm_id, clm_line_num); - --- define foreign key constraints between claim lineitems and a parent claims table. -ALTER TABLE IF EXISTS public.inpatient_claim_lines_new - ADD CONSTRAINT inpatient_claim_lines_clm_id_to_inpatient_claims_new FOREIGN KEY (clm_id) - REFERENCES public.inpatient_claims_new (clm_id); - --- create an index of the BENE_ID in parent claims table -CREATE INDEX IF NOT EXISTS inpatient_claims_new_bene_id_idx - ON public.inpatient_claims_new (bene_id); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V73__new_schema_outpatient_claims.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V73__new_schema_outpatient_claims.sql deleted file mode 100644 index 95ebb3761c..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V73__new_schema_outpatient_claims.sql +++ /dev/null @@ -1,843 +0,0 @@ --- NEW_SCHEMA_OUTPATIENT_CLAIMS.SQL --- flyway migration for OUTPATIENT_CLAIMS and OUTPATIENT_CLAIM_LINES tables into --- a new schema structure that: --- 1) changes data type of CLM_ID, BENE_ID from varchar to BIGINT. --- 2) change data type of CLM_GRP_ID from numeric to BIGINT --- 3) organizes parent claim table (OUTPATIENT_CLAIMS) such that common --- claims data columns are organized at top of table structure. --- --- The following db columns were redefined from NUMERIC to more --- appropriate data type(s): --- --- clm_line_num - changed to smallint --- --- Once current table data is migrated to new table name/structure, a --- subsequent PR will be deployed that changes the ORM model(s) and --- operational code for Inpatient Claims table(s). --- --- HSQL differs from PSQL (postgres) in that the table defintion --- must be explicitly declared prior to loading data into the --- target table. PSQL can derive the table structure based on --- the data input (i.e., column name, data type). Thus, for HSQL, --- we need to explicitly define the table structure prior to loading data. --- --- For HSQL, explicitly define/create a new OUTPATIENT_CLAIMS_NEW table in --- the current PUBLIC schema - -${logic.hsql-only} create table public.outpatient_claims_new ( -${logic.hsql-only} clm_id bigint not null, -${logic.hsql-only} bene_id bigint not null, -${logic.hsql-only} clm_grp_id bigint not null, -${logic.hsql-only} last_updated timestamp with time zone, -${logic.hsql-only} clm_from_dt date not null, -${logic.hsql-only} clm_thru_dt date not null, -${logic.hsql-only} clm_fac_type_cd char(1) not null, -${logic.hsql-only} clm_freq_cd char(1) not null, -${logic.hsql-only} final_action char(1) not null, -${logic.hsql-only} clm_tot_chrg_amt numeric(12,2) not null, -${logic.hsql-only} clm_pmt_amt numeric(12,2) not null, -${logic.hsql-only} clm_op_bene_pmt_amt numeric(12,2) not null, -${logic.hsql-only} clm_op_prvdr_pmt_amt numeric(12,2) not null, -${logic.hsql-only} claim_query_code char(1) not null, -${logic.hsql-only} clm_srvc_clsfctn_type_cd char(1) not null, -${logic.hsql-only} clm_mdcr_non_pmt_rsn_cd varchar(2), -${logic.hsql-only} clm_mco_pd_sw char(1), -${logic.hsql-only} nch_clm_type_cd varchar(2) not null, -${logic.hsql-only} nch_near_line_rec_ident_cd char(1) not null, -${logic.hsql-only} nch_wkly_proc_dt date not null, -${logic.hsql-only} nch_bene_blood_ddctbl_lblty_am numeric(12,2) not null, -${logic.hsql-only} nch_bene_ptb_coinsrnc_amt numeric(12,2) not null, -${logic.hsql-only} nch_bene_ptb_ddctbl_amt numeric(12,2) not null, -${logic.hsql-only} nch_prmry_pyr_clm_pd_amt numeric(12,2) not null, -${logic.hsql-only} nch_profnl_cmpnt_chrg_amt numeric(12,2) not null, -${logic.hsql-only} nch_prmry_pyr_cd char(1), -${logic.hsql-only} prvdr_num varchar(9) not null, -${logic.hsql-only} prvdr_state_cd varchar(2) not null, -${logic.hsql-only} at_physn_npi varchar(10), -${logic.hsql-only} at_physn_upin varchar(9), -${logic.hsql-only} op_physn_npi varchar(10), -${logic.hsql-only} op_physn_upin varchar(9), -${logic.hsql-only} ot_physn_npi varchar(10), -${logic.hsql-only} ot_physn_upin varchar(9), -${logic.hsql-only} org_npi_num varchar(10), -${logic.hsql-only} prncpal_dgns_cd varchar(7), -${logic.hsql-only} prncpal_dgns_vrsn_cd char(1), -${logic.hsql-only} ptnt_dschrg_stus_cd varchar(2), -${logic.hsql-only} fi_clm_proc_dt date, -${logic.hsql-only} fi_doc_clm_cntl_num varchar(23), -${logic.hsql-only} fi_num varchar(5), -${logic.hsql-only} fi_orig_clm_cntl_num varchar(23), -${logic.hsql-only} fst_dgns_e_cd varchar(7), -${logic.hsql-only} fst_dgns_e_vrsn_cd char(1), -${logic.hsql-only} rsn_visit_cd1 varchar(7), -${logic.hsql-only} rsn_visit_vrsn_cd1 char(1), -${logic.hsql-only} rsn_visit_cd2 varchar(7), -${logic.hsql-only} rsn_visit_vrsn_cd2 char(1), -${logic.hsql-only} rsn_visit_cd3 varchar(7), -${logic.hsql-only} rsn_visit_vrsn_cd3 char(1), -${logic.hsql-only} prcdr_dt1 date, -${logic.hsql-only} icd_dgns_cd1 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd1 char(1), -${logic.hsql-only} icd_prcdr_cd1 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd1 char(1), -${logic.hsql-only} icd_dgns_e_cd1 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd1 char(1), -${logic.hsql-only} prcdr_dt2 date, -${logic.hsql-only} icd_dgns_cd2 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd2 char(1), -${logic.hsql-only} icd_prcdr_cd2 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd2 char(1), -${logic.hsql-only} icd_dgns_e_cd2 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd2 char(1), -${logic.hsql-only} prcdr_dt3 date, -${logic.hsql-only} icd_dgns_cd3 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd3 char(1), -${logic.hsql-only} icd_prcdr_cd3 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd3 char(1), -${logic.hsql-only} icd_dgns_e_cd3 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd3 char(1), -${logic.hsql-only} prcdr_dt4 date, -${logic.hsql-only} icd_dgns_cd4 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd4 char(1), -${logic.hsql-only} icd_prcdr_cd4 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd4 char(1), -${logic.hsql-only} icd_dgns_e_cd4 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd4 char(1), -${logic.hsql-only} prcdr_dt5 date, -${logic.hsql-only} icd_dgns_cd5 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd5 char(1), -${logic.hsql-only} icd_prcdr_cd5 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd5 char(1), -${logic.hsql-only} icd_dgns_e_cd5 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd5 char(1), -${logic.hsql-only} prcdr_dt6 date, -${logic.hsql-only} icd_dgns_cd6 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd6 char(1), -${logic.hsql-only} icd_prcdr_cd6 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd6 char(1), -${logic.hsql-only} icd_dgns_e_cd6 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd6 char(1), -${logic.hsql-only} prcdr_dt7 date, -${logic.hsql-only} icd_dgns_cd7 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd7 char(1), -${logic.hsql-only} icd_prcdr_cd7 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd7 char(1), -${logic.hsql-only} icd_dgns_e_cd7 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd7 char(1), -${logic.hsql-only} prcdr_dt8 date, -${logic.hsql-only} icd_dgns_cd8 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd8 char(1), -${logic.hsql-only} icd_prcdr_cd8 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd8 char(1), -${logic.hsql-only} icd_dgns_e_cd8 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd8 char(1), -${logic.hsql-only} prcdr_dt9 date, -${logic.hsql-only} icd_dgns_cd9 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd9 char(1), -${logic.hsql-only} icd_prcdr_cd9 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd9 char(1), -${logic.hsql-only} icd_dgns_e_cd9 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd9 char(1), -${logic.hsql-only} prcdr_dt10 date, -${logic.hsql-only} icd_dgns_cd10 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd10 char(1), -${logic.hsql-only} icd_prcdr_cd10 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd10 char(1), -${logic.hsql-only} icd_dgns_e_cd10 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd10 char(1), -${logic.hsql-only} prcdr_dt11 date, -${logic.hsql-only} icd_dgns_cd11 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd11 char(1), -${logic.hsql-only} icd_prcdr_cd11 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd11 char(1), -${logic.hsql-only} icd_dgns_e_cd11 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd11 char(1), -${logic.hsql-only} prcdr_dt12 date, -${logic.hsql-only} icd_dgns_cd12 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd12 char(1), -${logic.hsql-only} icd_prcdr_cd12 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd12 char(1), -${logic.hsql-only} icd_dgns_e_cd12 varchar(7), -${logic.hsql-only} icd_dgns_e_vrsn_cd12 char(1), -${logic.hsql-only} prcdr_dt13 date, -${logic.hsql-only} icd_dgns_cd13 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd13 char(1), -${logic.hsql-only} icd_prcdr_cd13 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd13 char(1), -${logic.hsql-only} prcdr_dt14 date, -${logic.hsql-only} icd_dgns_cd14 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd14 char(1), -${logic.hsql-only} icd_prcdr_cd14 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd14 char(1), -${logic.hsql-only} prcdr_dt15 date, -${logic.hsql-only} icd_dgns_cd15 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd15 char(1), -${logic.hsql-only} icd_prcdr_cd15 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd15 char(1), -${logic.hsql-only} prcdr_dt16 date, -${logic.hsql-only} icd_dgns_cd16 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd16 char(1), -${logic.hsql-only} icd_prcdr_cd16 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd16 char(1), -${logic.hsql-only} prcdr_dt17 date, -${logic.hsql-only} icd_dgns_cd17 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd17 char(1), -${logic.hsql-only} icd_prcdr_cd17 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd17 char(1), -${logic.hsql-only} prcdr_dt18 date, -${logic.hsql-only} icd_dgns_cd18 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd18 char(1), -${logic.hsql-only} icd_prcdr_cd18 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd18 char(1), -${logic.hsql-only} prcdr_dt19 date, -${logic.hsql-only} icd_dgns_cd19 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd19 char(1), -${logic.hsql-only} icd_prcdr_cd19 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd19 char(1), -${logic.hsql-only} prcdr_dt20 date, -${logic.hsql-only} icd_dgns_cd20 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd20 char(1), -${logic.hsql-only} icd_prcdr_cd20 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd20 char(1), -${logic.hsql-only} prcdr_dt21 date, -${logic.hsql-only} icd_dgns_cd21 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd21 char(1), -${logic.hsql-only} icd_prcdr_cd21 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd21 char(1), -${logic.hsql-only} prcdr_dt22 date, -${logic.hsql-only} icd_dgns_cd22 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd22 char(1), -${logic.hsql-only} icd_prcdr_cd22 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd22 char(1), -${logic.hsql-only} prcdr_dt23 date, -${logic.hsql-only} icd_dgns_cd23 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd23 char(1), -${logic.hsql-only} icd_prcdr_cd23 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd23 char(1), -${logic.hsql-only} prcdr_dt24 date, -${logic.hsql-only} icd_dgns_cd24 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd24 char(1), -${logic.hsql-only} icd_prcdr_cd24 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd24 char(1), -${logic.hsql-only} prcdr_dt25 date, -${logic.hsql-only} icd_dgns_cd25 varchar(7), -${logic.hsql-only} icd_dgns_vrsn_cd25 char(1), -${logic.hsql-only} icd_prcdr_cd25 varchar(7), -${logic.hsql-only} icd_prcdr_vrsn_cd25 char(1), -${logic.hsql-only} constraint public.outpatient_claims_new_pkey -${logic.hsql-only} primary key (clm_id) ); --- --- create a new OUTPATIENT_CLAIM_LINES_NEW table in the current PUBLIC schema --- -${logic.hsql-only} create table public.outpatient_claim_lines_new ( -${logic.hsql-only} clm_id bigint not null, -${logic.hsql-only} clm_line_num smallint not null, -${logic.hsql-only} rev_cntr varchar(4) not null, -${logic.hsql-only} rev_cntr_unit_cnt numeric not null, -${logic.hsql-only} rev_cntr_rate_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_tot_chrg_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_ncvrd_chrg_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_coinsrnc_wge_adjstd_c numeric(12,2) not null, -${logic.hsql-only} rev_cntr_bene_pmt_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_blood_ddctbl_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_cash_ddctbl_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_rdcd_coinsrnc_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_pmt_amt_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_prvdr_pmt_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_dt date, -${logic.hsql-only} rev_cntr_ptnt_rspnsblty_pmt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_ndc_qty_qlfr_cd varchar(2), -${logic.hsql-only} rev_cntr_ndc_qty numeric, -${logic.hsql-only} rev_cntr_1st_ansi_cd varchar(5), -${logic.hsql-only} rev_cntr_1st_msp_pd_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_2nd_ansi_cd varchar(5), -${logic.hsql-only} rev_cntr_2nd_msp_pd_amt numeric(12,2) not null, -${logic.hsql-only} rev_cntr_3rd_ansi_cd varchar(5), -${logic.hsql-only} rev_cntr_4th_ansi_cd varchar(5), -${logic.hsql-only} rev_cntr_apc_hipps_cd varchar(5), -${logic.hsql-only} rev_cntr_dscnt_ind_cd char(1), -${logic.hsql-only} rev_cntr_ide_ndc_upc_num varchar(24), -${logic.hsql-only} rev_cntr_otaf_pmt_cd char(1), -${logic.hsql-only} rev_cntr_packg_ind_cd char(1), -${logic.hsql-only} rev_cntr_pmt_mthd_ind_cd varchar(2), -${logic.hsql-only} rev_cntr_stus_ind_cd varchar(2), -${logic.hsql-only} hcpcs_cd varchar(5), -${logic.hsql-only} hcpcs_2nd_mdfr_cd varchar(5), -${logic.hsql-only} hcpcs_1st_mdfr_cd varchar(5), -${logic.hsql-only} rndrng_physn_npi varchar(12), -${logic.hsql-only} rndrng_physn_upin varchar(12), -${logic.hsql-only} constraint public.outpatient_claim_lines_new_pkey -${logic.hsql-only} primary key (clm_id, clm_line_num) ); --- --- migrate data via INSERT from current INPATIENT_CLAIMS table to INPATIENT_CLAIMS_NEW table --- -${logic.psql-only} SET max_parallel_workers = 24; -${logic.psql-only} SET max_parallel_workers_per_gather = 20; -${logic.psql-only} SET parallel_leader_participation = off; -${logic.psql-only} SET parallel_tuple_cost = 0; -${logic.psql-only} SET parallel_setup_cost = 0; - -${logic.hsql-only} insert into public.outpatient_claims_new ( -${logic.hsql-only} clm_id, -${logic.hsql-only} bene_id, -${logic.hsql-only} clm_grp_id, -${logic.hsql-only} last_updated, -${logic.hsql-only} clm_from_dt, -${logic.hsql-only} clm_thru_dt, -${logic.hsql-only} clm_fac_type_cd, -${logic.hsql-only} clm_freq_cd, -${logic.hsql-only} final_action, -${logic.hsql-only} clm_tot_chrg_amt, -${logic.hsql-only} clm_pmt_amt, -${logic.hsql-only} clm_op_bene_pmt_amt, -${logic.hsql-only} clm_op_prvdr_pmt_amt, -${logic.hsql-only} claim_query_code, -${logic.hsql-only} clm_srvc_clsfctn_type_cd, -${logic.hsql-only} clm_mdcr_non_pmt_rsn_cd, -${logic.hsql-only} clm_mco_pd_sw, -${logic.hsql-only} nch_clm_type_cd, -${logic.hsql-only} nch_near_line_rec_ident_cd, -${logic.hsql-only} nch_wkly_proc_dt, -${logic.hsql-only} nch_bene_blood_ddctbl_lblty_am, -${logic.hsql-only} nch_bene_ptb_coinsrnc_amt, -${logic.hsql-only} nch_bene_ptb_ddctbl_amt, -${logic.hsql-only} nch_prmry_pyr_clm_pd_amt, -${logic.hsql-only} nch_profnl_cmpnt_chrg_amt, -${logic.hsql-only} nch_prmry_pyr_cd, -${logic.hsql-only} prvdr_num, -${logic.hsql-only} prvdr_state_cd, -${logic.hsql-only} at_physn_npi, -${logic.hsql-only} at_physn_upin, -${logic.hsql-only} op_physn_npi, -${logic.hsql-only} op_physn_upin, -${logic.hsql-only} ot_physn_npi, -${logic.hsql-only} ot_physn_upin, -${logic.hsql-only} org_npi_num, -${logic.hsql-only} prncpal_dgns_cd, -${logic.hsql-only} prncpal_dgns_vrsn_cd, -${logic.hsql-only} ptnt_dschrg_stus_cd, -${logic.hsql-only} fi_clm_proc_dt, -${logic.hsql-only} fi_doc_clm_cntl_num, -${logic.hsql-only} fi_num, -${logic.hsql-only} fi_orig_clm_cntl_num, -${logic.hsql-only} fst_dgns_e_cd, -${logic.hsql-only} fst_dgns_e_vrsn_cd, -${logic.hsql-only} rsn_visit_cd1, -${logic.hsql-only} rsn_visit_vrsn_cd1, -${logic.hsql-only} rsn_visit_cd2, -${logic.hsql-only} rsn_visit_vrsn_cd2, -${logic.hsql-only} rsn_visit_cd3, -${logic.hsql-only} rsn_visit_vrsn_cd3, -${logic.hsql-only} prcdr_dt1, -${logic.hsql-only} icd_dgns_cd1, -${logic.hsql-only} icd_dgns_vrsn_cd1, -${logic.hsql-only} icd_prcdr_cd1, -${logic.hsql-only} icd_prcdr_vrsn_cd1, -${logic.hsql-only} icd_dgns_e_cd1, -${logic.hsql-only} icd_dgns_e_vrsn_cd1, -${logic.hsql-only} prcdr_dt2, -${logic.hsql-only} icd_dgns_cd2, -${logic.hsql-only} icd_dgns_vrsn_cd2, -${logic.hsql-only} icd_prcdr_cd2, -${logic.hsql-only} icd_prcdr_vrsn_cd2, -${logic.hsql-only} icd_dgns_e_cd2, -${logic.hsql-only} icd_dgns_e_vrsn_cd2, -${logic.hsql-only} prcdr_dt3, -${logic.hsql-only} icd_dgns_cd3, -${logic.hsql-only} icd_dgns_vrsn_cd3, -${logic.hsql-only} icd_prcdr_cd3, -${logic.hsql-only} icd_prcdr_vrsn_cd3, -${logic.hsql-only} icd_dgns_e_cd3, -${logic.hsql-only} icd_dgns_e_vrsn_cd3, -${logic.hsql-only} prcdr_dt4, -${logic.hsql-only} icd_dgns_cd4, -${logic.hsql-only} icd_dgns_vrsn_cd4, -${logic.hsql-only} icd_prcdr_cd4, -${logic.hsql-only} icd_prcdr_vrsn_cd4, -${logic.hsql-only} icd_dgns_e_cd4, -${logic.hsql-only} icd_dgns_e_vrsn_cd4, -${logic.hsql-only} prcdr_dt5, -${logic.hsql-only} icd_dgns_cd5, -${logic.hsql-only} icd_dgns_vrsn_cd5, -${logic.hsql-only} icd_prcdr_cd5, -${logic.hsql-only} icd_prcdr_vrsn_cd5, -${logic.hsql-only} icd_dgns_e_cd5, -${logic.hsql-only} icd_dgns_e_vrsn_cd5, -${logic.hsql-only} prcdr_dt6, -${logic.hsql-only} icd_dgns_cd6, -${logic.hsql-only} icd_dgns_vrsn_cd6, -${logic.hsql-only} icd_prcdr_cd6, -${logic.hsql-only} icd_prcdr_vrsn_cd6, -${logic.hsql-only} icd_dgns_e_cd6, -${logic.hsql-only} icd_dgns_e_vrsn_cd6, -${logic.hsql-only} prcdr_dt7, -${logic.hsql-only} icd_dgns_cd7, -${logic.hsql-only} icd_dgns_vrsn_cd7, -${logic.hsql-only} icd_prcdr_cd7, -${logic.hsql-only} icd_prcdr_vrsn_cd7, -${logic.hsql-only} icd_dgns_e_cd7, -${logic.hsql-only} icd_dgns_e_vrsn_cd7, -${logic.hsql-only} prcdr_dt8, -${logic.hsql-only} icd_dgns_cd8, -${logic.hsql-only} icd_dgns_vrsn_cd8, -${logic.hsql-only} icd_prcdr_cd8, -${logic.hsql-only} icd_prcdr_vrsn_cd8, -${logic.hsql-only} icd_dgns_e_cd8, -${logic.hsql-only} icd_dgns_e_vrsn_cd8, -${logic.hsql-only} prcdr_dt9, -${logic.hsql-only} icd_dgns_cd9, -${logic.hsql-only} icd_dgns_vrsn_cd9, -${logic.hsql-only} icd_prcdr_cd9, -${logic.hsql-only} icd_prcdr_vrsn_cd9, -${logic.hsql-only} icd_dgns_e_cd9, -${logic.hsql-only} icd_dgns_e_vrsn_cd9, -${logic.hsql-only} prcdr_dt10, -${logic.hsql-only} icd_dgns_cd10, -${logic.hsql-only} icd_dgns_vrsn_cd10, -${logic.hsql-only} icd_prcdr_cd10, -${logic.hsql-only} icd_prcdr_vrsn_cd10, -${logic.hsql-only} icd_dgns_e_cd10, -${logic.hsql-only} icd_dgns_e_vrsn_cd10, -${logic.hsql-only} prcdr_dt11, -${logic.hsql-only} icd_dgns_cd11, -${logic.hsql-only} icd_dgns_vrsn_cd11, -${logic.hsql-only} icd_prcdr_cd11, -${logic.hsql-only} icd_prcdr_vrsn_cd11, -${logic.hsql-only} icd_dgns_e_cd11, -${logic.hsql-only} icd_dgns_e_vrsn_cd11, -${logic.hsql-only} prcdr_dt12, -${logic.hsql-only} icd_dgns_cd12, -${logic.hsql-only} icd_dgns_vrsn_cd12, -${logic.hsql-only} icd_prcdr_cd12, -${logic.hsql-only} icd_prcdr_vrsn_cd12, -${logic.hsql-only} icd_dgns_e_cd12, -${logic.hsql-only} icd_dgns_e_vrsn_cd12, -${logic.hsql-only} prcdr_dt13, -${logic.hsql-only} icd_dgns_cd13, -${logic.hsql-only} icd_dgns_vrsn_cd13, -${logic.hsql-only} icd_prcdr_cd13, -${logic.hsql-only} icd_prcdr_vrsn_cd13, -${logic.hsql-only} prcdr_dt14, -${logic.hsql-only} icd_dgns_cd14, -${logic.hsql-only} icd_dgns_vrsn_cd14, -${logic.hsql-only} icd_prcdr_cd14, -${logic.hsql-only} icd_prcdr_vrsn_cd14, -${logic.hsql-only} prcdr_dt15, -${logic.hsql-only} icd_dgns_cd15, -${logic.hsql-only} icd_dgns_vrsn_cd15, -${logic.hsql-only} icd_prcdr_cd15, -${logic.hsql-only} icd_prcdr_vrsn_cd15, -${logic.hsql-only} prcdr_dt16, -${logic.hsql-only} icd_dgns_cd16, -${logic.hsql-only} icd_dgns_vrsn_cd16, -${logic.hsql-only} icd_prcdr_cd16, -${logic.hsql-only} icd_prcdr_vrsn_cd16, -${logic.hsql-only} prcdr_dt17, -${logic.hsql-only} icd_dgns_cd17, -${logic.hsql-only} icd_dgns_vrsn_cd17, -${logic.hsql-only} icd_prcdr_cd17, -${logic.hsql-only} icd_prcdr_vrsn_cd17, -${logic.hsql-only} prcdr_dt18, -${logic.hsql-only} icd_dgns_cd18, -${logic.hsql-only} icd_dgns_vrsn_cd18, -${logic.hsql-only} icd_prcdr_cd18, -${logic.hsql-only} icd_prcdr_vrsn_cd18, -${logic.hsql-only} prcdr_dt19, -${logic.hsql-only} icd_dgns_cd19, -${logic.hsql-only} icd_dgns_vrsn_cd19, -${logic.hsql-only} icd_prcdr_cd19, -${logic.hsql-only} icd_prcdr_vrsn_cd19, -${logic.hsql-only} prcdr_dt20, -${logic.hsql-only} icd_dgns_cd20, -${logic.hsql-only} icd_dgns_vrsn_cd20, -${logic.hsql-only} icd_prcdr_cd20, -${logic.hsql-only} icd_prcdr_vrsn_cd20, -${logic.hsql-only} prcdr_dt21, -${logic.hsql-only} icd_dgns_cd21, -${logic.hsql-only} icd_dgns_vrsn_cd21, -${logic.hsql-only} icd_prcdr_cd21, -${logic.hsql-only} icd_prcdr_vrsn_cd21, -${logic.hsql-only} prcdr_dt22, -${logic.hsql-only} icd_dgns_cd22, -${logic.hsql-only} icd_dgns_vrsn_cd22, -${logic.hsql-only} icd_prcdr_cd22, -${logic.hsql-only} icd_prcdr_vrsn_cd22, -${logic.hsql-only} prcdr_dt23, -${logic.hsql-only} icd_dgns_cd23, -${logic.hsql-only} icd_dgns_vrsn_cd23, -${logic.hsql-only} icd_prcdr_cd23, -${logic.hsql-only} icd_prcdr_vrsn_cd23, -${logic.hsql-only} prcdr_dt24, -${logic.hsql-only} icd_dgns_cd24, -${logic.hsql-only} icd_dgns_vrsn_cd24, -${logic.hsql-only} icd_prcdr_cd24, -${logic.hsql-only} icd_prcdr_vrsn_cd24, -${logic.hsql-only} prcdr_dt25, -${logic.hsql-only} icd_dgns_cd25, -${logic.hsql-only} icd_dgns_vrsn_cd25, -${logic.hsql-only} icd_prcdr_cd25, -${logic.hsql-only} icd_prcdr_vrsn_cd25 ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} create table public.outpatient_claims_new as -select -${logic.hsql-only} convert(clm_id, SQL_BIGINT), -${logic.hsql-only} convert(bene_id, SQL_BIGINT), -${logic.hsql-only} convert(clm_grp_id, SQL_BIGINT), -${logic.psql-only} clm_id::bigint, -${logic.psql-only} bene_id::bigint, -${logic.psql-only} clm_grp_id::bigint, - last_updated, - clm_from_dt, - clm_thru_dt, - clm_fac_type_cd, - clm_freq_cd, - final_action, - clm_tot_chrg_amt, - clm_pmt_amt, - clm_op_bene_pmt_amt, - clm_op_prvdr_pmt_amt, - claim_query_code, - clm_srvc_clsfctn_type_cd, - clm_mdcr_non_pmt_rsn_cd, - clm_mco_pd_sw, - nch_clm_type_cd, - nch_near_line_rec_ident_cd, - nch_wkly_proc_dt, - nch_bene_blood_ddctbl_lblty_am, - nch_bene_ptb_coinsrnc_amt, - nch_bene_ptb_ddctbl_amt, - nch_prmry_pyr_clm_pd_amt, - nch_profnl_cmpnt_chrg_amt, - nch_prmry_pyr_cd, - prvdr_num, - prvdr_state_cd, - at_physn_npi, - at_physn_upin, - op_physn_npi, - op_physn_upin, - ot_physn_npi, - ot_physn_upin, - org_npi_num, - prncpal_dgns_cd, - prncpal_dgns_vrsn_cd, - ptnt_dschrg_stus_cd, - fi_clm_proc_dt, - fi_doc_clm_cntl_num, - fi_num, - fi_orig_clm_cntl_num, - fst_dgns_e_cd, - fst_dgns_e_vrsn_cd, - rsn_visit_cd1, - rsn_visit_vrsn_cd1, - rsn_visit_cd2, - rsn_visit_vrsn_cd2, - rsn_visit_cd3, - rsn_visit_vrsn_cd3, - prcdr_dt1, - icd_dgns_cd1, - icd_dgns_vrsn_cd1, - icd_prcdr_cd1, - icd_prcdr_vrsn_cd1, - icd_dgns_e_cd1, - icd_dgns_e_vrsn_cd1, - prcdr_dt2, - icd_dgns_cd2, - icd_dgns_vrsn_cd2, - icd_prcdr_cd2, - icd_prcdr_vrsn_cd2, - icd_dgns_e_cd2, - icd_dgns_e_vrsn_cd2, - prcdr_dt3, - icd_dgns_cd3, - icd_dgns_vrsn_cd3, - icd_prcdr_cd3, - icd_prcdr_vrsn_cd3, - icd_dgns_e_cd3, - icd_dgns_e_vrsn_cd3, - prcdr_dt4, - icd_dgns_cd4, - icd_dgns_vrsn_cd4, - icd_prcdr_cd4, - icd_prcdr_vrsn_cd4, - icd_dgns_e_cd4, - icd_dgns_e_vrsn_cd4, - prcdr_dt5, - icd_dgns_cd5, - icd_dgns_vrsn_cd5, - icd_prcdr_cd5, - icd_prcdr_vrsn_cd5, - icd_dgns_e_cd5, - icd_dgns_e_vrsn_cd5, - prcdr_dt6, - icd_dgns_cd6, - icd_dgns_vrsn_cd6, - icd_prcdr_cd6, - icd_prcdr_vrsn_cd6, - icd_dgns_e_cd6, - icd_dgns_e_vrsn_cd6, - prcdr_dt7, - icd_dgns_cd7, - icd_dgns_vrsn_cd7, - icd_prcdr_cd7, - icd_prcdr_vrsn_cd7, - icd_dgns_e_cd7, - icd_dgns_e_vrsn_cd7, - prcdr_dt8, - icd_dgns_cd8, - icd_dgns_vrsn_cd8, - icd_prcdr_cd8, - icd_prcdr_vrsn_cd8, - icd_dgns_e_cd8, - icd_dgns_e_vrsn_cd8, - prcdr_dt9, - icd_dgns_cd9, - icd_dgns_vrsn_cd9, - icd_prcdr_cd9, - icd_prcdr_vrsn_cd9, - icd_dgns_e_cd9, - icd_dgns_e_vrsn_cd9, - prcdr_dt10, - icd_dgns_cd10, - icd_dgns_vrsn_cd10, - icd_prcdr_cd10, - icd_prcdr_vrsn_cd10, - icd_dgns_e_cd10, - icd_dgns_e_vrsn_cd10, - prcdr_dt11, - icd_dgns_cd11, - icd_dgns_vrsn_cd11, - icd_prcdr_cd11, - icd_prcdr_vrsn_cd11, - icd_dgns_e_cd11, - icd_dgns_e_vrsn_cd11, - prcdr_dt12, - icd_dgns_cd12, - icd_dgns_vrsn_cd12, - icd_prcdr_cd12, - icd_prcdr_vrsn_cd12, - icd_dgns_e_cd12, - icd_dgns_e_vrsn_cd12, - prcdr_dt13, - icd_dgns_cd13, - icd_dgns_vrsn_cd13, - icd_prcdr_cd13, - icd_prcdr_vrsn_cd13, - prcdr_dt14, - icd_dgns_cd14, - icd_dgns_vrsn_cd14, - icd_prcdr_cd14, - icd_prcdr_vrsn_cd14, - prcdr_dt15, - icd_dgns_cd15, - icd_dgns_vrsn_cd15, - icd_prcdr_cd15, - icd_prcdr_vrsn_cd15, - prcdr_dt16, - icd_dgns_cd16, - icd_dgns_vrsn_cd16, - icd_prcdr_cd16, - icd_prcdr_vrsn_cd16, - prcdr_dt17, - icd_dgns_cd17, - icd_dgns_vrsn_cd17, - icd_prcdr_cd17, - icd_prcdr_vrsn_cd17, - prcdr_dt18, - icd_dgns_cd18, - icd_dgns_vrsn_cd18, - icd_prcdr_cd18, - icd_prcdr_vrsn_cd18, - prcdr_dt19, - icd_dgns_cd19, - icd_dgns_vrsn_cd19, - icd_prcdr_cd19, - icd_prcdr_vrsn_cd19, - prcdr_dt20, - icd_dgns_cd20, - icd_dgns_vrsn_cd20, - icd_prcdr_cd20, - icd_prcdr_vrsn_cd20, - prcdr_dt21, - icd_dgns_cd21, - icd_dgns_vrsn_cd21, - icd_prcdr_cd21, - icd_prcdr_vrsn_cd21, - prcdr_dt22, - icd_dgns_cd22, - icd_dgns_vrsn_cd22, - icd_prcdr_cd22, - icd_prcdr_vrsn_cd22, - prcdr_dt23, - icd_dgns_cd23, - icd_dgns_vrsn_cd23, - icd_prcdr_cd23, - icd_prcdr_vrsn_cd23, - prcdr_dt24, - icd_dgns_cd24, - icd_dgns_vrsn_cd24, - icd_prcdr_cd24, - icd_prcdr_vrsn_cd24, - prcdr_dt25, - icd_dgns_cd25, - icd_dgns_vrsn_cd25, - icd_prcdr_cd25, - icd_prcdr_vrsn_cd25 -from - public.outpatient_claims; - --- for PSQL need to define our not null constraints; for HSQL, --- we explicitly defined a table structure before migrating data. --- -${logic.psql-only} alter table public.outpatient_claims_new -${logic.psql-only} alter column clm_id SET NOT NULL, -${logic.psql-only} alter column bene_id SET NOT NULL, -${logic.psql-only} alter column clm_grp_id SET NOT NULL, -${logic.psql-only} alter column clm_from_dt SET NOT NULL, -${logic.psql-only} alter column clm_thru_dt SET NOT NULL, -${logic.psql-only} alter column clm_fac_type_cd SET NOT NULL, -${logic.psql-only} alter column clm_freq_cd SET NOT NULL, -${logic.psql-only} alter column final_action SET NOT NULL, -${logic.psql-only} alter column clm_tot_chrg_amt SET NOT NULL, -${logic.psql-only} alter column clm_pmt_amt SET NOT NULL, -${logic.psql-only} alter column clm_op_bene_pmt_amt SET NOT NULL, -${logic.psql-only} alter column clm_op_prvdr_pmt_amt SET NOT NULL, -${logic.psql-only} alter column claim_query_code SET NOT NULL, -${logic.psql-only} alter column clm_srvc_clsfctn_type_cd SET NOT NULL, -${logic.psql-only} alter column nch_clm_type_cd SET NOT NULL, -${logic.psql-only} alter column nch_near_line_rec_ident_cd SET NOT NULL, -${logic.psql-only} alter column nch_wkly_proc_dt SET NOT NULL, -${logic.psql-only} alter column nch_bene_blood_ddctbl_lblty_am SET NOT NULL, -${logic.psql-only} alter column nch_bene_ptb_coinsrnc_amt SET NOT NULL, -${logic.psql-only} alter column nch_bene_ptb_ddctbl_amt SET NOT NULL, -${logic.psql-only} alter column nch_prmry_pyr_clm_pd_amt SET NOT NULL, -${logic.psql-only} alter column nch_profnl_cmpnt_chrg_amt SET NOT NULL, -${logic.psql-only} alter column prvdr_num SET NOT NULL, -${logic.psql-only} alter column prvdr_state_cd SET NOT NULL; - --- migrate data via INSERT from current INPATIENT_CLAIM_LINES table to INPATIENT_CLAIM_LINES_NEW table --- -${logic.hsql-only} insert into public.outpatient_claim_lines_new ( -${logic.hsql-only} clm_id, -${logic.hsql-only} clm_line_num, -${logic.hsql-only} rev_cntr, -${logic.hsql-only} rev_cntr_unit_cnt, -${logic.hsql-only} rev_cntr_rate_amt, -${logic.hsql-only} rev_cntr_tot_chrg_amt, -${logic.hsql-only} rev_cntr_ncvrd_chrg_amt, -${logic.hsql-only} rev_cntr_coinsrnc_wge_adjstd_c, -${logic.hsql-only} rev_cntr_bene_pmt_amt, -${logic.hsql-only} rev_cntr_blood_ddctbl_amt, -${logic.hsql-only} rev_cntr_cash_ddctbl_amt, -${logic.hsql-only} rev_cntr_rdcd_coinsrnc_amt, -${logic.hsql-only} rev_cntr_pmt_amt_amt, -${logic.hsql-only} rev_cntr_prvdr_pmt_amt, -${logic.hsql-only} rev_cntr_dt, -${logic.hsql-only} rev_cntr_ptnt_rspnsblty_pmt, -${logic.hsql-only} rev_cntr_ndc_qty_qlfr_cd, -${logic.hsql-only} rev_cntr_ndc_qty, -${logic.hsql-only} rev_cntr_1st_ansi_cd, -${logic.hsql-only} rev_cntr_1st_msp_pd_amt, -${logic.hsql-only} rev_cntr_2nd_ansi_cd, -${logic.hsql-only} rev_cntr_2nd_msp_pd_amt, -${logic.hsql-only} rev_cntr_3rd_ansi_cd, -${logic.hsql-only} rev_cntr_4th_ansi_cd, -${logic.hsql-only} rev_cntr_apc_hipps_cd, -${logic.hsql-only} rev_cntr_dscnt_ind_cd, -${logic.hsql-only} rev_cntr_ide_ndc_upc_num, -${logic.hsql-only} rev_cntr_otaf_pmt_cd, -${logic.hsql-only} rev_cntr_packg_ind_cd, -${logic.hsql-only} rev_cntr_pmt_mthd_ind_cd, -${logic.hsql-only} rev_cntr_stus_ind_cd, -${logic.hsql-only} hcpcs_cd, -${logic.hsql-only} hcpcs_2nd_mdfr_cd, -${logic.hsql-only} hcpcs_1st_mdfr_cd, -${logic.hsql-only} rndrng_physn_npi, -${logic.hsql-only} rndrng_physn_upin ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} create table public.outpatient_claim_lines_new as -select -${logic.hsql-only} convert(clm_id, SQL_BIGINT), -${logic.hsql-only} convert(clm_line_num, SQL_SMALLINT), -${logic.psql-only} clm_id::bigint, -${logic.psql-only} clm_line_num::smallint, - rev_cntr, - rev_cntr_unit_cnt, - rev_cntr_rate_amt, - rev_cntr_tot_chrg_amt, - rev_cntr_ncvrd_chrg_amt, - rev_cntr_coinsrnc_wge_adjstd_c, - rev_cntr_bene_pmt_amt, - rev_cntr_blood_ddctbl_amt, - rev_cntr_cash_ddctbl_amt, - rev_cntr_rdcd_coinsrnc_amt, - rev_cntr_pmt_amt_amt, - rev_cntr_prvdr_pmt_amt, - rev_cntr_dt, - rev_cntr_ptnt_rspnsblty_pmt, - rev_cntr_ndc_qty_qlfr_cd, - rev_cntr_ndc_qty, - rev_cntr_1st_ansi_cd, - rev_cntr_1st_msp_pd_amt, - rev_cntr_2nd_ansi_cd, - rev_cntr_2nd_msp_pd_amt, - rev_cntr_3rd_ansi_cd, - rev_cntr_4th_ansi_cd, - rev_cntr_apc_hipps_cd, - rev_cntr_dscnt_ind_cd, - rev_cntr_ide_ndc_upc_num, - rev_cntr_otaf_pmt_cd, - rev_cntr_packg_ind_cd, - rev_cntr_pmt_mthd_ind_cd, - rev_cntr_stus_ind_cd, - hcpcs_cd, - hcpcs_2nd_mdfr_cd, - hcpcs_1st_mdfr_cd, - rndrng_physn_npi, - rndrng_physn_upin -from - public.outpatient_claim_lines; - --- for PSQL need to define our not null constraints; for HSQL, --- we explicitly defined a table structure before migrating data. --- -${logic.psql-only} alter table public.outpatient_claim_lines_new -${logic.psql-only} alter column clm_id SET NOT NULL, -${logic.psql-only} alter column clm_line_num SET NOT NULL, -${logic.psql-only} alter column rev_cntr SET NOT NULL, -${logic.psql-only} alter column rev_cntr_unit_cnt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_rate_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_tot_chrg_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_ncvrd_chrg_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_coinsrnc_wge_adjstd_c SET NOT NULL, -${logic.psql-only} alter column rev_cntr_bene_pmt_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_blood_ddctbl_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_cash_ddctbl_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_rdcd_coinsrnc_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_pmt_amt_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_prvdr_pmt_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_ptnt_rspnsblty_pmt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_1st_msp_pd_amt SET NOT NULL, -${logic.psql-only} alter column rev_cntr_2nd_msp_pd_amt SET NOT NULL; - --- for PSQL need to define our primary key -${logic.psql-only} alter table public.outpatient_claims_new -${logic.psql-only} add CONSTRAINT outpatient_claims_new_pkey PRIMARY KEY (clm_id); - --- for PSQL need to define our primary key -${logic.psql-only} ALTER TABLE public.outpatient_claim_lines_new -${logic.psql-only} ADD CONSTRAINT outpatient_claim_lines_new_pkey PRIMARY KEY (clm_id, clm_line_num); - --- define foreign key constraints between claim lineitems and a parent claims table. -ALTER TABLE IF EXISTS public.outpatient_claim_lines_new - ADD CONSTRAINT outpatient_claim_lines_clm_id_to_outpatient_claims_new FOREIGN KEY (clm_id) - REFERENCES public.outpatient_claims_new (clm_id); - --- create an index of the BENE_ID in parent claims table -CREATE INDEX IF NOT EXISTS outpatient_claims_new_bene_id_idx - ON public.outpatient_claims_new (bene_id); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V74__new_schema_partd_events.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V74__new_schema_partd_events.sql deleted file mode 100644 index 9004f9841b..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V74__new_schema_partd_events.sql +++ /dev/null @@ -1,212 +0,0 @@ --- NEW_SCHEMA_PARTD_EVENTS.SQL --- flyway migration for PARTD_EVENTS table into --- a new schema structure that: --- 1) changes data type of PDE_ID, BENE_ID from varchar to BIGINT. --- 2) change data type of CLM_GRP_ID from numeric to BIGINT --- 3) organizes parent claim table (PARTD_EVENTS) such that common --- claims data columns are organized at top of table structure. --- --- Once current table data is migrated to new table name/structure, a --- subsequent PR will be deployed that changes the ORM model(s) and --- operational code for PartD Events table. --- --- HSQL differs from PSQL (postgres) in that the table defintion --- must be explicitly declared prior to loading data into the --- target table. PSQL can derive the table structure based on --- the data input (i.e., column name, data type). Thus, for HSQL, --- we need to explicitly define the table structure prior to loading data. --- --- For HSQL, explicitly define/create a new PARTD_EVENTS_NEW table in --- the current PUBLIC schema - -${logic.hsql-only} create table public.partd_events_new ( -${logic.hsql-only} pde_id bigint not null, -${logic.hsql-only} bene_id bigint not null, -${logic.hsql-only} clm_grp_id bigint not null, -${logic.hsql-only} last_updated timestamp with time zone, -${logic.hsql-only} final_action char(1) not null, -${logic.hsql-only} cmpnd_cd integer not null, -${logic.hsql-only} drug_cvrg_stus_cd char(1) not null, -${logic.hsql-only} days_suply_num numeric not null, -${logic.hsql-only} srvc_dt date not null, -${logic.hsql-only} pd_dt date, -${logic.hsql-only} fill_num numeric not null, -${logic.hsql-only} qty_dspnsd_num numeric(10,3) not null, -${logic.hsql-only} cvrd_d_plan_pd_amt numeric(8,2) not null, -${logic.hsql-only} gdc_abv_oopt_amt numeric(8,2) not null, -${logic.hsql-only} gdc_blw_oopt_amt numeric(8,2) not null, -${logic.hsql-only} lics_amt numeric(8,2) not null, -${logic.hsql-only} ncvrd_plan_pd_amt numeric(8,2) not null, -${logic.hsql-only} othr_troop_amt numeric(8,2) not null, -${logic.hsql-only} plro_amt numeric(8,2) not null, -${logic.hsql-only} ptnt_pay_amt numeric(8,2) not null, -${logic.hsql-only} rptd_gap_dscnt_num numeric(8,2) not null, -${logic.hsql-only} ptnt_rsdnc_cd varchar(2) not null, -${logic.hsql-only} tot_rx_cst_amt numeric(8,2) not null, -${logic.hsql-only} daw_prod_slctn_cd char(1) not null, -${logic.hsql-only} phrmcy_srvc_type_cd varchar(2) not null, -${logic.hsql-only} plan_cntrct_rec_id varchar(5) not null, -${logic.hsql-only} plan_pbp_rec_num varchar(3) not null, -${logic.hsql-only} prod_srvc_id varchar(19) not null, -${logic.hsql-only} prscrbr_id varchar(15) not null, -${logic.hsql-only} prscrbr_id_qlfyr_cd varchar(2) not null, -${logic.hsql-only} rx_srvc_rfrnc_num numeric(12,0) not null, -${logic.hsql-only} srvc_prvdr_id varchar(15) not null, -${logic.hsql-only} srvc_prvdr_id_qlfyr_cd varchar(2) not null, -${logic.hsql-only} adjstmt_dltn_cd char(1), -${logic.hsql-only} brnd_gnrc_cd char(1), -${logic.hsql-only} ctstrphc_cvrg_cd char(1), -${logic.hsql-only} dspnsng_stus_cd char(1), -${logic.hsql-only} nstd_frmt_cd char(1), -${logic.hsql-only} prcng_excptn_cd char(1), -${logic.hsql-only} rx_orgn_cd char(1), -${logic.hsql-only} submsn_clr_cd varchar(2), -${logic.hsql-only} constraint public.partd_events_new_pkey -${logic.hsql-only} primary key (pde_id) ); - --- migrate data via INSERT from current PARTD_EVENTS table to PARTD_EVENTS_NEW table --- -${logic.hsql-only} insert into public.partd_events_new ( -${logic.hsql-only} pde_id, -${logic.hsql-only} bene_id, -${logic.hsql-only} clm_grp_id, -${logic.hsql-only} last_updated, -${logic.hsql-only} final_action, -${logic.hsql-only} cmpnd_cd, -${logic.hsql-only} drug_cvrg_stus_cd, -${logic.hsql-only} days_suply_num, -${logic.hsql-only} srvc_dt, -${logic.hsql-only} pd_dt, -${logic.hsql-only} fill_num, -${logic.hsql-only} qty_dspnsd_num, -${logic.hsql-only} cvrd_d_plan_pd_amt, -${logic.hsql-only} gdc_abv_oopt_amt, -${logic.hsql-only} gdc_blw_oopt_amt, -${logic.hsql-only} lics_amt, -${logic.hsql-only} ncvrd_plan_pd_amt, -${logic.hsql-only} othr_troop_amt, -${logic.hsql-only} plro_amt, -${logic.hsql-only} ptnt_pay_amt, -${logic.hsql-only} rptd_gap_dscnt_num, -${logic.hsql-only} ptnt_rsdnc_cd, -${logic.hsql-only} tot_rx_cst_amt, -${logic.hsql-only} daw_prod_slctn_cd, -${logic.hsql-only} phrmcy_srvc_type_cd, -${logic.hsql-only} plan_cntrct_rec_id, -${logic.hsql-only} plan_pbp_rec_num, -${logic.hsql-only} prod_srvc_id, -${logic.hsql-only} prscrbr_id, -${logic.hsql-only} prscrbr_id_qlfyr_cd, -${logic.hsql-only} rx_srvc_rfrnc_num, -${logic.hsql-only} srvc_prvdr_id, -${logic.hsql-only} srvc_prvdr_id_qlfyr_cd, -${logic.hsql-only} adjstmt_dltn_cd, -${logic.hsql-only} brnd_gnrc_cd, -${logic.hsql-only} ctstrphc_cvrg_cd, -${logic.hsql-only} dspnsng_stus_cd, -${logic.hsql-only} nstd_frmt_cd, -${logic.hsql-only} prcng_excptn_cd, -${logic.hsql-only} rx_orgn_cd, -${logic.hsql-only} submsn_clr_cd ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} SET max_parallel_workers = 24; -${logic.psql-only} SET max_parallel_workers_per_gather = 20; -${logic.psql-only} SET parallel_leader_participation = off; -${logic.psql-only} SET parallel_tuple_cost = 0; -${logic.psql-only} SET parallel_setup_cost = 0; - -${logic.psql-only} create table public.partd_events_new as -select -${logic.hsql-only} convert(pde_id, SQL_BIGINT), -${logic.hsql-only} convert(bene_id, SQL_BIGINT), -${logic.hsql-only} convert(clm_grp_id, SQL_BIGINT), -${logic.psql-only} pde_id::bigint, -${logic.psql-only} bene_id::bigint, -${logic.psql-only} clm_grp_id::bigint, - last_updated, - final_action, - cmpnd_cd, - drug_cvrg_stus_cd, - days_suply_num, - srvc_dt, - pd_dt, - fill_num, - qty_dspnsd_num, - cvrd_d_plan_pd_amt, - gdc_abv_oopt_amt, - gdc_blw_oopt_amt, - lics_amt, - ncvrd_plan_pd_amt, - othr_troop_amt, - plro_amt, - ptnt_pay_amt, - rptd_gap_dscnt_num, - ptnt_rsdnc_cd, - tot_rx_cst_amt, - daw_prod_slctn_cd, - phrmcy_srvc_type_cd, - plan_cntrct_rec_id, - plan_pbp_rec_num, - prod_srvc_id, - prscrbr_id, - prscrbr_id_qlfyr_cd, - rx_srvc_rfrnc_num, - srvc_prvdr_id, - srvc_prvdr_id_qlfyr_cd, - adjstmt_dltn_cd, - brnd_gnrc_cd, - ctstrphc_cvrg_cd, - dspnsng_stus_cd, - nstd_frmt_cd, - prcng_excptn_cd, - rx_orgn_cd, - submsn_clr_cd -from - public.partd_events; - --- for PSQL need to define our not null constraints; for HSQL, --- we explicitly defined a table structure before migrating data. --- -${logic.psql-only} alter table public.partd_events_new -${logic.psql-only} alter column pde_id SET NOT NULL, -${logic.psql-only} alter column bene_id SET NOT NULL, -${logic.psql-only} alter column clm_grp_id SET NOT NULL, -${logic.psql-only} alter column final_action SET NOT NULL, -${logic.psql-only} alter column cmpnd_cd SET NOT NULL, -${logic.psql-only} alter column drug_cvrg_stus_cd SET NOT NULL, -${logic.psql-only} alter column days_suply_num SET NOT NULL, -${logic.psql-only} alter column srvc_dt SET NOT NULL, -${logic.psql-only} alter column fill_num SET NOT NULL, -${logic.psql-only} alter column qty_dspnsd_num SET NOT NULL, -${logic.psql-only} alter column cvrd_d_plan_pd_amt SET NOT NULL, -${logic.psql-only} alter column gdc_abv_oopt_amt SET NOT NULL, -${logic.psql-only} alter column gdc_blw_oopt_amt SET NOT NULL, -${logic.psql-only} alter column lics_amt SET NOT NULL, -${logic.psql-only} alter column ncvrd_plan_pd_amt SET NOT NULL, -${logic.psql-only} alter column othr_troop_amt SET NOT NULL, -${logic.psql-only} alter column plro_amt SET NOT NULL, -${logic.psql-only} alter column ptnt_pay_amt SET NOT NULL, -${logic.psql-only} alter column rptd_gap_dscnt_num SET NOT NULL, -${logic.psql-only} alter column ptnt_rsdnc_cd SET NOT NULL, -${logic.psql-only} alter column tot_rx_cst_amt SET NOT NULL, -${logic.psql-only} alter column daw_prod_slctn_cd SET NOT NULL, -${logic.psql-only} alter column phrmcy_srvc_type_cd SET NOT NULL, -${logic.psql-only} alter column plan_cntrct_rec_id SET NOT NULL, -${logic.psql-only} alter column plan_pbp_rec_num SET NOT NULL, -${logic.psql-only} alter column prod_srvc_id SET NOT NULL, -${logic.psql-only} alter column prscrbr_id SET NOT NULL, -${logic.psql-only} alter column prscrbr_id_qlfyr_cd SET NOT NULL, -${logic.psql-only} alter column rx_srvc_rfrnc_num SET NOT NULL, -${logic.psql-only} alter column srvc_prvdr_id SET NOT NULL, -${logic.psql-only} alter column srvc_prvdr_id_qlfyr_cd SET NOT NULL; - --- for PSQL need to define our primary key -${logic.psql-only} alter table public.partd_events_new -${logic.psql-only} add CONSTRAINT partd_events_new_pkey PRIMARY KEY (pde_id); - --- create an index of the BENE_ID in partd_events_new table -CREATE INDEX IF NOT EXISTS partd_events_new_bene_id_idx - ON public.partd_events_new (bene_id); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V75__new_schema_remove_old_claims_tables.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V75__new_schema_remove_old_claims_tables.sql deleted file mode 100644 index 0bdb061a54..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V75__new_schema_remove_old_claims_tables.sql +++ /dev/null @@ -1,27 +0,0 @@ --- --- Script to drop old claims tables that have been replaced by _new tables. --- Once all db changes are complete, the _new table names will be renamed --- back to their original table names. --- -DROP TABLE IF EXISTS public.partd_events CASCADE; --- -DROP TABLE IF EXISTS public.carrier_claim_lines CASCADE; -DROP TABLE IF EXISTS public.carrier_claims CASCADE; --- -DROP TABLE IF EXISTS public.dme_claim_lines CASCADE; -DROP TABLE IF EXISTS public.dme_claims CASCADE; --- -DROP TABLE IF EXISTS public.hha_claim_lines CASCADE; -DROP TABLE IF EXISTS public.hha_claims CASCADE; --- -DROP TABLE IF EXISTS public.hospice_claim_lines CASCADE; -DROP TABLE IF EXISTS public.hospice_claims CASCADE; --- -DROP TABLE IF EXISTS public.inpatient_claim_lines CASCADE; -DROP TABLE IF EXISTS public.inpatient_claims CASCADE; --- -DROP TABLE IF EXISTS public.outpatient_claim_lines CASCADE; -DROP TABLE IF EXISTS public.outpatient_claims CASCADE; --- -DROP TABLE IF EXISTS public.snf_claim_lines CASCADE; -DROP TABLE IF EXISTS public.snf_claims CASCADE; \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V76__rda_meta_data_extra_columns.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V76__rda_meta_data_extra_columns.sql deleted file mode 100644 index 1e017686aa..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V76__rda_meta_data_extra_columns.sql +++ /dev/null @@ -1,21 +0,0 @@ --- Replacement table for rda_api_claim_message_meta_data that uses a natural key --- (claim_type/sequence_number) to save space. Easier to create a new table then --- later drop the old one than to deal with changing key in existing table and there --- is no production data to migrate over. - -${logic.hsql-only} CREATE TYPE json AS longvarchar; - -CREATE TABLE rda.claim_message_meta_data ( - claim_type char(1) NOT NULL, - sequence_number bigint NOT NULL, - claim_id varchar(25) NOT NULL, - mbi_id bigint, - claim_state varchar(1), - transaction_date DATE, - claim_location json, - received_date timestamp with time zone NOT NULL, - CONSTRAINT claim_message_meta_data_pkey PRIMARY KEY (claim_type, sequence_number), - CONSTRAINT claim_message_meta_data_mbi FOREIGN KEY (mbi_id) REFERENCES rda.mbi_cache(mbi_id) -); - -CREATE INDEX claim_message_meta_data_received_date_idx ON rda.claim_message_meta_data(received_date); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V77__pac_add_rda_position.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V77__pac_add_rda_position.sql deleted file mode 100644 index c291f9cea5..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V77__pac_add_rda_position.sql +++ /dev/null @@ -1,31 +0,0 @@ -alter table rda.fiss_audit_trails add column rda_position smallint; -update rda.fiss_audit_trails set rda_position = (priority + 1); -alter table rda.fiss_audit_trails alter column rda_position set not null; - -alter table rda.fiss_diagnosis_codes add column rda_position smallint; -update rda.fiss_diagnosis_codes set rda_position = (priority + 1); -alter table rda.fiss_diagnosis_codes alter column rda_position set not null; - -alter table rda.fiss_payers add column rda_position smallint; -update rda.fiss_payers set rda_position = (priority + 1); -alter table rda.fiss_payers alter column rda_position set not null; - -alter table rda.fiss_proc_codes add column rda_position smallint; -update rda.fiss_proc_codes set rda_position = (priority + 1); -alter table rda.fiss_proc_codes alter column rda_position set not null; - -alter table rda.mcs_adjustments add column rda_position smallint; -update rda.mcs_adjustments set rda_position = (priority + 1); -alter table rda.mcs_adjustments alter column rda_position set not null; - -alter table rda.mcs_audits add column rda_position smallint; -update rda.mcs_audits set rda_position = (priority + 1); -alter table rda.mcs_audits alter column rda_position set not null; - -alter table rda.mcs_diagnosis_codes add column rda_position smallint; -update rda.mcs_diagnosis_codes set rda_position = (priority + 1); -alter table rda.mcs_diagnosis_codes alter column rda_position set not null; - -alter table rda.mcs_locations add column rda_position smallint; -update rda.mcs_locations set rda_position = (priority + 1); -alter table rda.mcs_locations alter column rda_position set not null; \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V78__add_db_rbac_admin_functions.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V78__add_db_rbac_admin_functions.sql deleted file mode 100644 index a2575233a6..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V78__add_db_rbac_admin_functions.sql +++ /dev/null @@ -1,183 +0,0 @@ -/* - This migration adds a set of database admin functions to help us manage role-based access and ownership, while keeping versioned - migrations DRY. It duplicates the ./createSchema.sql callback to ensure the db admin functions are added to *existing* databases - (the createSchema.sql callback is only run once on new database installations). Note the createSchema.sql contents may drift from - this migration over time. - - Functions (all functions are idempotent): - 1. revoke_schema_privs(schema_name TEXT, role_name TEXT) - Revokes schema privileges from a role (tables, sequences, routines). - 2. create_role_if_not_exists(role_name TEXT) - Adds a new role, skipping if the role already exists. - 3. revoke_db_privs(db_name TEXT, role_name TEXT) - Revokes db privs (includes running revoke_schema_privs on all schemas in a db). - 4. add_reader_role_to_schema(role_name TEXT, schema_name TEXT) - Adds a read only role applied to the schema - 5. add_writer_role_to_schema(role_name TEXT, schema_name TEXT) - Read+Write - 6. add_migrator_role_to_schema(role_name TEXT, schema_name TEXT) - Read+Write+DDL - 7. add_db_group_if_not_exists(db_name TEXT, group_name TEXT) - Adds a new group, skipping if the group already exists. - 8. set_fhirdb_owner(role_name TEXT) - Makes the designated role own all existing and future tables, views, sequences, and routines in all schemas. - -*/ - -${logic.psql-only} -- -${logic.psql-only} -- revoke_schema_privs -${logic.psql-only} -- -${logic.psql-only} CREATE OR REPLACE FUNCTION revoke_schema_privs(schema_name TEXT, role_name TEXT) RETURNS void AS $func$ -${logic.psql-only} BEGIN -${logic.psql-only} IF EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = role_name) THEN -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I REVOKE ALL ON TABLES FROM %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I REVOKE ALL ON SEQUENCES FROM %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I REVOKE ALL ON ROUTINES FROM %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('REVOKE ALL ON ALL TABLES IN SCHEMA %I FROM %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('REVOKE ALL ON ALL SEQUENCES IN SCHEMA %I FROM %I;', schema_name, role_name); -${logic.psql-only} BEGIN -${logic.psql-only} -- we will get an error in aws if we try to modify perms on routines installed via system extensions -${logic.psql-only} -- (pg_stat_statements, etc).. just log and ignore the error -${logic.psql-only} EXECUTE format('REVOKE ALL ON ALL ROUTINES IN SCHEMA %I FROM %I;', schema_name, role_name); -${logic.psql-only} EXCEPTION WHEN SQLSTATE '42501' THEN RAISE NOTICE '%, skipping', SQLERRM USING ERRCODE = SQLSTATE; -${logic.psql-only} END; -${logic.psql-only} EXECUTE format('REVOKE ALL ON SCHEMA %I FROM %I;', schema_name, role_name); -${logic.psql-only} ELSE -${logic.psql-only} RAISE NOTICE 'role "%" not found, skipping', role_name; -${logic.psql-only} END IF; -${logic.psql-only} END $func$ LANGUAGE plpgsql; -${logic.psql-only} -${logic.psql-only} -- -${logic.psql-only} -- create_role_if_not_exists -${logic.psql-only} -- -${logic.psql-only} CREATE OR REPLACE FUNCTION create_role_if_not_exists(role_name TEXT) RETURNS void AS $func$ -${logic.psql-only} BEGIN -${logic.psql-only} EXECUTE format('CREATE ROLE %I;', role_name); -${logic.psql-only} EXCEPTION WHEN SQLSTATE '42710' THEN RAISE NOTICE '%, skipping', SQLERRM USING ERRCODE = SQLSTATE; -${logic.psql-only} END $func$ LANGUAGE plpgsql; -${logic.psql-only} -${logic.psql-only} -- -${logic.psql-only} -- revoke_db_privs -${logic.psql-only} -- -${logic.psql-only} CREATE OR REPLACE FUNCTION revoke_db_privs(db_name TEXT, role_name TEXT) RETURNS void AS $func$ -${logic.psql-only} DECLARE -${logic.psql-only} t record; -${logic.psql-only} BEGIN -${logic.psql-only} IF EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = role_name) THEN -${logic.psql-only} FOR t IN -${logic.psql-only} SELECT nspname FROM pg_catalog.pg_namespace -${logic.psql-only} WHERE nspname NOT LIKE 'pg_%' -${logic.psql-only} AND nspname != 'information_schema' -${logic.psql-only} AND nspname != 'public' -${logic.psql-only} LOOP -${logic.psql-only} PERFORM revoke_schema_privs(t.nspname, role_name); -${logic.psql-only} END LOOP; -${logic.psql-only} EXECUTE format('REVOKE ALL ON DATABASE %I FROM %I;', db_name, role_name); -${logic.psql-only} END IF; -${logic.psql-only} END $func$ LANGUAGE plpgsql; -${logic.psql-only} -${logic.psql-only} -- -${logic.psql-only} -- add_reader_role_to_schema -${logic.psql-only} -- -${logic.psql-only} CREATE OR REPLACE FUNCTION add_reader_role_to_schema(role_name TEXT, schema_name TEXT) RETURNS void AS $func$ -${logic.psql-only} BEGIN -${logic.psql-only} PERFORM create_role_if_not_exists(role_name); -${logic.psql-only} PERFORM revoke_schema_privs(role_name, schema_name); -${logic.psql-only} EXECUTE format('GRANT USAGE ON SCHEMA %I TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('GRANT SELECT ON ALL TABLES IN SCHEMA %I TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('GRANT SELECT ON ALL SEQUENCES IN SCHEMA %I TO %I;', schema_name, role_name); --curval -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT SELECT ON TABLES TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT SELECT ON SEQUENCES TO %I;', schema_name, role_name); -${logic.psql-only} END $func$ LANGUAGE plpgsql; -${logic.psql-only} -${logic.psql-only} -- -${logic.psql-only} -- add_writer_role_to_schema -${logic.psql-only} -- -${logic.psql-only} CREATE OR REPLACE FUNCTION add_writer_role_to_schema(role_name TEXT, schema_name TEXT) RETURNS void AS $func$ -${logic.psql-only} BEGIN -${logic.psql-only} PERFORM create_role_if_not_exists(role_name); -${logic.psql-only} PERFORM revoke_schema_privs(role_name, schema_name); -${logic.psql-only} EXECUTE format('GRANT USAGE ON SCHEMA %I TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA %I TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('GRANT USAGE ON ALL SEQUENCES IN SCHEMA %I TO %I;', schema_name, role_name); --curval, nextval -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT USAGE ON SEQUENCES TO %I;', schema_name, role_name); -${logic.psql-only} END $func$ LANGUAGE plpgsql; -${logic.psql-only} -${logic.psql-only} -- -${logic.psql-only} -- add_migrator_role_to_schema -${logic.psql-only} -- -${logic.psql-only} CREATE OR REPLACE FUNCTION add_migrator_role_to_schema(role_name TEXT, schema_name TEXT) RETURNS void AS $func$ -${logic.psql-only} BEGIN -${logic.psql-only} PERFORM create_role_if_not_exists(role_name); -${logic.psql-only} PERFORM revoke_schema_privs(role_name, schema_name); -${logic.psql-only} EXECUTE format('GRANT ALL ON SCHEMA %I TO %I;', schema_name, role_name); -- uwsage + create -${logic.psql-only} EXECUTE format('GRANT ALL ON ALL TABLES IN SCHEMA %I TO %I;', schema_name, role_name); -- tables/views -${logic.psql-only} EXECUTE format('GRANT ALL ON ALL SEQUENCES IN SCHEMA %I TO %I;', schema_name, role_name); --curval, nextval, setval -${logic.psql-only} BEGIN -${logic.psql-only} -- in aurora, we will get an error if we try to modify perms on routines installed via system extensions -${logic.psql-only} -- like pg_stat_statements, so just log the error and skip it -${logic.psql-only} EXECUTE format('GRANT ALL ON ALL ROUTINES IN SCHEMA %I TO %I;', schema_name, role_name); -${logic.psql-only} EXCEPTION WHEN SQLSTATE '42501' THEN RAISE NOTICE '%, skipping', SQLERRM USING ERRCODE = SQLSTATE; -${logic.psql-only} END; -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT ALL ON TABLES TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT ALL ON SEQUENCES TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT ALL ON ROUTINES TO %I;', schema_name, role_name); -${logic.psql-only} END $func$ LANGUAGE plpgsql; -${logic.psql-only} -${logic.psql-only} -- -${logic.psql-only} -- add_db_group_if_not_exists -${logic.psql-only} -- -${logic.psql-only} CREATE OR REPLACE FUNCTION add_db_group_if_not_exists(db_name TEXT, group_name TEXT) RETURNS void AS $func$ -${logic.psql-only} BEGIN -${logic.psql-only} PERFORM create_role_if_not_exists(group_name); -${logic.psql-only} EXECUTE format('GRANT CONNECT ON DATABASE %I TO %I;', db_name, group_name); -${logic.psql-only} -- ignore dup errors -${logic.psql-only} EXCEPTION WHEN duplicate_object THEN RAISE NOTICE '%, skipping', SQLERRM USING ERRCODE = SQLSTATE; -${logic.psql-only} END $func$ LANGUAGE plpgsql; -${logic.psql-only} -${logic.psql-only} -- -${logic.psql-only} -- set_fhirdb_owner -${logic.psql-only} -- -${logic.psql-only} CREATE OR REPLACE FUNCTION set_fhirdb_owner(role_name TEXT) RETURNS void AS $func$ -${logic.psql-only} DECLARE -${logic.psql-only} t record; -${logic.psql-only} BEGIN -${logic.psql-only} -- make the fhirdb owner role own all schemas except public/system schemas -${logic.psql-only} FOR t IN -${logic.psql-only} SELECT nspname, nspowner FROM pg_catalog.pg_namespace -${logic.psql-only} WHERE nspname != 'public' AND nspname != 'information_schema' AND nspname NOT LIKE 'pg_%' -${logic.psql-only} LOOP -${logic.psql-only} EXECUTE format('GRANT %I TO %I;', role_name, CURRENT_USER); -${logic.psql-only} EXECUTE format('ALTER SCHEMA %I OWNER TO %I', t.nspname, role_name); -${logic.psql-only} END LOOP; -${logic.psql-only} -${logic.psql-only} -- make role_name own all tables/views in all non system schemas/tables -${logic.psql-only} FOR t IN -${logic.psql-only} SELECT table_schema, table_name -${logic.psql-only} FROM information_schema.tables -${logic.psql-only} WHERE table_type = 'BASE TABLE' -${logic.psql-only} AND table_schema NOT LIKE 'pg_%' -${logic.psql-only} AND table_schema != 'information_schema' -${logic.psql-only} AND table_name NOT LIKE 'pg_%' -${logic.psql-only} LOOP -${logic.psql-only} EXECUTE format('ALTER TABLE %I.%I OWNER TO %I;', t.table_schema, t.table_name, role_name); -${logic.psql-only} END LOOP; -${logic.psql-only} -${logic.psql-only} -- sequences -${logic.psql-only} FOR t IN -${logic.psql-only} SELECT sequence_schema, sequence_name -${logic.psql-only} FROM information_schema.sequences -${logic.psql-only} WHERE sequence_name NOT LIKE 'pg_%' -${logic.psql-only} AND sequence_schema != 'information_schema' -${logic.psql-only} AND sequence_schema NOT LIKE 'pg_%' -${logic.psql-only} LOOP -${logic.psql-only} EXECUTE format('ALTER SEQUENCE %I.%I OWNER TO %I;', t.sequence_schema, t.sequence_name, role_name); -${logic.psql-only} END LOOP; -${logic.psql-only} -${logic.psql-only} -- functions and procedures (routines) -${logic.psql-only} FOR t IN -${logic.psql-only} SELECT routine_schema, routine_name -${logic.psql-only} FROM information_schema.routines -${logic.psql-only} WHERE routine_schema != 'pg_catalog' AND routine_schema != 'information_schema' -${logic.psql-only} LOOP -${logic.psql-only} BEGIN -${logic.psql-only} -- in aws, we will get an error if we try to modify perms on routines installed via system extensions -${logic.psql-only} -- (pg_stat_statements, etc).. just log and ignore the error -${logic.psql-only} EXECUTE format('ALTER ROUTINE %I.%I OWNER TO %I;', t.routine_schema, t.routine_name, role_name); -${logic.psql-only} EXCEPTION WHEN SQLSTATE '42501' THEN RAISE NOTICE 'set_fhir_db_owner: %, skipping', SQLERRM USING ERRCODE = SQLSTATE; -${logic.psql-only} END; -${logic.psql-only} END LOOP; -${logic.psql-only} END $func$ LANGUAGE plpgsql; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V79__add_bfd_and_rda_rbac_roles.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V79__add_bfd_and_rda_rbac_roles.sql deleted file mode 100644 index e6558f8b65..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V79__add_bfd_and_rda_rbac_roles.sql +++ /dev/null @@ -1,106 +0,0 @@ -/* - This migration adds a set of read, write, and migrate roles and groups for BFD and PACA's public/rda schemas. - - If any of these new roles/groups happen to exist, the correct permissions (as defined in the previous migration) will be - applied. It does not remove/delete/modify any existing roles, groups, or permissions, which will be cleaned up out-of-band. -*/ - -${logic.psql-only} DO $$ -${logic.psql-only} DECLARE -${logic.psql-only} t record; -${logic.psql-only} BEGIN -${logic.psql-only} -- ensure bfd read, write, and migrate roles exists -${logic.psql-only} PERFORM create_role_if_not_exists('bfd_reader_role'); -${logic.psql-only} PERFORM create_role_if_not_exists('bfd_writer_role'); -${logic.psql-only} PERFORM create_role_if_not_exists('bfd_migrator_role'); -${logic.psql-only} PERFORM revoke_db_privs('fhirdb', 'bfd_reader_role'); -${logic.psql-only} PERFORM revoke_db_privs('fhirdb', 'bfd_writer_role'); -${logic.psql-only} PERFORM revoke_db_privs('fhirdb', 'bfd_migrator_role'); -${logic.psql-only} -${logic.psql-only} -- add bfd read, write, migrate roles -${logic.psql-only} PERFORM add_reader_role_to_schema('bfd_reader_role', 'public'); -${logic.psql-only} PERFORM add_writer_role_to_schema('bfd_writer_role', 'public'); -${logic.psql-only} PERFORM add_migrator_role_to_schema('bfd_migrator_role', 'public'); -${logic.psql-only} -${logic.psql-only} -- add bfd user groups -${logic.psql-only} PERFORM add_db_group_if_not_exists('fhirdb', 'bfd_analyst_group'); -${logic.psql-only} PERFORM add_db_group_if_not_exists('fhirdb', 'bfd_data_admin_group'); -${logic.psql-only} PERFORM add_db_group_if_not_exists('fhirdb', 'bfd_schema_admin_group'); -${logic.psql-only} PERFORM revoke_db_privs('fhirdb', 'bfd_analyst_group'); -${logic.psql-only} PERFORM revoke_db_privs('fhirdb', 'bfd_data_admin_group'); -${logic.psql-only} PERFORM revoke_db_privs('fhirdb', 'bfd_schema_admin_group'); -${logic.psql-only} GRANT bfd_reader_role TO bfd_analyst_group; -${logic.psql-only} GRANT bfd_writer_role TO bfd_data_admin_group; -${logic.psql-only} GRANT bfd_migrator_role TO bfd_schema_admin_group; -${logic.psql-only} -${logic.psql-only} -- ensure paca read, write, migrate roles exists -${logic.psql-only} PERFORM create_role_if_not_exists('paca_reader_role'); -${logic.psql-only} PERFORM create_role_if_not_exists('paca_writer_role'); -${logic.psql-only} PERFORM create_role_if_not_exists('paca_migrator_role'); -${logic.psql-only} PERFORM revoke_db_privs('fhirdb', 'paca_reader_role'); -${logic.psql-only} PERFORM revoke_db_privs('fhirdb', 'paca_writer_role'); -${logic.psql-only} PERFORM revoke_db_privs('fhirdb', 'paca_migrator_role'); -${logic.psql-only} -${logic.psql-only} -- add paca read, write, migrate roles -${logic.psql-only} PERFORM add_reader_role_to_schema('paca_reader_role', 'rda'); -${logic.psql-only} PERFORM add_writer_role_to_schema('paca_writer_role', 'rda'); -${logic.psql-only} PERFORM add_migrator_role_to_schema('paca_migrator_role', 'rda'); -${logic.psql-only} -${logic.psql-only} -- add paca user groups -${logic.psql-only} PERFORM add_db_group_if_not_exists('fhirdb', 'paca_analyst_group'); -${logic.psql-only} PERFORM add_db_group_if_not_exists('fhirdb', 'paca_data_admin_group'); -${logic.psql-only} PERFORM add_db_group_if_not_exists('fhirdb', 'paca_schema_admin_group'); -${logic.psql-only} PERFORM revoke_db_privs('fhirdb', 'paca_analyst_group'); -${logic.psql-only} PERFORM revoke_db_privs('fhirdb', 'paca_data_admin_group'); -${logic.psql-only} PERFORM revoke_db_privs('fhirdb', 'paca_schema_admin_group'); -${logic.psql-only} GRANT paca_reader_role TO paca_analyst_group; -${logic.psql-only} GRANT paca_writer_role TO paca_data_admin_group; -${logic.psql-only} GRANT paca_migrator_role TO paca_schema_admin_group; -${logic.psql-only} -${logic.psql-only} -- add a fhirdb migrator role that can migrate both bfd and paca schemas -${logic.psql-only} PERFORM create_role_if_not_exists('fhirdb_migrator_role'); -${logic.psql-only} PERFORM revoke_db_privs('fhirdb', 'fhirdb_migrator_role'); -${logic.psql-only} GRANT bfd_migrator_role TO fhirdb_migrator_role; -${logic.psql-only} GRANT paca_migrator_role TO fhirdb_migrator_role; -${logic.psql-only} -${logic.psql-only} -- add an rds_superuser role to emulate AWS on local local db installs -${logic.psql-only} IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = 'rds_superuser') THEN -${logic.psql-only} CREATE ROLE rds_superuser WITH CREATEDB CREATEROLE INHERIT NOLOGIN; -${logic.psql-only} GRANT ALL ON DATABASE fhirdb TO rds_superuser; -${logic.psql-only} FOR t IN -${logic.psql-only} SELECT nspname FROM pg_namespace WHERE nspname NOT LIKE 'pg_%' AND nspname != 'information_schema' -${logic.psql-only} LOOP -${logic.psql-only} EXECUTE format('GRANT ALL ON SCHEMA %I TO rds_superuser', t.nspname); -${logic.psql-only} EXECUTE format('GRANT ALL ON ALL TABLES IN SCHEMA %I TO rds_superuser', t.nspname); -${logic.psql-only} EXECUTE format('GRANT ALL ON ALL SEQUENCES IN SCHEMA %I TO rds_superuser', t.nspname); -${logic.psql-only} EXECUTE format('GRANT ALL ON ALL ROUTINES IN SCHEMA %I TO rds_superuser', t.nspname); -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT ALL ON TABLES TO rds_superuser', t.nspname); -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT ALL ON SEQUENCES TO rds_superuser', t.nspname); -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT ALL ON ROUTINES TO rds_superuser', t.nspname); -${logic.psql-only} END LOOP; -${logic.psql-only} END IF; -${logic.psql-only} -${logic.psql-only} -- add a db administrator group (only db administrators will manage group membership) -${logic.psql-only} PERFORM add_db_group_if_not_exists('fhirdb', 'fhirdb_admin_group'); -${logic.psql-only} ALTER ROLE fhirdb_admin_group WITH CREATEDB CREATEROLE; -${logic.psql-only} GRANT rds_superuser TO fhirdb_admin_group WITH ADMIN OPTION; -${logic.psql-only} -${logic.psql-only} -- add a group for managing reader service accounts -${logic.psql-only} PERFORM add_db_group_if_not_exists('fhirdb', 'api_reader_svcs'); -${logic.psql-only} PERFORM revoke_db_privs('fhirdb', 'api_reader_svcs'); -${logic.psql-only} GRANT bfd_reader_role TO api_reader_svcs; -${logic.psql-only} GRANT paca_reader_role TO api_reader_svcs; -${logic.psql-only} -${logic.psql-only} -- add a group for managing pipeline service accounts -${logic.psql-only} PERFORM add_db_group_if_not_exists('fhirdb', 'api_pipeline_svcs'); -${logic.psql-only} PERFORM revoke_db_privs('fhirdb', 'api_pipeline_svcs'); -${logic.psql-only} GRANT bfd_writer_role TO api_pipeline_svcs; -${logic.psql-only} GRANT paca_writer_role TO api_pipeline_svcs; -${logic.psql-only} -${logic.psql-only} -- add a group for managing migrator service accounts (read+write+ddl) -${logic.psql-only} PERFORM add_db_group_if_not_exists('fhirdb', 'api_migrator_svcs'); -${logic.psql-only} PERFORM revoke_db_privs('fhirdb', 'api_migrator_svcs'); -${logic.psql-only} ALTER ROLE api_migrator_svcs WITH CREATEDB CREATEROLE; -${logic.psql-only} GRANT fhirdb_migrator_role TO api_migrator_svcs; -${logic.psql-only} END -${logic.psql-only} $$ LANGUAGE plpgsql; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V7__CBBF-147_Inpatient_Claim_fields_need_to_have_monetary_representation.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V7__CBBF-147_Inpatient_Claim_fields_need_to_have_monetary_representation.sql deleted file mode 100644 index d2de4a84c9..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V7__CBBF-147_Inpatient_Claim_fields_need_to_have_monetary_representation.sql +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Resolves http://issues.hhsdevcloud.us/browse/CBBF-147, correcting the - * precision and scale of the `InpatientClaim.indirectMedicalEducationAmount` - * and `InpatientClaim.disproportionateShareAmount` columns. - */ - -alter table "InpatientClaims" - alter column "indirectMedicalEducationAmount" ${logic.alter-column-type} numeric(12,2); -alter table "InpatientClaims" - alter column "disproportionateShareAmount" ${logic.alter-column-type} numeric(12,2); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V80__new_schema_beneficiaries.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V80__new_schema_beneficiaries.sql deleted file mode 100644 index fd865d2ea4..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V80__new_schema_beneficiaries.sql +++ /dev/null @@ -1,727 +0,0 @@ --- NEW_SCHEMA_BENEFICIARIES.SQL --- flyway migration for BENEFICIARIES table into --- a new schema structure that: --- 1) changes data type of BENE_ID from varchar to BIGINT. --- --- Once current table data is migrated to new table name/structure, a --- subsequent PR will be deployed that changes the ORM model(s) and --- operational code for Beneficiaries table. --- --- HSQL differs from PSQL (postgres) in that the table defintion --- must be explicitly declared prior to loading data into the --- target table. PSQL can derive the table structure based on --- the data input (i.e., column name, data type). Thus, for HSQL, --- we need to explicitly define the table structure prior to loading data. --- --- For HSQL, explicitly define/create a new BENEFICIARIES_NEW table in --- the current PUBLIC schema --- -${logic.hsql-only} create table public.beneficiaries_new ( -${logic.hsql-only} bene_id bigint not null, -${logic.hsql-only} mbi_num varchar(11), -${logic.hsql-only} rfrnc_yr numeric(4,0), -${logic.hsql-only} a_mo_cnt numeric(3,0), -${logic.hsql-only} b_mo_cnt numeric(3,0), -${logic.hsql-only} buyin_mo_cnt numeric(3,0), -${logic.hsql-only} plan_cvrg_mo_cnt numeric(3,0), -${logic.hsql-only} rds_mo_cnt numeric(3,0), -${logic.hsql-only} hmo_mo_cnt numeric(3,0), -${logic.hsql-only} dual_mo_cnt numeric(3,0), -${logic.hsql-only} efctv_bgn_dt date, -${logic.hsql-only} efctv_end_dt date, -${logic.hsql-only} covstart date, -${logic.hsql-only} bene_county_cd varchar(10) not null, -${logic.hsql-only} bene_entlmt_rsn_curr char(1), -${logic.hsql-only} bene_entlmt_rsn_orig char(1), -${logic.hsql-only} bene_mdcr_status_cd varchar(2), -${logic.hsql-only} bene_pta_trmntn_cd char(1), -${logic.hsql-only} bene_ptb_trmntn_cd char(1), -${logic.hsql-only} efivepct char(1), -${logic.hsql-only} enrl_src varchar(3), -${logic.hsql-only} sample_group varchar(2), -${logic.hsql-only} v_dod_sw char(1), -${logic.hsql-only} bene_esrd_ind char(1), -${logic.hsql-only} crnt_bic varchar(2), -${logic.hsql-only} mbi_hash varchar(64), -${logic.hsql-only} hicn_unhashed varchar(11), -${logic.hsql-only} bene_crnt_hic_num varchar(64) not null, -${logic.hsql-only} bene_srnm_name varchar(24) not null, -${logic.hsql-only} bene_gvn_name varchar(15) not null, -${logic.hsql-only} bene_mdl_name char(1), -${logic.hsql-only} bene_birth_dt date not null, -${logic.hsql-only} bene_sex_ident_cd char(1) not null, -${logic.hsql-only} state_code varchar(2) not null, -${logic.hsql-only} bene_zip_cd varchar(9) not null, -${logic.hsql-only} bene_race_cd char(1), -${logic.hsql-only} age numeric(3,0), -${logic.hsql-only} death_dt date, -${logic.hsql-only} rti_race_cd char(1), -${logic.hsql-only} drvd_line_1_adr varchar(40), -${logic.hsql-only} drvd_line_2_adr varchar(40), -${logic.hsql-only} drvd_line_3_adr varchar(40), -${logic.hsql-only} drvd_line_4_adr varchar(40), -${logic.hsql-only} drvd_line_5_adr varchar(40), -${logic.hsql-only} drvd_line_6_adr varchar(40), -${logic.hsql-only} city_name varchar(100), -${logic.hsql-only} state_cd varchar(2), -${logic.hsql-only} state_cnty_zip_cd varchar(9), -${logic.hsql-only} last_updated timestamp with time zone, -${logic.hsql-only} bene_link_key numeric(38,0), --- the rest of the columns in this table represent data actually --- exists in the beneficiary_monthly table; in all likelihood, these --- columns will be removed from this table upon completion of a --- thorough analysis. Thus, we have physically located these columns --- at the bottom of the new table structure to make altering the table --- (removing the db columns) more efficient when recovering usage space. -${logic.hsql-only} cst_shr_grp_jan_cd varchar(2), -${logic.hsql-only} cst_shr_grp_feb_cd varchar(2), -${logic.hsql-only} cst_shr_grp_mar_cd varchar(2), -${logic.hsql-only} cst_shr_grp_apr_cd varchar(2), -${logic.hsql-only} cst_shr_grp_may_cd varchar(2), -${logic.hsql-only} cst_shr_grp_jun_cd varchar(2), -${logic.hsql-only} cst_shr_grp_jul_cd varchar(2), -${logic.hsql-only} cst_shr_grp_aug_cd varchar(2), -${logic.hsql-only} cst_shr_grp_sept_cd varchar(2), -${logic.hsql-only} cst_shr_grp_oct_cd varchar(2), -${logic.hsql-only} cst_shr_grp_nov_cd varchar(2), -${logic.hsql-only} cst_shr_grp_dec_cd varchar(2), -${logic.hsql-only} fips_state_cnty_jan_cd varchar(5), -${logic.hsql-only} fips_state_cnty_feb_cd varchar(5), -${logic.hsql-only} fips_state_cnty_mar_cd varchar(5), -${logic.hsql-only} fips_state_cnty_apr_cd varchar(5), -${logic.hsql-only} fips_state_cnty_may_cd varchar(5), -${logic.hsql-only} fips_state_cnty_jun_cd varchar(5), -${logic.hsql-only} fips_state_cnty_jul_cd varchar(5), -${logic.hsql-only} fips_state_cnty_aug_cd varchar(5), -${logic.hsql-only} fips_state_cnty_sept_cd varchar(5), -${logic.hsql-only} fips_state_cnty_oct_cd varchar(5), -${logic.hsql-only} fips_state_cnty_nov_cd varchar(5), -${logic.hsql-only} fips_state_cnty_dec_cd varchar(5), -${logic.hsql-only} hmo_1_ind char(1), -${logic.hsql-only} hmo_2_ind char(1), -${logic.hsql-only} hmo_3_ind char(1), -${logic.hsql-only} hmo_4_ind char(1), -${logic.hsql-only} hmo_5_ind char(1), -${logic.hsql-only} hmo_6_ind char(1), -${logic.hsql-only} hmo_7_ind char(1), -${logic.hsql-only} hmo_8_ind char(1), -${logic.hsql-only} hmo_9_ind char(1), -${logic.hsql-only} hmo_10_ind char(1), -${logic.hsql-only} hmo_11_ind char(1), -${logic.hsql-only} hmo_12_ind char(1), -${logic.hsql-only} mdcr_entlmt_buyin_1_ind char(1), -${logic.hsql-only} mdcr_entlmt_buyin_2_ind char(1), -${logic.hsql-only} mdcr_entlmt_buyin_3_ind char(1), -${logic.hsql-only} mdcr_entlmt_buyin_4_ind char(1), -${logic.hsql-only} mdcr_entlmt_buyin_5_ind char(1), -${logic.hsql-only} mdcr_entlmt_buyin_6_ind char(1), -${logic.hsql-only} mdcr_entlmt_buyin_7_ind char(1), -${logic.hsql-only} mdcr_entlmt_buyin_8_ind char(1), -${logic.hsql-only} mdcr_entlmt_buyin_9_ind char(1), -${logic.hsql-only} mdcr_entlmt_buyin_10_ind char(1), -${logic.hsql-only} mdcr_entlmt_buyin_11_ind char(1), -${logic.hsql-only} mdcr_entlmt_buyin_12_ind char(1), -${logic.hsql-only} mdcr_stus_jan_cd varchar(2), -${logic.hsql-only} mdcr_stus_feb_cd varchar(2), -${logic.hsql-only} mdcr_stus_mar_cd varchar(2), -${logic.hsql-only} mdcr_stus_apr_cd varchar(2), -${logic.hsql-only} mdcr_stus_may_cd varchar(2), -${logic.hsql-only} mdcr_stus_jun_cd varchar(2), -${logic.hsql-only} mdcr_stus_jul_cd varchar(2), -${logic.hsql-only} mdcr_stus_aug_cd varchar(2), -${logic.hsql-only} mdcr_stus_sept_cd varchar(2), -${logic.hsql-only} mdcr_stus_oct_cd varchar(2), -${logic.hsql-only} mdcr_stus_nov_cd varchar(2), -${logic.hsql-only} mdcr_stus_dec_cd varchar(2), -${logic.hsql-only} meta_dual_elgbl_stus_jan_cd varchar(2), -${logic.hsql-only} meta_dual_elgbl_stus_feb_cd varchar(2), -${logic.hsql-only} meta_dual_elgbl_stus_mar_cd varchar(2), -${logic.hsql-only} meta_dual_elgbl_stus_apr_cd varchar(2), -${logic.hsql-only} meta_dual_elgbl_stus_may_cd varchar(2), -${logic.hsql-only} meta_dual_elgbl_stus_jun_cd varchar(2), -${logic.hsql-only} meta_dual_elgbl_stus_jul_cd varchar(2), -${logic.hsql-only} meta_dual_elgbl_stus_aug_cd varchar(2), -${logic.hsql-only} meta_dual_elgbl_stus_sept_cd varchar(2), -${logic.hsql-only} meta_dual_elgbl_stus_oct_cd varchar(2), -${logic.hsql-only} meta_dual_elgbl_stus_nov_cd varchar(2), -${logic.hsql-only} meta_dual_elgbl_stus_dec_cd varchar(2), -${logic.hsql-only} ptc_cntrct_jan_id varchar(5), -${logic.hsql-only} ptc_cntrct_feb_id varchar(5), -${logic.hsql-only} ptc_cntrct_mar_id varchar(5), -${logic.hsql-only} ptc_cntrct_apr_id varchar(5), -${logic.hsql-only} ptc_cntrct_may_id varchar(5), -${logic.hsql-only} ptc_cntrct_jun_id varchar(5), -${logic.hsql-only} ptc_cntrct_jul_id varchar(5), -${logic.hsql-only} ptc_cntrct_aug_id varchar(5), -${logic.hsql-only} ptc_cntrct_sept_id varchar(5), -${logic.hsql-only} ptc_cntrct_oct_id varchar(5), -${logic.hsql-only} ptc_cntrct_nov_id varchar(5), -${logic.hsql-only} ptc_cntrct_dec_id varchar(5), -${logic.hsql-only} ptc_pbp_jan_id varchar(3), -${logic.hsql-only} ptc_pbp_feb_id varchar(3), -${logic.hsql-only} ptc_pbp_mar_id varchar(3), -${logic.hsql-only} ptc_pbp_apr_id varchar(3), -${logic.hsql-only} ptc_pbp_may_id varchar(3), -${logic.hsql-only} ptc_pbp_jun_id varchar(3), -${logic.hsql-only} ptc_pbp_jul_id varchar(3), -${logic.hsql-only} ptc_pbp_aug_id varchar(3), -${logic.hsql-only} ptc_pbp_sept_id varchar(3), -${logic.hsql-only} ptc_pbp_oct_id varchar(3), -${logic.hsql-only} ptc_pbp_nov_id varchar(3), -${logic.hsql-only} ptc_pbp_dec_id varchar(3), -${logic.hsql-only} ptc_plan_type_jan_cd varchar(3), -${logic.hsql-only} ptc_plan_type_feb_cd varchar(3), -${logic.hsql-only} ptc_plan_type_mar_cd varchar(3), -${logic.hsql-only} ptc_plan_type_apr_cd varchar(3), -${logic.hsql-only} ptc_plan_type_may_cd varchar(3), -${logic.hsql-only} ptc_plan_type_jun_cd varchar(3), -${logic.hsql-only} ptc_plan_type_jul_cd varchar(3), -${logic.hsql-only} ptc_plan_type_aug_cd varchar(3), -${logic.hsql-only} ptc_plan_type_sept_cd varchar(3), -${logic.hsql-only} ptc_plan_type_oct_cd varchar(3), -${logic.hsql-only} ptc_plan_type_nov_cd varchar(3), -${logic.hsql-only} ptc_plan_type_dec_cd varchar(3), -${logic.hsql-only} ptd_cntrct_jan_id varchar(5), -${logic.hsql-only} ptd_cntrct_feb_id varchar(5), -${logic.hsql-only} ptd_cntrct_mar_id varchar(5), -${logic.hsql-only} ptd_cntrct_apr_id varchar(5), -${logic.hsql-only} ptd_cntrct_may_id varchar(5), -${logic.hsql-only} ptd_cntrct_jun_id varchar(5), -${logic.hsql-only} ptd_cntrct_jul_id varchar(5), -${logic.hsql-only} ptd_cntrct_aug_id varchar(5), -${logic.hsql-only} ptd_cntrct_sept_id varchar(5), -${logic.hsql-only} ptd_cntrct_oct_id varchar(5), -${logic.hsql-only} ptd_cntrct_nov_id varchar(5), -${logic.hsql-only} ptd_cntrct_dec_id varchar(5), -${logic.hsql-only} ptd_pbp_jan_id varchar(3), -${logic.hsql-only} ptd_pbp_feb_id varchar(3), -${logic.hsql-only} ptd_pbp_mar_id varchar(3), -${logic.hsql-only} ptd_pbp_apr_id varchar(3), -${logic.hsql-only} ptd_pbp_may_id varchar(3), -${logic.hsql-only} ptd_pbp_jun_id varchar(3), -${logic.hsql-only} ptd_pbp_jul_id varchar(3), -${logic.hsql-only} ptd_pbp_aug_id varchar(3), -${logic.hsql-only} ptd_pbp_sept_id varchar(3), -${logic.hsql-only} ptd_pbp_oct_id varchar(3), -${logic.hsql-only} ptd_pbp_nov_id varchar(3), -${logic.hsql-only} ptd_pbp_dec_id varchar(3), -${logic.hsql-only} ptd_sgmt_jan_id varchar(3), -${logic.hsql-only} ptd_sgmt_feb_id varchar(3), -${logic.hsql-only} ptd_sgmt_mar_id varchar(3), -${logic.hsql-only} ptd_sgmt_apr_id varchar(3), -${logic.hsql-only} ptd_sgmt_may_id varchar(3), -${logic.hsql-only} ptd_sgmt_jun_id varchar(3), -${logic.hsql-only} ptd_sgmt_jul_id varchar(3), -${logic.hsql-only} ptd_sgmt_aug_id varchar(3), -${logic.hsql-only} ptd_sgmt_sept_id varchar(3), -${logic.hsql-only} ptd_sgmt_oct_id varchar(3), -${logic.hsql-only} ptd_sgmt_nov_id varchar(3), -${logic.hsql-only} ptd_sgmt_dec_id varchar(3), -${logic.hsql-only} rds_jan_ind char(1), -${logic.hsql-only} rds_feb_ind char(1), -${logic.hsql-only} rds_mar_ind char(1), -${logic.hsql-only} rds_apr_ind char(1), -${logic.hsql-only} rds_may_ind char(1), -${logic.hsql-only} rds_jun_ind char(1), -${logic.hsql-only} rds_jul_ind char(1), -${logic.hsql-only} rds_aug_ind char(1), -${logic.hsql-only} rds_sept_ind char(1), -${logic.hsql-only} rds_oct_ind char(1), -${logic.hsql-only} rds_nov_ind char(1), -${logic.hsql-only} rds_dec_ind char(1), -${logic.hsql-only} constraint public.beneficiaries_new_pkey -${logic.hsql-only} primary key (bene_id) ); --- --- -${logic.psql-only} SET max_parallel_workers = 24; -${logic.psql-only} SET max_parallel_workers_per_gather = 20; -${logic.psql-only} SET parallel_leader_participation = off; -${logic.psql-only} SET parallel_tuple_cost = 0; -${logic.psql-only} SET parallel_setup_cost = 0; --- --- -${logic.hsql-only} insert into public.beneficiaries_new ( -${logic.hsql-only} bene_id, -${logic.hsql-only} mbi_num, -${logic.hsql-only} rfrnc_yr, -${logic.hsql-only} a_mo_cnt, -${logic.hsql-only} b_mo_cnt, -${logic.hsql-only} buyin_mo_cnt, -${logic.hsql-only} plan_cvrg_mo_cnt, -${logic.hsql-only} rds_mo_cnt, -${logic.hsql-only} hmo_mo_cnt, -${logic.hsql-only} dual_mo_cnt, -${logic.hsql-only} efctv_bgn_dt, -${logic.hsql-only} efctv_end_dt, -${logic.hsql-only} covstart, -${logic.hsql-only} bene_county_cd, -${logic.hsql-only} bene_entlmt_rsn_curr, -${logic.hsql-only} bene_entlmt_rsn_orig, -${logic.hsql-only} bene_mdcr_status_cd, -${logic.hsql-only} bene_pta_trmntn_cd, -${logic.hsql-only} bene_ptb_trmntn_cd, -${logic.hsql-only} efivepct, -${logic.hsql-only} enrl_src, -${logic.hsql-only} sample_group, -${logic.hsql-only} v_dod_sw, -${logic.hsql-only} bene_esrd_ind, -${logic.hsql-only} crnt_bic, -${logic.hsql-only} mbi_hash, -${logic.hsql-only} hicn_unhashed, -${logic.hsql-only} bene_crnt_hic_num, -${logic.hsql-only} bene_srnm_name, -${logic.hsql-only} bene_gvn_name, -${logic.hsql-only} bene_mdl_name, -${logic.hsql-only} bene_birth_dt, -${logic.hsql-only} bene_sex_ident_cd, -${logic.hsql-only} state_code, -${logic.hsql-only} bene_zip_cd, -${logic.hsql-only} bene_race_cd, -${logic.hsql-only} age, -${logic.hsql-only} death_dt, -${logic.hsql-only} rti_race_cd, -${logic.hsql-only} drvd_line_1_adr, -${logic.hsql-only} drvd_line_2_adr, -${logic.hsql-only} drvd_line_3_adr, -${logic.hsql-only} drvd_line_4_adr, -${logic.hsql-only} drvd_line_5_adr, -${logic.hsql-only} drvd_line_6_adr, -${logic.hsql-only} city_name, -${logic.hsql-only} state_cd, -${logic.hsql-only} state_cnty_zip_cd, -${logic.hsql-only} last_updated, -${logic.hsql-only} bene_link_key, -${logic.hsql-only} cst_shr_grp_jan_cd, -${logic.hsql-only} cst_shr_grp_feb_cd, -${logic.hsql-only} cst_shr_grp_mar_cd, -${logic.hsql-only} cst_shr_grp_apr_cd, -${logic.hsql-only} cst_shr_grp_may_cd, -${logic.hsql-only} cst_shr_grp_jun_cd, -${logic.hsql-only} cst_shr_grp_jul_cd, -${logic.hsql-only} cst_shr_grp_aug_cd, -${logic.hsql-only} cst_shr_grp_sept_cd, -${logic.hsql-only} cst_shr_grp_oct_cd, -${logic.hsql-only} cst_shr_grp_nov_cd, -${logic.hsql-only} cst_shr_grp_dec_cd, -${logic.hsql-only} fips_state_cnty_jan_cd, -${logic.hsql-only} fips_state_cnty_feb_cd, -${logic.hsql-only} fips_state_cnty_mar_cd, -${logic.hsql-only} fips_state_cnty_apr_cd, -${logic.hsql-only} fips_state_cnty_may_cd, -${logic.hsql-only} fips_state_cnty_jun_cd, -${logic.hsql-only} fips_state_cnty_jul_cd, -${logic.hsql-only} fips_state_cnty_aug_cd, -${logic.hsql-only} fips_state_cnty_sept_cd, -${logic.hsql-only} fips_state_cnty_oct_cd, -${logic.hsql-only} fips_state_cnty_nov_cd, -${logic.hsql-only} fips_state_cnty_dec_cd, -${logic.hsql-only} hmo_1_ind, -${logic.hsql-only} hmo_2_ind, -${logic.hsql-only} hmo_3_ind, -${logic.hsql-only} hmo_4_ind, -${logic.hsql-only} hmo_5_ind, -${logic.hsql-only} hmo_6_ind, -${logic.hsql-only} hmo_7_ind, -${logic.hsql-only} hmo_8_ind, -${logic.hsql-only} hmo_9_ind, -${logic.hsql-only} hmo_10_ind, -${logic.hsql-only} hmo_11_ind, -${logic.hsql-only} hmo_12_ind, -${logic.hsql-only} mdcr_entlmt_buyin_1_ind, -${logic.hsql-only} mdcr_entlmt_buyin_2_ind, -${logic.hsql-only} mdcr_entlmt_buyin_3_ind, -${logic.hsql-only} mdcr_entlmt_buyin_4_ind, -${logic.hsql-only} mdcr_entlmt_buyin_5_ind, -${logic.hsql-only} mdcr_entlmt_buyin_6_ind, -${logic.hsql-only} mdcr_entlmt_buyin_7_ind, -${logic.hsql-only} mdcr_entlmt_buyin_8_ind, -${logic.hsql-only} mdcr_entlmt_buyin_9_ind, -${logic.hsql-only} mdcr_entlmt_buyin_10_ind, -${logic.hsql-only} mdcr_entlmt_buyin_11_ind, -${logic.hsql-only} mdcr_entlmt_buyin_12_ind, -${logic.hsql-only} mdcr_stus_jan_cd, -${logic.hsql-only} mdcr_stus_feb_cd, -${logic.hsql-only} mdcr_stus_mar_cd, -${logic.hsql-only} mdcr_stus_apr_cd, -${logic.hsql-only} mdcr_stus_may_cd, -${logic.hsql-only} mdcr_stus_jun_cd, -${logic.hsql-only} mdcr_stus_jul_cd, -${logic.hsql-only} mdcr_stus_aug_cd, -${logic.hsql-only} mdcr_stus_sept_cd, -${logic.hsql-only} mdcr_stus_oct_cd, -${logic.hsql-only} mdcr_stus_nov_cd, -${logic.hsql-only} mdcr_stus_dec_cd, -${logic.hsql-only} meta_dual_elgbl_stus_jan_cd, -${logic.hsql-only} meta_dual_elgbl_stus_feb_cd, -${logic.hsql-only} meta_dual_elgbl_stus_mar_cd, -${logic.hsql-only} meta_dual_elgbl_stus_apr_cd, -${logic.hsql-only} meta_dual_elgbl_stus_may_cd, -${logic.hsql-only} meta_dual_elgbl_stus_jun_cd, -${logic.hsql-only} meta_dual_elgbl_stus_jul_cd, -${logic.hsql-only} meta_dual_elgbl_stus_aug_cd, -${logic.hsql-only} meta_dual_elgbl_stus_sept_cd, -${logic.hsql-only} meta_dual_elgbl_stus_oct_cd, -${logic.hsql-only} meta_dual_elgbl_stus_nov_cd, -${logic.hsql-only} meta_dual_elgbl_stus_dec_cd, -${logic.hsql-only} ptc_cntrct_jan_id, -${logic.hsql-only} ptc_cntrct_feb_id, -${logic.hsql-only} ptc_cntrct_mar_id, -${logic.hsql-only} ptc_cntrct_apr_id, -${logic.hsql-only} ptc_cntrct_may_id, -${logic.hsql-only} ptc_cntrct_jun_id, -${logic.hsql-only} ptc_cntrct_jul_id, -${logic.hsql-only} ptc_cntrct_aug_id, -${logic.hsql-only} ptc_cntrct_sept_id, -${logic.hsql-only} ptc_cntrct_oct_id, -${logic.hsql-only} ptc_cntrct_nov_id, -${logic.hsql-only} ptc_cntrct_dec_id, -${logic.hsql-only} ptc_pbp_jan_id, -${logic.hsql-only} ptc_pbp_feb_id, -${logic.hsql-only} ptc_pbp_mar_id, -${logic.hsql-only} ptc_pbp_apr_id, -${logic.hsql-only} ptc_pbp_may_id, -${logic.hsql-only} ptc_pbp_jun_id, -${logic.hsql-only} ptc_pbp_jul_id, -${logic.hsql-only} ptc_pbp_aug_id, -${logic.hsql-only} ptc_pbp_sept_id, -${logic.hsql-only} ptc_pbp_oct_id, -${logic.hsql-only} ptc_pbp_nov_id, -${logic.hsql-only} ptc_pbp_dec_id, -${logic.hsql-only} ptc_plan_type_jan_cd, -${logic.hsql-only} ptc_plan_type_feb_cd, -${logic.hsql-only} ptc_plan_type_mar_cd, -${logic.hsql-only} ptc_plan_type_apr_cd, -${logic.hsql-only} ptc_plan_type_may_cd, -${logic.hsql-only} ptc_plan_type_jun_cd, -${logic.hsql-only} ptc_plan_type_jul_cd, -${logic.hsql-only} ptc_plan_type_aug_cd, -${logic.hsql-only} ptc_plan_type_sept_cd, -${logic.hsql-only} ptc_plan_type_oct_cd, -${logic.hsql-only} ptc_plan_type_nov_cd, -${logic.hsql-only} ptc_plan_type_dec_cd, -${logic.hsql-only} ptd_cntrct_jan_id, -${logic.hsql-only} ptd_cntrct_feb_id, -${logic.hsql-only} ptd_cntrct_mar_id, -${logic.hsql-only} ptd_cntrct_apr_id, -${logic.hsql-only} ptd_cntrct_may_id, -${logic.hsql-only} ptd_cntrct_jun_id, -${logic.hsql-only} ptd_cntrct_jul_id, -${logic.hsql-only} ptd_cntrct_aug_id, -${logic.hsql-only} ptd_cntrct_sept_id, -${logic.hsql-only} ptd_cntrct_oct_id, -${logic.hsql-only} ptd_cntrct_nov_id, -${logic.hsql-only} ptd_cntrct_dec_id, -${logic.hsql-only} ptd_pbp_jan_id, -${logic.hsql-only} ptd_pbp_feb_id, -${logic.hsql-only} ptd_pbp_mar_id, -${logic.hsql-only} ptd_pbp_apr_id, -${logic.hsql-only} ptd_pbp_may_id, -${logic.hsql-only} ptd_pbp_jun_id, -${logic.hsql-only} ptd_pbp_jul_id, -${logic.hsql-only} ptd_pbp_aug_id, -${logic.hsql-only} ptd_pbp_sept_id, -${logic.hsql-only} ptd_pbp_oct_id, -${logic.hsql-only} ptd_pbp_nov_id, -${logic.hsql-only} ptd_pbp_dec_id, -${logic.hsql-only} ptd_sgmt_jan_id, -${logic.hsql-only} ptd_sgmt_feb_id, -${logic.hsql-only} ptd_sgmt_mar_id, -${logic.hsql-only} ptd_sgmt_apr_id, -${logic.hsql-only} ptd_sgmt_may_id, -${logic.hsql-only} ptd_sgmt_jun_id, -${logic.hsql-only} ptd_sgmt_jul_id, -${logic.hsql-only} ptd_sgmt_aug_id, -${logic.hsql-only} ptd_sgmt_sept_id, -${logic.hsql-only} ptd_sgmt_oct_id, -${logic.hsql-only} ptd_sgmt_nov_id, -${logic.hsql-only} ptd_sgmt_dec_id, -${logic.hsql-only} rds_jan_ind, -${logic.hsql-only} rds_feb_ind, -${logic.hsql-only} rds_mar_ind, -${logic.hsql-only} rds_apr_ind, -${logic.hsql-only} rds_may_ind, -${logic.hsql-only} rds_jun_ind, -${logic.hsql-only} rds_jul_ind, -${logic.hsql-only} rds_aug_ind, -${logic.hsql-only} rds_sept_ind, -${logic.hsql-only} rds_oct_ind, -${logic.hsql-only} rds_nov_ind, -${logic.hsql-only} rds_dec_ind ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} create table public.beneficiaries_new as -select -${logic.hsql-only} convert(bene_id, SQL_BIGINT), -${logic.psql-only} bene_id::bigint, - mbi_num, - rfrnc_yr, - a_mo_cnt, - b_mo_cnt, - buyin_mo_cnt, - plan_cvrg_mo_cnt, - rds_mo_cnt, - hmo_mo_cnt, - dual_mo_cnt, - efctv_bgn_dt, - efctv_end_dt, - covstart, - bene_county_cd, - bene_entlmt_rsn_curr, - bene_entlmt_rsn_orig, - bene_mdcr_status_cd, - bene_pta_trmntn_cd, - bene_ptb_trmntn_cd, - efivepct, - enrl_src, - sample_group, - v_dod_sw, - bene_esrd_ind, - crnt_bic, - mbi_hash, - hicn_unhashed, - bene_crnt_hic_num, - bene_srnm_name, - bene_gvn_name, - bene_mdl_name, - bene_birth_dt, - bene_sex_ident_cd, - state_code, - bene_zip_cd, - bene_race_cd, - age, - death_dt, - rti_race_cd, - drvd_line_1_adr, - drvd_line_2_adr, - drvd_line_3_adr, - drvd_line_4_adr, - drvd_line_5_adr, - drvd_line_6_adr, - city_name, - state_cd, - state_cnty_zip_cd, - last_updated, - bene_link_key, - cst_shr_grp_jan_cd, - cst_shr_grp_feb_cd, - cst_shr_grp_mar_cd, - cst_shr_grp_apr_cd, - cst_shr_grp_may_cd, - cst_shr_grp_jun_cd, - cst_shr_grp_jul_cd, - cst_shr_grp_aug_cd, - cst_shr_grp_sept_cd, - cst_shr_grp_oct_cd, - cst_shr_grp_nov_cd, - cst_shr_grp_dec_cd, - fips_state_cnty_jan_cd, - fips_state_cnty_feb_cd, - fips_state_cnty_mar_cd, - fips_state_cnty_apr_cd, - fips_state_cnty_may_cd, - fips_state_cnty_jun_cd, - fips_state_cnty_jul_cd, - fips_state_cnty_aug_cd, - fips_state_cnty_sept_cd, - fips_state_cnty_oct_cd, - fips_state_cnty_nov_cd, - fips_state_cnty_dec_cd, - hmo_1_ind, - hmo_2_ind, - hmo_3_ind, - hmo_4_ind, - hmo_5_ind, - hmo_6_ind, - hmo_7_ind, - hmo_8_ind, - hmo_9_ind, - hmo_10_ind, - hmo_11_ind, - hmo_12_ind, - mdcr_entlmt_buyin_1_ind, - mdcr_entlmt_buyin_2_ind, - mdcr_entlmt_buyin_3_ind, - mdcr_entlmt_buyin_4_ind, - mdcr_entlmt_buyin_5_ind, - mdcr_entlmt_buyin_6_ind, - mdcr_entlmt_buyin_7_ind, - mdcr_entlmt_buyin_8_ind, - mdcr_entlmt_buyin_9_ind, - mdcr_entlmt_buyin_10_ind, - mdcr_entlmt_buyin_11_ind, - mdcr_entlmt_buyin_12_ind, - mdcr_stus_jan_cd, - mdcr_stus_feb_cd, - mdcr_stus_mar_cd, - mdcr_stus_apr_cd, - mdcr_stus_may_cd, - mdcr_stus_jun_cd, - mdcr_stus_jul_cd, - mdcr_stus_aug_cd, - mdcr_stus_sept_cd, - mdcr_stus_oct_cd, - mdcr_stus_nov_cd, - mdcr_stus_dec_cd, - meta_dual_elgbl_stus_jan_cd, - meta_dual_elgbl_stus_feb_cd, - meta_dual_elgbl_stus_mar_cd, - meta_dual_elgbl_stus_apr_cd, - meta_dual_elgbl_stus_may_cd, - meta_dual_elgbl_stus_jun_cd, - meta_dual_elgbl_stus_jul_cd, - meta_dual_elgbl_stus_aug_cd, - meta_dual_elgbl_stus_sept_cd, - meta_dual_elgbl_stus_oct_cd, - meta_dual_elgbl_stus_nov_cd, - meta_dual_elgbl_stus_dec_cd, - ptc_cntrct_jan_id, - ptc_cntrct_feb_id, - ptc_cntrct_mar_id, - ptc_cntrct_apr_id, - ptc_cntrct_may_id, - ptc_cntrct_jun_id, - ptc_cntrct_jul_id, - ptc_cntrct_aug_id, - ptc_cntrct_sept_id, - ptc_cntrct_oct_id, - ptc_cntrct_nov_id, - ptc_cntrct_dec_id, - ptc_pbp_jan_id, - ptc_pbp_feb_id, - ptc_pbp_mar_id, - ptc_pbp_apr_id, - ptc_pbp_may_id, - ptc_pbp_jun_id, - ptc_pbp_jul_id, - ptc_pbp_aug_id, - ptc_pbp_sept_id, - ptc_pbp_oct_id, - ptc_pbp_nov_id, - ptc_pbp_dec_id, - ptc_plan_type_jan_cd, - ptc_plan_type_feb_cd, - ptc_plan_type_mar_cd, - ptc_plan_type_apr_cd, - ptc_plan_type_may_cd, - ptc_plan_type_jun_cd, - ptc_plan_type_jul_cd, - ptc_plan_type_aug_cd, - ptc_plan_type_sept_cd, - ptc_plan_type_oct_cd, - ptc_plan_type_nov_cd, - ptc_plan_type_dec_cd, - ptd_cntrct_jan_id, - ptd_cntrct_feb_id, - ptd_cntrct_mar_id, - ptd_cntrct_apr_id, - ptd_cntrct_may_id, - ptd_cntrct_jun_id, - ptd_cntrct_jul_id, - ptd_cntrct_aug_id, - ptd_cntrct_sept_id, - ptd_cntrct_oct_id, - ptd_cntrct_nov_id, - ptd_cntrct_dec_id, - ptd_pbp_jan_id, - ptd_pbp_feb_id, - ptd_pbp_mar_id, - ptd_pbp_apr_id, - ptd_pbp_may_id, - ptd_pbp_jun_id, - ptd_pbp_jul_id, - ptd_pbp_aug_id, - ptd_pbp_sept_id, - ptd_pbp_oct_id, - ptd_pbp_nov_id, - ptd_pbp_dec_id, - ptd_sgmt_jan_id, - ptd_sgmt_feb_id, - ptd_sgmt_mar_id, - ptd_sgmt_apr_id, - ptd_sgmt_may_id, - ptd_sgmt_jun_id, - ptd_sgmt_jul_id, - ptd_sgmt_aug_id, - ptd_sgmt_sept_id, - ptd_sgmt_oct_id, - ptd_sgmt_nov_id, - ptd_sgmt_dec_id, - rds_jan_ind, - rds_feb_ind, - rds_mar_ind, - rds_apr_ind, - rds_may_ind, - rds_jun_ind, - rds_jul_ind, - rds_aug_ind, - rds_sept_ind, - rds_oct_ind, - rds_nov_ind, - rds_dec_ind -from - beneficiaries; - -${logic.psql-only} alter table public.beneficiaries_new -${logic.psql-only} alter column bene_id SET NOT NULL, -${logic.psql-only} alter column bene_county_cd SET NOT NULL, -${logic.psql-only} alter column bene_crnt_hic_num SET NOT NULL, -${logic.psql-only} alter column bene_srnm_name SET NOT NULL, -${logic.psql-only} alter column bene_gvn_name SET NOT NULL, -${logic.psql-only} alter column bene_birth_dt SET NOT NULL, -${logic.psql-only} alter column bene_sex_ident_cd SET NOT NULL, -${logic.psql-only} alter column state_code SET NOT NULL, -${logic.psql-only} alter column bene_zip_cd SET NOT NULL; - --- for PSQL need to define our primary key -${logic.psql-only} alter table public.beneficiaries_new -${logic.psql-only} add CONSTRAINT beneficiaries_new_pkey PRIMARY KEY (bene_id); - --- create an index of the BENE_CRNT_HIC_NUM -CREATE INDEX IF NOT EXISTS beneficiaries_new_hicn_idx - ON public.beneficiaries_new (bene_crnt_hic_num); - --- create an index of the MBI_HASH -CREATE INDEX IF NOT EXISTS beneficiaries_new_mbi_hash_idx - ON public.beneficiaries_new (mbi_hash); - --- the following indexes will be created since they currently exist in --- the beneficiaries table; if we alter the table to remove the columns --- (see above comment in the HSQL table definition), these indexes will --- be removed. -CREATE INDEX IF NOT EXISTS beneficiaries_new_ptd_cntrct_number_jan_id_idx - ON public.beneficiaries_new (ptd_cntrct_jan_id); - -CREATE INDEX IF NOT EXISTS beneficiaries_new_ptd_cntrct_number_feb_id_idx - ON public.beneficiaries_new (ptd_cntrct_feb_id); - -CREATE INDEX IF NOT EXISTS beneficiaries_new_ptd_cntrct_number_mar_id_idx - ON public.beneficiaries_new (ptd_cntrct_mar_id); - -CREATE INDEX IF NOT EXISTS beneficiaries_new_ptd_cntrct_number_apr_id_idx - ON public.beneficiaries_new (ptd_cntrct_apr_id); - -CREATE INDEX IF NOT EXISTS beneficiaries_new_ptd_cntrct_number_may_id_idx - ON public.beneficiaries_new (ptd_cntrct_may_id); - -CREATE INDEX IF NOT EXISTS beneficiaries_new_ptd_cntrct_number_jun_id_idx - ON public.beneficiaries_new (ptd_cntrct_jun_id); - -CREATE INDEX IF NOT EXISTS beneficiaries_new_ptd_cntrct_number_jul_id_idx - ON public.beneficiaries_new (ptd_cntrct_jul_id); - -CREATE INDEX IF NOT EXISTS beneficiaries_new_ptd_cntrct_number_aug_id_idx - ON public.beneficiaries_new (ptd_cntrct_aug_id); - -CREATE INDEX IF NOT EXISTS beneficiaries_new_ptd_cntrct_number_sept_id_idx - ON public.beneficiaries_new (ptd_cntrct_sept_id); - -CREATE INDEX IF NOT EXISTS beneficiaries_new_ptd_cntrct_number_oct_id_idx - ON public.beneficiaries_new (ptd_cntrct_oct_id); - -CREATE INDEX IF NOT EXISTS beneficiaries_new_ptd_cntrct_number_nov_id_idx - ON public.beneficiaries_new (ptd_cntrct_nov_id); - -CREATE INDEX IF NOT EXISTS beneficiaries_new_ptd_cntrct_number_dec_id_idx - ON public.beneficiaries_new (ptd_cntrct_dec_id); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V81__new_schema_beneficiary_monthly.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V81__new_schema_beneficiary_monthly.sql deleted file mode 100644 index 758d0f69c3..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V81__new_schema_beneficiary_monthly.sql +++ /dev/null @@ -1,102 +0,0 @@ --- NEW_SCHEMA_BENEFICIARY_MONTHLY.SQL --- flyway migration for BENEFICIARY_MONTHLY table into --- a new schema structure that: --- 1) changes data type of BENE_ID from varchar to BIGINT. --- --- Once current table data is migrated to new table name/structure, a --- subsequent PR will be deployed that changes the ORM model(s) and --- operational code for Beneficiaries table. --- --- HSQL differs from PSQL (postgres) in that the table defintion --- must be explicitly declared prior to loading data into the --- target table. PSQL can derive the table structure based on --- the data input (i.e., column name, data type). Thus, for HSQL, --- we need to explicitly define the table structure prior to loading data. --- --- For HSQL, explicitly define/create a new BENEFICIARY_MONTHLY_NEW table in --- the current PUBLIC schema --- -${logic.hsql-only} create table public.beneficiary_monthly_new ( -${logic.hsql-only} bene_id bigint not null, -${logic.hsql-only} year_month date not null, -${logic.hsql-only} partd_contract_number_id varchar(5), -${logic.hsql-only} partc_contract_number_id varchar(5), -${logic.hsql-only} medicare_status_code varchar(2), -${logic.hsql-only} fips_state_cnty_code varchar(5), -${logic.hsql-only} entitlement_buy_in_ind char(1), -${logic.hsql-only} hmo_indicator_ind char(1), -${logic.hsql-only} medicaid_dual_eligibility_code varchar(2), -${logic.hsql-only} partd_pbp_number_id varchar(3), -${logic.hsql-only} partd_retiree_drug_subsidy_ind char(1), -${logic.hsql-only} partd_segment_number_id varchar(3), -${logic.hsql-only} partd_low_income_cost_share_group_code varchar(2), -${logic.hsql-only} partc_pbp_number_id varchar(3), -${logic.hsql-only} partc_plan_type_code varchar(3), -${logic.hsql-only} constraint public.beneficiary_monthly_new_pkey -${logic.hsql-only} primary key (bene_id, year_month) ); --- --- For PSQL, try to parallelize insert processing -${logic.psql-only} SET max_parallel_workers = 24; -${logic.psql-only} SET max_parallel_workers_per_gather = 20; -${logic.psql-only} SET parallel_leader_participation = off; -${logic.psql-only} SET parallel_tuple_cost = 0; -${logic.psql-only} SET parallel_setup_cost = 0; --- --- -${logic.hsql-only} insert into public.beneficiary_monthly_new ( -${logic.hsql-only} bene_id, -${logic.hsql-only} year_month, -${logic.hsql-only} partd_contract_number_id, -${logic.hsql-only} partc_contract_number_id, -${logic.hsql-only} medicare_status_code, -${logic.hsql-only} fips_state_cnty_code, -${logic.hsql-only} entitlement_buy_in_ind, -${logic.hsql-only} hmo_indicator_ind, -${logic.hsql-only} medicaid_dual_eligibility_code, -${logic.hsql-only} partd_pbp_number_id, -${logic.hsql-only} partd_retiree_drug_subsidy_ind, -${logic.hsql-only} partd_segment_number_id, -${logic.hsql-only} partd_low_income_cost_share_group_code, -${logic.hsql-only} partc_pbp_number_id, -${logic.hsql-only} partc_plan_type_code ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} create table public.beneficiary_monthly_new as -select -${logic.hsql-only} convert(bene_id, SQL_BIGINT), -${logic.psql-only} bene_id::bigint, - year_month, - partd_contract_number_id, - partc_contract_number_id, - medicare_status_code, - fips_state_cnty_code, - entitlement_buy_in_ind, - hmo_indicator_ind, - medicaid_dual_eligibility_code, - partd_pbp_number_id, - partd_retiree_drug_subsidy_ind, - partd_segment_number_id, - partd_low_income_cost_share_group_code, - partc_pbp_number_id, - partc_plan_type_code -from - public.beneficiary_monthly; - -${logic.psql-only} alter table public.beneficiary_monthly_new -${logic.psql-only} alter column bene_id SET NOT NULL, -${logic.psql-only} alter column year_month SET NOT NULL; - --- for PSQL need to define our primary key -${logic.psql-only} alter table public.beneficiary_monthly_new -${logic.psql-only} add CONSTRAINT beneficiary_monthly_new_pkey PRIMARY KEY (bene_id, year_month); - --- create an index to optimized Part D Contract by date -CREATE INDEX IF NOT EXISTS beneficiary_monthly_new_partd_contract_year_month_bene_id_idx - ON public.beneficiary_monthly_new (partd_contract_number_id, year_month, bene_id); - --- define foreign key constraints to beneficiary table. -ALTER TABLE IF EXISTS public.beneficiary_monthly_new - ADD CONSTRAINT beneficiary_monthly_new_to_benficiaries FOREIGN KEY (bene_id) - REFERENCES public.beneficiaries_new (bene_id); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V82__new_schema_mbi_hist.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V82__new_schema_mbi_hist.sql deleted file mode 100644 index c6627e6735..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V82__new_schema_mbi_hist.sql +++ /dev/null @@ -1,107 +0,0 @@ --- NEW_SCHEMA_MEDICARE_BENEFICIARY_HISTORY.SQL --- flyway migration for MEDICARE_BENEFICIARY_HISTORY table into --- a new schema structure that: --- 1) changes data type of BENE_ID from varchar to BIGINT. --- --- Once current table data is migrated to new table name/structure, a --- subsequent PR will be deployed that changes the ORM model(s) and --- operational code for Beneficiaries table. --- --- HSQL differs from PSQL (postgres) in that the table defintion --- must be explicitly declared prior to loading data into the --- target table. PSQL can derive the table structure based on --- the data input (i.e., column name, data type). Thus, for HSQL, --- we need to explicitly define the table structure prior to loading data. --- --- For HSQL, explicitly define/create a new MEDICARE_BENEFICIARY_HISTORY_NEW table in --- the current PUBLIC schema --- -${logic.hsql-only} create table public.medicare_beneficiaryid_history_new ( -${logic.hsql-only} bene_mbi_id numeric not null, -${logic.hsql-only} bene_id bigint, -${logic.hsql-only} mbi_sqnc_num numeric, -${logic.hsql-only} bene_ident_cd varchar(2), -${logic.hsql-only} bene_clm_acnt_num varchar(9), -${logic.hsql-only} bene_crnt_rec_ind_id numeric, -${logic.hsql-only} mbi_num varchar(11), -${logic.hsql-only} mbi_card_rqst_dt date, -${logic.hsql-only} mbi_bgn_rsn_cd varchar(5), -${logic.hsql-only} mbi_end_rsn_cd varchar(5), -${logic.hsql-only} mbi_efctv_bgn_dt date, -${logic.hsql-only} mbi_efctv_end_dt date, -${logic.hsql-only} last_updated timestamp with time zone, -${logic.hsql-only} creat_user_id varchar(30), -${logic.hsql-only} creat_ts timestamp without time zone, -${logic.hsql-only} updt_user_id varchar(30), -${logic.hsql-only} updt_ts timestamp without time zone, -${logic.hsql-only} constraint public.medicare_beneficiaryid_history_new_pkey -${logic.hsql-only} primary key (bene_mbi_id) ); --- --- -${logic.psql-only} SET max_parallel_workers = 24; -${logic.psql-only} SET max_parallel_workers_per_gather = 20; -${logic.psql-only} SET parallel_leader_participation = off; -${logic.psql-only} SET parallel_tuple_cost = 0; -${logic.psql-only} SET parallel_setup_cost = 0; --- --- -${logic.hsql-only} insert into public.medicare_beneficiaryid_history_new ( -${logic.hsql-only} bene_mbi_id, -${logic.hsql-only} bene_id, -${logic.hsql-only} mbi_sqnc_num, -${logic.hsql-only} bene_ident_cd, -${logic.hsql-only} bene_clm_acnt_num, -${logic.hsql-only} bene_crnt_rec_ind_id, -${logic.hsql-only} mbi_num, -${logic.hsql-only} mbi_card_rqst_dt, -${logic.hsql-only} mbi_bgn_rsn_cd, -${logic.hsql-only} mbi_end_rsn_cd, -${logic.hsql-only} mbi_efctv_bgn_dt, -${logic.hsql-only} mbi_efctv_end_dt, -${logic.hsql-only} last_updated, -${logic.hsql-only} creat_user_id, -${logic.hsql-only} creat_ts, -${logic.hsql-only} updt_user_id, -${logic.hsql-only} updt_ts ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} create table public.medicare_beneficiaryid_history_new as -select - bene_mbi_id, -${logic.hsql-only} convert(bene_id, SQL_BIGINT), -${logic.psql-only} bene_id::bigint, - mbi_sqnc_num, - bene_ident_cd, - bene_clm_acnt_num, - bene_crnt_rec_ind_id, - mbi_num, - mbi_card_rqst_dt, - mbi_bgn_rsn_cd, - mbi_end_rsn_cd, - mbi_efctv_bgn_dt, - mbi_efctv_end_dt, - last_updated, - creat_user_id, - creat_ts, - updt_user_id, - updt_ts -from - public.medicare_beneficiaryid_history; - -${logic.psql-only} alter table public.medicare_beneficiaryid_history_new -${logic.psql-only} alter column bene_mbi_id SET NOT NULL; - --- for PSQL need to define our primary key -${logic.psql-only} alter table public.medicare_beneficiaryid_history_new -${logic.psql-only} add CONSTRAINT medicare_beneficiaryid_history_new_pkey PRIMARY KEY (bene_mbi_id); - --- create an index of the BENE_ID -CREATE INDEX IF NOT EXISTS medicare_beneficiaryid_history_new_bene_id_idx - ON public.medicare_beneficiaryid_history_new (bene_id); - --- define foreign key constraints to beneficiary table. -ALTER TABLE IF EXISTS public.medicare_beneficiaryid_history_new - ADD CONSTRAINT medicare_beneficiaryid_history_new_to_benficiaries FOREIGN KEY (bene_id) - REFERENCES public.beneficiaries_new (bene_id); diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V83__new_schema_beneficiaries_history.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V83__new_schema_beneficiaries_history.sql deleted file mode 100644 index b1d9a30d4c..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V83__new_schema_beneficiaries_history.sql +++ /dev/null @@ -1,101 +0,0 @@ --- NEW_SCHEMA_BENEFICIARIES_HISTORY.SQL --- flyway migration for BENEFICIARIES_HISTORY table into --- a new schema structure that: --- 1) changes data type of BENE_ID from varchar to BIGINT. --- --- Once current table data is migrated to new table name/structure, a --- subsequent PR will be deployed that changes the ORM model(s) and --- operational code for Beneficiaries table. --- --- HSQL differs from PSQL (postgres) in that the table defintion --- must be explicitly declared prior to loading data into the --- target table. PSQL can derive the table structure based on --- the data input (i.e., column name, data type). Thus, for HSQL, --- we need to explicitly define the table structure prior to loading data. --- --- For HSQL, explicitly define/create a new BENEFICIARIES_HISTORY_NEW table in --- the current PUBLIC schema --- -${logic.hsql-only} create table public.beneficiaries_history_new ( -${logic.hsql-only} bene_history_id bigint not null, -${logic.hsql-only} bene_id bigint not null, -${logic.hsql-only} hicn_unhashed varchar(11), -${logic.hsql-only} mbi_num varchar(11), -${logic.hsql-only} efctv_bgn_dt date, -${logic.hsql-only} efctv_end_dt date, -${logic.hsql-only} bene_crnt_hic_num varchar(64) not null, -${logic.hsql-only} mbi_hash varchar(64), -${logic.hsql-only} bene_birth_dt date not null, -${logic.hsql-only} bene_sex_ident_cd char(1) not null, -${logic.hsql-only} last_updated timestamp with time zone, -${logic.hsql-only} constraint public.beneficiaries_history_new_pkey -${logic.hsql-only} primary key (bene_history_id) ); --- --- -${logic.psql-only} SET max_parallel_workers = 24; -${logic.psql-only} SET max_parallel_workers_per_gather = 20; -${logic.psql-only} SET parallel_leader_participation = off; -${logic.psql-only} SET parallel_tuple_cost = 0; -${logic.psql-only} SET parallel_setup_cost = 0; --- --- -${logic.hsql-only} insert into public.beneficiaries_history_new ( -${logic.hsql-only} bene_history_id, -${logic.hsql-only} bene_id, -${logic.hsql-only} hicn_unhashed, -${logic.hsql-only} mbi_num, -${logic.hsql-only} efctv_bgn_dt, -${logic.hsql-only} efctv_end_dt, -${logic.hsql-only} bene_crnt_hic_num, -${logic.hsql-only} mbi_hash, -${logic.hsql-only} bene_birth_dt, -${logic.hsql-only} bene_sex_ident_cd, -${logic.hsql-only} last_updated ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} create table public.beneficiaries_history_new as -select - bene_history_id, -${logic.hsql-only} convert(bene_id, SQL_BIGINT), -${logic.psql-only} bene_id::bigint, - hicn_unhashed, - mbi_num, - efctv_bgn_dt, - efctv_end_dt, - bene_crnt_hic_num, - mbi_hash, - bene_birth_dt, - bene_sex_ident_cd, - last_updated -from - public.beneficiaries_history; - -${logic.psql-only} alter table public.beneficiaries_history_new -${logic.psql-only} alter column bene_history_id SET NOT NULL, -${logic.psql-only} alter column bene_id SET NOT NULL, -${logic.psql-only} alter column bene_crnt_hic_num SET NOT NULL, -${logic.psql-only} alter column bene_birth_dt SET NOT NULL, -${logic.psql-only} alter column bene_sex_ident_cd SET NOT NULL; - --- for PSQL need to define our primary key -${logic.psql-only} alter table public.beneficiaries_history_new -${logic.psql-only} add CONSTRAINT beneficiaries_history_new_pkey PRIMARY KEY (bene_history_id); - --- create an index of the BENE_ID -CREATE INDEX IF NOT EXISTS beneficiaries_history_new_bene_id_idx - ON public.beneficiaries_history_new (bene_id); - --- create an index of the BENE_CRNT_HIC_NUM -CREATE INDEX IF NOT EXISTS beneficiaries_history_new_hicn_idx - ON public.beneficiaries_history_new (bene_crnt_hic_num); - --- create an index of the MBI_HASH -CREATE INDEX IF NOT EXISTS beneficiaries_history_new_mbi_hash_idx - ON public.beneficiaries_history_new (mbi_hash); - --- define foreign key constraints to beneficiary table. -ALTER TABLE IF EXISTS public.beneficiaries_history_new - ADD CONSTRAINT beneficiaries_history_new_to_benficiaries FOREIGN KEY (bene_id) - REFERENCES public.beneficiaries_new (bene_id); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V84__new_schema_skipped_rif_records.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V84__new_schema_skipped_rif_records.sql deleted file mode 100644 index c34701a43b..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V84__new_schema_skipped_rif_records.sql +++ /dev/null @@ -1,78 +0,0 @@ --- NEW_SCHEMA_SKIPPED_RIF_RECORDS.SQL --- flyway migration for SKIPPED_RIF_RECORDS table into --- a new schema structure that: --- 1) changes data type of BENE_ID from varchar to BIGINT. --- --- Once current table data is migrated to new table name/structure, a --- subsequent PR will be deployed that changes the ORM model(s) and --- operational code for Beneficiaries table. --- --- HSQL differs from PSQL (postgres) in that the table defintion --- must be explicitly declared prior to loading data into the --- target table. PSQL can derive the table structure based on --- the data input (i.e., column name, data type). Thus, for HSQL, --- we need to explicitly define the table structure prior to loading data. --- --- For HSQL, explicitly define/create a new SKIPPED_RIF_RECORDS_NEW table in --- the current PUBLIC schema --- -${logic.hsql-only} create table public.skipped_rif_records_new ( -${logic.hsql-only} record_id bigint not null, -${logic.hsql-only} bene_id bigint not null, -${logic.hsql-only} skip_reason varchar(50) not null, -${logic.hsql-only} rif_file_timestamp timestamp with time zone not null, -${logic.hsql-only} rif_file_type varchar(48) not null, -${logic.hsql-only} dml_ind varchar(6) not null, -${logic.hsql-only} rif_data ${type.text} not null, -${logic.hsql-only} constraint public.skipped_rif_records_new_pkey -${logic.hsql-only} primary key (record_id) ); --- --- For PSQL, try to parallelize insert processing -${logic.psql-only} SET max_parallel_workers = 24; -${logic.psql-only} SET max_parallel_workers_per_gather = 20; -${logic.psql-only} SET parallel_leader_participation = off; -${logic.psql-only} SET parallel_tuple_cost = 0; -${logic.psql-only} SET parallel_setup_cost = 0; --- --- -${logic.hsql-only} insert into public.skipped_rif_records_new ( -${logic.hsql-only} record_id, -${logic.hsql-only} bene_id, -${logic.hsql-only} skip_reason, -${logic.hsql-only} rif_file_timestamp, -${logic.hsql-only} rif_file_type, -${logic.hsql-only} dml_ind, -${logic.hsql-only} rif_data ) --- --- PSQL allows us to dynamically create a table via the --- associated SELECT statement used to populate the table. --- -${logic.psql-only} create table public.skipped_rif_records_new as -select - record_id, -${logic.hsql-only} convert(bene_id, SQL_BIGINT), -${logic.psql-only} bene_id::bigint, - skip_reason, - rif_file_timestamp, - rif_file_type, - dml_ind, - rif_data -from - public.skipped_rif_records; - -${logic.psql-only} alter table public.skipped_rif_records_new -${logic.psql-only} alter column record_id SET NOT NULL, -${logic.psql-only} alter column bene_id SET NOT NULL, -${logic.psql-only} alter column skip_reason SET NOT NULL, -${logic.psql-only} alter column rif_file_timestamp SET NOT NULL, -${logic.psql-only} alter column rif_file_type SET NOT NULL, -${logic.psql-only} alter column dml_ind SET NOT NULL, -${logic.psql-only} alter column rif_data SET NOT NULL; - --- for PSQL need to define our primary key -${logic.psql-only} alter table public.skipped_rif_records_new -${logic.psql-only} add CONSTRAINT skipped_rif_records_new_pkey PRIMARY KEY (record_id); - --- create an index on bene_id -CREATE INDEX IF NOT EXISTS skipped_rif_records_new_bene_id_idx - ON public.skipped_rif_records_new (bene_id); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V85__drop_mbi_ubique_constraint.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V85__drop_mbi_ubique_constraint.sql deleted file mode 100644 index 7b94b6c685..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V85__drop_mbi_ubique_constraint.sql +++ /dev/null @@ -1,8 +0,0 @@ --- Due to hibernate logging corresponding data in constraint violations, we're removing the unique --- constraint on the mbi. The hash is also unique, so it *should* provide duplicate row protection --- without leaking sensitive information to the logs - -drop index rda.mbi_cache_mbi_idx; - --- Create new index without unique constraint -create index mbi_cache_mbi_idx on rda.mbi_cache(mbi); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V86__new_schema_remove_old_beneficiary_tables.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V86__new_schema_remove_old_beneficiary_tables.sql deleted file mode 100644 index 0bbb8e12f5..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V86__new_schema_remove_old_beneficiary_tables.sql +++ /dev/null @@ -1,10 +0,0 @@ --- --- Script to drop old beneficiary-related tables that have been replaced --- by _new tables. Once all db changes are complete, the _new table names --- will be renamed back to their original table names. --- -DROP TABLE IF EXISTS public.beneficiaries_history CASCADE; -DROP TABLE IF EXISTS public.medicare_beneficiaryid_history CASCADE; -DROP TABLE IF EXISTS public.beneficiary_monthly CASCADE; -DROP TABLE IF EXISTS public.skipped_rif_records CASCADE; -DROP TABLE IF EXISTS public.beneficiaries CASCADE; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V87__new_schema_rebuild_claims_fk_constraints.conf b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V87__new_schema_rebuild_claims_fk_constraints.conf deleted file mode 100644 index 695a447a16..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V87__new_schema_rebuild_claims_fk_constraints.conf +++ /dev/null @@ -1,5 +0,0 @@ -# V87__rebuild_claims_fk_constraints -# -# Manually determine whether or not to execute this migration in a transaction. This is useful -# for databases like PostgreSQL where we specify that we want the lock update to allow sharing. -executeInTransaction=false \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V87__new_schema_rebuild_claims_fk_constraints.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V87__new_schema_rebuild_claims_fk_constraints.sql deleted file mode 100644 index 173a217b62..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V87__new_schema_rebuild_claims_fk_constraints.sql +++ /dev/null @@ -1,151 +0,0 @@ --- REBUILD_CLAIMS_FK_CONSTRAINTS.SQL --- --- This flyway script (re-) implements foreign key (FK) constraints between --- parent claims tables (i.e., carrier_claims) and the beneficiaries table --- on the column bene_id. --- --- The script does this operation 'in-place' meaning that the constraints --- are created on active database(s) (i.e., prod, prod-sbx, test). Normally --- an ALTER TABLE, ADD CONSTRAINT requires an EXCLUSIVE LOCK on a table --- because the db engine has to validate the integrity of the column value(s) --- used in the constraint. While there is no getting around the necessity for --- an EXCLUSIVE LOCK, we can minimize the duration of the lock by using a --- 2-step pattern: --- --- 1) creating the constraint as NOT VALID; this allows a constraint to be --- created (a meta-data operation) without verifying the column data. This --- limits the exclusive lock duration to be milli-seconds. --- --- 2) then the 2nd step performs the actual validation of the table column --- data; however, that operation only requires a SHARED LOCK on a table, --- meaning that things like READ (select) operations can function normally. --- --- Set a short lock timeout...no one should be updating a table (yet); --- lock requests are queued, so we don't want to hang around if some other --- process currently has a lock. If we don't get the requested lock in less --- than 100ms, then the script will exit/fail. -${logic.psql-only} set lock_timeout = 100; - --- alter table creates an exclusive lock while it validates the data for the --- table on which the constraint is being defined. We'll create the constraint --- in 'NOT VALID' mode which allows the constraint to created but not validated, --- resulting in a very fast meta-data only change. --- --- A side note for reviewers; the BFD standard naming convention calls for --- including the table name(s) as part of constraint name. We deviate slightly --- from this for the '_new' tables since: --- a) we are not currently using the original constraint name(s) --- b) by naming the constraints to use its original name, we eliminate --- the necessity to alter the constraint names once we rename all the --- _new tables back to their original name(s). --- --- Wrap in a transaction; acquiring a lock can only be done inside a transaction. --- We are explicitly starting a transaction to minimize exclusive lock duration; --- doing an ALTER TABLE implicitly acquires an EXCLUSIVE LOCK on the table and in --- theory, the lock would last only as long as the ALTER TABLE operation(s) were --- in progress. However, the flyway .conf file for this script turns off flyway --- transaction processing to allow this script to be in complete control of the --- transaction and its associated commit (which releases the lock). - -${logic.psql-only} begin; -alter table if exists public.carrier_claims_new - add constraint carrier_claims_bene_id_to_beneficiaries - foreign key (bene_id) -${logic.hsql-only} references public.beneficiaries_new (bene_id); -${logic.psql-only} references public.beneficiaries_new not valid; --- release the lock by either a commit or rollback of the transaction. -${logic.psql-only} commit; - --- The remaining constraint defintion(s) follows the pattern from above; wrap --- things in a transaction, add the constraint using 'not valid' mode, and then --- committing the transaction. We'll validate all our 'invalid' constraints in --- the next section of this Flyway script. - -${logic.psql-only} begin; -alter table if exists public.dme_claims_new - add constraint dme_claims_bene_id_to_beneficiaries - foreign key (bene_id) -${logic.hsql-only} references public.beneficiaries_new (bene_id); -${logic.psql-only} references public.beneficiaries_new not valid; -${logic.psql-only} commit; - -${logic.psql-only} begin; -alter table if exists public.hha_claims_new - add constraint hha_claims_bene_id_to_beneficiaries - foreign key (bene_id) -${logic.hsql-only} references public.beneficiaries_new (bene_id); -${logic.psql-only} references public.beneficiaries_new not valid; -${logic.psql-only} commit; - -${logic.psql-only} begin; -alter table if exists public.hospice_claims_new - add constraint hospice_claims_bene_id_to_beneficiaries - foreign key (bene_id) -${logic.hsql-only} references public.beneficiaries_new (bene_id); -${logic.psql-only} references public.beneficiaries_new not valid; -${logic.psql-only} commit; - -${logic.psql-only} begin; -alter table if exists public.inpatient_claims_new - add constraint inpatient_claims_bene_id_to_beneficiaries - foreign key (bene_id) -${logic.hsql-only} references public.beneficiaries_new (bene_id); -${logic.psql-only} references public.beneficiaries_new not valid; -${logic.psql-only} commit; - -${logic.psql-only} begin; -alter table if exists public.outpatient_claims_new - add constraint outpatient_claims_bene_id_to_beneficiaries - foreign key (bene_id) -${logic.hsql-only} references public.beneficiaries_new (bene_id); -${logic.psql-only} references public.beneficiaries_new not valid; -${logic.psql-only} commit; - -${logic.psql-only} begin; -alter table if exists public.partd_events_new - add constraint partd_events_bene_id_to_beneficiaries - foreign key (bene_id) -${logic.hsql-only} references public.beneficiaries_new (bene_id); -${logic.psql-only} references public.beneficiaries_new not valid; -${logic.psql-only} commit; - -${logic.psql-only} begin; -alter table if exists public.snf_claims_new - add constraint snf_claims_bene_id_to_beneficiaries - foreign key (bene_id) -${logic.hsql-only} references public.beneficiaries_new (bene_id); -${logic.psql-only} references public.beneficiaries_new not valid; -${logic.psql-only} commit; - --- the rest of the processing will be wrapped in a transaction; a validation --- of a constraint operates in shared access mode (i.e. allows read/select), --- so no need to have any further table locking. However, since we've turned --- off flyway transaction processing, we are now responsible for committing --- the changes. -${logic.psql-only} begin; - -${logic.psql-only} alter table public.carrier_claims_new -${logic.psql-only} validate constraint carrier_claims_bene_id_to_beneficiaries; - -${logic.psql-only} alter table if exists public.dme_claims_new -${logic.psql-only} validate constraint dme_claims_bene_id_to_beneficiaries; - -${logic.psql-only} alter table if exists public.hha_claims_new -${logic.psql-only} validate constraint hha_claims_bene_id_to_beneficiaries; - -${logic.psql-only} alter table if exists public.hospice_claims_new -${logic.psql-only} validate constraint hospice_claims_bene_id_to_beneficiaries; - -${logic.psql-only} alter table if exists public.inpatient_claims_new -${logic.psql-only} validate constraint inpatient_claims_bene_id_to_beneficiaries; - -${logic.psql-only} alter table if exists public.outpatient_claims_new -${logic.psql-only} validate constraint outpatient_claims_bene_id_to_beneficiaries; - -${logic.psql-only} alter table if exists public.partd_events_new -${logic.psql-only} validate constraint partd_events_bene_id_to_beneficiaries; - -${logic.psql-only} alter table if exists public.snf_claims_new -${logic.psql-only} validate constraint snf_claims_bene_id_to_beneficiaries; - -${logic.psql-only} commit; \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V88__new_schema_create_views.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V88__new_schema_create_views.sql deleted file mode 100644 index c82e08d324..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V88__new_schema_create_views.sql +++ /dev/null @@ -1,117 +0,0 @@ --- NEW_SCHEMA_CREATE_VIEWS.SQL --- --- This flyway script creates db views over the schema _new tables. This --- allows the BFD services code, in particular the generated entity beans, --- to point to updatable views instead of actual tables. This slight of hand --- allows us to introduce a subsequent flyway script which will then get the --- entire schema back to original table names, FK constraint names, index names, --- etc. without any db downtime. --- --- NOTE: for psql (Postgres) we create the view 'with check option' which --- enables the view to be updatable. - --- carrier_claims and carrier_claim_lines -create view carrier_claim_lines as - select * from carrier_claim_lines_new - ${logic.psql-only} with check option - ; -create view carrier_claims as - select * from carrier_claims_new - ${logic.psql-only} with check option - ; - - -- dme_claims and dme_claim_lines -create view dme_claim_lines as - select * from dme_claim_lines_new - ${logic.psql-only} with check option - ; -create view dme_claims as - select * from dme_claims_new - ${logic.psql-only} with check option - ; - --- hha_claims and hha_claim_lines -create view hha_claim_lines as - select * from hha_claim_lines_new - ${logic.psql-only} with check option - ; -create view hha_claims as - select * from hha_claims_new - ${logic.psql-only} with check option - ; - --- hospice_claims and hospice_claim_lines -create view hospice_claim_lines as - select * from hospice_claim_lines_new - ${logic.psql-only} with check option - ; -create view hospice_claims as - select * from hospice_claims_new - ${logic.psql-only} with check option - ; - --- inpatient_claims and inpatient_claim_lines -create view inpatient_claim_lines as - select * from inpatient_claim_lines_new - ${logic.psql-only} with check option - ; -create view inpatient_claims as - select * from inpatient_claims_new - ${logic.psql-only} with check option - ; - --- outpatient_claims and outpatient_claim_lines -create view outpatient_claim_lines as - select * from outpatient_claim_lines_new - ${logic.psql-only} with check option - ; -create view outpatient_claims as - select * from outpatient_claims_new - ${logic.psql-only} with check option - ; - --- partd_events -create view partd_events as - select * from partd_events_new - ${logic.psql-only} with check option - ; - --- snf_claims and snf_claim_lines -create view snf_claim_lines as - select * from snf_claim_lines_new - ${logic.psql-only} with check option - ; -create view snf_claims as - select * from snf_claims_new - ${logic.psql-only} with check option - ; - --- beneficiaries_history -create view beneficiaries_history as - select * from beneficiaries_history_new - ${logic.psql-only} with check option - ; - --- medicare_beneficiaryid_history -create view medicare_beneficiaryid_history as - select * from medicare_beneficiaryid_history_new - ${logic.psql-only} with check option - ; - --- beneficiary_monthly -create view beneficiary_monthly as - select * from beneficiary_monthly_new - ${logic.psql-only} with check option - ; - --- beneficiaries -create view beneficiaries as - select * from beneficiaries_new - ${logic.psql-only} with check option - ; - --- skipped_rif_records -create view skipped_rif_records as - select * from skipped_rif_records_new - ${logic.psql-only} with check option - ; \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V89__drop_obsolete_rda_metadata_table.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V89__drop_obsolete_rda_metadata_table.sql deleted file mode 100644 index bc1d7d24de..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V89__drop_obsolete_rda_metadata_table.sql +++ /dev/null @@ -1,11 +0,0 @@ --- --- This table has been replaced by claim_message_meta_data so we can safely remove it. --- - -drop table rda.rda_api_claim_message_meta_data; - --- --- This sequence was only used for the dropped rda_api_claim_message_meta_data;table. --- - -drop sequence rda.rda_api_claim_message_meta_data_meta_data_id_seq; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V8__Add_beneficiary_hicnHash_index.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V8__Add_beneficiary_hicnHash_index.sql deleted file mode 100644 index d5fc8743f9..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V8__Add_beneficiary_hicnHash_index.sql +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Resolves https://issues.hhsdevcloud.us/browse/CBBD-403. - * - * Adds a non-unique index to the "Beneficiaries"."hicn" column, which is used - * to store a 1-way cryptographic hash of each beneficiary's HICN. - * - * Why is this index non-unique? Because about 1700 out of 60M beneficiary - * HICNs have duplicates. Current opinion of folks is that this is a source - * data entry/records problem and non-resolvable. - * - * Why is this index needed? Because the Blue Button 2.0 frontend application - * will lookup beneficiaries by their HICN hash. - */ - - -create index ${logic.index-create-concurrently} "Beneficiaries_hicn_idx" - on "Beneficiaries" ("hicn"); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V90__new_schema_rename_to_original.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V90__new_schema_rename_to_original.sql deleted file mode 100644 index c7d51f54ed..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V90__new_schema_rename_to_original.sql +++ /dev/null @@ -1,534 +0,0 @@ --- NEW_SCHEMA_RENAME_TO ORIGINAL --- --- This flyway script is intended to a perform final fixup of BFD database --- table names, index names, and constraint names. It also removed (dropped) --- current db views so that BFD services will now point to actual db tables. --- --- BFD services app previously deployed code with entity beans pointing to --- db view(s) that followed a naming convention of: --- --- : current db "[table_name]_new" and drop the "_new" suffix. --- : change BFD services entity beans to point to the db view name --- --- In theory, we should not need to make any code changes since the current --- BFD app services are pointing to db views that match the same name as --- this script's table renames. However, there is a minor bit of code in the --- PipelineTestUtils.java (marked by a TODO) that needed to be removed; prior --- code would construct a table name by deriving it from the entity bean class. --- However, since the entity beans were pointing to views, the code had to --- construct an actual table name by appending "_new" to the name in order for --- the TRUNCATE TABLE invocation to work. So that code was removed (basically --- reverting back to its original state/name). - --- ===================== --- beneficiaries --- ===================== - --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.beneficiaries_new_pkey rename to beneficiaries_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key; --- note the use of cascade, which will drop constraints tied to beneficiaries_new.bene_id. -${logic.hsql-only} alter table public.beneficiaries_new -${logic.hsql-only} drop constraint public.beneficiaries_new_pkey cascade; -${logic.hsql-only} alter table public.beneficiaries_new -${logic.hsql-only} add constraint beneficiaries_pkey primary key (bene_id); - --- both psql and hsql support non-primary key index renaming -alter index ${logic.psql-only} if exists - public.beneficiaries_new_hicn_idx rename to beneficiaries_hicn_idx; -alter index ${logic.psql-only} if exists - public.beneficiaries_new_mbi_hash_idx rename to beneficiaries_mbi_hash_idx; -alter index ${logic.psql-only} if exists - public.beneficiaries_new_ptd_cntrct_number_jan_id_idx rename to beneficiaries_ptd_cntrct_number_jan_id_idx; -alter index ${logic.psql-only} if exists - public.beneficiaries_new_ptd_cntrct_number_feb_id_idx rename to beneficiaries_ptd_cntrct_number_feb_id_idx; -alter index ${logic.psql-only} if exists - public.beneficiaries_new_ptd_cntrct_number_mar_id_idx rename to beneficiaries_ptd_cntrct_number_mar_id_idx; -alter index ${logic.psql-only} if exists - public.beneficiaries_new_ptd_cntrct_number_apr_id_idx rename to beneficiaries_ptd_cntrct_number_apr_id_idx; -alter index ${logic.psql-only} if exists - public.beneficiaries_new_ptd_cntrct_number_may_id_idx rename to beneficiaries_ptd_cntrct_number_may_id_idx; -alter index ${logic.psql-only} if exists - public.beneficiaries_new_ptd_cntrct_number_jun_id_idx rename to beneficiaries_ptd_cntrct_number_jun_id_idx; -alter index ${logic.psql-only} if exists - public.beneficiaries_new_ptd_cntrct_number_jul_id_idx rename to beneficiaries_ptd_cntrct_number_jul_id_idx; -alter index ${logic.psql-only} if exists - public.beneficiaries_new_ptd_cntrct_number_aug_id_idx rename to beneficiaries_ptd_cntrct_number_aug_id_idx; -alter index ${logic.psql-only} if exists - public.beneficiaries_new_ptd_cntrct_number_sept_id_idx rename to beneficiaries_ptd_cntrct_number_sept_id_idx; -alter index ${logic.psql-only} if exists - public.beneficiaries_new_ptd_cntrct_number_oct_id_idx rename to beneficiaries_ptd_cntrct_number_oct_id_idx; -alter index ${logic.psql-only} if exists - public.beneficiaries_new_ptd_cntrct_number_nov_id_idx rename to beneficiaries_ptd_cntrct_number_nov_id_idx; -alter index ${logic.psql-only} if exists - public.beneficiaries_new_ptd_cntrct_number_dec_id_idx rename to beneficiaries_ptd_cntrct_number_dec_id_idx; - --- ===================== --- beneficiaries_history --- ===================== --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.beneficiaries_history_new_pkey -${logic.psql-only} rename to beneficiaries_history_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key -${logic.hsql-only} alter table public.beneficiaries_history_new -${logic.hsql-only} drop constraint public.beneficiaries_history_new_pkey; -${logic.hsql-only} alter table public.beneficiaries_history_new -${logic.hsql-only} add constraint beneficiaries_history_pkey primary key (bene_history_id); - --- change the name of the index for bene_id -alter index ${logic.psql-only} if exists - public.beneficiaries_history_new_bene_id_idx rename to beneficiaries_history_bene_id_idx; - --- change the name of the index for bene_crnt_hic_num -alter index ${logic.psql-only} if exists - public.beneficiaries_history_new_hicn_idx rename to beneficiaries_history_hicn_idx; - --- change the name of the index for mbi_hash -alter index ${logic.psql-only} if exists - public.beneficiaries_history_new_mbi_hash_idx rename to beneficiaries_history_mbi_hash_idx; - --- for hsql, we previously dropped the primary key with cascade, so we need --- to actually create the fk constraint -alter table if exists public.beneficiaries_history_new -${logic.hsql-only} add constraint beneficiaries_history_to_beneficiaries foreign key (bene_id) -${logic.hsql-only} references public.beneficiaries_new (bene_id); -${logic.psql-only} rename constraint beneficiaries_history_new_to_benficiaries -${logic.psql-only} to beneficiaries_history_to_beneficiaries; - --- ================================== --- medicare_beneficiaryid_history_new --- ================================== --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.medicare_beneficiaryid_history_new_pkey -${logic.psql-only} rename to medicare_beneficiaryid_history_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key -${logic.hsql-only} alter table public.medicare_beneficiaryid_history_new -${logic.hsql-only} drop constraint public.medicare_beneficiaryid_history_new_pkey; -${logic.hsql-only} alter table public.medicare_beneficiaryid_history_new -${logic.hsql-only} add constraint medicare_beneficiaryid_history_pkey primary key (bene_mbi_id); - --- change the name of the index for bene_id -alter index ${logic.psql-only} if exists - public.medicare_beneficiaryid_history_new_bene_id_idx rename to medicare_beneficiaryid_history_bene_id_idx; - -alter table if exists public.medicare_beneficiaryid_history_new -${logic.hsql-only} add constraint medicare_beneficiaryid_history_to_benficiaries foreign key (bene_id) -${logic.hsql-only} references public.beneficiaries_new (bene_id); -${logic.psql-only} rename constraint medicare_beneficiaryid_history_new_to_benficiaries -${logic.psql-only} to medicare_beneficiaryid_history_to_benficiaries; - --- ===================== --- beneficiary_monthly --- ===================== --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.beneficiary_monthly_new_pkey -${logic.psql-only} rename to beneficiary_monthly_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key -${logic.hsql-only} alter table public.beneficiary_monthly_new -${logic.hsql-only} drop constraint public.beneficiary_monthly_new_pkey; -${logic.hsql-only} alter table public.beneficiary_monthly_new -${logic.hsql-only} add constraint beneficiary_monthly_pkey primary key (bene_id, year_month); - -alter index ${logic.psql-only} if exists - public.beneficiary_monthly_new_partd_contract_year_month_bene_id_idx - rename to beneficiary_monthly_partd_contract_year_month_bene_id_idx; - -alter table if exists public.beneficiary_monthly_new -${logic.hsql-only} add constraint beneficiary_monthly_to_benficiaries foreign key (bene_id) -${logic.hsql-only} references public.beneficiaries_new (bene_id); -${logic.psql-only} rename constraint beneficiary_monthly_new_to_benficiaries -${logic.psql-only} to beneficiary_monthly_to_benficiaries; - --- ===================== --- skipped_rif_records --- ===================== --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.skipped_rif_records_new_pkey -${logic.psql-only} rename to skipped_rif_records_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key -${logic.hsql-only} alter table public.skipped_rif_records_new -${logic.hsql-only} drop constraint public.skipped_rif_records_new_pkey; -${logic.hsql-only} alter table public.skipped_rif_records_new -${logic.hsql-only} add constraint skipped_rif_records_pkey primary key (record_id); - -alter index ${logic.psql-only} if exists - public.skipped_rif_records_new_bene_id_idx - rename to skipped_rif_records_bene_id_idx; - --- ===================== --- carrier_claims --- ===================== --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.carrier_claims_new_pkey -${logic.psql-only} rename to carrier_claims_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key -${logic.hsql-only} alter table public.carrier_claims_new -${logic.hsql-only} drop constraint public.carrier_claims_new_pkey cascade; -${logic.hsql-only} alter table public.carrier_claims_new -${logic.hsql-only} add constraint carrier_claims_pkey primary key (clm_id); - -alter index ${logic.psql-only} if exists - public.carrier_claims_new_bene_id_idx - rename to carrier_claims_bene_id_idx; - --- ===================== --- carrier_claim_lines --- ===================== --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.carrier_claim_lines_new_pkey -${logic.psql-only} rename to carrier_claim_lines_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key -${logic.hsql-only} alter table public.carrier_claim_lines_new -${logic.hsql-only} drop constraint public.carrier_claim_lines_new_pkey cascade; -${logic.hsql-only} alter table public.carrier_claim_lines_new -${logic.hsql-only} add constraint carrier_claim_lines_pkey primary key (clm_id, line_num); - --- ===================== --- dme_claims --- ===================== --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.dme_claims_new_pkey -${logic.psql-only} rename to dme_claims_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key -${logic.hsql-only} alter table public.carrier_claims_new -${logic.hsql-only} drop constraint public.dme_claims_new_pkey cascade;; -${logic.hsql-only} alter table public.dme_claims_new -${logic.hsql-only} add constraint dme_claims_pkey primary key (clm_id); - -alter index ${logic.psql-only} if exists - public.dme_claims_new_bene_id_idx - rename to dme_claims_bene_id_idx; - --- ===================== --- dme_claim_lines --- ===================== --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.dme_claim_lines_new_pkey -${logic.psql-only} rename to dme_claim_lines_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key -${logic.hsql-only} alter table public.dme_claim_lines_new -${logic.hsql-only} drop constraint public.dme_claim_lines_new_pkey; -${logic.hsql-only} alter table public.dme_claim_lines_new -${logic.hsql-only} add constraint dme_claim_lines_pkey primary key (clm_id, line_num); - --- ===================== --- hha_claims --- ===================== --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.hha_claims_new_pkey -${logic.psql-only} rename to hha_claims_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key -${logic.hsql-only} alter table public.hha_claims_new -${logic.hsql-only} drop constraint public.hha_claims_new_pkey cascade;; -${logic.hsql-only} alter table public.hha_claims_new -${logic.hsql-only} add constraint hha_claims_pkey primary key (clm_id); - -alter index ${logic.psql-only} if exists - public.hha_claims_new_bene_id_idx - rename to hha_claims_bene_id_idx; - --- ===================== --- hha_claim_lines --- ===================== --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.hha_claim_lines_new_pkey -${logic.psql-only} rename to hha_claim_lines_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key -${logic.hsql-only} alter table public.hha_claim_lines_new -${logic.hsql-only} drop constraint public.hha_claim_lines_new_pkey; -${logic.hsql-only} alter table public.hha_claim_lines_new -${logic.hsql-only} add constraint hha_claim_lines_pkey primary key (clm_id, clm_line_num); - --- ===================== --- hospice_claims --- ===================== --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.hospice_claims_new_pkey -${logic.psql-only} rename to hospice_claims_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key -${logic.hsql-only} alter table public.hospice_claims_new -${logic.hsql-only} drop constraint public.hospice_claims_new_pkey cascade;; -${logic.hsql-only} alter table public.hospice_claims_new -${logic.hsql-only} add constraint hospice_claims_pkey primary key (clm_id); - -alter index ${logic.psql-only} if exists - public.hospice_claims_new_bene_id_idx - rename to hospice_claims_bene_id_idx; - --- ===================== --- hospice_claim_lines --- ===================== --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.hospice_claim_lines_new_pkey -${logic.psql-only} rename to hospice_claim_lines_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key -${logic.hsql-only} alter table public.hospice_claim_lines_new -${logic.hsql-only} drop constraint public.hospice_claim_lines_new_pkey; -${logic.hsql-only} alter table public.hospice_claim_lines_new -${logic.hsql-only} add constraint hospice_claim_lines_pkey primary key (clm_id, clm_line_num); - --- ===================== --- inpatient_claims --- ===================== --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.inpatient_claims_new_pkey -${logic.psql-only} rename to inpatient_claims_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key -${logic.hsql-only} alter table public.inpatient_claims_new -${logic.hsql-only} drop constraint public.inpatient_claims_new_pkey cascade;; -${logic.hsql-only} alter table public.inpatient_claims_new -${logic.hsql-only} add constraint inpatient_claims_pkey primary key (clm_id); - -alter index ${logic.psql-only} if exists - public.inpatient_claims_new_bene_id_idx - rename to inpatient_claims_bene_id_idx; - --- ===================== --- inpatient_claim_lines --- ===================== --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.inpatient_claim_lines_new_pkey -${logic.psql-only} rename to inpatient_claim_lines_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key -${logic.hsql-only} alter table public.inpatient_claim_lines_new -${logic.hsql-only} drop constraint public.inpatient_claim_lines_new_pkey; -${logic.hsql-only} alter table public.inpatient_claim_lines_new -${logic.hsql-only} add constraint inpatient_claim_lines_pkey primary key (clm_id, clm_line_num); - --- ===================== --- outpatient_claims --- ===================== --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.outpatient_claims_new_pkey -${logic.psql-only} rename to outpatient_claims_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key -${logic.hsql-only} alter table public.outpatient_claims_new -${logic.hsql-only} drop constraint public.outpatient_claims_new_pkey cascade;; -${logic.hsql-only} alter table public.outpatient_claims_new -${logic.hsql-only} add constraint outpatient_claims_pkey primary key (clm_id); - -alter index ${logic.psql-only} if exists - public.outpatient_claims_new_bene_id_idx - rename to outpatient_claims_bene_id_idx; - --- ===================== --- outpatient_claim_lines --- ===================== --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.outpatient_claim_lines_new_pkey -${logic.psql-only} rename to outpatient_claim_lines_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key -${logic.hsql-only} alter table public.outpatient_claim_lines_new -${logic.hsql-only} drop constraint public.outpatient_claim_lines_new_pkey; -${logic.hsql-only} alter table public.outpatient_claim_lines_new -${logic.hsql-only} add constraint outpatient_claim_lines_pkey primary key (clm_id, clm_line_num); - --- ===================== --- partd_events --- ===================== --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.partd_events_new_pkey -${logic.psql-only} rename to partd_events_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key -${logic.hsql-only} alter table public.partd_events_new -${logic.hsql-only} drop constraint public.partd_events_new_pkey cascade;; -${logic.hsql-only} alter table public.partd_events_new -${logic.hsql-only} add constraint partd_events_pkey primary key (pde_id); - -alter index ${logic.psql-only} if exists - public.partd_events_new_bene_id_idx - rename to partd_events_bene_id_idx; - --- ===================== --- snf_claims --- ===================== --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.snf_claims_new_pkey -${logic.psql-only} rename to snf_claims_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key -${logic.hsql-only} alter table public.snf_claims_new -${logic.hsql-only} drop constraint public.snf_claims_new_pkey cascade;; -${logic.hsql-only} alter table public.snf_claims_new -${logic.hsql-only} add constraint snf_claims_pkey primary key (clm_id); - -alter index ${logic.psql-only} if exists - public.snf_claims_new_bene_id_idx - rename to snf_claims_bene_id_idx; - --- ===================== --- snf_claim_lines --- ===================== --- psql allows you to rename primary key -${logic.psql-only} alter index if exists public.snf_claim_lines_new_pkey -${logic.psql-only} rename to snf_claim_lines_pkey; - --- hsql doesn't support rename on primary key; we'll drop and re-create primary key -${logic.hsql-only} alter table public.snf_claim_lines_new -${logic.hsql-only} drop constraint public.snf_claim_lines_new_pkey; -${logic.hsql-only} alter table public.snf_claim_lines_new -${logic.hsql-only} add constraint snf_claim_lines_pkey primary key (clm_id, clm_line_num); - --- ======================================================================== --- final fixup: --- : drop view(s) named "" --- : rename "_new" tables to "" --- ======================================================================== - --- beneficiaries -drop view ${logic.psql-only} if exists - beneficiaries; - -alter table ${logic.psql-only} if exists - public.beneficiaries_new rename to beneficiaries; - --- beneficiaries_history -drop view ${logic.psql-only} if exists - beneficiaries_history; - -alter table ${logic.psql-only} if exists - public.beneficiaries_history_new rename to beneficiaries_history; - --- medicare_beneficiaryid_history -drop view ${logic.psql-only} if exists - medicare_beneficiaryid_history; - -alter table ${logic.psql-only} if exists - public.medicare_beneficiaryid_history_new rename to medicare_beneficiaryid_history; - --- beneficiary_monthly -drop view ${logic.psql-only} if exists - beneficiary_monthly; - -alter table ${logic.psql-only} if exists - public.beneficiary_monthly_new rename to beneficiary_monthly; - --- skipped_rif_records -drop view ${logic.psql-only} if exists - skipped_rif_records; - -alter table ${logic.psql-only} if exists - public.skipped_rif_records_new rename to skipped_rif_records; - --- carrier_claims -drop view ${logic.psql-only} if exists - carrier_claims; - -alter table ${logic.psql-only} if exists - public.carrier_claims_new rename to carrier_claims; - --- carrier_claim_lines -drop view ${logic.psql-only} if exists - carrier_claim_lines; - -alter table ${logic.psql-only} if exists - public.carrier_claim_lines_new rename to carrier_claim_lines; - --- dme_claims -drop view ${logic.psql-only} if exists - dme_claims; - -alter table ${logic.psql-only} if exists - public.dme_claims_new rename to dme_claims; - --- dme_claim_lines -drop view ${logic.psql-only} if exists - dme_claim_lines; - -alter table ${logic.psql-only} if exists - public.dme_claim_lines_new rename to dme_claim_lines; - --- hha_claims -drop view ${logic.psql-only} if exists - hha_claims; - -alter table ${logic.psql-only} if exists - public.hha_claims_new rename to hha_claims; - --- hha_claim_lines -drop view ${logic.psql-only} if exists - hha_claim_lines; - -alter table ${logic.psql-only} if exists - public.hha_claim_lines_new rename to hha_claim_lines; - --- hospice_claims -drop view ${logic.psql-only} if exists - hospice_claims; - -alter table ${logic.psql-only} if exists - public.hospice_claims_new rename to hospice_claims; - --- hospice_claim_lines -drop view ${logic.psql-only} if exists - hospice_claim_lines; - -alter table ${logic.psql-only} if exists - public.hospice_claim_lines_new rename to hospice_claim_lines; - --- inpatient_claims -drop view ${logic.psql-only} if exists - inpatient_claims; - -alter table ${logic.psql-only} if exists - public.inpatient_claims_new rename to inpatient_claims; - --- inpatient_claim_lines -drop view ${logic.psql-only} if exists - inpatient_claim_lines; - -alter table ${logic.psql-only} if exists - public.inpatient_claim_lines_new rename to inpatient_claim_lines; - --- outpatient_claims -drop view ${logic.psql-only} if exists - outpatient_claims; - -alter table ${logic.psql-only} if exists - public.outpatient_claims_new rename to outpatient_claims; - --- outpatient_claim_lines -drop view ${logic.psql-only} if exists - outpatient_claim_lines; - -alter table ${logic.psql-only} if exists - public.outpatient_claim_lines_new rename to outpatient_claim_lines; - --- partd_events -drop view ${logic.psql-only} if exists - partd_events; - -alter table ${logic.psql-only} if exists - public.partd_events_new rename to partd_events; - --- snf_claims -drop view ${logic.psql-only} if exists - snf_claims; - -alter table ${logic.psql-only} if exists - public.snf_claims_new rename to snf_claims; - --- snf_claim_lines -drop view ${logic.psql-only} if exists - snf_claim_lines; - -alter table ${logic.psql-only} if exists - public.snf_claim_lines_new rename to snf_claim_lines; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V91__add_clm_grp_index.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V91__add_clm_grp_index.sql deleted file mode 100644 index 01d4eca463..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V91__add_clm_grp_index.sql +++ /dev/null @@ -1,28 +0,0 @@ --- ADD CLM_GRP_ID INDEX --- --- This flyway script is intended to add an index on clm_grp_id for a handful --- of tables that need their clm_grp_ids cleaned up for certain synthetic data. --- This index is temporary and will be removed in a subsequent script. - --- This is done in psql only since this index is only required for a one-time --- cleanup script against the actual database. - --- ===================== --- carrier_claims --- ===================== -${logic.psql-only} create index concurrently if not exists clm_grp_id_index on public.carrier_claims(clm_grp_id); - --- ===================== --- inpatient_claims --- ===================== -${logic.psql-only} create index concurrently if not exists clm_grp_id_index on public.inpatient_claims(clm_grp_id); - --- ===================== --- outpatient_claims --- ===================== -${logic.psql-only} create index concurrently if not exists clm_grp_id_index on public.outpatient_claims(clm_grp_id); - --- ===================== --- partd_events --- ===================== -${logic.psql-only} create index concurrently if not exists clm_grp_id_index on public.partd_events(clm_grp_id); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V92__add_clm_grp_index_correction.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V92__add_clm_grp_index_correction.sql deleted file mode 100644 index 1c41adefc5..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V92__add_clm_grp_index_correction.sql +++ /dev/null @@ -1,24 +0,0 @@ --- ADD CLM_GRP_ID INDEX --- --- This flyway script is intended to add an index on clm_grp_id for a handful --- of tables that need their clm_grp_ids cleaned up for certain synthetic data. --- This index is temporary and will be removed in a subsequent script. - --- This is done in psql only since this index is only required for a one-time --- cleanup script against the actual database. This script corrects the previous --- script which did not have unique names for each index. - --- ===================== --- inpatient_claims --- ===================== -${logic.psql-only} create index concurrently if not exists clm_grp_id_index_2 on public.inpatient_claims(clm_grp_id); - --- ===================== --- outpatient_claims --- ===================== -${logic.psql-only} create index concurrently if not exists clm_grp_id_index_3 on public.outpatient_claims(clm_grp_id); - --- ===================== --- partd_events --- ===================== -${logic.psql-only} create index concurrently if not exists clm_grp_id_index_4 on public.partd_events(clm_grp_id); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V93__remove_clm_grp_index.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V93__remove_clm_grp_index.sql deleted file mode 100644 index e0007f2470..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V93__remove_clm_grp_index.sql +++ /dev/null @@ -1,27 +0,0 @@ --- REMOVE CLM_GRP_ID INDEX --- --- This flyway script is intended to remove an index on clm_grp_id for a handful --- of tables that needed their clm_grp_ids cleaned up for certain synthetic data. --- This index was temporary and can now be removed since the data cleanup is complete. - --- This is done in psql only since this was only added in the real databases. - --- ===================== --- carrier_claims --- ===================== -${logic.psql-only} drop index concurrently if exists clm_grp_id_index; - --- ===================== --- inpatient_claims --- ===================== -${logic.psql-only} drop index concurrently if exists clm_grp_id_index_2; - --- ===================== --- outpatient_claims --- ===================== -${logic.psql-only} drop index concurrently if exists clm_grp_id_index_3; - --- ===================== --- partd_events --- ===================== -${logic.psql-only} drop index concurrently if exists clm_grp_id_index_4; \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V94__new_schema_final_cleanup.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V94__new_schema_final_cleanup.sql deleted file mode 100644 index f8cd55614a..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V94__new_schema_final_cleanup.sql +++ /dev/null @@ -1,55 +0,0 @@ --- NEW_SCHEMA_FINAL-CLEANUP.SQL --- --- This flyway script is intended to a perform final cleanup of BFD database --- schema changes related to using BIGINT for bene_id, clm_id, and clm_grp_id. --- --- In particular, this script: --- 1) fixes spelling errors in constraint names --- 2) removes some unused table indexes. --- 3) drop db triggers that are no longer used and in fact are invalid. --- 4) drops some tables that were temporarily used during various data analysis efforts --- 5) drop unused procedures that were used from db trigger(s) --- --- fix spelling error 'benficiaries' in constraint names --- -${logic.psql-only} alter table if exists public.medicare_beneficiaryid_history -${logic.psql-only} rename constraint medicare_beneficiaryid_history_to_benficiaries -${logic.psql-only} to medicare_beneficiaryid_history_to_beneficiaries; - -${logic.psql-only} alter table if exists public.beneficiary_monthly -${logic.psql-only} rename constraint beneficiary_monthly_to_benficiaries -${logic.psql-only} to beneficiary_monthly_to_beneficiaries; - --- remove unused indexes from beneficiaries table -drop index if exists beneficiaries_ptd_cntrct_number_jan_id_idx; -drop index if exists beneficiaries_ptd_cntrct_number_feb_id_idx; -drop index if exists beneficiaries_ptd_cntrct_number_mar_id_idx; -drop index if exists beneficiaries_ptd_cntrct_number_apr_id_idx; -drop index if exists beneficiaries_ptd_cntrct_number_may_id_idx; -drop index if exists beneficiaries_ptd_cntrct_number_jun_id_idx; -drop index if exists beneficiaries_ptd_cntrct_number_jul_id_idx; -drop index if exists beneficiaries_ptd_cntrct_number_aug_id_idx; -drop index if exists beneficiaries_ptd_cntrct_number_sept_id_idx; -drop index if exists beneficiaries_ptd_cntrct_number_oct_id_idx; -drop index if exists beneficiaries_ptd_cntrct_number_nov_id_idx; -drop index if exists beneficiaries_ptd_cntrct_number_dec_id_idx; - --- drop unused / invalid db triggers. -${logic.psql-only} drop trigger if exists -${logic.psql-only} beneficiaries_populate_bene_id_numeric -${logic.psql-only} on beneficiary_monthly cascade; - -${logic.psql-only} drop trigger if exists -${logic.psql-only} track_bene_monthly_change -${logic.psql-only} on beneficiary_monthly cascade; - --- drop tables that were used (at some point in time) for --- various data analysis or trouble-shooting efforts. -${logic.psql-only} drop table if exists bene_hist_temp; -${logic.psql-only} drop table if exists beneficiary_monthly_audit; -${logic.psql-only} drop table if exists ccw_load_temp; -${logic.psql-only} drop table if exists public."TempBene"; - --- cleanup old stored procedures -${logic.psql-only} drop procedure if exists load_from_ccw; -${logic.psql-only} drop procedure if exists update_bene_monthly; \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V95__add_rda_record_source.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V95__add_rda_record_source.sql deleted file mode 100644 index 8c53c9f482..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V95__add_rda_record_source.sql +++ /dev/null @@ -1,10 +0,0 @@ --- As part of the 0.8 RDA API update, record source information such as phase, phase seq number, and transmission timestamp are now available - -alter table rda.claim_message_meta_data add column phase smallint; -alter table rda.claim_message_meta_data add column phase_seq_num smallint; -alter table rda.claim_message_meta_data add column extract_date date; -alter table rda.claim_message_meta_data add column transmission_timestamp timestamp with time zone; - -alter table rda.mcs_details add column idr_dtl_number smallint; -update rda.mcs_details set idr_dtl_number = (priority + 1); -alter table rda.mcs_details alter column idr_dtl_number set not null; \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V96__add_rda_message_error_obsolete_column.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V96__add_rda_message_error_obsolete_column.sql deleted file mode 100644 index 55050ac842..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V96__add_rda_message_error_obsolete_column.sql +++ /dev/null @@ -1 +0,0 @@ -alter table rda.message_errors add column status varchar(20) default 'UNRESOLVED' not null; \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V97__recreate_pre_adj_child_tables.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V97__recreate_pre_adj_child_tables.sql deleted file mode 100644 index a7a56ab957..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V97__recreate_pre_adj_child_tables.sql +++ /dev/null @@ -1,198 +0,0 @@ --- Rebuild the schema to match new RDA specifications and truncate tables to end soft launch - -drop table rda.fiss_audit_trails; -drop table rda.fiss_diagnosis_codes; -drop table rda.fiss_payers; -drop table rda.fiss_proc_codes; -drop table rda.mcs_adjustments; -drop table rda.mcs_audits; -drop table rda.mcs_details; -drop table rda.mcs_diagnosis_codes; -drop table rda.mcs_locations; -truncate table rda.fiss_claims; -truncate table rda.mcs_claims; -truncate table rda.message_errors; -truncate table rda.rda_api_progress; --- Not truncating the metadata or MBI tables -alter table rda.claim_message_meta_data ${logic.alter-rename-column} received_date ${logic.rename-to} last_updated; -alter index rda.claim_message_meta_data_received_date_idx rename to claim_message_meta_data_last_updated_idx; - -/* - * fiss_audit_trails - */ -CREATE TABLE rda.fiss_audit_trails ( - dcn varchar(23) NOT NULL, - rda_position smallint NOT NULL, - badt_status varchar(1), - badt_loc varchar(5), - badt_oper_id varchar(9), - badt_reas varchar(5), - badt_curr_date date, - CONSTRAINT fiss_audit_trails_key PRIMARY KEY (dcn, rda_position), - CONSTRAINT fiss_audit_trails_parent FOREIGN KEY (dcn) REFERENCES rda.fiss_claims(dcn) -); - -/* - * fiss_diagnosis_codes - */ -CREATE TABLE rda.fiss_diagnosis_codes ( - dcn varchar(23) NOT NULL, - rda_position smallint NOT NULL, - diag_cd2 varchar(7) NOT NULL, - diag_poa_ind varchar(1), - bit_flags varchar(4), - CONSTRAINT fiss_diagnosis_codes_key PRIMARY KEY (dcn, rda_position), - CONSTRAINT fiss_diagnosis_codes_parent FOREIGN KEY (dcn) REFERENCES rda.fiss_claims(dcn) -); - -/* - * fiss_payers - */ -CREATE TABLE rda.fiss_payers ( - dcn varchar(23) NOT NULL, - rda_position smallint NOT NULL, - payer_type varchar(20), - payers_id varchar(1), - payers_name varchar(32), - rel_ind varchar(1), - assign_ind varchar(1), - provider_number varchar(13), - adj_dcn_icn varchar(23), - prior_pmt decimal(11,2), - est_amt_due decimal(11,2), - bene_rel varchar(2), - bene_last_name varchar(15), - bene_first_name varchar(10), - bene_mid_init varchar(1), - bene_ssn_hic varchar(19), - insured_rel varchar(2), - insured_name varchar(25), - insured_ssn_hic varchar(19), - insured_group_name varchar(17), - insured_group_nbr varchar(20), - bene_dob date, - bene_sex varchar(1), - treat_auth_cd varchar(18), - insured_sex varchar(1), - insured_rel_x12 varchar(2), - insured_dob date, - insured_dob_text varchar(9), - CONSTRAINT fiss_payers_key PRIMARY KEY (dcn, rda_position), - CONSTRAINT fiss_payers_parent FOREIGN KEY (dcn) REFERENCES rda.fiss_claims(dcn) -); - -/* - * fiss_proc_codes - */ -CREATE TABLE rda.fiss_proc_codes ( - dcn varchar(23) NOT NULL, - rda_position smallint NOT NULL, - proc_code varchar(10) NOT NULL, - proc_flag varchar(4), - proc_date date, - CONSTRAINT fiss_proc_codes_key PRIMARY KEY (dcn, rda_position), - CONSTRAINT fiss_proc_codes_parent FOREIGN KEY (dcn) REFERENCES rda.fiss_claims(dcn) -); - -/* - * mcs_adjustments - */ -CREATE TABLE rda.mcs_adjustments ( - idr_clm_hd_icn varchar(15) NOT NULL, - rda_position smallint NOT NULL, - idr_adj_date date, - idr_xref_icn varchar(15), - idr_adj_clerk varchar(4), - idr_init_ccn varchar(15), - idr_adj_chk_wrt_dt date, - idr_adj_b_eomb_amt decimal(7,2), - idr_adj_p_eomb_amt decimal(7,2), - CONSTRAINT mcs_adjustments_key PRIMARY KEY (idr_clm_hd_icn, rda_position), - CONSTRAINT mcs_adjustments_parent FOREIGN KEY (idr_clm_hd_icn) REFERENCES rda.mcs_claims(idr_clm_hd_icn) -); - -/* - * mcs_audits - */ -CREATE TABLE rda.mcs_audits ( - idr_clm_hd_icn varchar(15) NOT NULL, - rda_position smallint NOT NULL, - idr_j_audit_num int, - idr_j_audit_ind varchar(1), - idr_j_audit_disp varchar(1), - CONSTRAINT mcs_audits_key PRIMARY KEY (idr_clm_hd_icn, rda_position), - CONSTRAINT mcs_audits_parent FOREIGN KEY (idr_clm_hd_icn) REFERENCES rda.mcs_claims(idr_clm_hd_icn) -); - -/* - * mcs_details - */ -CREATE TABLE rda.mcs_details ( - idr_clm_hd_icn varchar(15) NOT NULL, - idr_dtl_number smallint NOT NULL, - idr_dtl_status varchar(1), - idr_dtl_from_date date, - idr_dtl_to_date date, - idr_proc_code varchar(5), - idr_mod_one varchar(2), - idr_mod_two varchar(2), - idr_mod_three varchar(2), - idr_mod_four varchar(2), - idr_dtl_diag_icd_type varchar(1), - idr_dtl_primary_diag_code varchar(7), - idr_k_pos_lname_org varchar(60), - idr_k_pos_fname varchar(35), - idr_k_pos_mname varchar(25), - idr_k_pos_addr1 varchar(55), - idr_k_pos_addr2_1st varchar(30), - idr_k_pos_addr2_2nd varchar(25), - idr_k_pos_city varchar(30), - idr_k_pos_state varchar(2), - idr_k_pos_zip varchar(15), - idr_tos varchar(1), - idr_two_digit_pos varchar(2), - idr_dtl_rend_type varchar(2), - idr_dtl_rend_spec varchar(2), - idr_dtl_rend_npi varchar(10), - idr_dtl_rend_prov varchar(10), - idr_k_dtl_fac_prov_npi varchar(10), - idr_dtl_amb_pickup_addres1 varchar(25), - idr_dtl_amb_pickup_addres2 varchar(20), - idr_dtl_amb_pickup_city varchar(20), - idr_dtl_amb_pickup_state varchar(2), - idr_dtl_amb_pickup_zipcode varchar(9), - idr_dtl_amb_dropoff_name varchar(24), - idr_dtl_amb_dropoff_addr_l1 varchar(25), - idr_dtl_amb_dropoff_addr_l2 varchar(20), - idr_dtl_amb_dropoff_city varchar(20), - idr_dtl_amb_dropoff_state varchar(2), - idr_dtl_amb_dropoff_zipcode varchar(9), - CONSTRAINT mcs_details_key PRIMARY KEY (idr_clm_hd_icn, idr_dtl_number), - CONSTRAINT mcs_details_parent FOREIGN KEY (idr_clm_hd_icn) REFERENCES rda.mcs_claims(idr_clm_hd_icn) -); - -/* - * mcs_diagnosis_codes - */ -CREATE TABLE rda.mcs_diagnosis_codes ( - idr_clm_hd_icn varchar(15) NOT NULL, - rda_position smallint NOT NULL, - idr_diag_icd_type varchar(1), - idr_diag_code varchar(7) NOT NULL, - CONSTRAINT mcs_diagnosis_codes_key PRIMARY KEY (idr_clm_hd_icn, rda_position), - CONSTRAINT mcs_diagnosis_codes_parent FOREIGN KEY (idr_clm_hd_icn) REFERENCES rda.mcs_claims(idr_clm_hd_icn) -); - -/* - * mcs_locations - */ -CREATE TABLE rda.mcs_locations ( - idr_clm_hd_icn varchar(15) NOT NULL, - rda_position smallint NOT NULL, - idr_loc_clerk varchar(4), - idr_loc_code varchar(3), - idr_loc_date date, - idr_loc_actv_code varchar(1), - CONSTRAINT mcs_locations_key PRIMARY KEY (idr_clm_hd_icn, rda_position), - CONSTRAINT mcs_locations_parent FOREIGN KEY (idr_clm_hd_icn) REFERENCES rda.mcs_claims(idr_clm_hd_icn) -); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V98__rda_0_10_0_updates.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V98__rda_0_10_0_updates.sql deleted file mode 100644 index fb240c623a..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V98__rda_0_10_0_updates.sql +++ /dev/null @@ -1,7 +0,0 @@ --- As part of the 0.10 RDA API update, new raw text fields are added for select date fields and FISS diag_cd_2 is now nullable - -alter table rda.fiss_claims add adm_date_text varchar(10); -alter table rda.fiss_claims add stmt_cov_from_date_text varchar(10); -alter table rda.fiss_claims add stmt_cov_to_date_text varchar(10); - -alter table rda.fiss_diagnosis_codes alter column diag_cd2 drop not null; diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V99__ccw_eoy_2022_audit_changes.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V99__ccw_eoy_2022_audit_changes.sql deleted file mode 100644 index a3058b0deb..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V99__ccw_eoy_2022_audit_changes.sql +++ /dev/null @@ -1,101 +0,0 @@ --- This flyway script is intended to track changes to the beneficiary_monthly --- table, primarily during the first couple of weeks of a new calendar year. --- This enables BFD to track data changes to the beneficiary_monthly table; --- visibility into BENEFICIARY ref_yr changes do not effect previous year's data. - -${logic.psql-only} DROP TABLE IF EXISTS public.beneficiary_monthly_audit; -${logic.psql-only} DROP TRIGGER IF EXISTS audit_ccw_update ON beneficiary_monthly; - --- The sequence used for the `skipped_rif_records.record_id` column. -CREATE SEQUENCE ${logic.psql-only} IF NOT EXISTS - bene_monthly_audit_seq - AS bigint ${logic.sequence-start} 1 ${logic.sequence-increment} 1 - NO CYCLE; - --- Create beneficiary_monthly_audit table; we'll create the table in both HSQL & PSQL --- but we don't bother with setting up the trigger in HSQL as this will only be useful --- during that timeframe when we are actively vetting CCW end-of-year/new year data. --- -CREATE TABLE public.beneficiary_monthly_audit( - bene_id bigint NOT NULL, - year_month date NOT NULL, - partd_contract_number_id varchar(5), - partc_contract_number_id varchar(5), - medicare_status_code varchar(2), - fips_state_cnty_code varchar(5), - entitlement_buy_in_ind char(1), - hmo_indicator_ind char(1), - medicaid_dual_eligibility_code varchar(2), - partd_pbp_number_id varchar(3), - partd_retiree_drug_subsidy_ind char(1), - partd_segment_number_id varchar(3), - partd_low_income_cost_share_group_code varchar(2), - partc_pbp_number_id varchar(3), - partc_plan_type_code varchar(3), - operation char(1) NOT NULL, - update_ts timestamp NOT NULL, - seq_id bigint NOT NULL, - CONSTRAINT beneficiary_monthly_audit_pkey PRIMARY KEY (seq_id)); - -CREATE INDEX beneficiary_monthly_audit_bene_id_year_month_idx - on beneficiary_monthly_audit (bene_id, year_month); --- --- Create function that tracks UPDATE operations to the beneficiary_monthly table. --- This will create a row in beneficiary_monthly_audit to reflect the update operation --- performed on beneficiary_monthly; psql variable TG_OP denotes the operation.} --- -${logic.psql-only} CREATE OR REPLACE FUNCTION public.track_bene_monthly_change() RETURNS TRIGGER -${logic.psql-only} AS $beneficiary_monthly_audit$ -${logic.psql-only} BEGIN -${logic.psql-only} IF (TG_OP = 'UPDATE') THEN -${logic.psql-only} INSERT INTO public.beneficiary_monthly_audit VALUES (OLD.*, 'U', now(), nextval('public.bene_monthly_audit_seq')); -${logic.psql-only} RETURN NEW; -${logic.psql-only} END IF; -${logic.psql-only} RETURN NULL; -- result is ignored since this is an AFTER trigger -${logic.psql-only} END; -${logic.psql-only} $beneficiary_monthly_audit$ LANGUAGE plpgsql; - --- Setup UPDATE triggers. --- -${logic.psql-only} DROP TRIGGER IF EXISTS audit_ccw_update ON beneficiary_monthly; - --- We'll track any changes to the beneficiary_monthly table; however, --- since we create 12 'empty' buckets at the beginning of a new REF_YR, --- we'd pretty much always see UPDATEs where the 'OLD' is zero'd out --- and the 'NEW' has value(s); those sort of updates are expected and --- frankly not interesting (nor problematic). So we'll check the original --- Part C/D contract ID(s) to verify that any changes were meaningful. --- -${logic.psql-only} CREATE TRIGGER audit_ccw_update -${logic.psql-only} AFTER UPDATE ON public.beneficiary_monthly -${logic.psql-only} FOR EACH ROW -${logic.psql-only} WHEN (( -${logic.psql-only} OLD.partd_contract_number_id <> '0' OR -${logic.psql-only} OLD.partc_contract_number_id <> '0') -${logic.psql-only} AND (( -${logic.psql-only} OLD.partd_contract_number_id, -${logic.psql-only} OLD.partc_contract_number_id, -${logic.psql-only} OLD.medicare_status_code, -${logic.psql-only} OLD.fips_state_cnty_code, -${logic.psql-only} OLD.entitlement_buy_in_ind, -${logic.psql-only} OLD.hmo_indicator_ind, -${logic.psql-only} OLD.medicaid_dual_eligibility_code, -${logic.psql-only} OLD.partd_pbp_number_id, -${logic.psql-only} OLD.partd_segment_number_id, -${logic.psql-only} OLD.partd_low_income_cost_share_group_code, -${logic.psql-only} OLD.partc_pbp_number_id, -${logic.psql-only} OLD.partc_plan_type_code) -${logic.psql-only} IS DISTINCT FROM ( -${logic.psql-only} NEW.partd_contract_number_id, -${logic.psql-only} NEW.partc_contract_number_id, -${logic.psql-only} NEW.medicare_status_code, -${logic.psql-only} NEW.fips_state_cnty_code, -${logic.psql-only} NEW.entitlement_buy_in_ind, -${logic.psql-only} NEW.hmo_indicator_ind, -${logic.psql-only} NEW.medicaid_dual_eligibility_code, -${logic.psql-only} NEW.partd_pbp_number_id, -${logic.psql-only} NEW.partd_segment_number_id, -${logic.psql-only} NEW.partd_low_income_cost_share_group_code, -${logic.psql-only} NEW.partc_pbp_number_id, -${logic.psql-only} NEW.partc_plan_type_code)) ) -${logic.psql-only} EXECUTE FUNCTION track_bene_monthly_change(); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V9__Create_beneficiary_history_table.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V9__Create_beneficiary_history_table.sql deleted file mode 100644 index 6e7f396670..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/V9__Create_beneficiary_history_table.sql +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Creates the beneficiary ID history table required by the application. This - * schema is derived from the JPA metadata, via the - * gov.hhs.cms.bluebutton.data.pipeline.rif.schema.HibernateSchemaPrinter - * utility. - */ - -${logic.tablespaces-escape} SET default_tablespace = fhirdb_ts2; - -create table "BeneficiariesHistory" ( - "beneficiaryHistoryId" bigint not null, - "beneficiaryId" varchar(15) not null, - "birthDate" date not null, - "hicn" varchar(64) not null, - "sex" char(1) not null, - constraint "BeneficiariesHistory_pkey" primary key ("beneficiaryHistoryId") -) -${logic.tablespaces-escape} tablespace "beneficiaries_ts" -; - -/* - * FIXME For consistency, sequence names should be mixed-case, but can't be, due - * to https://hibernate.atlassian.net/browse/HHH-9431. - */ -create sequence beneficiaryHistory_beneficiaryHistoryId_seq ${logic.sequence-start} 1 ${logic.sequence-increment} 50; - -create index "BeneficiariesHistory_hicn_idx" - on "BeneficiariesHistory" ("hicn"); \ No newline at end of file diff --git a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/createSchema.sql b/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/createSchema.sql deleted file mode 100644 index bac37a2daf..0000000000 --- a/apps/bfd-model/bfd-model-rif/src/main/resources/db/migration.old/createSchema.sql +++ /dev/null @@ -1,183 +0,0 @@ -/* - This callback (https://flywaydb.org/documentation/concepts/callbacks) is executed once, on new db installations, before Flyway - starts creating schemas. - - It adds a set of database admin functions to help us manage role-based access and ownership, while keeping versioned migrations DRY. - - Functions (all functions are idempotent): - 1. revoke_schema_privs(schema_name TEXT, role_name TEXT) - Revokes schema privileges from a role (tables, sequences, routines). - 2. create_role_if_not_exists(role_name TEXT) - Adds a new role, skipping if the role already exists. - 3. revoke_db_privs(db_name TEXT, role_name TEXT) - Revokes db privs (includes running revoke_schema_privs on all schemas in a db). - 4. add_reader_role_to_schema(role_name TEXT, schema_name TEXT) - Adds a read only role applied to the schema - 5. add_writer_role_to_schema(role_name TEXT, schema_name TEXT) - Read+Write - 6. add_migrator_role_to_schema(role_name TEXT, schema_name TEXT) - Read+Write+DDL - 7. add_db_group_if_not_exists(db_name TEXT, group_name TEXT) - Adds a new group, skipping if the group already exists. - 8. set_fhirdb_owner(role_name TEXT) - Makes the designated role own all existing and future tables, views, sequences, and routines in all schemas. - -*/ - -${logic.psql-only} -- -${logic.psql-only} -- revoke_schema_privs -${logic.psql-only} -- -${logic.psql-only} CREATE OR REPLACE FUNCTION revoke_schema_privs(schema_name TEXT, role_name TEXT) RETURNS void AS $func$ -${logic.psql-only} BEGIN -${logic.psql-only} IF EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = role_name) THEN -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I REVOKE ALL ON TABLES FROM %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I REVOKE ALL ON SEQUENCES FROM %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I REVOKE ALL ON ROUTINES FROM %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('REVOKE ALL ON ALL TABLES IN SCHEMA %I FROM %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('REVOKE ALL ON ALL SEQUENCES IN SCHEMA %I FROM %I;', schema_name, role_name); -${logic.psql-only} BEGIN -${logic.psql-only} -- we will get an error in aws if we try to modify perms on routines installed via system extensions -${logic.psql-only} -- (pg_stat_statements, etc).. just log and ignore the error -${logic.psql-only} EXECUTE format('REVOKE ALL ON ALL ROUTINES IN SCHEMA %I FROM %I;', schema_name, role_name); -${logic.psql-only} EXCEPTION WHEN SQLSTATE '42501' THEN RAISE NOTICE '%, skipping', SQLERRM USING ERRCODE = SQLSTATE; -${logic.psql-only} END; -${logic.psql-only} EXECUTE format('REVOKE ALL ON SCHEMA %I FROM %I;', schema_name, role_name); -${logic.psql-only} ELSE -${logic.psql-only} RAISE NOTICE 'role "%" not found, skipping', role_name; -${logic.psql-only} END IF; -${logic.psql-only} END $func$ LANGUAGE plpgsql; -${logic.psql-only} -${logic.psql-only} -- -${logic.psql-only} -- create_role_if_not_exists -${logic.psql-only} -- -${logic.psql-only} CREATE OR REPLACE FUNCTION create_role_if_not_exists(role_name TEXT) RETURNS void AS $func$ -${logic.psql-only} BEGIN -${logic.psql-only} EXECUTE format('CREATE ROLE %I;', role_name); -${logic.psql-only} EXCEPTION WHEN SQLSTATE '42710' THEN RAISE NOTICE '%, skipping', SQLERRM USING ERRCODE = SQLSTATE; -${logic.psql-only} END $func$ LANGUAGE plpgsql; -${logic.psql-only} -${logic.psql-only} -- -${logic.psql-only} -- revoke_db_privs -${logic.psql-only} -- -${logic.psql-only} CREATE OR REPLACE FUNCTION revoke_db_privs(db_name TEXT, role_name TEXT) RETURNS void AS $func$ -${logic.psql-only} DECLARE -${logic.psql-only} t record; -${logic.psql-only} BEGIN -${logic.psql-only} IF EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = role_name) THEN -${logic.psql-only} FOR t IN -${logic.psql-only} SELECT nspname FROM pg_catalog.pg_namespace -${logic.psql-only} WHERE nspname NOT LIKE 'pg_%' -${logic.psql-only} AND nspname != 'information_schema' -${logic.psql-only} AND nspname != 'public' -${logic.psql-only} LOOP -${logic.psql-only} PERFORM revoke_schema_privs(t.nspname, role_name); -${logic.psql-only} END LOOP; -${logic.psql-only} EXECUTE format('REVOKE ALL ON DATABASE %I FROM %I;', db_name, role_name); -${logic.psql-only} END IF; -${logic.psql-only} END $func$ LANGUAGE plpgsql; -${logic.psql-only} -${logic.psql-only} -- -${logic.psql-only} -- add_reader_role_to_schema -${logic.psql-only} -- -${logic.psql-only} CREATE OR REPLACE FUNCTION add_reader_role_to_schema(role_name TEXT, schema_name TEXT) RETURNS void AS $func$ -${logic.psql-only} BEGIN -${logic.psql-only} PERFORM create_role_if_not_exists(role_name); -${logic.psql-only} PERFORM revoke_schema_privs(role_name, schema_name); -${logic.psql-only} EXECUTE format('GRANT USAGE ON SCHEMA %I TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('GRANT SELECT ON ALL TABLES IN SCHEMA %I TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('GRANT SELECT ON ALL SEQUENCES IN SCHEMA %I TO %I;', schema_name, role_name); --curval -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT SELECT ON TABLES TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT SELECT ON SEQUENCES TO %I;', schema_name, role_name); -${logic.psql-only} END $func$ LANGUAGE plpgsql; -${logic.psql-only} -${logic.psql-only} -- -${logic.psql-only} -- add_writer_role_to_schema -${logic.psql-only} -- -${logic.psql-only} CREATE OR REPLACE FUNCTION add_writer_role_to_schema(role_name TEXT, schema_name TEXT) RETURNS void AS $func$ -${logic.psql-only} BEGIN -${logic.psql-only} PERFORM create_role_if_not_exists(role_name); -${logic.psql-only} PERFORM revoke_schema_privs(role_name, schema_name); -${logic.psql-only} EXECUTE format('GRANT USAGE ON SCHEMA %I TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA %I TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('GRANT USAGE ON ALL SEQUENCES IN SCHEMA %I TO %I;', schema_name, role_name); --curval, nextval -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT USAGE ON SEQUENCES TO %I;', schema_name, role_name); -${logic.psql-only} END $func$ LANGUAGE plpgsql; -${logic.psql-only} -${logic.psql-only} -- -${logic.psql-only} -- add_migrator_role_to_schema -${logic.psql-only} -- -${logic.psql-only} CREATE OR REPLACE FUNCTION add_migrator_role_to_schema(role_name TEXT, schema_name TEXT) RETURNS void AS $func$ -${logic.psql-only} BEGIN -${logic.psql-only} PERFORM create_role_if_not_exists(role_name); -${logic.psql-only} PERFORM revoke_schema_privs(role_name, schema_name); -${logic.psql-only} EXECUTE format('GRANT ALL ON SCHEMA %I TO %I;', schema_name, role_name); -- uwsage + create -${logic.psql-only} EXECUTE format('GRANT ALL ON ALL TABLES IN SCHEMA %I TO %I;', schema_name, role_name); -- tables/views -${logic.psql-only} EXECUTE format('GRANT ALL ON ALL SEQUENCES IN SCHEMA %I TO %I;', schema_name, role_name); --curval, nextval, setval -${logic.psql-only} BEGIN -${logic.psql-only} -- in aurora, we will get an error if we try to modify perms on routines installed via system extensions -${logic.psql-only} -- like pg_stat_statements, so just log the error and skip it -${logic.psql-only} EXECUTE format('GRANT ALL ON ALL ROUTINES IN SCHEMA %I TO %I;', schema_name, role_name); -${logic.psql-only} EXCEPTION WHEN SQLSTATE '42501' THEN RAISE NOTICE '%, skipping', SQLERRM USING ERRCODE = SQLSTATE; -${logic.psql-only} END; -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT ALL ON TABLES TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT ALL ON SEQUENCES TO %I;', schema_name, role_name); -${logic.psql-only} EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA %I GRANT ALL ON ROUTINES TO %I;', schema_name, role_name); -${logic.psql-only} END $func$ LANGUAGE plpgsql; -${logic.psql-only} -${logic.psql-only} -- -${logic.psql-only} -- add_db_group_if_not_exists -${logic.psql-only} -- -${logic.psql-only} CREATE OR REPLACE FUNCTION add_db_group_if_not_exists(db_name TEXT, group_name TEXT) RETURNS void AS $func$ -${logic.psql-only} BEGIN -${logic.psql-only} PERFORM create_role_if_not_exists(group_name); -${logic.psql-only} EXECUTE format('GRANT CONNECT ON DATABASE %I TO %I;', db_name, group_name); -${logic.psql-only} -- ignore dup errors -${logic.psql-only} EXCEPTION WHEN duplicate_object THEN RAISE NOTICE '%, skipping', SQLERRM USING ERRCODE = SQLSTATE; -${logic.psql-only} END $func$ LANGUAGE plpgsql; -${logic.psql-only} -${logic.psql-only} -- -${logic.psql-only} -- set_fhirdb_owner -${logic.psql-only} -- -${logic.psql-only} CREATE OR REPLACE FUNCTION set_fhirdb_owner(role_name TEXT) RETURNS void AS $func$ -${logic.psql-only} DECLARE -${logic.psql-only} t record; -${logic.psql-only} BEGIN -${logic.psql-only} -- make the fhirdb owner role own all schemas except public/system schemas -${logic.psql-only} FOR t IN -${logic.psql-only} SELECT nspname, nspowner FROM pg_catalog.pg_namespace -${logic.psql-only} WHERE nspname != 'public' AND nspname != 'information_schema' AND nspname NOT LIKE 'pg_%' -${logic.psql-only} LOOP -${logic.psql-only} EXECUTE format('GRANT %I TO %I;', role_name, CURRENT_USER); -${logic.psql-only} EXECUTE format('ALTER SCHEMA %I OWNER TO %I', t.nspname, role_name); -${logic.psql-only} END LOOP; -${logic.psql-only} -${logic.psql-only} -- make role_name own all tables/views in all non system schemas/tables -${logic.psql-only} FOR t IN -${logic.psql-only} SELECT table_schema, table_name -${logic.psql-only} FROM information_schema.tables -${logic.psql-only} WHERE table_type = 'BASE TABLE' -${logic.psql-only} AND table_schema NOT LIKE 'pg_%' -${logic.psql-only} AND table_schema != 'information_schema' -${logic.psql-only} AND table_name NOT LIKE 'pg_%' -${logic.psql-only} LOOP -${logic.psql-only} EXECUTE format('ALTER TABLE %I.%I OWNER TO %I;', t.table_schema, t.table_name, role_name); -${logic.psql-only} END LOOP; -${logic.psql-only} -${logic.psql-only} -- sequences -${logic.psql-only} FOR t IN -${logic.psql-only} SELECT sequence_schema, sequence_name -${logic.psql-only} FROM information_schema.sequences -${logic.psql-only} WHERE sequence_name NOT LIKE 'pg_%' -${logic.psql-only} AND sequence_schema != 'information_schema' -${logic.psql-only} AND sequence_schema NOT LIKE 'pg_%' -${logic.psql-only} LOOP -${logic.psql-only} EXECUTE format('ALTER SEQUENCE %I.%I OWNER TO %I;', t.sequence_schema, t.sequence_name, role_name); -${logic.psql-only} END LOOP; -${logic.psql-only} -${logic.psql-only} -- functions and procedures (routines) -${logic.psql-only} FOR t IN -${logic.psql-only} SELECT routine_schema, routine_name -${logic.psql-only} FROM information_schema.routines -${logic.psql-only} WHERE routine_schema != 'pg_catalog' AND routine_schema != 'information_schema' -${logic.psql-only} LOOP -${logic.psql-only} BEGIN -${logic.psql-only} -- in aws, we will get an error if we try to modify perms on routines installed via system extensions -${logic.psql-only} -- (pg_stat_statements, etc).. just log and ignore the error -${logic.psql-only} EXECUTE format('ALTER ROUTINE %I.%I OWNER TO %I;', t.routine_schema, t.routine_name, role_name); -${logic.psql-only} EXCEPTION WHEN SQLSTATE '42501' THEN RAISE NOTICE 'set_fhir_db_owner: %, skipping', SQLERRM USING ERRCODE = SQLSTATE; -${logic.psql-only} END; -${logic.psql-only} END LOOP; -${logic.psql-only} END $func$ LANGUAGE plpgsql; diff --git a/apps/bfd-shared-test-utils/src/main/java/gov/cms/bfd/DatabaseTestSchemaManager.java b/apps/bfd-shared-test-utils/src/main/java/gov/cms/bfd/DatabaseTestSchemaManager.java index 707e832cbd..66df8de29e 100644 --- a/apps/bfd-shared-test-utils/src/main/java/gov/cms/bfd/DatabaseTestSchemaManager.java +++ b/apps/bfd-shared-test-utils/src/main/java/gov/cms/bfd/DatabaseTestSchemaManager.java @@ -141,7 +141,6 @@ public static Map createScriptPlaceholdersMap(DataSource dataSou placeholders.put("logic.tablespaces-escape", "--"); placeholders.put("logic.drop-tablespaces-escape", ""); placeholders.put("logic.alter-column-type", "type"); - placeholders.put("logic.hsql-only-alter", "-- alter"); placeholders.put("logic.psql-only-alter", "alter"); placeholders.put("logic.alter-rename-column", "rename column"); placeholders.put("logic.alter-rename-constraint", "rename constraint"); @@ -151,7 +150,6 @@ public static Map createScriptPlaceholdersMap(DataSource dataSou placeholders.put("logic.sequence-increment", "increment"); placeholders.put("logic.perms", ""); placeholders.put("logic.psql-only", ""); - placeholders.put("logic.hsql-only", "-- "); } else { throw new RuntimeException("Unsupported database vendor"); } diff --git a/apps/bfd-shared-utils/src/main/java/gov/cms/bfd/sharedutils/database/DatabaseSchemaManager.java b/apps/bfd-shared-utils/src/main/java/gov/cms/bfd/sharedutils/database/DatabaseSchemaManager.java index 6838abab1f..0873dca081 100644 --- a/apps/bfd-shared-utils/src/main/java/gov/cms/bfd/sharedutils/database/DatabaseSchemaManager.java +++ b/apps/bfd-shared-utils/src/main/java/gov/cms/bfd/sharedutils/database/DatabaseSchemaManager.java @@ -166,7 +166,6 @@ private static Map createScriptPlaceholdersMap(DataSource dataSo placeholders.put("logic.tablespaces-escape", "--"); placeholders.put("logic.drop-tablespaces-escape", ""); placeholders.put("logic.alter-column-type", "type"); - placeholders.put("logic.hsql-only-alter", "-- alter"); placeholders.put("logic.psql-only-alter", "alter"); placeholders.put("logic.alter-rename-column", "rename column"); placeholders.put("logic.alter-rename-constraint", "rename constraint"); @@ -176,7 +175,6 @@ private static Map createScriptPlaceholdersMap(DataSource dataSo placeholders.put("logic.sequence-increment", "increment"); placeholders.put("logic.perms", ""); placeholders.put("logic.psql-only", ""); - placeholders.put("logic.hsql-only", "-- "); } else { throw new BadCodeMonkeyException( String.format( diff --git a/ops/Dockerfile b/ops/Dockerfile index 1fe74feef3..fd486ee6bf 100644 --- a/ops/Dockerfile +++ b/ops/Dockerfile @@ -5,7 +5,6 @@ RUN echo flyway.placeholders.type.int4=int4 > /flyway/conf/flyway.conf \ && echo flyway.placeholders.logic.tablespaces-escape=-- >> /flyway/conf/flyway.conf \ && echo flyway.placeholders.logic.drop-tablespaces-escape= >> /flyway/conf/flyway.conf \ && echo flyway.placeholders.logic.alter-column-type=type >> /flyway/conf/flyway.conf \ - && echo flyway.placeholders.logic.hsql-only-alter=-- alter >> /flyway/conf/flyway.conf \ && echo flyway.placeholders.logic.psql-only-alter=alter >> /flyway/conf/flyway.conf \ && echo flyway.placeholders.logic.alter-rename-column=rename column >> /flyway/conf/flyway.conf \ && echo flyway.placeholders.logic.alter-rename-constraint=rename constraint >> /flyway/conf/flyway.conf \ @@ -15,7 +14,6 @@ RUN echo flyway.placeholders.type.int4=int4 > /flyway/conf/flyway.conf \ && echo flyway.placeholders.logic.sequence-increment=increment >> /flyway/conf/flyway.conf \ && echo flyway.placeholders.logic.perms= >> /flyway/conf/flyway.conf \ && echo flyway.placeholders.logic.psql-only= >> /flyway/conf/flyway.conf \ - && echo flyway.placeholders.logic.hsql-only=-- >> /flyway/conf/flyway.conf \ && echo flyway.table=schema_version >> /flyway/conf/flyway.conf \ && echo flyway.schemas=public >> /flyway/conf/flyway.conf \ && echo flyway.url=jdbc:postgresql://db:5432/fhirdb >> /flyway/conf/flyway.conf \