Contact and User Management - Part 2

Creating and editing contacts and users with cht-conf

In this tutorial you will learn how to create and edit contacts and their associated users in the CHT application using cht-conf. If you haven’t already, have a look at part 1 of this tutorial for a useful overview of key concepts.

Brief Overview of Key Concepts

cht-conf is a command-line interface tool to manage and configure your apps built using the Core Framework of the Community Health Toolkit.

See more key concepts in part 1 of this tutorial.

Required Resources

You should have a functioning CHT instance and have cht-conf installed locally. Read How to set up a CHT local configuration environment

Implementation Steps

In these steps you are going to create a Health Facility, CHW Areas, primary contacts for the CHW Areas, and their associated users.

1. Create Health Facilities (using cht-conf’s csv-to-docs and upload-docs features)

To create contacts and their associated users with cht-conf, you will need to create a CSV file with the information of the contacts and the users that you would like to create. The name of the file determines the type of doc created for rows contained in the file.

For example, file named place.district_hospital.csv adds the property "type":"district_hospital" and a file named person.clinic.csv add the property "type":"person"

Create a CSV file named place.district_hospital.csv and add the details of the Health Facilities you would like to create.

name
Nairobi South Facility
Nairobi West Facility
Nairobi East Facility

Save this file to a folder name csv in your project’s base directory.

Open terminal or command line. cd to your project’s base directory and then run the command

cht csv-to-docs

This will convert rows of the CSV files from the csv folder to JSON docs that are stored in a json-docs folder.

To upload the JSON docs to your local test instance, run the command

cht --url=https://<username>:<password>@localhost --accept-self-signed-certs upload-docs

Be sure to replace the values <username> and <password> with the actual username and password of your test instance.



2. Create CHW Areas, CHW Contacts and Users (using cht-conf’s create-users feature)

Next you are going to create CHW Areas for the Health Facilities you created in the step above along with the CHW contacts and users for these CHW Areas.

Create a CSV file named users.csv and add the details of the Users, CHW contacts, and CHW Areas you would like to create. Save this file in the base project directory.

usernamepasswordrolesfullnamephonecontact.namecontact.phonecontact.sexcontact.ageplace.typeplace.nameplace.parent
mmutisoq3Z5-vH5district_adminMary Mutiso0712345678Mary Mutiso0712345678Female36health_centerMary Mutiso’s Area<facility uuid>


The value place.parent is the uuid of the Facility to which the CHW Area belongs to. You can get this value by selecting the Health Facility in the webapp and copying the last portion of the url.


Run the command

cht --url=https://<username>:<password>@localhost --accept-self-signed-certs create-users

This will create the CHW Area, the CHW contact, and the user that the CHW will use to log into the application.

Frequently Asked Questions


Building > Contact management > Contacts + Users 1

Creating and editing contacts and users in the CHT UI

CHT Core Framework > Overview > Database Schema

Schema for database objects

Building > Quick Guides > Data > Bulk Load Users

How to create users in bulk

Building > Concepts > Users

Defining the user roles and their permissions