Missing columns on form csv reports exports

Hello,
I have this data element visible on the reports section of CHT as per the screenshot below:
image

Using both the csv reports export and the API in exporting data the above column is missing from the data export. This is not by coincidence, there are a number of data elements that are visible on reports tab or json on couchdb but missing on excel export.
Is this a bug or am I missing something.
R,
Job

Hi @Job_Isabai

Was the data element added later to the form?
If yes, there’s a known bug that might cause what you are seeing: Report export fields can be skipped if forms are edited over time · Issue #7437 · medic/cht-core · GitHub

Hi @diana ,
No the data element was present in the initial form, but we have published various versions of the same form which I think might have resulted to this issue.
Thanks, I think its related to the known bug.

Hi @diana,
Apart from the API exports in csv, do we have a script that exports all reports in json. I am sure these data columns will be visible on json file.

Hi @Job_Isabai

If you want all reports, no advanced, then you can just use a standard CouchDB API to query a view directly and extract the json from the response.

You can choose from the pool of views that already exists: cht-core/ddocs/medic-db/medic-client/views at master · medic/cht-core · GitHub , particularly the ones that are named report_<something> that also include some level of filtering. You can check the source code of the view maps to see what kind of results you will get and choose the desired view.

Then you would just request results via the CouchDb API: 1.5.4. /db/_design/design-doc/_view/view-name — Apache CouchDB® 3.3 Documentation