-
Notifications
You must be signed in to change notification settings - Fork 1
Update location providers based on cvs: / walgreens: / etc concordance identifiers #707
Comments
The https://vial.calltheshots.us/api/docs#post-apiupdatelocations Lines 157 to 161 in 9cb542e
|
So I can run a script in a Jupyter notebook that retrieves the locations that need to be updated using https://vial.calltheshots.us/api/searchLocations?authority=cvs - maybe even add an extra search parameter for |
Updated documentation: https://vial-staging.calltheshots.us/api/docs#get-apisearchlocations Demo: https://vial-staging.calltheshots.us/api/searchLocations?size=0&provider_null=1 {
"results": [],
"total": 17917
} https://vial-staging.calltheshots.us/api/searchLocations?size=0&provider_null=1&authority=cvs {
"results": [],
"total": 109
} |
Being able to use |
This means I can know get the ID of every single location that is tagged with the |
Here's a map of all locations attached to the provider called CVS: https://vial-staging.calltheshots.us/api/searchLocations?provider=CVS&format=map&all=1 - 3832 locations All locations with a All locations with a |
Interestingly this suggests that, at least on staging, we have CVS locations that are NOT tagged with a |
https://vial-staging.calltheshots.us/api/searchLocations?provider=CVS&format=map&all=1&exclude.authority=cvs shows a map of every location attached to the CVS provider that does NOT have a |
Deploying this stuff to production to answer these questions there. |
In production we only have 72 locations with provider CVS that don't have a |
Spotted something weird: https://vial.calltheshots.us/api/searchLocations?authority=cvs returns 17707 results. But that seems like a LOT of CVSs. https://www.google.com/search?client=firefox-b-1-d&q=how+many+branches+of+CVS suggests there are 9,967 branches in the USA. On a hunch, I pulled and de-duped the full list of IDs using this:
Which returned 10,883 - so there's a bug in the API where multiple results can be returned. |
This SQL query shows locations with multiple select location.public_id, count(*), array_agg(authority || ':' || identifier)
from concordance_location join concordance_identifier on concordance_identifier.id = concordanceidentifier_id
join location on location_id = location.id
where authority = 'cvs' group by location.public_id
having count(*) > 1
order by count(*) desc There are a LOT - grouping by their duplicate count gives:
|
That fixed it:
|
https://vial.calltheshots.us/api/searchLocations?authority=cvs&exclude.provider=CVS&size=0 returns 7112 results - I'm going to assign them all to the CVS provider using the API. |
Running this now: import httpx
from tqdm.notebook import tqdm
api_key = "30:..."
url = "https://vial.calltheshots.us/api/searchLocations?authority=cvs&exclude.provider=CVS&all=1&format=ids"
ids = httpx.get(url, headers={"Authorization": "Bearer {}".format(api_key)}).json()
def make_chunks(sequence, n):
for i in range(0, len(sequence), n):
yield sequence[i:i + n]
chunks = list(make_chunks(ids, 100))
for chunk in tqdm(chunks):
httpx.post("https://vial.calltheshots.us/api/updateLocations", timeout=20, json={
"update": {
id: {
"provider_type": "Pharmacy",
"provider_name": "CVS",
} for id in chunk
},
"revision_comment": "Issue #707"
}, headers={"Authorization": "Bearer {}".format(api_key)}) Hitting https://vial.calltheshots.us/api/searchLocations?authority=cvs&exclude.provider=CVS&size=0 while it is running shows the number reducing as it works. |
OK, what other authorities should I do?
|
I'm going to start with these ones:
|
Health Mart is a chain of 5,000 independent member pharmacies: https://en.wikipedia.org/wiki/Health_Mart - https://vial.calltheshots.us/api/searchLocations?authority=health_mart&format=map&all=1 looks about right to me. It's here in VIAL: https://vial.calltheshots.us/admin/core/provider/98/change/ - I'm going to add the URLs to it. |
Rite-Aid is in VIAL twice: https://vial.calltheshots.us/admin/core/provider/119/change/?_changelist_filters=q%3Drite as "Rite-Aid" and https://vial.calltheshots.us/admin/core/provider/2/change/?_changelist_filters=q%3Drite as "Rite-Aid Pharmacy" https://vial.calltheshots.us/api/searchLocations?provider=Rite-Aid&format=map&all=1 shows 1689 |
I'm going to update all of the California "Rite-Aid Pharmacy" records to use "Rite-Aid" as their provider instead, then I'll rename the "Rite-Aid Pharmacy" provider in VIAL to "OBSOLETE Rite-Aid DO NOT USE" Done that, now https://vial.calltheshots.us/api/searchLocations?provider=Rite-Aid&format=map&all=1 has 2228 locations. |
Hy-Vee was missing so I added it - it's a super-market chain. https://vial.calltheshots.us/admin/core/provider/127/change/ https://vial.calltheshots.us/api/searchLocations?authority=hyvee&exclude.provider=Hy-Vee&size=0 |
Part of #705.
Key idea here is to ensure that all of our locations with a
cvs:
concordance are attached to the CVS provider, ditto forwalgreens:
and various other common concordance authorities.This will allow us to pick up the
appointments_url
from those providers, if it is set, when we serve locations to our new API and to the Mapbox export used on www.VaccinateTheStates.comThe text was updated successfully, but these errors were encountered: