def test_provider_id_from_name(): # positive cases _test_provider("Rite Aid Pharmacy 3897", "rite_aid", "3897") _test_provider("Walgreens #24295", "walgreens", "24295") _test_provider("Walgreens Pharmacy #24295", "walgreens", "24295") _test_provider("Walgreens Specialty Pharmacy #35326", "walgreens", "35326") _test_provider("Walgreens Specialty #24295", "walgreens", "24295") _test_provider("Safeway #85", "safeway", "85") _test_provider("Safeway PHARMACY #85", "safeway", "85") _test_provider("Vons Pharmacy #675", "vons", "675") _test_provider("SAV-ON PHARMACY #585", "albertsons", "585") _test_provider("SAVON PHARMACY #585", "albertsons", "585") _test_provider("Pavilions PHARMACY #8545", "pavilions", "8545") _test_provider("Walmart PHARMACY 10-585", "walmart", "585") _test_provider("Cvs 104", "cvs", "104") _test_provider("Cvs Store 104", "cvs", "104") _test_provider("Cvs Pharmacy 104", "cvs", "104") _test_provider("Cvs StorePharmacy 104", "cvs", "104") _test_provider("Cvs StorePharmacy, Inc. 104", "cvs", "104") _test_provider("Cvs Store #104", "cvs", "104") _test_provider("Cvs Pharmacy #104", "cvs", "104") _test_provider("Cvs StorePharmacy #104", "cvs", "104") _test_provider("Cvs StorePharmacy, Inc #104", "cvs", "104") _test_provider("Cvs StorePharmacy, Inc. #104", "cvs", "104") # negative cases assert provider_id_from_name("garbage") is None assert provider_id_from_name("Walblue 232555") is None
def _test_provider(input_str, expected_provider_name, expected_provider_id): result = provider_id_from_name(input_str) assert result actual_provider_name, actual_provider_id = result assert actual_provider_name == expected_provider_name assert actual_provider_id == expected_provider_id
def normalize(site: dict, timestamp: str) -> dict: links = [ schema.Link(authority="ct_gov", id=site["_id"]), schema.Link(authority="ct_gov_network_id", id=site["networkId"]), ] parent_organization = schema.Organization(name=site["networks"][0]["name"]) parsed_provider_link = provider_id_from_name(site["name"]) if parsed_provider_link is not None: links.append( schema.Link(authority=parsed_provider_link[0], id=parsed_provider_link[1]) ) parent_organization.id = parsed_provider_link[0] return schema.NormalizedLocation( id=f"ct_gov:{site['_id']}", name=site["displayName"], address=schema.Address( street1=site["addressLine1"], street2=site["addressLine2"], city=site["city"], state="CT", zip=site["zip"], ), location=_get_lat_lng(site), contact=[ schema.Contact( contact_type="booking", phone=site["phone"], website=site["link"] ), ], languages=None, opening_dates=None, opening_hours=None, availability=schema.Availability( appointments=site["availability"], ), inventory=[ schema.Vaccine(vaccine=vaccine["name"]) for vaccine in site["providerVaccines"] ], access=schema.Access( drive=site["isDriveThru"], ), parent_organization=parent_organization, links=links, notes=None, active=None, source=schema.Source( source="covidvaccinefinder_gov", id=site["_id"], fetched_from_uri="https://covidvaccinefinder.ct.gov/api/HttpTriggerGetProvider", # noqa: E501 fetched_at=timestamp, published_at=site["lastModified"], data=site, ), ).dict()
def _get_links(site: dict) -> Optional[List[schema.Link]]: links = None parsed_provider_link = provider_id_from_name(site["title"]) if parsed_provider_link is not None: provider_link = schema.Link( authority=parsed_provider_link[0], id=parsed_provider_link[1], ) links = [provider_link] return links
def normalize(site_blob: dict, timestamp: str) -> dict: site = site_blob["properties"] links = [schema.Link(authority="vaccinespotter_org", id=site["id"])] parsed_provider_link = provider_id_from_name( site["provider_brand_name"] # or use site["name"]? ) if parsed_provider_link is not None: links.append( schema.Link(authority=parsed_provider_link[0], id=parsed_provider_link[1])) _strip_source_data(site_blob) return schema.NormalizedLocation( id=f"vaccinespotter_org:{site['id']}", name=site["name"], address=_get_address(site), location=_get_lat_lng(site_blob["geometry"], site["id"]), contact=[ schema.Contact(contact_type=None, phone=None, website=site["url"]), ], languages=None, opening_dates=None, opening_hours=None, availability=schema.Availability( appointments=site["appointments_available"], drop_in=None), inventory=None, access=schema.Access(walk=None, drive=None, wheelchair=None), parent_organization=None, links=links, notes=None, active=None, source=schema.Source( source="vaccinespotter_org", id=site["id"], fetched_from_uri= "https://www.vaccinespotter.org/api/v0/US.json", # noqa: E501 fetched_at=timestamp, published_at=site["appointments_last_fetched"], data=site_blob, ), ).dict()
def _get_provider_store_page(site: dict) -> Optional[str]: """ Get the webpage for a specific store if possible, or a store listing for all stores in the state. """ provider = provider_id_from_name(site["name"]) if provider and provider[0] == schema.VaccineProvider.COSTCO: return "https://www.costco.com/warehouse-locations" if provider and provider[0] == schema.VaccineProvider.CVS: return "https://www.cvs.com/store-locator/cvs-pharmacy-locations/Colorado" if provider and provider[0] == schema.VaccineProvider.KING_SOOPERS: return f"https://www.kingsoopers.com/stores/details/620/{provider[1]}" if provider and provider[0] == schema.VaccineProvider.SAMS: return "https://www.samsclub.com/locator" if provider and provider[0] == schema.VaccineProvider.WALMART: return f"https://www.walmart.com/store/{provider[1]}" m = re.match(r"City Market Pharmacy 625(\d{5})", site["name"]) if m: return f"https://www.citymarket.com/stores/details/620/{m.group(1)}" if site["name"] == "Walgreen Drug Store": return "https://www.walgreens.com/storelistings/storesbycity.jsp?requestType=locator&state=CO" if site["name"] == "Pharmaca Integrative Pharmacy": return "https://www.pharmacarx.com/pharmacy-locator/" if "address" in site and site["address"]: if site["name"] == "Safeway Pharmacy": return f"https://local.safeway.com/search.html?q={urllib.parse.quote(site['address'])}&storetype=5657&l=en" if site["name"][0:17] == "The Little Clinic": return f"https://www.thelittleclinic.com/clinic-locator?searchText={urllib.parse.quote(site['address'])}" return None
def _get_links(site: dict) -> Optional[List[schema.Link]]: maybe_provider = provider_id_from_name(site["name"]) if maybe_provider: return [schema.Link(authority=maybe_provider[0], id=maybe_provider[1])] return None
def _get_parent_organization(site: dict) -> Optional[schema.Organization]: maybe_provider = provider_id_from_name(site["name"]) if maybe_provider: return schema.Organization(id=maybe_provider[0]) return None
def normalize(site_blob: dict, timestamp: str) -> dict: site = site_blob["properties"] geometry = site_blob["geometry"] street1 = site["address"] street2 = None # this is part of street1... normalized = { "id": f"vaccinespotter_org:{site['id']}", "name": site["name"], "address": { "street1": street1, "street2": street2, "city": site["city"], "state": site["state"], "zip": site["postal_code"], }, "location": { "latitude": geometry["coordinates"][1], "longitude": geometry["coordinates"][0], }, "contact": [ { "contact_type": None, "phone": None, "website": site["url"], "other": None, }, ], "availability": { "appointments": site["appointments_available"], "drop_in": None, }, "access": { "walk": None, "drive": None, "wheelchair": None, }, "languages": [], "links": [ { "authority": "vaccinespotter_org", "id": site["id"], }, ], "fetched_at": timestamp, "published_at": site[ "appointments_last_fetched" # we could also use `appointments_last_modified` ], "active": None, "source": { "source": "vaccinespotter_org", "id": site["id"], "fetched_from_uri": "https://www.vaccinespotter.org/api/v0/US.json", "fetched_at": timestamp, "published_at": site[ "appointments_last_fetched" # we could also use `appointments_last_modified` ], "data": site_blob, }, } parsed_provider_link = provider_id_from_name( site["provider_brand_name"] # or use site["name"]? ) if parsed_provider_link is not None: normalized["links"].append({ "authority": parsed_provider_link[0], "id": parsed_provider_link[1] }) return normalized
def normalize(site: dict, timestamp: str) -> dict: address = site["location"]["address"] address_parts = [p.strip() for p in address.split(",")] # Remove city from end of address address_parts.pop() street1 = address_parts[0] street2 = None if len(address_parts) > 1: street2 = ", ".join(address_parts[1:]) links = [schema.Link(authority="sf_gov", id=site["id"])] parsed_provider_link = provider_id_from_name(site["name"]) if parsed_provider_link is not None: links.append( schema.Link(authority=parsed_provider_link[0], id=parsed_provider_link[1])) contacts = [] if site["booking"]["phone"] and site["booking"]["phone"].lower() != "none": contacts.append( schema.Contact(contact_type="booking", phone=site["booking"]["phone"])) if site["booking"]["url"] and site["booking"]["url"].lower() != "none": contacts.append( schema.Contact(contact_type="booking", website=site["booking"]["url"])) if site["booking"]["info"] and site["booking"]["info"].lower() != "none": contacts.append( schema.Contact(contact_type="booking", other=site["booking"]["info"])) return schema.NormalizedLocation( id=f"sf_gov:{site['id']}", name=site["name"], address=schema.Address( street1=street1, street2=street2, city=site["location"]["city"], state="CA", zip=(site["location"]["zip"] if site["location"]["zip"] and site["location"]["zip"].lower() != "none" else None), ), location=schema.LatLng( latitude=site["location"]["lat"], longitude=site["location"]["lng"], ), contact=contacts, languages=[k for k, v in site["access"]["languages"].items() if v], opening_dates=None, opening_hours=None, availability=schema.Availability( appointments=site["appointments"]["available"], drop_in=site["booking"]["dropins"], ), inventory=None, access=schema.Access( walk=site["access_mode"]["walk"], drive=site["access_mode"]["drive"], wheelchair="yes" if site["access"]["wheelchair"] else "no", ), parent_organization=None, links=links, notes=None, active=site["active"], source=schema.Source( source="sf_gov", id=site["id"], fetched_from_uri= "https://vaccination-site-microservice.vercel.app/api/v1/appointments", # noqa: E501 fetched_at=timestamp, published_at=site["appointments"]["last_updated"], data=site, ), ).dict()
def normalize(site: dict, timestamp: str) -> dict: address = site["location"]["address"] address_parts = [p.strip() for p in address.split(",")] # Remove city from end of address address_parts.pop() street1 = address_parts[0] street2 = None if len(address_parts) > 1: street2 = ", ".join(address_parts[1:]) normalized = { "id": f"sf_gov:{site['id']}", "name": site["name"], address: { "street1": street1, "street2": street2, "city": site["location"]["city"], "state": "CA", "zip": site["location"]["zip"], }, "location": { "latitude": site["location"]["lat"], "longitude": site["location"]["lng"], }, "contact": [ { "contact_type": "booking", "phone": site["booking"]["phone"], "website": site["booking"]["url"], "other": site["booking"]["info"], }, ], "availability": { "appointments": site["appointments"]["available"], "drop_in": site["booking"]["dropins"], }, "access": { "walk": site["access_mode"]["walk"], "drive": site["access_mode"]["drive"], "wheelchair": site["access"]["wheelchair"], }, "languages": [k for k, v in site["access"]["languages"].items() if v], "links": [ { "authority": "sf_gov", "id": site["id"], }, ], "fetched_at": timestamp, "published_at": site["appointments"]["last_updated"], "active": site["active"], "source": { "source": "sf_gov", "id": site["id"], "fetched_from_uri": "https://vaccination-site-microservice.vercel.app/api/v1/appointments", "fetched_at": timestamp, "published_at": site["appointments"]["last_updated"], "data": site, }, } parsed_provider_link = provider_id_from_name(site["name"]) if parsed_provider_link is not None: normalized["links"].append({ "authority": parsed_provider_link[0], "id": parsed_provider_link[1] }) return normalized
def normalize(site: dict, timestamp: str) -> dict: normalized = { "id": f"ct_gov:{site['_id']}", "name": site["displayName"], "address": { "street1": site["addressLine1"], "street2": site["addressLine2"], "city": site["city"], "state": "CT", "zip": site["zip"], }, "location": { "latitude": site["lat"], "longitude": site["lng"], }, "contact": [ { "contact_type": "booking", "phone": site["phone"], "website": site["link"], }, ], "availability": { "appointments": site["availability"], }, "access": { "drive": site["isDriveThru"], }, "inventory": [ {"vaccine": vaccine["name"]} for vaccine in site["providerVaccines"] ], "links": [ { "authority": "ct_gov", "id": site["_id"], }, { "authority": "ct_gov:network_id", "id": site["networkId"], }, ], "parent_organization": { "name": site["networks"][0]["name"], }, "fetched_at": timestamp, "published_at": site["lastModified"], "source": { "source": "ct", "id": site["_id"], "fetched_from_uri": "https://covidvaccinefinder.ct.gov/api/HttpTriggerGetProvider", "fetched_at": timestamp, "published_at": site["lastModified"], "data": site, }, } parsed_provider_link = provider_id_from_name(site["name"]) if parsed_provider_link is not None: normalized["links"].append( {"authority": parsed_provider_link[0], "id": parsed_provider_link[1]} ) normalized["parent_organization"]["id"] = parsed_provider_link[0] return normalized
def test_provider_id_from_name(): # positive cases _test_provider("Acme Pharmacy #1058", VaccineProvider.ACME, "1058") _test_provider("Albertsons Pharmacy #1915", VaccineProvider.ALBERTSONS, "1915") _test_provider("Albertsons Market Pharmacy #1915", VaccineProvider.ALBERTSONS, "1915") _test_provider("Big Y Pharmacy #17 Rx #408532", VaccineProvider.BIG_Y, "408532") _test_provider("Big Y Pharmacy #067209", VaccineProvider.BIG_Y, "67209") _test_provider("Brookshire Pharmacy #14 #351329", VaccineProvider.BROOKSHIRE, "351329") _test_provider("COSTCO MARKET PHARMACY #122", VaccineProvider.COSTCO, "122") _test_provider("COSTCO PHARMACY #122", VaccineProvider.COSTCO, "122") _test_provider("Costco Wholesale Corporation #1062", VaccineProvider.COSTCO, "1062") _test_provider("Costco Pharmacy # 1014", VaccineProvider.COSTCO, "1014") _test_provider("Cub Pharmacy #122 #242356", VaccineProvider.CUB, "242356") _test_provider("Cvs 104", VaccineProvider.CVS, "104") _test_provider("Cvs Store 104", VaccineProvider.CVS, "104") _test_provider("Cvs Pharmacy 104", VaccineProvider.CVS, "104") _test_provider("Cvs StorePharmacy 104", VaccineProvider.CVS, "104") _test_provider("Cvs StorePharmacy, Inc. 104", VaccineProvider.CVS, "104") _test_provider("Cvs Store #104", VaccineProvider.CVS, "104") _test_provider("Cvs Pharmacy #104", VaccineProvider.CVS, "104") _test_provider("Cvs StorePharmacy #104", VaccineProvider.CVS, "104") _test_provider("Cvs StorePharmacy, Inc #104", VaccineProvider.CVS, "104") _test_provider("Cvs StorePharmacy, Inc. #104", VaccineProvider.CVS, "104") _test_provider("CVS Pharmacy, Inc. #008104", VaccineProvider.CVS, "8104") _test_provider("Dillon's Pharmacy #61500005", VaccineProvider.DILLONS, "61500005") _test_provider("Drugco Discount Pharmacy #3425", VaccineProvider.DRUGCO, "3425") _test_provider("Family Fare Pharmacy 0115 #5221", VaccineProvider.FAMILY_FARE, "5221") _test_provider("Family Fare Pharmacy #0115 #5221", VaccineProvider.FAMILY_FARE, "5221") _test_provider("Food City Pharmacy #0115 #5221", VaccineProvider.FOOD_CITY, "5221") _test_provider("Food Lion #5221", VaccineProvider.FOOD_LION, "5221") _test_provider("Fred Meyer #5221", VaccineProvider.FRED_MEYER, "5221") _test_provider("Fred Meyer Pharmacy #5221", VaccineProvider.FRED_MEYER, "5221") _test_provider("Fry's Food And Drug #66000061", VaccineProvider.FRYS, "66000061") _test_provider( "Genoa Healthcare 00010 (Chattanooga - Bell Avenue)", VaccineProvider.GENOA, "10", ) _test_provider("Genoa Healthcare LLC #00072", VaccineProvider.GENOA, "72") _test_provider("Giant Eagle Pharmacy #0012 #G00122", VaccineProvider.GIANT_EAGLE, "122") _test_provider("Giant Food #198", VaccineProvider.GIANT_FOOD, "198") _test_provider("Giant #6269", VaccineProvider.GIANT, "6269") _test_provider("Haggen Pharmacy #3450", VaccineProvider.HAGGEN, "3450") _test_provider("Hannaford #3450", VaccineProvider.HANNAFORD, "3450") _test_provider("Harmons Pharmacy #18", VaccineProvider.HARMONS, "18") _test_provider("Harps Pharmacy #177", VaccineProvider.HARPS, "177") _test_provider("Harris Teeter Pharmacy #09700030", VaccineProvider.HARRIS_TEETER, "9700030") _test_provider("Hartig Drug Co #34 #324429", VaccineProvider.HARTIG, "324429") _test_provider("Hartig Drug Co 26 #324429", VaccineProvider.HARTIG, "324429") _test_provider("H-E-B #198", VaccineProvider.HEB, "198") _test_provider("Homeland Pharmacy #24429", VaccineProvider.HOMELAND, "24429") _test_provider("Hy-Vee Inc. #449", VaccineProvider.HY_VEE, "449") _test_provider("Ingles Pharmacy #031 #438575", VaccineProvider.INGLES, "438575") _test_provider("KAISER HEALTH PLAN B PHY 722", VaccineProvider.KAISER_HEALTH_PLAN, "722") _test_provider("KAISER HEALTH PLAN BLDG PHY 632", VaccineProvider.KAISER_HEALTH_PLAN, "632") _test_provider("KAISER HEALTH PLAN MOB 1 PHY 511", VaccineProvider.KAISER_HEALTH_PLAN, "511") _test_provider("KAISER PERMANENTE PHARMACY #054", VaccineProvider.KAISER_PERMANENTE, "54") _test_provider("King Soopers Pharmacy #62000121", VaccineProvider.KING_SOOPERS, "62000121") _test_provider("King Soopers Pharmacy 62000001", VaccineProvider.KING_SOOPERS, "62000001") _test_provider("Kroger Pharmacy #01100330", VaccineProvider.KROGER, "1100330") _test_provider("Kroger Pharmacy 743", VaccineProvider.KROGER, "743") _test_provider("Mariano's Pharmacy #53100520", VaccineProvider.MARIANOS, "53100520") _test_provider("Medicap Pharmacy #8207 #162543", VaccineProvider.MEDICAP, "162543") _test_provider("Meijer #312", VaccineProvider.MEIJER, "312") _test_provider("The Little Clinic #36213", VaccineProvider.LITTLE_CLINIC, "36213") _test_provider("Market Street Pharmacy #531", VaccineProvider.MARKET_STREET, "531") _test_provider("Osco Drug #3272", VaccineProvider.OSCO, "3272") _test_provider("Osco Pharmacy #3272", VaccineProvider.OSCO, "3272") _test_provider("Pavilions PHARMACY #8545", VaccineProvider.PAVILIONS, "8545") _test_provider("Pick N Save Pharmacy #53400102", VaccineProvider.PICK_N_SAVE, "53400102") _test_provider("Price Chopper Pharmacy 184 #039929", VaccineProvider.PRICE_CHOPPER, "39929") _test_provider( "Price Chopper Pharmacy #20 #MS1004804", VaccineProvider.PRICE_CHOPPER, "1004804", ) _test_provider("Publix Super Markets Inc. #850", VaccineProvider.PUBLIX, "850") _test_provider("QFC Pharmacy #70500126", VaccineProvider.QFC, "70500126") _test_provider("RALEY'S PHARMACY #339", VaccineProvider.RALEYS, "339") _test_provider("Rite Aid Pharmacy 3897", VaccineProvider.RITE_AID, "3897") _test_provider("Rite Aid #RA100216", VaccineProvider.RITE_AID, "100216") _test_provider("Safeway #85", VaccineProvider.SAFEWAY, "85") _test_provider("Safeway PHARMACY #85", VaccineProvider.SAFEWAY, "85") _test_provider("Sam's Pharmacy #6549", VaccineProvider.SAMS, "6549") _test_provider("Sams Club #10-6371", VaccineProvider.SAMS, "6371") _test_provider("Sams Club 6331", VaccineProvider.SAMS, "6331") _test_provider("Sams Pharmacy 10-6371", VaccineProvider.SAMS, "6371") _test_provider("SAV-ON PHARMACY #585", VaccineProvider.SAV_ON, "585") _test_provider("SAVON PHARMACY #585", VaccineProvider.SAV_ON, "585") _test_provider("Shoprite Pharmacy #447", VaccineProvider.SHOP_RITE, "447") _test_provider("Smith's Pharmacy #70600075", VaccineProvider.SMITHS, "70600075") _test_provider("Stop & Shop #694", VaccineProvider.STOP_AND_SHOP, "694") _test_provider("Tom Thumb Pharmacy #2554", VaccineProvider.TOM_THUMB, "2554") _test_provider("Thrifty Drug Stores Inc #5", VaccineProvider.THRIFTY, "5") _test_provider("Vons Pharmacy #675", VaccineProvider.VONS, "675") _test_provider("Walgreens #24295", VaccineProvider.WALGREENS, "24295") _test_provider("Walgreens Co. #1158", VaccineProvider.WALGREENS, "1158") _test_provider("Walgreens Pharmacy #24295", VaccineProvider.WALGREENS, "24295") _test_provider("Walgreens Specialty Pharmacy #35326", VaccineProvider.WALGREENS, "35326") _test_provider("Walgreens Specialty #24295", VaccineProvider.WALGREENS, "24295") _test_provider("Walmart Inc, #2509", VaccineProvider.WALMART, "2509") _test_provider("Walmart Inc #10-1165", VaccineProvider.WALMART, "1165") _test_provider("Walmart PHARMACY 10-585", VaccineProvider.WALMART, "585") _test_provider("Walmart Pharmacy #1001", VaccineProvider.WALMART, "1001") _test_provider("Weis Pharmacy #227 #801371", VaccineProvider.WEIS, "801371") _test_provider("Winn-Dixie #435", VaccineProvider.WINN_DIXIE, "435") # negative cases assert provider_id_from_name("garbage") is None assert provider_id_from_name("Walblue 232555") is None