How does the default delivery form create new contacts?

Okay, hopefully this is an easy question, but I have not been able to figure it out. When using the default configuration and I submit a delivery form with one (or more) live births, I see that a new contact is added to the mother’s household for each baby.

What I am trying to figure out is where the actual code is that triggers the new contacts to be created for the babies. I did not see anything in the delivery form config or the default tasks.js that I thought would be able to do that, but maybe I am missing something…

Thank you!

This function creates the list of docs (original + extra) to be created when a form is submitted: cht-core/enketo.service.ts at master · medic/cht-core · GitHub

What defines a new document is the db-doc xml attribute: cht-core/enketo.service.ts at master · medic/cht-core · GitHub

However, all properties of the document, except for its uuid, are assigned by the form itself (by using calculates). Take the default delivery form as an example: cht-core/delivery.xml at master · medic/cht-core · GitHub or cht-core/delivery.xml at master · medic/cht-core · GitHub

2 Likes

Thanks @diana that is exactly what I was missing! For anyone looking at this in the future, here is the documentation page that missed when first looking for the answer.