Skip to content

vaccinations

vaccinations.py

module

Vaccination module, initialize and store all vaccination objects.

Attibutes

vaccinations (list): List of vacination objects

__init__(self, vacc_params, comm) special

Initializes vaccination module.

Parameters:

Name Type Description Default
vacc_params list

List of parsed vaccinations parameters.

required
comm comorbuss.community

Community object

required
Source code in
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
def __init__(self, vacc_params, comm):
    """Initializes vaccination module.

    Args:
        vacc_params (list): List of parsed vaccinations parameters.
        comm (comorbuss.community): Community object
    """
    super(module, self).__init__(vacc_params, comm, name=__name__)

    self.pop.add_attribute("particles_coefficients", {}, store=False)

    # Initialize vaccinations
    self.vaccinations = []
    for i, vacc_param in enumerate(vacc_params):
        self.init_vacc(vacc_param, i + 1)

    for vaccination in self.vaccinations:
        setattr(self, vaccination.name, vaccination)

    # Check if module has valid vaccination configuration.
    self.loaded = False
    self.check_loaded()
    self.list = self.vaccinations

init_vacc(self, vacc_param, i)

Initialize vaccination policies.

Parameters:

Name Type Description Default
vacc_param dict

Parameters for the module.

required
i community

Vaccination id.

required

Returns:

Type Description
List

List of the vaccination objects.

Source code in
245
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
def init_vacc(self, vacc_param, i):
    """Initialize vaccination policies.

    Args:
        vacc_param (dict): Parameters for the module.
        i (community): Vaccination id.

    Returns:
        List: List of the vaccination objects.
    """
    vacc_param["effectiveness"], eff_ok = effectiveness_parse(
        vacc_param["effectiveness"], vacc_param["name"], self.comm
    )
    vacc_param["filter"], fok = filter_parse(
        vacc_param["filter"],
        self.comm,
        allowed_filters=["tracing", "service", "module", "workers"],
    )
    vacc_param["id"] = i
    if eff_ok and fok:
        vacc = vaccination(vacc_param, self.comm, self)
        self.vaccinations.append(vacc)
        return vacc, eff_ok and fok
    else:
        self.comm.event_log(
            "Can't activate {} vaccination protocol, there is an invalid filter or effectiveness.".format(
                vacc_param["name"]
            ),
            S.MSG_WRNG,
        )

log_results(self)

Aggregate vaccinations related results at the end of the simulation.

Source code in
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
def log_results(self):
    """Aggregate vaccinations related results at the end of the simulation."""
    nvac = np.sum(self.pop.time_vaccinated >= 0)
    self.event_log("Total number vaccinated: {:}".format(nvac), S.MSG_RSLT)
    calculate_efficacy = nvac < self.pop.Nparticles
    if calculate_efficacy:
        self.comm.add_to_store("efficacy", "comm.vaccinations.efficacy", False)
        self.efficacy = []
    else:
        self.event_log(
            "Can't calculate efficacy of vaccinations, there is no unvaccinated particles.",
            S.MSG_RSLT,
        )
    for vacc in self.vaccinations:
        nvac = np.sum(self.pop.immunity_state == vacc.id)
        self.event_log('"{}" vaccination: {:}'.format(vacc.name, nvac), S.MSG_RSLT)
        if calculate_efficacy:
            efficacy, limits = vacc.calculate_efficacy()
            self.efficacy.append((efficacy, limits))
            self.event_log(
                '"{}" efficacy: {:.1f}%'.format(vacc.name, 100 * efficacy),
                S.MSG_RSLT,
            )

run(self, at_start=False)

Runs the vaccination campaigns set on self.vaccinations.

Source code in
291
292
293
294
295
296
def run(self, at_start=False):
    """Runs the vaccination campaigns set on self.vaccinations."""
    for vacc in self.vaccinations:
        vacc(at_start=at_start)

    self.update_disease_coeficients()

update_disease_coeficients(self)

Update coefficients for each affected disease attribute.

Source code in
298
299
300
301
302
303
304
305
def update_disease_coeficients(self):
    """Update coefficients for each affected disease attribute."""
    for attr in self.pop.particles_coefficients:
        self.pop.disease.set_coefficient(
            attr,
            self.pop.particles_coefficients[attr][self.clk.today, :],
            "vaccinations",
        )

triage

Parses vaccinations parameters.

Parameters:

Name Type Description Default
vaccinations list

List of vaccinations parameters.

required
sim_parameters dict

Parsed simulation parameters.

required
clk clock

Clock object.

required
event_log function

Event_log function.

required

Returns:

Type Description
list

List of parsed vaccinations parameters.

Source code in
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
def triage(vaccinations, sim_parameters, clk, event_log):
    """Parses vaccinations parameters.

    Args:
        vaccinations (list):  List of vaccinations parameters.
        sim_parameters (dict): Parsed simulation parameters.
        clk (clock): Clock object.
        event_log (function): Event_log function.

    Returns:
        list: List of parsed vaccinations parameters.
    """
    from ...triage import parse_from_defaults, merge_list_of_dicts

    vaccinations = merge_list_of_dicts(vaccinations, "vaccinations", event_log)

    for vacc in vaccinations:
        parse_from_defaults(vacc, "vaccination", DEFAULTS, DEFAULTS_TYPES, event_log)

        vacc["doses_per_day"] = int(
            np.max([vacc["doses_per_day"] / sim_parameters["norm_N"], 1])
        )

    return vaccinations

ADULTS

Apply the default number of doses on adults citizens (age groups 5 to 21, 20+ years old).

CHILDRENS

Apply the default number of doses on child citizens (age groups 0 to 4, 0-19 years old).

DIAG_NO

Apply the default number of doses on citizens that where not diagnosed.

HOSPITALS_WORKERS

Apply the default number of doses on hospitals workers.

MAKETS_WORKERS

Apply the default number of doses on markets workers.

SENIORS

Apply the default number of doses on senior citizens (age groups 12 to 21, 60+ years old).

VACC_NYET

Marker for particles not vaccinated