Пример #1
0
/**
 * Responds to a commitment to vaccinate event by recording the herd's status
 * as "waiting".
 *
 * @param self the model.
 * @param event a commitment to vaccinate event.
 */
void
handle_commitment_to_vaccinate_event (struct ergadm_model_t_ *self,
                                      EVT_commitment_to_vaccinate_event_t * event)
{
  local_data_t *local_data;
  HRD_herd_t *herd;
  unsigned int nherds, nanimals;

#if DEBUG
  g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
         "----- ENTER handle_commitment_to_vaccinate_event (%s)", MODEL_NAME);
#endif

  local_data = (local_data_t *) (self->model_data);
  herd = event->herd;

  if (local_data->status[herd->index] == NOT_ON_WAITING_LIST)
    {
      local_data->status[herd->index] = event->day;

      /* Increment the count of herds awaiting vaccination. */
      RPT_reporting_add_integer (local_data->nherds_awaiting_vaccination, 1, NULL);
      if (local_data->nherds_awaiting_vaccination_by_prodtype->frequency != RPT_never)
        RPT_reporting_add_integer1 (local_data->nherds_awaiting_vaccination_by_prodtype, 1,
                                    herd->production_type_name);
      nherds = RPT_reporting_get_integer (local_data->nherds_awaiting_vaccination, NULL);
      if (nherds > local_data->peak_nherds)
        {
          local_data->peak_nherds = nherds;
          RPT_reporting_set_integer (local_data->peak_nherds_awaiting_vaccination, nherds, NULL);
        }

      /* Increment the count of animals awaiting vaccination. */
      RPT_reporting_add_integer (local_data->nanimals_awaiting_vaccination, herd->size, NULL);
      if (local_data->nanimals_awaiting_vaccination_by_prodtype->frequency != RPT_never)
        RPT_reporting_add_integer1 (local_data->nanimals_awaiting_vaccination_by_prodtype,
                                    herd->size, herd->production_type_name);
      nanimals = RPT_reporting_get_integer (local_data->nanimals_awaiting_vaccination, NULL);
      if (nanimals > local_data->peak_nanimals)
        {
          local_data->peak_nanimals = nanimals;
          RPT_reporting_set_integer (local_data->peak_nanimals_awaiting_vaccination, nanimals,
                                     NULL);
        }
    }

#if DEBUG
  g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
         "----- EXIT handle_commitment_to_vaccinate_event (%s)", MODEL_NAME);
#endif
}
Пример #2
0
/**
 * Records the day of the first detection.
 *
 * @param self the model.
 * @param event a detection event.
 */
void
handle_detection_event (struct ergadm_model_t_ *self, EVT_detection_event_t * event)
{
    local_data_t *local_data;
    HRD_herd_t *herd;
    char *peek;
    gboolean first;
    HRD_update_t update;

#if DEBUG
    g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "----- ENTER handle_detection_event (%s)", MODEL_NAME);
#endif

    local_data = (local_data_t *) (self->model_data);
    herd = event->herd;

    peek = RPT_reporting_get_text (local_data->detections, NULL);
    first = (peek == NULL) || (strlen (peek) == 0);

    g_string_printf (local_data->target, first ? "%u" : ",%u", herd->index);
    RPT_reporting_append_text (local_data->detections, local_data->target->str, NULL);

    if (NULL != guilib_detect_herd)
    {
        update.index = herd->index;
        update.success = 2;       /* Unused */
        guilib_detect_herd (update);
    }
    /*
       #if ARDEBUG
       printf( "Successful detection: herd index %d\n", herd->index );
       #endif
     */

    if (local_data->first_detection)
    {
        RPT_reporting_set_integer (local_data->day_1st_detection, event->day, NULL);
        local_data->first_detection = FALSE;
    }
    RPT_reporting_add_integer (local_data->nherds_detected, 1, NULL);
    RPT_reporting_add_integer1 (local_data->nherds_detected_by_prodtype, 1,
                                herd->production_type_name);
    RPT_reporting_add_integer (local_data->cumul_nherds_detected, 1, NULL);
    RPT_reporting_add_integer1 (local_data->cumul_nherds_detected_by_prodtype, 1,
                                herd->production_type_name);

