Merged in methodology_breakout_test (pull request #438)

Methodology breakout test

* initial commit

* added test_methodology_breakout jupyter file

* added test methodology breakout files

* methodology breakout testing

* removed duplicate file methodology_breakout_prediction2.py

* added AARETE_DERIVED_FEE_SCHEDULE_VERSION

* fixed CONTRACT_REIMBURSEMENT_PERCENT_RATE prompt

* moved test breakout files to testbed

* cleaned label df

* updated prompts for methodology breakout

* updated methodology breakout prompts

* accuracy calc. fixed

* updated valid reimbursement methodologies

* Merge branch 'main' into methodology_breakout_test
merged main

* dofr fix

* accuracy fix

* AWP, WAC and ASP to MedRx update

* prompt updated for UNIT_OF_MEASURE_FOR_FLAT_RATE

* fixed issues raised in mr

* Medicare Member Cost Share fixed

* Merge branch 'main' into methodology_breakout_test
merged changes from main


Approved-by: Alex Galarce
This commit is contained in:
Mayank Aamseek
2025-03-17 18:31:51 +00:00
committed by Alex Galarce
parent dc9f8d2b0e
commit c4219ad6dc
5 changed files with 1138 additions and 17 deletions
@@ -115,15 +115,24 @@ VALID_CONTRACT_CLAIM_TYPE = [
VALID_REIMBURSEMENT_METHOD = [
"Billed Charges",
"Fee Schedule",
"Flat Rate",
"Case Rate",
"Per Diem Rate",
"Flat Rate", # Per line
"Per Visit", # multiple lines
"Per Diem", # claim level
"Case Rate", # multiple claim level
# "MedRx",
"AWP", # will be converted to MedRx in postprocessing
"ASP", # will be converted to MedRx in postprocessing
"WAC", # will be converted to MedRx in postprocessing
"Cost Plus",
"AWP",
"Pass Through"
"Pass Through",
"Grouper",
"Outlier",
"Stop-Loss",
"Reductions",
"DOFR"
"RBRVS",
"RVU",
# "DOFR", # moved to prompt as this value is rare
# "Medicare Member Cost Share" # This is a special case where the member is responsible for the cost share and these records will be removed in postprocessing. moved to prompt as this value is rare.
]
VALID_CARVEOUTS = {
@@ -219,13 +219,16 @@ def get_methodology_breakout(reimbursement_primary_answers: list[dict], filename
contract_reimbursement_method = answer_dict.get("CONTRACT_REIMBURSEMENT_METHOD")
# Methodology Breakout: AARETE_DERIVED_REIMBURSEMENT_METHOD, CONTRACT_REIMBURSEMENT_FEE_RATE, CONTRACT_REIMBURSEMENT_PERCENT_RATE, CONTRACT_LESSER_OF_IND, CONTRACT_GREATER_OF_IND, AARETE_DERIVED_PROV_TYPE
if contract_reimbursement_method:
methodology_breakout_answer = string_utils.universal_json_load(
llm_utils.invoke_claude(
investment_prompts.REIMBURSEMENT_METHODOLOGY_BREAKOUT(contract_reimbursement_method, methodology_breakout_questions),
config.MODEL_ID_CLAUDE35_SONNET,
filename
)
)
llm_response = llm_utils.invoke_claude(
investment_prompts.REIMBURSEMENT_METHODOLOGY_BREAKOUT(contract_reimbursement_method, methodology_breakout_questions),
config.MODEL_ID_CLAUDE35_SONNET,
filename
)
try:
methodology_breakout_answer = string_utils.universal_json_load(llm_response)
except ValueError as e:
print(f"universal_string_load failed for input {llm_response} with error {e}\nassigning methodology_breakout_answer to []")
methodology_breakout_answer = []
for methodology_breakout_dict in methodology_breakout_answer:
# Fee Schedule Breakout
if contract_reimbursement_method and "Fee Schedule" in methodology_breakout_dict.get("AARETE_DERIVED_REIMBURSEMENT_METHOD", ""):
+10 -1
View File
@@ -36,8 +36,17 @@ def postprocess(df):
"AARETE_DERIVED_TERMINATION_DATE"
] = "9999/01/01"
# Remove rows where 'AARETE_DERIVED_REIMBURSEMENT_METHOD' value is "Medicare Member Cost Share"
df = df[df['AARETE_DERIVED_REIMBURSEMENT_METHOD'] != "Medicare Member Cost Share"]
# Standardize 'AARETE_DERIVED_REIMBURSEMENT_METHOD' values
# Copy AWP, ASP, WAC to AARETE_DERIVED_FEE_SCHEDULE column for the corresponding row
medrx_fee_schedule_values = ['AWP', 'ASP', 'WAC']
df.loc[df['AARETE_DERIVED_REIMBURSEMENT_METHOD'].isin(medrx_fee_schedule_values), 'AARETE_DERIVED_FEE_SCHEDULE'] = df['AARETE_DERIVED_REIMBURSEMENT_METHOD']
# Convert AARETE_DERIVED_REIMBURSEMENT_METHOD values [AWP, ASP, WAC] to 'MedRx'
df['AARETE_DERIVED_REIMBURSEMENT_METHOD'] = df['AARETE_DERIVED_REIMBURSEMENT_METHOD'].replace({'AWP': 'MedRx', 'ASP': 'MedRx', 'WAC': 'MedRx'})
# Standardize output column order - this should ALWAYS be the final postprocessing step
df = postprocessing_funcs.reorder_columns(df, COLUMN_ORDER)
@@ -27,9 +27,16 @@
"field_name": "AARETE_DERIVED_REIMBURSEMENT_METHOD",
"relationship": "one_to_n",
"field_type": "methodology_breakout",
"prompt": "What is the method of reimbursement? Choose only from the following: {valid_values}. Note that if the reimbursement is a dollar value, the AARETE_DERIVED_REIMBURSEMENT_METHOD cannot be 'Fee Schedule'.",
"prompt": "What is the method of reimbursement? Choose only from the following: {valid_values}. Note that if the reimbursement is a dollar value, the AARETE_DERIVED_REIMBURSEMENT_METHOD cannot be 'Fee Schedule'.if Average Sales Price (ASP) is present in the methodology, then return 'ASP' value. In cases Where we have 'cost plus 5% based on AWP' it should be AWP not Cost Plus. Answer DOFR only when the word 'DOFR' is specifically mentioned. Answer 'Medicare Member Cost Share' only when the phrase 'Medicare Member Cost Share' is specifically mentioned.",
"valid_values": "VALID_REIMBURSEMENT_METHOD"
},
{
"field_name": "UNIT_OF_MEASURE",
"relationship": "one_to_n",
"field_type": "methodology_breakout",
"prompt": "If the reimbursement rate is flat rate, what is its unit of measure. some examples are Per Minute, Per Hour, Per Unit, Per mg, ml etc."
},
{
"field_name": "CONTRACT_REIMBURSEMENT_FEE_RATE",
"relationship": "one_to_n",
@@ -40,7 +47,7 @@
"field_name": "CONTRACT_REIMBURSEMENT_PERCENT_RATE",
"relationship": "one_to_n",
"field_type": "methodology_breakout",
"prompt": "If the reimbursement rate is a percentage of something, what is that percentage? Note that 100% may be implied."
"prompt": "If the reimbursement rate is a percentage of something, what is that percentage?. If no specific percentage is explicitly mentioned, return 100 as the default value. Extract only the final percentage value from the text."
},
{
"field_name": "REIMBURSEMENT_EFFECTIVE_DT",
@@ -88,7 +95,7 @@
{
"field_name": "AARETE_DERIVED_FEE_SCHEDULE_VERSION",
"relationship": "one_to_n",
"field_type": "TBD",
"field_type": "fee_schedule_breakout",
"prompt": "What version of the fee schedule is it? Look for a version number, a year, a date, or the words 'prevailing', 'current', or similar."
},
{
File diff suppressed because it is too large Load Diff