Skip to content

Form Specification

Benjamin Mwalimu edited this page Jun 9, 2020 · 2 revisions

Form Defination

Here are a few instructions on how to write the JSON Form:

//Start of your JSON FORM
{
  "count": 1,
  "encounter_type": "Birth Registration",
  "mother": {},
  "entity_id": "",
  "relational_id": "",
  "metadata": {},
  "step1": {
    "title": "Birth Registration",
    "fields": [
      {
        "type": "edit_text",
        "openmrs_entity_id": "",
        "hint": "First name",
        "key": "First_Name",
        "v_regex": {
          "value": "[A-Za-z]*",
          "err": "Please enter a valid name"
        }
      },
      {}
    ]
  },
  "properties_file_name": "birth_registration"
}

The android implementation code can be found here

JSON FORM ATTRIBUTES

Attribute Type Meaning
count Integer Number of steps or forms
encounter_type String Type of Encounter in OpenMRS
mother JSON Object Object detailing another encounter created during the first step step1
*entity_id String Unique identifier of the OpenMRS Entity
*relational_id String Unique identifer for the relationship in OpenMRS
metadata JSON Object Object detailing the metadata such as start, end, simserial, deviceid objects found here
step1 JSON Object Object detailing a single form to be displayed as a fragment, activity. Upcoming steps i.e. step2, step3 will only be displayed after step1 is completed
properties_file_name String defines the property file to use for Multi language support

STEP/SINGLE FORM ATTRIBUTES

Attribute Type Meaning
title String The title of the form
fields Array(of form fields) This is a list of input fields in the form

INPUT FIELD ATTRIBUTES

Attribute Type Meaning
type String The type of input field: Available - edit_text, choose_image, check_box, spinner, radio, label, barcode, date_picker, tree
*openmrs_entity_id String The unique identifier of the OpenMRS Entity
hint String This is the string displayed in case the input field is blank
*key String This is the field name in the data models
value String Value of this form field. Optional during creation but generated after the form is filled. Default Value is ""
look_up String **(Optional)**Either "true" or "false" indicating whether it is a lookup field. Default value is "false"
read_only Boolean Indicates whether the value of the field cannot be edited. Default value of read_only is false
hidden Boolean **(Optional)**The field is not visible. Default value is false
relevance JSON Object Object detailing the visibility toggle rules for a specific widget
calculation JSON Object Object detailing any calculations rules tied to the specific widget
constraints JSON Object Object detailing the constraints set on a specific widget
  • For attributes with an asterisk above, go to OpenMRS documentation for more information
  • More widget specific attributes are addressed in the specific widget pages.