Input data available in forms

Data accessible from within CHT forms

CHT forms have access to varying amounts of input data depending on the type of form and its source.

contact forms

Available data:

inputs data for contact in contact forms

Forms for adding contacts have access to a small group of fields nested in the inputs group. These fields are contained in a group that is named for the contact_type id of the contact being added (so person, clinic, etc).

begin groupinputsNO_LABEL
begin grouppersonNO_LABEL
hiddenparentParent IdContains the doc id for the new contact’s parent contact doc.
hiddencontact_typeContact TypeThe contact_type id of the contact.
end group
end group

app forms

Available data:

Form source

If a form is created from the “People” tab, inputs/source will be set to “contact”. If a form is created from a task, inputs/source will be set to “task”.

inputs data for contact in app forms

app forms with a contact in context have access to that contact’s data in the inputs/contact group.

The contact group contains all the fields from the doc of the contact in context. If a place is in context, the primary person for that place will be hydrated in the inputs/contact/contact group. Alternatively, when a person is in context, the parent place for the person will be hydrated in inputs/contact/parent.

contact-summary data

app forms with a contact in context can access the contact-summary data associated with the contact. This is done by referencing an instance named contact-summary. E.g. instance('contact-summary')/context/${variable}. See the reference documentation for more information.

inputs data from task

app forms created via a task have access to any data supplied by the task in the inputs group.

user data

Both app and contact forms can access the current user’s data at inputs/user. The data provided is simply the CouchDB doc for the user (e.g. org.couchdb.user:username) plus an additional language field that contains the user’s currently selected language code.

Example of saving user data as metadata on a report

begin groupinputsNO_LABEL
begin groupuserNO_LABEL
stringcontact_idUser’s contact id
stringfacility_idId for user’s facility
end group
end group
calculatecreated_byUsername that created report../inputs/user/name
calculatecreated_by_person_uuidUUID that created report../inputs/user/contact_id
calculatecreated_by_place_uuidFacility of user that created report../inputs/user/facility_id

Loading the user’s contact data

While the inputs/user group does not contain the user’s contact data, it does contain the user’s contact_id which can be used to load the contact doc via a contact selector.

Contact selector

Using a contact selector allows you to load data from the selected contact (person or place). The contact’s id can be provided by the form or the user can search for an existing contact.

To select a contact in a form, create a field with the type string and set the appearance to select-contact type-{{contact_type_1}} type-{{contact_type_2}} .... Setting multiple contact_type ids allows the user to search among multiple types of contacts. If no contact type appearance is specified then all contact types will be queried when searching.

The contact selector can be used to link reports to the person or place in context when the form was created. Getting the values for _id or patient_id and setting them to patient_id or patient_uuid on the final report will link that report to the contact. Then the report will be displayed on the contact’s summary page.

begin groupinputsNO_LABEL
begin groupcontactNO_LABEL
string_idPatient IDselect-contact type-person
stringpatient_idMedic IDhidden
end group
end group
calculatepatient_uuidPatient UUID../contact/_id
calculatepatient_idPatient ID../contact/patient_id

CHT Applications > Reference > contact-summary.templated.js

Contact Pages: Customizing the fields, cards, and actions on profile pages

CHT Applications > Quick Guides > Tasks > Passing Data from Tasks to Forms

Demonstrates how to pass data into an application form via tasks