Get cha phone number in a patient form

Hello CHT Developers,

I have a challenge,

Issue: Patient death reports submitted by the CHP are missing supervisor (CHA) name and phone number.

  • Need: The form must capture CHA details at the Community Health Unit (CHU) level.

  • Reason: To properly reflect the reporting hierarchy: Patient → Household → CHP Area → CHU → Subcounty → County.
    I need to get the cha name + phone so that I can pass those to the Subcounty Supervisor for Death Reporting Reminder Tasks.
    This is the hierarchy on the death_report.xlsx

On the xlsx, I can get the CHU ID but NOT the CHA Name + Phone Number.
Tried contact-summary to pass the value to the xlsx but I am unable to get to the CHA details.

content.t_cha_phone = (user.parent && user.parent.parent && user.parent.parent.contact && user.parent.parent.contact.phone) || '';

Attached is a screenshot of the inputs section of the xlsx.
I’d appreciate your thoughts on how we can solve this.

Are you getting the CHA _id value populated (at /inputs/contact/parent/parent/parent/contact/_id)? I think this should be getting loaded properly.

If so, then hopefully all you need to do to load data for the CHA is to switch that /inputs/contact/parent/parent/parent/contact/_id field to be a contact selector (add the appearances: select-contact type-{{contact_type_1}}). (Make sure to use the proper contact type id in your appearance.) This should prompt the form logic to load the additional data for that contact doc (including name and phone).

By default, the input contact data for an app form will only include the data from the doc referenced by /inputs/contact/_id plus the data from inputs/contact/contact/_id and/or inputs/contact/parent/_id. I do not think data for parent values higher in the hierarchy (e.g. your CHA) is loaded by default.

Thank you @jkuester No, am not getting the CHA ID at ../inputs/contact/parent/parent/parent/contact/_id.

Still, let me explore this.

:thinking: If you get stuck, it would be helpful if you could post your form xlsx here and an example contact doc that one of these forms would be submitted for.