Write custom transition and edit contact form with task

Originally apart of this thread.

Would it be possible to raise, or flag, duplicate contacts for correction using a custom transition & tasks?

Looking at the death reporting functionality CHT provides, we’ve seen it’s possible for a app report to affect a contact record.
We’re hoping we could write a custom transition that checks it’s immediate siblings for a possible match. If the record is deemed as too similar, we’d like to append a rectify=true field to the record.
After syncing, a task watching for that property would then trigger and highlight the item needing attention.
The edit form of that contact, will then clear that rectify field value that was appended to the record by the transition.

I believe sentinel transitions run in series, and since this could be expensive, it would need to be placed last?

Having the task open the contact form does not load it’s previous information. I’ve tried to provide the information via the modifyContent function, however, it does not seem to set the ID to the original contact. Which does not update the original record. Is there a way to do this?

Saving the edit contact form that was opened via the task creates a report, is there any way to suppress this?

Some great design thoughts here! Unfortunately, none of this is really going to be possible without changes to cht-core code. I agree that it could be possible to follow a similar pattern from death/muting. One big decision to make would be how this should work offline (or if it should work at all). If we want to be able to flag duplicates while the user is offline, then a Sentinel transition cannot be involved. I would encourage having these more in-depth design discussions over on the GitHub issue: Prevent and/or merge duplicate contacts · Issue #6363 · medic/cht-core · GitHub Hopefully we can start to coalesce on an agreed upon design approach (particularly if there is interest in raising a PR!).

Also, unfortunately at this time I do not think it is possible to launch a contact form from a task. I have seen it done where the task launches an ephemeral app form that simply provides the user with a link to go edit the contact.

1 Like