Processing Medicare Claims via API in Python¶
While the Bedrock Billing Web Application is excellent for manual review, the true power of the platform lies in its Myelin calculation engine. By integrating directly with the Claims Processing API, you can automate pricing, group assignment, and code editing seamlessly within your own backend or EHR system.
In this tutorial, we will write a Python script that submits a raw Inpatient claim to the API, runs it through the Medicare Code Editor (MCE) and MS-DRG Grouper, and finally prices it under the Inpatient Prospective Payment System (IPPS).
Prerequisites¶
- Python 3.7+
- The
requestslibrary (pip install requests) - A valid Bedrock Billing API Key (Retrieve this from your Organization Dashboard).
Step 1: Constructed the Claim Payload¶
The /myelin/process/pps endpoint expects a standardized JSON Claim object. The most important field is the modules array—this tells the engine exactly which pipelines to route the claim through.
Since we are doing an inpatient stay, our modules are ["MCE", "MSDRG", "IPPS"].
Create a file named price_claim.py:
import requests
import json
API_KEY = "sk_live_your_api_key_here"
BASE_URL = "https://api.bedrockbilling.com/api/v1"
# Define our standardized Claim object
claim_payload = {
"claimid": "INPATIENT-DEMO-001",
"modules": ["MCE", "MSDRG", "IPPS"],
"from_date": "2025-01-01",
"thru_date": "2025-01-05",
"admit_date": "2025-01-01",
"bill_type": "111", # 111 = Hospital Inpatient Part A
"patient_status": "01", # 01 = Discharged to home/self-care
"total_charges": 15000.00,
"principal_dx": {
"code": "I50.21", # Acute systolic (congestive) heart failure
"poa": "Y" # Present on Admission
},
"billing_provider": {
"npi": "1234567890",
"other_id": "123456", # The facility's CMS Certification Number (CCN)
"additional_data": {
"ipsf": {
# We can optionally override the CMS Provider Specific File (PSF) limits
"operating_cost_to_charge_ratio": 0.25
}
}
}
}
Step 2: Submitting the Request¶
Next, we will issue a POST request to the API. The API uses standard Bearer token authentication.
headers = {
"Authorization": f"X-API-Key {API_KEY}",
"Content-Type": "application/json"
}
print("Submitting claim to Bedrock Billing Myelin Engine...")
response = requests.post(
f"{BASE_URL}/myelin/process/pps",
headers=headers,
json=claim_payload
)
if response.status_code == 200:
print("Claim processed successfully!")
else:
print(f"Error {response.status_code}: {response.text}")
exit(1)
Step 3: Parsing the Response¶
The API responds with a structured MyelinOutput object containing the results for each module requested. Since we asked for MS-DRG and IPPS, we can extract the grouped DRG and the final payment calculations.
result = response.json()
# 1. Inspect the Grouper Output
drg_info = result.get("msdrg", {})
print("\n--- MS-DRG Grouper Results ---")
print(f"Assigned DRG: {drg_info.get('drg')} ({drg_info.get('description')})")
print(f"Relative Weight: {drg_info.get('weight')}")
# 2. Inspect the Pricer Output
ipps_info = result.get("ipps", {})
print("\n--- IPPS Pricing Results ---")
print(f"Base Federal Payment: ${ipps_info.get('federal_payment', 0):,.2f}")
print(f"Outlier Payment: ${ipps_info.get('outlier_payment', 0):,.2f}")
print(f"Capital Payment: ${ipps_info.get('capital_payment', 0):,.2f}")
print(f"Total Reimbursement: ${ipps_info.get('total_payment', 0):,.2f}")
Running the Code¶
When you execute this script (python price_claim.py), it will hit the Bedrock Billing API and return sub-second pricing logic based on current CMS regulations:
Submitting claim to Bedrock Billing Myelin Engine...
Claim processed successfully!
--- MS-DRG Grouper Results ---
Assigned DRG: 291 (HEART FAILURE & SHOCK W MCC)
Relative Weight: 1.2345
--- IPPS Pricing Results ---
Base Federal Payment: $11,000.00
Outlier Payment: $0.00
Capital Payment: $1,500.50
Total Reimbursement: $12,500.50
Next Steps¶
This exact same architecture applies to processing Outpatient claims (OPPS, IOCE), Skilled Nursing (SNF), or Home Health (HHAG, HHA). Simply adjust the modules array and provide the context-specific fields (like lines for outpatient, or oasis_assessment for Home Health).