#if DEBUG
    g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "----- EXIT handle_detection_event (%s)", MODEL_NAME);
#endif
}
Пример #3
0
/**
 * Responds to a trace result event by recording it.
 *
 * @param self the model.
 * @param event a trace result event.
 */
void
handle_trace_result_event (struct adsm_module_t_ *self, EVT_trace_result_event_t *event)
{
  local_data_t *local_data;
  UNT_unit_t *identified_unit, *origin_unit;
  UNT_trace_t trace;
  ADSM_contact_type contact_type;
  UNT_production_type_t prodtype;
  double nanimals;

  #if DEBUG
    g_debug ("----- ENTER handle_trace_result_event (%s)", MODEL_NAME);
  #endif

  identified_unit = (event->direction == ADSM_TraceForwardOrOut) ? event->exposed_unit : event->exposing_unit;
  origin_unit = (event->direction == ADSM_TraceForwardOrOut) ? event->exposing_unit : event->exposed_unit; 
  
  /* Record the trace in the GUI */
  /* --------------------------- */
  trace.day = (int) event->day;
  trace.initiated_day = (int) event->initiated_day;
  
  trace.identified_index = identified_unit->index;
  trace.identified_state = (ADSM_disease_state) identified_unit->state;
  
  trace.origin_index = origin_unit->index; 
  trace.origin_state = (ADSM_disease_state) origin_unit->state;
  
  trace.trace_type = event->direction;
  trace.contact_type = event->contact_type;
  if (trace.contact_type != ADSM_DirectContact
      && trace.contact_type != ADSM_IndirectContact)
    {
      g_error( "Bad contact type in contact-recorder-model.attempt_trace_event" );
      trace.contact_type = 0;
    }

  if( TRUE == event->traced )
    trace.success = ADSM_SuccessTrue;
  else
    trace.success = ADSM_SuccessFalse; 

  #ifdef USE_SC_GUILIB
    sc_trace_unit( event->exposed_unit, trace );
  #else
    if (NULL != adsm_trace_unit)
      adsm_trace_unit (trace);
  #endif


  /* Record the trace in the SC version */
  /* ---------------------------------- */
  local_data = (local_data_t *) (self->model_data);
  

  /* Record a potentially traced contact. */

  contact_type = event->contact_type;
  prodtype = identified_unit->production_type;
  nanimals = (double)(identified_unit->size);

  RPT_reporting_add_integer (local_data->nunits_potentially_traced, 1);
  RPT_reporting_add_integer (local_data->nunits_potentially_traced_by_contacttype[contact_type], 1);
  RPT_reporting_add_integer (local_data->nunits_potentially_traced_by_prodtype[prodtype], 1);
  RPT_reporting_add_integer (local_data->nunits_potentially_traced_by_contacttype_and_prodtype[contact_type][prodtype], 1);
  RPT_reporting_add_integer (local_data->cumul_nunits_potentially_traced, 1);
  RPT_reporting_add_integer (local_data->cumul_nunits_potentially_traced_by_contacttype[contact_type], 1);
  RPT_reporting_add_integer (local_data->cumul_nunits_potentially_traced_by_prodtype[prodtype], 1);
  RPT_reporting_add_integer (local_data->cumul_nunits_potentially_traced_by_contacttype_and_prodtype[contact_type][prodtype], 1);
  RPT_reporting_add_real (local_data->nanimals_potentially_traced, nanimals);
  RPT_reporting_add_real (local_data->nanimals_potentially_traced_by_contacttype[contact_type], nanimals);
  RPT_reporting_add_real (local_data->nanimals_potentially_traced_by_prodtype[prodtype], nanimals);
  RPT_reporting_add_real (local_data->nanimals_potentially_traced_by_contacttype_and_prodtype[contact_type][prodtype], nanimals);
  RPT_reporting_add_real (local_data->cumul_nanimals_potentially_traced, nanimals);
  RPT_reporting_add_real (local_data->cumul_nanimals_potentially_traced_by_contacttype[contact_type], nanimals);
  RPT_reporting_add_real (local_data->cumul_nanimals_potentially_traced_by_prodtype[prodtype], nanimals);
  RPT_reporting_add_real (local_data->cumul_nanimals_potentially_traced_by_contacttype_and_prodtype[contact_type][prodtype], nanimals);

  if (event->traced == TRUE)
    {
      /* Record a successfully traced contact. */

      RPT_reporting_add_integer (local_data->nunits_traced, 1);
      RPT_reporting_add_integer (local_data->nunits_traced_by_contacttype[contact_type], 1);
      RPT_reporting_add_integer (local_data->nunits_traced_by_prodtype[prodtype], 1);
      RPT_reporting_add_integer (local_data->nunits_traced_by_contacttype_and_prodtype[contact_type][prodtype], 1);
      RPT_reporting_add_integer (local_data->cumul_nunits_traced, 1);
      RPT_reporting_add_integer (local_data->cumul_nunits_traced_by_contacttype[contact_type], 1);
      RPT_reporting_add_integer (local_data->cumul_nunits_traced_by_prodtype[prodtype], 1);
      RPT_reporting_add_integer (local_data->cumul_nunits_traced_by_contacttype_and_prodtype[contact_type][prodtype], 1);
      RPT_reporting_add_real (local_data->nanimals_traced, nanimals);
      RPT_reporting_add_real (local_data->nanimals_traced_by_contacttype[contact_type], nanimals);
      RPT_reporting_add_real (local_data->nanimals_traced_by_prodtype[prodtype], nanimals);
      RPT_reporting_add_real (local_data->nanimals_traced_by_contacttype_and_prodtype[contact_type][prodtype], nanimals);
      RPT_reporting_add_real (local_data->cumul_nanimals_traced, nanimals);
      RPT_reporting_add_real (local_data->cumul_nanimals_traced_by_contacttype[contact_type], nanimals);
      RPT_reporting_add_real (local_data->cumul_nanimals_traced_by_prodtype[prodtype], nanimals);
      RPT_reporting_add_real (local_data->cumul_nanimals_traced_by_contacttype_and_prodtype[contact_type][prodtype], nanimals);
    }

  #if DEBUG
    g_debug ("----- EXIT handle_trace_result_event (%s)", MODEL_NAME);
  #endif
}
Пример #4
0
/**
 * Responds to a new day event by updating the reporting variables.
 *
 * @param self the model.
 * @param herds a list of herds.
 * @param zones a list of zones.
 * @param event a new day event.
 */
