From 8a3832afeed09ceecbb99fe1159ec5eef13526ad Mon Sep 17 00:00:00 2001 From: Robin James Kerrison <7150842+rjkerrison@users.noreply.github.com> Date: Wed, 15 Dec 2021 12:36:02 +0100 Subject: [PATCH] adding automatic handling of vaccine age restrictions --- doctoshotgun.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doctoshotgun.py b/doctoshotgun.py index 3374b6f..b201cdf 100755 --- a/doctoshotgun.py +++ b/doctoshotgun.py @@ -362,6 +362,12 @@ def get_patients(self): return self.page.get_patients() + def get_patient_age(self): + birthdate = datetime.datetime.strptime( + self.patient['birthdate'], '%Y-%m-%d').date() + today = datetime.date.today() + return today.year - birthdate.year - ((today.month, today.day) < (birthdate.month, birthdate.day)) + @classmethod def normalize(cls, string): nfkd = unicodedata.normalize('NFKD', string) @@ -822,6 +828,17 @@ def main(self, cli_args=None): else: motives.append(docto.KEY_ASTRAZENECA) + if docto.get_patient_age() < 18: + # Removing moderna based on eligibility rules + log('Including only Pfizer vaccines as patient is under 18', color='yellow') + inclusions = (docto.KEY_PFIZER_SECOND, docto.KEY_PFIZER, docto.KEY_PFIZER_THIRD) + motives = [motive for motive in motives if motive in inclusions] + elif docto.get_patient_age() < 30: + # Removing moderna based on eligibility rules + log('Excluding Moderna vaccine as patient is under 30', color='yellow') + exclusions = (docto.KEY_MODERNA_SECOND, docto.KEY_MODERNA, docto.KEY_MODERNA_THIRD) + motives = [motive for motive in motives if motive not in exclusions] + vaccine_list = [docto.vaccine_motives[motive] for motive in motives] if args.start_date: