Hi,
As per the documentation https://docs.communityhealthtoolkit.org/apps/guides/forms/form-inputs/#app-forms, I am unable to populate some data collected from person create contact to an app form, that requires the data for further processing as below without redundancy of collecting the same twice, please advise.
Person Contact Create Fields
DSS App Form
It looks like you might be mixing a couple different methods for loading contact data in an app form.
If you want to load data into your DSS app form (e.g. the person’s per_info/opdno
field) for the person in context (you opened the DSS form from the person’s profile page), then you can just include the inputs/contact/per_info/opdno
field in your form and it will be automatically populated with data from the contact in context as indicated by these docs. Then you can reference the inputs/contact/per_info/opdno
field from calculation
s and use the value wherever you want. (But note that you do need to include the groups and field for inputs/contact/per_info/opdno
in your xlsx config for the value to be picked up.)
type |
name |
calculation |
begin group |
inputs |
|
begin group |
contact |
|
begin group |
per_info |
|
hidden |
opdno |
|
end group |
per_info |
|
end group |
contact |
|
end group |
input |
|
calculate |
current_opdno |
…/inputs/contact/per_info/opdno |
If you need to load data from a contact that is not the one in context, then you need to use the contact selector configuration. In that case, though, you should use a dedicated group that contains the fields you want to load from the contact (with the select-contact
appearance _just on the _id
field).
type |
name |
appearance |
begin group |
current_person |
|
string |
_id |
select-contact type-person |
begin group |
per_info |
|
hidden |
opdno |
|
end group |
per_info |
|
end group |
current_person |
|
That should let you load the opdno
value for whatever contact the user selects during the DSS app form.
1 Like
@jkuester, thank you for the feedback, was getting lost from the docs on when to use the select-contact type-person and select-contact type-clinic, will revise the form and test
2 Likes
@jkuester, when trying to edit the forms, especially create person contact, it doesnt pull the data but brings blank fields. Spent time following documentation ([Input data available in forms | Community Health Toolkit]) to revise the edit forms, but not yet working, what could I have missed? The fields are blank when you click on edit.
For the edit form, the data for the existing contact is “contained in a top-level group that is named for the contact_type id of the contact”.
In your case, it looks like you expect the contact_type of the person you are editing to be new_patient
. Is that correct? (Can you double-check one of the contact docs to confirm that it’s contact_type is actually new_patient
?). If new_patient
is correct, then your form config looks generally correct. Which exact data is not being loaded as expected?
@jkuester, yes the contact type is new_patient as below:
{
“id”:“new_patient”,
“name_key”:“contact.type.new_patient”,
“group_key”:“contact.type.new_patient.plural”,
“create_key”:“contact.type.new_patient.new”,
“edit_key”:“contact.type.new_patient.edit”,
“primary_contact_key”:“new_patient.field.contact”,
“parents”:[
“national_office”,
“link_facility”,
“facility_admin”,
“health_worker”
],
“icon”:“patient”,
“create_form”:“form:contact:new_patient:create”,
“edit_form”:“form:contact:new_patient:edit”,
“person”: true
}
When you edit the contact created, a blank form is displayed with no data as below:
Okay, got it. Unfortunately, nothing is jumping out here to me as being the cause of the issue. ![:thinking: :thinking:](https://communityhealthtoolkit.b-cdn.net/images/emoji/apple/thinking.png?v=12)
Can you possibly send me the create/edit contact forms and I can try to debug this more on my end? You can ether post them here or dm/email me.
@oyierphil regarding the data not being pulling into the edit form, can you double-check that you uploaded the latest version of your create/edit forms to your test instance? I was able to deploy the forms you shared with me, and the data for an existing contact loaded just fine into the edit form. (First I wrote a new contact with the create form, then I tried editing it with the edit form.)
I did see an error when initially loading the create
form (not sure if it works fine on 3.x
and just fails on 4.x
). Basically I had to update the ephemeral_years
field to have a relevant
value of ${age_years} != ''
. Adding this expression allowed the form to load for me without error.
@jkuester, I noted the error with the date field in CHT 4.9 on the console, so I deleted the sections for getting the date in the contact forms, and captured the date in the app forms, the form is simplified and can now edit the contacts, will update the date field for future forms, best.
1 Like