void
handle_new_day_event (struct ergadm_model_t_ *self, HRD_herd_list_t * herds,
                      ZON_zone_list_t * zones, EVT_new_day_event_t * event)
{
    local_data_t *local_data;
    gboolean shape_due, area_due, num_areas_due, num_units_due;
    int i;
    ZON_zone_t *zone, *next_smaller_zone;
    GString *s;
    double area;
    unsigned int nherds;
    HRD_herd_t *herd;
    char *drill_down_list[3] = { NULL, NULL, NULL };

#if DEBUG
    g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "----- ENTER handle_new_day_event (%s)", MODEL_NAME);
#endif

    local_data = (local_data_t *) (self->model_data);

    shape_due = RPT_reporting_due (local_data->shape, event->day);
    area_due = RPT_reporting_due (local_data->area, event->day);
    num_areas_due = RPT_reporting_due (local_data->num_separate_areas, event->day);
    num_units_due = RPT_reporting_due (local_data->num_units, event->day);

    for (i = 0; i < local_data->nzones; i++)
    {
        zone = ZON_zone_list_get (zones, i);

        if (shape_due)
        {
            s = polygon_to_wkt (zone->poly);
            RPT_reporting_set_text1 (local_data->shape, s->str, zone->name);
            /* The string was copied so it can be freed. */
            g_string_free (s, TRUE);
        }

        if (area_due)
        {
            area = ZON_update_area (zone);
            RPT_reporting_set_real1 (local_data->area, area, zone->name);
        }

        if (num_areas_due)
            RPT_reporting_set_integer1 (local_data->num_separate_areas,
                                        zone->poly->num_contours, zone->name);
    }

    /* In the loop above, the area of each zone polygon was computed.  But since
     * zones are nested inside of each other, that's not exactly what we want:
     * we want the area displayed for an "outer" zone to exclude the area of the
     * smaller "inner" zones.  So we do that computation here. */
    if (area_due)
    {
        /* Start with the next-to-last zone, because the last one is the
         * "background" zone. */
        for (i = local_data->nzones - 2; i > 0; i--)
        {
            zone = ZON_zone_list_get (zones, i);
            next_smaller_zone = ZON_zone_list_get (zones, i - 1);
            zone->area -= next_smaller_zone->area;
            RPT_reporting_set_real1 (local_data->area, zone->area, zone->name);

            if (NULL != guilib_record_zone_area)
                guilib_record_zone_area (zone->level, zone->area);
        }

        /* Don't forget to report the smallest zone to the GUI! */
        if (NULL != guilib_record_zone_area)
        {
            zone = ZON_zone_list_get (zones, 0);
            guilib_record_zone_area (zone->level, zone->area);
        }
    }

    if (local_data->num_animal_days_by_prodtype->frequency != RPT_never || num_units_due)
    {
        nherds = zones->membership_length;
        for (i = 0; i < local_data->nzones; i++)
        {
            zone = ZON_zone_list_get (zones, i);
            RPT_reporting_set_integer1 (local_data->num_units, 0, zone->name);
        }
        for (i = 0; i < nherds; i++)
        {
            zone = zones->membership[i]->parent;
            RPT_reporting_add_integer1 (local_data->num_units, 1, zone->name);
            herd = HRD_herd_list_get (herds, i);
            if (herd->status != Destroyed)
            {
                drill_down_list[0] = herd->production_type_name;
                drill_down_list[1] = zone->name;
                RPT_reporting_add_integer (local_data->num_animal_days_by_prodtype, herd->size,
                                           drill_down_list);
            }
        }
    }

