Skip to content

Instantly share code, notes, and snippets.

@spenthil
Created April 19, 2012 08:15
Show Gist options
  • Save spenthil/2419577 to your computer and use it in GitHub Desktop.
Save spenthil/2419577 to your computer and use it in GitHub Desktop.
claim submission "Blue Shield California" or "Blue Cross of California"
import requests
from datetime import datetime
import re
from counsyl.product.billing.models import InsurancePayer
def filing_blue_payer(payer_name, date=None):
try:
prefix = InsurancePayer.objects.get(name=payer_name).member_id_regexes.all()[0].regex
except IndexError:
return "no prefixes :("
date = date or datetime.now()
url = "https://www.blueshieldca.com/provider/claims/submit/home.sp?formToken=&claimsRoutingTool=true&prefix={prefix}&serviceDate={month}%2F{day}%2F{year}&alphaPrefix.x=0&alphaPrefix.y=0".format(
day=date.strftime("%d"),
month=date.strftime("%m"),
year=date.strftime("%Y"),
prefix=prefix.upper(),
)
response = requests.get(url)
# error-prone way of finding the response in the html - if isn't broken, don't fix it
matches = re.search(r' <b>([^,]*)', response.text)
if not matches:
matches = re.search(r' <span style="font-size:9pt; padding-left:5px"><b>([^<]*)', response.text)
return matches.group(1)
assert(filing_blue_payer("BC/BS of Connecticut - Anthem") == u'Blue Shield of California')
assert(filing_blue_payer("BC/BS of Colorado") == u'Anthem Blue Cross of California')
assert(filing_blue_payer("BC/BS Mississippi State and Teacher Employees") == 'no prefixes :(')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment