Users are people who are authorised to access the PainChek system.
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 and Managing Access to Sites for a User for more details. |
phone |
Optional string |
A contact number for the user |
role |
Mandatory string |
The role the user can act in - one of: - license_admin: A Super Administrator with all rights - admin: An administrator - user: A regular user A full description of the roles is beyond the scope of this document - please consult with PainChek support start for more details. |
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:
|
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:
{ "count": 2, "next": null, "previous": null, "results": [{ "uuid": "c0d06995-87dd-4437-a92e-338f53b7dba5", "license": "a89e0cc1-fd90-4721-b09b-7f527f5ff626", "license_name": "A89E0CC1-FD90/PainChek Ltd/2018-08-25", "email": "user_e@painchek.com", "first_name": "User", "last_name": "E", "phone": "", "institution": null, "institution_name": null, "position": "", "avatar": null, "has_activated": true, "role": "user", "is_active": true, "date_joined": "2017-08-28T12:13:38.364000Z", "modified_at": "2017-09-01T07:49:55.055000Z", "external_id": null }, { "uuid": "0507f1a3-7d50-4f3e-a5ae-a8f3c318e151", "license": "a89e0cc1-fd90-4721-b09b-7f527f5ff626", "license_name": "A89E0CC1-FD90/PainChek Ltd/2018-08-25", "email": "user_f@painchek.com", "first_name": "User", "last_name": "F", "phone": "", "institution": "c186cf8e-708c-479e-acbd-d534f54b7e89", "institution_name": "St George Hospital / Kogarah", "position": "", "avatar": null, "has_activated": true, "role": "admin", "is_active": true, "date_joined": "2017-11-09T22:51:43.901808Z", "modified_at": "2017-11-17T23:03:15.653663Z", "external_id": null }] }
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 }
Note
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.
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/").
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
Note
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 }
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.