Field Types Reference

Field Types

The OpenMRS Form Engine leverages what has sometimes been called “The React Form Engine (RFE)”. This project committed to the schema used by the previous Angular-based Form Engine, and as such, there is a high level of compatibility. The OpenMRS Form Engine supports almost all the field types from the JSON schema with a few extensions. The most commonly used fields include text, textarea, number, date and select.

Field types are defined in the questionOptions definition of a question using the following syntax:

{ "questionOptions": { "rendering": "" // field type goes here } }

text

Renders a text input.

{ "label":"What Identification Number was issued to the client?", "type":"obs", "questionOptions":{ "rendering":"text", "concept":"162576AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" }, "id":"patientIdentificationNumber" }

Renders:

image-20240418-155503.png

number

Renders a number input

{ "label":"Number of pregnancies delivered (parity)", "type":"obs", "id":"noDelivery", "questionOptions":{ "concept":"a899a920-1350-11df-a1f1-0026b9348838", "rendering":"number" }, "validators":[ ] }

Renders:

image-20240418-155607.png

select

Renders as a dropdown list

Renders:

date

Renders as date input. When clicked, the input reveals a date picker with current date as the default value.

Renders:

datetime

Renders the date input with a time picker beside it. When clicked, the input will reveal a time picker with the current time as the default value. The time picker is disabled only until a date is provided

Renders:

 

 

checkbox

Renders like a multi-choice select field. This kind of field lets you select more that one option.

Renders:

textarea

Renders a textarea input. By default, the textarea will be 4 rows tall. You can configure the number of visible text lines for the input by providing a number to the rows property in your questionOptions definition.

Renders:

radio

Renders a radio input. A radio input allows users to select an option from a list. All options are displayed at the same time and only one option from the available choices can be selected.

Renders:

toggle

Renders a toggle input. This type of control is suitable for collecting boolean values. By default, it’s set to false

Renders:

content-switcher

This is a custom single select control from Carbon.

Renders:

fixed-value

Think of this as a hidden HTML input. In some cases, a form needs to a persist a predefined non-mutable value on submission.

This happens for example on instances where multiple forms operate on the same encounter, and where the status of that encounter changes based on the form submitted — for example a lab encounter. A lab request form would set its status to Pending, and when a result comes in, the status becomes Complete.

The value is driven by form behaviour which is defined by user intent. The default (*) behaviour sets the value to 162866AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA (Pending status). When this form is loaded with the COVID_LAB_ORDER_EMBED intent, no observation will be created because the field is evaluated as isHidden.

group

Used to create an obsGroup. This is used when you need to link multiple questions together.

Renders:

repeating

Renders a repeating group field.

Renders:

 

The required number of repeatable groups is inferred from the value obtained from the limitExpression property in the repeatOptions object.

If the number of repeated groups in the form does not match the required number specified for the field, a validation error will be thrown.

file

Renders a file input control. This allows you to upload files such as images and PDFs. It has options to upload files from computer storage of via camera capture.

Renders:

ui-select-extended

The ui-select-extended is a searchable combo box used to load values from a data source. It works with both inbuilt datasources and custom datasources.

The currently inbuilt datasources are:

  • location_datasource - A LocationDataSource component that fetches Location entities with name matching search term entered in the combo box

  • drug_datasource - A ConceptDataSource component that fetches drug Concept entities with name matching search term entered in the combo box

  • problem_datasource - A ConceptDataSource component that fetches diagnosis & symptom Concept entities with name matching search term entered in the combo box

Renders:

 

Under datasource, you pass the datasource name and optionally you can pass a config parameter. For the case of location, in the config, we pass the tag.

The ui-select-extended also has 2 flavours (preloaded and searchable)

searchable means we don't preload the data but instead call the api after the user starts to search. For searchable, you would add an extra parameter in the schema - "isSearchable": "true"

problem

This will render a dropdown list that is hooked up to a Problem DataSource. This field will have answers that have class Diagnosis, Problem or Symptom For example: Reason for hospitalisation: answers such as malaria, fever utilising the ui-select-extended control to render concepts of class Diagnosis and Symptom.

Renders:

drug

This Rendering type is used for capturing a drug as an observation. Behind the scenes this is done by introducing the drug data source and utilising functionality of the ui-select-extended control.

Renders: