Skip to content

Vaccination campaign

VaccinationCampaign

Defines a campaign to vaccinate a group of people in a given time span and with a given vaccine

Source code in june/epidemiology/vaccines/vaccination_campaign.py
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
class VaccinationCampaign:
    """Defines a campaign to vaccinate a group of people in
    a given time span and with a given vaccine

    """

    def __init__(
        self,
        vaccine: Vaccine,
        days_to_next_dose: List[int],
        dose_numbers: List[int] = [0, 1],
        start_time: str = "2100-01-01",
        end_time: str = "2100-01-02",
        group_by: str = "age",
        group_type: str = "50-100",
        group_coverage: float = 1.0,
        last_dose_type: Optional[str] = None,
    ):
        """__init__.

        Parameters
        ----------
        vaccine : Vaccine
            vaccine to give out
        days_to_next_dose : List[int]
            days to wait from the moment a person is vaccinated to
            their next dose. Should have same length as dose_numbers
        dose_numbers : List[int]
            what doses to give out.
            Example: dose_numbers = [0,1] would give out first
            and second dose, whereas dose_numbers = [2] would
            only give a third dose
        start_time : str
            date at which to start vaccinating people
        end_time : str
            date at which to stop vaccinating people
        group_by : str
            defines what group to vaccinate.
            Examples: 'age', 'sex', 'residence', 'primary_activity'
        group_type : str
            from the group defined by group_by, what people to vaccinate.
            Examples:
            if group_by = 'age' -> group_type = '20-40' would vaccinate
            people aged between 20 and 40
            if group_by = 'residence' -> group_type = 'carehome' would vaccinate
            people living in care homes.
        group_coverage : float
            percentage of the eligible group to vaccinate. Must be between 0. and 1.
        last_dose_type : Optional[str]
            if not starting with a first dose (dose_numbers[0] = 0), whether to
            vaccinate only people whose previous vaccines where of a certain type.
        """
        self.start_time = read_date(start_time)
        self.end_time = read_date(end_time)
        self.vaccine = vaccine
        self.days_to_next_dose = days_to_next_dose
        self.group_attribute, self.group_value = self.process_group_description(
            group_by, group_type
        )
        self.total_days = (self.end_time - self.start_time).days
        self.group_coverage = group_coverage
        if last_dose_type is None:
            self.last_dose_type = []
        else:
            self.last_dose_type = last_dose_type
        self.dose_numbers = dose_numbers
        self.vaccinated_ids = set()
        self.starting_dose = self.dose_numbers[0]
        self.days_from_administered_to_finished = (
            sum(self.days_to_next_dose)
            + sum(
                [
                    self.vaccine.days_administered_to_effective[dose]
                    for dose in self.dose_numbers
                ]
            )
            + sum(
                [
                    self.vaccine.days_effective_to_waning[dose]
                    for dose in self.dose_numbers
                ]
            )
            + sum([self.vaccine.days_waning[dose] for dose in self.dose_numbers])
        )

    def is_active(self, date: datetime.datetime) -> bool:
        """Returns true if the policy is active, false otherwise

        Args:
            date (datetime.datetime): date to check

        """
        return self.start_time <= date < self.end_time

    def process_group_description(self, group_by: str, group_type: str) -> Tuple[str]:
        """process_group_description.

        Args:
            group_by (str): group_by
            group_type (str): group_type

        Returns:
            Tuple[str]: 

        """
        if group_by in ("residence", "primary_activity"):
            return f"{group_by}.group.spec", group_type
        else:
            return f"{group_by}", group_type

    def is_target_group(self, person: "Person") -> bool:
        """is_target_group.

        Args:
            person ("Person"): person

        Returns:
            bool: 

        """
        if self.group_attribute != "age":
            try:
                if (
                    operator.attrgetter(self.group_attribute)(person)
                    == self.group_value
                ):
                    return True
            except Exception:
                return False
        else:
            if (
                int(self.group_value.split("-")[0])
                <= getattr(person, self.group_attribute)
                < int(self.group_value.split("-")[1])
            ):
                return True
        return False

    def has_right_dosage(self, person: "Person") -> bool:
        """has_right_dosage.

        Args:
            person ("Person"): person

        Returns:
            bool: 

        """
        if person.vaccinated is not None and self.starting_dose == 0:
            return False
        if self.starting_dose > 0:
            if person.vaccinated is None or person.vaccinated != self.starting_dose - 1:
                return False
            if self.last_dose_type and person.vaccine_type not in self.last_dose_type:
                return False
        return True

    def should_be_vaccinated(self, person: "Person") -> bool:
        """should_be_vaccinated.

        Args:
            person ("Person"): person

        Returns:
            bool: 

        """
        return self.has_right_dosage(person) and self.is_target_group(person)

    def vaccinate(
        self,
        person: "Person",
        date: datetime.datetime,
        record: Optional["Record"] = None,
    ):
        """vaccinate.

        Args:
            person ("Person"): person
            date (datetime.datetime): date
            record (Optional["Record"], optional): record (Default value = None)

        """

        vaccine_trajectory = self.vaccine.generate_trajectory(
            person=person,
            dose_numbers=self.dose_numbers,
            days_to_next_dose=self.days_to_next_dose,
            date=date,
        )
        #print("\nDOSAGE about to be updated via VACCINATE:")
        vaccine_trajectory.update_dosage(person=person, record=record, entered_via=0)
        person.vaccine_trajectory = vaccine_trajectory
        self.vaccinated_ids.add(person.id)

    def daily_vaccination_probability(self, days_passed: int) -> float:
        """daily_vaccination_probability.

        Args:
            days_passed (int): days_passed

        Returns:
            float: 

        """
        return self.group_coverage * (
            1 / (self.total_days - days_passed * self.group_coverage)
        )

__init__(vaccine, days_to_next_dose, dose_numbers=[0, 1], start_time='2100-01-01', end_time='2100-01-02', group_by='age', group_type='50-100', group_coverage=1.0, last_dose_type=None)

init.

Parameters

vaccine : Vaccine vaccine to give out days_to_next_dose : List[int] days to wait from the moment a person is vaccinated to their next dose. Should have same length as dose_numbers dose_numbers : List[int] what doses to give out. Example: dose_numbers = [0,1] would give out first and second dose, whereas dose_numbers = [2] would only give a third dose start_time : str date at which to start vaccinating people end_time : str date at which to stop vaccinating people group_by : str defines what group to vaccinate. Examples: 'age', 'sex', 'residence', 'primary_activity' group_type : str from the group defined by group_by, what people to vaccinate. Examples: if group_by = 'age' -> group_type = '20-40' would vaccinate people aged between 20 and 40 if group_by = 'residence' -> group_type = 'carehome' would vaccinate people living in care homes. group_coverage : float percentage of the eligible group to vaccinate. Must be between 0. and 1. last_dose_type : Optional[str] if not starting with a first dose (dose_numbers[0] = 0), whether to vaccinate only people whose previous vaccines where of a certain type.

Source code in june/epidemiology/vaccines/vaccination_campaign.py
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
def __init__(
    self,
    vaccine: Vaccine,
    days_to_next_dose: List[int],
    dose_numbers: List[int] = [0, 1],
    start_time: str = "2100-01-01",
    end_time: str = "2100-01-02",
    group_by: str = "age",
    group_type: str = "50-100",
    group_coverage: float = 1.0,
    last_dose_type: Optional[str] = None,
):
    """__init__.

    Parameters
    ----------
    vaccine : Vaccine
        vaccine to give out
    days_to_next_dose : List[int]
        days to wait from the moment a person is vaccinated to
        their next dose. Should have same length as dose_numbers
    dose_numbers : List[int]
        what doses to give out.
        Example: dose_numbers = [0,1] would give out first
        and second dose, whereas dose_numbers = [2] would
        only give a third dose
    start_time : str
        date at which to start vaccinating people
    end_time : str
        date at which to stop vaccinating people
    group_by : str
        defines what group to vaccinate.
        Examples: 'age', 'sex', 'residence', 'primary_activity'
    group_type : str
        from the group defined by group_by, what people to vaccinate.
        Examples:
        if group_by = 'age' -> group_type = '20-40' would vaccinate
        people aged between 20 and 40
        if group_by = 'residence' -> group_type = 'carehome' would vaccinate
        people living in care homes.
    group_coverage : float
        percentage of the eligible group to vaccinate. Must be between 0. and 1.
    last_dose_type : Optional[str]
        if not starting with a first dose (dose_numbers[0] = 0), whether to
        vaccinate only people whose previous vaccines where of a certain type.
    """
    self.start_time = read_date(start_time)
    self.end_time = read_date(end_time)
    self.vaccine = vaccine
    self.days_to_next_dose = days_to_next_dose
    self.group_attribute, self.group_value = self.process_group_description(
        group_by, group_type
    )
    self.total_days = (self.end_time - self.start_time).days
    self.group_coverage = group_coverage
    if last_dose_type is None:
        self.last_dose_type = []
    else:
        self.last_dose_type = last_dose_type
    self.dose_numbers = dose_numbers
    self.vaccinated_ids = set()
    self.starting_dose = self.dose_numbers[0]
    self.days_from_administered_to_finished = (
        sum(self.days_to_next_dose)
        + sum(
            [
                self.vaccine.days_administered_to_effective[dose]
                for dose in self.dose_numbers
            ]
        )
        + sum(
            [
                self.vaccine.days_effective_to_waning[dose]
                for dose in self.dose_numbers
            ]
        )
        + sum([self.vaccine.days_waning[dose] for dose in self.dose_numbers])
    )

