Skip to main content

Komodo Remits: Stoploss

Takeaways:

There is no clear stoploss pattern and certainly nothing that aligns with expectations based on hospital MRF data. One reason for the noisiness may be that we are not aggregating charges and allowed amounts correctly. There is not sufficient data to prove whether aggregation is correct or not.

We also conduct volume analysis to see how many high-dollar claims exist for the top hospitals in each state (by revenue) for BUCA contracts. For United, Cigna, and Aetna, we would expect 510 * 3 = 1530 contracts (payer–provider pairs) if every top hospital in each state had contracts with these payers. We find 206 contracts with at least 1 high-cost encounter (13.5%).

Goal

Assess whether stoploss inference is feasible with Remits data. Stoploss inference requires estimation of the stoploss threshold and percentage for each contract. Feasibility will be determined based on volume and accuracy:

Accuracy

  • Where we have contracts, does the estimated stoploss threshold and percentage align with expected values?
  • Where we don’t have contracts, does the distribution of thresholds and percentages align with expectations?

Volume

  • Are there sufficiently many contracts (payer–providers) in remits data where we can estimate stoploss threshold and percentage?

Analysis should be narrow in scope to answer questions above as thoroughly as possible within a day or two.


Data

  • Remits data: tq_intermediate.external_komodo.remits
  • Payer crosswalk: tq_production.spines.spines_payer_identifiers
  • Provider crosswalk: tq_production.spines.spines_provider_hospitals_additional_npis
  • Stoploss extracted from hospital MRF data: tq_dev.internal_dev_csong_sandbox.clear_rates_hospital_data_stoploss

Inclusion Criteria

For this analysis, only consider:

  • encounters with bill_type_code = '11'
  • payer/hospital exist in crosswalks (spines)

Methodology

Analysis

Sample/Accuracy Analysis

  1. Randomly sample 30 contracts where:
    • we have enough high-cost encounters, and
    • stoploss values are extracted from hospital MRF data
  2. For these 30 contracts:
    • create plots showing the distribution of allowed amounts as a percentage of total cost
    • add a horizontal line to indicate the expected values based on MRF data

Take 1: Flat Allowed Amount / Total Cost Scatter Plots and Summary Statistics

Code
# %%
df = pd.read_sql(f"""
WITH
gtr_100k AS (
SELECT encounter_key
FROM tq_intermediate.external_komodo.remits
WHERE bill_type_code = '11'
GROUP BY 1
HAVING SUM(billed_amount) > 100000
AND SUM(allowed_amount) > 0
),
df AS (
SELECT
p.payer_id,
s.provider_id,
r.encounter_key,
r.billed_amount,
r.allowed_amount,
sp.additional_payer_notes,
sp.highest_number_payer
FROM tq_intermediate.external_komodo.remits r
JOIN tq_production.spines.spines_payer_identifiers p
ON TRY_CAST(r.payer_id AS INT) = CAST(p.payer_identifier_value AS INT)
JOIN tq_production.spines.spines_provider_hospitals_additional_npis s
ON s.npi = r.payee_npi
JOIN tq_dev.internal_dev_csong_sandbox.clear_rates_hospital_data_stoploss sp
ON sp.provider_id = s.provider_id
AND sp.payer_id = p.payer_id
WHERE p.payer_identifier_type_id = '3'
AND r.bill_type_code = '11'
AND r.encounter_key IN (SELECT encounter_key FROM gtr_100k)
AND sp.additional_payer_notes IS NOT NULL
AND sp.highest_number_payer IS NOT NULL
),
encounters AS (
SELECT
payer_id,
provider_id,
encounter_key,
MAX(additional_payer_notes) as additional_payer_notes,
MAX(highest_number_payer) as highest_number_payer,
sum(billed_amount) as total_billed,
sum(allowed_amount) as total_allowed,
sum(allowed_amount) / nullif(sum(billed_amount), 0) as percent_allowed
FROM df
GROUP BY 1, 2, 3
),
samples AS (
SELECT *
FROM (
SELECT payer_id, provider_id
FROM encounters
GROUP BY 1, 2
HAVING count(distinct encounter_key) BETWEEN 50 AND 500
)
ORDER BY RANDOM()
LIMIT 30
)
SELECT
payer_id || '_' || provider_id AS contract_id,
payer_id,
provider_id,
encounter_key,
additional_payer_notes,
highest_number_payer,
total_billed,
total_allowed,
percent_allowed
FROM encounters
-- WHERE (payer_id, provider_id) IN (SELECT payer_id, provider_id FROM samples)
WHERE payer_id || '_' || provider_id IN (
'42_3295',
'76_5297',
'643_2251',
'388_2251',
'391_4704',
'52_1729',
'42_1521',
'454_4553',
'42_3204',
'510_3200',
'42_3147',
'7_5297',
'42_591',
'174_1225',
'52_1634',
'42_3200',
'169_5297',
'42_2621',
'643_3200',
'510_3147',
'391_4781'
)
""", con=trino_conn)


# %%
print(df[['contract_id', 'additional_payer_notes']].drop_duplicates().to_markdown(index=False))

#
expected_stoploss = [
('42_3295', 380488, 0.244),
('76_5297', 332423, 0.6061),
('643_2251', 260000, None),
('388_2251', 73420, 0.7246),
('391_4704', 94500, 0.30),
('52_1729', 99727.58, 0.2271),
('42_1521', 347288, 0.585),
('454_4553', 67500, 0.55),
('42_3204', 100000, None),
('510_3200', 250000, None),
('42_3147', 100000, None),
('7_5297', 176384, 0.777),
('42_591', 181076.10, 0.7251),
('174_1225', None, None),
('52_1634', 99727.58, 0.2271),
('42_3200', 100000, None),
('169_5297', 290427, 0.635),
('42_2621', 92000, 0.60),
('643_3200', 250000, None),
('510_3147', 202517, 0.594),
('391_4781', 104000, 0.45),
]
df_expected = pd.DataFrame(expected_stoploss, columns=['contract_id', 'expected_stoploss_amount', 'expected_stoploss_percent'])
df_merged = df.merge(df_expected, on='contract_id', how='left')


# %%
for contract_id in df_merged['contract_id'].unique():
df_contract = df_merged[df_merged['contract_id'] == contract_id]
expected_percent = df_contract['expected_stoploss_percent'].iloc[0]
expected_stoploss_amount = df_contract['expected_stoploss_amount'].iloc[0]
if expected_percent > 0:
ax = sns.scatterplot(data=df_contract, x='total_billed', y='percent_allowed')
ax.set_ylim(0, 1)
ax.set_xlim(0, min(max(df_contract['total_billed']), 2e6))
plt.axhline(expected_percent, color='red', linestyle='--', label='Expected Stoploss Percent')
plt.axvline(expected_stoploss_amount, color='blue', linestyle='--', label='Expected Stoploss Amount')
plt.title(f'Payer_Provider: {contract_id}')
plt.legend()
# save as png
plt.savefig(f'plots/stoploss_scatter_{contract_id}.png')
plt.show()
Results
contract_idpayer_idprovider_idexpected_stoploss_amountexpected_stoploss_percentencounter_countp05p25p50p75p95
169_529716952972904270.6355920.141350.2530540.3818930.6085861
388_22513882251734200.72463040.00145160.01285250.032240.3996640.618201
391_47043914704945000.312920.03749630.1936290.272270.3837360.584909
391_478139147811040000.453650.01754860.1737040.2264480.3186370.473881
42_15214215213472880.5859940.00785520.1136040.1897980.3248920.618703
42_3147423147100000nan3360.000393250.000922250.1107130.4809140.933049
42_3200423200100000nan38970.000335650.006391750.2559870.5125390.954417
42_32954232953804880.2442170.00042580.0010720.0215230.1174210.307892
42_591425911810760.725116740.00035170.0168990.3172020.5380680.983149
454_45534544553675000.558370.00718980.0134420.020350.4401731
510_32005103200250000nan110600.005162250.0869770.1635940.306241
52_163452163499727.60.227120540.08667030.2213180.2851870.4141520.602497
52_172952172999727.60.22714200.01480720.2127280.2479240.3510150.564136
643_22516432251260000nan5430.06571020.2018950.3091730.4794180.70984
643_32006433200250000nan551600.06172720.1806690.2995590.605435
76_52977652973324230.60613160.01333340.270280.4669170.7306880.938858
7_5297752971763840.7775070.00063590.1728550.3310720.4880430.799535

stoploss_scatter_169_5297 stoploss_scatter_391_4704 stoploss_scatter_42_1521 stoploss_scatter_76_5297 stoploss_scatter_388_2251 stoploss_scatter_391_4781 stoploss_scatter_42_3295 stoploss_scatter_454_4553 stoploss_scatter_7_5297

Take 2: Second Dollar Allowed Amount / Total Cost Scatter Plots and Summary Statistics

Difference from section above: only consider allowed amounts after stoploss threshold is exceeded.

