Setting up a hidden calculation to label duplicates

Hello!

We use our CommCare app as an electronic medical record, and would like to set up a way to label when patient cases are closed because they are duplicates vs. when they are closed because the patient has stopped treatment, moved, died, etc., so that we can filter out duplicate records from our aggregate reports.

It seems to me that the best way to do this would be to add a hidden calculation to the forms that update a patient case property that indicates whether the record is a duplicate or not. We would want it to be possible to indicate that the record is a duplicate in 2 ways--first, users should be able to do this from the app if they fill out a form (that already exists) to close a case because it's a duplicate; second, CommCare HQ users should be able to update this field before they close a case because it is a duplicate.

What is the best way to achieve these 2 things? Any insight you have would be greatly appreciated!

Hi Katy,

This sounds like a great idea, and my thoughts are below:

  • You could have a hidden value called "duplicate" and save that to a case property called "duplicate"
  • When a duplicate is identified by a mobile worker, they could do this through a form and set the hidden value to = "1", thereby setting the case property to "1"
  • When a duplicate value is identified by a web user, they could go into the case on HQ and use the "clean case data" feature to change the case property "duplicate" from 0 to 1.
  • Then, if you wanted to automate this process, you could use automatic case closing rules: https://confluence.dimagi.com/display/commcarepublic/Automatically+Close+Cases that look for the "duplicate" value to equal 1!

Thanks,
Kai

Hi Kai,

Thanks for this advice! I was successfully able to add a hidden value called "duplicate_patient" into the form we use within the app to mark patients as having stopped treatment. It's set up so that if the reason selected for closing the case is that the record is a duplicate, the value = 1.

If(close reason = 'duplicate', 1, "").

However, I would like to be able to edit this field by exporting case data, changing the value, and re-importing it (since we have a lot of duplicates we want to flag). I tried doing this for some sample cases but I wasn't able to change the value stored in CommCare. My intuition is that I need to use a coalesce function (?) or something similar for the calculation, but I'm having trouble wrapping my head around this.

Do you have any advice?

Thanks!

Hey Katy,

Did you get any error messages? Or did the upload simply not stick?

Thanks,
Kai

They just didn’t stick!