daily_vaccination_probability(days_passed)

daily_vaccination_probability.

Parameters:

Name Type Description Default
days_passed int

days_passed

required

Returns:

Name Type Description
float float
Source code in june/epidemiology/vaccines/vaccination_campaign.py
231
232
233
234
235
236
237
238
239
240
241
242
243
def daily_vaccination_probability(self, days_passed: int) -> float:
    """daily_vaccination_probability.

    Args:
        days_passed (int): days_passed

    Returns:
        float: 

    """
    return self.group_coverage * (
        1 / (self.total_days - days_passed * self.group_coverage)
    )

has_right_dosage(person)

has_right_dosage.

Parameters:

Name Type Description Default
person Person

person

required

Returns:

Name Type Description
bool bool
Source code in june/epidemiology/vaccines/vaccination_campaign.py
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
def has_right_dosage(self, person: "Person") -> bool:
    """has_right_dosage.

    Args:
        person ("Person"): person

    Returns:
        bool: 

    """
    if person.vaccinated is not None and self.starting_dose == 0:
        return False
    if self.starting_dose > 0:
        if person.vaccinated is None or person.vaccinated != self.starting_dose - 1:
            return False
        if self.last_dose_type and person.vaccine_type not in self.last_dose_type:
            return False
    return True

is_active(date)

Returns true if the policy is active, false otherwise

Parameters:

Name Type Description Default
date datetime

date to check

required
Source code in june/epidemiology/vaccines/vaccination_campaign.py
121
122
123
124
125
126
127
128
def is_active(self, date: datetime.datetime) -> bool:
    """Returns true if the policy is active, false otherwise

    Args:
        date (datetime.datetime): date to check

    """
    return self.start_time <= date < self.end_time

is_target_group(person)

is_target_group.

Parameters:

Name Type Description Default
person Person

person

required

Returns:

Name Type Description
bool bool
Source code in june/epidemiology/vaccines/vaccination_campaign.py
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
def is_target_group(self, person: "Person") -> bool:
    """is_target_group.

    Args:
        person ("Person"): person

    Returns:
        bool: 

    """
    if self.group_attribute != "age":
        try:
            if (
                operator.attrgetter(self.group_attribute)(person)
                == self.group_value
            ):
                return True
        except Exception:
            return False
    else:
        if (
            int(self.group_value.split("-")[0])
            <= getattr(person, self.group_attribute)
            < int(self.group_value.split("-")[1])
        ):
            return True
    return False

process_group_description(group_by, group_type)

process_group_description.

Parameters:

Name Type Description Default
group_by str

group_by

required
group_type str

group_type

required

Returns:

Type Description
Tuple[str]

Tuple[str]:

Source code in june/epidemiology/vaccines/vaccination_campaign.py
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
def process_group_description(self, group_by: str, group_type: str) -> Tuple[str]:
    """process_group_description.

    Args:
        group_by (str): group_by
        group_type (str): group_type

    Returns:
        Tuple[str]: 

    """
    if group_by in ("residence", "primary_activity"):
        return f"{group_by}.group.spec", group_type
    else:
        return f"{group_by}", group_type

