Contract Methodology
Goal: We want to map each roid to a contract methodology. In this
version, we rely on MRF representation of contract methodology in either the
contract_methodology field of hospital MRF data or negotiated_type in payer
MRF data.
"Contract methodology" may be one of:
- per diem
- fee schedule
- case rate
- percent of total billed charges
For some contract_methodology and negotiated_type values, we are not able to
cleanly map them to one of the defined categories. For example, contract_methodology
may be NULL or "other" and payer_negotiated may be "negotiated" or "derived".
We do not need to map every roid to a contract methodology, but a large fraction
of our rates have payer_negotiated = 'negotiated' (over 30%). So we rely on
whether the code is a surgery code to determine if it's a case rate or fee schedule.
Code:​
First create a dictionary mapping each rate column to a contract methodology.
{% set methodology_mapping = {} %}
{% for col in hospital_raw_cols + payer_raw_cols + allowed_amounts +
hospital_transformation_cols + payer_transformation_cols + imputation_cols %}
{% if 'case_rate' in col or 'base_rate' in col or 'cstm_negotiated_rate' in col %}
{% set _ = methodology_mapping.update({col: "Case Rate"}) %}
{% endif %}
{% if
('hospital_perc' in col) or
('payer_' in col and 'perc_to_dol' in col) or
('cstm_' in col and 'perc_to_dol' in col) or
('rc_' in col and 'perc_to_dol' in col)
%}
{% set _ = methodology_mapping.update({col: "Percent of Total Billed Charges"}) %}
{% endif %}
{% if 'fee_schedule' in col %}
{% set _ = methodology_mapping.update({col: "Fee Schedule"}) %}
{% endif %}
{% endfor %}
If a column is not in the mapping above, we use the following logic:
- If
payer_negotiatedorpayer_derivedandis_surg_code = True, then "Case Rate" - If
payer_negotiatedorpayer_derivedandis_surg_code = False, then "Fee Schedule" - If
per_diemand `bill_type NOT IN ('Inpatient'), then "Case Rate" - If
per_diemand `bill_type IN ('Inpatient'), then "Per Diem" - Else "Unknown"
{% for c in (rate_cols) %}
{% if c in methodology_mapping %}
'{{ methodology_mapping[c] }}'
{% else %}
CASE
WHEN {{ 'payer_negotiated' in c or 'payer_derived' in c }} AND is_surg_code = True
THEN 'Case Rate'
WHEN {{ 'payer_negotiated' in c or 'payer_derived' in c }} AND COALESCE(is_surg_code, False) = False
THEN 'Fee Schedule'
WHEN {{ 'per_diem' in c }} AND c.bill_type NOT IN ('Inpatient')
THEN 'Case Rate'
WHEN {{ 'per_diem' in c }} AND c.bill_type IN ('Inpatient')
THEN 'Per Diem'
ELSE 'Unknown'
END
{% endif %}
{% if not loop.last %}, {% endif %}
{% endfor %}