Commit Graph

1605 Commits

Author SHA1 Message Date
VenkataKrishna Reddy Avula a9b08388e3 Merged in bugfix/payer_name (pull request #827)
Bugfix/payer name to main

* added full context instruction for payer name

* removed print statement


Approved-by: Katon Minhas
2026-01-06 16:40:59 +00:00
Karan Desai 04a190d5b7 Merged in bugfix/hmk-issues (pull request #824)
Bugfix/hmk issues

* fix for missing AARETE_DERIVED_LOB

* fix for AARETE_DERIVED_SID

* bugfix in universal_json_load

* bugfix for normalize_state_field

*  reimb eff date assignmnet prompt update

* prompt update for missing reimb terms

* Merged main into bugfix/hmk-issues

* test case for universal_json_loads

* reveresed the prompt update for missing reimb

* prompt fix for reimb dates


Approved-by: Katon Minhas
2026-01-05 18:34:18 +00:00
VenkataKrishna Reddy Avula b0eed711fc Merged in bugfix/carveout (pull request #825)
bugfix/carveout to main

* removed specific service in base covered

* Merged main into bugfix/carveout

* Merged main into bugfix/carveout


Approved-by: Katon Minhas
2026-01-05 15:43:28 +00:00
Mayank Aamseek fd390e3907 Merged in bugfix/highmark-reimb-primary (pull request #823)
reimb primary prompt update

* reimb primary prompt update

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

* Update reimb primary prompt


Approved-by: Katon Minhas
2026-01-05 15:41:09 +00:00
VenkataKrishna Reddy Avula 49e8964986 Merged in bugfix/provider_tin (pull request #822)
bugfix/provider_tin to main

* false positives case added to prompt


Approved-by: Katon Minhas
2026-01-05 14:15:08 +00:00
Katon Minhas 541a0f97e0 Merged in hotfix/highmark-issues (pull request #821)
Remove EXHIBIT_TEXT column (and all other invalid columns)

* Remove EXHIBIT_TEXT column (and all other invalid columns)
2025-12-29 20:36:22 +00:00
Karan Desai a8146cad11 Merged in bugfix/hmk-1-to-1 (pull request #820)
fix for redundantly populated  provider twice

* fix for redundantly populated  provider twice

* Merged main into bugfix/hmk-1-to-1


Approved-by: Katon Minhas
2025-12-26 20:44:04 +00:00
Praneel Panchigar 85f2c8cecc Merged in bugfix/bill_type_code_fixes (pull request #819)
Bugfix/bill type code fixes

* Fix LOB_PROGRAM_RELATIONSHIP extraction and preserve debugging code

- Add format requirements to LOB_RELATIONSHIP_INSTRUCTION for proper caching
- Strengthen LOB_RELATIONSHIP prompt with explicit pipe delimiter requirements
- Preserve all DEBUG blocks and print statements in dynamic_funcs.py and file_processing.py
- Update crosswalk mappings and gitignore
- Ensure format instructions are cached at API level to prevent missing pipe delimiters

* Merge main into bugfix/dynamic_issuefixes

Resolved merge conflicts in:
- fieldExtraction/src/investment/dynamic_funcs.py (merged debug print statements)
- fieldExtraction/src/investment/file_processing.py (merged debug statements and exhibit inheritance code)

All conflicts resolved successfully.

* Update FILL_BILL_TYPE prompt with place-of-service priority and optional exhibit_text

- Add optional exhibit_text parameter to FILL_BILL_TYPE function
- Update instructions to prioritize place-of-service over service-only terminology
- Add new examples: 'home dialysis' and 'dialysis' while keeping original examples
- Add conditional exhibit context section when exhibit_text is provided
- Maintains backward compatibility (exhibit_text defaults to None)

Ref: PLAN_BILL_TYPE_CD_IMPROVEMENTS.md

* Implement two-step bill type CD determination with exhibit text fallback

- Add EXHIBIT_TEXT to answer_dict in combine_one_to_n() for contextual analysis
- Update fill_bill_type() to use two-step approach:
  1. First attempt: service term only (no exhibit text)
  2. Second attempt: service term + exhibit text (only if first fails)
- Update extract_codes_from_service() to pass exhibit_text to fill_bill_type()
- Add debug print when full exhibit text context is used
- More efficient: only makes second LLM call when service term alone fails

Ref: PLAN_BILL_TYPE_CD_IMPROVEMENTS.md

* Remove debug print statement and merge main into bill_type_code_fixes

- Remove debug print statement from fill_bill_type() in code_funcs.py
- Merge latest changes from main branch
- Includes updates to prompt_templates.py (payer_name parameter)
- Includes updates to file_processing.py (provider info ordering)
- Includes updates to aarete_derived.py, crosswalk mappings, and tin_npi_funcs

* Remove remaining debug print statements from dynamic_funcs.py and file_processing.py


Approved-by: Katon Minhas
2025-12-26 18:24:57 +00:00
Praneel Panchigar b64e1fe4cc Merged in bugfix/derived_lob_changes (pull request #817)
Bugfix/derived lob changes

* Fix LOB_PROGRAM_RELATIONSHIP extraction and preserve debugging code

- Add format requirements to LOB_RELATIONSHIP_INSTRUCTION for proper caching
- Strengthen LOB_RELATIONSHIP prompt with explicit pipe delimiter requirements
- Preserve all DEBUG blocks and print statements in dynamic_funcs.py and file_processing.py
- Update crosswalk mappings and gitignore
- Ensure format instructions are cached at API level to prevent missing pipe delimiters

* Merge main into bugfix/dynamic_issuefixes

Resolved merge conflicts in:
- fieldExtraction/src/investment/dynamic_funcs.py (merged debug print statements)
- fieldExtraction/src/investment/file_processing.py (merged debug statements and exhibit inheritance code)

All conflicts resolved successfully.

* Fix AARETE_DERIVED_LOB to merge values from all crosswalks (PROGRAM and PRODUCT)

- Updated fill_na_mapping to always check both AARETE_DERIVED_PROGRAM and PRODUCT crosswalks
- Merges unique values from all sources (existing, PROGRAM, PRODUCT) instead of only filling when empty
- Ensures Duals is included when PRODUCT contains Molina Medicare Options Plus
- Deduplicates and sorts values before pipe-delimiting
- Each row processed individually for correct LOB assignment per reimbursement term

* Merged main into bugfix/derived_lob_changes


Approved-by: Katon Minhas
2025-12-22 19:40:31 +00:00
Sha Brown 77c845a82e Merged in bugfix/prov-info-issues (pull request #816)
Bugfix/prov info issues

* Initial commit

* Passed payer name to tin npi llm call to avoid assigning tin npi to payer

* Removed record that contains NO_IDENTIFIERS_FOUND from PROV_INFO_JSON

* Updated unit test for test_tin_npi_funcs

* Changed name check code back to original to be consistent

* Updated test_tin_npi_funcs.py to pass in payer_name in functions

* Add fix to unit test

* Updated output in unit tests

* Merged main into bugfix/prov-info-issues


Approved-by: Katon Minhas
2025-12-22 19:03:09 +00:00
Mayank Aamseek 7ffd62fd8e Merged in bugfix/highmark-methodology-breakout (pull request #815)
Bugfix/highmark methodology breakout

* fix reimb_term rows for dates

* reimb_primary prompt update

* prompt changes

* Merge remote-tracking branch 'origin/main' into bugfix/highmark-methodology-breakout

* prompt changes

* prompt updates

* Merge branch 'main' into bugfix/highmark-methodology-breakout

* prompt updates

* Prompt updates


Approved-by: Katon Minhas
2025-12-22 18:58:34 +00:00
VenkataKrishna Reddy Avula e8cb48643c Merged in bugfix/carveout_base (pull request #814)
bugfix/carveout_base to main

* updated base covered services


Approved-by: Katon Minhas
2025-12-18 16:51:56 +00:00
Sha Brown 46494274ff Merged in bugfix/one_to_one_and_prov_info (pull request #808)
Bugfix/one to one and prov info

* Add post-processing logic to update PROV_INFO_JSON if needed; Updated prompt to verify the number of digitis in TIN and NPI

* Added update_prov_info_with_group_name to postprocessing_funcs.py

* Updated FIRST_PAGE_PROVIDER_NAME_TEMPLATE to ask LLM to explain resoning before answering

* Updated logic to use LLM to check if provider name matches

* Use only Hybrid Smart Chunking to get provider group name

* Cleaned up code

* Removed commented out code

* Updated unit test

* Merged main into bugfix/one_to_one_and_prov_info

* Edited prompt to distinguish provider names and to enclose answer in pipes

* Updated test_tin_npi_funcs


Approved-by: Katon Minhas
2025-12-17 22:37:06 +00:00
Praneel Panchigar d3bfec0b6b Merged in bugfix/dynamic_issuefixes-clean (pull request #813)
Fix LOB_PROGRAM_RELATIONSHIP extraction and preserve debugging code

* Fix LOB_PROGRAM_RELATIONSHIP extraction and preserve debugging code

- Add format requirements to LOB_RELATIONSHIP_INSTRUCTION for proper caching
- Strengthen LOB_RELATIONSHIP prompt with explicit pipe delimiter requirements
- Preserve all DEBUG blocks and print statements in dynamic_funcs.py and file_processing.py
- Update crosswalk mappings and gitignore
- Ensure format instructions are cached at API level to prevent missing pipe delimiters

* Merge main into bugfix/dynamic_issuefixes-clean and remove all debug print statements

* Remove redundant one_to_one_fields initialization to match main


Approved-by: Katon Minhas
2025-12-17 20:42:13 +00:00
Praneel Panchigar f26b83bd0b Merged in feature/cross-exhibit-dynamic (pull request #789)
Feature/cross exhibit dynamic

* Merge branch 'feature/deprecate-haiku-3' into feature/1toN-Optimization

* fix over-filtering of lesser of

* Merged in bugfix/UT-methodology-breakout (pull request #794)

Bugfix/UT methodology breakout

* updated valid values for AARETE_DERIVED_REIMB_METHOD

* removed example reimbursements

* prompt update

* prompt update

* Merged feature/1toN-Optimization into bugfix/nv_issue_fixes

* add service term in mb prompts

* Merged feature/1toN-Optimization into bugfix/UT-methodology-breakout

* print statement removed

* Merge branch 'bugfix/UT-methodology-breakout' of https://bitbucket.org/aarete/doczy.ai into bugfix/UT-methodology-breakout

* primary prompt update

* remove duplicate prompt


Approved-by: Katon Minhas

* Merge branch 'main' into feature/1toN-Optimization

* Merge branch 'main' into feature/1toN-Optimization

* Update preprocessing to make the exhibit_chunk_mapping start at first page

* Merge remote-tracking branch 'origin/feature/1toN-Optimization' into cross-exhibit-dynamic

* Address merge request comments: refactor prompt templates and logging

- Make DYNAMIC_PRIMARY_TEXT LOB-specific instructions conditional (only show when field_name is LOB)
- Remove MEDICAID FEE SCHEDULE point from DYNAMIC_ASSIGNMENT (point #2)
- Generalize SERVICE_TERM context guidance to apply to all fields (LOB, PROGRAM, NETWORK, PRODUCT)
- Refactor proximity guidance to emphasize contextual connection over strict section boundaries
- Update point #1 to explicitly prevent inferring LOB from Programs alone
- Change exhibit inheritance logging from info to debug level

* Move function to one_to_n_funcs

* Merge row_funcs.py changes from feature/cross-exhibit-dynamic

* Merged feature/1toN-Optimization into feature/cross-exhibit-dynamic

* Merged in bugfix/UT-grouper-issues (pull request #796)

Bugfix/UT grouper issues

* updated valid values for AARETE_DERIVED_REIMB_METHOD

* removed example reimbursements

* prompt update

* prompt update

* Merged feature/1toN-Optimization into bugfix/nv_issue_fixes

* add service term in mb prompts

* Merged feature/1toN-Optimization into bugfix/UT-methodology-breakout

* print statement removed

* Merge branch 'bugfix/UT-methodology-breakout' of https://bitbucket.org/aarete/doczy.ai into bugfix/UT-methodology-breakout

* primary prompt update

* prompt update

* Merge remote-tracking branch 'origin/feature/1toN-Optimization' into bugfix/UT-grouper-issues

* removed temp changes

* removed temp changes

* Update reimb primary


Approved-by: Katon Minhas

* Merged in bugfix/validation_fixes (pull request #795)

bugfix/validation_fixes to feature/1toN-Optimization

* updated validation of clean claims reimbursement

* Merged feature/1toN-Optimization into bugfix/validation_fixes


Approved-by: Katon Minhas

* Merge branch 'feature/1toN-Optimization' into feature/cross-exhibit-dynamic

* Re-add dynamic codes and reimb-info

* Re-structure empty reimbursement prompt

* Fix lesser of check overfiltering

* Merged feature/1toN-Optimization into feature/cross-exhibit-dynamic

* Update LOB inference logic and prompt guidance

- Revert DYNAMIC_PRIMARY_TEXT to original template (remove LOB-specific conditional section)
- Add explicit guidance in DYNAMIC_ASSIGNMENT: presence of Medicaid programs does NOT imply LOB is Medicaid
- Update get_dynamic_one_to_one_fields to only check AARETE_DERIVED_LOB (not raw LOB) when skipping PROGRAM/PRODUCT/NETWORK

* Fix LOB_PROGRAM_RELATIONSHIP extraction: add pipe format instructions to LOB_RELATIONSHIP_INSTRUCTION

* Update Fidelis Essential Plan mappings in crosswalk_product_lob.json

- Add mappings for Essential Plan variants (Aliessa, EP-QHP, EP, Essential Plan)
- Essential Plan Aliessa and EP Aliessa map to Medicaid
- EP-QHP maps to Commercial
- EP and Essential Plan map to Medicaid|Commercial

* Remove debug logging statements from prompt_lob_relationship

* Merge main into feature/cross-exhibit-dynamic: resolved conflicts, removed debug statements, synced prompt_templates.py with main

* Sync non-exhibit-merge files with main before merge

* Remove test.py to match main


Approved-by: Katon Minhas
2025-12-17 19:15:49 +00:00
Karan Desai ca53ff8395 Merged in bugfix/cpt-codes (pull request #812)
Bugfix/cpt codes

* formatting fix for revenue_cd

* format fix for procedure_codes

* bugfix for revenue_codes

* working version from code main

* code formatting from main and code main

* removed dubug prints

* removed local file paths

* standardize state fields

* updated test scenerios

* minor fix

* Merge branch 'main' into bugfix/cpt-codes
merging main into cpt code fix

* checks for all fields

* reused is_empty functionality

* moved normalize_to_json_list to utils

* Merge branch 'main' into bugfix/cpt-codes
merging upto date main

* minor touches

* pytest fix


Approved-by: Katon Minhas
2025-12-17 19:05:09 +00:00
VenkataKrishna Reddy Avula f31c02517a Merged in bugfix/carveout_cd (pull request #811)
bugfix/carveout_cd to main

* added age constraint for payment carveout

* Merged main into bugfix/carveout_cd


Approved-by: Katon Minhas
2025-12-17 16:10:32 +00:00
Siddhant Medar c302c1023a Merged in bugfix/qc_qa_filetype (pull request #810)
Bugfix/qc qa filetype

* WIP: support multi-filetype

* Add graceful error handling to QC/QA standalone CLI

Wrap validation pipeline in try/except to ensure no partial results
are created/uploaded if the pipeline fails mid-execution.

* Add comprehensive QC/QA unit tests, improve coverage to 95%

- Add CLI integration tests for __main__.py (6 tests)
- Add pipeline validation tests for all validation steps (20+ tests)
- Test multi-filetype I/O (CSV, XLSX input/output)
- Test graceful error handling
- Coverage: 43% → 95%

* Merge remote-tracking branch 'origin/main' into bugfix/qc_qa_filetype


Approved-by: Katon Minhas
2025-12-16 20:56:55 +00:00
Katon Minhas 9b89b0a10a Merged main into bugfix/UT-reimbursement-dates 2025-12-15 21:00:27 +00:00
Katon Minhas 33241d5808 Pipeline 2025-12-15 12:52:53 -05:00
Mayank db92b42679 reimb terms based on dates 2025-12-15 15:11:35 +00:00
Praneel Panchigar 87a2b8b4ce Merged in issuefix/hmk-1-to-n (pull request #806)
Issuefix/hmk 1 to n

* Merge branch 'main' into feature/1toN-Optimization

* Merge branch 'main' into feature/1toN-Optimization

* Update preprocessing to make the exhibit_chunk_mapping start at first page

* Merge row_funcs.py changes from feature/cross-exhibit-dynamic

* Merged in bugfix/UT-grouper-issues (pull request #796)

Bugfix/UT grouper issues

* updated valid values for AARETE_DERIVED_REIMB_METHOD

* removed example reimbursements

* prompt update

* prompt update

* Merged feature/1toN-Optimization into bugfix/nv_issue_fixes

* add service term in mb prompts

* Merged feature/1toN-Optimization into bugfix/UT-methodology-breakout

* print statement removed

* Merge branch 'bugfix/UT-methodology-breakout' of https://bitbucket.org/aarete/doczy.ai into bugfix/UT-methodology-breakout

* primary prompt update

* prompt update

* Merge remote-tracking branch 'origin/feature/1toN-Optimization' into bugfix/UT-grouper-issues

* removed temp changes

* removed temp changes

* Update reimb primary


Approved-by: Katon Minhas

* Merged in bugfix/validation_fixes (pull request #795)

bugfix/validation_fixes to feature/1toN-Optimization

* updated validation of clean claims reimbursement

* Merged feature/1toN-Optimization into bugfix/validation_fixes


Approved-by: Katon Minhas

* Re-add dynamic codes and reimb-info

* Re-structure empty reimbursement prompt

* Fix lesser of check overfiltering

* Merged in bugfix/generic-methodology-breakout (pull request #797)

Bugfix/generic methodology breakout

* fee schedule fix

* carveout+special case prompt changed

* fee schedule changes

* prompt changes and column order


Approved-by: Katon Minhas

* pytest fix

* remove prints

* Update valid_carveouts.json to include level designations in PAYMENT_CARVEOUT definition and add adultBasic mapping for Highmark

* Fix REIMB_DATES extraction to capture only relevant date range per term

- Updated REIMB_DATES prompt to extract only the date range that applies to the specific reimbursement term
- Added proximity-based extraction: looks for dates in same section/table as the term
- Prevents cross-contamination from other contract sections
- Handles 'Same as Effective Date of Agreement' case
- Returns single date range instead of multiple comma-separated ranges

* Update prompt templates

* Update tracked files and add untracked_tests to gitignore

* Merge branch 'main' into issuefix/hmk-1-to-n

* complete merge

* complete merge

* Merge branch 'main' into issuefix/hmk-1-to-n

* Remove prints

* Update gitignore

* Revert BASE_COVERED_SERVICES and REIMB_DATES prompts to original definitions

- Revert BASE_COVERED_SERVICES definition to original concise version
- Revert REIMB_DATES prompt to original general description (specific assignment logic handled by dedicated template)
- Add DEBUG comment blocks around print statements in dynamic_funcs.py and file_processing.py for easy identification and toggling

* remove prints

* Merge branch 'main' into issuefix/hmk-1-to-n


Approved-by: Katon Minhas
2025-12-12 18:36:57 +00:00
Mayank Aamseek 042a429ffb Merged in bugfix/UT-special-cases (pull request #807)
Bugfix/UT special cases

* stoploss fix

* Merged main into bugfix/UT-special-cases

* added IPPS

* added Federal PPS

* added IRF PPS

* Merged main into bugfix/UT-special-cases


Approved-by: Katon Minhas
2025-12-12 16:56:36 +00:00
Mayank 06a889781f added IRF PPS 2025-12-12 15:21:35 +00:00
Mayank 5032968f9a added Federal PPS 2025-12-12 15:07:04 +00:00
Mayank 89165c36f7 added IPPS 2025-12-12 15:00:42 +00:00
Katon Minhas 57a2907bbd Update for confusing language 2025-12-11 17:18:37 -06:00
Katon Minhas a00ffd4b98 Update mappings 2025-12-11 17:15:23 -06:00
Katon Minhas 9e7f8840af Merged main into bugfix/UT-special-cases 2025-12-11 20:55:07 +00:00
VenkataKrishna Reddy Avula c91435d2f1 Merged in bugfix/reimb_method_grouper (pull request #805)
bugfix/reimb_method_grouper to main

* modified grouper reimb_method

* Merged main into bugfix/reimb_method_grouper


Approved-by: Katon Minhas
2025-12-11 20:54:47 +00:00
Sha Brown 3bf8860ca6 Merged in bugfix/prov_info (pull request #803)
Bugfix/prov info

* Added logic to extract provider name from first page

* Added prompt to extract provider name from first page

* Added prompts and provider name extraction using Hybrid Smart Chunking

* Cleaned up code

* Added additional logic to check if the provider name on tin/npi page matches provider name extracted from page 1.

* Added fix for IS_GROUP issue in provider info json

* Remove commented out code

* unit test fix

* uni test fix

* Merge branch 'main' into bugfix/prov_info

* Change to string_utils.is_empty

* Minor refactor


Approved-by: Katon Minhas
2025-12-11 20:53:21 +00:00
Mayank 93d3fa93e2 stoploss fix 2025-12-11 15:00:28 +00:00
Karan Desai 290a1e7315 Merged in issuefix/hmk-1-to-1 (pull request #804)
Issuefix/hmk 1 to 1

* prompt fix for auto renew ind

* filename tin regex update

* amendment  number prompt fix

* effective date prompt tunning

* Merge remote-tracking branch 'origin/main' into issuefix/hmk-1-to-1


Approved-by: Katon Minhas
2025-12-10 23:26:24 +00:00
Mayank Aamseek 1de74c9322 Merged in Optimization/reimb-primary (pull request #800)
Optimization/reimb primary

* Merged in bugfix/UT-methodology-breakout (pull request #794)

Bugfix/UT methodology breakout

* updated valid values for AARETE_DERIVED_REIMB_METHOD

* removed example reimbursements

* prompt update

* prompt update

* Merged feature/1toN-Optimization into bugfix/nv_issue_fixes

* add service term in mb prompts

* Merged feature/1toN-Optimization into bugfix/UT-methodology-breakout

* print statement removed

* Merge branch 'bugfix/UT-methodology-breakout' of https://bitbucket.org/aarete/doczy.ai into bugfix/UT-methodology-breakout

* primary prompt update

* remove duplicate prompt


Approved-by: Katon Minhas

* Merge branch 'main' into feature/1toN-Optimization

* Merge branch 'main' into feature/1toN-Optimization

* Update preprocessing to make the exhibit_chunk_mapping start at first page

* Merge row_funcs.py changes from feature/cross-exhibit-dynamic

* Merged in bugfix/UT-grouper-issues (pull request #796)

Bugfix/UT grouper issues

* updated valid values for AARETE_DERIVED_REIMB_METHOD

* removed example reimbursements

* prompt update

* prompt update

* Merged feature/1toN-Optimization into bugfix/nv_issue_fixes

* add service term in mb prompts

* Merged feature/1toN-Optimization into bugfix/UT-methodology-breakout

* print statement removed

* Merge branch 'bugfix/UT-methodology-breakout' of https://bitbucket.org/aarete/doczy.ai into bugfix/UT-methodology-breakout

* primary prompt update

* prompt update

* Merge remote-tracking branch 'origin/feature/1toN-Optimization' into bugfix/UT-grouper-issues

* removed temp changes

* removed temp changes

* Update reimb primary


Approved-by: Katon Minhas

* Merged in bugfix/validation_fixes (pull request #795)

bugfix/validation_fixes to feature/1toN-Optimization

* updated validation of clean claims reimbursement

* Merged feature/1toN-Optimization into bugfix/validation_fixes


Approved-by: Katon Minhas

* Re-add dynamic codes and reimb-info

* Re-structure empty reimbursement prompt

* Fix lesser of check overfiltering

* Merged in bugfix/generic-methodology-breakout (pull request #797)

Bugfix/generic methodology breakout

* fee schedule fix

* carveout+special case prompt changed

* fee schedule changes

* prompt changes and column order


Approved-by: Katon Minhas

* fix not_to_exceed distribution

* pytest fix

* remove prints

* Merge remote-tracking branch 'origin/feature/1toN-Optimization' into Optimization/reimb-primary

* prompt update for reimb primary

* Update mapping

* Update tests

* Update test

* row order fixed

* Merge remote-tracking branch 'origin/feature/1toN-Optimization' into Optimization/reimb-primary

* chargemaster fix

* Merge branch 'main' into Optimization/reimb-primary

* Complete merge

* Final updates


Approved-by: Katon Minhas
2025-12-10 22:24:44 +00:00
Katon Minhas 0e2622f156 Merged in feature/1toN-Optimization (pull request #799)
Feature/1toN Optimization

* Update config - remove Haiku 3

* Merged in optimization/trigger-cap (pull request #792)

Optimization/trigger cap

* trigger cap breakout added

* Merge remote-tracking branch 'origin/feature/1toN-Optimization' into optimization/trigger-cap

* carveout breakout added


Approved-by: Katon Minhas

* Merged in bugfix/utah_issue_fixes (pull request #791)

Bugfix/utah issue fixes to feature/1toN-Optimization

* updated valid values for AARETE_DERIVED_REIMB_METHOD

* removed example reimbursements

* removed reciprocatory agreements section reimbs

* Merged feature/1toN-Optimization into bugfix/utah_issue_fixes

* update reimb primary


Approved-by: Katon Minhas

* Update unit tests

* Update llm_utils

* Merge branch 'feature/deprecate-haiku-3' into feature/1toN-Optimization

* fix over-filtering of lesser of

* Merged in bugfix/UT-methodology-breakout (pull request #794)

Bugfix/UT methodology breakout

* updated valid values for AARETE_DERIVED_REIMB_METHOD

* removed example reimbursements

* prompt update

* prompt update

* Merged feature/1toN-Optimization into bugfix/nv_issue_fixes

* add service term in mb prompts

* Merged feature/1toN-Optimization into bugfix/UT-methodology-breakout

* print statement removed

* Merge branch 'bugfix/UT-methodology-breakout' of https://bitbucket.org/aarete/doczy.ai into bugfix/UT-methodology-breakout

* primary prompt update

* remove duplicate prompt


Approved-by: Katon Minhas

* Merge branch 'main' into feature/1toN-Optimization

* Merge branch 'main' into feature/1toN-Optimization

* Update preprocessing to make the exhibit_chunk_mapping start at first page

* Merge row_funcs.py changes from feature/cross-exhibit-dynamic

* Merged in bugfix/UT-grouper-issues (pull request #796)

Bugfix/UT grouper issues

* updated valid values for AARETE_DERIVED_REIMB_METHOD

* removed example reimbursements

* prompt update

* prompt update

* Merged feature/1toN-Optimization into bugfix/nv_issue_fixes

* add service term in mb prompts

* Merged feature/1toN-Optimization into bugfix/UT-methodology-breakout

* print statement removed

* Merge branch 'bugfix/UT-methodology-breakout' of https://bitbucket.org/aarete/doczy.ai into bugfix/UT-methodology-breakout

* primary prompt update

* prompt update

* Merge remote-tracking branch 'origin/feature/1toN-Optimization' into bugfix/UT-grouper-issues

* removed temp changes

* removed temp changes

* Update reimb primary


Approved-by: Katon Minhas

* Merged in bugfix/validation_fixes (pull request #795)

bugfix/validation_fixes to feature/1toN-Optimization

* updated validation of clean claims reimbursement

* Merged feature/1toN-Optimization into bugfix/validation_fixes


Approved-by: Katon Minhas

* Re-add dynamic codes and reimb-info

* Re-structure empty reimbursement prompt

* Fix lesser of check overfiltering

* Merged in bugfix/generic-methodology-breakout (pull request #797)

Bugfix/generic methodology breakout

* fee schedule fix

* carveout+special case prompt changed

* fee schedule changes

* prompt changes and column order


Approved-by: Katon Minhas

* pytest fix

* remove prints

* Update mapping

* Update tests

* Update test

* Address PR review comments: add logging, fix return types, fix variable propagation, and add tests

- Add warning log in code_funcs.py try/except block for grouper code parsing failures
- Add warning log in hybrid_smart_chunking_funcs.py except block for JSON parsing failures
- Add return type annotation to lesser_of_distribution function
- Fix first_reimbursement_page variable propagation issue by returning updated value
- Add comprehensive tests for simplify_exhibit, chunk_by_exhibit, and lesser_of_distribution functions

* Merged in bugfix/prov_info_json (pull request #802)

Bugfix/prov info json to feature/1toN-Optimization

* prov_info_json added

* remove print statements


Approved-by: Katon Minhas


Approved-by: Siddhant Medar
2025-12-10 20:01:52 +00:00
Katon Minhas 83fcb104a2 Merged in feature/deprecate-haiku-3 (pull request #793)
Feature/deprecate haiku 3

* Update config - remove Haiku 3

* Update llm_utils

* Merged main into feature/deprecate-haiku-3


Approved-by: Siddhant Medar
2025-12-02 17:34:15 +00:00
Karan Desai 407b4bd55e optimized sig field query 2025-12-01 16:21:10 -06:00
VenkataKrishna Reddy Avula 2482adb465 Merged in optimization/tin_npi (pull request #790)
Optimization/tin npi

* updated signature page and added for tin  npi

* updated signature page

* removed print statements

* removed print statement

* updated test for extract signature page

* updated data type


Approved-by: Katon Minhas
2025-11-26 17:21:44 +00:00
Karan Desai 4334800fa3 Merged in feature/pc_code_optimization (pull request #788)
added stopwords json

* added stopwords json


Approved-by: Katon Minhas
2025-11-25 23:03:05 +00:00
Karan Desai e0e0ceee8b Merged in feature/available_signature_lines (pull request #786)
Available Signature Lines

* pp funcs for sig fields


Approved-by: Katon Minhas
2025-11-24 17:01:29 +00:00
Katon Minhas 89c4447c75 Merged in hotfix/clover-errors (pull request #785)
Hotfix/clover errors

* Update function name

* Update logging

* remove excess info

* remove breakout print

* Typehints

* Don't add lists

* remove prints


Approved-by: Siddhant Medar
Approved-by: Karan Desai
2025-11-21 22:38:49 +00:00
Katon Minhas 5e9de5021d Merged in hotfix/nltk-bug (pull request #784)
backup - tempfix

* backup - tempfix


Approved-by: Karan Desai
2025-11-21 19:21:56 +00:00
Mayank Aamseek 8ea69063b1 Merged in bugfix/code-list-format (pull request #781)
Bugfix/code list format

* replace | with comma in lists

* partial revert

* remove test changes

* Merged main into bugfix/code-list-format

* fix list format

* pipeline error fixed

* pipeline error fixed

* pipeline error fixed


Approved-by: Katon Minhas
2025-11-21 14:59:54 +00:00
VenkataKrishna Reddy Avula 18d893c40a Merged in bugfix/payer_name_provider_state (pull request #780)
Bugfix/payer name provider state to main

* updated provider state

* updated prompt

* Merged main into bugfix/payer_name_provider_state

* updated smart chunked field types

* added post processing for provider state

* field check added

* filter by field_type instead of retrieval question

* Merged main into bugfix/payer_name_provider_state


Approved-by: Katon Minhas
2025-11-19 19:02:45 +00:00
Karan Desai f8ceb39111 Merged in feature/signatures_present (pull request #779)
Feature/signatures present

* initial commit

* shifted from pp to one_to_one

* moved func in one_to_one_funcs

* Merged main into feature/signatures_present


Approved-by: Katon Minhas
2025-11-19 18:42:04 +00:00
Siddhant Medar 36a5ff938e Merged in feature/automated-qc-qa (pull request #778)
Feature/automated qc qa

* Moved automation_saas.py from alien_strings to qc_qa module

* Moved from alien_string

* Moved from alien_string

* clean up

* WIP: prepare saas automation script for integration

* format code and fix mypy issue

* minor fixes during e2e testing

* add tests

* format and fix mypy issues

* Merge remote-tracking branch 'origin/main' into feature/automated-qc-qa

* Remove print - replace with logging


Approved-by: Katon Minhas
2025-11-19 18:40:11 +00:00
Karan Desai 5887cf651e Merged in feature/pc (pull request #773)
Feature/pc

* file read update

* removed unused code

* replace pring with logging.info

* input args for docczy output

* input args for docczy output

* added json for loading mappings

* exception for bool keys

* exception for bool keys

* added init.py

* write to s3/local functionality

* write to s3/local functionality

* logging errors and main functionality fix

* pc functionality from main

* pc functionality from main

* function signature fix

* fixed path returns

* Updated names for varaibles; Modified termination date cleaning function

* Removed commented out function

* Renamed client column names to SAAS column names

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

* removed pc utils

* black formatting

* rename function

* rename func

* additional file removed


Approved-by: Katon Minhas
2025-11-17 14:16:39 +00:00
Praneel Panchigar ff400f4b1c Merged in feature/llm-utils-refactor (pull request #776)
Feature/llm utils refactor

* - Removed some temporary logging code
- Removed unused imports (uuid, datetime) from llm_utils.py
- Added cache token columns (cache_creation_tokens, cache_read_tokens) to CSV exports
- Added tracking for cache warming
- Updated usage_tracking.py to track cache tokens separately in data structure

All token tracking functionality remains intact.

* Split input tokens into fresh and cache in summary section

- Add total_fresh_input_tokens and total_cache_tokens to GLOBAL_USAGE
- Update summary CSV to include split token columns for better tractability
- Add averages for fresh_input_tokens and cache_tokens
- Maintain total_input_tokens = fresh_input_tokens + cache_tokens relationship
- All calculations verified and match per-file totals correctly

* upload files functionality

* Add comprehensive unit tests for usage_tracking module

- Implement Phase 1-4 tests covering all 10 functions in usage_tracking.py
- Add 98 test cases with parametrized tests for comprehensive coverage
- Fix extract_usage_from_response to handle None input gracefully
- Add python-dotenv dependency to pyproject.toml
- Tests cover: core functions, data access, export functions, and utilities
- All tests passing (98/98)

* Add S3 upload tests for main.py and fix f-string syntax error

- Add tests/test_investment_main_s3.py with 3 test cases:
  * test_main_writes_final_and_error_to_s3: validates both final and error DataFrames uploaded when processing has errors
  * test_main_writes_only_final_when_no_errors: validates only final DataFrame uploaded when all files succeed
  * test_main_writes_usage_when_present: validates usage tracking files uploaded when usage data exists
- Tests use monkeypatching and module stubs to isolate S3 write logic without external dependencies
- Fix syntax error in src/codes/code_funcs.py: nested f-string quotes (level_dict['level_suffix'])
- All tests passing

* Add comprehensive test for usage_tracking.get_usage_dataframes S3 uploads

- Add test_usage_dataframes_written_to_s3 to validate per_file_usage_df and batch_summary_df
- Test verifies both dataframes from usage_tracking.get_usage_dataframes() are written to S3
- Validates 'usage' suffix writes per_file_usage_df with correct schema (file_name, tokens, cost)
- Validates 'usage_summary' suffix writes batch_summary_df with correct schema (totals, averages, region_mode)
- Uses pd.testing.assert_frame_equal to ensure exact dataframes are uploaded
- Fix module caching issue between tests by clearing sys.modules cache
- All 4 tests passing

* Add cleanup fixture to prevent test pollution

- Add autouse pytest fixture to clean up stubbed modules after each test
- Remove manual cache clearing from individual tests (now handled by fixture)
- Prevents our module stubs from affecting other test files in CI/CD pipeline
- Fixes Bitbucket pipeline failures where other tests couldn't find llm_utils attributes

* Refactor tests: add comprehensive io_utils coverage; disable usage_tracking suite

- Added 22 focused tests for write_local and write_s3 plus existing IO behaviors
- Introduced FakeS3Client to avoid boto3 network/credential dependency
- Added preserve_config fixture (no monkeypatch) to isolate config side effects
- Marked test_usage_tracking.py skipped per new consolidation approach
- Verified 26 tests (io_utils + investment_main) all pass locally without AWS exceptions

* Fix S3_CLIENT mocking: use mocker.patch instead of direct assignment

- Changed preserve_config fixture to NOT save/restore S3_CLIENT
- Updated all 5 write_s3 tests to use mocker.patch('src.config.S3_CLIENT', fake)
- This prevents pollution of config.S3_CLIENT across test modules
- Fixes NoCredentialsError in other tests that were importing config after our tests set FakeS3Client
- All 22 io_utils tests pass + 4 investment_main_s3 tests pass
- test_llm_utils::test_invoke_claude_local_mode now passes

* Add tests for write_s3 function

* Resolve merge conflict: keep mocker-based write_s3 tests

* Remove rogue skip mark from test_usage_tracking.py

The skip mark was incorrectly added by remote branch claiming tests were
migrated to io_utils. However, test_io_utils.py only tests io_utils functions
(read/write operations), not usage_tracking functions.

Restore the comprehensive usage_tracking tests from commit 26a556f0 which
includes 98 test cases covering all 10 functions in usage_tracking.py.

* Fix test pollution: add config cleanup fixture and restore RUN_MODE

- Add autouse fixture in test_io_utils.py to restore config values after each test
- Fix test_llm_utils.py to restore RUN_MODE after test_invoke_claude_local_mode
- Prevents config patches from leaking into subsequent tests causing NoCredentialsError

* Remove redundant test_investment_main_s3.py

- File was testing same write_s3 functionality already covered in test_io_utils.py
- Was causing module pollution by stubbing src.utils.llm_utils
- Caused test failures in other test files due to module cache issues
- Integration testing was minimal and mocked write_s3 anyway

* Phase 1: Remove unused code and align cost constants

- Remove count_tokens() function (unused, replaced by exact API counts)
- Remove unused cost constants from invoke_claude() and invoke_claude_with_image_array()
- Remove unused math import
- Update usage_tracking.py to match correct cost constants from llm_utils.py:
  - Corrected Haiku cache_read: 0.000025 -> 0.00003
  - Implemented correct cache creation cost calculation:
    * Sonnet models: 25% higher than input (0.00375 vs 0.003)
    * Haiku: 20% higher than input (0.0003 vs 0.00025)
- Remove test_count_tokens() test
- Update test_track_usage_single_call() to account for corrected cache creation costs

All 437 tests passing. Token counts verified against previous runs.

* Phase 2: Remove redundant update_stats() tracking

- Remove all update_stats() calls from EC2 mode (3 locations)
- Remove update_stats() function definition
- Remove estimated token counting (tokens_sent, tokens_received)
- Remove elapsed_time calculations
- Remove unused start_time assignments
- Remove test_update_stats() test case
- Clean up setUp() method in test_llm_utils.py
- Update docstrings to reflect usage_tracking.py as source of truth

All token tracking now uses exact API counts via usage_tracking.track_usage().
All 436 tests passing.

* Merge main into feature/llm-utils-refactor

Resolved merge conflicts:
- llm_utils.py: Kept refactored code (removed legacy update_stats, math import)
- usage_tracking.py: Kept corrected cost constants and cache creation pricing logic
- io_utils.py: Merged main's new 'dtc' and 'dtc_summary' output types
- test_usage_tracking.py: Kept corrected test values for cache_read and cache_creation costs

All conflicts resolved while preserving Phase 1 & 2 refactoring work.

* Fix merge conflict artifact in test_usage_tracking.py

Removed leftover merge conflict marker (<<<<<<< HEAD) that was missed
during merge resolution. The test now correctly calculates cache creation
costs for Sonnet (25% higher) and Haiku (20% higher) models.

* Phase 3: Add thread safety and enhance cache key generation

Step 3.1: Add thread safety to cache operations
- Added _cache_lock = threading.Lock() at module level
- Wrapped all cache operations (get, set, move_to_end, popitem) with lock
- All 4 cache operation locations now thread-safe:
  * Cache check/retrieval in invoke_claude()
  * Cache storage in invoke_claude()
  * Cache check/retrieval in invoke_claude_with_image_array()
  * Cache storage in invoke_claude_with_image_array()

Step 3.2: Enhance cache key generation
- Updated get_cache_key() to include instruction, max_tokens, and cache flag
- Updated get_cache_key_with_image_array() with same enhancements
- Cache keys now differentiate based on all relevant parameters
- Backward compatible (all new parameters are optional)

Step 3.3: Update call sites
- Updated invoke_claude() to pass instruction, max_tokens, cache to get_cache_key()
- Updated invoke_claude_with_image_array() to pass max_tokens

All 412 tests passing. Cache operations are now thread-saf…
* Phase 4: Add comprehensive tests for cache operations and token tracking

Step 4.1: Remove legacy test cases
- Already completed in Phase 2 (test_update_stats, test_count_tokens removed)
- setUp() cleaned up (no MODEL_STATS/GLOBAL_STATS setup needed)

Step 4.2: Add tests for thread-safe cache operations
- test_cache_thread_safety_concurrent_reads: 10 concurrent cache reads
- test_cache_thread_safety_concurrent_writes: 10 concurrent cache writes
- test_cache_thread_safety_mixed_operations: mixed read/write operations

Step 4.3: Add tests for enhanced cache key generation
- test_get_cache_key_basic: backward compatibility test
- test_get_cache_key_with_instruction: instruction parameter
- test_get_cache_key_with_max_tokens: max_tokens parameter
- test_get_cache_key_with_cache_flag: cache flag
- test_get_cache_key_all_parameters: all parameters together
- test_get_cache_key_with_image_array: image array variant
- test_invoke_claude_uses_enhanced_cache_key: integration test

Step 4.4: Verify token tracking uses e…
* Phase 5: Replace legacy CSV export with usage_tracking.py

Step 5.1: Replace write_stats_to_csv() implementation
- Updated write_stats_to_csv() to use usage_tracking.get_usage_dataframes() instead of config.MODEL_STATS/GLOBAL_STATS
- Added import for usage_tracking module
- Function now reads from usage_tracking.py as the single source of truth

Step 5.2: Add optional run_id and timestamp parameters
- Added optional run_id parameter (defaults to config.BATCH_ID)
- Added optional timestamp parameter (defaults to current timestamp)
- Updated upload_tracking_logs() to pass batch_id and run_timestamp

Step 5.3: Transform usage_tracking format to legacy CSV format
- Aggregates per-file, per-model data to per-file data
- Maps model names to Claude 2/3/3.5 request counts
- Calculates tokens_sent (fresh input tokens) and tokens_received (output tokens)
- Maintains backward compatibility with legacy CSV structure
- Handles empty data gracefully (writes headers-only CSV)

Step 5.4: Verify call sites work with updated f…
* refactor(llm_utils): extract helper functions and reduce code duplication

- Add private helper functions: _track_usage_from_response(), _build_claude_3_request_body(), _store_in_cache()
- Simplify routing logic using model sets (_CLAUDE_2_MODELS, _CLAUDE_3_AND_UP_MODELS)
- Replace 8 instances of usage tracking pattern with single function call
- Replace 3 instances of request body building with helper function
- Replace 2 instances of cache storage with helper function
- Add Claude 4.5 Sonnet to cache support list
- Reduce file size from 1,004 to 860 lines (14.3% reduction, 144 lines removed)
- All tests passing (422 tests)
- Maintains backward compatibility and functionality

* Re-support Claude 3 Haiku and add comprehensive tests for new helper functions

- Re-added Claude 3 Haiku to supported models (removed from deprecated patterns)
- Updated model validation to include Haiku in supported models list
- Added comprehensive test coverage for new helper functions:
  - _validate_model_support() - 5 tests covering deprecation, support, and context
  - _supports_prompt_cache() - 2 tests for cache support detection
  - _build_claude_3_request_body() - 4 tests for request body building with/without cache
- Updated error messages to reflect Claude 3+ models (Haiku, Sonnet 3.5/3.7/4/4.5)
- All 23 tests passing

* Merged main into feature/llm-utils-refactor

* Merged main into feature/llm-utils-refactor


Approved-by: Siddhant Medar
Approved-by: Katon Minhas
2025-11-17 14:15:46 +00:00
VenkataKrishna Reddy Avula 2ac6d58f08 Merged in bugfix/effective_dt (pull request #777)
Bugfix/effective dt to main

* removed secondary instruction

* paased right field to full context

* added secondary rule

* remove print statements


Approved-by: Katon Minhas
2025-11-14 16:00:34 +00:00
VenkataKrishna Reddy Avula ca5a0619ba Merged in bugfix/tin_exception (pull request #775)
bugfix/tin_exception to main

* added additional TIN instruction


Approved-by: Katon Minhas
2025-11-12 15:12:30 +00:00