should_be_vaccinated(person)

should_be_vaccinated.

Parameters:

Name Type Description Default
person Person

person

required

Returns:

Name Type Description
bool bool
Source code in june/epidemiology/vaccines/vaccination_campaign.py
193
194
195
196
197
198
199
200
201
202
203
def should_be_vaccinated(self, person: "Person") -> bool:
    """should_be_vaccinated.

    Args:
        person ("Person"): person

    Returns:
        bool: 

    """
    return self.has_right_dosage(person) and self.is_target_group(person)

vaccinate(person, date, record=None)

vaccinate.

Parameters:

Name Type Description Default
person Person

person

required
date datetime

date

required
record Optional[Record]

record (Default value = None)

None
Source code in june/epidemiology/vaccines/vaccination_campaign.py
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
def vaccinate(
    self,
    person: "Person",
    date: datetime.datetime,
    record: Optional["Record"] = None,
):
    """vaccinate.

    Args:
        person ("Person"): person
        date (datetime.datetime): date
        record (Optional["Record"], optional): record (Default value = None)

    """

    vaccine_trajectory = self.vaccine.generate_trajectory(
        person=person,
        dose_numbers=self.dose_numbers,
        days_to_next_dose=self.days_to_next_dose,
        date=date,
    )
    #print("\nDOSAGE about to be updated via VACCINATE:")
    vaccine_trajectory.update_dosage(person=person, record=record, entered_via=0)
    person.vaccine_trajectory = vaccine_trajectory
    self.vaccinated_ids.add(person.id)

VaccinationCampaigns

VaccinationCampaigns.

Source code in june/epidemiology/vaccines/vaccination_campaign.py
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
class VaccinationCampaigns:
    """VaccinationCampaigns."""

    def __init__(self, vaccination_campaigns: List[VaccinationCampaign]):
        """__init__.

        Parameters
        ----------
        vaccination_campaigns : List[VaccinationCampaign]
            vaccination_campaigns
        """
        self.vaccination_campaigns = vaccination_campaigns

    @classmethod
    def from_disease_config(
        cls, disease_config: DiseaseConfig
    ):
        """from_config.

        Args:
            disease_config (DiseaseConfig): 

        """
        vaccines = Vaccines.from_config(disease_config=disease_config)

        config = disease_config.vaccination_manager.get_vaccination_campaigns()
        vaccination_campaigns = []
        for key, params_dict in config.items():
            vaccine_type = params_dict["vaccine_type"]

            params_dict["vaccine"] = vaccines.get_by_name(vaccine_type)

            campaign = VaccinationCampaign(
                **{k: v for k, v in params_dict.items() if k != "vaccine_type"}
            )
            vaccination_campaigns.append(campaign)

        return cls(vaccination_campaigns=vaccination_campaigns)

    def __iter__(
        self,
    ):
        """__iter__."""
        return iter(self.vaccination_campaigns)

    def get_active(self, date: datetime) -> List[VaccinationCampaign]:
        """get_active.

        Args:
            date (datetime): date

        Returns:
            List[VaccinationCampaign]: 

        """
        return [vc for vc in self.vaccination_campaigns if vc.is_active(date)]

    def apply(
        self, person: "Person", date: datetime, record: Optional["Record"] = None
    ):
        """apply.

        Args:
            person ("Person"): person
            date (datetime): date
            record (Optional["Record"], optional): record (Default value = None)

        """
        # Step 1: Get active vaccination campaigns
        active_campaigns = self.get_active(date=date)

        # Step 2: Check eligibility and calculate probabilities
        daily_probability, campaigns_to_chose_from = [], []
        counter = 0
        for vc in active_campaigns:
            counter += 1
            if vc.should_be_vaccinated(person=person):
                days_passed = (date - vc.start_time).days
                prob = vc.daily_vaccination_probability(days_passed=days_passed)
                daily_probability.append(prob)
                campaigns_to_chose_from.append(vc)

        # Proceed only if the person is eligible
        if daily_probability:

            daily_probability = np.array(daily_probability)
            norm = daily_probability.sum()

            # Step 3: Normalise probabilities and decide vaccination
            if random() < norm:
                daily_probability /= norm
                campaign = np.random.choice(campaigns_to_chose_from, p=daily_probability)
                #print(f"Person ID {person.id} is eligible for vaccination on {date}.")
                #print(f"Total Daily Vaccination Probability (Norm): {norm:.2f}")
                #print(
                #    f"Person ID {person.id} is vaccinated in Campaign '{counter}' on {date}."
                #)
                campaign.vaccinate(person=person, date=date, record=record)
            #else:
                #print(f"Person ID {person.id} did not get vaccinated (random chance).")

    def collect_all_dates_in_past(
        self, current_date: datetime.datetime
    ) -> Set[datetime.datetime]:
        """

        Args:
            current_date (datetime.datetime): 

        """
        dates = set()
        for cv in self.vaccination_campaigns:
            start_time = cv.start_time
            if start_time < current_date:
                days_to_finished = cv.days_from_administered_to_finished
                end_time = min(
                    current_date,
                    cv.end_time + datetime.timedelta(days=days_to_finished),
                )
                delta = end_time - start_time
                for i in range(delta.days + 1):
                    date = start_time + datetime.timedelta(days=i)
                    dates.add(date)
        return sorted(list(dates))

    def apply_past_campaigns(
        self, people, date: datetime.datetime, record: Optional["Record"] = None
    ):
        """

        Args:
            people: 
            date (datetime.datetime): 
            record (Optional["Record"], optional): (Default value = None)

        """
        dates_to_vaccinate = self.collect_all_dates_in_past(current_date=date)
        logger.info(f"Applying past vaccination campaigns...")

        total_people_updated = 0  # Counter to track people with updated vaccine trajectories
        tpv = 0
        for date_to_vax in dates_to_vaccinate:
            logger.info(f"Vaccinating at date {date_to_vax.date()}")
            for person in people:
                self.apply(person=person, date=date_to_vax, record=record)
                tpv +=1
                if person.vaccine_trajectory is not None:
                    person.vaccine_trajectory.update_vaccine_effect(
                        person=person, date=date_to_vax, record=record
                    )
                    total_people_updated += 1  # Increment the counter when updated

            if record is not None:
                record.time_step(timestamp=date_to_vax)
        logger.info(f"Total people updated with vaccine effects: {total_people_updated} out of {tpv}")
        logger.info(f"Finished applying past vaccinations campaigns.")

