Saving and Processing Native Forms Data: Client Processing
This tutorial assumes an existing set of an Android Project with dependencies on client-core and native-forms
What is Client Processing?
OpenSRP uses the EC Data model, a flexible data storage model, that can be compared to the Entity Attribute Value that makes it among other reasons, easier to store semi-structured data such as JSON in a traditional styled RDMS such as SQLite.
Client Processing is the process of extracting, modifying, and preparing the JSON Response returned by Native Forms OpenSRP Library. This results in generating an OpenSRP Event, OpenSRP Client and conditionally updating an ec_table, which is used for fast retrieval, search, and sorting.
Rendering a Form via Native Forms.
Create a form in the assets directory of your app. e.g check basic_form.json below
2. Open and fill a Form
Intent intent = new Intent(activity, JsonWizardFormActivity.class);
intent.putExtra("json, jsonForm);
startActivityForResult(intent, JsonFormUtils.REQUEST_CODE_GET_JSON);
3. Receive the results of a form
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
String jsonString = data.getStringExtra("json");
// excluded for brevity
Saving Data from Native Forms
This guideline is for implementations that depend on OpenSRP client core library
1. Define the event types and table relationships.
File | Purpose | Example |
---|---|---|
ec_client_classification.json | Defines Event Type / Table mapping | {
"case_classification_rules": [
{
"comment": "Process Family Details",
"rule": {
"type": "event",
"fields": [
{
"field": "eventType",
"field_value": "Family_Member_Registration",
"creates_case": [
"ec_family_member"
]
},
{
"field": "eventType",
"field_value": "Update_Family_Registration",
"creates_case": [
"ec_family"
]
}
]
}
}
]
} |
ec_client_fields.json | Defines Event Observation / Table Column relationship |
2. Client Process the event
This site is no longer maintained. Please visit docs.opensrp.io for current documentation.