import utils import preprocess import table_funcs import prompts import claude_funcs import config import pandas as pd import os import shutil # input_dict = utils.read_input() # filename = list(input_dict.keys())[0] # contract_text = input_dict[filename] # contract_text = preprocess.clean_newlines(contract_text) # contract_text = preprocess.clean_billed_charges(contract_text) # text_dict = preprocess.split_text(contract_text) # text_dict = table_funcs.align_and_format_tables(text_dict) # text_dict = preprocess.highlight_rates(text_dict) # def BOTTOM_UP_PRIMARY(page, payer): # return f""" # ### PAGE START ### {page} ### PAGE END # The preceding text is one page of a contract between Payer {payer} and a provider in their network. Your job is to extract attributes related to the reimbursement of different services and specialties. # The reimbursement values will be identified with >>> <<< indicators (e.g. >>>105%<<<). Make sure there is at least one dictionary object for EVERY reimbursement value seen (either % or $). # Some values are found in sections explicitly identified as examples - these must be omitted from output. Other values might be related to liability - these must also be excluded. # If any of the attributes are not found, return N/A. For all attributes, only write what is written on the page. Do not make up new phrases or words. # Return at least one json object for each combination of attributes seen. It is possible that a page will not have any attributes. When this is the case, return an empty list. # 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. Use only exact text from the document. Do not leave this field N/A. # '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 methodology. # 'DATE_RANGE' : If the listed reimbursement only applies to a specific date range, write that range here. Write only the exact text. Write only the range. If there is none, write 'N/A'. # 'REIMBURSEMENT_TIN' : If the listed reimbursement only applies to a specific TIN, write only the TIN here. If not, write 'N/A' # Note that only one of REIMBURSEMENT_FLAT_FEE or REIMBURSEMENT_RATE should be populated in each dictionary. Ensure all 4 keys are in the dictionary. # Only return the list, with no other commentary or explanation. Ensure you abide by proper JSON formatting. # """ # answer_dict = {} # for page_number in text_dict.keys(): # if utils.contains_reimbursement(text_dict, page_number): # # Run Primary # prompt = BOTTOM_UP_PRIMARY(text_dict[page_number], config.CLIENT_NAME) # answer = claude_funcs.invoke_claude_3(prompt, max_tokens=4000) # answer_dict[page_number] = answer # for page_num in answer_dict.keys(): # print(f"Page {page_num}\n") # print(answer_dict[page_num]) batch1_files = pd.read_excel("C:\\Users\\kminhas\\Documents\\Doczy\\Facility TINs_DOCZY AI_DOCUMENT EXTRACTION_ASSIGNMENT_7.1.2024.xlsx", sheet_name='DOCZY AI') batch1_files = batch1_files['File Name'] # print(list(batch1_files)) tdrive_path = "T:\\AArete Client Work\\Centene\\Restricted\\HealthNet\\Doczy Contract Metadata\\1. Contracts\\05232024\\Extracted" batch_path = os.path.join(tdrive_path, 'Batch0') try: os.mkdir(batch_path) except: pass for file in os.listdir(tdrive_path): if file.endswith('.Pdf') and file.split('.Pdf')[0] in list(batch1_files): try: source_path = os.path.join(tdrive_path, file) destination_path = os.path.join(batch_path, file) shutil.move(source_path, destination_path) print(f"Moved file: {file}") except: pass