__init__(vaccination_campaigns)

init.

Parameters

vaccination_campaigns : List[VaccinationCampaign] vaccination_campaigns

Source code in june/epidemiology/vaccines/vaccination_campaign.py
249
250
251
252
253
254
255
256
257
def __init__(self, vaccination_campaigns: List[VaccinationCampaign]):
    """__init__.

    Parameters
    ----------
    vaccination_campaigns : List[VaccinationCampaign]
        vaccination_campaigns
    """
    self.vaccination_campaigns = vaccination_campaigns

__iter__()

iter.

Source code in june/epidemiology/vaccines/vaccination_campaign.py
285
286
287
288
289
def __iter__(
    self,
):
    """__iter__."""
    return iter(self.vaccination_campaigns)

apply(person, date, record=None)

apply.

Parameters:

Name Type Description Default
person Person

person

required
date datetime

date

required
record Optional[Record]

record (Default value = None)

None
Source code in june/epidemiology/vaccines/vaccination_campaign.py
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
def apply(
    self, person: "Person", date: datetime, record: Optional["Record"] = None
):
    """apply.

    Args:
        person ("Person"): person
        date (datetime): date
        record (Optional["Record"], optional): record (Default value = None)

    """
    # Step 1: Get active vaccination campaigns
    active_campaigns = self.get_active(date=date)

    # Step 2: Check eligibility and calculate probabilities
    daily_probability, campaigns_to_chose_from = [], []
    counter = 0
    for vc in active_campaigns:
        counter += 1
        if vc.should_be_vaccinated(person=person):
            days_passed = (date - vc.start_time).days
            prob = vc.daily_vaccination_probability(days_passed=days_passed)
            daily_probability.append(prob)
            campaigns_to_chose_from.append(vc)

    # Proceed only if the person is eligible
    if daily_probability:

        daily_probability = np.array(daily_probability)
        norm = daily_probability.sum()

        # Step 3: Normalise probabilities and decide vaccination
        if random() < norm:
            daily_probability /= norm
            campaign = np.random.choice(campaigns_to_chose_from, p=daily_probability)
            #print(f"Person ID {person.id} is eligible for vaccination on {date}.")
            #print(f"Total Daily Vaccination Probability (Norm): {norm:.2f}")
            #print(
            #    f"Person ID {person.id} is vaccinated in Campaign '{counter}' on {date}."
            #)
            campaign.vaccinate(person=person, date=date, record=record)

