I learnt that health programs are first created on the dhis2 website, so the url is used in the app to login then health programs are fetched.
I’m trying to create a new Dhis2 application from the scratch using the Dhis2 sdk core, but i cannot seem to find a documentation that talks about targeting specfic health programs created on the dhis2 website.
I want to be able to fetch events, clients and even submit data to specific health programs i am targeting in code.
I am completely new to dhis2, and I will appreciate a guide on this request thank you.
Hi @samuel.awodire,
this DHIS2 Android sdk is designed to work in offline mode mainly. It means that metadata must be downloaded in first place. The sdk will download all the health programs that are accessible to the user, which means:
these programs must be assigned to any organisationUnit assgined to the user
the user must have data write access to the program and its program stages
Well, if you want to get a specific program by uid you can call the method like Sdk.d2().programModule().programs().uid("program_uid").blockingGet(),
or if you need to get the list of programs assigned to a particular orgunit, then Sdk.d2().programModule().programs().byOrganisationUnitUid("ou_uid").blockingGet()
Then, you can use the programUid to filter TrackedEntityInstances or Events in their respective repositories.
@vgarciabnz Thanks a lot .
sorry one more thing, how do i submit an enrollment form to a specific program using the uid, and which format does Dhis2 support e.g JSON
@vgarciabnz Thanks for the help so far, i have really made a lot of progress on my app development.
But, i still need your help on a method, i read the doc but i didn’t find the best way to get this method.
Please, how do i get the number of tracked entities or events to a program either by program uid or program name?
the blockCount() stuff
This method includes the deleted enrollment in the count. If you want to exclude them, it is better to use the TEI query repository (similar to TEI repository, but has advanced filtering methods).
In all the previous cases, you might replace the string “program_uid” by the actual uid or by a query to the program repository filtering by name. For example: