```coffeescript
SmartEvents = require '/imports/collections/smartEvents'
Incidents = require '/imports/collections/incidentReports'
#Allow multiple modals or the suggested locations list won't show after the
#loading modal is hidden
Modal.allowMultiple = true

Template.smartEvent.onCreated ->
  @editState = new ReactiveVar false
  @eventId = new ReactiveVar()
  @autorun =>
    eventId = Router.current().getParams()._id
    @eventId.set eventId
    @subscribe 'smartEvents', eventId,
      onReady: =>
        event = SmartEvents.findOne(eventId)
        eventDateRange = event.dateRange
        query = disease: event.disease
        if eventDateRange
          query['dateRange.start'] = $lte: eventDateRange.end
          query['dateRange.end'] = $gte: eventDateRange.start
        @subscribe 'smartEventIncidents', query

Template.smartEvent.onRendered ->
  new Clipboard '.copy-link'

Template.smartEvent.helpers
  smartEvent: ->
    SmartEvents.findOne(Template.instance().eventId.get())

  isEditing: ->
    Template.instance().editState.get()

  deleted: ->
    SmartEvents.findOne(Template.instance().eventId.get())?.deleted

  hasAssociatedIncidents: ->
    Incidents.find().count()

  incidentReportsTemplateData: ->
    incidents: Incidents.find({}, {sort: {'dateRange.end': 1}})
    eventType: 'smart'

Template.smartEvent.events
  'click .edit-link, click #cancel-edit': (event, instance) ->
    instance.editState.set(not instance.editState.get())
```

Make IR query reactive when smart event is edited
user
```coffeescript
SmartEvents = require '/imports/collections/smartEvents'
Incidents = require '/imports/collections/incidentReports'
#Allow multiple modals or the suggested locations list won't show after the
#loading modal is hidden
Modal.allowMultiple = true

Template.smartEvent.onCreated ->
  @editState = new ReactiveVar false
  @eventId = new ReactiveVar()

Template.smartEvent.onRendered ->
  eventId = Router.current().getParams()._id
  @eventId.set(eventId)
  @subscribe 'smartEvents', eventId
  @autorun =>
    event = SmartEvents.findOne(eventId)
    if event
      eventDateRange = event.dateRange
      query = disease: event.disease
      if eventDateRange
        query['dateRange.start'] = $lte: eventDateRange.end
        query['dateRange.end'] = $gte: eventDateRange.start
      @subscribe 'smartEventIncidents', query

Template.smartEvent.onRendered ->
  new Clipboard '.copy-link'

Template.smartEvent.helpers
  smartEvent: ->
    SmartEvents.findOne(Template.instance().eventId.get())

  isEditing: ->
    Template.instance().editState.get()

  deleted: ->
    SmartEvents.findOne(Template.instance().eventId.get())?.deleted

  hasAssociatedIncidents: ->
    Incidents.find().count()

  incidentReportsTemplateData: ->
    incidents: Incidents.find({}, sort: 'dateRange.end': 1)
    eventType: 'smart'

Template.smartEvent.events
  'click .edit-link, click #cancel-edit': (event, instance) ->
    instance.editState.set(not instance.editState.get())
```
assistant