Notifications - danmarksmiljoeportal/rotter GitHub Wiki

Introduction

Each day at 8:00 and 13:00 UTC, a service will look for notifications to be sent to users. Notifications relevant for any specific Municipality or Extermination Company will be combined into an email per user of that organisation with relevant notifications. Users of municipalities may receive different content if they have chosen to subscribe to only select notification types. image

Glossary

R1: R1 Extermination Company R2: R2 Private Exterminator

Notification Types

In the following we list all the types of notifications that exist in the system.

Notifications are created and queued based on Triggers. Triggers are usually events in the system like a Rat Occurrence record being created or updated and having a certain combination of data.

When the daily service collects notifications to send, it will do a final cancellation check to see whether the notification is still relevant. This final check is called the Cancel check. In most cases, if the notification is no longer relevant, it will be deleted.

A created notification needs not necessarily be sent immediately, but may be set with an Execution date in the future. Some notifications can be created for the future as to make sure they are ready in case they are needed. If they are no longer needed, the Cancel check will make sure to remove them.

Sometimes, we will remove any non-executed notifications (ExecutedDate=NULL) before running triggers for new notifications, so that the trigger will be able to reconsider if the type of notification is still viable. We call this Pre-trigger action.

Notification type: The municipality is informed of a new Rat Occurrence MessageType=0 Description: When R1 or R2 creates a new Rat Occurrence on a property that belongs to the municipality Pre-trigger action: Delete any non-executed notification of this message type belonging to same Rat Occurrence Trigger algorithm:

RatOccurrence is created/updated WHERE

  1. CreatedByUser is an R1 or R2 user
  2. Animal = 'Rat'
  3. Non-existed executed notification of this message type belonging to same Rat Occurrence

Execution date: Current date Cancel check: IF Rat Occurrence is deleted Message: Bekæmper fra {firma} (CVR: {firma Cvr}) har oprettet en ny rotteanmeldelse. Send to: Municipality of the Rat Occurrence


Notification type: The municipality is informed of completed Rat Occurrence MessageType=1 Description: When Rat Occurrence that belongs to the municipality is completed. Pre-trigger action: Delete any non-executed notification of this message type belonging to same Rat Occurrence Trigger algorithm:

RatOccurrence is created/updated WHERE

  1. CreatedByUser is an R1 or R2 user AND
  2. The completedate of rat occurrence is updated from NULL to having a value AND
  3. Animal = 'Rat' AND
  4. Non-existed executed notification of this message type belonging to same Rat Occurrence

Execution date: Current date Cancel check: IF Rat Occurrence is deleted Message: Bekæmper fra {firma} (CVR: {firma Cvr}) har afsluttet en rotteanmeldelse. Send to: Municipality of the Rat Occurrence


Notification type: The extermination company is informed of Rat Occurrences that have not been completed within 35 days MessageType=2 Description: When a Rat Occurrence where CreatedByUser is R1 or R2 user has not been completed within 35 days. Pre-trigger action: Delete any non-executed notification of this message type belonging to same Rat Occurrence Trigger algorithm:

RatOccurrence is created/updated WHERE

  1. CreatedByUser is an R1 or R2 user AND
  2. The CompletedDate of Rat Occurrence is NULL
  3. Non-existed executed notification of this message type belonging to same Rat Occurrence

Execution date: In 35 days Cancel check: IF Rat Occurrence is deleted Message: Påmindelse om at rotteanmeldelsen på adressen {adresse} skal afsluttes hurtigst muligt og der er nu allerede gået 35 dage siden anmeldelse Send to:

  1. If RatOccurrence has one or more Rotteanmeldelse_BekaemperNotificationEmails, then send to these AND
  2. If RatOccurrence has values for [dbo].[Bekaempelsesfirma].[ContactEmails] that is not in the Rotteanmeldelse_BekaemperNotificationEmails then also send to these.

Notification type: The municipality is informed of Rat Occurrences that have not been completed within 35 days MessageType=3 Description: When a Rat Occurrence belonging to R1 or R2 user has not yet been completed within 35 days. Pre-trigger action: Delete any non-executed notification of this message type belonging to same Rat Occurrence Trigger algorithm:

RatOccurrence is created/updated WHERE

  1. CreatedByUser is an R1 or R2 user AND
  2. The CompletedDate of Rat Occurrence is NULL
  3. Non-existed executed notification of this message type belonging to same Rat Occurrence

Execution date: In 35 days Cancel check: IF Rat Occurrence is deleted Message: Bekæmper fra {firma} (CVR: {firma Cvr}) har ikke afsluttet rotteanmeldelse indenfor 35 dage. Send to: Municipality of the Rat Occurrence


Notification type: The extermination company is informed of Rat Occurrences that have not been completed within 50 days MessageType=4 Description: When a rat occurrence belonging to R1 or R2 user has not yet been completed within 50 days. Pre-trigger action: Delete any non-executed notification of this message type belonging to same Rat Occurrence Trigger algorithm:

RatOccurrence is created/updated WHERE

  1. CreatedByUser is an R1 or R2 user AND
  2. The CompletedDate of Rat Occurrence is NULL
  3. Non-existed executed notification of this message type belonging to same Rat Occurrence

Execution date: In 50 days Cancel check: IF Rat Occurrence is deleted Message: Påmindelse om at rotteanmeldelsen på adressen {adresse} skal afsluttes hurtigst muligt og der er nu allerede gået 50 dage siden anmeldelse Send to:

  1. If RatOccurrence has one or more Rotteanmeldelse_BekaemperNotificationEmails, then send to these. AND
  2. If RatOccurrence has values for [dbo].[Bekaempelsesfirma].[ContactEmails] that is not in the Rotteanmeldelse_BekaemperNotificationEmails then also send to these.

Notification type: The municipality is informed of Rat Occurrences that have not been completed within 50 days MessageType=5 Description: When a rat occurrence belonging to R1 or R2 user has not yet been completed within 50 days. Pre-trigger action: Delete any non-executed notification of this message type belonging to same Rat Occurrence Trigger algorithm:

RatOccurrence is created/updated WHERE

  1. CreatedByUser is an R1 or R2 user AND
  2. The CompletedDate of Rat Occurrence is NULL
  3. Non-existed executed notification of this message type belonging to same Rat Occurrence

Execution date: In 50 days Cancel check: IF Rat Occurrence is deleted Message: Bekæmper fra {firma} (CVR: {firma Cvr}) har ikke afsluttet rotteanmeldelse indenfor 50 dage Send to: Municipality of the Rat Occurrence


Notifikationstype: Rat Occurrences was started with a poison where strength is neither "weak" nor "other" MessageType=6 Description: When a Rat Occurrence of an R1 or R2 user was not started with a Poison where Poison Strength is "weak" or "other". Pre-trigger action: Delete any non-executed notification of this message type belonging to same Rat Occurrence Trigger algorithm:

