Merged in bugfix/mb-prompts (pull request #833)

Bugfix/mb prompts

* reimb primary prompt update

* Merge branch 'main' into bugfix/highmark-reimb-primary

* prompt reorganised

* Merged main into bugfix/mb-prompts

* mb prompt refinement

* Merge branch 'bugfix/mb-prompts' of https://bitbucket.org/aarete/doczy.ai into bugfix/mb-prompts

* Merged main into bugfix/mb-prompts

* fee schedule prompt simplified

* Merged in bugfix/methodology_breakout_reimb_pct_rate (pull request #831)

bugfix/methodology_breakout_reimb_pct_rate to bugfix/mb-prompts

* remove case rate from fill empty reimb pct rate

* Merged bugfix/mb-prompts into bugfix/methodology_breakout_reimb_pct_rate


Approved-by: Katon Minhas

* Merged main into bugfix/mb-prompts

* grouper breakout prompt changes

* Merged main into bugfix/mb-prompts

* Merged main into bugfix/mb-prompts

* Update reimb primary prompt


Approved-by: Katon Minhas
This commit is contained in:
Mayank Aamseek
2026-01-12 18:18:42 +00:00
committed by Katon Minhas
parent 72f633cad2
commit 87f3d2f4f0
4 changed files with 17 additions and 22 deletions
@@ -17,10 +17,10 @@ def postprocess(df, constants: Constants):
sort_columns = ["FILE_NAME"]
if "EXHIBIT_PAGE" in df.columns:
sort_columns.append("EXHIBIT_PAGE")
if "REIMB_LESSER_OF_ID" in df.columns:
sort_columns.append("REIMB_LESSER_OF_ID")
if "REIMB_ID" in df.columns:
sort_columns.append("REIMB_ID")
if "REIMB_LESSER_OF_ID" in df.columns:
sort_columns.append("REIMB_LESSER_OF_ID")
df = df.sort_values(by=sort_columns).reset_index(drop=True)
# Format rate fields
@@ -585,7 +585,7 @@ def fill_empty_reimb_pct_rate(df):
df.loc[fill_mask, "REIMB_PCT_RATE"] = "100"
# Set to N/A for specific reimbursement methods
na_methods = ["Per Diem", "Flat Rate", "Per Visit", "Case Rate"]
na_methods = ["Per Diem", "Flat Rate", "Per Visit"]
na_mask = df["AARETE_DERIVED_REIMB_METHOD"].isin(na_methods)
df.loc[na_mask, "REIMB_PCT_RATE"] = "N/A"
@@ -21,7 +21,7 @@
"field_name": "AARETE_DERIVED_REIMB_METHOD",
"relationship": "one_to_n",
"field_type": "methodology_breakout",
"prompt": "What is the method of reimbursement? Choose only from the following valid values: {valid_values}.\nFollow these mapping rules:\n- If any of Medicare, Medicaid, Average Sales Price (ASP), AWP (Average Wholesale Price), WAC (Wholesale Acquisition Cost), RBRVS (Resource-Based Relative Value Scale), RVU (Relative Value Unit) or ASA (American Society of Anesthesiology) or any type of Fee Schedule is mentioned, method of reimbursement is generally 'Fee Schedule'.\n- In case of DRG, MS-DRG, AP-DRG, SDA (Standard Dollar Amount), APR-DRG, APG, EAPG, APC (Ambulatory Payment Classification)/OPPS (Outpatient Prospective Payment System) or Ambulatory Surgical Center (ASC), Inpatient/IRF Prospective Payment System, method is generally 'Grouper'.\n- In case of Percent of Charge or Percentage of Billed, return 'Billed Charges'.\n- When reimbursement is Per Case, Per Unit, or similar, return 'Flat Rate'.\n- When reimbursement is defined on a per-day basis, the applicable method is Per Diem.\n- For mixed methodologies (e.g., 'cost plus 5% based on AWP'), prioritize the base method (AWP).\n\nImportant exceptions and additional rules:\n- Reimbursements with specific dollar values cannot be 'Fee Schedule'.\n- Provider interest rates are not considered 'Flat Rate'.\n- Charge master increase caps or limitations on provider pricing behavior are NOT reimbursement methodologies and should be ignored.\n\nChoose the most appropriate value from the valid values list. Never return 'N/A'.",
"prompt": "What is the method of reimbursement? Choose only from the following valid values: {valid_values}.\nFollow these mapping rules:\n- If any of Medicare, Medicaid, Average Sales Price (ASP), AWP (Average Wholesale Price), WAC (Wholesale Acquisition Cost), RBRVS (Resource-Based Relative Value Scale), RVU (Relative Value Unit) or ASA (American Society of Anesthesiology) or any type of Fee Schedule is mentioned, method of reimbursement is generally 'Fee Schedule'.\n- In case of DRG, MS-DRG, AP-DRG, SDA (Standard Dollar Amount), APR-DRG, APG, EAPG, APC (Ambulatory Payment Classification)/OPPS (Outpatient Prospective Payment System) or Ambulatory Surgical Center (ASC), Inpatient/IRF Prospective Payment System, method is generally 'Grouper'.\n- In case of Percent of Charge or Percentage of Billed, return 'Billed Charges'.\n- When reimbursement is Per Case, Per Unit, or similar, return 'Flat Rate'.\n- When reimbursement is defined on a per-day basis, the applicable method is Per Diem.\n- For mixed methodologies (e.g., 'cost plus 5% based on AWP'), prioritize the base method (AWP).\n\nImportant exceptions and additional rules:\n- Reimbursements with specific dollar values cannot be 'Fee Schedule'.\n- Provider interest rates, Charge master increase caps or limitations on provider pricing behavior are NOT reimbursement methodologies and should be ignored.\n\nChoose the most appropriate value from the valid values list. Never return 'N/A'.",
"valid_values": "VALID_REIMB_METHODOLOGY"
},
{
@@ -34,13 +34,13 @@
"field_name": "REIMB_PCT_RATE",
"relationship": "one_to_n",
"field_type": "methodology_breakout",
"prompt": "What is the percentage rate of reimbursement? Extract the numeric percentage value (without % symbol).\n\nPRIORITIZE the primary percentage that directly describes the reimbursement rate. Look for percentages in:\n- Numeric form (e.g., '50%', '100%', '80%')\n- Written form (e.g., 'fifty percent' = 50, 'one hundred percent' = 100, 'eighty percent' = 80)\n- Parenthetical form (e.g., 'fifty percent (50%)' = 50)\n\nIMPORTANT RULES:\n1. Extract the PRIMARY percentage rate that applies to the base payment calculation\n2. If multiple percentages are mentioned, prioritize the one that directly modifies the payment amount (e.g., '50% of the full DRG payment' → extract 50)\n3. If the text says 'plus' followed by a PERCENTAGE (e.g., 'plus 5%'), add that percentage to 100 (e.g., 'plus 5%' = 105)\n4. If the text says 'plus' followed by a NON-PERCENTAGE term (e.g., 'plus the single per diem', 'plus $100'), IGNORE that addition and extract only the base percentage\n5. For complex terms like '50% of X plus Y', extract the 50% (the percentage modifier), not 100\n\nDEFAULT BEHAVIOR:\n- If no percentage is found AND no specific dollar amount is mentioned in the text, return 100 as default\n- If a specific dollar amount is mentioned (but no percentage), return 'N/A'\n- If both percentage and dollar amount are mentioned, extract the percentage value"
"prompt": "What is the percentage rate of reimbursement? Extract the numeric percentage value (without % symbol).\n\nPRIORITIZE the primary percentage that directly describes the reimbursement rate. Look for percentages in different forms e.g., '50%', 'fifty percent', 'fifty percent (50%)'.\n\nIMPORTANT RULES:\n1. Extract the PRIMARY percentage rate that applies to the base payment calculation\n2. If multiple percentages are mentioned, prioritize the one that directly modifies the payment amount (e.g., '50% of the full DRG payment' → extract 50)\n3. If the text says 'plus' followed by a PERCENTAGE (e.g., 'plus 5%'), add that percentage to 100 (e.g., 'plus 5%' = 105), otherwise ignore it (e.g., 'plus $100').\n\nDEFAULT BEHAVIOR:\n- If no percentage is found AND no specific dollar amount is mentioned in the text, return 100 as default\n- If a specific dollar amount is mentioned (but no percentage), return 'N/A'\n- If both percentage and dollar amount are mentioned, extract the percentage value."
},
{
"field_name": "REIMB_CONVERSION_FACTOR",
"relationship": "one_to_n",
"field_type": "methodology_breakout",
"prompt": "What is the conversion factor (a specific dollar amount) mentioned in the text? A conversion factor is a dollar amount used to determine payment for healthcare services, typically under a fee-for-service or Diagnosis-Related Group (DRG) reimbursement model. It serves as a multiplier that converts a relative value (such as a DRG weight or Relative Value Unit — RVU) into an actual payment amount. If no conversion factor is mentioned, return 'N/A'. If it is mentioned as a dollar amount, return it as a numeric value only (e.g., 1.25 for $1.25)."
"prompt": "What is the conversion factor (a specific dollar amount) mentioned in the text? A conversion factor is a dollar amount used to determine payment for healthcare services, typically under a fee-for-service or Diagnosis-Related Group (DRG) reimbursement model. It serves as a multiplier that converts a relative value (such as a DRG weight or Relative Value Unit — RVU) into an actual payment amount. In the case of 'RBRVS', 'RVU', or American Society of Anesthesiology ('ASA'), any dollar amount mentioned refers to a conversion factor, and not to a flat fee rate. If no conversion factor is mentioned, return 'N/A'. If it is mentioned as a dollar amount, return it as a numeric value only (e.g., 1.25 for $1.25)."
},
{
"field_name": "UNIT_OF_MEASURE",
@@ -92,7 +92,7 @@
"field_name": "AARETE_DERIVED_FEE_SCHEDULE_VERSION",
"relationship": "one_to_n",
"field_type": "fee_schedule_breakout",
"prompt": "Identify the version of the fee schedule by following these steps in order:\n\n1. Look for explicit version indicators:\n • Version numbers (e.g., 'Version 5.2')\n • Specific years (e.g., '2023')\n • Specific dates (e.g., 'January 2023')\n • Descriptive terms (e.g., 'prevailing', 'current')\n\n2. If found, return the exact version indicator as it appears in the text.\n\n3. If multiple indicators are found, prioritize them in this order:\n a. Explicit version numbers\n b. Years or dates\n c. Descriptive terms\n\n4. If no explicit version is found, but descriptive terms such as 'prevailing', 'in effect on the date of service', 'then-current', 'most current', 'unspecified', or 'current' are present, return 'current'.\n\n5. If no version indicators are found, choose ONLY from the following standardized values: {valid_values}.\n\n6. If nothing related to version is mentioned, return 'N/A'.\n\nExamples:\n• '2023 Medicare Fee Schedule' → return '2023'\n• 'prevailing CMS rates' → return 'current'\n• 'Version 5.2 Fee Schedule' → return '5.2'",
"prompt": "Identify the version of the fee schedule based on this priority order:\n\n1. Return the exact text if a version number (e.g., 'Version 5.2'), specific year (e.g., '2023'), or specific date (e.g., 'January 2023') is found.\n2. Return 'current' if terms like 'prevailing', 'in effect on the date of service', 'then-current', 'most current', or 'current' are used.\n3. If no explicit version or descriptive term is found, choose only from: ['current', 'year prior'].\n4. If nothing related to version is mentioned, return 'N/A'.",
"valid_values": "VALID_AARETE_DERIVED_FEE_SCHEDULE_VERSION"
},
{
@@ -474,7 +474,7 @@
"field_name": "GROUPER_TYPE",
"relationship": "one_to_n",
"field_type": "grouper_breakout",
"prompt": "Extract all grouper types from the Service and Methodology. Look for MS-DRG, APR-DRG, DRG, APC, APG, EAPG, OPPS (Outpatient Prospective Payment System), Inpatient/IRF Prospective Payment System and similar grouper methodologies. Follow these rules: 1) Standardize all MS-DRG variations (MSDRG, MS DRG, MSDRGs, etc.) to 'MS-DRG'. 2) Standardize all APR-DRG variations (APRDRG, APR DRG, APRDRGs, etc.) to 'APR-DRG'. 3) For other DRG variants (Ohio Medicaid DRG, Non-weighted DRGs, TDH DRG, etc.), extract only 'DRG' without prefixes. 4) Remove all descriptive prefixes - for 'Surgical MSDRGs' return 'MS-DRG', for 'Enhanced APR-DRG' return 'APR-DRG'. 5) In case of OPPS or Outpatient Prospective Payment System of any type, return 'APC'. 6) In case of Inpatient/IRF Prospective Payment System of any type, return 'MS-DRG'. 7) When both MS-DRG/APR-DRG and generic DRG are present in same context, extract only the specific one ('MS-DRG' or 'APR-DRG'), not both. 8) Extract only abbreviations, not full forms. If multiple different grouper types are found, separate them with commas. Do not return empty arrays, empty strings, or brackets. If no grouper methodology is found, return only N/A."
"prompt": "Extract grouper methodologies (MS-DRG, APR-DRG, APC, APG, etc.) from the text. Apply these standardization rules:\n1) Normalize Variations: Convert all 'MS-DRG' variants (e.g., MSDRG, Surgical MSDRGs) to 'MS-DRG'. Convert all 'APR-DRG' variants (e.g., APRDRG, Enhanced APR-DRG) to 'APR-DRG'.\n2) Handle Generic vs. Specific: If a specific type (MS-DRG/APR-DRG) is present alongside generic 'DRG', extract ONLY the specific type. For other variants (Ohio Medicaid DRG, etc.), extract only 'DRG'.\n3) System Mapping: Map any 'OPPS' references to 'APC'. Map any 'Inpatient/IRF Prospective Payment System' references to 'MS-DRG'.\n4) Formatting: Do not return full names, brackets, or empty strings. Return N/A if none found."
},
{
"field_name": "GROUPER_CD",
@@ -492,19 +492,19 @@
"field_name": "GROUPER_VERSION",
"relationship": "one_to_n",
"field_type": "grouper_breakout",
"prompt": "Extract the exact grouper version or release terminology from the Service and Methodology as it appears in the contract. Look for version references like 'MS-DRG Version 40', 'APR-DRG Version 34', 'APC 2023', 'DRG v38', or similar version indicators. Include the complete version phrase exactly as written. If multiple versions are mentioned, separate them with commas. If no version is mentioned, return any additional information present related to grouper type, e.g., 'Ohio Medicaid DRG', 'NYS APR-DRG', 'Michigan Medicaid APC Rates', 'Medicare APC'. Return 'N/A' if no version or additional information related to grouper type is specified."
"prompt": "Extract the exact grouper version phrase (e.g., 'MS-DRG Version 40', 'APR-DRG Version 34', 'APC 2023', 'DRG v38'). If no specific version is listed, fallback to descriptive grouper types (e.g., 'Ohio Medicaid DRG', 'Michigan Medicaid APC Rates'). Return N/A if neither are found."
},
{
"field_name": "AARETE_DERIVED_GROUPER_VERSION",
"relationship": "one_to_n",
"field_type": "grouper_breakout",
"prompt": "Extract only the specific version number or year from any grouper version references in the Service and Methodology. Look for and extract only: 2-digit version numbers (like '40' from 'MS-DRG Version 40'), 4-digit years (like '2024' from 'APC 2024'), or the word 'current' when referring to the most recent version. Return just the number/year/word without any additional text. If multiple versions exist, separate them with commas.. Return N/A if no version is specified."
"prompt": "Extract only the version number, year, or 'current' indicator from grouper references. \n- Target formats: 2-digit numbers (40), 4-digit years (2024), or the word 'current'.\n- Output: Return just the value. Return N/A if unspecified."
},
{
"field_name": "GROUPER_ALTERNATIVE_LEVEL_OF_CARE",
"relationship": "one_to_n",
"field_type": "grouper_breakout",
"prompt": "Extract any reimbursement language from the Service and Methodology that references alternative level of care situations. Look for terms like 'alternative level of care', 'ALC', 'alternative care', 'alternative treatment', 'no longer requiring intensive inpatient services', 'patient ready for discharge but requiring alternative placement', or similar language indicating a patient is in an inpatient setting but no longer needs intensive inpatient services. Extract the exact language as it appears. If multiple references exist, separate them with commas. Return N/A if no alternative level of care language is found."
"prompt": "Extract text referencing 'alternative level of care' (ALC) or patients ready for discharge but requiring alternative placement (e.g., 'no longer requiring intensive inpatient services'). Return exact text or N/A."
},
{
"field_name": "GROUPER_SEVERITY_IND",
@@ -516,13 +516,13 @@
"field_name": "GROUPER_SEVERITY",
"relationship": "one_to_n",
"field_type": "grouper_breakout",
"prompt": "Extract any contract language from the Service and Methodology that references severity levels within grouper systems that influence reimbursement. Look for terms like 'severity level', 'severity of illness', 'acuity level', 'DRG acuity level', 'complications and comorbidities', 'CC/MCC', 'risk adjustment', 'clinical complexity', 'with/without complications', or similar severity-related language. Extract the exact language as it appears. If the severity references are codes or levels, include the grouper type context (APR-DRG, MS-DRG, APC, etc.) with the severity information. If multiple severity references exist, separate them with commas. Return N/A if no severity levels are specified."
"prompt": "Extract any contract language from the Service and Methodology that references severity levels within grouper systems that influence reimbursement. Look for terms like 'severity level', 'severity of illness', 'acuity level', 'DRG acuity level', 'complications and comorbidities', 'CC/MCC', 'risk adjustment', 'clinical complexity', 'with/without complications', or similar severity-related language. Extract the exact language as it appears. If the severity references are codes or levels, include the grouper type context (APR-DRG, MS-DRG, APC, etc.) with the severity information. Return N/A if no severity levels are specified."
},
{
"field_name": "GROUPER_RISK_OF_MORTALITY_SUBCLASS",
"relationship": "one_to_n",
"field_type": "grouper_breakout",
"prompt": "Extract any language from the Service and Methodology that references patient risk of mortality subclasses or mortality-based adjustments within grouper systems that impact reimbursement. Look for terms like 'risk of mortality', 'mortality subclass', 'mortality adjustment', 'ROM', 'mortality risk level', 'death probability', 'mortality indicator', or similar mortality-related classifications used by grouper methodologies. Extract the exact language as it appears. If multiple mortality references exist, separate them with commas. Return N/A if no risk of mortality language is specified."
"prompt": "Extract any language from the Service and Methodology that references patient risk of mortality subclasses or mortality-based adjustments within grouper systems that impact reimbursement. Look for terms like 'risk of mortality', 'mortality subclass', 'mortality adjustment', 'ROM', 'mortality risk level', 'death probability', 'mortality indicator', or similar mortality-related classifications used by grouper methodologies. Extract the exact language as it appears. Return N/A if no risk of mortality language is specified."
},
{
"field_name": "GROUPER_TRANSFER_IND",
@@ -515,20 +515,15 @@ Analyze a given term from a Payer-Provider contract and extract key fields.
- If a clause includes a **"lesser of" (or similar comparative)** structure:
- Carefully extract **every individual reimbursement clause within the comparison**.
- For example: "Lesser of (i) 80% of billed charges, (ii) Medicare rate, or (iii) $400" should yield **three separate JSON dictionaries**.
- **Do not skip any clause**. Every item compared under "lesser of", "greater of", or similar comparative logic must be represented as its own dictionary in the output list.
- **IMPORTANT**: For each component, classify the `AARETE_DERIVED_REIMB_METHOD` based on the INDIVIDUAL component, not the overall structure:
- Dollar amounts (e.g., "$1,180.92") → "Flat Rate"
- Percentages of charges (e.g., "100% of billed charges") → "Billed Charges"
- Fee schedule references (e.g., "Medicare rate") → "Fee Schedule"
- If the methodology includes **additional reimbursement terms** beyond the "lesser of" structure (e.g., administrative fees, per diem charges, or carve-out payments):
- **Do not skip any clause**. Every item compared under "lesser of", "greater of", "equal to", or similar comparative logic must be represented as its own dictionary in the output list.
- **IMPORTANT**: For each component, classify the `AARETE_DERIVED_REIMB_METHOD` based on the INDIVIDUAL component, not the overall structure.
- If the methodology includes **additional reimbursement terms** beyond the "lesser of" structure (e.g., per diem charges, or carve-out payments):
- **These must also be extracted as separate JSON dictionaries** in the same list.
- These are often found in follow-on sentences or clauses and may not be part of a comparative limit but are still enforceable and reimbursable.
- If the methodology includes two reimbursement methodologies that are comparative or equal, such as "70% of Billed Charges equal to Provider's Acquisition Cost plus five percent (5%)", each should be represented as a separate dictionary in the output list.
- For each dictionary, only one of the following fields should be present: REIMB_FEE_RATE, REIMB_PCT_RATE, or REIMB_CONVERSION_FACTOR. The others should be "N/A".
- For each dictionary, only one of the following fields should be present: REIMB_FEE_RATE, REIMB_PCT_RATE, or REIMB_CONVERSION_FACTOR. The others should be "N/A".
- Do not repeat the same reimbursement information in different output entries. For example, if 'cost of vaccines plus a $5 administration fee' is present and $5 is already captured as an addition, do not create a separate dictionary with $5 as a flat fee. Include it only once as an addition.
- For direct calculations like a flat fee of "$150.00 + $8.00", calculate the total ($158.00) and include only this flat fee rate in one dictionary.
In the case of 'RBRVS', 'RVU', or American Society of Anesthesiology ('ASA'), any dollar amount mentioned refers to a conversion factor, and not to a flat fee rate.
If AARETE_DERIVED_REIMB_METHOD is Grouper, the dollar amount refers to REIMB_CONVERSION_FACTOR. If AARETE_DERIVED_REIMB_METHOD is Flat Rate or similar, the dollar amount refers to a REIMB_FEE_RATE.
[OUTPUT FORMAT]