Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Done
-
Labels:
Description
Context
Currently, the json serializer that converts data entered into a mUzima form into a json payload checks for input fields with the keywords 'patient' and 'encounter' and packages these into respective entities into the json payload. Any additional input fields are packaged into the Obs section of the json payload. This behavior is inflexible and incorrectly defines that non-obs data.
muzima.js: line 301
$.fn.serializeEncounterForm = function () { var jsonResult = $.extend({}, serializeNonConceptElements(this), serializeConcepts(this), serializeNestedConcepts(this)); var patient = {}; var encounter = {}; var observation = {}; $.each(jsonResult, function (k, v) { if (k.indexOf('patient') === 0) { patient[k] = v; } else if (k.indexOf('encounter') === 0) { encounter[k] = v; } else { observation[k] = v; } }); var finalResult = {}; finalResult['patient'] = patient; finalResult['encounter'] = encounter; finalResult['observation'] = observation; return finalResult; };
Requirements
It is required to make the json serializer for json forms to be more flexible. It is proposed that the serializer will read the tag information and create the correct structure. eg. patient.id -> patient object with id property in the json without hardcoding the "patient"
Acceptance Criteria
- A generic json serializer
- js test code for serializer