Check for vaccine availability or book an appointment on Co-WIN.
USE THIS AT YOUR OWN RISK. See the LICENSE.
This will land your in a Lisp REPL. First you need to switch to the COWIN
package:
(in-package :cowin)
Then you can do the following things.
Check for available vaccination centers using a date and either a district name:
(available-centers (get-centers "08-05-2021" :district-name "Gurgaon"))
Or a pin code:
(available-centers (get-centers "08-05-2021" :pincode "122001"))
The date should be in DD-MM-YYYY format. GET-CENTERS
searches for availabiliy
for seven days starting from the given date.
To book an appointment, first you need to validate your mobile:
(validate-mobile "xxx") ;; xxx here is your mobile number
This will ask you to provide the OTP sent to your mobile. Once the mobile is
validated, the easiest way to book an appointment would be to run the
BOOK-LOOP
function:
(book-loop (list "08-05-2021") :district-name "Gurgaon")
This will try to book an appointment for every beneficiary registered on the validated mobile that doesn't already have an appointment. It will stop when an appointment is booked or when the session expires (approx. 15 minutes).
A center is considered available if it at least one dose is available on any of the dates returned and the age requirement is 18+.
To change the availability logic to suit your needs, for example, to change
the age requirement to 45+, modify SESSION-HAS-AVAILABILITY
as follows:
(defun session-has-availability (session)
(and (plusp (lookup :available--capacity session))
(= (lookup :min--age--limit session) 45)))
To put a restriction on centers that can be booked, modify
SHOULD-BOOK-CENTER
. For example, to restrict the centers by name and
availability date, you can do something like this:
(defun should-book-center (center)
(and (member (lookup :name center) '("Fortis Memorial Resarch Inst" "Max Hospital")
:test #'string-equal)
(let ((sessions (available-sessions (lookup :sessions center))))
(some (lambda (session)
(member (lookup :date session) '("08-05-2021" "09-05-2021")
:test #'string-equal))
sessions))))