Merged in feature/na_blank_handling (pull request #460)

Feature/na blank handling

* Update prompts to clarify responses for unknown vs N/A values

* Update code description mapping to differentiate between empty and unknown grouper codes

* Update prompts and code descriptions to standardize 'unknown' to 'UNKNOWN'

* Update PIPE_FORMAT_INSTRUCTIONS to replace 'concept' with 'requested information'

* Merge remote-tracking branch 'origin/main' into feature/na_blank_handling

* Merged main into feature/na_blank_handling

* Update NPI prompt for clarity and detailed instructions

* Enhance TIN prompt for clarity and detailed identification instructions

* Merged main into feature/na_blank_handling

* Merged main into feature/na_blank_handling


Approved-by: Katon Minhas
This commit is contained in:
Alex Galarce
2025-04-08 17:36:20 +00:00
parent 807155fe49
commit 273d124d09
3 changed files with 18 additions and 12 deletions
+3 -1
View File
@@ -487,8 +487,10 @@ def code_description_mapping(answer_dicts, all_mappings):
answer_dict["GROUPER_CD_DESC"] = get_code_description(grouper_code, all_mappings['grouper_mapping_ms'])
elif grouper_type == 'APR-DRG':
answer_dict["GROUPER_CD_DESC"] = get_code_description(grouper_code, all_mappings['grouper_mapping_apr'])
elif string_utils.is_empty(grouper_code):
answer_dict["GROUPER_CD_DESC"] = "N/A" # No grouper code exists
else:
answer_dict["GROUPER_CD_DESC"] = "N/A"
answer_dict["GROUPER_CD_DESC"] = "UNKNOWN" # Grouper code exists but type isn't recognized
answer_dict["AUTH_ADMIT_TYPE_DESC"] = get_code_description(admit_type_code, all_mappings['admit_mapping'])
return answer_dicts
@@ -84,7 +84,7 @@
"field_name": "AARETE_DERIVED_FEE_SCHEDULE",
"relationship": "one_to_n",
"field_type": "fee_schedule_breakout",
"prompt": "What type of fee schedule is it? Choose ONLY from the following: {valid_values}. If it is not mentioned, write 'N/A'",
"prompt": "What type of fee schedule is it? Choose ONLY from the following: {valid_values}. If a fee schedule is mentioned but doesn't match any values in the list, write 'UNKNOWN'. If no fee schedule is mentioned at all, write 'N/A'.",
"valid_values" : "VALID_AARETE_DERIVED_FEE_SCHEDULE"
},
{
@@ -218,7 +218,7 @@
"field_name": "PROV_GROUP_TIN",
"relationship": "regex",
"field_type": "regex",
"prompt": "What is the Provider Group's (as opposed to an individual provider's) TIN? Choose ONLY from the following: {valid_values}. If there is no clear Group TIN, write N/A. If there are multiple numbers that appear to be the Group TIN, or multiple Groups that each have a TIN, return number in a comma-separated list."
"prompt": "What is the Provider's Tax Identification Number (TIN) referenced in the contract? Choose ONLY from the following: {valid_values}.\n\nTo identify the correct TIN:\n- Look for TINs in contract headers, identification sections, payment terms, or signature blocks\n- The TIN may appear as 'Tax ID,' 'Tax Identification Number', 'EIN', 'Employer Identification Number', or simply 'TIN'\n- This applies to both provider groups and individual providers\n- Focus on the primary contracted entity rather than subcontractors or affiliated entities\n\nIf multiple TINs appear to be for primary contracted providers, return them in a comma-separated list.\nIf TINs are present but none can be clearly identified as belonging to the primary contracted provider, write 'unknown'.\nIf no TINs are found in the document, write 'N/A'."
},
{
"field_name": "PROV_OTHER_TIN",
@@ -230,7 +230,7 @@
"field_name": "PROV_GROUP_NPI",
"relationship": "regex",
"field_type": "regex",
"prompt": "What is the Provider Group's NPI? This will be the NPI that corresponds with the PROV_GROUP_TIN value. Choose ONLY from the following: {valid_values}. If there is no clear Group NPI, write N/A. If there are multiple numbers that appear to be the Group NPI, return them in a comma-separated list."
"prompt": "What is the Provider's NPI associated with the PROV_GROUP_TIN? Choose ONLY from the following: {valid_values}.\n\nTo identify the correct NPI:\n- Look for NPIs that appear near or in association with the PROV_GROUP_TIN\n- Look for NPIs in contract headers, signature blocks, or identification sections\n- The NPI may not be explicitly labeled as 'Group NPI' - it could be listed simply as 'NPI' or 'Provider NPI'\n- This applies to both provider groups and individual providers\n\nIf multiple NPIs appear to be associated with the PROV_GROUP_TIN, return them in a comma-separated list.\nIf NPIs are present but none can be clearly associated with the PROV_GROUP_TIN, write 'unknown'.\nIf no NPIs are found in the document, write 'N/A'."
},
{
"field_name": "PROV_OTHER_NPI",
@@ -343,7 +343,7 @@
"field_name": "AARETE_DERIVED_PROV_TYPE",
"relationship": "one_to_n",
"field_type": "exhibit_level",
"prompt": "What Provider Type does the Exhibit apply to? Choose ONLY from the following: {valid_values}. If there is no obvious answer, write 'N/A'.",
"prompt": "What Provider Type does the Exhibit apply to? Choose ONLY from the following: {valid_values}. If a provider type is mentioned but doesn't match any values in the list, write 'UNKNOWN'. If no provider type is mentioned at all, write 'N/A'.",
"valid_values": "VALID_PROV_TYPE"
},
{
@@ -14,7 +14,7 @@ from src.utils.string_utils import extract_text_from_delimiters
import json
import importlib
PIPE_FORMAT_INSTRUCTIONS = "Feel free to justify your answer, but enclose your final answer in |pipes|. If the question cannot be answered with the given context, return |N/A|."
PIPE_FORMAT_INSTRUCTIONS = "Feel free to justify your answer, but enclose your final answer in |pipes|. If the requested information doesn't apply to this context, return |N/A|. If the information should exist but cannot be clearly identified, return |UNKNOWN|."
class Field:
def __init__(self, field_dict):
@@ -116,7 +116,7 @@ class Field:
resolved_prompt = resolved_prompt.replace(f"{{{placeholder}}}", str(resolved_value))
else:
pass
# raise ValueError(f"Unknown placeholder: {placeholder}")
# raise ValueError(f"unknown placeholder: {placeholder}")
start_idx = resolved_prompt.find("{", end_idx)
@@ -275,7 +275,8 @@ Here are the attributes to be included in the dictionary, and instructions on ho
For each field, return ALL correct answers found. There may be more than one correct answer. If there are multiple, return them in a comma-separated list.
If a list of valid values is provided, ONLY answer with the EXACT value from that list.
If there are no correct answers for a given field, write N/A as the answer for that field.
If there are no correct answers for a given field because the requested information doesn't apply to this context, write 'N/A' as the answer for that field.
If there are no correct answers for a given field because the requested information should exist but cannot be clearly identified, write 'UNKNOWN' as the answer for that field.
Here is the text to analyze:
@@ -528,7 +529,8 @@ For each question, explain your reasoning. Then provide your final answers in a
The JSON should:
- Include every key
- Use 'N/A' for any question that cannot be answered from the context
- Use 'N/A' for any question where the requested information doesn't apply to this context
- Use 'UNKNOWN' for any question where the requested information should exist but cannot be clearly identified
- Contain only the final answers, not explanations
Example format:
@@ -637,7 +639,8 @@ TINs are 9-digit numbers, often of the format '12-3456789'. They may also be fou
The Group TIN will most often be the one listed on the Signature Page, or the one found on the first page of the contract, if applicable.
If there are multiple Group TINs, return them in a comma-separated list.
If there is no clear Group TIN, simply return 'N/A'.
If TINs are present but none can be clearly identified as the Group TIN, return 'UNKNOWN'.
If there are no TINs at all or the contract doesn't involve a Provider Group, return 'N/A'.
Here is the contract text to analyze:
@@ -652,14 +655,15 @@ def PROV_GROUP_NPI_CHECK(contract_text, prov_group_tin):
else:
tin_sentence = "The Group NPI will most often be the one listed on the Signature Page, or the one found on the first page of the contract, if applicable."
return f"""Examine the contract text below and determine which of the National Provider Identifiers (NPIs) seen belong to the provider group, as opposed to a specific provider.
return f"""Examine the contract text below and determine which of the National Provider Identifiers (NPIs) seen belong to the provider group, as opposed to a specific provider.
NPIs are 10-digit numbers, usually labelled as NPI.
{tin_sentence}
If there are multiple Group NPIs, return them in a comma-separated list.
If there is no clear Group NPI, simply return 'N/A'.
If NPIs are present but none can be clearly identified as the Group NPI, return 'UNKNOWN'.
If there are no NPIs at all or the contract doesn't involve a Provider Group, return 'N/A'.
Here is the contract text to analyze: