Relationships Data

Hello support,

I have a question about exporting the data for relationships on DHIS2. Is that applicable or not ?

Thank you in advance,

Hey @dina.mazloum, this is really the support of the community! The DHIS2 core team does try to contribute to the community and support when necessary but then everyone here relies on each other to support each other as well! We’re learning from each other and it’s the best part.

One question, please, have you tried using the API? For example, in this URL I can get all the relationship types (https://play.dhis2.org/2.36.3/api/relationshipTypes?fields=*) and if I want to get all the relationships I’d use (https://play.dhis2.org/2.36.3/api/relationships?) but then I’d have to specify the ID of either the tei=’ ‘, event=’ ‘, or an enrollment=’ ’

Hello Gassim,
I think that you didn’t get my point. I mean that I need the data for relationships. What I mean is the members that are related to the same household.

Okay, sorry! Could you take a screenshot of where you see these relationships in the instance? I will try to extract the API from the network tap … then we can download a csv. Thanks!

In the tracker capture, I can find the widget Relationships, but I can’t take a screenshot because I have data and it is confidential

1 Like

Okay, no wories, so if you want to list all the relationships you can use this API request: (/api/trackedEntityInstances.json?ou=yourHighestLevelOU&ouMode=DESCENDANTS&fields=relationships). For example, in one of the play instances I used: https://play.dhis2.org/2.35.8/api/trackedEntityInstances.json?ou=ImspTQPwCqd&ouMode=DESCENDANTS&fields=relationships

It’s possible to change the word json in the url I posted to CSV and it will download a CSV file for you but for some reason this isn’t working in the play instance so I asked for support on downloading, but you can see the list as I showed you in the URL from the play instance.

Thanks! Hope this helps! (:

@Gassim , Thanks for sharing some insights. Is there a way of getting all relationships at once? Rather than specify tei by tei

1 Like

Hi @paleu256

The required parameters are ‘trackedEntity’, ‘enrollment’ or ‘event’, so if you don’t want to specifiy by trackedEntity, you can select by event or by enrollment.

Additionally, make sure to use the API endpoint /tracker/relationships not api/relationships.