apply_past_campaigns(people, date, record=None)

Parameters:

Name Type Description Default
people
required
date datetime
required
record Optional[Record]

(Default value = None)

None
Source code in june/epidemiology/vaccines/vaccination_campaign.py
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
def apply_past_campaigns(
    self, people, date: datetime.datetime, record: Optional["Record"] = None
):
    """

    Args:
        people: 
        date (datetime.datetime): 
        record (Optional["Record"], optional): (Default value = None)

    """
    dates_to_vaccinate = self.collect_all_dates_in_past(current_date=date)
    logger.info(f"Applying past vaccination campaigns...")

    total_people_updated = 0  # Counter to track people with updated vaccine trajectories
    tpv = 0
    for date_to_vax in dates_to_vaccinate:
        logger.info(f"Vaccinating at date {date_to_vax.date()}")
        for person in people:
            self.apply(person=person, date=date_to_vax, record=record)
            tpv +=1
            if person.vaccine_trajectory is not None:
                person.vaccine_trajectory.update_vaccine_effect(
                    person=person, date=date_to_vax, record=record
                )
                total_people_updated += 1  # Increment the counter when updated

        if record is not None:
            record.time_step(timestamp=date_to_vax)
    logger.info(f"Total people updated with vaccine effects: {total_people_updated} out of {tpv}")
    logger.info(f"Finished applying past vaccinations campaigns.")

collect_all_dates_in_past(current_date)

Parameters:

Name Type Description Default
current_date datetime
required
Source code in june/epidemiology/vaccines/vaccination_campaign.py
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
def collect_all_dates_in_past(
    self, current_date: datetime.datetime
) -> Set[datetime.datetime]:
    """

    Args:
        current_date (datetime.datetime): 

    """
    dates = set()
    for cv in self.vaccination_campaigns:
        start_time = cv.start_time
        if start_time < current_date:
            days_to_finished = cv.days_from_administered_to_finished
            end_time = min(
                current_date,
                cv.end_time + datetime.timedelta(days=days_to_finished),
            )
            delta = end_time - start_time
            for i in range(delta.days + 1):
                date = start_time + datetime.timedelta(days=i)
                dates.add(date)
    return sorted(list(dates))

from_disease_config(disease_config) classmethod

from_config.

Parameters:

Name Type Description Default
disease_config DiseaseConfig
required
Source code in june/epidemiology/vaccines/vaccination_campaign.py
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
@classmethod
def from_disease_config(
    cls, disease_config: DiseaseConfig
):
    """from_config.

    Args:
        disease_config (DiseaseConfig): 

    """
    vaccines = Vaccines.from_config(disease_config=disease_config)

    config = disease_config.vaccination_manager.get_vaccination_campaigns()
    vaccination_campaigns = []
    for key, params_dict in config.items():
        vaccine_type = params_dict["vaccine_type"]

        params_dict["vaccine"] = vaccines.get_by_name(vaccine_type)

        campaign = VaccinationCampaign(
            **{k: v for k, v in params_dict.items() if k != "vaccine_type"}
        )
        vaccination_campaigns.append(campaign)

    return cls(vaccination_campaigns=vaccination_campaigns)

get_active(date)

get_active.

Parameters:

Name Type Description Default
date datetime

date

required

Returns:

Type Description
List[VaccinationCampaign]

List[VaccinationCampaign]:

Source code in june/epidemiology/vaccines/vaccination_campaign.py
291
292
293
294
295
296
297
298
299
300
301
def get_active(self, date: datetime) -> List[VaccinationCampaign]:
    """get_active.

    Args:
        date (datetime): date

    Returns:
        List[VaccinationCampaign]: 

    """
    return [vc for vc in self.vaccination_campaigns if vc.is_active(date)]