Skip to main content

QA

Overview

This document describes the QA test suite for the Eli Lilly pricing DAG. The tests validate the pricing service rates table to ensure data integrity and correctness across services, providers, and payers.

Test Structure

The test suite is organized into four main modules:

  • service_tests.py - Validates service-level data (episodes, SSPs, billing codes, etc.)
  • provider_tests.py - Validates provider-level data and constraints
  • payer_tests.py - Validates payer and network data
  • interaction_tests.py - Validates relationships between services, providers, and payers

Test Data Source

All tests query the rates table defined by:

  • Schema: Configured via schema parameter (default: tq_dev.internal_dev_csong_consumer_pricing_service)
  • Table: pricing_service_rates_eli_lilly_{rates_table_version}

Service Tests

Location: dags/consumer_engineering/eli_lilly_pricing/tasks/qa/service_tests.py

test_distinct_episode_ids

Purpose: Verify there are exactly 2 distinct episode_ids Expected: {'AZ-001', 'AZ-002'}

test_distinct_ssp_ids

Purpose: Verify there are exactly 2 distinct ssp_ids Expected: {'RA005', 'UN000'}

test_distinct_sub_package_ids

Purpose: Verify there are exactly 2 distinct sub_package_ids Expected: {'161RA', '355UN'}

test_distinct_sub_package_variant_ids

Purpose: Verify there are exactly 2 distinct sub_package_variant_ids Expected: {'161RA', '355UN'}

test_distinct_billing_codes

Purpose: Verify there are exactly 3 distinct billing_codes Expected: {'70551', 'J0175', '96365'}

test_distinct_fee_types

Purpose: Verify there are exactly 2 distinct fee_types Expected: {'professional', 'facility'}

test_episode_ssp_relationship

Purpose: Verify episode_id to ssp_id relationships Expected:

  • AZ-001{'RA005', 'UN000'} (both SSPs)
  • AZ-002{'UN000'} (only UN000)

test_ssp_billing_code_relationship

Purpose: Verify ssp_id to billing_code relationships Expected:

  • RA005{'70551'}
  • UN000{'J0175', '96365'}

test_billing_units

Purpose: Verify billing_units values for each billing_code Expected:

  • J0175 → 350
  • 70551 → 1
  • 96365 → 1

test_asp_units

Purpose: Verify asp_unit values for each billing_code Expected:

  • J0175 → '2mg'
  • 70551 → NULL
  • 96365 → NULL

test_is_package_base_code

Purpose: Verify is_package_base_code is always 0 Expected: All rows have is_package_base_code = 0


Provider Tests

Location: dags/consumer_engineering/eli_lilly_pricing/tasks/qa/provider_tests.py

test_distinct_provider_types

Purpose: Verify there are exactly 3 distinct provider_types Expected: {'Imaging Center', 'Infusion Center', 'Hospital'}

test_distinct_provider_count

Purpose: Verify there are at least 300 distinct provider_ids Expected: Count ≥ 300 providers


Payer Tests

Location: dags/consumer_engineering/eli_lilly_pricing/tasks/qa/payer_tests.py

test_distinct_payer_ids

Purpose: Verify there are exactly 4 distinct payer_ids Expected: {'0', '510', '643', '7'}

test_distinct_payer_names

Purpose: Verify there are exactly 4 distinct payer_names Expected: {'Medicare', 'Aetna', 'Humana', 'United Healthcare'}

test_distinct_network_ids

Purpose: Verify there are exactly 4 distinct network_ids Expected: {3396679882140345282, -6680783754063068487, -7966117643725474756, 5229724777607702119}

test_distinct_network_names

Purpose: Verify there are exactly 2 distinct network_names Expected: {'Medicare', 'Medicare Advantage'}

test_medicare_always_in_network

Purpose: Verify payer_id '0' (Medicare) is always in_network Expected: All Medicare rows have in_network = True

test_all_payers_have_in_network

Purpose: Verify for each payer_id, the distinct count of in_network provider_ids is > 80% of the distinct count of total provider_ids Expected: For each of the 4 payers, the ratio of (distinct in_network providers) / (distinct total providers) must be > 80%


Interaction Tests

Location: dags/consumer_engineering/eli_lilly_pricing/tasks/qa/interaction_tests.py

test_hospital_service_relationships

Purpose: Verify Hospital provider_type has correct service combinations Expected:

  • Episodes: {'AZ-001', 'AZ-002'}
  • SSPs: {'RA005', 'UN000'}
  • Billing Codes: {'70551', 'J0175', '96365'}

test_imaging_center_service_relationships

Purpose: Verify Imaging Center provider_type has correct constraints Expected:

  • Episodes: {'AZ-001'} (only AZ-001)
  • SSPs: {'RA005'} (only RA005)
  • Billing Codes: {'70551'} (only 70551)
  • Fee Types: {'professional'} (only professional)

test_infusion_center_service_relationships

Purpose: Verify Infusion Center provider_type has correct constraints Expected:

  • Episodes: {'AZ-001', 'AZ-002'}
  • SSPs: {'UN000'} (only UN000)
  • Billing Codes: {'J0175', '96365'}
  • Fee Types: {'professional'} (only professional)

test_service_payer_interaction

Purpose: Verify each payer has all service combinations Expected: Each of the 4 payers has:

  • All episode_ids: {'AZ-001', 'AZ-002'}
  • All ssp_ids: {'RA005', 'UN000'}
  • All billing_codes: {'70551', 'J0175', '96365'}
  • All fee_types: {'professional', 'facility'}

test_contract_methodology_by_provider_type

Purpose: Verify contract_methodology values by provider_type Expected:

  • Hospital: {'OPPS', 'MPFS'} (both methodologies)
  • Imaging Center: {'MPFS'} (only MPFS)
  • Infusion Center: {'MPFS'} (only MPFS)

test_hospital_fee_type_contract_methodology

Purpose: Verify Hospital fee type to contract methodology mapping Expected:

  • Professional fee → 'MPFS'
  • Facility fee → 'OPPS'

How to Run

Running Individual Tests

Tests are implemented as Airflow tasks and can be invoked in the DAG. Each test function is decorated with @task and returns a dictionary with test status.

Test Parameters

All tests accept the following parameters via Airflow context:

  • schema - Database schema (default: tq_dev.internal_dev_csong_consumer_pricing_service)
  • rates_table_version - Table version suffix (default: test)
  • db_conn_name - Trino connection ID (default: trino_default)

Test Results

Each test returns:

{"test": "test_name", "status": "PASSED"}

On failure, tests raise an AssertionError with details about the mismatch.


Expected Values Reference

All expected values are defined in dags/consumer_engineering/eli_lilly_pricing/answers.py

Service Values

EXPECTED_EPISODE_IDS = {'AZ-001', 'AZ-002'}
EXPECTED_SSP_IDS = {'RA005', 'UN000'}
EXPECTED_SUB_PACKAGE_IDS = {'161RA', '355UN'}
EXPECTED_SUB_PACKAGE_VARIANT_IDS = {'161RA', '355UN'}
EXPECTED_BILLING_CODES = {'70551', 'J0175', '96365'}
EXPECTED_FEE_TYPES = {'professional', 'facility'}

Billing Units

EXPECTED_BILLING_UNITS = {
'J0175': 350,
'70551': 1,
'96365': 1
}

EXPECTED_ASP_UNITS = {
'J0175': '2mg',
'70551': None,
'96365': None
}

Provider Values

EXPECTED_PROVIDER_TYPES = {'Imaging Center', 'Infusion Center', 'Hospital'}
EXPECTED_PROVIDER_COUNT = 300

Payer Values

EXPECTED_PAYER_IDS = {'0', '510', '643', '7'}
EXPECTED_PAYER_NAMES = {'Medicare', 'Aetna', 'Humana', 'United Healthcare'}
EXPECTED_NETWORK_IDS = {3396679882140345282, -6680783754063068487,
-7966117643725474756, 5229724777607702119}
EXPECTED_NETWORK_NAMES = {'Medicare', 'Medicare Advantage'}

Relationship Mappings

Episode to SSP

EPISODE_SSP_IDS = {
'AZ-001': {'RA005', 'UN000'}, # Both SSPs
'AZ-002': {'UN000'} # Only UN000
}

SSP to Billing Code

SSP_BILLING_CODES = {
'RA005': {'70551'}, # Only 70551 (imaging)
'UN000': {'J0175', '96365'} # Drug + infusion
}

Provider Type Constraints

# Hospital: All services
HOSPITAL_EPISODE_IDS = {'AZ-001', 'AZ-002'}
HOSPITAL_SSP_IDS = {'RA005', 'UN000'}
HOSPITAL_BILLING_CODES = {'70551', 'J0175', '96365'}

# Imaging Center: Only radiology services
IMAGING_CENTER_EPISODE_IDS = {'AZ-001'}
IMAGING_CENTER_SSP_IDS = {'RA005'}
IMAGING_CENTER_BILLING_CODES = {'70551'}
IMAGING_CENTER_FEE_TYPES = {'professional'}

# Infusion Center: Only infusion services
INFUSION_CENTER_EPISODE_IDS = {'AZ-001', 'AZ-002'}
INFUSION_CENTER_SSP_IDS = {'UN000'}
INFUSION_CENTER_BILLING_CODES = {'J0175', '96365'}
INFUSION_CENTER_FEE_TYPES = {'professional'}

Contract Methodologies

HOSPITAL_CONTRACT_METHODOLOGIES = {'OPPS', 'MPFS'}
IMAGING_CENTER_CONTRACT_METHODOLOGIES = {'MPFS'}
INFUSION_CENTER_CONTRACT_METHODOLOGIES = {'MPFS'}

# Hospital fee type mapping
HOSPITAL_PROFESSIONAL_CONTRACT_METHODOLOGY = 'MPFS'
HOSPITAL_FACILITY_CONTRACT_METHODOLOGY = 'OPPS'

Test Coverage Summary

Data Completeness

  • ✓ All expected episodes, SSPs, and billing codes are present
  • ✓ All expected provider types are present
  • ✓ All expected payers and networks are present
  • ✓ Minimum provider count is met

Data Relationships

  • ✓ Episode-to-SSP mappings are correct
  • ✓ SSP-to-billing-code mappings are correct
  • ✓ Provider type constraints are enforced
  • ✓ Each payer has all service combinations

Data Attributes

  • ✓ Billing units are correct per code
  • ✓ ASP units are correct per code
  • ✓ is_package_base_code is always 0
  • ✓ Medicare is always in-network
  • ✓ All payers have >80% of distinct providers in-network

Contract Methodologies

  • ✓ Provider types have correct methodologies
  • ✓ Hospital fee types map to correct methodologies
  • ✓ OPPS is used for hospital facility fees
  • ✓ MPFS is used for professional fees and non-hospital providers

Maintenance Notes

Updating Expected Values

When the expected data changes, update dags/consumer_engineering/eli_lilly_pricing/answers.py accordingly.

Adding New Tests

  1. Add test functions to the appropriate module (service_tests.py, provider_tests.py, payer_tests.py, or interaction_tests.py)
  2. Use the @task decorator
  3. Follow the naming convention: test_<description>
  4. Return {"test": "test_name", "status": "PASSED"} on success
  5. Raise AssertionError with descriptive message on failure
  6. Add expected values to answers.py if needed
  7. Update this documentation