/
How to add new forms to OpenSRP App
How to add new forms to OpenSRP App
- Forms are authored according to XLSForm standard (using Microsoft Excel)
- These forms are then uploaded to https://ona.io/ which converts them into XForm standard. All OpenSRP forms can be found at https://ona.io/opensrp (this requires login)
- XForm is then converted to Enketo HTML form by running the following command with the <username> replaced by the account name & <form_id> replaced with the actual value
curl command
curl -X POST -d "server_url=https://api.ona.io/<username>&form_id=<form_id>" https://enketo.org/transform/get_html_form
Please Note the username is the Ona account username while form_id is the id of the form as viewed from the form settings see screenshot below
- This generates a xml document which contains two nodes, model and form, rest of the nodes can be ignored. model is the XForm Model instance, this is used by Enketo to do all the validations and calculations in the forms. form is the HTML DOM which Enketo uses to render the form
- model and form are saved as model.xml and form.xml. These files are then copied to the location <dristhi_app_root>/dristhi-app/assets/www/form/<form_name>/model.xml and <dristhi_app_root>/dristhi-app/assets/www/form/<form_name>/form.xml. When a form is launched, form_name is passed in the query parameter. Using this Enketo renders the form
- Another important part of form is form_definition.json file. This is a mapping file that is written for every form which maps the fields within the form to Dristhi database. More about form_definition.json later
- So model.xml, form.xml and form_definition.json comprise a Enketo Form
The model.xml would look like something similar to (this will be provided by a developer).
<model> <instance> <hh_reg id="hh_reg" version="201503231156"> <formhub> <uuid/> </formhub> <HH_ID/> <HH_Name/> <ec_repeat template=""> <woman_name/> <husband_name/> <EC_HH_ID/> <EC_HH_Name/> <note/> <raihan_text/> </ec_repeat> <meta> <instanceID/> </meta> </hh_reg> </instance> </model>
This is a sample of how a model.xml would look like. This form has a few questions and as well as a repeating group. Please note the repeating group lies in between the tags "<ec_repeat >".
, multiple selections available,
Related content
OpenSRP Developer's Guide
OpenSRP Developer's Guide
Read with this
Form Autodownload for Client
Form Autodownload for Client
More like this
entity_relationship.json
entity_relationship.json
Read with this
How to update forms on OpenSRP app
How to update forms on OpenSRP app
More like this
How to upload configurable forms using the API
How to upload configurable forms using the API
More like this
OpenSRP Form Architecture
OpenSRP Form Architecture
More like this