RatOccurrence is created/updated WHERE

  1. CreatedByUser is an R1 or R2 user AND
  2. it has at least one related RotteanmeldelseGiftAnvendelse object AND
  3. All the RotteanmeldelseGiftAnvendelse object related with lowest Date have Styrke NOT IN (0,3) (i.e "Andet" or "Svag) AND
  4. Non-existed executed notification of this message type belonging to same Rat Occurrence AND
  5. Animal = 'Rat'

Execution date: Current date Cancel check: IF Rat Occurrence is deleted Message: Bekæmper fra {firma} (CVR: {firma Cvr}) ikke startet med en svag gift Send to: Municipality of the Rat Occurrence


Notification type: Extermination Company has switched from one type of poison to another on the same Rat Occurrence MessageType=7 Description: When changing to the use of a new type of poison on the same Rat Occurrence belonging to a R1 or R2 user. Pre-trigger action: Delete any non-executed notification of this message type belonging to same Rat Occurrence. Trigger algorithm:

RatOccurrence is updated WHERE

  1. CreatedByUser is an R1 or R2 user AND
  2. The array of Poison Types on the Rat Occurrence before and after update is different AND
  3. Animal = 'Rat'

Execution date: Current date Cancel check: IF Rat Occurrence is deleted Message: Bekæmper fra {firma} (CVR: {firma Cvr}) har skiftet gifttype Send to: Municipality of the Rat Occurrence


Notification type: Extermination Company has used more poison than recommended MessageType=8 Description: When more or less poison is used than the limit values ​​set in the rat hole on a rat occurrence belonging to a R1 or R2 user. Right now, the upper limit for all poisons is set at 100 kg. No lower limit has been set, which is why all values ​​down to 0 are accepted. Negative values ​​are not allowed. Pre-trigger action: Delete any non-executed notification of this message type belonging to same Rat Occurrence. Trigger algorithm:

RatOccurrence is created/updated WHERE

  1. CreatedByUser is an R1 or R2 user AND
  2. That Rat Occurrence have RotteanmeldelseGiftAnvendelse with amount greater than 100 kg AND
  3. Animal = 'Rat'

Execution date: Current date Cancel check: IF Rat Occurrence is deleted Message: Bekæmper fra {firma} (CVR: {firma Cvr}) har brugt mere gift end anbefalet Send to: Municipality of the Rat Occurrence


Notification type: An R2 User has asked the municipality to take over the extermination in relation to a Rat Occurrence MessageType=9 Description: When a R2 user wants to hand over a Rat Occurrence to the municipality. Pre-trigger action: N/A Trigger algorithm:

  1. When R2 hands over a Rat Occurrences to municipality

Execution date: Current date Cancel check: IF Rat Occurrence is deleted THEN delete notification Message: Bekæmper fra {childRatOccurrence ExterminationCompany Name} (CVR: {childRatOccurrence ExterminationCompany Cvr}) har bedt kommunen overtage bekæmpelsen Send to: Municipality of the Rat Occurrence


Notification type: AN R2 User has asked a R1 Company to take over the extermination in relation to a Rat Occurrence MessageType=10 Description: When a R2 user wants to transfer a rat occurrence to an R1 user. Pre-trigger action: N/A Trigger algorithm:

  1. When R2 hands over a rat occurrence to R1 user

Execution date: Current date Cancel check: IF Rat Occurrence is deleted THEN delete notification Message: Bekæmper fra {childRatOccurrence ExterminationCompany Name} (CVR: {childRatOccurrence ExterminationCompany Cvr}) har R1-autoriseret om at overtage bekæmpelsen Send to: R1 that is responsible Extermination Company of the Rat Occurrence


Notification type: Bekæmper has created a Rat Occurrence where cause might be of interest to the municipality MessageType=11 Description: When a rat report belonging to a R1 and R2 is given a reason for the rat report, which is marked with a tick in "notification" configuration. That is, a cause that is considered interesting for the municipality. Most recently, the cause types marked as interesting are all those that are drain-related. Pre-trigger action: Delete any non-executed notification of this message type belonging to same Rat Occurrence. Trigger algorithm:

RatOccurrence is created/updated WHERE

  1. CreatedByUser is an R1 or R2 user AND
  2. At least one reason AND
  3. the reason value is in the list ('Brud på privat stikledning', 'Defekt vakuumventil', 'Usikret faldstammeudluftning', 'Defekt tagnedløb', 'Defekt samlebrønd', 'Defekt tagbrønd', 'Usikret gulvafløb', 'Defekt vandlås/manglende vandlås', 'Defekte ledninger under eller i bygninger og beboelse', 'Defekt offentlig ledning (kommunal/forsyning)', 'Defekt offentlig samlebrønd (kommunal/forsyning)') AND
  4. Non-existed executed notification of this message type belonging to same Rat Occurrence AND
  5. Animal = 'Rat'

Execution date: Current date Cancel check: IF Rat Occurrence is deleted Message: Bekæmper fra {firma} har noteret at årsagen til anmeldelsen er: {årsag} Send to: Municipality of the Rat Occurrence


Notification type: Notification that it is time to follow up on a Rat Occurrence MessageType=12 Description: It is possible for R1 and R2 to be notified by the system before a follow-up date. The user can set the number of days notice. When this notice period occurs, a notification is sent. Pre-trigger action: Delete any non-executed notification of this message type belonging to same Rat Occurrence. Trigger algorithm:

When user created or updates rat occurrence (where completedDate is null), the notifications for followup date will be re-calculated

  1. Create new notifications using array of followup dates AND
  2. Remove notification duplicates (in case user has changed reminderDays and thereby created duplicates)

Execution date: One per future follow up date (by date) - reminderDays Cancel check: IF Rat Occurrence is deleted Message: Husk du skal lave opfølgende bekæmpelse på rotteanmeldelse den {opfølgningsdato} på adressen {adresse} Send to:

  1. If RatOccurrence has one or more Rotteanmeldelse_BekaemperNotificationEmails, then send to these AND
  2. If RatOccurrence has values for [dbo].[Bekaempelsesfirma].[ContactEmails] that is not in the Rotteanmeldelse_BekaemperNotificationEmails then also send to these.

Notification type: Send to the municipality if it has not submitted new or edited existing Rat Occurrences in the system for 14 days or more MessageType=13 Description: If the municipality has not created/updated any rat reports for 14 days, a warning is sent that the system may be down. Pre-trigger action: N/A Trigger algorithm:

Trigger is run everyday and checks for each Municipality(x) IF NO Rotteanmeldelse(y) belonging to Municipality(x) exists WHERE

  1. (Rotteanmeldelse(y)'s [AendretAfBrugerId] belongs to Municipality(x) OR Rotteanmeldelse(y)'s [OprettetAfBrugerId] belongs to Municipality(x)) AND
  2. (Rotteanmeldelse(y)'s [AendretDato]> now - 14 days)

Execution date: Current date Cancel check: N/A Message: Vær opmærksom på, at det er {antal dage} dage siden jeres kommune senest har indleveret eller opdateret en rotteanmeldelse i rottehullet. Denne notifikation indeholder et link til den seneste rotteanmeldelse der blev modtaget af Rottedatabasen fra jeres myndighed. Send to: Municipality of the Rat Occurrence


Notification type: When an address is specified as a food business, but the address is not found on Smileyordningen MessageType=14 Description: When R1 and R2 submits a Rat Occurrence where the address is on Smileyordningen, but the user has assessed the property as a food business. Pre-trigger action: Delete any non-executed notification of this message type belonging to same Rat Occurrence. Trigger algorithm:

RatOccurrence is created/updated WHERE

  1. CreatedByUser is an R1 or R2 user AND
  2. Has PropertyType = fødevarevirksomhed AND
  3. IsSmiley = false AND
  4. Non-existed executed notification of this message type belonging to same Rat Occurrence AND
  5. Animal = 'Rat'

Execution date: Current date Cancel check: IF Rat Occurrence is deleted Message: Der er på adressen {adresse} ikke registreret en fødevarevirksomhed omfattet af smileyordning, men bekæmperen vurderer, at det er en fødevarevirksomhed. Danmarks Miljøportal har underrettet Fødevarestyrelsen herom via mailnotifikation. Send to: Municipality of the Rat Occurrence


Notification type: When rat occurrence is created at an address that also exists on the smiley scheme MessageType=15 Description: When rat occurrence is created where the address is on the smiley scheme Pre-trigger action: Delete any non-executed notification of this message type belonging to same Rat Occurrence. Trigger algorithm:

RatOccurrence is created/updated WHERE

  1. CreatedByUser is an R1 or R2 user AND
  2. where the address is on the smiley scheme AND
  3. Non-existed executed notification of this message type belonging to same Rat Occurrence AND
  4. Animal = 'Rat'

Execution date: Current date Cancel check: IF Rat Occurrence is deleted Message: Der er registreret en anmeldelse på adressen {adresse} hvor der også er registreret en virksomhed omfattet af smileyordningen. Du kan undersøge nærmere på www.findsmiley.dk. Send to: Municipality of the Rat Occurrence