← Back to team overview

dhis2-devs team mailing list archive

Re: Retrieve enrollment based on attribute value using Android SDK

 

Hi Apoorv,


Here is an example of web API calls and SDK method references which will search TrackedEntityInstances based on attribute values.

Demo server credentials: 
 - username: android
 - password: Android123


First, you need to find TrackedEntityInstance (child) on server by filtering on corresponding attributes (phone number or first name in this example). 
Example of API request: https://play.dhis2.org/demo/api/trackedEntityInstances.json?ou=DiszpKrYNg8&program=IpHINAT79UW&filter=w75KJ2mc4zz:LIKE:donald

In SDK, you can use TrackerController.queryTrackedEntityInstancesDataFromServer() method which allows you to search TrackedEntityInstances based on attribute values.
Method in SDK: https://github.com/dhis2/dhis2-android-sdk/blob/2.22-legacy/core/src/main/java/org/hisp/dhis/android/sdk/controllers/tracker/TrackerController.java#L402


Second, you need to get enrollments which are assigned to given TrackedEntityInstance.
Example of API request: https://play.dhis2.org/demo/api/enrollments.json?ou=DiszpKrYNg8&program=IpHINAT79UW&trackedEntityInstance=XF7tJoenIpr

This call will download and save specified TrackedEntityInstances with assigned Enrollments:
Method in SDK: https://github.com/dhis2/dhis2-android-sdk/blob/2.22-legacy/core/src/main/java/org/hisp/dhis/android/sdk/controllers/tracker/TrackerController.java#L410


Best regards,

—
Araz Abishov,
Android developer, DHIS 2
University of Oslo
https://www.dhis2.org/

On May 15, 2016 at 3:02:49 AM, Apoorv Patel (patelapoorv9990@xxxxxxxxx) wrote:

Hi,

I am enrolling a child with certain attributes like First Name, Last Name, Phone Number and saving it on the server using the Android SDK.

How can I retrieve that enrollment based on the Phone Number value?

Thanks,
Apoorv
_______________________________________________  
Mailing list: https://launchpad.net/~dhis2-devs  
Post to : dhis2-devs@xxxxxxxxxxxxxxxxxxx  
Unsubscribe : https://launchpad.net/~dhis2-devs  
More help : https://help.launchpad.net/ListHelp  

References