df['allowed_less_stoploss'] = df['total_allowed'] - df['expected_stoploss_amount']
df['charges_less_stoploss'] = df['total_billed'] - df['expected_stoploss_amount']
df = df.loc[df['allowed_less_stoploss'] >= 0]
df['percent_allowed'] = df['allowed_less_stoploss'] / df['charges_less_stoploss']
Code
df = pd.read_sql(f"""
WITH
gtr_100k AS (
SELECT encounter_key
FROM tq_intermediate.external_komodo.remits
WHERE bill_type_code = '11'
GROUP BY 1
HAVING SUM(billed_amount) > 100000
AND SUM(allowed_amount) > 0
),
df AS (
SELECT
p.payer_id,
s.provider_id,
r.encounter_key,
r.billed_amount,
r.allowed_amount,
sp.additional_payer_notes,
sp.highest_number_payer
FROM tq_intermediate.external_komodo.remits r
JOIN tq_production.spines.spines_payer_identifiers p
ON TRY_CAST(r.payer_id AS INT) = CAST(p.payer_identifier_value AS INT)
JOIN tq_production.spines.spines_provider_hospitals_additional_npis s
ON s.npi = r.payee_npi
JOIN tq_dev.internal_dev_csong_sandbox.clear_rates_hospital_data_stoploss sp
ON sp.provider_id = s.provider_id
AND sp.payer_id = p.payer_id
WHERE p.payer_identifier_type_id = '3'
AND r.bill_type_code = '11'
AND r.encounter_key IN (SELECT encounter_key FROM gtr_100k)
AND sp.additional_payer_notes IS NOT NULL
AND sp.highest_number_payer IS NOT NULL
),
encounters AS (
SELECT
payer_id,
provider_id,
encounter_key,
MAX(additional_payer_notes) as additional_payer_notes,
MAX(highest_number_payer) as highest_number_payer,
sum(billed_amount) as total_billed,
sum(allowed_amount) as total_allowed,
sum(allowed_amount) / nullif(sum(billed_amount), 0) as percent_allowed
FROM df
GROUP BY 1, 2, 3
),
samples AS (
SELECT *
FROM (
SELECT payer_id, provider_id
FROM encounters
GROUP BY 1, 2
HAVING count(distinct encounter_key) BETWEEN 50 AND 500
)
ORDER BY RANDOM()
LIMIT 30
)
SELECT
payer_id || '_' || provider_id AS contract_id,
payer_id,
provider_id,
encounter_key,
additional_payer_notes,
highest_number_payer,
total_billed,
total_allowed
FROM encounters
-- WHERE (payer_id, provider_id) IN (SELECT payer_id, provider_id FROM samples)
WHERE payer_id || '_' || provider_id IN (
'42_3295',
'76_5297',
'643_2251',
'388_2251',
'391_4704',
'52_1729',
'42_1521',
'454_4553',
'42_3204',
'510_3200',
'42_3147',
'7_5297',
'42_591',
'174_1225',
'52_1634',
'42_3200',
'169_5297',
'42_2621',
'643_3200',
'510_3147',
'391_4781'
)
""", con=trino_conn)


# %%
print(df[['contract_id', 'additional_payer_notes']].drop_duplicates().to_markdown(index=False))

#
expected_stoploss = [
('42_3295', 380488, 0.244),
('76_5297', 332423, 0.6061),
('643_2251', 260000, None),
('388_2251', 73420, 0.7246),
('391_4704', 94500, 0.30),
('52_1729', 99727.58, 0.2271),
('42_1521', 347288, 0.585),
('454_4553', 67500, 0.55),
('42_3204', 100000, None),
('510_3200', 250000, None),
('42_3147', 100000, None),
('7_5297', 176384, 0.777),
('42_591', 181076.10, 0.7251),
('174_1225', None, None),
('52_1634', 99727.58, 0.2271),
('42_3200', 100000, None),
('169_5297', 290427, 0.635),
('42_2621', 92000, 0.60),
('643_3200', 250000, None),
('510_3147', 202517, 0.594),
('391_4781', 104000, 0.45),
]
df_expected = pd.DataFrame(expected_stoploss, columns=['contract_id', 'expected_stoploss_amount', 'expected_stoploss_percent'])
df_merged = df.merge(df_expected, on='contract_id', how='left')

# %%
df_merged['allowed_less_stoploss'] = df_merged['total_allowed'] - df_merged['expected_stoploss_amount']
df_merged['charges_less_stoploss'] = df_merged['total_billed'] - df_merged['expected_stoploss_amount']
df_merged = df_merged.loc[df_merged['allowed_less_stoploss'] >= 0]
df_merged['percent_allowed'] = df_merged['allowed_less_stoploss'] / df_merged['charges_less_stoploss']

# %%
for contract_id in df_merged['contract_id'].unique():
df_contract = df_merged[df_merged['contract_id'] == contract_id]
expected_percent = df_contract['expected_stoploss_percent'].iloc[0]
expected_stoploss_amount = df_contract['expected_stoploss_amount'].iloc[0]
if len(df_contract.loc[df_contract['total_billed']<2e6]) < 10:
continue
if expected_percent > 0:
ax = sns.scatterplot(data=df_contract, x='total_billed', y='percent_allowed')
ax.set_ylim(0, 1)
ax.set_xlim(0, min(max(df_contract['total_billed']), 2e6))
plt.axhline(expected_percent, color='red', linestyle='--', label='Expected Stoploss Percent')
plt.axvline(expected_stoploss_amount, color='blue', linestyle='--', label='Expected Stoploss Amount')
plt.title(f'Payer_Provider: {contract_id}')
plt.legend()
# save as png
plt.savefig(f'plots_second_dollar/stoploss_scatter_{contract_id}.png')
plt.show()


# %%
percentiles = [0.05, 0.25, 0.5, 0.75, 0.95]

df_summary = (
df_merged
.groupby(
[
'contract_id',
'payer_id',
'provider_id',
'expected_stoploss_amount',
'expected_stoploss_percent',
],
dropna=False
)
.agg(
encounter_count=('encounter_key', 'nunique'),
p05=('percent_allowed', lambda x: x.quantile(0.05)),
p25=('percent_allowed', lambda x: x.quantile(0.25)),
p50=('percent_allowed', lambda x: x.quantile(0.50)),
p75=('percent_allowed', lambda x: x.quantile(0.75)),
p95=('percent_allowed', lambda x: x.quantile(0.95)),
)
.reset_index()
)
print(df_summary.to_markdown(index=False))
Results
contract_idpayer_idprovider_idexpected_stoploss_amountexpected_stoploss_percentencounter_countp05p25p50p75p95
169_529716952972904270.6352720.03769960.1989650.4022710.7595111
388_22513882251734200.72461310.05241430.2119480.33060.5185410.637591
391_47043914704945000.36540.01319840.06856620.1357290.2469950.482096
391_478139147811040000.451180.01775190.04932950.1069470.1540440.322301
42_15214215213472880.585140.03378780.05140040.1293790.2681610.363054
42_2621422621920000.610.04987450.04987450.04987450.04987450.0498745
42_3147423147100000nan400.03683390.1735520.4210060.666361
42_3200423200100000nan10550.02126570.138420.3228020.6830581
42_3204423204100000nan50.03421180.1690520.2181860.3901230.63194
42_591425911810760.725112660.01695760.2393220.4148060.6121721
454_45534544553675000.551380.1143810.35056111
510_32005103200250000nan120.008985860.02824230.0561710.1077120.14864
52_163452163499727.60.227119610.1059730.2210510.2866440.4144930.602048
52_172952172999727.60.22713930.09383550.2194130.2490240.3492680.556422
643_22516432251260000nan210.03468480.1805230.2731790.360271
643_32006433200250000nan100.01183850.02420270.03032350.06564620.100539
76_52977652973324230.60611440.0282690.1944090.5579890.6797070.945095
7_5297752971763840.7772010.02732710.1151740.2688550.5300930.888584

alt text alt text alt text alt text alt text alt text alt text alt text

Take 3: Exclude Drugs and Implants

In ADDITION to second dollar calculation, exclude encounters where revenue_code NOT IN ('0636', '0343', '0344', '0274', '0275', '0276', '0278')

Code
# %%
df = pd.read_sql(f"""
WITH
gtr_100k AS (
SELECT encounter_key
FROM tq_intermediate.external_komodo.remits
WHERE bill_type_code = '11'
AND revenue_code NOT IN (
'0636',
'0343',
'0344',
'0274',
'0275',
'0276',
'0278'
)
GROUP BY 1
HAVING SUM(billed_amount) > 100000
AND SUM(allowed_amount) > 0
),
df AS (
SELECT
p.payer_id,
s.provider_id,
r.encounter_key,
r.billed_amount,
r.allowed_amount,
sp.additional_payer_notes,
sp.highest_number_payer
FROM tq_intermediate.external_komodo.remits r
JOIN tq_production.spines.spines_payer_identifiers p
ON TRY_CAST(r.payer_id AS INT) = CAST(p.payer_identifier_value AS INT)
JOIN tq_production.spines.spines_provider_hospitals_additional_npis s
ON s.npi = r.payee_npi
JOIN tq_dev.internal_dev_csong_sandbox.clear_rates_hospital_data_stoploss sp
ON sp.provider_id = s.provider_id
AND sp.payer_id = p.payer_id
WHERE p.payer_identifier_type_id = '3'
AND r.bill_type_code = '11'
AND revenue_code NOT IN (
'0636',
'0343',
'0344',
'0274',
'0275',
'0276',
'0278'
)
AND r.encounter_key IN (SELECT encounter_key FROM gtr_100k)
AND sp.additional_payer_notes IS NOT NULL
AND sp.highest_number_payer IS NOT NULL
),
encounters AS (
SELECT
payer_id,
provider_id,
encounter_key,
MAX(additional_payer_notes) as additional_payer_notes,
MAX(highest_number_payer) as highest_number_payer,
sum(billed_amount) as total_billed,
sum(allowed_amount) as total_allowed,
sum(allowed_amount) / nullif(sum(billed_amount), 0) as percent_allowed
FROM df
GROUP BY 1, 2, 3
),
samples AS (
SELECT *
FROM (
SELECT payer_id, provider_id
FROM encounters
GROUP BY 1, 2
HAVING count(distinct encounter_key) BETWEEN 50 AND 500
)
ORDER BY RANDOM()
LIMIT 30
)
SELECT
payer_id || '_' || provider_id AS contract_id,
payer_id,
provider_id,
encounter_key,
additional_payer_notes,
highest_number_payer,
total_billed,
total_allowed
FROM encounters
-- WHERE (payer_id, provider_id) IN (SELECT payer_id, provider_id FROM samples)
WHERE payer_id || '_' || provider_id IN (
'42_3295',
'76_5297',
'643_2251',
'388_2251',
'391_4704',
'52_1729',
'42_1521',
'454_4553',
'42_3204',
'510_3200',
'42_3147',
'7_5297',
'42_591',
'174_1225',
'52_1634',
'42_3200',
'169_5297',
'42_2621',
'643_3200',
'510_3147',
'391_4781'
)
""", con=trino_conn)


# %%
print(df[['contract_id', 'additional_payer_notes']].drop_duplicates().to_markdown(index=False))

#
expected_stoploss = [
('42_3295', 380488, 0.244),
('76_5297', 332423, 0.6061),
('643_2251', 260000, None),
('388_2251', 73420, 0.7246),
('391_4704', 94500, 0.30),
('52_1729', 99727.58, 0.2271),
('42_1521', 347288, 0.585),
('454_4553', 67500, 0.55),
('42_3204', 100000, None),
('510_3200', 250000, None),
('42_3147', 100000, None),
('7_5297', 176384, 0.777),
('42_591', 181076.10, 0.7251),
('174_1225', None, None),
('52_1634', 99727.58, 0.2271),
('42_3200', 100000, None),
('169_5297', 290427, 0.635),
('42_2621', 92000, 0.60),
('643_3200', 250000, None),
('510_3147', 202517, 0.594),
('391_4781', 104000, 0.45),
]
df_expected = pd.DataFrame(expected_stoploss, columns=['contract_id', 'expected_stoploss_amount', 'expected_stoploss_percent'])
df_merged = df.merge(df_expected, on='contract_id', how='left')

# %%
df_merged['allowed_less_stoploss'] = df_merged['total_allowed'] - df_merged['expected_stoploss_amount']
df_merged['charges_less_stoploss'] = df_merged['total_billed'] - df_merged['expected_stoploss_amount']
df_merged = df_merged.loc[df_merged['allowed_less_stoploss'] >= 0]
df_merged['percent_allowed'] = df_merged['allowed_less_stoploss'] / df_merged['charges_less_stoploss']

# %%
for contract_id in df_merged['contract_id'].unique():
df_contract = df_merged[df_merged['contract_id'] == contract_id]
expected_percent = df_contract['expected_stoploss_percent'].iloc[0]
expected_stoploss_amount = df_contract['expected_stoploss_amount'].iloc[0]
print(contract_id, len(df_contract))
if len(df_contract.loc[df_contract['total_billed']<2e6]) < 10:
continue
if expected_percent > 0:
ax = sns.scatterplot(data=df_contract, x='total_billed', y='percent_allowed')
ax.set_ylim(0, 1)
ax.set_xlim(0, min(max(df_contract['total_billed']), 2e6))
plt.axhline(expected_percent, color='red', linestyle='--', label='Expected Stoploss Percent')
plt.axvline(expected_stoploss_amount, color='blue', linestyle='--', label='Expected Stoploss Amount')
plt.title(f'Payer_Provider: {contract_id}')
plt.legend()
# save as png
plt.savefig(f'plots_second_dollar_no_drug_implants/stoploss_scatter_{contract_id}.png')
plt.show()


# %%
percentiles = [0.05, 0.25, 0.5, 0.75, 0.95]

df_summary = (
df_merged
.groupby(
[
'contract_id',
'payer_id',
'provider_id',
'expected_stoploss_amount',
'expected_stoploss_percent',
],
dropna=False
)
.agg(
encounter_count=('encounter_key', 'nunique'),
p05=('percent_allowed', lambda x: x.quantile(0.05)),
p25=('percent_allowed', lambda x: x.quantile(0.25)),
p50=('percent_allowed', lambda x: x.quantile(0.50)),
p75=('percent_allowed', lambda x: x.quantile(0.75)),
p95=('percent_allowed', lambda x: x.quantile(0.95)),
)
.reset_index()
)
print(df_summary.to_markdown(index=False))
Results

alt text alt text alt text


Volume Analysis

  1. Create a table where each row is a contract with the following statistics:
    • count of encounters with total charges > $200k
  2. Using Clear Rates whispers, identify the top 10 hospitals in each state based on revenue.
  3. Using the table from (1), filter to:
    • contracts that exist in the hospital list from (2), and
    • payer is united, aetna, cigna, blues
Code
df = pd.read_sql(f"""
WITH
provider_names AS (
SELECT
DISTINCT
provider_id,
provider_name
FROM tq_production.spines.spines_provider_hospitals
),
payer_names AS (
SELECT
DISTINCT
payer_id,
payer_name
FROM tq_production.spines.spines_payer
),
ranked AS (
SELECT
state,
provider_id,
ROW_NUMBER() OVER (PARTITION BY state ORDER BY provider_net_patient_revenue_state_rank ASC) AS rn
FROM tq_dev.internal_dev_csong_cld_v2_3_1.prod_rollup_provider
),
top_providers AS (
SELECT *
FROM ranked
WHERE rn <= 10
AND state NOT IN ('VI', 'PR')
),
inpatient_claims AS (
SELECT DISTINCT
encounter_key
FROM tq_intermediate.external_komodo.remits
WHERE (
bill_type_code = '11'
) OR (
drg_code IS NOT NULL
AND payee_npi IN (
SELECT npi
FROM tq_production.spines.spines_provider_hospitals_additional_npis
)
)
),
df AS (
SELECT
tp.state,
p.payer_id,
s.provider_id,
r.encounter_key,
r.billed_amount,
r.allowed_amount
FROM tq_intermediate.external_komodo.remits r
JOIN tq_production.spines.spines_payer_identifiers p
ON TRY_CAST(r.payer_id AS INT) = CAST(p.payer_identifier_value AS INT)
JOIN tq_production.spines.spines_provider_hospitals_additional_npis s on
s.npi = r.payee_npi
JOIN top_providers tp
ON s.provider_id = tp.provider_id
WHERE p.payer_identifier_type_id = '3'
AND r.encounter_key IN (
SELECT encounter_key FROM inpatient_claims
)
AND p.payer_id IN (
'643', '76', '7',
'42','43','44','46','47','48','49','50','51','52','53','54','56','61','62',
'101','160','165','166','168','169','170','174','229','383','388','389',
'390','391','392','397','398','403','454','455','456','458','461','462',
'464','628','729','837','914', '952'
)
),
encounters AS (
SELECT
state,
payer_id,
provider_id,
encounter_key,
sum(billed_amount) as total_billed,
sum(allowed_amount) as total_allowed,
sum(allowed_amount) / nullif(sum(billed_amount), 0) as percent_allowed
FROM df
WHERE encounter_key IS NOT NULL
AND allowed_amount > 0
GROUP BY 1, 2, 3, 4
HAVING sum(billed_amount) > 200000
)
SELECT
state,
enc.payer_id,
enc.provider_id,
payn.payer_name,
pn.provider_name,
count(distinct encounter_key) as n_encounters
FROM encounters enc
LEFT JOIN provider_names pn
ON enc.provider_id = pn.provider_id
LEFT JOIN payer_names payn
ON enc.payer_id = payn.payer_id
GROUP BY 1,2,3,4,5
ORDER BY 1, n_encounters DESC
""", con=trino_conn)

# %%
df

# %%
print(df.to_markdown(index=False))
df.loc[df['payer_id'].isin(['7', '76', '643']), :]

