Skip to content

Commit 8beaa38

Browse files
authored
Merge pull request #334 from Enterprise-CMCS/MCP_PRV_TMSIS_view_dev
IBM - DBDAART-15627 & DBDAART-15629: PRV & MCP TMSIS Views
2 parents ff93190 + eb97951 commit 8beaa38

File tree

20 files changed

+353
-258
lines changed

20 files changed

+353
-258
lines changed

taf/MCP/MCP.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,25 @@ def screen_runid(self, intbl, runtbl, runvars, outtbl, runtyp="C"):
4040
T.submitting_state = R.submitting_state and
4141
upper(T.state_plan_id_num) = R.state_plan_id_num"""
4242

43+
# retain tmsis table column names used in subsequent merge and in TAF_Metadata.py
44+
renames = [
45+
'tmsis_run_id as tms_run_id',
46+
'submtg_state_cd as submitting_state',
47+
]
48+
4349
# diststyle key distkey(state_plan_id_num)
4450
# compound sortkey (&&&runvars) as
4551
z = f"""
4652
create or replace temporary view {outtbl} as
4753
select
4854
T.*
49-
from
50-
{intbl} T
55+
from (
56+
select
57+
*,
58+
{ ','.join(renames) }
59+
from
60+
{intbl}
61+
) T
5162
inner join {runtbl} R
5263
{ on.format(runvars) }
5364
order by
@@ -78,7 +89,7 @@ def copy_activerows(self, intbl, collist, whr, outtbl):
7889
from
7990
{ intbl }
8091
where
81-
tms_is_active=1
92+
tmsis_actv_ind=1
8293
{ whr }
8394
order by
8495
tms_run_id,
@@ -90,21 +101,24 @@ def copy_activerows(self, intbl, collist, whr, outtbl):
90101
def copy_activerows_nts(self, intbl, collist, outtbl):
91102

