Building > Contact management : Contact Summary
Managing contacts and users in your CHT Application
This tutorial will take you through building a contact summary for CHT applications.
Contact summaries display basic information about the contact.
You will be adding a contact summary that displays information about a person’s patient id, age, sex, phone number, and information about the place they belong to ie. parent.
Each field that can be shown on a contact’s profile is defined as an object in the fields array of contact-summary.templated.js
.
The properties for each object determine how and when the field is shown.
You should have a functioning CHT instance with cht-conf
installed locally, and completed a project folder setup.
Create a contact-summary.templated.js
file. (This may have already been created by the initialise-project-layout command.)
Add the following dependencies and variable definitions at the top of the file:
const thisContact = contact;
const thisLineage = lineage;
Define the patient_id
, age
, sex
, phone
, and parent
contact fields as shown below:
const thisContact = contact;
const thisLineage = lineage;
const fields = [
{ appliesToType: 'person', label: 'patient_id', value: thisContact.patient_id, width: 4 },
{ appliesToType: 'person', label: 'contact.age', value: thisContact.date_of_birth, width: 4, filter: 'age' },
{ appliesToType: 'person', label: 'contact.sex', value: 'contact.sex.' + thisContact.sex, translate: true, width: 4 },
{ appliesToType: 'person', label: 'person.field.phone', value: thisContact.phone, width: 4 },
{ appliesToType: 'person', label: 'contact.parent', value: thisLineage, filter: 'lineage' },
];
patient_id
and date_of_birth
, should exist in the contact’s document for it to return a value.fields
Export the defined fields as shown below:
const thisContact = contact;
const thisLineage = lineage;
const fields = [
{ appliesToType: 'person', label: 'patient_id', value: thisContact.patient_id, width: 4 },
{ appliesToType: 'person', label: 'contact.age', value: thisContact.date_of_birth, width: 4, filter: 'age' },
{ appliesToType: 'person', label: 'contact.sex', value: 'contact.sex.' + thisContact.sex, translate: true, width: 4 },
{ appliesToType: 'person', label: 'person.field.phone', value: thisContact.phone, width: 4 },
{ appliesToType: 'person', label: 'contact.parent', value: thisLineage, filter: 'lineage' },
];
module.exports = {
fields: fields
};
To compile and upload app settings to your local instance, run the following command:
cht --url=https://<username>:<password>@localhost --accept-self-signed-certs compile-app-settings upload-app-settings
<username>
and <password>
with the actual username and password of your test instance.Managing contacts and users in your CHT Application
Customizing the fields, cards, and actions on profile pages
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.