#if DEBUG
    g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "----- EXIT handle_new_day_event (%s)", MODEL_NAME);
#endif
}
Пример #5
0
/**
 * Responds to an exposure event by recording it.
 *
 * @param self the model.
 * @param event an exposure event.
 */
void
handle_exposure_event (struct naadsm_model_t_ *self, EVT_exposure_event_t * event)
{
  local_data_t *local_data;
  HRD_herd_t *exposing_herd, *exposed_herd;
  const char *cause;
  char *peek;
  gboolean first_of_cause;
  const char *drill_down_list[3] = { NULL, NULL, NULL };
  HRD_expose_t update;
  
#if DEBUG
  g_debug ("----- ENTER handle_exposure_event (%s)", MODEL_NAME);
#endif

  local_data = (local_data_t *) (self->model_data);
  exposing_herd = event->exposing_herd;
  exposed_herd = event->exposed_herd;

  /* Update the text string that lists exposed herd indices. */
  cause = NAADSM_contact_type_abbrev[event->contact_type];
  peek = RPT_reporting_get_text1 (local_data->exposures, cause);
  first_of_cause = (peek == NULL) || (strlen (peek) == 0);

  g_string_printf (local_data->source_and_target,
                   first_of_cause ? "%u->%u" : ",%u->%u",
                   event->exposing_herd->index, event->exposed_herd->index);
  RPT_reporting_append_text1 (local_data->exposures, local_data->source_and_target->str,
                              cause);
                                
  update.src_index = exposing_herd->index;
  update.src_status = (NAADSM_disease_state) exposing_herd->status;
  update.dest_index = exposed_herd->index;
  update.dest_status = (NAADSM_disease_state) exposed_herd->status;
  
  update.initiated_day = (int) event->initiated_day;
  update.finalized_day = (int) event->initiated_day + event->delay;
  
  if( TRUE == event->adequate )
    update.is_adequate = NAADSM_SuccessTrue;
  else
    update.is_adequate = NAADSM_SuccessFalse;
  
  switch (event->contact_type)
    {
      case NAADSM_DirectContact:
      case NAADSM_IndirectContact:
      case NAADSM_AirborneSpread:
        update.exposure_method = event->contact_type;
        break;      
      default:
        /* If this condition occurs, someone forgot something. */
        g_error( "An unrecognized exposure mechanism (%s) occurred in handle_exposure_event", cause );
        update.exposure_method = 0;     
    }

      
#ifdef USE_SC_GUILIB
  sc_expose_herd( exposed_herd, update );
#else	  
  if (NULL != naadsm_expose_herd)
    {
      naadsm_expose_herd (update);
    }
#endif  

#if UNDEFINED
  printf ("Herd at index %d exposed by method %s\n", event->exposed_herd->index, cause);
#endif

  /* Update the counts of exposures. */
  RPT_reporting_add_integer  (local_data->num_units_exposed, 1, NULL);
  RPT_reporting_add_integer1 (local_data->num_units_exposed_by_cause, 1, cause);
  RPT_reporting_add_integer1 (local_data->num_units_exposed_by_prodtype, 1, exposed_herd->production_type_name);
  RPT_reporting_add_integer  (local_data->num_animals_exposed, exposed_herd->size, NULL);
  RPT_reporting_add_integer1 (local_data->num_animals_exposed_by_cause, exposed_herd->size, cause);
  RPT_reporting_add_integer1 (local_data->num_animals_exposed_by_prodtype, exposed_herd->size, exposed_herd->production_type_name);
  RPT_reporting_add_integer  (local_data->cumul_num_units_exposed, 1, NULL);
  RPT_reporting_add_integer1 (local_data->cumul_num_units_exposed_by_cause, 1, cause);
  RPT_reporting_add_integer1 (local_data->cumul_num_units_exposed_by_prodtype, 1, exposed_herd->production_type_name);
  RPT_reporting_add_integer  (local_data->cumul_num_animals_exposed, exposed_herd->size, NULL);
  RPT_reporting_add_integer1 (local_data->cumul_num_animals_exposed_by_cause, exposed_herd->size,
                              cause);
  RPT_reporting_add_integer1 (local_data->cumul_num_animals_exposed_by_prodtype, exposed_herd->size,
                              exposed_herd->production_type_name);
  drill_down_list[0] = cause;
  drill_down_list[1] = exposed_herd->production_type_name;
  if (local_data->num_units_exposed_by_cause_and_prodtype->frequency != RPT_never)
    RPT_reporting_add_integer (local_data->num_units_exposed_by_cause_and_prodtype, 1, drill_down_list);
  if (local_data->num_animals_exposed_by_cause_and_prodtype->frequency != RPT_never)
    RPT_reporting_add_integer (local_data->num_animals_exposed_by_cause_and_prodtype, exposed_herd->size,
                               drill_down_list);
  if (local_data->cumul_num_units_exposed_by_cause_and_prodtype->frequency != RPT_never)
    RPT_reporting_add_integer (local_data->cumul_num_units_exposed_by_cause_and_prodtype, 1, drill_down_list);
  if (local_data->cumul_num_animals_exposed_by_cause_and_prodtype->frequency != RPT_never)
    RPT_reporting_add_integer (local_data->cumul_num_animals_exposed_by_cause_and_prodtype,
                               exposed_herd->size, drill_down_list);
  if (event->adequate)
    {
      RPT_reporting_add_integer (local_data->num_adequate_exposures, 1, NULL);
      RPT_reporting_add_integer (local_data->cumul_num_adequate_exposures, 1, NULL);
    }

#if DEBUG
  g_debug ("----- EXIT handle_exposure_event (%s)", MODEL_NAME);
#endif
}
Пример #6
0
/**
 * Responds to an exposure event by recording it.
 *
 * @param self the model.
 * @param event an exposure event.
 */
