This is the process of converting form submissions to Event and Client models.
...
Field | Type | openmrs_entity | Notes | |||||||
---|---|---|---|---|---|---|---|---|---|---|
_id | java.lang.String | Auto generated by couchdb | ||||||||
_rev | java.lang.String | Auto generated by couchdb | ||||||||
eventType | java.lang.String | Equivalent to encounter_type value in model.xml | ||||||||
baseEntityId | java.lang.String | This is the client unique identifier equivalent to id in relational databases. Equivalent to formSubmission.entityId() value.
| ||||||||
entityType | java.lang.String | This is equivalent to the bind_type value in the form_definition | ||||||||
dateCreated | java.util.Date | Current date in the format: yyyyMMddTHHmmssSSSZ This is the date when the event is created on the server | ||||||||
providerId | java.lang.String | Logged in user username | ||||||||
formSubmissionId | java.lang.String | FormsubmissionId of the form submission currently being converted to EC | ||||||||
locationId | java.lang.String | Location id of the logged in user as returned by OpenMRS authentication process during login | ||||||||
version | java.lang.Long | Current timestamp long value. Most of the server side repeating jobs use this value to get the last updated or created events This timestamp indicates when an event was created on the device | ||||||||
eventDate | java.util.Date | This is the encounter date This is the date when the encounter happened. In most instances this indicates the date the event was created. However if an encounter happened in the past e.g immunization was done in the past, the eventDate this is changed to reflect that. | ||||||||
type | java.lang.String | Document type. Should be Event | ||||||||
obs | List<org.ei.opensrp.clientandeventmodel.Obs> | concept | Each field of type concept is an Obs object as show below
The humanReadableValues key stores a human readable version of the concept value for easier processing in the client app | |||||||
status | ||||||||||
statusHistory | ||||||||||
priority | ||||||||||
episodeOfCare | ||||||||||
referrals | ||||||||||
category | ||||||||||
duration | ||||||||||
reason |
...
- The FormUtils.generateFormSubmisionFromXMLString() is called in the activities saveFormSubmission() method and converts the XML data received from enketo to a JSONObject and loads the form_definition.json for the current formsubmission to get the form and the subforms from the xml data in the enketo data creating an instance of org.ei.opensrp.domain.form.FormSubmission .
- With the FormSubmission instance, call FormUtils.generateClientAndEventModelsForFormSubmission() method in the above method to retrived EC data from the form submission
- In the FormUtils.generateClientAndEventModelsForFormSubmission() method, formEntityConverter.getClientFromFormSubmission() method is called to generate clients and formEntityConverter.getEventFromFormSubmission() to generate events. The method formEntityConverter.getDependentClientsFromFormSubmission () is called to retrieve other clients/events in case the form had subforms and return them in a java.util.Map.
CloudantDataHandler.createEventDocument() and CloudantDataHandler.createClientDocument() are called to create Cloudant event and client models respectively.