LOB and Program cleaning

This commit is contained in:
Katon Minhas
2024-05-08 12:01:34 -07:00
committed by Michael McGuinness
parent 6571341012
commit 6709da216d
5 changed files with 127 additions and 506 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ AWS_SECRET_ACCESS_KEY="U3zdt9cAgCFVdy48uwktZSx2owC4QXo4/mtWCwdQ"
AWS_SESSION_TOKEN="IQoJb3JpZ2luX2VjEIv//////////wEaCXVzLWVhc3QtMiJHMEUCIQCxyHC2X3koEVwj1v5GQCySf/crrB3a1muqvXsMEUOvjwIgbX9sZ25cw8Hc0zklioXs/5rq9hfXna4AeAynR3O0+eUqjAMI5P//////////ARAAGgw2NjAxMzEwNjg3ODIiDDZ45+avGABDdEaUiirgAkJzeXOOSyKxFQv6Mq3sCSFlAGkjzUuMAziu1RZdWcF99u0rQthauWdxJ6rU4kwfd/M2LoWRQgu/8VxsktWxcivbleRrxwGAtcayMOBDWzeCdCDnvWZgKxZULiefEeJK3BDwUsWRN541FgZ/xqsAoASQlMO98rpNZ6W8xNq961xSpVUItMRPjOuHAot9YhPi1xLl+haeIdpsxGhx4ztQuJ+/ag5KAVrKpEiSsrQqf2L/q4FHB/3/YYzzAgXqP7Wy4qoPsWxfARvCw1FAoOqqPGjcmFwD3kov8q0FyYG4cc7/0UySSHxl7qUHFAr8vPuF7i+BdAFxeZEpAFd4s00gIm0V4ne8ta0wELiIfbkULdKZu7UezROqhm4+q9nQByrog4d1+YRE7B6x3zA9koFogcHQizZtZyoBDYK6Q3p+eab+SjIW6NndyYhCT1diebVLfnpth0MDMnIHibMHetm+XGwwiMnrsQY6pgGKQdkRrc2lhFuoRtw4uh4GTTz9PTQap3Ts2UNe7sT/49TpWxtqSB5WUyFGn2GAqnh1sOBZON3jo1e8qjibVxfACfv38PUBlktj6bVI0izhKfcEdoSyYWW1Cs5CTt1wlF3sOu5ztkTB+Gq8+H20gYAH+BgctDy43H6OwCGbBcveRxOEVH9jn+9GC6I99GNmjQ0w3Is9jT7zaJf52lE9nAA4n/p64Rro"
# File Paths
LOCAL_PATH = '../docs/test/' # Replace with local
LOCAL_PATH = 'docs/test/' # Replace with local
# S3 Settings
S3_CLIENT = boto3.client('s3',
+54
View File
@@ -1,4 +1,7 @@
import config
import difflib
import prompts
# Filter applied between primary and secondary
def primary_filter(answer_dict):
@@ -11,11 +14,57 @@ def primary_filter(answer_dict):
filtered_dicts.append(d)
return filtered_dicts
def get_closest_match(val, val_list, similarity_threshold=0.6):
matches = difflib.get_close_matches(val.upper(), val_list, n=1, cutoff=similarity_threshold)
if matches:
index = val_list.index(matches[0])
return val_list[index]
else:
return None
def get_mappings(original_vals, actual_vals, similarity_threshold):
field_mapping = {}
non_field_mapping = {}
for original_val in original_vals:
val = original_val.upper()
if ',' in val:
val_list = [v.strip() for v in val.split(',')]
else:
val_list = [val]
map_to = []
non_field = []
for sub_val in val_list:
if sub_val in actual_vals:
map_to.append(sub_val)
else:
closest_match = get_closest_match(sub_val, actual_vals, similarity_threshold)
if closest_match:
map_to.append(closest_match)
else:
non_field.append(sub_val)
field_mapping[original_val] = ', '.join(map_to)
if non_field:
non_field_mapping[original_val] = ', '.join(non_field)
return field_mapping, non_field_mapping
def lob_product_program_clean(df):
original_lobs = df['CONTRACT_LOB'].astype(str).unique()
original_programs = df['CONTRACT_PROGRAM'].astype(str).unique()
# Get Mappings
lob_mapping, non_lob_mapping = get_mappings(original_lobs, prompts.VALID_LOBS, 0.5)
program_mapping, non_program_mapping = get_mappings(original_programs, prompts.VALID_PROGRAMS, 0.6)
# INCOMPLETE
return df
def bottom_up_postprocess(df):
# Remove Unnamed columns
df = df[[col for col in df.columns if 'UNNAMED' not in col.upper()]]
df = lob_product_program_clean(df)
# Reimbursement Flat Fee
df.loc[:, 'REIMBURSEMENT_FLAT_FEE'] = df['REIMBURSEMENT_FLAT_FEE'].astype(str).str.replace(r'[^\d.]', '', regex=True)
@@ -24,3 +73,8 @@ def bottom_up_postprocess(df):
return df
+5 -8
View File
@@ -32,12 +32,13 @@ Your job is to identify what LOBs, Products, Plans, and Provider Types the reimb
Return a dictionary object with the following attributes:
'CONTRACT_LOB' : What Line of Business is the reimbursement schedule for? It will be Medicaid, Medicare, Marketplace, or similar. It will likely only be listed once per page, if at all.
'CONTRACT_PROGRAM' : What Program is the reimbursement schedule for? This may be something like CHIP, CHIP PERINATE, STAR, STAR PLUS, or similar. This will likely only be listed once per page, if at all.
'CONTRACT_PROGRAM' : What Program is the reimbursement schedule for? This may be something like CHIP, CHIP PERINATE, STAR, STAR PLUS, DSNP, Dual, or similar. This will likely only be listed once per page, if at all.
'PRODUCT' : What Product is the reimbursement schedule for? This the brand name of the health plan. It is NOT the same as LOB. It is NOT the name of a hospital. This will likely only be listed once per page, if at all.
'PROV_TYPE' : For what provider type or place of service is this fee schedule for? It could be Hospital, Professional, Ancillary, or similar. This will likely only be listed once per page, if at all.
If there are multiple correct answers for any of the above attributes, return only the answer corresponding to the SECOND of the two pages.
If there are multiple correct answers for the second page, return them both in a comma-separated list. However, in most instances there will be only one.
Sometimes the information is presented as 'SELECTED' OR 'NOT_SELECTED' - when this is the case, 'SELECTED' indicates the correct value(s).
Return N/A for any answers not found.
@@ -138,13 +139,9 @@ Only return the dictionary, with no other commentary or explanation. Ensure you
"""
VALID_LOBS = ['MEDICARE', 'MEDICARE ADVANTAGE', 'MEDICAID', 'MARKETPLACE', 'COMMERCIAL', 'GROUP', 'MEDICARE-MEDICAID']
VALID_PROGRAMS = ['CHIP', 'CHIP-P', 'CHIP-PERINATE', 'STAR', 'STAR+PLUS', 'MA', 'DUAL SPECIAL NEEDS PLAN', 'DSNP', 'DUAL']
VALID_PROV_TYPES = ['INPATIENT', 'OUTPATIENT', 'SKILLED NURSING FACILITY', 'AMBULATORY SURGERY CENTER', 'HOME HEALTH', 'RURAL HEALTH CLINIC']
-497
View File
@@ -1,497 +0,0 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import utils\n",
"import preprocess\n",
"import re\n",
"import pandas as pd\n",
"import bottom_up_funcs\n",
"import dict_operations\n",
"import postprocess\n",
"import prompts\n",
"import claude_funcs\n",
"\n",
"pd.set_option('display.max_rows', None)\n",
"pd.set_option('display.max_columns', None)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"input_dict = utils.read_input()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dict_keys(['133923495 CAIPA 2015 PHSP.txt'])"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"input_dict.keys()"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [],
"source": [
"def format_table(table):\n",
" table = table.replace('>>>', '').replace('<<<', '')\n",
" table_dict = eval(table)\n",
" \n",
" keys = list(table_dict.keys())\n",
" # If values are lists\n",
" if isinstance(table_dict[keys[0]], list):\n",
" final_string = \"\"\n",
" for i in range(len(table_dict[keys[0]])):\n",
" for k in keys:\n",
" key_string = k + ': ' + table_dict[k][i] + ', '\n",
" final_string += key_string\n",
" final_string += '|\\n'\n",
" else:\n",
" # If values are not lists\n",
" final_string = \"\"\n",
" for k in keys:\n",
" key_string = k + ': ' + table_dict[k] + ', '\n",
" final_string += key_string\n",
" final_string += '|\\n'\n",
" return final_string\n",
"\n",
"def align_and_format_tables(text_dict):\n",
" pattern = re.compile(r'-------Table Start--------(.*?)-------Table End--------', re.DOTALL)\n",
" for page, text in text_dict.items():\n",
" tables = pattern.findall(text)\n",
" for table in tables:\n",
" pre_table = table.split('{')[0].strip() # Get the pretable text for alignment\n",
" text = text.replace(table, '') # Remove full table\n",
" table_only = table.replace(pre_table, '')\n",
" try:\n",
" formatted_table = format_table(table_only)\n",
" except:\n",
" formatted_table = table\n",
" text = text.replace(pre_table, pre_table + formatted_table) # replace remaining pretable text with full table\n",
" text = text.replace('-------Table Start--------', '')\n",
" text = text.replace('-------Table End--------', '') \n",
" text_dict[page] = text\n",
" return text_dict"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Managed Health, Inc.: By:, Provider: Chinese American Independent Practice Association, Inc.: By:, |\n",
"Managed Health, Inc.: Name: Print Name, Provider: Chinese American Independent Practice Association, Inc.: Name: Print Name, |\n",
"Managed Health, Inc.: Title:, Provider: Chinese American Independent Practice Association, Inc.: Title:, |\n",
"Managed Health, Inc.: Date:, Provider: Chinese American Independent Practice Association, Inc.: Date:, |\n",
"\n",
"Code Range: 97001-97006, Code Range Description: Physical Medicine Assessments, |\n",
"Code Range: 97010-97028, Code Range Description: Physical Therapy Treatment Modalities: Supervised, |\n",
"Code Range: 97032-97039, Code Range Description: Physical Therapy Treatment Modalities: Constant Attendance, |\n",
"Code Range: 97110-97546, Code Range Description: Other Therapeutic Techniques With Direct Patient Contact, |\n",
"Code Range: 97750-97755, Code Range Description: Physical performance test & Assistive technology assessment, |\n",
"\n",
"CPT Code: 43235, CPT Description: Upper gastrointestinal endoscopy, |\n",
"CPT Code: 43239, CPT Description: Upper gastrointestinal endoscopy, with biopsy, |\n",
"CPT Code: 45378, CPT Description: Colonoscopy, diagnostic, |\n",
"CPT Code: 45380, CPT Description: Colonoscopy, with biopsies, |\n",
"CPT Code: 45385, CPT Description: Colonoscopy, removal of tumor, |\n",
"\n",
"CPT Code: 99381, CPT Description: Initial visit, new patient, infant (under 1 year), Amount: $65.00, |\n",
"CPT Code: 99382, CPT Description: Initial visit, new patient, early childhood (age 1-4), Amount: $61.00, |\n",
"CPT Code: 99383, CPT Description: Initial visit, new patient, late childhood (age 5-11), Amount: $60.00, |\n",
"CPT Code: 99384, CPT Description: Initial visit, new patient, adolescent (age 12-17), Amount: $65.00, |\n",
"CPT Code: 99385, CPT Description: Initial visit, new patient, age 18-39, Amount: $74.00, |\n",
"CPT Code: 99386, CPT Description: Initial visit, new patient, age 40-64, Amount: $80.00, |\n",
"CPT Code: 99387, CPT Description: Initial visit, new patient, age 65 and older, Amount: $118.00, |\n",
"CPT Code: 99391, CPT Description: Periodic visit, established patient, infant (under 1 year), Amount: $61.00, |\n",
"CPT Code: 99392, CPT Description: Periodic visit, established patient, early childhood (age 1-4), Amount: $61.00, |\n",
"CPT Code: 99393, CPT Description: Periodic visit, established patient, late childhood (age 5-11), Amount: $60.00, |\n",
"CPT Code: 99394, CPT Description: Periodic visit, established patient, adolescent (age 12-17), Amount: $60.00, |\n",
"CPT Code: 99395, CPT Description: Periodic visit, established patient, age 18-39, Amount: $75.00, |\n",
"CPT Code: 99396, CPT Description: Periodic visit, established patient, age 40-64, Amount: $90.00, |\n",
"CPT Code: 99397, CPT Description: Periodic visit, established patient, age 65 and older, Amount: $99.00, |\n",
"CPT Code: 99401, CPT Description: Preventive medicine counseling, Individual, approx 15 minutes, Amount: $31.00, |\n",
"CPT Code: 99402, CPT Description: Preventive medicine counseling, Individual, approx 30 minutes, Amount: $40.00, |\n",
"CPT Code: 99403, CPT Description: Preventive medicine counseling, Individual, approx 45 minutes, Amount: $60.00, |\n",
"CPT Code: 99404, CPT Description: Preventive medicine counseling, Individual, approx 60 minutes, Amount: $79.00, |\n",
"CPT Code: 99411, CPT Description: Preventive medicine counseling, Group, approx 30 minutes, Amount: $28.00, |\n",
"CPT Code: 99412, CPT Description: Preventive medicine counseling, Group, approx 60 minutes, Amount: $57.00, |\n",
"\n",
"Healthfirst PHSP, Inc.: By: Name: Print Name, Chinese American Independent Practice Association, Inc.: By: Name: Print Name, |\n",
"Healthfirst PHSP, Inc.: Title:, Chinese American Independent Practice Association, Inc.: Title:, |\n",
"Healthfirst PHSP, Inc.: Date: -, Chinese American Independent Practice Association, Inc.: Date:, |\n",
"\n",
"Code Range: 97001-97004, Code Range Description: Physical Medicine Assessments, |\n",
"Code Range: 97010-97028, Code Range Description: Physical Therapy Treatment Modalities: Supervised, |\n",
"Code Range: 97032-97039, Code Range Description: Physical Therapy Treatment Modalities: Constant Attendance, |\n",
"Code Range: 97110-97546, Code Range Description: Other Therapeutic Techniques With Direct Patient Contact, |\n",
"Code Range: 97750-97755, Code Range Description: Physical performance test & Assistive technology assessment, |\n",
"\n",
"CPT Code: 43235, CPT Description: Upper gastrointestinal endoscopy, |\n",
"CPT Code: 43239, CPT Description: Upper gastrointestinal endoscopy, with biopsy, |\n",
"CPT Code: 45378, CPT Description: Colonoscopy, diagnostic, |\n",
"CPT Code: 45380, CPT Description: Colonoscopy, with biopsy, |\n",
"CPT Code: 45385, CPT Description: Colonoscopy, removal of tumor, |\n",
"\n",
"CPT Code/Modifier: 99205-P1, CPT Description: PCAP Initial Visit, Amount: $196.07, |\n",
"CPT Code/Modifier: 99212-P2, CPT Description: PCAP Prenatal Visit, Amount: $130.00, |\n",
"CPT Code/Modifier: 99215-P3, CPT Description: PCAP Post partum Visit, Amount: $163.00, |\n",
"CPT Code/Modifier: 59409, CPT Description: Vaginal Delivery, Amount: $1500.00, |\n",
"CPT Code/Modifier: 59514, CPT Description: Cesarean Delivery, Amount: $1500.00, |\n",
"CPT Code/Modifier: 99381, CPT Description: Initial visit, new patient, infant (under 1 year), Amount: $65.00, |\n",
"CPT Code/Modifier: 99382, CPT Description: Initial visit, new patient, early childhood (age 1-4), Amount: $61.00, |\n",
"CPT Code/Modifier: 99383, CPT Description: Initial visit, new patient, late childhood (age 5-11), Amount: $60.00, |\n",
"CPT Code/Modifier: 99384, CPT Description: Initial visit, new patient, adolescent (age 12-17), Amount: $65.00, |\n",
"CPT Code/Modifier: 99385, CPT Description: Initial visit, new patient, age 18-39, Amount: $74.00, |\n",
"CPT Code/Modifier: 99386, CPT Description: Initial visit, new patient, age 40-64, Amount: $80.00, |\n",
"CPT Code/Modifier: 99387, CPT Description: Initial visit, new patient, age 65 and older, Amount: $118.00, |\n",
"CPT Code/Modifier: 99391, CPT Description: Periodic visit, established patient, infant (under 1 year), Amount: $61.00, |\n",
"CPT Code/Modifier: 99392, CPT Description: Periodic visit, established patient, early childhood (age 1-4), Amount: $61.00, |\n",
"CPT Code/Modifier: 99393, CPT Description: Periodic visit, established patient, late childhood (age 5-11), Amount: $60.00, |\n",
"CPT Code/Modifier: 99394, CPT Description: Periodic visit, established patient, adolescent (age 12-17), Amount: $60.00, |\n",
"CPT Code/Modifier: 99395, CPT Description: Periodic visit, established patient, age 18-39, Amount: $75.00, |\n",
"CPT Code/Modifier: 99396, CPT Description: Periodic visit, established patient, age 40-64, Amount: $90.00, |\n",
"CPT Code/Modifier: 99397, CPT Description: Periodic visit, established patient, age 65 and older, Amount: $99.00, |\n",
"CPT Code/Modifier: 99401, CPT Description: Preventive medicine counseling, Individual, approx 15 minutes, Amount: $31.00, |\n",
"CPT Code/Modifier: 99402, CPT Description: Preventive medicine counseling, Individual, approx 30 minutes, Amount: $40.00, |\n",
"CPT Code/Modifier: 99403, CPT Description: Preventive medicine counseling, Individual, approx 45 minutes, Amount: $60.00, |\n",
"CPT Code/Modifier: 99404, CPT Description: Preventive medicine counseling, Individual, approx 60 minutes, Amount: $79.00, |\n",
"CPT Code/Modifier: 99411, CPT Description: Preventive medicine counseling, Group, approx 30 minutes, Amount: $28.00, |\n",
"CPT Code/Modifier: 99412, CPT Description: Preventive medicine counseling, Group, approx 60 minutes, Amount: $57.00, |\n",
"\n",
"Managed Health, Inc.: DocuSigned by: By: Paul E. Portsmore, Provider: Chinese American Independent Practice Association, Inc.: By: family, |\n",
"Managed Health, Inc.: 441CEAD8E502476 Name: Paul E. Portsmore Print Name, Provider: Chinese American Independent Practice Association, Inc.: Name: PEGGY SHENG Print Name, |\n",
"Managed Health, Inc.: Title: SVP, Provider: Chinese American Independent Practice Association, Inc.: Chief Operating Officer Title:, |\n",
"Managed Health, Inc.: Date: 12/31/2014 18:32:28 ET, Provider: Chinese American Independent Practice Association, Inc.: Date: Dec. 26, 2015, |\n",
"\n",
"Code Range: 97001-97006, Code Range Description: Physical Medicine Assessments, |\n",
"Code Range: 97010-97028, Code Range Description: Physical Therapy Treatment Modalities: Supervised, |\n",
"Code Range: 97032-97039, Code Range Description: Physical Therapy Treatment Modalities: Constant Attendance, |\n",
"Code Range: 97110-97546, Code Range Description: Other Therapeutic Techniques With Direct Patient Contact, |\n",
"Code Range: 97750-97755, Code Range Description: Physical performance test & Assistive technology assessment, |\n",
"\n",
"CPT Code: 43235, CPT Description: Upper gastrointestinal endoscopy, |\n",
"CPT Code: 43239, CPT Description: Upper gastrointestinal endoscopy, with biopsy, |\n",
"CPT Code: 45378, CPT Description: Colonoscopy, diagnostic, |\n",
"CPT Code: 45380, CPT Description: Colonoscopy, with biopsies, |\n",
"CPT Code: 45385, CPT Description: Colonoscopy, removal of tumor, |\n",
"\n",
"CPT Code: 99381, CPT Description: Initial visit, new patient, infant (under 1 year), Amount: $65.00, |\n",
"CPT Code: 99382, CPT Description: Initial visit, new patient, early childhood (age 1-4), Amount: $61.00, |\n",
"CPT Code: 99383, CPT Description: Initial visit, new patient, late childhood (age 5-11), Amount: $60.00, |\n",
"CPT Code: 99384, CPT Description: Initial visit, new patient, adolescent (age 12-17), Amount: $65.00, |\n",
"CPT Code: 99385, CPT Description: Initial visit, new patient, age 18-39, Amount: $74.00, |\n",
"CPT Code: 99386, CPT Description: Initial visit, new patient, age 40-64, Amount: $80.00, |\n",
"CPT Code: 99387, CPT Description: Initial visit, new patient, age 65 and older, Amount: $118.00, |\n",
"CPT Code: 99391, CPT Description: Periodic visit, established patient, infant (under 1 year), Amount: $61.00, |\n",
"CPT Code: 99392, CPT Description: Periodic visit, established patient, early childhood (age 1-4), Amount: $61.00, |\n",
"CPT Code: 99393, CPT Description: Periodic visit, established patient, late childhood (age 5-11), Amount: $60.00, |\n",
"CPT Code: 99394, CPT Description: Periodic visit, established patient, adolescent (age 12-17), Amount: $60.00, |\n",
"CPT Code: 99395, CPT Description: Periodic visit, established patient, age 18-39, Amount: $75.00, |\n",
"CPT Code: 99396, CPT Description: Periodic visit, established patient, age 40-64, Amount: $90.00, |\n",
"CPT Code: 99397, CPT Description: Periodic visit, established patient, age 65 and older, Amount: $99.00, |\n",
"CPT Code: 99401, CPT Description: Preventive medicine counseling, Individual, approx 15 minutes, Amount: $31.00, |\n",
"CPT Code: 99402, CPT Description: Preventive medicine counseling, Individual, approx 30 minutes, Amount: $40.00, |\n",
"CPT Code: 99403, CPT Description: Preventive medicine counseling, Individual, approx 45 minutes, Amount: $60.00, |\n",
"CPT Code: 99404, CPT Description: Preventive medicine counseling, Individual, approx 60 minutes, Amount: $79.00, |\n",
"CPT Code: 99411, CPT Description: Preventive medicine counseling, Group, approx 30 minutes, Amount: $28.00, |\n",
"CPT Code: 99412, CPT Description: Preventive medicine counseling, Group, approx 60 minutes, Amount: $57.00, |\n",
"\n",
"Healthfirst PHSP, Inc.: DocuSigned by: By: Paul E. Portsmore, Chinese American Independent Practice Association, Inc.: By: f Sear, |\n",
"Healthfirst PHSP, Inc.: 441CEAD8E502476. Name: Paul E. Portsmore Print Name, Chinese American Independent Practice Association, Inc.: Name: PEGGY SHENG Print Name, |\n",
"Healthfirst PHSP, Inc.: Title: SVP -, Chinese American Independent Practice Association, Inc.: Title: Chief Operating Officer, |\n",
"Healthfirst PHSP, Inc.: Date: 12/31/2014 I 18:32:28 ET -, Chinese American Independent Practice Association, Inc.: Date: December 26, 2014, |\n",
"\n",
"Code Range: 97001-97004, Code Range Description: Physical Medicine Assessments, |\n",
"Code Range: 97010-97028, Code Range Description: Physical Therapy Treatment Modalities: Supervised, |\n",
"Code Range: 97032-97039, Code Range Description: Physical Therapy Treatment Modalities: Constant Attendance, |\n",
"Code Range: 97110-97546, Code Range Description: Other Therapeutic Techniques With Direct Patient Contact, |\n",
"Code Range: 97750-97755, Code Range Description: Physical performance test & Assistive technology assessment, |\n",
"\n",
"CPT Code: 43235, CPT Description: Upper gastrointestinal endoscopy, |\n",
"CPT Code: 43239, CPT Description: Upper gastrointestinal endoscopy, with biopsy, |\n",
"CPT Code: 45378, CPT Description: Colonoscopy, diagnostic, |\n",
"CPT Code: 45380, CPT Description: Colonoscopy, with biopsy, |\n",
"CPT Code: 45385, CPT Description: Colonoscopy, removal of tumor, |\n",
"\n",
"CPT Code/Modifier: 99205-P1, CPT Description: PCAP Initial Visit, Amount: $196.07, |\n",
"CPT Code/Modifier: 99212-P2, CPT Description: PCAP Prenatal Visit, Amount: $130.00, |\n",
"CPT Code/Modifier: 99215-P3, CPT Description: PCAP Post partum Visit, Amount: $163.00, |\n",
"CPT Code/Modifier: 59409, CPT Description: Vaginal Delivery, Amount: $1500.00, |\n",
"CPT Code/Modifier: 59514, CPT Description: Cesarean Delivery, Amount: $1500.00, |\n",
"CPT Code/Modifier: 99381, CPT Description: Initial visit, new patient, infant (under 1 year), Amount: $65.00, |\n",
"CPT Code/Modifier: 99382, CPT Description: Initial visit, new patient, early childhood (age 1-4), Amount: $61.00, |\n",
"CPT Code/Modifier: 99383, CPT Description: Initial visit, new patient, late childhood (age 5-11), Amount: $60.00, |\n",
"CPT Code/Modifier: 99384, CPT Description: Initial visit, new patient, adolescent (age 12-17), Amount: $65.00, |\n",
"CPT Code/Modifier: 99385, CPT Description: Initial visit, new patient, age 18-39, Amount: $74.00, |\n",
"CPT Code/Modifier: 99386, CPT Description: Initial visit, new patient, age 40-64, Amount: $80.00, |\n",
"CPT Code/Modifier: 99387, CPT Description: Initial visit, new patient, age 65 and older, Amount: $118.00, |\n",
"CPT Code/Modifier: 99391, CPT Description: Periodic visit, established patient, infant (under 1 year), Amount: $61.00, |\n",
"CPT Code/Modifier: 99392, CPT Description: Periodic visit, established patient, early childhood (age 1-4), Amount: $61.00, |\n",
"CPT Code/Modifier: 99393, CPT Description: Periodic visit, established patient, late childhood (age 5-11), Amount: $60.00, |\n",
"CPT Code/Modifier: 99394, CPT Description: Periodic visit, established patient, adolescent (age 12-17), Amount: $60.00, |\n",
"CPT Code/Modifier: 99395, CPT Description: Periodic visit, established patient, age 18-39, Amount: $75.00, |\n",
"CPT Code/Modifier: 99396, CPT Description: Periodic visit, established patient, age 40-64, Amount: $90.00, |\n",
"CPT Code/Modifier: 99397, CPT Description: Periodic visit, established patient, age 65 and older, Amount: $99.00, |\n",
"CPT Code/Modifier: 99401, CPT Description: Preventive medicine counseling, Individual, approx 15 minutes, Amount: $31.00, |\n",
"CPT Code/Modifier: 99402, CPT Description: Preventive medicine counseling, Individual, approx 30 minutes, Amount: $40.00, |\n",
"CPT Code/Modifier: 99403, CPT Description: Preventive medicine counseling, Individual, approx 45 minutes, Amount: $60.00, |\n",
"CPT Code/Modifier: 99404, CPT Description: Preventive medicine counseling, Individual, approx 60 minutes, Amount: $79.00, |\n",
"CPT Code/Modifier: 99411, CPT Description: Preventive medicine counseling, Group, approx 30 minutes, Amount: $28.00, |\n",
"CPT Code/Modifier: 99412, CPT Description: Preventive medicine counseling, Group, approx 60 minutes, Amount: $57.00, |\n",
"\n"
]
}
],
"source": [
"contract_text = preprocess.clean_newlines(input_dict['133923495 CAIPA 2015 PHSP.txt'])\n",
"text_dict = preprocess.split_text(contract_text)\n",
"text_dict = align_and_format_tables(text_dict)\n",
"text_dict = preprocess.highlight_rates(text_dict)"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
"answer_strings = bottom_up_funcs.run_bottom_up_primary({'5' : text_dict['5']}, 4000)\n",
"answer_dicts = dict_operations.primary_string_to_dict(answer_strings)\n",
"answer_dicts = postprocess.primary_filter(answer_dicts)"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'SERVICE': 'Initial visit, new patient, infant (under 1 year)',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$65.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Initial visit, new patient, early childhood (age 1-4)',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$61.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Initial visit, new patient, late childhood (age 5-11)',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$60.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Initial visit, new patient, adolescent (age 12-17)',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$65.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Initial visit, new patient, age 18-39',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$74.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Initial visit, new patient, age 40-64',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$80.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Initial visit, new patient, age 65 and older',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$118.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Periodic visit, established patient, infant (under 1 year)',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$61.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Periodic visit, established patient, early childhood (age 1-4)',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$61.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Periodic visit, established patient, late childhood (age 5-11)',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$60.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Periodic visit, established patient, adolescent (age 12-17)',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$60.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Periodic visit, established patient, age 18-39',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$75.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Periodic visit, established patient, age 40-64',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$90.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Periodic visit, established patient, age 65 and older',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$99.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Preventive medicine counseling, Individual, approx 15 minutes',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$31.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Preventive medicine counseling, Individual, approx 30 minutes',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$40.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Preventive medicine counseling, Individual, approx 45 minutes',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$60.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Preventive medicine counseling, Individual, approx 60 minutes',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$79.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Preventive medicine counseling, Group, approx 30 minutes',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$28.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Preventive medicine counseling, Group, approx 60 minutes',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$57.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': 'N/A',\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Hearing Aids',\n",
" 'REIMBURSEMENT_FLAT_FEE': 'N/A',\n",
" 'REIMBURSEMENT_RATE': '80%',\n",
" 'FULL_METHODOLOGY': \"IPA Providers shall be reimbursed for the cost of hearing aids at eighty percent (80%) of the manufacturer's suggested retail price.\",\n",
" 'page_num': '5'},\n",
" {'SERVICE': 'Network Access and Administrative Fees for Medicare Advantage members',\n",
" 'REIMBURSEMENT_FLAT_FEE': '$5.00',\n",
" 'REIMBURSEMENT_RATE': 'N/A',\n",
" 'FULL_METHODOLOGY': \"Healthfirst shall compensate IPA $5.00 per Member per month for the following administrative services,: Access to IPA's network of Participating IPA Providers Credentialing of Participating IPA Providers Reporting on Health Care Services provided to Enrollees as reasonably requested by Healthfirst Administrative services relating to quality improvement and Enrollee satisfaction Education of Participating IPA Providers regarding Healthfirst's policies and procedures and quality improvement programs.\",\n",
" 'page_num': '5'}]"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"answer_dicts"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [],
"source": [
"def BOTTOM_UP_CODES(d, page):\n",
" return f\"\"\"### PAGE START ### {page} ### PAGE END\n",
"\n",
"The above text contains a number of reimbursement terms. For the rest of this request, focus only on the specific term listed below:\n",
"Service: {d['SERVICE']}\n",
"Methodology: {d['FULL_METHODOLOGY']}\n",
"\n",
"Your job is to identify codes associated with this specific term.\n",
"\n",
"Read and analyze the page, then populate a JSON dictionary with the following code types if they are associated with the given Service and Methodology (descriptions provided):\n",
"'REIMBURSEMENT_ADMITTYPE_CODES' : Single-digit codes that indicate the type of admission to a facility.\n",
"'REIMBURSEMENT_DIAG_CODES' : Multi-digit alphanumeric codes related to diagnosis. They may contain a '.' after the first 3 characters. These may be labelled as ICD-10 or ICD-10-CM codes.\n",
"'REIMBURSEMENT_GROUPER_CODES' : 3- or 4-digit codes that may be labelled DRG or or similar.\n",
"'REIMBURSEMENT_GROUPER' : If there are grouper codes, what type are they? They could be MSDRG, APDRG, APRDRG, APC, APG, or EAPG. Choose only from these options.\n",
"'REIMBURSEMENT_PLACEOFSERVICE_CODES' : 2-digit codes related to the place of service.\n",
"'REIMBURSEMENT_PROC_CODES' : 5-digit numeric or alphanumeric codes. They may be labelled as CPT or HCPCS codes. These are related to specific procedures.\n",
"'REIMBURSEMENT_REVENUE_CODES' : 3- or 4-digit numeric or alphanumeric codes related to revenue. They may be labelled as 'Rev' codes.\n",
"'REIMBURSEMENT_STATUS_INDICATOR_CODES' : 1- or 2-digit alphanumeric codes indicating the payment status.\n",
"\n",
"Return a value for each type of code - return N/A for any values not found. Multiple codes for each type may be found. In this case, return them all. They may also present as a range. If so, return the range.\n",
"\n",
"Only return the dictionary, with no other commentary or explanation. Ensure you abide by proper JSON formatting.\n",
"\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [],
"source": [
"prompt = BOTTOM_UP_CODES(answer_dicts[0], text_dict['5'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"code_answer = claude_funcs.invoke_claude_3(prompt, max_tokens=4000)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
+67
View File
@@ -0,0 +1,67 @@
import pandas as pd
import numpy as np
import difflib
import prompts
df = pd.read_csv('output/consolidated_results_20240503_v1.csv')
def get_closest_match(val, val_list, similarity_threshold=0.6):
matches = difflib.get_close_matches(val.upper(), val_list, n=1, cutoff=similarity_threshold)
if matches:
index = val_list.index(matches[0])
return val_list[index]
else:
return None
def get_mappings(original_vals, actual_vals, similarity_threshold):
field_mapping = {}
non_field_mapping = {}
for original_val in original_vals:
val = original_val.upper()
if ',' in val:
val_list = [v.strip() for v in val.split(',')]
else:
val_list = [val]
map_to = []
non_field = []
for sub_val in val_list:
if sub_val in actual_vals:
map_to.append(sub_val)
else:
closest_match = get_closest_match(sub_val, actual_vals, similarity_threshold)
if closest_match:
map_to.append(closest_match)
else:
non_field.append(sub_val)
field_mapping[original_val] = ', '.join(map_to)
if non_field:
non_field_mapping[original_val] = ', '.join(non_field)
return field_mapping, non_field_mapping
def lob_product_program_clean(df):
original_lobs = df['CONTRACT_LOB'].astype(str).unique()
original_programs = df['CONTRACT_PROGRAM'].astype(str).unique()
# Get Mappings
lob_mapping, non_lob_mapping = get_mappings(original_lobs, prompts.VALID_LOBS, 0.5)
program_mapping, non_program_mapping = get_mappings(original_programs, prompts.VALID_PROGRAMS, 0.6)
print(program_mapping)
print(non_program_mapping)
#print(program_mapping)
#print(get_closest_match('COMMERCIAL PRODUCTS', prompts.VALID_LOBS))
lob_product_program_clean(df)
#print(df['CONTRACT_LOB'].value_counts(dropna=False))
#print(df['CONTRACT_PROGRAM'].value_counts(dropna=False))