Skip to content

Instantly share code, notes, and snippets.

@therealsanmah
Last active February 13, 2020 12:30
Show Gist options
  • Save therealsanmah/72bbbdeab913c700c47be875b1a8f068 to your computer and use it in GitHub Desktop.
Save therealsanmah/72bbbdeab913c700c47be875b1a8f068 to your computer and use it in GitHub Desktop.
result = {}
for racz in RatingAreaCountyZip.objects.filter():
if result.get(str(racz.county.id) + '___' + str(racz.zip)):
result[str(racz.county.id) + '___' + str(racz.zip)].append((str(racz.ratingArea.id), racz.ratingArea.name))
else:
result[str(racz.county.id) + '___' + str(racz.zip)] = [(str(racz.ratingArea.id), racz.ratingArea.name)]
result = [(k,v) for k,v in result.iteritems() if len(v) >1]
res2 = []
for k,vals in result:
output = []
countyId, zip = k.split('___')
county = County.get_or_none(id=countyId)
for val in vals:
cclis = list(InsuranceCompanyCarrierLineInfo.objects_across_company.filter(Q(address__county=county)|Q(address__county=None), ratingArea=val[0], state__ne='INIT', address__zip=zip, lineType='MEDICAL'))
if len(cclis):
output.append((val[1], cclis))
if output:
res2.append(output)
return res2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment