diff --git a/src/pipelines/clients/clover/prompts/prompt_calls.py b/src/pipelines/clients/clover/prompts/prompt_calls.py index 1a5410c..7dd9cfe 100644 --- a/src/pipelines/clients/clover/prompts/prompt_calls.py +++ b/src/pipelines/clients/clover/prompts/prompt_calls.py @@ -759,7 +759,6 @@ def prompt_lesser_of_check( instruction=prompt_templates.LESSER_OF_CHECK_INSTRUCTION(), usage_label="LESSER_OF_CHECK", ) - try: # Extract JSON from pipes llm_answer_final = _parser( diff --git a/src/pipelines/saas/prompts/prompt_calls.py b/src/pipelines/saas/prompts/prompt_calls.py index 114c6a4..df9688b 100644 --- a/src/pipelines/saas/prompts/prompt_calls.py +++ b/src/pipelines/saas/prompts/prompt_calls.py @@ -503,7 +503,7 @@ def prompt_exhibit_header(page_content, filename): usage_label="EXHIBIT_HEADER", ) llm_answer_extracted = _parser(llm_answer_raw) - return llm_answer_extracted + return llm_answer_extracted[0] def prompt_date_fix(date: str) -> str: @@ -724,14 +724,9 @@ def prompt_lesser_of_check( ) try: - # Extract JSON from pipes llm_answer_final = _parser(llm_answer_raw) - logging.debug(f"LESSER_OF_CHECK extracted from pipes: {llm_answer_final}") - # Parse JSON - lesser_of_answer_dict = json.loads(llm_answer_final) - # Validate required fields required_fields = [ "service_term", @@ -741,7 +736,7 @@ def prompt_lesser_of_check( "exhibit_reference", ] for field in required_fields: - if field not in lesser_of_answer_dict: + if field not in llm_answer_final: logging.warning( f"LESSER_OF_CHECK missing field '{field}' for service '{service_term}', " f"exhibit '{exhibit_title}', defaulting to STANDALONE" @@ -755,13 +750,13 @@ def prompt_lesser_of_check( } logging.info( - f"LESSER_OF_CHECK classification: scope={lesser_of_answer_dict['scope']}, " - f"target={lesser_of_answer_dict['target_exhibit']}, " - f"exhibit_ref={lesser_of_answer_dict.get('exhibit_reference')}, " + f"LESSER_OF_CHECK classification: scope={llm_answer_final['scope']}, " + f"target={llm_answer_final['target_exhibit']}, " + f"exhibit_ref={llm_answer_final.get('exhibit_reference')}, " f"service='{service_term}...', exhibit='{exhibit_title}'" ) - return lesser_of_answer_dict + return llm_answer_final except json.JSONDecodeError as e: logging.error( diff --git a/src/pipelines/saas/test.py b/src/pipelines/saas/test.py index 4b99efd..cf63627 100644 --- a/src/pipelines/saas/test.py +++ b/src/pipelines/saas/test.py @@ -5,34 +5,14 @@ from src.utils import io_utils from src.pipelines.saas.prompts import prompt_calls from src.pipelines.shared.extraction.one_to_n_funcs import reimbursement_level -constants = Constants() +# constants = Constants() -all_exhibit_rows = [ - {"LOB" : ['Medicaid']} -] +service_term = "Covered Services provided to KIDSfirst Members" +reimb_term = "One hundred percent (100%) of the prevailing yearly and current Medicaid fee schedule for the State of Texas or the Participating Ancillary Services Provider's usual and customary charge, whichever is less." +exhibit_title = 'Attachment B SECTION 1 - PCHP MEDICAID STAR HMO SERVICES' +filename = "" -page_text = """ -PARKLAND COMMUNITY HEALTH PLAN, INC. -A PROGRAM OF DALLAS COUNT HOSPITAL DISTRICT -PARTICIPATING ANCILLARY SERVICES PROVIDER AGREEMENT -Attachment B -SECTION 1 - PCHP MEDICAID STAR HMO SERVICES -Participating Ancillary Services Provider shall be reimbursed for medically necessary Covered -Services provided to HEALTHfirst Members as follows: -1. One hundred percent (100%) of the prevailing yearly and current Medicaid fee schedule for -the State of Texas or the Participating Ancillary Services Provider's usual and customary -charge, whichever is less. -SECTION 2 PCHP CHIP HMO SERVICES -Participating Ancillary Services Provider shall be reimbursed for Covered Services provided to -KIDSfirst Members as follows: -1. One hundred percent (100%) of the prevailing yearly and current Medicaid fee schedule for -the State of Texas or the Participating Ancillary Services Provider's usual and customary -charge, whichever is less. -""" -filename= "sample_files" -reimbursement_primary_answers = reimbursement_level( - page_text, constants, filename -) +lesser_of_answer_dict = prompt_calls.prompt_lesser_of_check(service_term, reimb_term, exhibit_title, filename) -print("FInal: ", reimbursement_primary_answers) +print(lesser_of_answer_dict) diff --git a/src/prompts/prompt_templates.py b/src/prompts/prompt_templates.py index e745500..6ecb553 100644 --- a/src/prompts/prompt_templates.py +++ b/src/prompts/prompt_templates.py @@ -727,14 +727,15 @@ Reimbursement: "lesser of Allowable Charges or Company's fee schedule in effect **OUTPUT FORMAT:** Briefly explain your reasoning, then return a properly-formatted JSON dictionary with the following structure: -{ +{{ "service_term": "", "reimb_term": "", "scope": "", "target_exhibit": "", "exhibit_reference": "" -} -{JSON_DICT_WITH_LISTS_FORMAT_INSTRUCTIONS}""" +}} + +{JSON_DICT_FORMAT_INSTRUCTIONS}""" def LESSER_OF_CHECK(service_term: str, reimb_term: str, exhibit_title: str) -> Tuple[str, Callable[[str], dict]]: