Hi there,
I have just started my way in DHIS app development and have a questions on how can I create a TEI, enrollment and events all together like below in one mutation request by using dhis-runtime:
{
"trackedEntityInstances": [
{
"created": "2024-06-24T20:01:53.782",
"orgUnit": "ohhWSkJKVLf",
"createdAtClient": "2024-06-24T20:01:53.782",
"trackedEntityType": "gAkFSYjEBoP",
"storedBy": "admin",
"createdByUserInfo": {
"uid": "M5zQapPyTZI",
"firstName": "admin",
"surname": "admin",
"username": "admin"
},
"enrollments": [
{
"storedBy": "admin",
"createdAtClient": "2024-06-24T20:01:53.955",
"program": "vXMY3ACeWzL",
"created": "2024-06-24T20:01:53.952",
"orgUnit": "ohhWSkJKVLf",
"trackedEntityType": "gAkFSYjEBoP",
"enrollmentDate": "2024-06-24T00:00:00.000",
"incidentDate": "2024-06-24T00:00:00.000",
"status": "ACTIVE",
"createdByUserInfo": {
"uid": "M5zQapPyTZI",
"firstName": "admin",
"surname": "admin",
"username": "admin"
},
"events": [
{
"storedBy": "admin",
"dueDate": "2024-06-25T08:17:58.781",
"program": "vXMY3ACeWzL",
"programStage": "LknBcxH89wZ",
"orgUnit": "ohhWSkJKVLf",
"status": "ACTIVE",
"eventDate": "2024-06-25T00:00:00.000",
"attributeCategoryOptions": "xYerKDKCefk",
"created": "2024-06-25T08:17:58.781",
"attributeOptionCombo": "HllvX50cXC0",
"createdByUserInfo": {
"uid": "M5zQapPyTZI",
"firstName": "admin",
"surname": "admin",
"username": "admin"
},
"dataValues": [
{
"lastUpdated": "2024-06-25T08:18:09.089",
"created": "2024-06-25T08:18:09.089",
"dataElement": "BRYWi0UnxPL",
"value": "YNA_yes",
"providedElsewhere": false,
"createdByUserInfo": {
"uid": "M5zQapPyTZI",
"firstName": "admin",
"surname": "admin",
"username": "admin"
}
},
{
"lastUpdated": "2024-06-25T08:18:14.268",
"created": "2024-06-25T08:18:14.268",
"dataElement": "rklRSkweZ8E",
"value": "true",
"providedElsewhere": false,
"createdByUserInfo": {
"uid": "M5zQapPyTZI",
"firstName": "admin",
"surname": "admin",
"username": "admin"
}
}
]
},
{
"program": "vXMY3ACeWzL",
"programStage": "EJYTLHjoVGH",
"orgUnit": "ohhWSkJKVLf",
"status": "COMPLETED",
"eventDate": "2024-06-24",
"completedDate": "2024-06-24",
"dataValues": [
{
"value": 1,
"dataElement": "Dcdgn4pvrcZ"
},
{
"value": 6,
"dataElement": "OkvIx4cjxkM"
},
{
"value": "true",
"dataElement": "lZ8xgz8bX3C"
},
{
"value": "some_text",
"dataElement": "ce6jIeCeMdK"
},
{
"value": "pl_NGO",
"dataElement": "n1zMMq13TKE"
}
]
}
],
"attributes": [
{
"lastUpdated": "2024-06-24T20:01:53.803",
"storedBy": "admin",
"created": "2024-06-24T20:01:53.803",
"valueType": "TEXT",
"attribute": "kmzHA3cJtLx",
"value": "АХUR115"
},
{
"lastUpdated": "2024-06-24T20:01:53.787",
"storedBy": "admin",
"created": "2024-06-24T20:01:53.787",
"valueType": "TEXT",
"attribute": "H8beMnOxMzX",
"value": "plhiv"
}
]
}
],
"attributes": [
{
"lastUpdated": "2024-06-24T20:01:53.803",
"storedBy": "admin",
"created": "2024-06-24T20:01:53.803",
"valueType": "TEXT",
"attribute": "kmzHA3cJtLx",
"value": "АХUR115"
},
{
"lastUpdated": "2024-06-24T20:01:53.787",
"storedBy": "admin",
"created": "2024-06-24T20:01:53.787",
"valueType": "TEXT",
"attribute": "H8beMnOxMzX",
"value": "plhiv"
}
]
}
]
}
In case if I used normal API point, I could create such nested TEI by posting all TEI to the /api/trackedEntityInstances API point. But I have no idea how to use useDataMutation hook and its mutation payload\request part, as couldn’t find clear guidance on the portal and documentations.
If it is not possible, then please guide me the steps which to be done to create such nested TEI with enrollments & events in other ways.
Thank you
Regards,
Ulanbek