# How to link index case with his contacts

**URL:** <https://community.dhis2.org/t/how-to-link-index-case-with-his-contacts/39345>\
**Category:** COVID-19\
**Created:** [27 May 2020 10:41 UTC](https://community.dhis2.org/t/how-to-link-index-case-with-his-contacts/39345 "2020-05-27T10:41:32Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amza](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/amza/32/35404_2.png) [@Amza](https://community.dhis2.org/u/Amza)\
**Post date:** [27 May 2020 10:41 UTC](https://community.dhis2.org/t/how-to-link-index-case-with-his-contacts/39345/1 "2020-05-27T10:41:32Z")

</div>

Dear Community members,

we are using Covid-19 tracker program to tracker cases and contact tracing to track their contacts. I would like to link each cases with their contacts data, can someone help me to address this.  
Thanks

Amza

---

<div class="post-metadata">

**Author:** ![omielp](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/omielp/32/28088_2.png) [@omielp](https://community.dhis2.org/u/omielp)\
**Post date:** [28 May 2020 21:12 UTC](https://community.dhis2.org/t/how-to-link-index-case-with-his-contacts/39345/2 "2020-05-28T21:12:17Z")

</div>

@Amza you can use the relationship feature to add/link contacts to the index case while on the _COVID-19 Case-based Surveillance program_ and similarly, you can add/link case to contacts while in the _COVID-19 Contact Registration & Follow-up_. For more information please refer to the COVID19 tracker [design document](https://docs.google.com/document/d/12-pex7VOMoRAnsiIcTLq0mTD6UTSfVBZWIX0vufIt6I/edit)

 ![Screen Shot 2020-05-29 at 09.19.13](https://dhis2.b-cdn.net/uploads/default/original/3X/e/7/e7eb018179181c070f51c66ceddb52659f211a83.png)

---

<div class="post-metadata">

**Author:** ![dmbantu](https://dhis2.b-cdn.net/letter_avatar_proxy/v4/letter/d/85f322/32.png) [@dmbantu](https://community.dhis2.org/u/dmbantu)\
**Post date:** [5 July 2021 14:21 UTC](https://community.dhis2.org/t/how-to-link-index-case-with-his-contacts/39345/3 "2021-07-05T14:21:30Z")

</div>

Hi @omielp,

I am wondering if you could help me create relationship types step by step. Although I have looked at COVID\_19 document, I couldn’t find an answer

I want to create a TB tracker program where I have to register index cases and their contacts, but the problem is that I am unable to create a relationship.

I have just logged in to Sierra Leone demo to see the relationship types created, but I cannot figure out something:

I see these the following two relationship types:

1. Mother-Child\_a-to-b\_(Person-Person)

2. Mother-Child\_b-to-a\_(Person-Person)

But no program has been selected in both relationship types.

 ![image](https://dhis2.b-cdn.net/uploads/default/original/3X/8/a/8ab4f34917813aa075d18d06662b0fed75eded35.png)

What I would like to know is if I have to create two relationships e.g. 1. Index Case-Contact\_a-to-b and 2. Contact-Index Case\_b-to-a as on demo or just one relationship.

What is the correct configuration?

Any help will be appreciated.

---

<div class="post-metadata">

**Author:** ![Shurajit\_Dutta](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/shurajit_dutta/32/31781_2.png) [@Shurajit\_Dutta](https://community.dhis2.org/u/Shurajit_Dutta)\
**Post date:** [29 July 2021 16:57 UTC](https://community.dhis2.org/t/how-to-link-index-case-with-his-contacts/39345/4 "2021-07-29T16:57:40Z")

</div>

Hi there @dmbantu

In this case, I would just create one simple, bidirectional relationship that looks something like this

 ![image](https://dhis2.b-cdn.net/uploads/default/original/3X/1/f/1ff3150109624aa0244a6a6be100a624f4c970e0.png)

This should work whether or not you have a separate program for contacts or are creating contacts within your TB program. You may also want to define that link in program maintenance with the default program you will be creating relationships within, though this is optional

 ![image](https://dhis2.b-cdn.net/uploads/default/original/3X/6/d/6d497073697ed73788040dffb0f4b0828fc338ec.png)

---

<div class="post-metadata">

**Author:** ![dmbantu](https://dhis2.b-cdn.net/letter_avatar_proxy/v4/letter/d/85f322/32.png) [@dmbantu](https://community.dhis2.org/u/dmbantu)\
**Post date:** [30 July 2021 08:21 UTC](https://community.dhis2.org/t/how-to-link-index-case-with-his-contacts/39345/5 "2021-07-30T08:21:42Z")

</div>

Hi @Shurajit_Dutta,

I am creating a separate program for contacts.

a) Would it be possible to register contacts within the index case program? How would the program look like as regards to its structure?

Sorry but these parts are not clear for me:

> [@](#):
>
> This should work whether or not you have a separate program for contacts or are creating contacts within your TB program.

> [@](#):
>
> You may also want to define that link in program maintenance with the default program you will be creating relationships within, though this is optional
> 
> ![image](https://dhis2.b-cdn.net/uploads/default/original/3X/6/d/6d497073697ed73788040dffb0f4b0828fc338ec.png)

Thanks.

---

<div class="post-metadata">

**Author:** ![fernandoshake](https://dhis2.b-cdn.net/letter_avatar_proxy/v4/letter/f/9de053/32.png) [@fernandoshake](https://community.dhis2.org/u/fernandoshake)\
**Post date:** [27 January 2022 10:27 UTC](https://community.dhis2.org/t/how-to-link-index-case-with-his-contacts/39345/6 "2022-01-27T10:27:09Z")

</div>

Hi @omielp, @Shurajit_Dutta,

Would you mind explaining how to view the **total number of contacts per index cas** e in the Analytics: event reports or any other way?

Having defined a relationship for two of my programs (household, member), I would like to view all members per household.

Hope you can provide considerable input

Thanks

---

<div class="post-metadata">

**Author:** ![YuryR](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/yuryr/32/34849_2.png) [@YuryR](https://community.dhis2.org/u/YuryR)\
**Post date:** [27 January 2022 11:05 UTC](https://community.dhis2.org/t/how-to-link-index-case-with-his-contacts/39345/7 "2022-01-27T11:05:57Z")

</div>

Hi @fernandoshake .

In order to display a total number of contacts for you index case in an event report, you need to create an enrollment type program indicator with the expression:

d2:relationshipCount(‘\<uid\_of\_your\_relationship\_type\>’).

In tracker, you can create relationships to the TEIs in the contact tracing program.

Then, after you run Analytics, you can configure your event report (type enrollment), select the parameters to display including the created “Contacts” program indicator.

You should get the total number of contacts of the specified type for your enrollment.

Hope that helps.

---

<div class="post-metadata">

**Author:** ![fernandoshake](https://dhis2.b-cdn.net/letter_avatar_proxy/v4/letter/f/9de053/32.png) [@fernandoshake](https://community.dhis2.org/u/fernandoshake)\
**Post date:** [27 January 2022 12:49 UTC](https://community.dhis2.org/t/how-to-link-index-case-with-his-contacts/39345/8 "2022-01-27T12:49:22Z")

</div>

Hi @YuryR,

About this part

> [@](#):
>
> In tracker, you can create relationships to the TEIs in the contact tracing program.

I have built two example tracker programs (index and contact programs) in demo Sierra Leone. And I would like to register contacts of index from contact program but it seems it is not working well. Would you me help identify the problem?

Below the relationship definition

 ![image](https://dhis2.b-cdn.net/uploads/default/original/3X/5/b/5b0b53455dbfb1143a59b45f17c7dcf216663743.png)  
[https://play.dhis2.org/2.36.7/dhis-web-maintenance/index.html#/edit/programSection/relationshipType/DuJ5jBDnJeU](https://play.dhis2.org/2.36.7/dhis-web-maintenance/index.html#/edit/programSection/relationshipType/DuJ5jBDnJeU)

The programs:  
[

 ![image](https://dhis2.b-cdn.net/uploads/default/original/3X/1/1/11be600b32d7d14c7fb5ff58f4434584a07f09fc.png)]

[https://play.dhis2.org/2.36.7/dhis-web-tracker-capture/index.html#/dashboard?tei=HOk4POOYoP0&program=iZoaZrIrPTt&ou=DiszpKrYNg8](https://play.dhis2.org/2.36.7/dhis-web-tracker-capture/index.html#/dashboard?tei=HOk4POOYoP0&program=iZoaZrIrPTt&ou=DiszpKrYNg8)

Sorry, but I did not understand this part very well:

> [@](#):
>
> Then, after you run Analytics, you can configure your event report (type enrollment), select the parameters to display including the created “Contacts” program indicator.  
> You should get the total number of contacts of the specified type for your enrollment.

Thanks

---

<div class="post-metadata">

**Author:** ![YuryR](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/yuryr/32/34849_2.png) [@YuryR](https://community.dhis2.org/u/YuryR)\
**Post date:** [27 January 2022 22:44 UTC](https://community.dhis2.org/t/how-to-link-index-case-with-his-contacts/39345/9 "2022-01-27T22:44:11Z")

</div>

Hi!

When you set up your relationship type, you can make it “bidirectional” TEI to TEI.  
Program selection is optional.

I have seen your programs, it is possible to create relationships from the index case to contact.  
You can search or register the TEI when you add a relationship.

In order to see the name or other attributes in the relationship widget, you have to enable the property  
“Display in list without program” for each attribute you want to see in the list:

 ![Screenshot 2022-01-27 at 23.18.13](https://dhis2.b-cdn.net/uploads/default/original/3X/b/8/b80519d356c83134cd64af8bee98de632c740561.png)

For event reports:  
Once you have your indicator set up, you need to update your analytics tables:  
(App)Data Administration/Analytics Tables/Start Export

Then set up the event report:  
(App)Event Reports  
Line list  
Enrollment  
Add the program indicator you created and you will see the number of contacts for each of the index cases.

 ![Screenshot 2022-01-27 at 23.43.32](https://dhis2.b-cdn.net/uploads/default/original/3X/3/e/3ede68e19db5bcd306302a65d6367a19b75f6946.png)

Hope that helps.

---

<div class="post-metadata">

**Author:** ![fernandoshake](https://dhis2.b-cdn.net/letter_avatar_proxy/v4/letter/f/9de053/32.png) [@fernandoshake](https://community.dhis2.org/u/fernandoshake)\
**Post date:** [28 January 2022 05:54 UTC](https://community.dhis2.org/t/how-to-link-index-case-with-his-contacts/39345/10 "2022-01-28T05:54:24Z")

</div>

Hi @YuryR ,

Your explanation has cast light on my problem. One more question: If I want to register contacts of index from the contact registration from, do I have to alter the order of tracked entity instances during relationship definition?

In the relationship above, I have the following:

From constraint: index case

To constraint: contact

I would like to create a relationship from contact registration tracker; not from the index case tracker. as it is now.

Thanks

---

<div class="post-metadata">

**Author:** ![YuryR](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/yuryr/32/34849_2.png) [@YuryR](https://community.dhis2.org/u/YuryR)\
**Post date:** [28 January 2022 10:06 UTC](https://community.dhis2.org/t/how-to-link-index-case-with-his-contacts/39345/11 "2022-01-28T10:06:38Z")

</div>

Good that the info was helpful.

If you want to keep your relationship type one directional, then you need to enter the initiating TET first and then the target TET.

If you want to make your relationship biderectional, it does not matter what comes first. Just make sure to enter the text each relationship will show:

contact to index  
index to contact.

Consider setting your relationships bidirectional as it might b useful to see the relationships form contacts to index.

Good luck,

Yury

---

<div class="post-metadata">

**Author:** ![fernandoshake](https://dhis2.b-cdn.net/letter_avatar_proxy/v4/letter/f/9de053/32.png) [@fernandoshake](https://community.dhis2.org/u/fernandoshake)\
**Post date:** [28 January 2022 13:10 UTC](https://community.dhis2.org/t/how-to-link-index-case-with-his-contacts/39345/12 "2022-01-28T13:10:02Z")

</div>

Hi @YuryR,

Thank you very much for all your help.