# %%
df.to_excel('stoploss_coverage_by_top_providers.xlsx', index=False)
Results
statepayer_idprovider_idpayer_nameprovider_namen_encounters
AK6286703Premera Blue CrossBartlett Regional Hospital8
AK76703AetnaBartlett Regional Hospital1
AL1603510Blue Cross Blue Shield of AlabamaChildrens of Alabama69
AL763520CignaUAB Hospital28
AL6433520UnitedHealthcareUAB Hospital27
AL73520AetnaUAB Hospital8
AL423520AnthemUAB Hospital2
AL763510CignaChildrens of Alabama1
AR4544553Blue Cross Blue Shield of ArkansasSt Bernards Medical Center25
AR6434553UnitedHealthcareSt Bernards Medical Center3
AR764553CignaSt Bernards Medical Center1
AZ6435919UnitedHealthcareBanner - University Medical Center Phoenix728
AZ6435960UnitedHealthcareBanner - University Medical Center Tucson570
AZ435919Blue Cross Blue Shield of ArizonaBanner - University Medical Center Phoenix518
AZ6435872UnitedHealthcareBanner Desert Medical Center385
AZ435872Blue Cross Blue Shield of ArizonaBanner Desert Medical Center373
AZ6435871UnitedHealthcareBanner Thunderbird Medical Center352
AZ435960Blue Cross Blue Shield of ArizonaBanner - University Medical Center Tucson326
AZ435871Blue Cross Blue Shield of ArizonaBanner Thunderbird Medical Center200
AZ765919CignaBanner - University Medical Center Phoenix114
AZ765872CignaBanner Desert Medical Center94
AZ765871CignaBanner Thunderbird Medical Center59
AZ765960CignaBanner - University Medical Center Tucson45
AZ75871AetnaBanner Thunderbird Medical Center3
AZ75872AetnaBanner Desert Medical Center3
AZ765876CignaTucson Medical Center2
AZ425876AnthemTucson Medical Center1
AZ75919AetnaBanner - University Medical Center Phoenix1
AZ75960AetnaBanner - University Medical Center Tucson1
AZ6435876UnitedHealthcareTucson Medical Center1
AZ75876AetnaTucson Medical Center1
CA426546AnthemStanford University Hospital3001
CA4036546Blue Shield of CaliforniaStanford University Hospital2277
CA6436546UnitedHealthcareStanford University Hospital648
CA766546CignaStanford University Hospital593
CA6436646UnitedHealthcareLucile Packard Childrens Hospital Stanford343
CA76546AetnaStanford University Hospital240
CA426646AnthemLucile Packard Childrens Hospital Stanford231
CA4036646Blue Shield of CaliforniaLucile Packard Childrens Hospital Stanford73
CA76646AetnaLucile Packard Childrens Hospital Stanford37
CA766646CignaLucile Packard Childrens Hospital Stanford28
CA526546Blue Cross Blue Shield of North CarolinaStanford University Hospital4
CA446546Blue Cross Blue Shield of Maryland & DC (CareFirst)Stanford University Hospital3
CA3926546Blue Cross Blue Shield of MassachusettsStanford University Hospital3
CA3836546Blue Cross of IdahoStanford University Hospital2
CA2296546Blue Cross Blue Shield of New Jersey (Horizon)Stanford University Hospital2
CO6435722UnitedHealthcareHCA HealthONE Sky Ridge1
CT42747AnthemHartford Hospital165
CT643747UnitedHealthcareHartford Hospital60
CT42752AnthemStamford Hospital56
CT42753AnthemSt Vincents Medical Center51
CT76747CignaHartford Hospital43
CT76753CignaSt Vincents Medical Center16
CT76752CignaStamford Hospital11
CT7747AetnaHartford Hospital9
CT643753UnitedHealthcareSt Vincents Medical Center9
CT643752UnitedHealthcareStamford Hospital8
CT397747Blue Cross Blue Shield of Rhode IslandHartford Hospital2
CT7753AetnaSt Vincents Medical Center2
CT7752AetnaStamford Hospital1
DC441434Blue Cross Blue Shield of Maryland & DC (CareFirst)MedStar Washington Hospital Center877
DC441435Blue Cross Blue Shield of Maryland & DC (CareFirst)MedStar Georgetown University Hospital806
DC6431434UnitedHealthcareMedStar Washington Hospital Center316
DC6431435UnitedHealthcareMedStar Georgetown University Hospital271
DC761434CignaMedStar Washington Hospital Center172
DC761435CignaMedStar Georgetown University Hospital166
DC421435AnthemMedStar Georgetown University Hospital19
DC6431438UnitedHealthcareMedStar National Rehabilitation Hospital5
DC71434AetnaMedStar Washington Hospital Center3
DC761438CignaMedStar National Rehabilitation Hospital2
DC421434AnthemMedStar Washington Hospital Center1
DC441438Blue Cross Blue Shield of Maryland & DC (CareFirst)MedStar National Rehabilitation Hospital1
DC71435AetnaMedStar Georgetown University Hospital1
DE71357AetnaNemours Childrens Hospital - Delaware170
DE2291357Blue Cross Blue Shield of New Jersey (Horizon)Nemours Childrens Hospital - Delaware73
DE1741355Highmark Blue Cross Blue ShieldBeebe Healthcare - Margaret H Rollins Lewes Campus68
DE561357Blue Cross Blue Shield of Pennsylvania (Independence)Nemours Childrens Hospital - Delaware50
DE6431357UnitedHealthcareNemours Childrens Hospital - Delaware31
DE1741357Highmark Blue Cross Blue ShieldNemours Childrens Hospital - Delaware25
DE6431355UnitedHealthcareBeebe Healthcare - Margaret H Rollins Lewes Campus10
DE761357CignaNemours Childrens Hospital - Delaware10
DE761355CignaBeebe Healthcare - Margaret H Rollins Lewes Campus2
DE71356AetnaTidalHealth Nanticoke1
FL3882251Blue Cross Blue Shield of Florida (Florida Blue)Moffitt Cancer Center Magnolia Campus120
FL6432251UnitedHealthcareMoffitt Cancer Center Magnolia Campus88
FL762251CignaMoffitt Cancer Center Magnolia Campus43
FL72251AetnaMoffitt Cancer Center Magnolia Campus26
FL422251AnthemMoffitt Cancer Center Magnolia Campus1
FL6432203UnitedHealthcareOrlando Health Orlando Regional Medical Center1
GA761884CignaPiedmont Atlanta Hospital248
GA71884AetnaPiedmont Atlanta Hospital196
GA421884AnthemPiedmont Atlanta Hospital166
GA6431884UnitedHealthcarePiedmont Atlanta Hospital155
GA761864CignaArthur M Blank Hospital63
GA1681884Blue Cross Blue Shield of South CarolinaPiedmont Atlanta Hospital8
GA3881884Blue Cross Blue Shield of Florida (Florida Blue)Piedmont Atlanta Hospital4
GA6431952UnitedHealthcareEmory University Hospital2
ID3835632Blue Cross of IdahoBingham Memorial Hospital1
KY423266AnthemBaptist Health Louisville821
KY423271AnthemBaptist Health Lexington300
KY423313AnthemPikeville Medical Center82
KY6433271UnitedHealthcareBaptist Health Lexington59
KY6433266UnitedHealthcareBaptist Health Louisville26
KY6433313UnitedHealthcarePikeville Medical Center24
KY73266AetnaBaptist Health Louisville20
KY73271AetnaBaptist Health Lexington13
KY523266Blue Cross Blue Shield of North CarolinaBaptist Health Louisville8
KY73313AetnaPikeville Medical Center4
KY763313CignaPikeville Medical Center4
KY763271CignaBaptist Health Lexington3
KY523271Blue Cross Blue Shield of North CarolinaBaptist Health Lexington1
KY4613266Wellmark Blue Cross Blue ShieldBaptist Health Louisville1
KY4613271Wellmark Blue Cross Blue ShieldBaptist Health Lexington1
KY763266CignaBaptist Health Louisville1
LA3914704Blue Cross Blue Shield of LouisianaOchsner Lafayette General Medical Center409
LA3914667Blue Cross Blue Shield of LouisianaSt Tammany Health System326
LA6434704UnitedHealthcareOchsner Lafayette General Medical Center215
LA6434667UnitedHealthcareSt Tammany Health System101
LA764667CignaSt Tammany Health System5
LA764704CignaOchsner Lafayette General Medical Center4
MA392651Blue Cross Blue Shield of MassachusettsBoston Childrens Hospital2070
MA643651UnitedHealthcareBoston Childrens Hospital237
MA392665Blue Cross Blue Shield of MassachusettsDana-Farber Cancer Institute144
MA76651CignaBoston Childrens Hospital114
MA7651AetnaBoston Childrens Hospital101
MA42665AnthemDana-Farber Cancer Institute6
MA643665UnitedHealthcareDana-Farber Cancer Institute4
MA76665CignaDana-Farber Cancer Institute2
MA7665AetnaDana-Farber Cancer Institute1
MD6431372UnitedHealthcareMedStar Franklin Square Medical Center20
MD441372Blue Cross Blue Shield of Maryland & DC (CareFirst)MedStar Franklin Square Medical Center6
MD441424Blue Cross Blue Shield of Maryland & DC (CareFirst)TidalHealth Peninsula Regional4
MD71424AetnaTidalHealth Peninsula Regional1
MD761372CignaMedStar Franklin Square Medical Center1
MD71372AetnaMedStar Franklin Square Medical Center1
MI493037Blue Cross Blue Shield of MichiganCorewell Health William Beaumont University Hospital261
MI492907Blue Cross Blue Shield of MichiganCorewell Health Butterworth Hospital214
MI492931Blue Cross Blue Shield of MichiganUniversity Hospital192
MI493055Blue Cross Blue Shield of MichiganCorewell Health Beaumont Troy Hospital107
MI6432907UnitedHealthcareCorewell Health Butterworth Hospital53
MI6433037UnitedHealthcareCorewell Health William Beaumont University Hospital48
MI72931AetnaUniversity Hospital40
MI6432931UnitedHealthcareUniversity Hospital28
MI762907CignaCorewell Health Butterworth Hospital21
MI72907AetnaCorewell Health Butterworth Hospital20
MI763037CignaCorewell Health William Beaumont University Hospital15
MI762931CignaUniversity Hospital12
MI6433055UnitedHealthcareCorewell Health Beaumont Troy Hospital11
MI763055CignaCorewell Health Beaumont Troy Hospital9
MI73037AetnaCorewell Health William Beaumont University Hospital8
MI492963Blue Cross Blue Shield of MichiganHenry Ford St John Hospital4
MI73055AetnaCorewell Health Beaumont Troy Hospital2
MI422907AnthemCorewell Health Butterworth Hospital1
MN6433795UnitedHealthcareHennepin County Medical Center73
MN503795Blue Cross Blue Shield of MinnesotaHennepin County Medical Center43
MN763795CignaHennepin County Medical Center9
MN73795AetnaHennepin County Medical Center3
MN4613795Wellmark Blue Cross Blue ShieldHennepin County Medical Center2
MS4563599Blue Cross Blue Shield of MississippiUniversity Hospital427
MS6433599UnitedHealthcareUniversity Hospital293
MS763599CignaUniversity Hospital10
MT1655561Blue Cross Blue Shield of MontanaGreat Falls Clinic Hospital32
MT75561AetnaGreat Falls Clinic Hospital2
NE6434305UnitedHealthcareChildrens Nebraska149
NE514243Blue Cross Blue Shield of NebraskaBryan East Campus147
NE514310Blue Cross Blue Shield of NebraskaMethodist Hospital of Nebraska Methodist Health System106
NE6434243UnitedHealthcareBryan East Campus101
NE514305Blue Cross Blue Shield of NebraskaChildrens Nebraska32
NE4614310Wellmark Blue Cross Blue ShieldMethodist Hospital of Nebraska Methodist Health System23
NE74310AetnaMethodist Hospital of Nebraska Methodist Health System16
NE74243AetnaBryan East Campus15
NE764310CignaMethodist Hospital of Nebraska Methodist Health System8
NE6434310UnitedHealthcareMethodist Hospital of Nebraska Methodist Health System8
NE764305CignaChildrens Nebraska8
NE764243CignaBryan East Campus7
NE514319Blue Cross Blue Shield of NebraskaRegional West Medical Center5
NE764319CignaRegional West Medical Center1
NH42591AnthemDartmouth-Hitchcock Medical Center310
NH42584AnthemConcord Hospital205
NH462591Blue Cross Blue Shield of VermontDartmouth-Hitchcock Medical Center168
NH643591UnitedHealthcareDartmouth-Hitchcock Medical Center114
NH76591CignaDartmouth-Hitchcock Medical Center78
NH42598AnthemElliot Hospital72
NH643584UnitedHealthcareConcord Hospital27
NH76584CignaConcord Hospital25
NH42600AnthemSouthern New Hampshire Medical Center17
NH42592AnthemCheshire Medical Center8
NH76600CignaSouthern New Hampshire Medical Center7
NH76598CignaElliot Hospital6
NH7591AetnaDartmouth-Hitchcock Medical Center5
NH643600UnitedHealthcareSouthern New Hampshire Medical Center5
NH643598UnitedHealthcareElliot Hospital3
NH7584AetnaConcord Hospital2
NH462592Blue Cross Blue Shield of VermontCheshire Medical Center2
NH643592UnitedHealthcareCheshire Medical Center1
NH76592CignaCheshire Medical Center1
NJ2291020Blue Cross Blue Shield of New Jersey (Horizon)Cooper University Hospital2003
NJ2291097Blue Cross Blue Shield of New Jersey (Horizon)Virtua Voorhees Hospital1002
NJ2291061Blue Cross Blue Shield of New Jersey (Horizon)Cooperman Barnabas Medical Center553
NJ6431020UnitedHealthcareCooper University Hospital499
NJ2291056Blue Cross Blue Shield of New Jersey (Horizon)Morristown Medical Center342
NJ6431061UnitedHealthcareCooperman Barnabas Medical Center322
NJ6431097UnitedHealthcareVirtua Voorhees Hospital241
NJ6431065UnitedHealthcareRobert Wood Johnson University Hospital New Brunswick175
NJ2291065Blue Cross Blue Shield of New Jersey (Horizon)Robert Wood Johnson University Hospital New Brunswick139
NJ761056CignaMorristown Medical Center103
NJ71056AetnaMorristown Medical Center82
NJ6431056UnitedHealthcareMorristown Medical Center76
NJ761097CignaVirtua Voorhees Hospital68
NJ761061CignaCooperman Barnabas Medical Center47
NJ561020Blue Cross Blue Shield of Pennsylvania (Independence)Cooper University Hospital35
NJ561097Blue Cross Blue Shield of Pennsylvania (Independence)Virtua Voorhees Hospital31
NJ2291060Blue Cross Blue Shield of New Jersey (Horizon)University Hospital30
NJ761020CignaCooper University Hospital28
NJ761065CignaRobert Wood Johnson University Hospital New Brunswick20
NJ71097AetnaVirtua Voorhees Hospital17
NJ6431060UnitedHealthcareUniversity Hospital8
NJ421056AnthemMorristown Medical Center7
NJ71060AetnaUniversity Hospital4
NJ71061AetnaCooperman Barnabas Medical Center3
NJ71020AetnaCooper University Hospital3
NJ761060CignaUniversity Hospital3
NJ71065AetnaRobert Wood Johnson University Hospital New Brunswick2
NJ421060AnthemUniversity Hospital1
NM1665850Blue Cross Blue Shield of New MexicoCHRISTUS St Vincent Regional Medical Center245
NM1665814Blue Cross Blue Shield of New MexicoCHRISTUS Health Southern New Mexico122
NM1665825Blue Cross Blue Shield of New MexicoPresbyterian Hospital93
NM6435825UnitedHealthcarePresbyterian Hospital70
NM765825CignaPresbyterian Hospital10
NM6435850UnitedHealthcareCHRISTUS St Vincent Regional Medical Center8
NM6435814UnitedHealthcareCHRISTUS Health Southern New Mexico5
NM75814AetnaCHRISTUS Health Southern New Mexico4
NM765850CignaCHRISTUS St Vincent Regional Medical Center4
NM765814CignaCHRISTUS Health Southern New Mexico3
NM425825AnthemPresbyterian Hospital1
NM75850AetnaCHRISTUS St Vincent Regional Medical Center1
NV766057CignaCarson Tahoe Regional Medical Center3
NV6436057UnitedHealthcareCarson Tahoe Regional Medical Center2
OH6432412UnitedHealthcareCleveland Clinic Main Campus696
OH72412AetnaCleveland Clinic Main Campus162
OH762412CignaCleveland Clinic Main Campus136
OH6432378UnitedHealthcareUniversity of Cincinnati Medical Center76
OH762376CignaCincinnati Childrens Burnet Campus68
OH72376AetnaCincinnati Childrens Burnet Campus61
OH6432376UnitedHealthcareCincinnati Childrens Burnet Campus53
OH762378CignaUniversity of Cincinnati Medical Center53
OH72378AetnaUniversity of Cincinnati Medical Center36
OH422412AnthemCleveland Clinic Main Campus8
OH4612412Wellmark Blue Cross Blue ShieldCleveland Clinic Main Campus3
OK534827Blue Cross Blue Shield of OklahomaOklahoma Heart Hospital North132
OK6434827UnitedHealthcareOklahoma Heart Hospital North15
OK534926Blue Cross Blue Shield of OklahomaStillwater Medical Center6
OK764827CignaOklahoma Heart Hospital North4
PA1741106Highmark Blue Cross Blue ShieldLehigh Valley Hospital - Cedar Crest2171
PA541106Blue Cross Blue Shield of Pennsylvania (Capital Blue Cross)Lehigh Valley Hospital - Cedar Crest1099
PA6431106UnitedHealthcareLehigh Valley Hospital - Cedar Crest393
PA761106CignaLehigh Valley Hospital - Cedar Crest131
PA6431279UnitedHealthcareTemple University Hospital122
PA561279Blue Cross Blue Shield of Pennsylvania (Independence)Temple University Hospital19
PA2291279Blue Cross Blue Shield of New Jersey (Horizon)Temple University Hospital15
PA761279CignaTemple University Hospital11
PA71279AetnaTemple University Hospital3
PA71106AetnaLehigh Valley Hospital - Cedar Crest1
RI397741Blue Cross Blue Shield of Rhode IslandSouth County Hospital2
SC1681854Blue Cross Blue Shield of South CarolinaLexington Medical Center967
SC6431854UnitedHealthcareLexington Medical Center59
SC761854CignaLexington Medical Center20
SC6431824UnitedHealthcarePrisma Health Greenville Memorial Hospital4
SC71808AetnaPrisma Health Richland Hospital3
SC6431808UnitedHealthcarePrisma Health Richland Hospital3
SC71824AetnaPrisma Health Greenville Memorial Hospital2
SC421808AnthemPrisma Health Richland Hospital1
SC761808CignaPrisma Health Richland Hospital1
SC761824CignaPrisma Health Greenville Memorial Hospital1
SC511824Blue Cross Blue Shield of NebraskaPrisma Health Greenville Memorial Hospital1
SD4614222Wellmark Blue Cross Blue ShieldAvera McKennan Hospital & University Health Center12
SD6434222UnitedHealthcareAvera McKennan Hospital & University Health Center4
SD4614177Wellmark Blue Cross Blue ShieldAvera St Lukes Hospital1
SD4614234Wellmark Blue Cross Blue ShieldAvera Sacred Heart Hospital1
TN763432CignaMethodist University Hospital295
TN6433432UnitedHealthcareMethodist University Hospital266
TN3983432Blue Cross Blue Shield of TennesseeMethodist University Hospital262
TN3983471Blue Cross Blue Shield of TennesseeWest Tennessee Healthcare Jackson-Madison County General Hospital32
TN763372CignaErlanger Baroness Hospital21
TN3983372Blue Cross Blue Shield of TennesseeErlanger Baroness Hospital17
TN6433471UnitedHealthcareWest Tennessee Healthcare Jackson-Madison County General Hospital17
TN763471CignaWest Tennessee Healthcare Jackson-Madison County General Hospital10
TN763351CignaCHI Memorial Hospital Chattanooga5
TN73372AetnaErlanger Baroness Hospital3
TN6433372UnitedHealthcareErlanger Baroness Hospital2
TN423372AnthemErlanger Baroness Hospital1
TX1695297Blue Cross Blue Shield of TexasWilliam P Clements Jr University Hospital1595
TX6435297UnitedHealthcareWilliam P Clements Jr University Hospital222
TX765297CignaWilliam P Clements Jr University Hospital124
TX75297AetnaWilliam P Clements Jr University Hospital76
TX425297AnthemWilliam P Clements Jr University Hospital2
TX3895297Blue Cross Blue Shield of IllinoisWilliam P Clements Jr University Hospital1
VA421523AnthemSentara Norfolk General Hospital267
VA421517AnthemRiverside Regional Medical Center95
VA6431523UnitedHealthcareSentara Norfolk General Hospital72
VA761523CignaSentara Norfolk General Hospital30
VA6431517UnitedHealthcareRiverside Regional Medical Center22
VA761517CignaRiverside Regional Medical Center8
VA71523AetnaSentara Norfolk General Hospital6
VA521523Blue Cross Blue Shield of North CarolinaSentara Norfolk General Hospital2
VA3881523Blue Cross Blue Shield of Florida (Florida Blue)Sentara Norfolk General Hospital1
VA4611523Wellmark Blue Cross Blue ShieldSentara Norfolk General Hospital1
VT462610Blue Cross Blue Shield of VermontThe University of Vermont Medical Center2
VT462625Blue Cross Blue Shield of VermontMt Ascutney Hospital and Health Center1
WA616163Regence Blue Cross Blue ShieldSeattle Childrens Hospital762
WA6286163Premera Blue CrossSeattle Childrens Hospital586
WA6436165UnitedHealthcareHarborview Medical Center402
WA6436163UnitedHealthcareSeattle Childrens Hospital372
WA616171Regence Blue Cross Blue ShieldUW Medical Center - Montlake309
WA6286165Premera Blue CrossHarborview Medical Center180
WA616165Regence Blue Cross Blue ShieldHarborview Medical Center175
WA6286171Premera Blue CrossUW Medical Center - Montlake146
WA6436171UnitedHealthcareUW Medical Center - Montlake132
WA766171CignaUW Medical Center - Montlake35
WA766163CignaSeattle Childrens Hospital34
WA76163AetnaSeattle Childrens Hospital18
WA766165CignaHarborview Medical Center14
WA76171AetnaUW Medical Center - Montlake1
WA76165AetnaHarborview Medical Center1
WI6433200UnitedHealthcareFroedtert Hospital399
WI423200AnthemFroedtert Hospital326
WI423121AnthemBellin Hospital Green Bay7
WI6433121UnitedHealthcareBellin Hospital Green Bay7
WV1741630Highmark Blue Cross Blue ShieldWVU Medicine Wheeling Hospital1
WY6435681UnitedHealthcareBanner Wyoming Medical Center25
WY4645688Blue Cross Blue Shield of WyomingCampbell County Memorial Hospital4
WY765681CignaBanner Wyoming Medical Center2

