Hey all
I am trying to copy data from a third party app to DHIS2 using Tracker Data Capture. But I am confused regarding the flow.
I have a Program, say Family Registration. This program has a child program, set via Relations, Members Registered. Family Registration uses Family Entity Type and Members Registered use Family Member Entity Type.
Now I can create a new registration using UI, but I have more than 10K rows for these forms/programs doing them via UI is not possible. Also that app has new data every few days so my bridge (between App and DHIS) will run every other day.
This is what I understand regading the flow for new enrollment.
I am to make a new enrollment so I understand I’ll make a POST request to /api/enrollments,
but what will be my parameters?
What I understand is I might need to generate a POST request to /api/trackedEntityInstances using attributes from GET request to /api/trackedEntityTypes and use UID from these two in enrollment, but again what will be my parameters.
After filling Family Registration I have to add a Relation (Family Member Program). I’ll most probably will be doing same as above and then create a relation? ( I am asking, as I am lost with this part).
If someone can help me understand this it would be great or if someone can guide me to the right material that would be great too.
Hi Salik,
This is an interesting use case and I can tell you the essentials for tracker data import in bulk could certainly be documented in more detail…
A few questions…
Which version of DHIS2 are you using? This may affect what API endpoints are available for your import strategy.
Are the enrollments repeatable* for a single TEI, i.e. would you need to check if an enrollment already exists for a given TEI before importing?
In general the following should be set up first…
org units
tracked entity type
tracked entity attributes
program
programStages
relationShip type
Then your application imports…
tracked entity instance (with attributes)
enrollment, using the tei uid above
events, using the tei and enrollment uids
In v2.29 and above, it is possible to create a tei and enroll it into a program, in a single request with one JSON payload. See here:
So in your application, you can also fetch the UIDs for the org unit, program, tracked entity type, tracked entity attribute, and your new TEI to construct the payload for each POST request.
When you have the TEI IDs for the family TEI and “child” members TEI, you can import relationships to the relationships resource, from v2.32 (and maybe as early as v2.30, but its not documented) .Home - DHIS2 Documentation
I hope this is enough info to get you started. Good luck!