void
handle_exposure_event (struct adsm_module_t_ *self, EVT_exposure_event_t * event)
{
  local_data_t *local_data;
  UNT_unit_t *exposing_unit, *exposed_unit;
  UNT_expose_t update;
  ADSM_contact_type cause;
  UNT_production_type_t prodtype;
  double nanimals;
  
#if DEBUG
  g_debug ("----- ENTER handle_exposure_event (%s)", MODEL_NAME);
#endif

  local_data = (local_data_t *) (self->model_data);
  exposing_unit = event->exposing_unit;
  exposed_unit = event->exposed_unit;

  cause = event->contact_type;
                                
  /* No exposing unit means this is an initially infected unit. */
  if (exposing_unit != NULL)
    {
      update.src_index = exposing_unit->index;
      update.src_state = (ADSM_disease_state) exposing_unit->state;
      update.dest_index = exposed_unit->index;
      update.dest_state = (ADSM_disease_state) exposed_unit->state;
  
      update.initiated_day = (int) event->initiated_day;
      update.finalized_day = (int) event->initiated_day + event->delay;
  
      if( TRUE == event->adequate )
        update.is_adequate = ADSM_SuccessTrue;
      else
        update.is_adequate = ADSM_SuccessFalse;
  
      switch (event->contact_type)
        {
          case ADSM_DirectContact:
          case ADSM_IndirectContact:
          case ADSM_AirborneSpread:
            update.exposure_method = event->contact_type;
            break;      
          default:
            /* If this condition occurs, someone forgot something. */
            g_error( "An unrecognized exposure mechanism (%s) occurred in handle_exposure_event", cause );
            update.exposure_method = 0;     
        }

    #ifdef USE_SC_GUILIB
      sc_expose_unit( exposed_unit, update );
    #else	  
      if (NULL != adsm_expose_unit)
        {
          adsm_expose_unit (update);
        }
    #endif  

    #if UNDEFINED
      printf ("unit at index %d exposed by method %s\n", event->exposed_unit->index, cause);
    #endif

      /* Update the counts of exposures. */
      prodtype = exposed_unit->production_type;
      nanimals = (double)(exposed_unit->size);
      RPT_reporting_add_integer (local_data->num_units_exposed, 1);
      RPT_reporting_add_integer (local_data->num_units_exposed_by_cause[cause], 1);
      RPT_reporting_add_integer (local_data->num_units_exposed_by_prodtype[prodtype], 1);
      RPT_reporting_add_integer (local_data->num_units_exposed_by_cause_and_prodtype[cause][prodtype], 1);
      RPT_reporting_add_real (local_data->num_animals_exposed, nanimals);
      RPT_reporting_add_real (local_data->num_animals_exposed_by_cause[cause], nanimals);
      RPT_reporting_add_real (local_data->num_animals_exposed_by_prodtype[prodtype], nanimals);
      RPT_reporting_add_real (local_data->num_animals_exposed_by_cause_and_prodtype[cause][prodtype], nanimals);
      RPT_reporting_add_integer (local_data->cumul_num_units_exposed, 1);
      RPT_reporting_add_integer (local_data->cumul_num_units_exposed_by_cause[cause], 1);
      RPT_reporting_add_integer (local_data->cumul_num_units_exposed_by_prodtype[prodtype], 1);
      RPT_reporting_add_integer (local_data->cumul_num_units_exposed_by_cause_and_prodtype[cause][prodtype], 1);
      RPT_reporting_add_real (local_data->cumul_num_animals_exposed, nanimals);
      RPT_reporting_add_real (local_data->cumul_num_animals_exposed_by_cause[cause], nanimals);
      RPT_reporting_add_real (local_data->cumul_num_animals_exposed_by_prodtype[prodtype], nanimals);
      RPT_reporting_add_real (local_data->cumul_num_animals_exposed_by_cause_and_prodtype[cause][prodtype], nanimals);
      if (event->adequate)
        {
          RPT_reporting_add_integer (local_data->num_adequate_exposures, 1);
          RPT_reporting_add_integer (local_data->cumul_num_adequate_exposures, 1);
          RPT_reporting_add_integer (local_data->cumul_num_adequate_exposures_by_cause[cause], 1);
        }
    }

#if DEBUG
  g_debug ("----- EXIT handle_exposure_event (%s)", MODEL_NAME);
#endif
}
Пример #7
0
/**
 * Responds to a vaccination by recording it.
 *
 * @param self the model.
 * @param event a vaccination event.
 */
