Import Event into an Enrollment

Hello,

I’m experiencing errors when trying to import an event to an already enrolled TEI. I cannot POST an event or import via the native Import/Export app using the headers below …

event status program programStage enrollment orgUnit eventDate dueDate latitude longitude dataElement value storedBy providedElsewhere completedDate completedBy geometry

In the Import/Export App I get an error ‘Event.trackedEntityInstance does not point to a valid tracked entity instance: null’ however I can view the TEI in the api and I can find the case in Tracker capture.

In postman, I only get a conflict error message without any further descriptor.

Is there something I’m missing when importing an event into an already existing TEI already enrolled in a program?

@Gassim do you have any insight on this?

Thank you!
Lauren Fregosi

MSF-OCP

1 Like

@lnfregos normally what I do, when need to move some events, from other TEI

  1. get the TEI where the event should be added DHIS 2 Demo - Sierra Leone*

  2. get the event to be added
    DHIS 2 Demo - Sierra Leone*

  3. insert event into TEI json

  4. check events IDs in enrollment and trackedEntityInstance fields, so they must be the same in TEI - enrollment and trackedEntityInstance

  5. Post it back with Postman

Obviously before to post either you should delete existing event, which you want to move, or create it as new by deleting the event id

Good luck!
Regards,

1 Like

Hello @Ulanbek Thanks for your response. In your fourth step, do you mean that the event IDs should be the same for the 1st and 2nd events (given there are two) or do you mean the enrollment and TEI IDs need to be the same for each event? If its the second, then this is the case for us. We don’t have an existing event in the stage we want to import an event into already. What do you mean by ‘create it as new by deleting the event id’?

Thanks!

Hi @lnfregos

I will try to explain on the real example below:

  1. I have get json TEI from https://play.dhis2.org/2.36.13.2/api/trackedEntityInstances/QGyxOe1zewj.json?fields=*
  2. This is part of JSON file
{
  "created": "2019-08-21T13:25:51.247",
  "orgUnit": "DiszpKrYNg8",
  "createdAtClient": "2019-03-19T01:12:40.850",
  "trackedEntityInstance": "QGyxOe1zewj",
  "lastUpdated": "2019-08-21T13:31:41.331",
  "trackedEntityType": "Zy2SEgA61ys",
  "lastUpdatedAtClient": "2019-03-19T01:12:40.850",
  "inactive": false,
  "deleted": false,
  "featureType": "NONE",
  "programOwners": [
    {
      "ownerOrgUnit": "DiszpKrYNg8",
      "program": "qDkgAbB5Jlk",
      "trackedEntityInstance": "QGyxOe1zewj"
    }
  ],
  "enrollments": [
    {
      "storedBy": "belen_test",
      "created": "2019-08-21T13:25:53.570",
      "orgUnit": "DiszpKrYNg8",
      "createdAtClient": "2019-03-10T15:45:18.847",
      "program": "qDkgAbB5Jlk",
      "trackedEntityInstance": "QGyxOe1zewj",
      "enrollment": "PvJFfKjNWbq",
      "lastUpdated": "2019-08-21T13:31:41.328",
      "trackedEntityType": "Zy2SEgA61ys",
      "lastUpdatedAtClient": "2019-08-21T13:31:41.328",
      "orgUnitName": "Ngelehun CHC",
      "enrollmentDate": "2023-03-10T00:00:00.000",
      "followup": false,
      "deleted": false,
      "incidentDate": "2023-03-10T15:45:18.845",
      "status": "COMPLETED",
      "notes": [
        
      ],
      "relationships": [
        
      ],
      "attributes": [
        
      ],
      "events": [
        {
          "storedBy": "belen_test",
          "dueDate": "2023-03-12T00:00:00.000",
          "createdAtClient": "2019-03-10T15:45:19.043",
          "program": "qDkgAbB5Jlk",
          "event": "AiJUOyxiF3C",
          "programStage": "C0aLZo75dgJ",
          "orgUnit": "DiszpKrYNg8",
          "trackedEntityInstance": "QGyxOe1zewj",
          "enrollment": "PvJFfKjNWbq",
          "enrollmentStatus": "COMPLETED",
          "status": "COMPLETED",

line 8 “trackedEntityInstance”: “QGyxOe1zewj” should be same inside ENROLLMENTS section lines 29 and inside EVENTS section line 58,

Also the line 30 “enrollment”: “PvJFfKjNWbq” of ENROLLMENTS section should be the same for the line 59 in the EVENTS section

Regards, Ulanbek

1 Like