54a62944aa
QCQA Integration * Merged in bugfix/npi_hotfix (pull request #305) double filter for duplicates * double filter for duplicates Approved-by: Katon Minhas * Merged in chore/npi (pull request #309) npi hotfix into main * npi hotfix into main * npi hotfix into main Approved-by: Alex Galarce * Merged in chore/irs (pull request #310) irs hotfix into main * irs hotfix into main * pass top sheet to irs hotfix func * docstring updates Approved-by: Alex Galarce * slight fix to methodology short fix * Merged in bugfix/all_cnc_hotfixes (pull request #302) DRAFT: Bugfix/all cnc hotfixes * Pipeline fix - health plan state * Update for prompt vs non-prompt fixes * Revert utils.find_regex_matches() * Remove prints * Non-prompt run * Health Plan State, IRS, NPI, LOB, Lesser, Prov 2, Default, Rate Standard, Contract Effective Date, Term Group * Merged in bugfix/agreement_name (pull request #294) contract title fixed * contract title fixed * Merged bugfix/all_cnc_hotfixes into bugfix/agreement_name Approved-by: Katon Minhas * All hotfixes added * Fixed utils * fix for clean_contract_effective_date * Merged in default-fix (pull request #296) moved default funcs to the top, dropped intermediate columns * moved default funcs to the top, dropped intermediate columns Approved-by: Katon Minhas * quick fix to dropping extra columns * Merged in bugfix/effective_date_meridian (pull request #297) fixed effective date for meridian contracts * fixed effective date for meridian contracts Approved-by: Kat… * Merged in hotfix/irs_tweak (pull request #303) returning None instead on str(N/A) * returning None instead on str(N/A) Approved-by: Katon Minhas * Merged in bugfix/npi_hotfix (pull request #305) double filter for duplicates * double filter for duplicates Approved-by: Katon Minhas * Merged in bugfix/all_cnc_hotfixes (pull request #302) DRAFT: Bugfix/all cnc hotfixes * Pipeline fix - health plan state * Update for prompt vs non-prompt fixes * Revert utils.find_regex_matches() * Remove prints * Non-prompt run * Health Plan State, IRS, NPI, LOB, Lesser, Prov 2, Default, Rate Standard, Contract Effective Date, Term Group * Merged in bugfix/agreement_name (pull request #294) contract title fixed * contract title fixed * Merged bugfix/all_cnc_hotfixes into bugfix/agreement_name Approved-by: Katon Minhas * All hotfixes added * Fixed utils * fix for clean_contract_effective_date * Merged in default-fix (pull request #296) moved default funcs to the top, dropped intermediate columns * moved default funcs to the top, dropped intermediate columns Approved-by: Katon Minhas * quick fix to dropping extra columns * Merged in bugfix/effective_date_meridian (pull request #297) fixed effective date for meridian contracts * fixed effective date for meridian contracts Approved-by: Kat… * Merged in hotfix/irs_tweak (pull request #303) returning None instead on str(N/A) * returning None instead on str(N/A) Approved-by: Katon Minhas * Merged in bugfix/npi_hotfix (pull request #305) double filter for duplicates * double filter for duplicates Approved-by: Katon Minhas * Merged in chore/npi (pull request #309) npi hotfix into main * npi hotfix into main * npi hotfix into main Approved-by: Alex Galarce * Merged in chore/irs (pull request #310) irs hotfix into main * irs hotfix into main * pass top sheet to irs hotfix func * docstring updates Approved-by: Alex Galarce * Merged in bugfix/clean_short_methodology (pull request #312) changed regex pattern in get_short_methodology * changed regex pattern in Approved-by: Katon Minhas * Merged in hotfix/filename_fix (pull request #314) filename corrected * filename corrected * Merged main into hotfix/filename_fix Approved-by: Katon Minhas * Merge remote-tracking branch 'remotes/origin/main' into HEAD * rearranged qcqa scripts/funcs and prep for merge w main, moved lots of stuff to postprocess * slight change to icm_number_fix * transitioned some qcqa funcs to postprocessing, added fields to qcqa report * Merged main into QCQA_Integration * reorganization of qa qc helpers, consolidate_output, qa_qc from Katon's feedback * adhoc and at scale qcqa ran successfully * fix to consolidate_output * Merge remote-tracking branch 'remotes/origin/main' into QCQA_Integration * Merged main into QCQA_Integration * small changes to npi_check, changed name of config.CONTRACT_FILE_NAME to config.FILE_NAME_COLUMN Approved-by: Katon Minhas
120 lines
3.1 KiB
Python
120 lines
3.1 KiB
Python
import pandas as pd
|
|
import re
|
|
import os
|
|
import numpy as np
|
|
|
|
import postprocessing_funcs
|
|
import valid
|
|
import prompts
|
|
import claude_funcs
|
|
import config
|
|
import utils
|
|
|
|
|
|
def b_postprocess(filename, df, pages):
|
|
|
|
if df.shape[0] > 0:
|
|
# Metadata fields
|
|
df.drop("Filename", axis=1, inplace=True)
|
|
|
|
df["Contract Name"] = "Filename: " + filename
|
|
df["Parent Agreement Code"] = postprocessing_funcs.get_parent_agreement_code(
|
|
filename
|
|
)
|
|
df["Pages"] = pages
|
|
|
|
# Add Single Code, Multiple Rate
|
|
df = postprocessing_funcs.add_scmr(df)
|
|
|
|
# Filter Add Ons
|
|
df = postprocessing_funcs.filter_add_ons(df)
|
|
|
|
# Clean MSR
|
|
df = postprocessing_funcs.clean_msr_lesser(df)
|
|
|
|
# Clean Default
|
|
df = postprocessing_funcs.clean_default_term(df)
|
|
|
|
# Clean Prov 2
|
|
df = postprocessing_funcs.clean_prov_2(df)
|
|
|
|
# Clean Lesser Of Rate
|
|
df = postprocessing_funcs.clean_lesser_rate(df)
|
|
|
|
# Clean LOB
|
|
df = postprocessing_funcs.clean_lob(df, filename)
|
|
|
|
df = postprocessing_funcs.methodology_short_fix(df)
|
|
|
|
df = postprocessing_funcs.yn_fixes(df)
|
|
|
|
# Rename and reorder
|
|
df.rename(columns=valid.B_MAPPING, inplace=True)
|
|
|
|
column_order = [col for col in valid.B_MAPPING.values() if col in df.columns]
|
|
final_df = df[column_order]
|
|
|
|
return final_df
|
|
else:
|
|
return df
|
|
|
|
|
|
def ac_postprocess(df, text_dict, filename, pages):
|
|
|
|
if df.shape[0] > 0:
|
|
|
|
df["Contract Name"] = "Filename: " + filename
|
|
|
|
df["Pages"] = pages
|
|
|
|
df["Parent Agreement Code"] = postprocessing_funcs.get_parent_agreement_code(
|
|
filename
|
|
)
|
|
|
|
df = df.fillna("")
|
|
|
|
df = postprocessing_funcs.clean_term_clause(df)
|
|
|
|
df = postprocessing_funcs.clean_auto_renewal_ind(df)
|
|
|
|
df = postprocessing_funcs.get_tin_from_filename(df)
|
|
|
|
df = postprocessing_funcs.clean_tin(df)
|
|
|
|
df = postprocessing_funcs.clean_npi(df)
|
|
|
|
df = postprocessing_funcs.clean_network_access_fees(df)
|
|
|
|
df = postprocessing_funcs.clean_health_plan_state(df)
|
|
|
|
df = postprocessing_funcs.clean_health_plan_state_from_hotfix(df,filename,text_dict)
|
|
|
|
df = postprocessing_funcs.clean_notice_provider_name_and_address(df)
|
|
|
|
df = postprocessing_funcs.clean_policies_and_procedures(df)
|
|
|
|
df = postprocessing_funcs.clean_tin_npi_other(df)
|
|
|
|
df = postprocessing_funcs.icm_number_fix(df)
|
|
|
|
df = postprocessing_funcs.yn_fixes(df)
|
|
|
|
df = df.apply(lambda x: x.map(postprocessing_funcs.replace_null_terms))
|
|
|
|
df = df.apply(lambda x: x.map(postprocessing_funcs.replace_quotes))
|
|
|
|
# Derive Indicators
|
|
df = df.apply(postprocessing_funcs.derive_indicators, axis=1)
|
|
|
|
# Rename and Reorder
|
|
df = df.rename(columns=valid.AC_MAPPING)
|
|
column_order = [col for col in valid.ABC_COLUMNS if col in df.columns] + [
|
|
col for col in df.columns if col not in valid.ABC_COLUMNS
|
|
]
|
|
|
|
final_df = df[column_order]
|
|
|
|
return final_df
|
|
else:
|
|
return df
|