Accessing contact parents info from app forms

Hi there,
In a form with a person type context I’m able to access to the info of his c40_chw_area like this

../inputs/contact/parent/parent/_id
../inputs/contact/parent/parent/name
../inputs/contact/parent/parent/aire_de_sante
../inputs/contact/parent/parent/mam

But I’m not able to the same with the ancestors of this place, I can get the _id of the c30_supervisor_area with

../inputs/contact/parent/parent/_id

but not other info of this place like name or whatever in his doc.
The same occurs with his others ancestors, like c20_health_area or c10_site only _id is avaliable.

Is there another way to get access to all ancestors info in addition to the _id ?

When referencing the _id field of the c30_supervisor_area in your form, are you using the contact selector functionality (select-contact or db-object)?

Loading this contact data in the inputs can be a little confusing since you will get any of the data already in the contact doc (e.g. the _id) automatically, but if you want to hydrate anything on the parent docs, you need to use the contact selector on those _id fields… Once you have setup the _id field with the contact selector appearance, the sibling fields should automatically be populated with the data from the identified document.

I’ve been using both with no success but in the area that i can get all the document, apparenace is set to db-object

@bamatic would it be possible for you to post a more complete table of the config you are using (at least for the inputs)? Also, what version of the CHT are you running?

These will be helpful when trying to recreate this issue!

type name label::en label::fr label::bm required required_message::en required_message::fr required_message::bm appearance relevant default constraint constraint_message::en constraint_message::fr constraint_message::bm choice_filter calculation hint::en hint::fr hint::bm media::image::en media::image::fr media::image::bm media::video instance::type instance::tag read_only
begin group inputs Patient Patient field-list ./source = ‘user’ hidden
string source Source Source hidden user
string source_id Source ID Source de l’Identifiant hidden
begin group user User User
string language NO_LABEL NO_LABEL NO_LABEL 0
string fullname NO_LABEL NO_LABEL NO_LABEL hidden
string is_in_sih NO_LABEL NO_LABEL NO_LABEL hidden
end group
begin group contact Contact Contact
db:person _id What is the patient name? Quel est le nom du patient? Banabagatɔ tɔgɔ n’a jamu db-object Patient must be more than 5 years old L’âge du patient doit être inférieur ou égal à 5 ans Banabagatɔ si mankan ka caya ni san 5 ye select a person from the list Choisir une personne dans la liste Mɔgɔ dɔ sugandi lisi kɔnɔ
string name Name Nom Tɔgɔ ni jamu hidden
string date_of_birth Date of birth Date de naissance Bange waati hidden
string sex Sex Sexe Cɛ wa muso hidden
string phone Phone Phone Phone hidden
string external_id Muso ID ID de Muso Banabagatɔ ka nimɔrɔ
begin group parent Family NO_LABEL NO_LABEL
db:person _id Parent ID db-object
string type Type
begin group parent CHW Area Zone d’ASC NO_LABEL
db:person _id Area ID ID de la zone db-object
db:person aire_de_sante CSCOM CSCOM CSCOM hidden
string name NOM
string mam MAM
begin group parent SUPERVISOR ZONE Zone de supervision NO_LABEL
string _id supervisor_id ID de la zone select-contact
string name name
string mam MAM
begin group parent HEALTH AREA ZONE DE SANTE NO_LABEL
db:person _id Health ID ID de la zone db-object
string mam MAM
begin group parent SITE SITE NO_LABEL
db:person _id Area ID ID de la zone db-object
string mam MAM MAM MAM hidden
end group
end group
end group
end group
end group
end group

The version is 3.14.2

type name label::en label::fr label::bm required required_message::en required_message::fr required_message::bm appearance
begin group parent CHW Area Zone d’ASC NO_LABEL
db:person _id Area ID ID de la zone db-object
db:person aire_de_sante CSCOM CSCOM CSCOM hidden
string name NOM
string mam MAM

I am not sure if this is the root cause of your issue, but it is a place to start. You do not want to have two separate contact selector fields (e.g. db:person) in the same group since that could cause collisions when trying to load data from both into the group.

To load the data for the aire_de_sante (assuming that is a different id value than parent/_id) then I think the best thing to do would be to just define that field as a string instead of a db:person. Then, in a new group (that could just go at the root level, or wherever else makes sense) you could load the data for that doc:

type name label::en label::fr label::bm required required_message::en required_message::fr required_message::bm appearance calculation
begin group health_area NO_LABEL hidden
string _id Area ID select-contact ${aire_de_sante}
string name Area Name
end group

I have tried all those combinantions, use string, with both apperanbce use db;person and string etc etc indeedd for the chw_area and the aire_de_sante key we dont have problems, but for the levels up to this level we can only get the _id
our hierarchy is person->c50_family->c40_chw_area->c30_supervisor_area->c20_helath_area->c10_site
I don’t know the cht-core source code, but it looks like the data population from couchdb doc to enketo forms, could maybe not hydrated for some high levels ? we are able to get from app forms data for the doc for levels till c40_chw_area, tomorrow I will try to do the same in 3.15 thank you

CHWs would log in at c40_chw_area and as such would have no visibility to documents from c30_* and above since they are ‘restricted to their place’. This behaviour is consistent across all cht releases for users restricted to a place.

2 Likes