Skip to content

Commit 4f4816b

Browse files
vaccine update
1 parent 07a8b74 commit 4f4816b

8 files changed

+4451
-3967
lines changed

CovidData.csv

Lines changed: 3955 additions & 3955 deletions
Large diffs are not rendered by default.

app.py

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@
55
import findCounty as fc
66
from nearestCentersDictionary import nearest_centers
77
from makeMessage import formulate_message
8+
from makeMessage import formulate_message_vaccine
89
from test import cases_data
910
import os, ssl
1011
import random
1112
from puns import puns
12-
from twilio.jwt.access_token import AccessToken
13+
from vaccine_centers_nearest import refined_vaccine_sites
1314
if (not os.environ.get('PYTHONHTTPSVERIFY', '') and getattr(ssl, '_create_unverified_context', None)):
1415
ssl._create_default_https_context = ssl._create_unverified_context
1516

16-
#auth_token = AccessToken('AC0d79e56293d4494c36eee4f48a59ff8e', 'SKeb5a25313bb48bd91b84eedbe6834520', 'bsamiAWrhwdHLCYpPNiy6Ch2t9WT1gAT', identity='PythonCovidBot')
1717

18+
#auth_token = AccessToken('AC0d79e56293d4494c36eee4f48a59ff8e', 'SKeb5a25313bb48bd91b84eedbe6834520', 'bsamiAWrhwdHLCYpPNiy6Ch2t9WT1gAT', identity='PythonCovidBot')
1819

20+
auth_token = "15caae692cc9007c162f8d0c7f77e04d"
1921
app = Flask(__name__)
2022
account_sid = 'AC0d79e56293d4494c36eee4f48a59ff8e'
21-
auth_token = '15caae692cc9007c162f8d0c7f77e04d'
2223
client = Client(account_sid, auth_token)
2324
bot_number = "+14155238886"
2425

@@ -40,6 +41,7 @@ def hello():
4041
@app.route("/sms", methods=['POST'])
4142
def sms_reply():
4243
msg = request.form.get('Body')
44+
print(msg)
4345
phone_no = request.form.get('From')
4446
responded = False
4547

@@ -57,12 +59,11 @@ def sms_reply():
5759
elif msg == 'A':
5860
if phone_no in user_zips.keys():
5961
zip = user_zips[phone_no][0]
60-
print(zip)
6162
county = fc.find_county_by_zip_code(zip)
6263
if county[1] == "No":
6364
send_message("Enter a valid zip code. Otherwise, I'm sorry, I cannot retrieve data for you :(", bot_number, phone_no)
6465
elif county[0] == 2:
65-
send_message("Which county are you located in: {}. Type the numerical index of the county you are in starting from 1.".format(county[1]), bot_number, phone_no)
66+
send_message("Which county are you located in: {}".format(county[1]), bot_number, phone_no)
6667
# length 1, no need for more user input
6768
else:
6869
#county = fc.find_county_by_zip_code(zip)
@@ -110,7 +111,7 @@ def sms_reply():
110111
fourth_test_center = formulate_message(centers[3][1])
111112
fifth_test_center = formulate_message(centers[4][1])
112113

