Example #1
0
def convert_xml_hospital_list_async(request):
    doc = minidom.parseString(render_to_string('old/hospitals/rows.xml'))
    Hospital.objects.all().delete()
    for row in doc.getElementsByTagName('row'):
        try:
            children = row.childNodes
            hospital = Hospital()
            hospital.name = _get_child(children, 'hospital_name')
            hospital.address1 = _get_child(children, 'address_1')
            hospital.city = _get_child(children, 'city')
            hospital.state = _get_child(children, 'state')
            hospital.zip = _get_child(children, 'zip_code')
            hospital.county_name = _get_child(children, 'county_name')
            hospital.phone = _get_child(children, 'phone_number',
                                        'phone_number')
            hospital.longitude = _get_child(children, 'location', 'longitude')
            hospital.latitude = _get_child(children, 'location', 'latitude')
            hospital.save()
        except Exception, e:
            logging.info(e)
Example #2
0
def convert_xml_hospital_list_async(request):
    doc = minidom.parseString(render_to_string('old/hospitals/rows.xml'))
    Hospital.objects.all().delete()
    for row in doc.getElementsByTagName('row'):
        try:
            children = row.childNodes
            hospital = Hospital()
            hospital.name = _get_child(children, 'hospital_name')
            hospital.address1 = _get_child(children, 'address_1')
            hospital.city = _get_child(children, 'city')
            hospital.state = _get_child(children, 'state')
            hospital.zip = _get_child(children, 'zip_code')
            hospital.county_name = _get_child(children, 'county_name')
            hospital.phone = _get_child(children, 'phone_number', 'phone_number')
            hospital.longitude = _get_child(children, 'location', 'longitude')
            hospital.latitude = _get_child(children, 'location', 'latitude')
            hospital.save()
        except Exception, e:
            logging.info(e)
Example #3
0
def convert_json_hospital_list_async(request):
    url = "http://data.medicare.gov/resource/v287-28n3.json"
    result = urlfetch.fetch(url)
    Hospital.objects.all().delete()
    if result.status_code == 200:
        items = simplejson.loads(result.content, 'utf-8')
        for item in items:
            hospital = Hospital()
            hospital.name = item['hospital_name']
            hospital.address1 = item['address_1']
            hospital.address2 = item['address_2'] if 'address_2' in item else ''
            hospital.city = item['city']
            hospital.state = item['state']
            hospital.zip = item['zip_code']
            hospital.county_name = item[
                'county_name'] if 'county_name' in item else ''
            hospital.phone = item['phone_number']['phone_number']
            hospital.longitude = float(item['location']['longitude'])
            hospital.latitude = float(item['location']['latitude'])
            hospital.save()
    return HttpResponse('OK')
Example #4
0
def convert_json_hospital_list_async(request):
    url = "http://data.medicare.gov/resource/v287-28n3.json"
    result = urlfetch.fetch(url)
    Hospital.objects.all().delete()
    if result.status_code == 200:
        items = simplejson.loads(result.content, 'utf-8')
        for item in items:
            hospital = Hospital()
            hospital.name = item['hospital_name']
            hospital.address1 = item['address_1']
            hospital.address2 = item['address_2'] if 'address_2' in item else ''
            hospital.city = item['city']
            hospital.state = item['state']
            hospital.zip = item['zip_code']
            hospital.county_name = item['county_name'] if 'county_name' in item else ''
            hospital.phone = item['phone_number']['phone_number']
            hospital.longitude = float(item['location']['longitude'])
            hospital.latitude = float(item['location']['latitude'])
            hospital.save()
    return HttpResponse('OK')