Building App Forms

Building CHT app forms

App forms allow users to submit reports from Android devices

This tutorial will take you through how to build App forms for CHT applications, including:

  • Authoring forms in Excel, Google sheets or other spreadsheet applications.
  • Converting XLSForms to XForms
  • Uploading XForms to CHT

You will be building assessment workflow that allows Community Health Workers to conduct a health assessment for children under the age of 5.

Brief Overview of Key Concepts

App forms serve as actions within the app.

XLSForm is a form standard created to help simplify the authoring of forms in Excel.

XForm is a CHT-enhanced version of the ODK XForm standard.

Required Resources

You should have a functioning CHT instance with cht-conf installed locally and a project folder set up already.

Implementation Steps

Create a new spread sheet in Google sheets or other preferred editor like Excel or Open Office. Name the spreadsheet assessment. The final file name should be assessment.xlsx.

Create 2 additional sheets. Rename the sheets survey, choices and settings.

1. Define XLS Survey/Form Fields

Create the following columns in the survey sheet and then add the following rows that are populated automatically before the form is rendered to the user. These fields are usually hidden by default but can be accessed to display certain information about the person being assessed:

typenamelabelrequiredrelevantappearanceconstraintconstraint_messagecalculationchoice_filterhintdefault
begin groupinputsPatient./source = ‘user’field-list
hiddensourceSourceuser
hiddensource_idSource_ID
hiddentask_idTask_ID
begin groupcontactContact
string_idPatient IDselect-contact type-personSelect a person from the list
hiddenpatient_idMedic ID
hiddennamePatient Name
begin groupparentParent
hidden_idFamily UUID
begin groupparentGrandparent
hidden_idCHW Area UUID
hiddennameCHW Name
hiddenphoneCHW Phone
begin groupparentGreat Grandparent
hidden_idCU UUID
end group
end group
end group
end group
end group
calculatepatient_id../inputs/contact/_id
calculatepatient_name../inputs/contact/name

Add the following rows that define the data collection fields below the existing rows (leave out the column names):

typenamelabelrequiredrelevantappearanceconstraintconstraint_messagecalculationchoice_filterhintdefault
begin groupgroup_assessmentAssessment
select_one yes_nocoughDoes ${patient_name} have a cough?yes
select_one symptom_durationcough_durationHow long has the cough lasted?yes${cough} = ‘yes’
end group

2. Define the Choices

Add the following column names and rows to the choices sheet:

list_namenamelabel
yes_noyesYes
yes_nonoNo
symptom_duration33 days or less
symptom_duration74 - 7 days
symptom_duration138 - 13 days
symptom_duration1414 days or more

3. Define the XLS Settings

Add the following column names and rows to the settings sheet:

form_titleform_idversionstylepathinstance_namedefault_language
Assess patientassessment1pagesdataen

4. Convert the XLSForm and Upload the XForm

Add the file to the forms/app subfolder in your project.

project-name
  forms
    app
      assessment.xlsx

To convert and upload the form to your local instance, run the following command from the root folder:

cht --url=https://<username>:<password>@localhost --accept-self-signed-certs convert-app-forms upload-app-forms -- assessment

Next steps

In the next tutorial, you will define the form <form_id>.properties.json which will allow you to define the form’s title and icon, as well as when and where the form should be available.


CHT Applications > Reference > forms/ > contact

Contact Forms: Used for creating and editing people and places

CHT Applications > Reference > forms/ > app

App Forms: Used to complete reports, tasks, and actions in the app

Design System > Best Practices : Forms

This document covers the configuration best practices of forms, tasks, targets, and contact profiles when building your own community health app.

Design System > Best Practices : Content and Layout

This document covers the configuration best practices of forms, tasks, targets, and contact profiles when building your own community health app.

Design System > Best Practices : Summary Page

This document covers the configuration best practices of forms, tasks, targets, and contact profiles when building your own community health app.