Commit Graph

123 Commits

Author SHA1 Message Date
Mayank Aamseek 7b05d6bfe2 Merged in bugfix/rate-escalator-name (pull request #838)
field name updated

* field name updated


Approved-by: Katon Minhas
2026-01-21 16:05:26 +00:00
Faizan Mohiuddin 8c9060e425 Merged in feature/multithreading (pull request #828)
Feature/multithreading

* fixes

* Merge main into feature/multithreading

Resolved conflicts:
- Kept timing instrumentation in file_processing.py
- Kept new 3-step Exhibit-based approach for one-to-n processing
- Maintained parallelization improvements (20 workers)

Changes include:
- Timing utils integration for performance monitoring
- Increased max_workers from 5 to 20 across all components
- Parallelized code_breakout and grouper_breakout
- Fixed tin_npi_funcs function call parameters

* Fix max_workers error for empty documents

- Add check to skip parallel processing when no pages exist
- Use min(len(all_page_tasks), 20) to prevent max_workers=0
- Handles edge case of documents with no exhibits or pages

* Fix max_workers=0 errors in one_to_n_funcs

- Add checks before all ThreadPoolExecutor creations
- Prevents errors when processing empty lists:
  - carveout_and_special_case
  - breakout
  - special_case_breakout
  - filter_services_without_reimbursements
  - run_lob_relationship
- Ensures executor only created when there are items to process

* Reduce code processing parallelism to prevent API throttling

Lower max_workers from 20 to 10 for code_breakout and grouper_breakout
to prevent overwhelming Bedrock API with concurrent requests

* fixed

* Merged main into feature/multithreading

* Move documentation into folder

* Fix logging statements

* Merge branch 'main' into feature/multithreading

* Refactor for clarity

* Update previous exhibit passing logic

* properly simplify exhibits

* Merged main into feature/multithreading

* update conditional for None

* exhibit multithreading changed

* exhibit multithreading changed

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

* synced with main

* Parallelize dynamic assignment, refactor HSC field worker, add timing/exhibit unit tests, tidy imports/ignore helpers

* analyze_regression.py edited online with Bitbucket
* count_pages.py edited online with Bitbucket
* compare_regressed_with_baseline.py edited online with Bitbucket
* simple_testbed_compare.py edited online with Bitbucket
* run_testbed_metrics_regressed.py edited online with Bitbucket

Approved-by: Katon Minhas
2026-01-09 20:18:01 +00:00
VenkataKrishna Reddy Avula d97a31aa5b Merged in optimization/prov_info (pull request #829)
optimization_prov_info to main

* removed on signature page field which is unnecessary


Approved-by: Katon Minhas
2026-01-07 15:19:35 +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
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
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
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
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
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
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
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
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
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
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
Siddhant Medar f7a9d80162 Merged in feature/dtc-clean (pull request #767)
Feature/dtc clean

* dtc v1 initial commit

* second layer of prompt

* Added MAX_PAGES_TO_CHECK and page looping to get answer from llm

* Edited contract_type prompt to get cleaner output with no additional text

* Updated document_type_classification prompt

* Added non-contract type classifcation

* Added dtc_v1_test.py for testing only

* Updated prompt

* Updated prompt

* at scale changes

* add save feature for individual file output

* update dockerfile

* clean dtc to prepare for merge

* clean up dtc script

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

* reafactor code

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


Approved-by: Katon Minhas
2025-11-10 20:18:33 +00:00
Praneel Panchigar 7056c1c687 Merged in feature/automated-cost-logging-csv (pull request #768)
Feature/automated cost logging csv

* feat: Add usage and cost tracking with CSV export

- Add usage_tracking.py module for thread-safe token and cost tracking
- Extract actual tokens from Bedrock API responses (replaces word count estimation)
- Integrate usage tracking into llm_utils.py for all LLM invocations
- Add CSV export functionality (per-file/per-model and batch summary)
- Integrate CSV export into main.py for local runs
- Update .gitignore to exclude PRD

Phase 1: Data collection and local CSV export implemented
- Tracks all LLM calls including utility functions (date_fix, derive_term_date)
- Calculates costs per model using centralized cost constants
- Generates two CSV files: USAGE.csv and USAGE-SUMMARY.csv
- Exports to same directory as final results when write_to_s3=False

* - 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

* Merged main into feature/automated-cost-logging-csv


Approved-by: Karan Desai
Approved-by: Katon Minhas
2025-11-10 19:29:45 +00:00
Siddhant Medar 55643b5a04 Merged in feature/saas-hybrid-smart-chunking (pull request #760)
Feature/saas hybrid smart chunking

* WIP: Initial work on SaaS HSC integration

* clean up hsc funcs script

* fix merging dict issue

* Merge remote-tracking branch 'origin/main' into feature/saas-hybrid-smart-chunking

* added changes as per feedback comments

* add tests and remove old smart chunking funcs

* add more tests


Approved-by: Katon Minhas
2025-11-05 15:20:33 +00:00
Katon Minhas 3eed26b558 Merged in bugfix/ut-errors (pull request #756)
Bugfix/ut errors

* Update universal_json_load and unit tests

* Update tests

* Fix unit tests

* remove test

* remove imports

* Update function

* update pd Series is_empty

* Update reimbursement check

* added some test cases

* Merged main into bugfix/ut-errors

* Merged main into bugfix/ut-errors

* remove import

* Merged main into bugfix/ut-errors


Approved-by: Karan Desai
2025-11-03 20:45:58 +00:00
Katon Minhas 2b9bf50c2e Merged in feature/effective-dt (pull request #752)
Feature/effective dt

* move prompt_smart_chunked to prompt_calls.py

* refactor pass_smart_chunked_to_full_context

* Mypy fix

* Update field to EFFECTIVE_DT

* move to prompt_calls

* Update vision funcs

* Restructure prompt-based date derivation

* E2E passed

* Remove test

* Merge branch 'main' into feature/effective-dt

* remove deprecated postprocessing_func

* Docstrings

* refactor - send global lesser of to prompt_calls.py

* remove deprecated function

* more docstrings

* Merged main into feature/effective-dt

* Merged main into feature/effective-dt

* added base field for aarete derived effective date


Approved-by: VenkataKrishna Reddy Avula
2025-10-30 15:28:39 +00:00
Mayank Aamseek 3027d8e1d5 Merged in bugfix/mi-reimb-terms (pull request #740)
Bugfix/mi reimb terms

* test changes

* logging added

* Merge branch 'main' into bugfix/generic-reimb-terms

* parsing fixes

* fix missing reimbursements

* make service terms unique by adding additional context

* Merge branch 'main' into bugfix/mi-reimb-terms

* remomoving test changes

* remomoving test changes

* remomoving test changes

* test case for universal_json_load added


Approved-by: Katon Minhas
2025-10-22 15:21:43 +00:00
VenkataKrishna Reddy Avula 775d7eb1fb Merged in bugfix/code_breakout_rev (pull request #739)
bugfix/code_breakout_rev to main

* added methodology to code explicit

* pipeline fixes

* Merged main into bugfix/code_breakout_rev

* Remove prints


Approved-by: Katon Minhas
2025-10-16 21:49:33 +00:00
Katon Minhas a7090c8327 Merged in bugfix/ut-issues (pull request #733)
Bugfix/ut issues

* Update exhibit linking

* prompt_calls refactor

* remove test

* Add Healthy Kids Program

* Move Healthy Kids to UT specifically

* Remove header check from Dynamic process

* Merged main into bugfix/ut-issues

* prep for merge

* remove deprecated tests

* Merged main into bugfix/ut-issues

* Merged main into bugfix/ut-issues


Approved-by: Faizan Mohiuddin
2025-10-10 20:47:13 +00:00
VenkataKrishna Reddy Avula 8ec2561a68 Merged in bugfix/special-cases (pull request #716)
Bugfix/special cases to Main

* prompt update

* Merge branch 'main' into bugfix/json_and_unit_of_measure

* minor bugfix

* minor bugfix

* prompt update for outlier rate

* added outlier testing jupyter notebook

* Remove special case from any empty

* updated outlier breakout prompt

* Merged main into bugfix/special-cases

* reimb_method minor fix

* Merged main into bugfix/special-cases

* bugfix field to add dynamic funcs

* merged with main

* latest outlier changes

* Merged main into bugfix/special-cases

* added table guidelines for special case primary

* updated special case primary prompt

* Merged main into bugfix/special-cases

* updated special case primary table handling

* merged main into bugfix special cases

* Merged main into bugfix/special-cases

* Remove test notebooks from tracking

* trying out pipeline fix

* reverted chnages

* pipeline fix


Approved-by: Katon Minhas
2025-10-10 16:41:23 +00:00
Katon Minhas a910f27cd2 Merged in bugfix/mi-dynamic (pull request #726)
Bugfix/mi dynamic

* Refactor - split out one_to_n_cleaning

* Rework postprocess

* Update postprocessing - fill dynamic values if there is only 1 non-empty value

* Update to use string_utils

* Group by AARETE_DERIVED_LOB as well

* Update crosswalk mapping to handle | lists

* Update constants - run with MI flag


Approved-by: Siddhant Medar
2025-10-07 15:06:10 +00:00
Mayank Aamseek bb34b0292f Merged in bugfix/methodology-breakout (pull request #723)
Bugfix/methodology breakout

* moved carveout after methodology breakout

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

* fixed unit_of_measure issues

* carveout_cd fixes

* pipeline error fix

* Merged main into bugfix/methodology-breakout


Approved-by: Katon Minhas
2025-10-03 18:51:30 +00:00
Alex Galarce 674add9a3e Merged in feature/black-and-isort (pull request #717)
Feature/black and isort

* black and isort constants

* black and isort codes

* black and isort crosswalks

* black and isort investment

* black and isort prompts

* isort testbed

* isort tracking

* black and isort utils

* poetry and black tests


Approved-by: Katon Minhas
2025-09-30 20:56:02 +00:00
Katon Minhas b788ffc352 Merged in bugfix/dynamic (pull request #714)
Bugfix/dynamic

* Update MA-SNP

* Update LOB relationship prompt

* Update lob-relationship prompt

* Remove test

* Remove print

* revert lob relatinoship function

* Merged main into bugfix/dynamic

* Update prompt_call


Approved-by: Alex Galarce
2025-09-29 16:13:01 +00:00
Alex Galarce 0562b90646 Merged in feature/io-utils-docs (pull request #713)
io_utils documentation

* add docstring to read_local function and handle file read errors gracefully by returning None on failure

* update read_local function to support .xlsx files and improve error handling

* add docstring to read_s3 function to clarify its purpose and return value

* refactor read_s3 and read_s3_csv functions to improve error handling and add type hints

* improve error handling in read_s3_csv function for CSV file parsing

* enhance read_input function with error handling and detailed docstring

* Add TODOs for read_input_csv and filter_already_processed functions; add type hints and docstring for remove_txt_extension

* enhance write_local function documentation; make docstrings more consistent when there is a "notes" section

* enhance write_local and write_s3 functions; improve documentation, add error output type handling, and ensure consistent CSV writing options

* refactor test_io_utils.py; reorganize imports and enhance read_input_local test with additional mock for file existence


Approved-by: Katon Minhas
2025-09-26 20:47:55 +00:00
Katon Minhas 1050287397 Merged in refactor/one-to-n (pull request #702)
Refactor/one to n

* remove print

* Update logging for fsbreakout and grouper breakout

* Additional type hints

* updated special case primary

* Remove deprecated special case check

* OUTLIER_TERMS-->OUTLIER_TERM standardization

* Applied suggestion to fieldExtraction/src/prompts/investment_prompts.json
* update unit test

* Update Carveout IND and Default IND logic

* Split out exhibit-level lesser

* Bugfix

* update lesser of exhibit prompt

* Bugfix

* exhibit lesser of varible name bugfix

* Update exhibit lesser of passing

* Update Exhibit-level prompt template

* Shorten full_context prompt length if the questions are long

* Special case assignment index

* Resolve unit tests

* updated UC IND prompt

* Remove print

* update one-to-n unit test

* added dot based date example

* updated date fix prompt

* Merged in bugfix/json_error_and_unit_of_measure (pull request #708)

Bugfix/json error and unit of measure

* json parser fixes and prompt changes

* universal json load fixed

* json error fixed

* json error fixed 2

* Merged refactor/one-to-n into bugfix/json_error_and_unit_of_measure


Approved-by: Katon Minhas


Approved-by: Alex Galarce
2025-09-24 15:56:27 +00:00
Mayank Aamseek 5d196843da Merged in bugfix/trigger_cap_fixes (pull request #704)
Bugfix/trigger cap fixes

* stoploss prompt added again

* stoploss prompt added again

* stoploss prompt updated

* reverted back to one stage for trigger cap cases

* Merge branch 'main' into bugfix/trigger_cap_fixes

* pipeline error fixed

* incorrect discount special case fixed


Approved-by: Alex Galarce
2025-09-11 13:31:03 +00:00
Alex Galarce 306034820c Merged in feature/tin-enhancements (pull request #697)
Feature/tin enhancements

* Add OCR-correctable TIN patterns and substitution mapping

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

* Refactor OCR-correctable TIN pattern and enhance documentation for clarity

* Enhance get_all_matches function with type hints and improve documentation; add get_all_matches_with_ocr for OCR-correctable matches

* Add attempt_ocr_correction function for TIN OCR error handling and validation

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

* Integrate OCR correction for TIN extraction in run_provider_info_fields; log corrections for monitoring

* Refactor OCR-correctable patterns in regex_patterns.py; add NPI_OCR_PATTERN and enhance documentation for clarity

* Enhance OCR correction in attempt_ocr_correction to support both TIN and NPI; update validation logic for identifier lengths

* Integrate NPI OCR correction in run_provider_info_fields; log corrections for monitoring

* Enhance logging in run_provider_info_fields to summarize TIN and NPI extraction quality; include counts of exact and OCR-corrected identifiers

* Add unit and integration tests for OCR correction

* isort

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

* Merged main into feature/tin-enhancements


Approved-by: Katon Minhas
2025-09-05 15:15:39 +00:00
Katon Minhas edc48ec3c8 Merged in feature/filename-tin (pull request #693)
Add FILENAME_TIN

* Add FILENAME_TIN


Approved-by: Alex Galarce
2025-09-03 21:03:02 +00:00
Alex Galarce 39a07f63c9 Merged in bugfix/dynamic-primary-and-pyproject (pull request #683)
pyproject requirements, prep for logging fixes

* remove chroma

* update project name to "doczy-field-extraction" in pyproject.toml

* update lock file

* replace print statements with logging for better traceability in process_file function

* replace print statements with logging for improved error tracking and information logging

* replace print statements with logging for improved error handling and traceability

* replace print statements with logging for improved error handling in llm_utils and string_utils

* remove unused table_utils module; supplanted by table_funcs and unreferenced

* replace capsys with caplog in test_invalid_input_type for improved logging of invalid input


Approved-by: Katon Minhas
2025-08-27 16:37:48 +00:00
Alex Galarce 7ca723037a Merged in bugfix/too-many-files (pull request #677)
Bugfix/too many files

* Implement caching for field data loading to optimize performance and prevent "too many open files" errors

* Documentation

* isort

* fix breaking test to clear cache and ensure mock data is actually being used

* Merge remote-tracking branch 'origin/main' into bugfix/too-many-files

* Implement thread-safe vectorstore caching and cleanup in field context extraction

* Refactor imports in smart_chunking_funcs.py for clarity and organization

* Update module docstring in smart_chunking_funcs.py

* Fix mypy errors

* Fix variable naming and error handling in run_smart_chunked_fields function

* Reorganize imports and enhance module documentation for clarity

* Add logging for error handling in field_context function


Approved-by: Katon Minhas
2025-08-25 14:43:36 +00:00
Alex Galarce 04aa447831 Merged in feature/remove-costlog (pull request #675)
Remove cost logging functionality and related tests

* Remove cost logging functionality and related tests

* Remove cost log entry test and related CSV writer mock

* Merged main into feature/remove-costlog


Approved-by: Katon Minhas
2025-08-21 17:45:18 +00:00
Alex Galarce b2a0dc4b60 Merged in bugfix/uom (pull request #661)
Bugfix/uom

* Add "Per Procedure" to valid unit of measure list

* Enhance unit of measure prompt for clarity and specificity in reimbursement methodologies

* Refine unit of measure prompt to ensure defaulting to 'Per Unit' regardless of procedure codes for flat rate methodologies

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

* Merged main into bugfix/uom

* Enhance logic for setting UNIT_OF_MEASURE to 'Per Unit' for Flat Rate reimbursement, handling all edge cases including NaN and empty strings.

* Enhance is_empty function to handle additional empty value cases for pd.Series and strings

* Enhance test cases for is_empty function to cover additional whitespace and null-like values

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

* Enhance type checking for is_empty function with overloads for str, list, and pd.Series

* Overload fix

* Merged main into bugfix/uom


Approved-by: Katon Minhas
2025-08-13 14:51:46 +00:00
Katon Minhas 5d49d4c44b Merged in bugfix/dynamic-primary-issues (pull request #660)
Bugfix/dynamic primary issues

* Update get prompt for direct valid value setting

* prep for merge

* Merge branch 'main' into bugfix/dynamic-primary-issues

* Remove test

* Update unit tests with real constants object

* Ready for review

* direct replace {valid_values}


Approved-by: Alex Galarce
2025-08-12 17:57:09 +00:00
Alex Galarce e56d629b1a Merged in bugfix/carveout-cd (pull request #659)
Bugfix/carveout cd

* Update field class - change Null criteria

* Add default

* Enhance documentation for get_special_cases function with detailed processing flow and architecture decisions

* Enhance get_special_cases and run_trigger_cap_breakout functions with detailed docstrings for clarity on processing methodologies

* Update constants passing

* Fix questions

* Update fs and mb questions"

* pass constanst correctly for dynamic

* Merge branch 'feature/trigger_cap_breakout' into bugfix/dynamic-primary-issues

* update constants

* only add questions if present

* ensure answer is a valid special_case

* Set carveout indicator for two-stage process; prepped set_carveout_indicators and run_methodology_breakout_with_carveout_indicators to replace process_carveout_or_special_case

* Fix unit tests

* Remove test file

* Refactor carveout handling: streamline indicator setting and enhance methodology breakout integration

* Refactor get_carveout_and_special_fields: ensure methodology breakout runs regardless of carveout/special case configs; streamline handling of indicators and questions

* Remove deprecated process_carveout_or_special_case function

* Merge remote-tracking branch 'origin/bugfix/dynamic-primary-issues' into bugfix/carveout-cd

* Add tests for carveout indicator setting and special cases processing

* Add tests for unrecognized carveout handling and legacy stop-loss processing

* Refactor special case configurations: streamline STOP_LOSS handling and update test cases for methodology prompt templates

* Refactor special case handling: improve argument formatting in get_special_cases and run_methodology_breakout_with_carveout_indicators functions

* Add test for run_methodology_breakout_with_carveout_indicators function

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


Approved-by: Katon Minhas
2025-08-12 16:40:33 +00:00
Katon Minhas 46be909642 Merged in bugfix/dynamic-primary-issues (pull request #657)
Bugfix/dynamic primary issues

* Refactor TRIGGER_CAP special case configuration to utilize only trigger cap questions for two-stage processing

* Refactor get_special_cases to improve handling of N/A responses and merge methodology results with special case results

* Fix field type in get_special_cases for fee schedule breakout configuration

* Create fieldset.py - refactor

* Fix placeholders

* string concatenate new questions

* Update trigger cap questions output format

* Update TRIGGER_CAP_THRESHOLD_AMT prompt for clarity and specificity in reimbursement methodology

* Update constants class

* Update Field class

* Resolve constants passing

* Update field class - change Null criteria

* Add default

* Enhance documentation for get_special_cases function with detailed processing flow and architecture decisions

* Enhance get_special_cases and run_trigger_cap_breakout functions with detailed docstrings for clarity on processing methodologies

* Update constants passing

* Fix questions

* Update fs and mb questions"

* pass constanst correctly for dynamic

* Merge branch 'feature/trigger_cap_breakout' into bugfix/dynamic-primary-issues

* update constants

* only add questions if present

* ensure answer is a valid special_case

* Fix unit tests

* Remove test file


Approved-by: Alex Galarce
2025-08-11 20:47:52 +00:00
Katon Minhas 73e43f1c65 Merged in refactor/update-claude-models (pull request #650)
Refactor/update claude models

* Revert prompts

* Remove qa_qc tests

* Remove valid lines

* model aliasing

* Haiku alias

* remove erroneous import


Approved-by: Alex Galarce
2025-08-06 15:06:49 +00:00
Katon Minhas c4e519894b Merged in refactor/one-time-io (pull request #648)
Refactor/one time io

* Delete client work

* Streamline imports

* Fix list class

* Update tests

* Clear code funcs test

* Fix unit tests

* Single read code funcs

* Single-read model

* Single-load embeddings

* Successful E2E test

* update unit tests

* Update importsg

* Reload poetry.lock

* remove old exhibit header function

* Remove aarete_derived generic function

* remove align and format tables

* Remove strings to dict

* references

* Clear code

* Move preprocessing_funcs

* remove keywords

* refactor postprocessing_funcs

* Pass unit test - remove qa_qc directory

* Black and isort

* remove print


Approved-by: Alex Galarce
2025-08-05 20:46:19 +00:00
Katon Minhas 1c15489370 Merged in feature/rename-proc-cd (pull request #645)
rename columns function

* rename columns function

* update columns


Approved-by: Alex Galarce
2025-08-04 16:10:26 +00:00
Katon Minhas c2d5db19d4 Merged in feature/doczy-codes (pull request #619)
Feature/doczy codes

* Ignore service and procedure generic terms

* UPdate PT/OT/ST codes

* Standardize stop-loss

* UPdate for multiple identical values

* Modify code funcs

* Run highest match Implicit Level first

* Fix implicit code bug

* Add PT individually to special case

* change revenue code conditions

* Merge branch 'main' into feature/doczy-codes

* Merged main into feature/doczy-codes

* Update main

* Relocate create_code_embeddings back to scripts

* Remove investment code_funcs (use codes.code_funcs now)

* Add docstrings

* stop-loss

* Update unit tests

* Remove test

* Remove reimb_dates

* fix dtypes

* Remove prints

* update prompt

* Update code breakout unit test

* Merge branch 'main' into feature/doczy-codes

* Merge branch 'main' into feature/doczy-codes


Approved-by: Alex Galarce
2025-08-01 22:36:01 +00:00
VenkataKrishna Reddy Avula 84a09002fa Merged in feature/contract_level_rate_escalator (pull request #644)
Feature/contract level rate escalator to Main

* added rate escalator fields to dynamic one to one fields

* added rate escalator breakout

* update prompts and fixed errors

* fixed pipeline error

* removed exhibit level rate escalator

* removed rate escalator parameter from reimb level fxn

* removed print statement

* updated contract level rate escalator

* Merged main into feature/contract_level_rate_escalator

* Clean up

* Cleanup

* in place combine fields


Approved-by: Alex Galarce
Approved-by: Katon Minhas
2025-08-01 22:14:00 +00:00
Alex Galarce 1c30c12672 Merged in bugfix/dedupe-prov-info-in-columns (pull request #625)
Implement deduplication of provider columns in DataFrame and add corresponding unit tests

* Implement deduplication of provider columns in DataFrame and add corresponding unit tests


Approved-by: Katon Minhas
2025-07-18 21:59:30 +00:00
VenkataKrishna Reddy Avula 0df334905e Merged in bugfix/rate_escalator_reimbursements (pull request #616)
Bugfix/rate escalator reimbursements to Main

* rate_escalator_terms added

* added RE statement

* fixed pattern error

* fixed enhanced reimb term

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


Approved-by: Alex Galarce
2025-07-17 22:05:33 +00:00
Alex Galarce c094fa35b0 Merged in feature/further-phase-1-and-2-fixes (pull request #622)
Table Continuation Fix

* Add EXHIBIT_HEADER_MARKERS for improved document header recognition in table handling

* Refactor EXHIBIT_HEADER_MARKERS definition for improved clarity and organization

* remove unused page span tracking code; add unit tests for new functionality

* remove debugging logs from combine_continuous_tables function

* Refactor logging setup and update test file configuration in investment field testing notebook

* Merge remote-tracking branch 'origin/main' into feature/further-phase-1-and-2-fixes


Approved-by: Katon Minhas
2025-07-17 19:39:33 +00:00
Alex Galarce 2680259f22 Merged in bugfix/samaritan-missing-rows (pull request #608)
Exhibit-level Lesser Of

* Enhance exception language clarity in investment prompts

* Roll back exception language

* initial try at exhibit_lesser_of

* simplify `create_exhibit_lesser_of_row`

* Refine prompt for extracting 'lesser of' and 'not to exceed' constraints in exhibit

* Remove unused `get_service_breakout` function; it was unreferenced

* run exhibit-level answers FIRST, apply exhibit lesser-of WITHIN reimbursement_level

* Refine prompt for extracting 'lesser of' and 'not to exceed' constraints to clarify expected output and handling of multiple constraints.

* Merge remote-tracking branch 'origin/main' into bugfix/samaritan-missing-rows

* add exhibit_lesser_of="N/A" to tests

* Add exhibit_lesser_of parameter to reimbursement_level calls in tests

* restore dynamic answer retrieval for primary, reimbursement info, and code fields

* Merge remote-tracking branch 'origin/main' into bugfix/samaritan-missing-rows

* "fill in the blank" prompt attempt

* Merge remote-tracking branch 'origin/main' into bugfix/samaritan-missing-rows

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

* Merge remote-tracking branch 'origin/feature/sonnet-4' into bugfix/samaritan-missing-rows

* Merge remote-tracking branch 'origin/main' into bugfix/samaritan-missing-rows

* Remove carveout patterns from has_explicit_lesser_of_carveout function

* Add deduplicate_methodology_breakout function to remove duplicate reimbursement methodologies

* Add deduplication of methodology breakout rows in postprocess function

* Enhance create_exhibit_lesser_of_row to avoid redundancy with substring checks

* Change log level from info to debug for exhibit constraint check in create_exhibit_lesser_of_row

* Remove deduplication of methodology breakout rows from postprocess function (we handle it upstream)

* Merged main into bugfix/samaritan-missing-rows


Approved-by: Katon Minhas
2025-07-14 22:04:41 +00:00
Katon Minhas 45db295d17 Merged in hotfix/prov-info-json (pull request #607)
derive IS_GROUP

* derive IS_GROUP

* Update unit tests


Approved-by: Alex Galarce
2025-07-09 21:01:15 +00:00