HTML Tips to Enhance Your eCRF

In some cases, the display of your OpenClinica eCRF may not be exactly what you had in mind. You may want to highlight key words or phrases, create a bullet point list, or insert a URL or image. Using HTML tags, you can make some simple manipulations to change the look and feel of your case report forms and make them more inviting for data entry.

Using HTML tags to enhance your eCRF

The HTML tags described in this document can be used in the following columns in the CRF Excel template:

  • Items Tab: LEFT_ITEM_TEXT
  • Items Tab: RIGHT_ITEM_TEXT
  • Items Tab: HEADER
  • Items Tab: SUBHEADER
  • Sections Tab: INSTRUCTIONS

What are HTML tags?

HTML, or Hyper Text Markup Language, is a markup language that is commonly used for web page development. HTML is written using “tags” that surround text or elements. These tags typically come in pairs, with a start tag and an end tag:

<start tag>Text to format</end tag>

To insert an HTML tag, simply surround the text you want to format with the desired tag. Below are the HTML tags that work in OpenClinica:


You can download this HTML Tags Knowledge Article to help you to get started.

Inserting URLs and Images

HTML also allows you to insert a URL or Image into your CRF, which may be used to provide users with additional information or references.

Insert a URL

A URL may be inserted into a CRF in order to provide a link to further instructions or protocol information. To insert a URL into your CRF, use the following format:

Inserting images - using HTML tags to optimize your eCRF

Simply replace the areas highlighted in yellow with (a) your URL (inside the quotation marks) and (b) the hyperlinked text that you want to display to the user.

The following example will prompt the user to “Click Here!” and will open the OpenClinica website in a new browser tab:

<a href=”” target=”_blank”>Click Here!</a>

Inserting an image - using HTML tags to optimize your eCRF

Insert an Image

Similarly, HTML can be used to insert an image into your CRF. You might consider using an image to display a pain scale (or other reference image), or even to display your company’s logo.

Inserting an image - using HTML tags in OpenClinica

To insert an image into your CRF, use the following format:

<img src=”images/ImageName”>

Again, simply replace the highlighted text with your image name. You can use PNG, JPG, or GIF image extensions. You can control the height and width of the image using the following format:

<img src=”images/ImageName” width=“n” height=“n”>

The highlighted n corresponds to the desired width and height of the image in pixels.

The following example will insert an image (image1.png) with a width of 300 and a height of 150:

<img src=”images/image1.png” width=”300″ height=”150″>

You can download this Images & URLs Example CRF to help you practice.

The examples included in the above CRF Excel template will insert an image that already exists in the images directory of your OpenClinica application. To insert a custom image, community users will need to place the image in the following directory of the OpenClinica application:


OpenClinica Enterprise customers can request an image be placed on the application server by reaching out to the OpenClinica Enterprise Support team via the Issue Tracker.

Have you used HTML in your CRFs? Let us know if you have any other suggestions or tips!


 The RESPONSE_OPTIONS_TEXT field is not included in the list above, as HTML tags are currently not supported for response options.

 The QUESTION_NUMBER field will display the text properly, but has been known to cause issues when extracting data. Therefore, HTML should not be used in this column.

Demystifying the Decode() Function

When I started learning to use OpenClinica, I was mystified by all of the things there were to learn. One year later, I continue to be surprised by the number of new skills and tricks I am discovering – whether in the form of existing functionality, new features (EventAction Rules!) or community contributions.

In May, I was putting together a workshop for OC14, OpenClinica’s Global Conference, on best practices for building studies in OpenClinica, and a colleague suggested I spend some time explaining all of the functions in our platform that can be used for calculations.

Alright, I thought, that should be easy. Functions for calculations in OpenClinica, while useful, are pretty simple. After reviewing the information found in the CRF Excel template for calculations, this is what I found:

Decode() screenshot

Sum()? Got it.

Min() and max()? Easy.

Stdev()? Fine.

Decode()? … wait, what?

A vague memory of our trainer’s explanation of the decode() function at OpenClinica’s Central User Training flashed through my mind. My guess is that there are users out there who don’t even know this little gem exists. Some of you may have seen it and simply dismissed it.

So what exactly is the decode() function?

The decode() function allows you to create an IF-THEN-ELSE type of statement. An item is compared to a list of search values, one by one. If the item matches a search value, then a corresponding result value is returned.

Here is your basic format:

decode(ComparatorItem, SearchVal1, ResultVal1, SearchVal2, ResultVal2, … DefaultValue)

The ComparatorItem is compared to each SearchVal in the list, one at a time:

  • The ComparatorItem is first compared to SearchVal1.
    • If the ComparatorItem = SearchVal1, return ResultVal1.
    • Otherwise, if ComparatorItem = SearchVal2, return Result2
    • And so on…
  • If none of the values in the Search List match the ComparatorItem, then the DefaultValue is returned.
    • The DefaultValue is optional, and can be omitted entirely.

The decode() function is probably best explained using an example. I will start by illustrating the general format of the function, and then move on to a few examples that may prove useful in your OpenClinica studies.

Let’s say users are entering a cardinal direction initial (i.e. N, S, E, W) and you want to decode the initial to the actual cardinal direction name (i.e. North, South, East, West). Your decode function would resemble the following:

decode(DirectionInitial, N, North, S, South, E, East, W, West, Unknown)

decode() function

Upon clicking save, the entry in the DirectionInitial Item will first be compared to “N” and if there is a match, “North” is returned. Otherwise, the DirectionInitial Item is compared to “E” and if there is a match, “East” is returned, and so on. If DirectionInitial Item does not match any of the options (N, S, E, or W), then “Unknown” will be returned.

Let’s look at a few examples that may be more applicable to your OpenClinica studies…


If you have a Vital Signs or Physical Exam CRF, you may be capturing the Subject’s temperature. In the case report form, there can be two options for temperature units (Celsius or Fahrenheit), but the statistician may be interested only in a final temperature in degrees Celsius. To please both your data entry person and your statistician, you can create a field to capture the Temperature, and then create another Units field to record either Celsius or Fahrenheit. The final Temperature item will contain the decode function, which would resemble the following:

decode(TemperatureUnits, Celsius, Temperature, Fahrenheit, ((Temperature-32)*(5/9)) )

If TemperatureUnits is equal to “Celsius,” then return the value recorded in the Temperature Item. Otherwise, if TemperatureUnits is equal to “Fahrenheit,” then convert the value recorded in the Temperature Item to Celsius.

decode() function example


Additionally, the decode() function is a great tool when scoring responses. For example, you may have an eligibility questionnaire with response options Yes, No, and NA, corresponding to response values 1, 0, and 99. You would like to count the number of ‘Yes’ responses. However, a simple sum() function will not work because if ‘NA’ is selected, ‘99’ will be included in the calculation. This can be solved by combining the decode() function with the sum() function.

First, you will need to determine the decode function for each item. In this case your function would be as follows:


If Yes is selected (value of 1), then 1 will be returned. If No is selected (value of 0) then 0 will be returned. If NA is selected (value of 99) then 0 will be returned.

Note: We only want to calculate the number of ‘Yes’ responses.

This can then be combined into a sum() function. If you have three eligibility items in your CRF, then your decode function would be as follows:

sum(decode(Item1, 1,1,0,0,99,0), decode(Item2, 1,1,0,0,99,0), decode(Item3, 1,1,0,0,99,0)

decode() function examples

Interested in seeing any of these examples in action?
You can download this CRF Excel template which includes each of the three above examples.

Also, if you found another useful way to use this function, feel free to comment and share your tips with us!