Redundant and Unnecessary properties in JSON data in Bahmni Connect?

Tags: #<Tag:0x00007fa3eed23a68>

Hi everyone, so I’ve been working on Bahmni Connect Android app and I’ve noticed that some redundant objects in the json data.

The data I’m referring to is the one that is stored in the resources column of the forms table in Bahmni Connect Android database. The resources column basically contains all the metadata about the form i.e it will tell us what concepts make up the form, its datatype, its answers etc. This is for forms created using the Form Builder i.e Forms 2.0

Here is a sample data from the resources column:

In our case we have a form called Treatment Form and in it is a coded concept called Drug Name which has various concepts as its answers. Currently we have 240 answers for it.

When I try to open the form on the app I get an error and the form does not open/render. So i reduced the number of answers from 240 to 230 and then the form did open without any problems.

I changed it to 240 again and did some debugging. I noticed that with 240 answers the column size was larger than the sqlite cursor size. Thats what the error stack mentioned.

Next, I went through the json representing the resources column and found that the answers object is repeated twice.

In the link provided above, you can observe the 1st instance of answers object at array►0►value►controls►1►concept►setMembers►0►answers► and the 2nd instance at array►0►value►controls►1►controls►0►concept►answers►

Since its taking up twice the space required what is the reason for these both? Similarly, we have the name object and the names object with names containing the same data as names. Also present are the links objects which seem to be totally unnecessary in Bahmni Connect app.

So my doubt is that can a lot of these be dropped like: one of the answers object , the names object, links etc? Will it cause any problems?

Memory is a huge constraint on mobile devices and this is how it can be optimized.

@angshuonline @binduak @mksd @mksrom

You should use the Forms2 forms in connect.

Aren’t Forms made using Form Builder called Forms2.0?

Yes. didn’t notice that you are using Form builder. And yes, the problem is that sqlite column has limited space and you need to keep the information limited. If the answers are that many, probably you should rethink about the breaking on the element (maybe use 2 different questions) if possible, and restricting the sets - it might not be logical. otherwise, the other option is to make it auto complete, in which case, the answers are not downloaded. Alternatively, modify the codebase of the android and you can programatically change the SQLite column size.

Actually its not the sqlite column size thats causing the problem. It actually the Database cursor thats holding the data from the select query.

The size of the cursor is limited and is not able to hold the entire column

Also @angshuonline, shouldn’t those duplicate nodes in the json be removed?