OpenSRP Form Architecture
Sequence Diagram for OpenSRP Forms
The above mentioned components can be found in code as below:
- Form Activity is one of FormActivity or MicroFormActivity based on whether the form is opened in full screen mode or in micro form mode
- Enketo Form Template refers to the template.html of Enketo Dristhi. In Dristhi app, this can be found at <app_root>/dristhi-app/assets/www/enketo/template.html
- Dristhi Android Context is implemented as FormWebInterface. This object is injected into Enketo as a Javascript object using Android Javascript Interface API
- Ziggy Form Data Controller is the object in Ziggy that is implemented as ziggy/FormDataController. This can be found in Ziggy at <ziggy_root>/ziggy/src/FormDataController
More information about the sequence diagram messages below:
- When a form is to be launched, Form Activity is used to open the form. Form name, Entity ID and meta data (field overrides, reminder ID, etc) are passed to Form Activity via the Intent
- Form Activity then uses webView to load Enketo-Dristhi’s template.html and passes to it the intent parameters mentioned above. It also injects Dristhi Android Context as a Javascript object. template.html is the skeleton of a Enketo form
- Enketo then gets the XForm Model from Dristhi Android Context by calling getModel method. Dristhi Android Context would then return the XForm Model which is the contents of file at <dristhi_app_root>/dristhi-app/assets/www/form/<form_name>/model.xml
- Enketo then gets the HTML Form DOM from Dristhi Android Context by calling getForm method. Dristhi Android Context would then return the DOM which is the contents of file at <dristhi_app_root>/dristhi-app/assets/www/form/<form_name>/form.xml
- Enketo then calls Ziggy’s Form Data Controller to get the form model. Form model will be similar in structue to form_definition, but with the values per-populated. Enketo passes the query params to Ziggy and Ziggy uses these to load the data from Dristhi App SQLite database and returns the form model to Enketo
- Enketo uses XForm Model, HTML Form DOM and form model to render and pre-populate the form
This site is no longer maintained. Please visit docs.opensrp.io for current documentation.