The calls documented in this section are currently not available for public use.
If you would like access to these endpoints, contact PainChek support and we can discuss lifting the restrictions on these endpoints.
Users are people (or systems) authorised to access the PainChek system.
Key User fields
Field |
Type |
Comment |
---|---|---|
first_name |
Mandatory String |
The patients first name |
last_name |
Mandatory String |
The patients last name |
|
Mandatory String |
The users' email address and login id |
position |
Optional string |
The users position - e.g. "Doctor", "Nurse", "Carer" |
institution |
Optional UUID |
The UUID of the institution that the user belongs to. See Managing Sites for more details. |
phone |
Optional string |
A contact number for the user |
role |
Mandatory string |
The role the user can act in - one of: |
is_active |
Mandatory boolean |
Indicates if the user can sign in or not. Defaults to true. |
full_site_access |
Optional Boolean (defaults to False) |
Indicates if a user has access to all sites (that is, can the access data for all residents, or just a subset of residents admitted to particular sites). For a "license_admin", this field is ignored and full site access is always granted. For other roles, set as follows:
|
Listing Users
To list all Users in your PainChek instance (in the User Acceptance Environment), issue the following command:
curl https://ap.ua.painchek.com/api/account/users/
Sample return data:
Creating a User
To create a user, issue the following command (which shows the minimum fields that need to be supplied - you can add other fields, such as a nickname):
curl \
-H "Content-Type: application/json" \
-X POST https://ap.ua.painchek.com/api/account/users/ -d @- << EOF
{
"first_name":"Fred",
"last_name":"Smith",
"is_active": true,
"email": "user_f@painchek.com",
"role": "user"
}
EOF
The return is the full user record:
{
"uuid": "d3aacc26-d4ba-41b4-a213-8ee9753d63f8",
"license": "a89e0cc1-fd90-4721-b09b-7f527f5ff626",
"license_name": "A89E0CC1-FD90/PainChek Ltd/2018-08-25",
"email": "user_g@painchek.com",
"first_name": "Fred",
"last_name": "Smith",
"phone": null,
"institution": null,
"institution_name": null,
"position": null,
"avatar": null,
"has_activated": false,
"role": "user",
"is_active": true,
"date_joined": "2017-11-18T01:35:04.466992Z",
"modified_at": "2017-11-18T01:35:04.473454Z",
"external_id": null
}
After creating a user, they will be emailed an activation email. Once they follow the link in that email and activate their account (and see a password for the account), the users' "has_activated" field will change from false (as seen above) to true.
Updating a User
To update a User, issue a PATCH to the "api/account/users/{user_uuid}/" endpoint, passing the same JSON details as you would when creating the record using a POST to "api/account/users/".
You will get the full details of the user returned (i.e. the same details as you get returned when creating the record using a POST to "api/accounts/users/").
Enabling and Disabling a User
A user can be disabled (or re-enabled) by issuing a PATCH to the user record, updating the is_active field as required.:
curl \
-H "Content-Type: application/json" \
-X PATCH https://ap.ua.painchek.com/api/account/users/d3aacc26-d4ba-41b4-a213-8ee9753d63f8/ -d @- << EOF
{
"is_active": false
}
EOF
The UUID of the user to update is included in the URL - in this case it is "d3aacc26-d4ba-41b4-a213-8ee9753d63f8".
The return is the full user record:
{
"uuid": "d3aacc26-d4ba-41b4-a213-8ee9753d63f8",
"license": "a89e0cc1-fd90-4721-b09b-7f527f5ff626",
"license_name": "A89E0CC1-FD90/PainChek Ltd/2018-08-25",
"email": "user_g@painchek.com",
"first_name": "Fred",
"last_name": "Smith",
"phone": null,
"institution": null,
"institution_name": null,
"position": null,
"avatar": null,
"has_activated": false,
"role": "user",
"is_active": false,
"date_joined": "2017-11-18T01:35:04.466992Z",
"modified_at": "2017-11-18T01:50:36.739241Z",
"external_id": null
}
Changing a Users Role
A users role can be changed by using the same method (i.e. issuing a PATCH) as used to enable/disable a user.
To change their role, set the "role" attribute to the required value.
Setting a Users Avatar
This is currently not supported.