92103
# diststyle even compound sortkey(tms_run_id, submitting_state)
104+
# upon conversion from using TMSIS tables to using TMSIS views
105+
# retain TMSIS table column names to preserve downstream processing
93106
z = f"""
94107
create or replace temporary view {outtbl} as
95108
select
96109
{ ', '.join(collist) }
97110
from (
98111
select
99112
*,
100-
submitting_state as submtg_state_cd
113+
tmsis_run_id as tms_run_id,
114+
submtg_state_cd as submitting_state
101115
from
102116
{intbl}
103117
where
104-
tms_is_active = 1 and
105-
tms_reporting_period is not null and
118+
tmsis_actv_ind = 1 and
119+
tmsis_rptg_prd is not null and
106120
tot_rec_cnt > 0 and
107-
trim(submitting_state) not in ('94','96'))
121+
trim(submtg_state_cd) not in ('94','96'))
108122
where
109123
1=1 { self.mcp.ST_FILTER() }
110124
order by

taf/MCP/MCP01.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def process_01_header(self, outtbl):
2121

2222
# copy managed care header table
2323
self.copy_activerows_nts(
24-
"tmsis.file_header_record_managed_care", cols01, "MC01_Header_Copy"
24+
"tmsis.tmsis_fhdr_rec_mc", cols01, "MC01_Header_Copy"
2525
)
2626

2727
# self.mcp.countrows('MC01_Header_Copy', 'cnt_active', 'MC01_Active')

taf/MCP/MCP02.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,33 @@ def process_02_mcmain(self, runtbl, outtbl):
2020
runlist = ["tms_run_id", "submitting_state"]
2121

2222
self.screen_runid(
23-
"tmsis.Managed_Care_Main", runtbl, runlist, "MC02_Main_Latest1", "M"
23+
"tmsis.Tmsis_Mc_Mn_Data", runtbl, runlist, "MC02_Main_Latest1", "M"
2424
)
2525

2626
# row count
2727
self.count_rows("MC02_Main_Latest1", "cnt_latest", "MC02_Latest")
2828

29+
# upon conversion from using TMSIS tables to using TMSIS views
30+
# retain TMSIS table column names to preserve downstream processing
2931
cols02 = [
30-
"tms_run_id",
31-
"tms_reporting_period",
32-
"submitting_state",
33-
"submitting_state as submtg_state_cd",
34-
"record_number",
32+
"tmsis_run_id as tms_run_id",
33+
"tmsis_rptg_prd as tms_reporting_period",
34+
"submtg_state_cd as submitting_state",
35+
"submtg_state_cd",
36+
"rec_num as record_number",
3537
"%upper_case(state_plan_id_num) as state_plan_id_num",
36-
"managed_care_main_rec_eff_date",
37-
"managed_care_main_rec_end_date",
38-
"%fix_old_dates(managed_care_contract_eff_date)",
39-
"case when managed_care_contract_eff_date is not null and managed_care_contract_end_date is null then to_date('9999-12-31') when to_date('1600-01-01') > managed_care_contract_end_date then to_date('1599-12-31') else managed_care_contract_end_date end as MC_CNTRCT_END_DT",
40-
"managed_care_name",
41-
"managed_care_program",
42-
"managed_care_plan_type",
43-
"reimbursement_arrangement",
44-
"managed_care_profit_status",
45-
"core_based_statistical_area_code",
46-
"percent_business",
47-
"managed_care_service_area",
38+
"mc_mn_rec_efctv_dt as managed_care_main_rec_eff_date",
39+
"mc_mn_rec_end_dt as managed_care_main_rec_end_date",
40+
"%fix_old_dates_rename(mc_cntrct_efctv_dt, managed_care_contract_eff_date)",
41+
"case when mc_cntrct_efctv_dt is not null and mc_cntrct_end_dt is null then to_date('9999-12-31') when to_date('1600-01-01') > mc_cntrct_end_dt then to_date('1599-12-31') else mc_cntrct_end_dt end as MC_CNTRCT_END_DT",
42+
"mc_name as managed_care_name",
43+
"mc_pgm_cd as managed_care_program",
44+
"mc_plan_type_cd as managed_care_plan_type",
45+
"reimbrsmt_arngmt_cd as reimbursement_arrangement",
46+
"mc_prft_stus_cd as managed_care_profit_status",
47+
"cbsa_cd as core_based_statistical_area_code",
48+
"busns_pct as percent_business",
49+
"mc_sarea_cd as managed_care_service_area",
4850
]
4951

5052
whr02 = "upper(state_plan_id_num) is not null"

taf/MCP/MCP03.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def process_03_location(self, runtbl, outtbl):
1919
runlist = ["tms_run_id", "submitting_state", "state_plan_id_num"]
2020

2121
self.screen_runid(
22-
"tmsis.Managed_care_location_and_contact_info",
22+
"tmsis.Tmsis_Mc_Lctn_Cntct",
2323
runtbl,
2424
runlist,
2525
"MC03_Location_Latest1",
@@ -29,27 +29,29 @@ def process_03_location(self, runtbl, outtbl):
2929
# row count
3030
self.count_rows("MC03_Location_Latest1", "cnt_latest", "MC03_Latest")
3131

32+
# upon conversion from using TMSIS tables to using TMSIS views
33+
# retain TMSIS table column names to preserve downstream processing
3234
cols03 = [
33-
"tms_run_id",
34-
"tms_reporting_period",
35-
"record_number",
36-
"submitting_state",
37-
"submitting_state as submtg_state_cd",
35+
"tmsis_run_id as tms_run_id",
36+
"tmsis_rptg_prd as tms_reporting_period",
37+
"rec_num as record_number",
38+
"submtg_state_cd as submitting_state",
39+
"submtg_state_cd",
3840
"%upper_case(state_plan_id_num) as state_plan_id_num",
39-
"%upper_case(managed_care_location_id) as managed_care_location_id",
40-
"%fix_old_dates(managed_care_location_and_contact_info_eff_date)",
41-
"%set_end_dt(managed_care_location_and_contact_info_end_date) as managed_care_location_and_contact_info_end_date",
42-
"%upper_case(managed_care_addr_ln1) as managed_care_addr_ln1",
43-
"managed_care_addr_ln2",
44-
"managed_care_addr_ln3",
45-
"managed_care_addr_type",
46-
"managed_care_city",
47-
"managed_care_county",
48-
"%upper_case(managed_care_state) as managed_care_state",
49-
"managed_care_zip_code",
41+
"%upper_case(mc_lctn_id) as managed_care_location_id",
42+
"%fix_old_dates_rename(mc_lctn_cntct_efctv_dt, managed_care_location_and_contact_info_eff_date)",
43+
"%set_end_dt(mc_lctn_cntct_end_dt) as managed_care_location_and_contact_info_end_date",
44+
"%upper_case(mc_line_1_adr) as managed_care_addr_ln1",
45+
"mc_line_2_adr as managed_care_addr_ln2",
46+
"mc_line_3_adr as managed_care_addr_ln3",
47+
"mc_adr_type_cd as managed_care_addr_type",
48+
"mc_city_name as managed_care_city",
49+
"mc_cnty_cd as managed_care_county",
50+
"%upper_case(mc_state_cd) as managed_care_state",
51+
"mc_zip_cd as managed_care_zip_code",
5052
]
5153

52-
whr03 = "managed_care_addr_type=3"
54+
whr03 = "mc_adr_type_cd=3"
5355

5456
self.copy_activerows(
5557
"MC03_Location_Latest1", cols03, whr03, "MC03_Location_Copy"

taf/MCP/MCP04.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def process_04_service_area(self, runtbl, outtbl):
1919
runlist = ["tms_run_id", "submitting_state", "state_plan_id_num"]
2020

2121
self.screen_runid(
22-
"tmsis.Managed_care_service_area",
22+
"tmsis.Tmsis_Mc_Sarea",
2323
runtbl,
2424
runlist,
2525
"MC04_Service_Area_Latest1",
@@ -28,19 +28,21 @@ def process_04_service_area(self, runtbl, outtbl):
2828
# row count
2929
self.count_rows("MC04_Service_Area_Latest1", "cnt_latest", "MC04_Latest")
3030

31+
# upon conversion from using TMSIS tables to using TMSIS views
32+
# retain TMSIS table column names to preserve downstream processing
3133
cols04 = [
32-
"tms_run_id",
33-
"tms_reporting_period",
34-
"record_number",
35-
"submitting_state",
36-
"submitting_state as submtg_state_cd",
34+
"tmsis_run_id as tms_run_id",
35+
"tmsis_rptg_prd as tms_reporting_period",
36+
"rec_num as record_number",
37+
"submtg_state_cd as submitting_state",
38+
"submtg_state_cd",
3739
f"""{ TAF_Closure.upper_case('state_plan_id_num')} as state_plan_id_num""",
38-
f"""{ TAF_Closure.upper_case('managed_care_service_area_name')} as managed_care_service_area_name""",
39-
f"""{ TAF_Closure.fix_old_dates('managed_care_service_area_eff_date')}""",
40-
f"""{ TAF_Closure.set_end_dt('managed_care_service_area_end_date')} as managed_care_service_area_end_date"""
40+
f"""{ TAF_Closure.upper_case('mc_sarea_name')} as managed_care_service_area_name""",
41+
f"""{ TAF_Closure.fix_old_dates_rename('mc_sarea_efctv_dt','managed_care_service_area_eff_date')}""",
42+
f"""{ TAF_Closure.set_end_dt('mc_sarea_end_dt')} as managed_care_service_area_end_date"""
4143
]
4244

43-
whr04 = "upper(managed_care_service_area_name) is not null"
45+
whr04 = "upper(mc_sarea_name) is not null"
4446

4547
self.copy_activerows(
4648
"MC04_Service_Area_Latest1", cols04, whr04, "MC04_Service_Area_Copy"

taf/MCP/MCP05.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def process_05_operating_authority(self, runtbl, outtbl):
1919
runlist = ["tms_run_id", "submitting_state", "state_plan_id_num"]
2020

2121
self.screen_runid(
22-
"tmsis.Managed_care_operating_authority",
22+
"tmsis.Tmsis_Mc_Oprtg_Authrty",
2323
runtbl,
2424
runlist,
2525
"MC05_Operating_Authority_Latest1",
@@ -28,27 +28,29 @@ def process_05_operating_authority(self, runtbl, outtbl):
2828
# row count
2929
self.count_rows("MC05_Operating_Authority_Latest1", "cnt_latest", "MC05_Latest")
3030

31+
# upon conversion from using TMSIS tables to using TMSIS views
32+
# retain TMSIS table column names to preserve downstream processing
3133
cols05 = [
32-
"tms_run_id",
33-
"tms_reporting_period",
34-
"record_number",
35-
"submitting_state",
36-
"submitting_state as submtg_state_cd",
34+
"tmsis_run_id as tms_run_id",
35+
"tmsis_rptg_prd as tms_reporting_period",
36+
"rec_num as record_number",
37+
"submtg_state_cd as submitting_state",
38+
"submtg_state_cd",
3739
"%upper_case(state_plan_id_num) as state_plan_id_num",
3840
"""case
39-
when length(trim(TRAILING FROM operating_authority))<2 and length(trim(TRAILING FROM operating_authority))>0 and operating_authority in ('1','2','3','4','5','6','7','8','9')
40-
then lpad(trim(TRAILING FROM operating_authority),2,'0')
41-
when trim(TRAILING FROM operating_authority) in ('01','02','03','04','05','06','07','08','09') or
42-
trim(TRAILING FROM operating_authority) in ('10','11','12','13','14','15','16','17','18','19','20','21','22','23')
43-
then trim(TRAILING FROM operating_authority)
41+
when length(trim(TRAILING FROM oprtg_authrty_cd))<2 and length(trim(TRAILING FROM oprtg_authrty_cd))>0 and oprtg_authrty_cd in ('1','2','3','4','5','6','7','8','9')
42+
then lpad(trim(TRAILING FROM oprtg_authrty_cd),2,'0')
43+
when trim(TRAILING FROM oprtg_authrty_cd) in ('01','02','03','04','05','06','07','08','09') or
44+
trim(TRAILING FROM oprtg_authrty_cd) in ('10','11','12','13','14','15','16','17','18','19','20','21','22','23')
45+
then trim(TRAILING FROM oprtg_authrty_cd)
4446
else null
4547
end as operating_authority""",
46-
"%upper_case(waiver_id) as waiver_id",
47-
"managed_care_op_authority_eff_date",
48-
"managed_care_op_authority_end_date",
48+
"%upper_case(wvr_id) as waiver_id",
49+
"mc_op_authrty_efctv_dt as managed_care_op_authority_eff_date",
50+
"mc_op_authrty_end_dt as managed_care_op_authority_end_date",
4951
]
5052

51-
whr05 = "(trim(TRAILING FROM operating_authority) in ('1','2','3','4','5','6','7','8','9') or trim(TRAILING FROM operating_authority) in ('01','02','03','04','05','06','07','08','09') or trim(TRAILING FROM operating_authority) in ('10','11','12','13','14','15','16','17','18','19','20','21','22','23')) or (upper(waiver_id) is not null)"
53+
whr05 = "(trim(TRAILING FROM oprtg_authrty_cd) in ('1','2','3','4','5','6','7','8','9') or trim(TRAILING FROM oprtg_authrty_cd) in ('01','02','03','04','05','06','07','08','09') or trim(TRAILING FROM oprtg_authrty_cd) in ('10','11','12','13','14','15','16','17','18','19','20','21','22','23')) or (upper(wvr_id) is not null)"
5254

5355
self.copy_activerows(
5456
"MC05_Operating_Authority_Latest1",

taf/MCP/MCP06.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def process_06_population(self, runtbl, outtbl):
2020
runlist = ["tms_run_id", "submitting_state", "state_plan_id_num"]
2121

2222
self.screen_runid(
23-
"tmsis.Managed_care_plan_population_enrolled",
23+
"tmsis.Tmsis_Mc_Plan_Pop_Enrld",
2424
runtbl,
2525
runlist,
2626
"MC06_Population_Latest1",
@@ -29,19 +29,21 @@ def process_06_population(self, runtbl, outtbl):
2929
# row count
3030
self.count_rows("MC06_Population_Latest1", "cnt_latest", "MC06_Latest")
3131

32+
# upon conversion from using TMSIS tables to using TMSIS views
33+
# retain TMSIS table column names to preserve downstream processing
3234
cols06 = [
33-
"tms_run_id",
34-
"tms_reporting_period",
35-
"record_number",
36-
"submitting_state",
37-
"submitting_state as submtg_state_cd",
35+
"tmsis_run_id as tms_run_id",
36+
"tmsis_rptg_prd as tms_reporting_period",
37+
"rec_num as record_number",
38+
"submtg_state_cd as submitting_state",
39+
"submtg_state_cd",
3840
"%upper_case(state_plan_id_num) as state_plan_id_num",
39-
"%zero_pad(managed_care_plan_pop, 2)",
40-
"%fix_old_dates(managed_care_plan_pop_eff_date)",
41-
"%set_end_dt(managed_care_plan_pop_end_date) as managed_care_plan_pop_end_date",
41+
"%zero_pad_rename(mc_plan_pop_cnt, 2, managed_care_plan_pop)",
42+
"%fix_old_dates_rename(mc_plan_pop_efctv_dt, managed_care_plan_pop_eff_date)",
43+
"%set_end_dt(mc_plan_pop_end_dt) as managed_care_plan_pop_end_date",
4244
]
4345

44-
whr06 = "managed_care_plan_pop is not null"
46+
whr06 = "mc_plan_pop_cnt is not null"
4547

4648
self.copy_activerows(
4749
"MC06_Population_Latest1", cols06, whr06, "MC06_Population_Copy"

taf/MCP/MCP07.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def process_07_accreditation(self, runtbl, outtbl):
2020
runlist = ["tms_run_id", "submitting_state", "state_plan_id_num"]
2121

2222
self.screen_runid(
23-
"tmsis.Managed_care_accreditation_organization",
23+
"tmsis.Tmsis_Mc_Acrdtn_Org",
2424
runtbl,
2525
runlist,
2626
"MC07_Accreditation_Latest1",
@@ -30,19 +30,21 @@ def process_07_accreditation(self, runtbl, outtbl):
3030
# row count
3131
self.count_rows("MC07_Accreditation_Latest1", "cnt_latest", "MC07_Latest")
3232

33+
# upon conversion from using TMSIS tables to using TMSIS views
34+
# retain TMSIS table column names to preserve downstream processing
3335
cols07 = [
34-
"tms_run_id",
35-
"tms_reporting_period",
36-
"record_number",
37-
"submitting_state",
38-
"submitting_state as submtg_state_cd",
36+
"tmsis_run_id as tms_run_id",
37+
"tmsis_rptg_prd as tms_reporting_period",
38+
"rec_num as record_number",
39+
"submtg_state_cd as submitting_state",
40+
"submtg_state_cd",
3941
"%upper_case(state_plan_id_num) as state_plan_id_num",
40-
"%zero_pad(accreditation_organization, 2)",
41-
"%fix_old_dates(date_accreditation_achieved)",
42-
"%set_end_dt(date_accreditation_end) as date_accreditation_end",
42+
"%zero_pad_rename(acrdtn_org_cd, 2, accreditation_organization)",
43+
"%fix_old_dates_rename(acrdtn_achvmt_dt, date_accreditation_achieved)",
44+
"%set_end_dt(acrdtn_end_dt) as date_accreditation_end",
4345
]
4446

45-
whr07 = "accreditation_organization is not null"
47+
whr07 = "acrdtn_org_cd is not null"
4648

4749
self.copy_activerows(
4850
"MC07_Accreditation_Latest1", cols07, whr07, "MC07_Accreditation_Copy"

0 commit comments

Comments
 (0)