Modified output, modified LOB prompt
This commit is contained in:
committed by
Michael McGuinness
parent
08dc848952
commit
69e6ebe1d6
+5
-5
@@ -13,7 +13,7 @@ TODAY = datetime.now().strftime("%Y%m%d")
|
||||
# I/O Options
|
||||
WRITE_OUTPUT = True # True writes csvs, False prints result in console but no output written
|
||||
READ_MODE = '_LOCAL_' # OR '_S3_'
|
||||
OUTPUT_MODE = '_INDIVIDUAL_' # or'_CONSOLIDATED_'
|
||||
OUTPUT_MODE = '_INDIVIDUAL_' # or '_CONSOLIDATED_'
|
||||
|
||||
# Multithread Settings
|
||||
MAX_WORKERS = 20
|
||||
@@ -28,12 +28,12 @@ RUN_EXCEPTION = True
|
||||
RUN_CODES = True
|
||||
|
||||
# AWS Keys
|
||||
AWS_ACCESS_KEY_ID="ASIAZTMXAXNXC5Y4PKXJ"
|
||||
AWS_SECRET_ACCESS_KEY="f/mOlRpK7+iSlm1P5ZK1LOdS2UjnsbAQ2ysL7Mms"
|
||||
AWS_SESSION_TOKEN="IQoJb3JpZ2luX2VjEM3//////////wEaCXVzLWVhc3QtMiJGMEQCIGqPr40CU3Fz4nvSQJ1jaPgkOGIWWyDXBVLUU+VmsfIjAiAgluQOwSGIYph5hLcKVVsiFQ7OpLOs3lLsumxzeyw6nyqDAwhGEAAaDDY2MDEzMTA2ODc4MiIM5odYPf2eQP8/f9NBKuAC7eMH0qjb6ASoeBhtKNFzMWXpR5snAahfBheyiUo1my8q8VFbZem8m0n5c0vWnKsPhm9+K+qpVqM6ohhjVMIXCta/ZlGNizatHJt7gMpDOGQNyBI4rpXF9/urQMgN8PkjMG2hkD+XefkPYGmvgz9ZVKFs/oAnP/buG21Ju54F/D0qqnxhR/90pVM6Z48sgzkQThHHjB7wNgfy1hIA7CL9yeM0k+sdzlYvriDogDi3lcP3UkXMUJhQl5xQb7t8iLR70L/0H74ynfldpbaBfktWPred4ehoRMv2Zd/Jh6JNBIAeDQyfIKQTYn2FF/RuPBmqa+iLS9lJh/SnhwXNuMYc9JOERwMHaijgqQjenISnysSEr10u1Y+XiUI7waXRO6e8CBS/LygUKZZf8+cSeXIE3VN2XrMW72Ix5sg16QHAMvR3oUDJdYdf8jnWET995kocK6UctJdVKEna/FUnIdNgwzDirrKyBjqnAZjoQpVVuEh8p9tuGrjdWsjzLsXRkNRyqm/6xxIGtqITzvAv+TKQLSgJun/rRTOncaMLDwt0PAKL1Y8cVnOcuSIfVFUtpeZ+p27MgByL/fBQGd0yfZGHy15ZMPw51viYhjQo3MeA4y0YLRW+12v2ilrMxGHYlwTUT19Zj+qQNobTrlcJWQ7737lXmVL2WOZzmtduH7wf/fyAn2ZhZT/lcnSSQsef9ORk"
|
||||
AWS_ACCESS_KEY_ID="ASIAZTMXAXNXDI7HGA7Q"
|
||||
AWS_SECRET_ACCESS_KEY="mXAJEp6Ar35G+VEwUfKq/3cu+1Hn721R+pNs+Fxh"
|
||||
AWS_SESSION_TOKEN="IQoJb3JpZ2luX2VjEOj//////////wEaCXVzLWVhc3QtMiJHMEUCIQDlpQWz84O6hWg0qtTjfoNx1nIt3Ip82gSG/jdYh05Z/AIgK3N9ViVt3ez4iwTbo7hwOgtnTbeK6Jn5fpCRfcHDv2QqgwMIYhAAGgw2NjAxMzEwNjg3ODIiDC3AfcU4Q5o7CB6tkCrgAjwqqjf8jXvnSMmnxvYmhqy4IwD/N4hyCIwYSHC1iGMOp9QsFyBVKixjAEl6m9dzt24XomQCY/GSoVNchUbqewuFIy5im3nyKlF/tGYj/xi261JTIr0szXk5UDw5twCXHSSdem1PII+C3EmsGl6fLjRFbPNlXi6vY3Z/X6nnhix/J6ZJQzPg5Plj6jGY9uBrtE/CF5DYtfGRPvFT13ZiI+UYJ/97viOM5JOWcT1nHoVY8DCLWicRCZO4aXbrOUs8QtRNns7oJye1sL1mU+0ocgkrXCYOnX54McYj4dViAHy3UUYo9w9u6a2LeW2MfQjvKam0W+q2iHuLs1ydn8ip7WjDzmBzLTAKZPWnPTjKZXlCGUsPXTj7U1rF0wNgBmIpOgMO7d49TsbSL0MWifCXuOF4sgu5ICKt5bcd7N0rvGgQR3I/kAY7abH60EAl37tbhP79tLmPt//hlR4xJ2lKuD0wrrq4sgY6pgEsIEApALn8eIykqKZPFf5jz1QWbhuScAy3Yjh+OjOvk29eUERS3xvIeOgYUF40qlkPboFkCRY3NNgvHLkbfg9I9m929zKk6Tugb6S30Aiqy9prxpPNvIA9/X877EzIb0xoIbxJHb8ucvW1xBkUNEwwZGlA6xbzKXqTHau7/j6odzLd/CPno+IQ9lCBSilCbg/1W1NAiDZC4IwJjpV8rHONSaXVdA44"
|
||||
|
||||
# File Paths
|
||||
LOCAL_PATH = 'docs/test/' # Replace with local
|
||||
LOCAL_PATH = 'docs/priority_health/' # Replace with local
|
||||
|
||||
# S3 Settings
|
||||
S3_CLIENT = boto3.client('s3',
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ def main():
|
||||
|
||||
# Write Output
|
||||
if config.WRITE_OUTPUT and config.OUTPUT_MODE == '_CONSOLIDATED_':
|
||||
consolidated_df = utils.consolidate_individual(folder='temp') # Consolidate temp results to one file, then write output
|
||||
consolidated_df = utils.consolidate_individual(input_folder='temp') # Consolidate temp results to one file, then write output
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ Return at least one json object for each combination of attributes seen. It is p
|
||||
|
||||
Here are the attributes to be included in each dictionary, and instructions on how to correctly answer:
|
||||
'SERVICE' : What is the Service that is being reimbursed? Use your best judgement and knowledge of the healthcare industry to answer. Do not leave this field N/A.
|
||||
'REIMBURSEMENT_FLAT_FEE' : If the listed reimbursement is direct dollar value, return only that dollar value. There can only be one answer for each object. If more than one rate is found, create additional objects for them.
|
||||
'REIMBURSEMENT_FLAT_FEE' : If the listed reimbursement is dollar value, return only that dollar value. There can only be one answer for each object. If more than one rate is found, create additional objects for them.
|
||||
'REIMBURSEMENT_RATE' : If the listed reimbursement is a percent of something, return only that percent. There can only be one answer for each object. If more than one rate is found, create additional objects for them. Do NOT include multiple percentages in this value.
|
||||
'FULL_METHODOLOGY' : If the listed reimbursement is a percent of something, what is it the percent of? If the listed reimbursement is a direct dollar value, how is that dollar value paid (per diem, per unit, etc)? Write the full sentence in text describing the payment methology.
|
||||
|
||||
@@ -130,7 +130,7 @@ Here are the attributes to be included in each dictionary, and instructions on h
|
||||
'CONTRACT_NETWORK' : List any Networks mentioned on the page. Networks are types of managed care organizations involved in the delivery of healthcare services. Some examples of Networks are: HMO, PPO, EMO, POS, FFS
|
||||
'PRODUCT' : List any Products listed on the page. These are typically the brand name of a health plan. You may also use this field as a catch-all for entities that you are unsure of.
|
||||
|
||||
If any of the attributes are not found, return N/A. If there are multiple answers for a given attribute, return them in a comma-separated list.
|
||||
If any of the attributes are not found, return N/A. If there are multiple answers for a given attribute, return a separate dictionary for them such that each of the four attributes is associated with the other attributes in the dictionary.
|
||||
|
||||
For all attributes, only write what is written on the page. Do not make up new phrases or words.
|
||||
|
||||
|
||||
+11
-235
@@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -19,250 +19,26 @@
|
||||
"import claude_funcs\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Upload \n",
|
||||
"input_dict = utils.read_input()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"filename = 'Baz Allergy Asthma & Sinus_MU.txt'\n",
|
||||
"contract_text = input_dict['Baz Allergy Asthma & Sinus_MU.txt']\n",
|
||||
"\n",
|
||||
"contract_text = preprocess.clean_newlines(contract_text)\n",
|
||||
"text_dict = preprocess.split_text(contract_text)\n",
|
||||
"text_dict = table_funcs.align_and_format_tables(text_dict)\n",
|
||||
"text_dict = preprocess.highlight_rates(text_dict)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[{\"CONTRACT_LOB\": \"Commercial, Medicare Advantage, Medicaid\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"Fee-For-Service, Direct Network\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"Fee-For-Service Direct Network\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[\n",
|
||||
" {\n",
|
||||
" \"CONTRACT_LOB\": \"N/A\",\n",
|
||||
" \"CONTRACT_PROGRAM\": \"N/A\",\n",
|
||||
" \"CONTRACT_NETWORK\": \"FFS\",\n",
|
||||
" \"PRODUCT\": \"Health Net\"\n",
|
||||
" }\n",
|
||||
"]\n",
|
||||
"[{\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"Medicare Advantage\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"FFS\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[\n",
|
||||
" {\n",
|
||||
" \"CONTRACT_LOB\": \"Commercial\",\n",
|
||||
" \"CONTRACT_PROGRAM\": \"N/A\",\n",
|
||||
" \"CONTRACT_NETWORK\": \"HMO\",\n",
|
||||
" \"PRODUCT\": \"Health Net\"\n",
|
||||
" }\n",
|
||||
"]\n",
|
||||
"[{\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"FFS\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"Fee-For-Service Direct Network\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"Fee-For-Service Direct Network\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"FFS\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"FFS\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"Fee-For-Service Direct Network\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"Fee-For-Service Direct Network\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"N/A\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"Fee-For-Service Direct Network\", \"PRODUCT\": \"N/A\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"Commercial\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"HMO, PPO, EPO, POS\", \"PRODUCT\": \"AIM, leased networks\"}, {\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"PPO, EPO, POS, Leased PPO\", \"PRODUCT\": \"N/A\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"Commercial\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"Direct Network, Fee-For-Service\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"Medicare Advantage\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"Medicare Advantage\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"Medicare Advantage\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"Medicare Advantage\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"Medicare Advantage\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"Direct Network, Fee-For-Service\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"Medicaid\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"HMO\", \"PRODUCT\": \"Health Net, CalViva Health, Medi-Cal\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"Medicaid\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"Health Net Medi-Cal\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"Medicaid\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"HMO\", \"PRODUCT\": \"Health Net, Medi-Cal HMO\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"Medicaid\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"HMO\", \"PRODUCT\": \"Medi-Cal, Health Net\"}, {\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"N/A\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"Medicaid\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"HMO\", \"PRODUCT\": \"Medi-Cal, Healthy Families\"}, {\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"Medicaid\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"Health Net\"}, {\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"CHDP (Children's Health and Disability Prevention) Program, CCS (California Children's Services), CPSP (Comprehensive Perinatal Services Program), Vaccines for Children Program (VFC)\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"N/A\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"Medicaid\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"Fee-For-Service\", \"PRODUCT\": \"Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"Medicaid\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"FFS\", \"PRODUCT\": \"Medi-Cal Benefit Program, Health Net\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"Fee-For-Service Direct Network\", \"PRODUCT\": \"N/A\"}]\n",
|
||||
"[\n",
|
||||
" {\n",
|
||||
" \"CONTRACT_LOB\": \"Medicaid\",\n",
|
||||
" \"CONTRACT_PROGRAM\": \"Healthy Families, Healthy Kids\",\n",
|
||||
" \"CONTRACT_NETWORK\": \"HMO, EPO\",\n",
|
||||
" \"PRODUCT\": \"Healthy Families Plan\"\n",
|
||||
" }\n",
|
||||
"]\n",
|
||||
"[{\"CONTRACT_LOB\": \"Medicaid\", \"CONTRACT_PROGRAM\": \"Healthy Families, Healthy Kids\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"Health Net, Managed Health Network\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"Medicaid\", \"CONTRACT_PROGRAM\": \"Healthy Families, Healthy Kids Benefit Program\", \"CONTRACT_NETWORK\": \"Direct Network, FFS\", \"PRODUCT\": \"Health Net\"}, {\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"Medi-Cal Fee-For-Service Program, CMS\"}]\n",
|
||||
"[{\"CONTRACT_LOB\": \"Commercial, Medicare Advantage, Medicaid, Healthy Families, Healthy Kids\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"FFS\", \"PRODUCT\": \"Health Net\"}, {\"CONTRACT_LOB\": \"N/A\", \"CONTRACT_PROGRAM\": \"N/A\", \"CONTRACT_NETWORK\": \"N/A\", \"PRODUCT\": \"N/A\"}]\n"
|
||||
"ename": "FileNotFoundError",
|
||||
"evalue": "[WinError 3] The system cannot find the path specified: 'results'",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[1;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
|
||||
"Cell \u001b[1;32mIn[3], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mutils\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mconsolidate_individual\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n",
|
||||
"File \u001b[1;32mc:\\Users\\kminhas\\Documents\\Doczy\\doczy.ai\\src\\utils.py:57\u001b[0m, in \u001b[0;36mconsolidate_individual\u001b[1;34m(input_folder, output_folder)\u001b[0m\n\u001b[0;32m 55\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mconsolidate_individual\u001b[39m(input_folder\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mresults\u001b[39m\u001b[38;5;124m'\u001b[39m, output_folder\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124moutput\u001b[39m\u001b[38;5;124m'\u001b[39m):\n\u001b[0;32m 56\u001b[0m dfs \u001b[38;5;241m=\u001b[39m []\n\u001b[1;32m---> 57\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m filename \u001b[38;5;129;01min\u001b[39;00m \u001b[43mos\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlistdir\u001b[49m\u001b[43m(\u001b[49m\u001b[43minput_folder\u001b[49m\u001b[43m)\u001b[49m:\n\u001b[0;32m 58\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m filename\u001b[38;5;241m.\u001b[39mendswith(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m.csv\u001b[39m\u001b[38;5;124m'\u001b[39m):\n\u001b[0;32m 59\u001b[0m filepath \u001b[38;5;241m=\u001b[39m os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mjoin(input_folder, filename)\n",
|
||||
"\u001b[1;31mFileNotFoundError\u001b[0m: [WinError 3] The system cannot find the path specified: 'results'"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import prompts\n",
|
||||
"import dict_operations\n",
|
||||
"\n",
|
||||
"def run_top_down(filename, text_dict):\n",
|
||||
" all_results = []\n",
|
||||
"\n",
|
||||
" # Primary\n",
|
||||
" for page_num, page_text in text_dict.items():\n",
|
||||
" if not page_num.isdigit():\n",
|
||||
" continue\n",
|
||||
" prompt = prompts.TOP_DOWN_PRIMARY(page_text)\n",
|
||||
" answer = claude_funcs.invoke_claude_3(prompt, max_tokens=4000)\n",
|
||||
" answer_dicts = dict_operations.primary_string_to_dict({page_num : answer}, filename) # Convert to list of dictionaries\n",
|
||||
" all_results.append(answer_dicts)\n",
|
||||
" td_primary = [i for d in all_results for i in d] # Consolidate to one list\n",
|
||||
"\n",
|
||||
" # Secondaries\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" return td_primary # List of list of dictionaries"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 50,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def format_td_check(td_dicts, dont_include_list):\n",
|
||||
" final_str = \"\"\n",
|
||||
" dict_count = 1\n",
|
||||
" for td_dict in td_dicts:\n",
|
||||
" final_str += str(dict_count) + '. '\n",
|
||||
" for k in td_dict.keys():\n",
|
||||
" if k not in dont_include_list:\n",
|
||||
" final_str += k + ': ' + td_dict[k] + ', '\n",
|
||||
" final_str += '\\n'\n",
|
||||
" dict_count += 1\n",
|
||||
" return final_str\n",
|
||||
"\n",
|
||||
"def TOP_DOWN_METAL_LEVEL(LOB, page):\n",
|
||||
" return f\"\"\"### PAGE START ### {page} ### PAGE END\n",
|
||||
" \n",
|
||||
"The above page was identified as applying to a Commercial or Marketplace Line of Business. \n",
|
||||
"\n",
|
||||
"What is the metal level(s) of the line of business. It might be Bronze, Silver, Gold, or Platinum. If multiple are found, return them all in a comma-separated list. If no metal level is found, return 'N/A'.\n",
|
||||
"\n",
|
||||
"Only write what is written on the page. Do not make up new phrases or words. \n",
|
||||
"\n",
|
||||
"ONLY return the metal level, with no other commentary or explanation.\n",
|
||||
"\"\"\"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def TOP_DOWN_DATE(type_, d, page):\n",
|
||||
" return f\"\"\"### PAGE START ### {page} ### PAGE END\n",
|
||||
"\n",
|
||||
"Above is a page of a contract. Identify the {type_} Date associated with the information below:\n",
|
||||
"\n",
|
||||
"{d}\n",
|
||||
"\n",
|
||||
"Only write what is written on the page. Do not make up new phrases or words. If no {type_} date is listed, return 'N/A'.\n",
|
||||
"\n",
|
||||
"Ensure that you do not mistake EFFECTIVE date for TERMINATION date, or vice versa. They are not the same thing. \n",
|
||||
"The TERMINATION date will NOT be labelled as the EFFECTIVE date, and the EFFECTIVE date will NOT be labelled as the TERMINATION date. This is very important, so pay extra close attention.\n",
|
||||
"\n",
|
||||
"ONLY return the answer, with no other commentary or explanation.\n",
|
||||
"\"\"\"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def run_top_down_metal_level(d, page):\n",
|
||||
" if 'MARKETPLACE' in str(d['CONTRACT_LOB']).upper() or 'COMMERCIAL' in str(d['CONTRACT_LOB']).upper():\n",
|
||||
" prompt = TOP_DOWN_METAL_LEVEL(d['CONTRACT_LOB'], page)\n",
|
||||
" answer = claude_funcs.invoke_claude_3(prompt, max_tokens=4000)\n",
|
||||
" else:\n",
|
||||
" answer = 'N/A' \n",
|
||||
" return answer\n",
|
||||
"\n",
|
||||
"def run_top_down_date(type_, d, page):\n",
|
||||
" formatted_d = format_td_check([d], ['Filename', 'page_num'])\n",
|
||||
" prompt = TOP_DOWN_DATE('EFFECTIVE', formatted_d, page)\n",
|
||||
" answer = claude_funcs.invoke_claude_3(prompt, max_tokens=4000)\n",
|
||||
" return answer\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def top_down_secondary(td_results, text_dict):\n",
|
||||
" updated_dicts = []\n",
|
||||
" for d in td_results:\n",
|
||||
" # Run Metal Level\n",
|
||||
" d['CONTRACT_MARKETPLACE_METAL_LEVEL'] = run_top_down_metal_level(d, text_dict[d['page_num']])\n",
|
||||
" \n",
|
||||
" # Dates\n",
|
||||
" d['LOB_PRICING_TERMS_EFFECTIVE_DATE'] = run_top_down_date('EFFECTIVE' , d, text_dict[d['page_num']])\n",
|
||||
" d['LOB_PRICING_TERMS_TERMINATION_DATE'] = run_top_down_date('TERMINATION', d, text_dict[d['page_num']])\n",
|
||||
"\n",
|
||||
" updated_dicts.append(d)\n",
|
||||
" return updated_dicts\n",
|
||||
"\n",
|
||||
"td_dicts = top_down_secondary(td_results, text_dict)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 53,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'CONTRACT_LOB': 'N/A',\n",
|
||||
" 'CONTRACT_PROGRAM': 'N/A',\n",
|
||||
" 'CONTRACT_NETWORK': 'Fee-For-Service Direct Network',\n",
|
||||
" 'PRODUCT': 'Health Net',\n",
|
||||
" 'page_num': '19',\n",
|
||||
" 'Filename': 'Baz Allergy Asthma & Sinus_MU.txt',\n",
|
||||
" 'CONTRACT_MARKETPLACE_METAL_LEVEL': 'N/A',\n",
|
||||
" 'LOB_PRICING_TERMS_EFFECTIVE_DATE': '10-6-2011',\n",
|
||||
" 'LOB_PRICING_TERMS_TERMINATION_DATE': '10-6-2011'}"
|
||||
]
|
||||
},
|
||||
"execution_count": 53,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"td_dicts[18]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 44,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"19 7.14 Status as Independent Entitles. None of the provisions of this Agreement is intended to create, nor shall be deemed or construed to create any relationship between Provider and Health Net or a Payor other than that of independent entities contracting with each other solely for the purpose of effecting the provisions of this Agreement. Neither Provider nor Health Net/Payor, nor any of their respective agents, employees or representatives shall be construed to be the agent, employee or representative of the other. 7.15 Addenda. Each Addendum to this Agreement is made a part of this Agreement as though set forth fully herein. Any provision of an Addendum that is in conflict with any provision of this Agreement shall take precedence and superseda the conflicting provision of this Agreement with respect to the subject matter of the Addendum. 7.16 Calculation of Time. The parties agree that for purposes of calculating time under this Agreement, any time period of less than ten (10) days shall be deemed to refer to business days and any time period of ten (10) days or more shall be deemed to refer to calendar days unless the term \"business\" precedes the term \"days\". 7.17 Waiver of Breach. The waiver of any breach of this Agreement by either party shall not constitute a continuing waiver of any subsequent breach of either the same or any other provision(s) of this Agreement. Further, any such waiver shall not be construed to be a waiver on the part of such party to enforce strict compliance in the future and to exercise any right or remedy related thereto. THIS CONTRACT CONTAINS A BINDING ARBITRATION CLAUSE, WHICH MAY BE ENFORCED BY THE PARTIES, IN WITNESS WHEREOF, the parties have executed this Agreement. PROVIDER Love HEALTHNE Signature Obly Signature Hoens Health Malik N. BAZ , M.D. Cathy Hoens Print Name Print Name Chairman Title VP Provider Network Management & Strategy Title Baz Allergy Asthma & Sinus Group Name (If Applicable) LIR. 6/29/2011 Date 77-0508441 7/15/11 Tax Identification Number 10-6-2011 Effective Date Date California Provider Participation Agreement Fee-For-Service Direct Network Template 18 HN-DIN-PPA-04-08-11 This page has 2 signature.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(text_dict['19'])"
|
||||
"utils.consolidate_individual(input_folder='../results/', output_folder='../output/')"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user