void
handle_vaccination_event (struct adsm_module_t_ *self, EVT_vaccination_event_t * event)
{
  local_data_t *local_data;
  UNT_unit_t *unit;
  UNT_control_t update;
  ADSM_control_reason reason;
  UNT_production_type_t prodtype;
  double nanimals;
  
#if DEBUG
  g_debug ("----- ENTER handle_vaccination_event (%s)", MODEL_NAME);
#endif 
  
  local_data = (local_data_t *) (self->model_data);
  unit = event->unit;

  update.unit_index = unit->index;
  update.day_commitment_made = event->day_commitment_made;
  update.reason = event->reason;
  
#ifdef USE_SC_GUILIB
  sc_vaccinate_unit( event->day, unit, update );
#else  
  if (NULL != adsm_vaccinate_unit)
    {
      adsm_vaccinate_unit (update);
    }
#endif  

  reason = event->reason;
  prodtype = unit->production_type;
  nanimals = (double)(unit->size);
  
  /* Initially vaccinated units do not count as the first vaccination. */
  if (event->reason != ADSM_ControlInitialState)
    {
      if (local_data->first_vaccination->is_null)
        {
          RPT_reporting_set_integer (local_data->first_vaccination, event->day);
          RPT_reporting_set_integer (local_data->vaccination_occurred, 1);
        }
      if (local_data->first_vaccination_by_reason[reason]->is_null)
        RPT_reporting_set_integer (local_data->first_vaccination_by_reason[reason], event->day);
      if (local_data->first_vaccination_by_prodtype[prodtype]->is_null)
        RPT_reporting_set_integer (local_data->first_vaccination_by_prodtype[prodtype], event->day);  
      if (local_data->first_vaccination_by_reason_and_prodtype[reason][prodtype]->is_null)
        RPT_reporting_set_integer (local_data->first_vaccination_by_reason_and_prodtype[reason][prodtype], event->day);

      /* Initially vaccinated units also are not included in many of the
       * counts.  They will not be part of vacnU or vacnU broken down by
       * production type.  They will be part of vacnUIni and vacnUIni broken
       * down by production type. */
      RPT_reporting_add_integer (local_data->num_units_vaccinated, 1);
      RPT_reporting_add_integer (local_data->num_units_vaccinated_by_prodtype[prodtype], 1);
      RPT_reporting_add_real (local_data->num_animals_vaccinated, nanimals);
      RPT_reporting_add_real (local_data->num_animals_vaccinated_by_prodtype[prodtype], nanimals);
      RPT_reporting_add_integer (local_data->cumul_num_units_vaccinated, 1);
      RPT_reporting_add_integer (local_data->cumul_num_units_vaccinated_by_prodtype[prodtype], 1);
      RPT_reporting_add_real (local_data->cumul_num_animals_vaccinated, nanimals);
      RPT_reporting_add_real (local_data->cumul_num_animals_vaccinated_by_prodtype[prodtype], nanimals);
    }
  RPT_reporting_add_integer (local_data->num_units_vaccinated_by_reason[reason], 1);
  RPT_reporting_add_real (local_data->num_animals_vaccinated_by_reason[reason], nanimals);
  RPT_reporting_add_integer (local_data->cumul_num_units_vaccinated_by_reason[reason], 1);
  RPT_reporting_add_real (local_data->cumul_num_animals_vaccinated_by_reason[reason], nanimals);
  RPT_reporting_add_integer (local_data->num_units_vaccinated_by_reason_and_prodtype[reason][prodtype], 1);
  RPT_reporting_add_real (local_data->num_animals_vaccinated_by_reason_and_prodtype[reason][prodtype], nanimals);
  RPT_reporting_add_integer (local_data->cumul_num_units_vaccinated_by_reason_and_prodtype[reason][prodtype], 1);
  RPT_reporting_add_real (local_data->cumul_num_animals_vaccinated_by_reason_and_prodtype[reason][prodtype], nanimals);

#if DEBUG
  g_debug ("----- EXIT handle_vaccination_event (%s)", MODEL_NAME);
#endif
}