Infopath to HTML Form Converter (Design Page)

Note: These are NOT instructions for users of this module. This is a description of the project for the developers

Background

Originally, the only way to create data entry forms in OpenMRS was using Microsoft Infopath. Now there are alternatives--one that has several advantages is the HTML Form Entry module. It would ease migration to this module if there were an automatic utility to convert an Infopath form to an HTML Form. The point of this project is to write that utility.

What's in an Infopath form? An HTML Form?

An Infopath form is an XSN file. (This is actually just a CAB archive with an XSN file extension. Windows can handle these natively, while on linux you'd use the 'cabextract' utility.) Among other files, the archive contains:

  • formentry.xsd -> the model of the form, representing the "form schema" in OpenMRS

  • page#.xsl (multiple) -> each of these is the view for a single page of the form

An OpenMRS HTML Form is an xml document that contains mostly HTML, but also some special tags, in particular <obs/> which puts an observation widget on the form. See HTML Form Entry Module for an example and all available tags.

Examples

Attached here is an example of an Infopath XSN file that represents PIH's Cardiology Consultation form. We will use this as an example. To see what this looks like you would need to download the file, and (in Windows) right click on it and say Design.

What you need to do

You need to merge the xsl files in the infopath XSN, along with supporting information from the xsd file in the XSN, and create an HTML Form Entry xml document from it. Using XSLT might be the way to go, or else doing some brute-force java code with regex searches.

These are all based on the example.

Element

Infopath representation

HTML Form Representation

Element

Infopath representation

HTML Form Representation

Pages

File names page1.xsl

<htmlform> <page title="Page 1"> ... </page> ... </htmlform>

Sections

???

<section headerLabel="section 1"> content here </section>

Patient Name

(other things besides given_name work similarly)< span hideFocus="1" ... xd:binding="patient/patient.given_name" ... >
<xsl:value-of select="patient/patient.given_name"/>
</ span>

<lookup expression="patient.personName.givenName"/>

Encounter location

the whole radio button section with Rusumo, Mulindi, etc.

Encounter date

Date picker widget bound to encounter/encounter.encounter_datetime

Encounter provider

Widget bound to encounter/encounter.provider_id (after "Form completed today by:")

Checkbox for coded observation

the checkbox before "patient est hospitalisé"

warning that this cannot be handled correctly (because of the value-when-unchecked)

Checkbox group for multi-select coded observation

The checkboxes in 3. like "bonne apparence" and "cachectique"

Needs multiple widgets:

Radio button group for coded observation

the radio button group including "NYHA classe I"

Collapse to a single element. If you change the layout, give a warning.

Select list for coded observation

no examples in this form

archive:HTML_Form_Entry_Module_HTML_Reference#Boolean

Checkbox for boolean observation

the checkbox before "La même que DDB" in 1.C.

Other booleans

no examples in this form

Textarea for text observation

text box under "La même que DDB" in 1.C.

Text field for text observation

text field in first row under "4. Labos préalables"

Text field for numeric observation

the text box after Poids

Date observations

The column under "4. Labos préalables"

Submit button

 

Other HTML Markup

< table > < div > ...

Pass this straight through

Obs Groups

  • If an obs field is not directly in the <obs> section of the xsd, but it's inside a grouping concept, it needs to result in an <obsgroup groupingConceptId="567">...</obsgroup>

    • Note that obs groups in HTML forms need to have all their widgets next to each other, whereas this isn't required in infopath. If you find something that can't be represented, then throw an error.