How to get the reference ID of an extension case during a case export

commcare

I am using a series of extension cases in my application (structure shown below) and need a way to associate the extension cases with each other after doing a case export.

Extension case structure:

Adult > Child (extension case) > Health Task (extension case)

When I download the case export for the health task cases, the indices for the associated child cases are blank, making it impossible to map the health task cases to their associated child cases.

Using the raw_doc ID search for the health task case I am able to find the reference ID for the associated child case. However, this only allows me to search for one health task case at a time.

Is there a way for me to extract the reference ID for associated child cases in bulk for all of my health task cases?

Best Answer

The standard way to link exports between a case and it's parent case (or host case if you're using a host/extension relationship instead of parent/child) is to enable the section at the bottom of the Export Settings page called "Parent Cases" (select all boxes). Make sure [row] number is selected in the main case export.

Then when you look at your export in excel, you will have 2 tabs, the main one with the case's properties and a second one with the parent case ids. If every case in your export has a parent case, then the column for parent_case_id can just be copied from this tab into your main tab. If only some cases have parents, then you will have to use the "number" columns to match them up. Either way, you will end up with your export of all of the cases along with their parent_case_id. You can then use that id to link the cases to a separate export of the parent cases.