113-
print(first_test_center, fourth_test_center)
114+
#print(first_test_center, fourth_test_center)
114115
send_message(first_test_center + "\n" + " " + "\n" + second_test_center + "\n" + " " + "\n" + third_test_center + "\n" + " " + "\n" + fourth_test_center + "\n" + " " + "\n" + fifth_test_center, bot_number, phone_no)
115116
'''
116117
send_message(formulate_message(centers[1][1]), bot_number, phone_no)
@@ -151,6 +152,7 @@ def sms_reply():
151152
send_message(
152153
"Hi There, I am CovidBot! I am a chatbot that helps guide you through the pandemic with truthful and insightful info.\n"
153154
"Your friend, whose number is {} share me with you. Say Hi to activate".format(msg), bot_number, msg)
155+
154156
else:
155157
send_message("Check if you formatted the number correct. There seems to be a mistake.", bot_number, phone_no)
156158

@@ -163,6 +165,34 @@ def sms_reply():
163165
elif msg.lower() in bye_statements:
164166
send_message("Goodbye", bot_number, phone_no)
165167

168+
169+
#vaccine centers option addition
170+
elif msg.lower() == 'V'.lower():
171+
if phone_no in user_zips.keys():
172+
search = str(user_zips[phone_no][0])
173+
174+
if search not in refined_vaccine_sites:
175+
send_message("Please provide a zip code and re-enter the letter you typed: ", bot_number, phone_no)
176+
else:
177+
print(search)
178+
centers = refined_vaccine_sites[search]
179+
print(centers)
180+
181+
182+
first_test_center = formulate_message_vaccine(centers[0][1])
183+
second_test_center = formulate_message_vaccine(centers[1][1])
184+
third_test_center = formulate_message_vaccine(centers[2][1])
185+
#fourth_test_center = formulate_message_vaccine(centers[3][1])
186+
#fifth_test_center = formulate_message_vaccine(centers[4][1])
187+
188+
189+
send_message(
190+
first_test_center + "\n" + " " + "\n" + second_test_center + "\n" + " " + "\n" + third_test_center,
191+
bot_number, phone_no)
192+
193+
else:
194+
send_message("Please provide a zip code and re-enter the letter you typed: ", bot_number, phone_no)
195+
166196
else:
167197
send_message("I don't understand. Here is the menu again: ", bot_number, phone_no)
168198
responded = send_menu(bot_number, phone_no)
@@ -176,10 +206,11 @@ def send_menu(bot_num, phone_no):
176206
"Type 'C' -> Finds your nearest test sites\n" \
177207
"Type 'D' -> Share this bot!\n" \
178208
"Type 'E' -> Donate for Covid-19\n" \
179-
"Type 'F' -> More Information about the virus"
209+
"Type 'F' -> More Information about the virus\n" \
210+
"Type 'V' -> Find your nearest vaccination site!"
180211

181212
send_message(keyword, bot_num, phone_no)
182213
return True
183214

184215
if __name__ == "__main__":
185-
app.run(debug=True)
216+
app.run(debug=True)

build_dataset_vaccine.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import requests
2+
3+
r = requests.get('https://am-i-eligible.covid19vaccine.health.ny.gov/api/list-providers').json()
4+
for i in r['providerList']:
5+
print(i)
6+
7+
8+
9+
10+
11+
'''
12+
Structure of JSON:
13+
14+
{'id': , vaccineBrands: { : }, contact: {phone: }, hours: , address: }
15+
16+
'''
17+
18+
#vaccineBrands is for brand: in stock/call to confirm
19+
20+

findNearest.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
from selenium import webdriver
33
import time
44
from selenium.webdriver.common.keys import Keys
5+
import json
56
closest_distance_dict = {}
67

78

8-
zip_codes = ["10522, New York", "10533, New York", "10530, New York", "10502, New York", "10706, New York", '10607, New York', '10710, New York', '10701, New York', '10703, New York', '10708, New York', '10709, New York']
9+
zip_codes = ["10522 Dobbs Ferry", "10533, Irvington", "10530 Hartsdale", "10502 Ardsley", "10706 Hastings", '10607 Fairview', '10710 Yonkers', '10701 Yonkers', '10703 Yonkers', '10708 Bronxville', '10709 Eastchester']
910

1011
nearest_centers_zip_codes = {}
1112

1213

1314
def driving_distance(add1, add2):
14-
PATH = "/Users/martinmashalov/Documents/chromedriver 2"
15+
PATH = "/Users/martinmashalov/Downloads/VaccineDriver"
1516
driver = webdriver.Chrome(PATH)
1617
driver.get("https://www.mapdevelopers.com/distance_from_to.php")
1718

@@ -30,23 +31,27 @@ def driving_distance(add1, add2):
3031

3132
driving_distance = driver.find_element_by_id("driving_status")
3233
driving_distance_text = driving_distance.text
34+
print(driving_distance_text)
3335
closest_distance_dict[address] = driving_distance_text
3436

3537
driver.quit()
3638
return closest_distance_dict
3739

3840
def process_distance(add1, add2):
3941
for add in add1:
42+
print(add)
4043
nearest_center_tuples = []
4144
closest_distance_dict = driving_distance(add, add2)
4245
for location, value in closest_distance_dict.items():
4346
miles = float(''.join(list(value)[18:22]))
4447
nearest_center_tuples.append((miles, location))
48+
print(miles)
4549
nearest_center_tuples.sort()
4650
nearest_centers_zip_codes[add] = nearest_center_tuples[0:5]
4751

4852
return nearest_centers_zip_codes
4953

5054
add2 = ['Stony Brook University, NY', 'Dutchess Stadium, 1500 NY-9D', '300 Enterprise Drive, NY, 12401', '462 1st Avenue, New York, NY 10016', '79-01 Broadway, New York', '506 Lenox Avenue, New York, NY', '1901 1st Avenue, New York, NY 10029', '451 Clarkson Avenue, Brooklyn, NY', '234 East 149th Street, Bronx, NY', '760 Broadway, Brooklyn, NY', '82-68 164th Street, Jamaica, NY', '2601 Ocean Parkway, Brooklyn, NY', '1400 Pelham Parkway South, Bronx, NY', '1225 Gerard Avenue, Bronx, NY', '545 East 142nd Street, Bronx, NY', '100 North Portland Avenue, Brooklyn, NY', '2094 Pitkin Avenue, Brooklyn, NY', '227 Madison Street, New York, NY', '264 West 118th Street, New York, NY', '165 Vanderbilt Avenue, Staten Island, NY', 'Palisades Parkway, NY', 'Weyman Ave, New Rochelle, NY', '1 Ocean Pkwy, New York', '555 N. Broadway, New York', '3 Delaware Drive, Lake Success, NY', '10033 4th Ave. Brooklyn, NY', '291 3rd Ave. New York', '254-61 Nassau Blvd. Queens, NY', '1149 Old Country Road, Riverhead, NY', '1167 Wantagh Ave. Wantagh, NY', '1601 3rd Ave. New York', '147 Lake St, Newburgh, NY', '1400 Pelham Parkway South Bronx, New York 10461', '545 East 142nd Street Bronx, New York 10454', '30 Hamilton St, Dobbs Ferry, NY 10522', '2393 Central Park Ave, Yonkers, NY 10710', '2290 Central Park Ave, Yonkers, NY 10710', '555 S Broadway, Tarrytown, NY 10591', '650 White Plains Rd, Tarrytown, NY 10591', '155 White Plains Rd, Tarrytown, New York', '269A Livingston St, Northvale, NJ 07647', '305 N Central Ave, Hartsdale, NY 10530', '359 N Central Ave, Hartsdale, NY 10530', '2 Park Ave, Yonkers, NY 10703', '259 Heathcote Rd, Scarsdale, NY 10583', '41 E Post Rd, White Plains, NY 10601', '222 Mamaroneck Ave, White Plains, NY 10605', '280 Mamaroneck Ave, White Plains, NY 10605', '7-11 S Broadway, White Plains, NY 10601', '100 Woods Rd, Valhalla, New York', '77 Quaker Ridge Rd Ste 4, New Rochelle, NY', '203 Gramatan Ave, Mt Vernon, NY', '500 Westchester Ave, West Harrison, NY 10604']
51-
print(process_distance(zip_codes, add2))
52-
#['Stony Brook University, NY', 'Dutchess Stadium, 1500 NY-9D', '300 Enterprise Drive', '462 First Avenue, New York, NY', '79-01 Broadway, New York', '506 Lenox Avenue, New York, NY', '1901 First Avenue, New York, NY', '451 Clarkson Avenue, Brooklyn, NY', '234 East 149th Street, Bronx, NY', '760 Broadway, Brooklyn, NY', '82-68 164th Street, Jamaica, NY', '2601 Ocean Parkway, Brooklyn, NY', '1400 Pelham Parkway South, Bronx, NY', '1225 Gerard Avenue, Bronx, NY', '545 East 142nd Street, Bronx, NY', '100 North Portland Avenue, Brooklyn, NY', '2094 Pitkin Avenue, Brooklyn, NY', '227 Madison Street, New York, NY', '264 West 118th Street, New York, NY', '165 Vanderbilt Avenue, Staten Island, NY', 'Palisades Parkway, NY', 'Weyman Ave, New Rochelle, NY', '1 Ocean Pkwy, New York', '555 N. Broadway, New York', '3 Delaware Drive, Lake Success, NY', '10033 4th Ave. Brooklyn, NY', '291 3rd Ave. New York', '254-61 Nassau Blvd. Queens, NY', '1149 Old Country Road, Riverhead, NY', '1167 Wantagh Ave. Wantagh, NY', '1601 3rd Ave. New York', '147 Lake St, Newburgh, NY', '1400 Pelham Parkway South Bronx, New York 10461', '545 East 142nd Street Bronx, New York 10454', '30 Hamilton St, Dobbs Ferry, NY 10522', '2393 Central Park Ave, Yonkers, NY 10710', '2290 Central Park Ave, Yonkers, NY 10710', '555 S Broadway, Tarrytown, NY 10591', '650 White Plains Rd, Tarrytown, NY 10591', '155 White Plains Rd, Tarrytown, New York', '269A Livingston St, Northvale, NJ 07647', '305 N Central Ave, Hartsdale, NY 10530', '359 N Central Ave, Hartsdale, NY 10530', '2 Park Ave, Yonkers, NY 10703', '259 Heathcote Rd, Scarsdale, NY 10583', '41 E Post Rd, White Plains, NY 10601', '222 Mamaroneck Ave, White Plains, NY 10605', '280 Mamaroneck Ave, White Plains, NY 10605', '7-11 S Broadway, White Plains, NY 10601', '100 Woods Rd, Valhalla, New York', '77 Quaker Ridge Rd Ste 4, New Rochelle, NY', '203 Gramatan Ave, Mt Vernon, NY', '500 Westchester Ave, West Harrison, NY 10604']
55+
#print(process_distance(zip_codes, add2))
56+
vaccine_address = ['871 Saw Mill River Rd, Ardsley, NY 10502', '35 Valley Ave Elmsford, NY, 10523', '2290 Central Park Ave Yonkers, NY 10710', '1230 Nepperhan Ave Yonkers, NY 10703', '81 Ny-303 Tappan, NY 10983', '196 E Hartsdale Ave Hartsdale, NY 10530', '269a Livingston St Northvale, NJ 07647', '333 Saw Mill River Rd Elmsford, NY 10523', '199 Brook St Scarsdale, NY 10583', '199 Brook St Scarsdale, NY 10583', '44 E Post Rd, White Plains, NY 10601', '375 White Plains Rd, Eastchester, NY 10709', '370 White Plains Rd, Eastchester, NY 10709', '24 Mamaroneck Ave, White Plains, NY 10601', '325 Mamaroneck Ave, White Plains, NY 10605', '16 Ny-59, Nyack, NY 10960', '154 Westchester Ave, White Plains, NY 10601', '670 N Broadway, White Plains, NY 10603', '66 Main St, Yonkers, NY 10701', '585 Yonkers Ave, Yonkers, NY 10704', '111 Vredenburgh Ave, Yonkers, NY 10704', '24 W Grand St, Mt Vernon, NY 10552', '6 Mclean Ave, Yonkers, NY 10705', '1046 Yonkers Ave, Yonkers, NY 10704', '5700 Mosholu Ave, The Bronx, NY 10471', '678 Mclean Ave, Yonkers, NY 10704', '2425 Palmer Ave, New Rochelle, NY 10801', '211 E Sandford Blvd, Mt Vernon, NY 10550', '50 W Madison Ave, Dumont, NJ 07628', '175 Memorial Hwy Suite 1-14, New Rochelle, NY 10801', '35 Kensico Rd, Thornwood, NY 10594', '1310 Boston Post Road Ferndale Shopping Center, Larchmont, NY 10538', '4232 Baychester Ave, The Bronx, NY 10466', '202 S Highland Ave, Ossining, NY 10562', '1333 W Boston Post Rd, Larchmont, NY 10538', '1024 Broadway, Thornwood, NY 10594', '4159 White Plains Rd, The Bronx, NY 10466', '551 Main St, New Rochelle, NY 10801', '32 S Middletown Rd, Nanuet, NY 10954', '761 Main St, New Rochelle, NY 10805', '1179 E 233rd St, The Bronx, NY 10466', '20 W Hudson Ave, Englewood, NJ 07631', '10 Portland Ave, Bergenfield, NJ 07621', '3901 White Plains Rd, The Bronx, NY 10466', '5825 Broadway, The Bronx, NY 10463', '3547 Johnson Ave, The Bronx, NY 10463', '541 W 235th St, The Bronx, NY 10463', '350 Engle St, Englewood, NJ 07631', '558 W 235th St, The Bronx, NY 10463', '3480 Jerome Ave, The Bronx, NY 10467']
57+
#print(process_distance(zip_codes, vaccine_address))

makeMessage.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from TestingCenters import full_centers_json
2+
import json
23

34
array = []
45

@@ -11,9 +12,38 @@ def formulate_message(center):
1112
array.append(dict['physical_address'][0]['country'])
1213
array.append(dict['physical_address'][0]['state_province'])
1314
array.append(dict['phones'][0]['number'])
15+
1416
message = "Test center in {}. \n Simply copy-paste this full address into Google Maps: " \
1517
"{}, {}. \n "\
1618
"Here is the center's phone number if you need to make an appointment: {}.\n" \
1719
"I recommend you call to make sure!".format(array[1], array[0], array[3], array[5])
20+
1821
array.clear()
1922
return message
23+
24+
data_storage = None
25+
26+
def formulate_message_vaccine(center_search):
27+
with open('vaccine_centersJsonFinal.json ') as vaccine_file:
28+
vaccine_centers_json = json.load(vaccine_file)
29+
30+
for center in vaccine_centers_json:
31+
address = center['address']
32+
33+
if address == center_search:
34+
id = center['id']
35+
36+
message = "Test center found!. \n Simply click on this address to go to Google Maps: " \
37+
"{}. \n " \
38+
"Here is the vaccine center's phone number to call: {}.\n" \
39+
"Here are the vaccines available.\n Pfizer: {}, \n Moderna: {}, \n Johnson & Johnson: {} \n" \
40+
"The hours are as follows. {}\n" \
41+
"I recommend you call to make sure first!".format(vaccine_centers_json[id-1]['address'],
42+
vaccine_centers_json[id-1]['contact']['phone'],
43+
vaccine_centers_json[id-1]['vaccineBrands']['Pfizer'],
44+
vaccine_centers_json[id-1]['vaccineBrands']['Moderna'],
45+
vaccine_centers_json[id-1]['vaccineBrands']['Johnson & Johnson'],
46+
vaccine_centers_json[id-1]['hours'])
47+
print(message)
48+
return message
49+

0 commit comments

Comments
 (0)