Using a rule to send a mail

Sometimes it's useful to send an e-mail, based on the input of a CRF. Think of the situation where the Study-coordinator wants to be notified when a patient has been randomized.
Before we explain how to do this, a word of warning. The options to send the mail are limited: it will be sent to one or more static addresses and you can not change the message body dynamically. But still it's worth it to give it a try.

Getting the ingredients

The message will be send by a Rule, so just as with a rule, we need the OIDs of the Study Event, the CRF version, the Item Group and the Item. How to do this is explained here in detail.
We'll base our mail on the CRF Randomisation, fig.1.

fig. 1: The CRF

Now we compose our xml-file and I prefer Notepad++ for that. I start the file with a short description, plus the list of OIDs I will use (fig. 2).

fig. 2: the header of the XML file with comments

The part for sending the mail is very much like a normal validation rule, but DiscrepancyNoteAction is now replaced with EmailAction
The tag itself has two elements: Message and To. Message will be used in the Subject of your e-mail message. In the To-tag you can put one or more addresses to which the mail must be sent, separated by a comma.

fig. 3: RuleAssignment

Now you must define the RuleDef and that's straight-forward. You want the rule to fire if the Item with allocation number is not empty (fig. 4).

fig. 4: RuleDef

But how does it look?

'Fine, fine' you may think, 'but what do I see in my mail-reader?'. What you see depends on your mail program, but it will look something like fig. 5.

fig. 5: Mail

As you can see, the Subject of your mail is not just "Randomisation message", but is is preceeded by "OpenClinica" and then the name of your Study, between square brackets.

Then a short introduction follows: "You received this email from OpenClinica regarding 'TOPFIT Trial' because you were listed as a person to contact. Please review the information below: "

Next are the details of the Target of your rule: Study, Site, Study Subject, Study Event Definition, CRF, Section, Item Group, Item Name and Message.

Very handy is the part that follows: a link to the CRF. The message ends with a disclaimer.

Other how-to-pages can be found here.