Full List of Top 10 Hospitals by State

Code
all_candidates = pd.read_sql(f"""
WITH
provider_names AS (
SELECT
DISTINCT
provider_id,
provider_name
FROM tq_production.spines.spines_provider_hospitals
),
payer_names AS (
SELECT
DISTINCT
payer_id,
payer_name
FROM tq_production.spines.spines_payer
),
ranked AS (
SELECT
state,
provider_id,
ROW_NUMBER() OVER (PARTITION BY state ORDER BY provider_net_patient_revenue_state_rank ASC) AS rn
FROM tq_dev.internal_dev_csong_cld_v2_3_1.prod_rollup_provider
),
top_providers AS (
SELECT *
FROM ranked
WHERE rn <= 10
AND state NOT IN ('VI', 'PR')
)
SELECT
tp.state,
tp.provider_id,
pn.provider_name
FROM top_providers tp
LEFT JOIN provider_names pn
ON tp.provider_id = pn.provider_id
WHERE pn.provider_name IS NOT NULL
ORDER BY 1, tp.provider_id
""", con=trino_conn)
print(all_candidates.to_markdown(index=False))
all_candidates.to_excel('all_top_providers_candidates.xlsx', index=False)
Results
stateprovider_idprovider_name
AK6695Alaska Regional Hospital
AK6696Providence Alaska Medical Center
AK6697Samuel Simmonds Memorial Hospital
AK6701Fairbanks Memorial Hospital
AK6703Bartlett Regional Hospital
AK6705PeaceHealth Ketchikan Medical Center
AK6711Mat-Su Regional Medical Center
AL3482Mobile Infirmary
AL3509Grandview Medical Center
AL3510Childrens of Alabama
AL3519UAB St Vincents Birmingham
AL3520UAB Hospital
AL3531Southeast Health Medical Center
AL3554Huntsville Hospital
AL3566Baptist Medical Center South
AL3568East Alabama Medical Center - Opelika
AL3584DCH Regional Medical Center
AR4498Northwest Medical Center - Springdale
AR4539Washington Regional Medical Center
AR4542Mercy Hospital Fort Smith
AR4543Baptist Health - Fort Smith
AR4553St Bernards Medical Center
AR4556Baptist Health Medical Center - Little Rock
AR4557Arkansas Childrens Hospital
AR4560CHI St Vincent Infirmary
AR4561University of Arkansas for Medical Sciences Medical Center
AR4581Mercy Hospital Northwest Arkansas
AZ5871Banner Thunderbird Medical Center
AZ5872Banner Desert Medical Center
AZ5875Mayo Clinic Hospital - Arizona
AZ5876Tucson Medical Center
AZ5882Chandler Regional Medical Center
AZ5910Phoenix Childrens Hospital
AZ5919Banner - University Medical Center Phoenix
AZ5924City of Hope Phoenix
AZ5927St Josephs Hospital and Medical Center
AZ5960Banner - University Medical Center Tucson
CA6287UCSF Helen Diller Medical Center at Parnassus Heights
CA6394Cedars-Sinai Medical Center
CA6404Helford Clinical Research Hospital
CA6497Los Angeles General Medical Center
CA6504Ronald Reagan UCLA Medical Center
CA6546Stanford University Hospital
CA6577University of California Davis Medical Center
CA6593UC San Diego Medical Center
CA6615Santa Clara Valley Medical Center
CA6646Lucile Packard Childrens Hospital Stanford
CO5717UCHealth Poudre Valley Hospital
CO5722HCA HealthONE Sky Ridge
CO5744UCHealth Memorial Hospital Central
CO5749Childrens Hospital Colorado - Anschutz Medical Campus
CO5750Denver Health Main Campus
CO5754HCA HealthONE Presbyterian St Lukes
CO5756Intermountain Health Saint Joseph Hospital
CO5759UCHealth University of Colorado Hospital
CO5766HCA HealthONE Swedish
CO7368Penrose Hospital
CT68The Hospital of Central Connecticut - Bradley Memorial Campus
CT746Bridgeport Hospital
CT747Hartford Hospital
CT748Saint Francis Hospital and Medical Center
CT752Stamford Hospital
CT753St Vincents Medical Center
CT758Danbury Hospital
CT760Greenwich Hospital
CT761UConn John Dempsey Hospital
CT769Yale New Haven Hospital
DC1432Childrens National Hospital
DC1433Howard University Hospital
DC1434MedStar Washington Hospital Center
DC1435MedStar Georgetown University Hospital
DC1436The George Washington University Hospital
DC1438MedStar National Rehabilitation Hospital
DC1441Sibley Memorial Hospital
DC1442United Medical Center
DE10065PAM Rehabilitation Hospital of Dover
DE1350Bayhealth Hospital - Kent Campus
DE1355Beebe Healthcare - Margaret H Rollins Lewes Campus
DE1356TidalHealth Nanticoke
DE1357Nemours Childrens Hospital - Delaware
DE1358Christiana Hospital
DE1359Saint Francis Hospital
DE1362Encompass Health Rehabilitation Hospital of Middletown
DE71Bayhealth Hospital - Sussex Campus
DE9484PAM Health Rehabilitation Hospital of Georgetown
FL2055St Josephs Hospital
FL2131UF Health Shands Hospital
FL2135Memorial Regional Hospital
FL2140Baptist Medical Center Jacksonville
FL2180Jackson Memorial Hospital
FL2181Baptist Hospital
FL2201AdventHealth Orlando
FL2203Orlando Health Orlando Regional Medical Center
FL2250Tampa General Hospital
FL2251Moffitt Cancer Center Magnolia Campus
GA1862Northeast Georgia Medical Center Gainesville
GA1864Arthur M Blank Hospital
GA1880Emory University Hospital Midtown
GA1882Grady Memorial Hospital
GA1883Northside Hospital Atlanta
GA1884Piedmont Atlanta Hospital
GA1905Northside Hospital Gwinnett
GA1933City of Hope Atlanta cancer hospital
GA1952Emory University Hospital
GA1975Wellstar Kennestone Regional Medical Center
HI6719Pali Momi Medical Center
HI6721Hilo Benioff Medical Center Main
HI6727Wilcox Medical Center
HI6731Maui Memorial Medical Center
HI6734Kaiser Permanente Moanalua Medical Center
HI6735Kapiolani Medical Center for Women & Children
HI6737Kuakini Medical Center
HI6739Queens Medical Center
HI6741Straub Medical Center
HI6744Adventist Health Castle
IA3854MercyOne North Iowa Medical Center
IA3855MercyOne Des Moines Medical Center
IA3856MercyOne Genesis Davenport Medical Center
IA3869Southeast Iowa Regional Medical Center - West Burlington Campus
IA3872Mercy Medical Center - Cedar Rapids
IA3873UnityPoint Health St Lukes Hospital
IA3894Iowa Methodist Medical Center
IA3919University of Iowa Hospitals & Clinics
IA3968Allen Hospital
IA3969MercyOne Waterloo Medical Center
ID5624Portneuf Medical Center
ID5625Mountain View Hospital
ID5632Bingham Memorial Hospital
ID5639Saint Alphonsus Regional Medical Center
ID5640St Lukes Boise Medical Center
ID5646Kootenai Health
ID5653Eastern Idaho Regional Medical Center
ID5662Saint Alphonsus Medical Center - Nampa
ID5672St Lukes Magic Valley Medical Center
ID5675St Lukes Nampa Medical Center
IL2692Northwestern Medicine Central DuPage Hospital
IL2694Evanston Hospital
IL2728Advocate Lutheran General Hospital
IL2733Northwestern Memorial Hospital
IL2745Loyola University Medical Center
IL2750Rush University Medical Center
IL2765Uchicago Medicine Mitchell Hospital - Hyde Park
IL2851Advocate Christ Medical Center
IL2863OSF Saint Francis Medical Center
IL2888Carle Foundation Hospital
IN2530Community Hospital North
IN2532Ascension St Vincent Evansville
IN2533Franciscan Health Indianapolis
IN2589Deaconess Midtown Hospital
IN2614Community Hospital East
IN2618Ascension St Vincent Hospital - Indianapolis
IN2641Community Hospital
IN2660Memorial Hospital of South Bend
IN2666Union Hospital
IN6845IU Health Methodist Hospital
KS4349Ascension Via Christi St Francis
KS4351Menorah Medical Center
KS4420The University of Kansas Hospital
KS4428Lawrence Memorial Hospital
KS4451Olathe Medical Center
KS4455Overland Park Regional Medical Center
KS4457AdventHealth Shawnee Mission
KS4477The University of Kansas Health System St Francis Campus
KS4478Stormont Vail Hospital
KS4487Wesley Medical Center
KY10320St Elizabeth Covington Hospital
KY3215Owensboro Health Regional Hospital
KY3229Kings Daughters Medical Center
KY3266Baptist Health Louisville
KY3271Baptist Health Lexington
KY3277UK Albert B Chandler Hospital
KY3282Norton Hospital
KY3284UofL Health - Jewish Hospital
KY3286UofL Hospital
KY3313Pikeville Medical Center
LA4603University Medical Center New Orleans
LA4604Our Lady of the Lake Regional Medical Center
LA4609Baton Rouge General Medical Center - Bluebonnet Campus
LA4641Womans Hospital
LA4667St Tammany Health System
LA4704Ochsner Lafayette General Medical Center
LA4705Our Lady of Lourdes Regional Medical Center
LA4755Manning Family Childrens
LA4756Ochsner Medical Center - Main Campus
LA4782Willis-Knighton Medical Center
MA632Boston Medical Center
MA635Beth Israel Deaconess Medical Center
MA636Charlton Memorial Hospital
MA646Brigham and Womens Hospital
MA651Boston Childrens Hospital
MA658Massachusetts General Hospital
MA665Dana-Farber Cancer Institute
MA673Lahey Hospital & Medical Center - Burlington
MA687UMass Memorial Medical Center - University Campus
MA714Baystate Medical Center
MD1369Luminis Health Anne Arundel Medical Center
MD1370Johns Hopkins Bayview Medical Center
MD1372MedStar Franklin Square Medical Center
MD1377The Johns Hopkins Hospital
MD1381Mercy Medical Center
MD1382Ascension Saint Agnes Hospital
MD1384Sinai Hospital
MD1387University of Maryland Medical Center
MD1424TidalHealth Peninsula Regional
MD1425Holy Cross Hospital
ME541MaineHealth Mid Coast Hospital
ME545Northern Light Eastern Maine Medical Center
ME546St Joseph Hospital of ME
ME560Central Maine Medical Center
ME561MaineHealth Maine Medical Center Biddeford
ME562St Marys Health System
ME568MaineHealth Maine Medical Center Portland
ME575MaineGeneral Medical Center - Alfond Center for Health
ME578York Hospital
ME8047Northern Light Mercy Hospital - Fore River Campus
MI2907Corewell Health Butterworth Hospital
MI2930Trinity Health Ann Arbor Hospital
MI2931University Hospital
MI2959Henry Ford Hospital
MI2963Henry Ford St John Hospital
MI2999Bronson Methodist Hospital
MI3003UM Health - Sparrow Lansing
MI3037Corewell Health William Beaumont University Hospital
MI3055Corewell Health Beaumont Troy Hospital
MI9942Henry Ford Providence Southfield
MN3710M Health Fairview University of Minnesota Medical Center - West Bank East
MN3722Mercy Hospital
MN3757Childrens Minnesota Hospital - Minneapolis
MN3758Mayo Clinic Hospital - Saint Marys Campus
MN3789Abbott Northwestern Hospital
MN3791Methodist Hospital
MN3795Hennepin County Medical Center
MN3821CentraCare - St Cloud Hospital
MN3824Regions Hospital
MN3826United Hospital
MO4020University Hospital
MO4042Childrens Mercy Adele Hall Campus
MO4051Saint Lukes Hospital of Kansas City
MO4082Barnes-Jewish Hospital
MO4086SSM Health St Marys Hospital - St Louis
MO4088SSM Health Saint Louis University Hospital
MO4093Mercy Hospital St Louis
MO4094St Louis Childrens Hospital
MO4102Cox Medical Center South
MO4103Mercy Hospital Springfield
MS3597Baptist Memorial Hospital - Golden Triangle
MS3599University Hospital
MS3602Mississippi Baptist Medical Center
MS3612Pascagoula Hospital
MS3645Memorial Hospital Gulfport
MS3646Forrest General Hospital
MS3656St Dominic Hospital
MS3680Baptist Memorial Hospital - North Mississippi
MS3691North Mississippi Medical Center - Tupelo
MS3699Baptist Memorial Hospital - DeSoto
MT5557Benefis Hospital - East Campus
MT5560Logan Health Medical Center
MT5561Great Falls Clinic Hospital
MT5565Billings Clinic Hospital
MT5566St Vincent Regional Hospital
MT5567Bozeman Health Deaconess Regional Medical Center
MT5569St James Healthcare
MT5592St Peters Health Regional Medical Center
MT5601Community Medical Center
MT5602Providence St Patrick Hospital
NC1635Cone Health Moses Cone Hospital
NC1644Novant Health New Hanover Regional Medical Center
NC1663UNC Medical Center
NC1664Atrium Health Carolinas Medical Center
NC1666Novant Health Presbyterian Medical Center
NC1670Duke University Hospital
NC1693ECU Health Medical Center
NC1731UNC Rex Hospital
NC1762Novant Health Forsyth Medical Center
NC1765Atrium Health Wake Forest Baptist Medical Center
ND4125Altru Hospital
ND4126Essentia Health - Fargo
ND4127Trinity Hospital
ND4134Sanford Medical Center Bismarck
ND4135CHI St Alexius Health Bismarck Medical Center
ND4144CHI St Alexius Health Dickinson Medical Center
ND4154Jamestown Regional Medical Center
ND4173CHI St Alexius Health Williston Medical Center
ND7712Sanford Broadway Medical Center
ND8702PAM Rehabilitation Hospital of Fargo
NE4240Faith Regional Health Services
NE4242Nebraska Medical Center
NE4243Bryan East Campus
NE4246CHI Health Lakeside
NE4283Mary Lanning Memorial Hospital
NE4302Great Plains Health
NE4305Childrens Nebraska
NE4310Methodist Hospital of Nebraska Methodist Health System
NE4311CHI Health Creighton University Medical Center - Bergan Mercy
NE4319Regional West Medical Center
NH579Portsmouth Regional Hospital
NH584Concord Hospital
NH586Wentworth-Douglass Hospital
NH588Exeter Hospital
NH591Dartmouth-Hitchcock Medical Center
NH592Cheshire Medical Center
NH596Catholic Medical Center
NH598Elliot Hospital
NH600Southern New Hampshire Medical Center
NH601St Joseph Hospital of NH
NJ1020Cooper University Hospital
NJ1032Englewood Hospital and Medical Center
NJ1035Hackensack University Medical Center
NJ1056Morristown Medical Center
NJ1058Jersey Shore University Medical Center
NJ1060University Hospital
NJ1061Cooperman Barnabas Medical Center
NJ1065Robert Wood Johnson University Hospital New Brunswick
NJ1080The Valley Hospital
NJ1097Virtua Voorhees Hospital
NM5814CHRISTUS Health Southern New Mexico
NM5817MountainView Regional Medical Center
NM5824University of New Mexico Hospital
NM5825Presbyterian Hospital
NM5826Lovelace Medical Center
NM5836San Juan Regional Medical Center
NM5842Memorial Medical Center
NM5846Nor-Lea Hospital District
NM5850CHRISTUS St Vincent Regional Medical Center
NM5863Lovelace Womens Hospital
NV6043Summerlin Hospital Medical Center
NV6044MountainView Hospital
NV6045Dignity Health St Rose Dominican - Siena Campus
NV6049Spring Valley Hospital Medical Center
NV6057Carson Tahoe Regional Medical Center
NV6074Sunrise Hospital & Medical Center
NV6075University Medical Center
NV6077Valley Hospital Medical Center
NV6086Renown Regional Medical Center
NV6092Henderson Hospital
NY794NewYork-Presbyterian Weill Cornell Medical Center
NY876Long Island Jewish Medical Center
NY897North Shore University Hospital
NY919NYC Langone Tisch Hospital
NY924Memorial Sloan Kettering Cancer Center
NY926Montefiore Hospital - Moses Campus
NY927The Mount Sinai Hospital
NY964Strong Memorial Hospital
NY978Stony Brook University Hospital
NY989Westchester Medical Center
OH2295The James Cancer Hospital and Solove Research Institute
OH2376Cincinnati Childrens Burnet Campus
OH2378University of Cincinnati Medical Center
OH2412Cleveland Clinic Main Campus
OH2419University Hospitals Cleveland Medical Center
OH2422Nationwide Childrens Hospital
OH2428Ohio State University Wexner Medical Center
OH2429OhioHealth Riverside Methodist Hospital
OH2436Miami Valley Hospital
OH2499ProMedica Toledo Hospital
OK4827Oklahoma Heart Hospital North
OK4888Comanche County Memorial Hospital
OK4904INTEGRIS Baptist Medical Center
OK4907Mercy Hospital Oklahoma City
OK4909SSM Health St Anthony Hospital - Oklahoma City
OK4926Stillwater Medical Center
OK4934Hillcrest Medical Center
OK4936Saint Francis Hospital
OK4937Ascension St John Medical Center
OK8859OU Health - University of Oklahoma Medical Center
OR6204Legacy Emanuel Medical Center
OR6212PeaceHealth Sacred Heart Medical Center at RiverBend
OR6215St Charles Bend
OR6218Good Samaritan Regional Medical Center
OR6238Asante Rogue Regional Medical Center
OR6247Legacy Good Samaritan Medical Center
OR6250Providence Portland Medical Center
OR6251Providence St Vincent Medical Center
OR6253OHSU Hospital - Portland
OR6261Salem Hospital
PA1106Lehigh Valley Hospital - Cedar Crest
PA1115UPMC Presbyterian
PA1120Thomas Jefferson University Hospital
PA1124St Lukes University Hospital - Bethlehem
PA1191Geisinger Medical Center
PA1206Penn State Health Milton S Hershey Medical Center
PA1263Childrens Hospital of Philadelphia
PA1267Hospital of the University of Pennsylvania
PA1279Temple University Hospital
PA1341WellSpan York Hospital
RI733Newport Hospital
RI734Our Lady of Fatima Hospital
RI736Miriam Hospital
RI737Women & Infants Hospital
RI738Rhode Island Hospital
RI739Roger Williams Medical Center
RI741South County Hospital
RI742Landmark Medical Center
RI743Kent Hospital
RI744Westerly Hospital
SC1774McLeod Regional Medical Center
SC1790AnMed Health Medical Center
SC1808Prisma Health Richland Hospital
SC1815Trident Medical Center
SC1824Prisma Health Greenville Memorial Hospital
SC1825St Francis Downtown
SC1838Grand Strand Medical Center
SC1847Spartanburg Medical Center
SC1854Lexington Medical Center
SC9730Medical University of South Carolina Medical Center
SD4175Monument Health Rapid City Hospital
SD4176Avera Queen of Peace Hospital
SD4177Avera St Lukes Hospital
SD4179Sanford USD Medical Center
SD4180Avera Heart Hospital
SD4182Sioux Falls Specialty Hospital
SD4222Avera McKennan Hospital & University Health Center
SD4225Monument Health Spearfish Hospital
SD4231Prairie Lakes Healthcare System
SD4234Avera Sacred Heart Hospital
TN3339TriStar Centennial Medical Center
TN3351CHI Memorial Hospital Chattanooga
TN3372Erlanger Baroness Hospital
TN3404Johnson City Medical Center
TN3414The University of Tennessee Medical Center
TN3427Baptist Memorial Hospital - Memphis
TN3432Methodist University Hospital
TN3447Ascension Saint Thomas West
TN3448Vanderbilt University Medical Center
TN3471West Tennessee Healthcare Jackson-Madison County General Hospital
TX5256Childrens Medical Center Dallas
TX5297William P Clements Jr University Hospital
TX5357Cook Childrens Medical Center
TX5390Memorial Hermann - Texas Medical Center
TX5394University of Texas MD Anderson Cancer Center
TX5396Houston Methodist Hospital
TX5402Texas Childrens Hospital
TX5502Methodist Hospital
TX5522Baylor Scott & White Medical Center - Temple
TX7279Memorial Hermann Southwest Hospital
UT5994Logan Regional Hospital
UT6000Intermountain Medical Center
UT6003McKay-Dee Hospital
UT6008Utah Valley Hospital
UT6011St George Regional Hospital
UT6012LDS Hospital
UT6014Primary Childrens Hospital - Salt Lake City
UT6015St Marks Hospital
UT6016Holy Cross Hospital - Jordan Valley
UT6018University of Utah Hospital
VA1453Centra Lynchburg General Hospital
VA1513Inova Fairfax Hospital
VA1517Riverside Regional Medical Center
VA1523Sentara Norfolk General Hospital
VA1538VCU Medical Center Main Hospital
VA1541St Marys Hospital
VA1544Carilion Roanoke Memorial Hospital
VA1559Winchester Medical Center
VA1564University Hospital
VA6871Johnston-Willis Hospital
VT610The University of Vermont Medical Center
VT611Central Vermont Medical Center
VT612Southwestern Vermont Medical Center
VT613Brattleboro Memorial Hospital
VT618Gifford Medical Center
VT619Rutland Regional Medical Center
VT620Northwestern Medical Center
VT622Springfield Hospital
VT623Grace Cottage Hospital
VT625Mt Ascutney Hospital and Health Center
WA6099Providence Regional Medical Center Everett - Colby Campus
WA6101Swedish Medical Center - First Hill Campus
WA6159Valley Medical Center
WA6163Seattle Childrens Hospital
WA6165Harborview Medical Center
WA6171UW Medical Center - Montlake
WA6172Virginia Mason Medical Center
WA6181Providence Sacred Heart Medical Center
WA6186MultiCare Tacoma General Hospital
WA6193PeaceHealth Southwest Medical Center
WI3067Aurora St Lukes Medical Center of Aurora Health Care Metro
WI3113Mayo Clinic Health System - Eau Claire
WI3121Bellin Hospital Green Bay
WI3124HSHS St Vincent Hospital
WI3132Gundersen Lutheran Medical Center
WI3139UW Health University Hospital
WI3142Marshfield Medical Center - Marshfield
WI3150Childrens Wisconsin
WI3199Aspirus Wausau Hospital
WI3200Froedtert Hospital
WV1572JW Ruby Memorial Hospital
WV1585United Hospital Center
WV1594Cabell Huntington Hospital
WV1597St Marys Medical Center
WV1604Berkeley Medical Center
WV1607Mon Health Medical Center
WV1610Camden Clark Medical Center - Memorial Campus
WV1615Princeton Community Hospital
WV1621Thomas Health - Thomas Memorial Hospital
WV1630WVU Medicine Wheeling Hospital
WY5676Cheyenne Regional Medical Center - West Campus
WY5681Banner Wyoming Medical Center
WY5684Cody Regional Health
WY5688Campbell County Memorial Hospital
WY5690St Johns Health
WY5692Ivinson Memorial Hospital
WY5696Powell Valley Healthcare
WY5698Memorial Hospital of Sweetwater County
WY5699SageWest - Riverton
WY5700Sheridan Memorial Hospital

Limitations:

  • Remits table has payer-level specificity but not network-level
  • Stoploss applies to outliers and outliers are rare
  • Unclear methodology to calculate claim-level total allowed amounts and total charges
    • if we need to use total_claim_charge_amount from medical_headers, then remits table adds 0 value