HTML Form Schema to OpenMRS Form Schema Mapping


Just for clarification, the OpenMRS Form Schema model is referred as "Form Schema" and it's composed by the form, field, form_field and field_type tables in the OpenMRS Data Model. The HTML Form Schema model is referred as "HTML Form Schema" and it's mapped mostly from the HTML code.


The HTML Form has a reference to a Form. All attributes of a Form can be changed in the HTML Form, as if an HTML Form is a Form, so no special mapping is required.


I've identified 2 major field types, that can be mapped in the field_type table:

  • Section, corresponding to structural sections in the HTML (with the <section> tag)
  • Concept, corresponding to Observation questions, identified by the Concept ID (with the <obs> tag)

Sections (<section>) can be mapped as follows:

  • field.field_type = Section
  • =
  • All children of an HtmlFormSection should have its form_field.parent_form_field set to the section

Observations (<obs>) can be mapped as follows:

  • field.field_type = Concept
  • = name
  • field.concept_id = ObsField.question.concept_id

There are some attributes that I think that can be automatically mapped, based on the concept_id but I'm not sure yet:

  • field.table_name
  • field.attribute_name 

Also, there are some attributes that are not mapped in the HTML Form Schema:

  • field.default_value
  • field.select_multiple
  • form_field.field_number
  • form_field.field_part
  • form_field.page_number
  • form_field.min_occurs
  • form_field.max_occurs
  • form_field.required

Observations have answers. This could be mapped by the field_answer table, but I don't believe this table is used right now (I may be wrong). Answers to the obs questions can be an important part of the HTML Form Schema, but they are not currently represented in the OpenMRS Form Schema.