Is there a way I can pull via the API the start and endDates associated with each dataValue in a given dataSet? The period type in this case is Bi-weekly.
Thanks,
MBK
Is there a way I can pull via the API the start and endDates associated with each dataValue in a given dataSet? The period type in this case is Bi-weekly.
Thanks,
MBK
Hi @mykbitz ,
Using the ADX format, you will get the startDate of the period. Refer the documentation below.
Thanks,
Rithvik
Thanks @rithvik for the suggestion.
You can also create an SQL View on your DHIS2 instance to extract this information i.e start and end dates, and any other related data. See the select query below:
SELECT DISTINCT pe.startdate,
pe.enddate,
pt.periodtypeid AS periodtype,
pt.name AS periodname,
ps.biweekly AS BiWeek,
ps.monthly as Month,
ps.quarterly as Quarter
FROM datavalue dv
INNER JOIN dataelement de ON dv.dataelementid = de.dataelementid
INNER JOIN period pe ON dv.periodid = pe.periodid
INNER JOIN periodtype pt ON pe.periodtypeid = pt.periodtypeid
INNER JOIN _periodstructure ps ON pe.periodid = ps.periodid
INNER JOIN organisationunit ou ON dv.sourceid = ou.organisationunitid
LEFT JOIN categoryoptioncombo coc ON dv.categoryoptioncomboid = coc.categoryoptioncomboid
LEFT JOIN categoryoptioncombo aoc ON dv.attributeoptioncomboid = aoc.categoryoptioncomboid
WHERE pt.name = 'BiWeekly'
ORDER BY pe.startdate ASC
You can then pull this via the api to your reporting tool (PowerBi/Tableau/R) via an API:
https://my.example.com/dhis2instance/api/sqlViews/yoursqlviewuid/data.json