Manual Reference Source Test
import UserService from 'clinical6/src/services/UserService.js'
public class | source

UserService

Extends:

AbstractServiceJsonApiService → UserService

Service handling User calls with specific endpoints.

In order to manage user-specific data, access, and info, our SDK provides a user sign-in as well as a guest sign-in. With the plugin, as soon as a user launches your app, they will automatically be signed in as a guest. After you build a login page/UI, your users can enter their credentials to sign in to their own account.

Constructor Summary

Public Constructor
public

Update type to be mobile_users

Member Summary

Public Members
public

Method Summary

Public Methods
public

async acceptInvitation(token: String, options: String): Promise<User>

Allows a user to accept an invitation given a device and token

public
this method was deprecated.

Sets the pin value for an invited user.

public

async addAwardedBadge(awardedBadge: Object): Promise<AwardedBadge>

Add Awarded Badge

public

async addSchedule(schedule: Object): Promise<Schedule>

Add Schedule

public

async confirm(token: String, cacheMode: String): Promise

Confirms user with token

public

async delete(user: User, cacheMode: String): Promise

public
this method was deprecated.

Removes the current user from the system.

public
this method was deprecated.

Deletes the profile attribute value with the given ID.

public
this method was deprecated.

Removes a related mobile user.

public
this method was deprecated.

Disables a related mobile user.

public
this method was deprecated.

Disables the current user's account. This action will revoke the user's access to the system.

public

emailAccountName(emailAddress: String): Promise

this method was deprecated.

Sends user's account name via email. This method does not require an access token.

public

emailPassword(emailAddress: String): Promise

this method was deprecated.

Starts the reset password process and sends an email to the user with instructions.

public
this method was deprecated.

Enable a related mobile user.

public

async get(params: Object, cacheMode: String): Promise<User[]|User>

public
this method was deprecated.

Returns all the values for the given profile attribute.

public

async getAwardedBadges(awardee: Object, awardedBadge: Object, cacheMode: String): Promise<Badge[]|Badge>

Get User Badges

public

async getDataGroup(user: Object, params: Object, cacheMode: String): Promise<FlowDataGroup>

Get Flow Data Group for a user.

public

async getEntries(user: Object, filters: Object, cacheMode: String): Promise<Entry[]|Entry>

Get eDiary entries

public

async getInvitationStatus(user: User, attributes: Object, relationships: Object): Promise<User>

Invite a user.

public

async getNotifications(user: Object, cacheMode: String): Promise<Notification[]

Get Notifications

public

async getProfile(user: Object, cacheMode: String): Promise<Profile>

Get the profile of a user (or current user if null).

public

getProfileAttributes(includeHidden: Boolean, includeValues: Boolean): Promise

this method was deprecated.

Gets all the custom attributes for the profile along with its values.

public

async getRegistrationStatus(attributes: Object, meta: String): Promise<String>

Returns the registration status of the user.

public

getRelatedMobileUsers(): Promise<{followed_users: User[], followers: User[]}>

this method was deprecated.

Retrieves all the related mobile users.

public

async getSchedules(user: Object, cacheMode: String): Promise<Schedule[]|Schedule>

Get Schedules for a user based on an id.

public

async getSession(token: String, cacheMode: String): Promise

Get the session of the logged in user.

public

async getSites(user: Object, cacheMode: String): Promise<Site[]|Site>

Get User Sites

public

async insert(user: User, cacheMode: String): Promise<User>

public
this method was deprecated.

Inserts a new value for the given profile attribute.

public

async invite(user: User, attributes: Object, relationships: Object): Promise<User>

Invite a user.

public

async register(attributes: Object, device: Device): Promise<User>

Register a device for guest, a username, or email

public

async removeAwardedBadge(awardedBadge: Object, cacheMode: String): Promise<AwardedBadge>

Remove Awarded Badge

public

async requestPasswordReset(attributes: Object): Promise

Starts the reset password process and sends an email to the user with instructions.

public

resendInvite(id: Number, options: any): Promise

this method was deprecated.

Resends an invite to a related mobile user.

public

async resetPassword(attributes: Object, device: Device): Promise<User>

Allows users to complete the Password reset flow.

public

resetPasswordSimple(newPassword: String, newPasswordConf: String, oldPassword: String): Promise

this method was deprecated.

Sends user's account name via email. This method does not require an access token.

public

async revokeConsent(user: User, cacheMode: String): Promise

This method revokes the consent for a user.

public

async saveProfile(param: Object, options: String): Promise<Profile>

Update Profile

public

Sends a confirmation email to an email address

public
this method was deprecated.

Sets the pin value for an invited user.

public

async signIn(attributes: Object, device: Device, cacheMode: String): Promise<Session>

Sign in user with account name.

public

async signOut(): Promise

Detaches the device from the mobile_user.

public

signUp(username: String, password: String, profile: Object): Promise

this method was deprecated.

Sign up a user with a user profile.

public

async unlockUser(email: String, unlockToken: String): Promise

Unlocks a user

public

update(user: User, options: String): Promise<User>

public

async updateAwardedBadge(awardedBadge: Object, cacheMode: String): Promise<AwardedBadge>

Update Awarded Badge

public
this method was deprecated.

Updates the profile information for the current, authenticated user.

public

async updateSchedule(schedule: Object, cacheMode: String): Promise<Schedule>

Update Schedule

Private Methods
private

_loginGetSession(response: Session | User, device: Device): Session

Get and Login Session From Response

private

_loginGetUser(response: Session | User, device: Device): User

Get and Login User From Response

Inherited Summary

From class AbstractService
public get
public set
public
private
From class JsonApiService
public

options: *

public

async delete(obj: Object, options: String): Promise

Call a DELETE request on the main obj.type expecting JSON API information.

public

async get(params: Object, options: String): Promise

Call a GET request expecting JSON API information.

public

async getChildren(parent: Object, child: Object, options: String): Promise

Call a GET request expecting JSON API information for children given a parent.

public

async insert(obj: Object, options: String): Promise

Call a POST request on the main obj.type expecting JSON API information.

public

async update(obj: Object, options: String): Promise

Call a PATCH request on the main obj.type expecting JSON API information.

Public Constructors

public constructor() source

Update type to be mobile_users

Override:

JsonApiService#constructor

Public Members

public type: String source

Override:

AbstractService#type

Public Methods

public async acceptInvitation(token: String, options: String): Promise<User> source

Allows a user to accept an invitation given a device and token

Params:

NameTypeAttributeDescription
token String
  • nullable: false

Token from request password reset email or accepting invitation email

options String
  • optional

Additional options for accepting invitations

options.anti_spam_accepted Boolean
  • optional

If the anti-spam policy was accepted by the user.

options.device Object
  • optional

Accept invitation with this device

options.device.id Number
  • optional

Must be the device id

options.email String
  • optional

Email, if it is set with the invitation acceptance page.

options.password String
  • optional

Password, if it is set with the invitation acceptance page.

options.privacy_policy_accepted Boolean
  • optional

If the privacy policy was accepted by the user.

options.terms_of_use_accepted Boolean
  • optional

If the terms of use accepted by the user.

Return:

Promise<User>

Session object is returned. For Mobile Users, this is a local Session object with the authentication token and the user object inserted locally.

Throw:

Clinical6Error

If missing required parameters

Example:

Mobile Users
import { mobileUserService } from 'clinical6';
mobileUserService.acceptInvitation('1afw00f...', {
   password: 'myPassword!@',
   terms_of_use_accepted: true,
   privacy_policy_accepted: true,
   anti_spam_accepted: true,
   device: { id: 15 }
}).then(user => console.log(user));
Admin Users
import { userService } from 'clinical6';
userService.acceptInvitation('1afw00f...', {
   password: 'myPassword!@',
   terms_of_use_accepted: true,
   privacy_policy_accepted: true,
   anti_spam_accepted: true
}).then(session => console.log(session.user));

Test:

public acceptInvitationPinV2(json: Object): Promise source

this method was deprecated.

Sets the pin value for an invited user.

Params:

NameTypeAttributeDescription
json Object

The JSON value with the attributes to provide for set pin.

json.pin String
  • nullable: false

The PIN

json.pin_confirmation String
  • nullable: false

The PIN Confirmation

json.invitation_token String
  • nullable: false

The invitation token

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Decorators:

  • deprecate

Example:

Accept Invitation
import { userService } from 'clinical6';
userService.acceptInvitationPinV2({
  "pin": "123456",
  "pin_confirmation": "123456",
  "invitation_token": "12345678910"
});
Success Response
{
  "status": "ok"
}
Failure, Password and confirmation do not match
{
  "error_detail": "Review the new_password and new_password_confirmation parameters",
  "friendly_error": "Password and confirmation do not match",
  "internal_code": 50362,
  "more_info": "",
  "status": "fail",
  "message": "Password and confirmation do not match"
}
Failure, No user found with the specified invitation_token
{
  "error_detail": {
    "invitation_token": [
      "invalid_value"
    ]
  },
  "friendly_error": "No user found with the specified invitation_token",
  "internal_code": 50364,
  "more_info": "",
  "status": "fail",
  "message": "No user found with the specified invitation_token"
}
Failure, Pin already exists
{
  "error_detail": {
    "password": [
      "already_exists"
    ]
  },
  "friendly_error": "Pin already exists",
  "internal_code": 50374,
  "more_info": "",
  "status": "fail",
  "message": "Pin already exists"
}

Test:

public async addAwardedBadge(awardedBadge: Object): Promise<AwardedBadge> source

Add Awarded Badge

Params:

NameTypeAttributeDescription
awardedBadge Object
  • nullable: false

The user, must have id

awardedBadge.attributes Object
  • nullable: false

Hashmap to add for award badge

awardedBadge.user User
  • nullable: false

The user, must have id

awardedBadge.user.id Number
  • nullable: false

The user id

awardedBadge.badge Badge
  • nullable: false

The user, must have id

awardedBadge.badge.id Number
  • nullable: false

The user id

Return:

Promise<AwardedBadge>

Promise object that returns one object or hashmap

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { userService, AwardedBadge, Badge, User } from 'clinical6';
const awardedBadge = new AwardedBadge({ updatedAt: '2018-06-02' });
awardedBadge.awardee = new User({ id: 5, ... });
awardedBadge.badge = new Badge({ id: 5, ... });

// You can add an awarded badge using the `addAwardedBadge` method
userService.addAwardedBadge(awardedBadge).then(result => console.log(result));

// Additionally, you can do the same thing using `User.addAwardedBadge()`
user.addAwardedBadge(awardedBadge).then(result => console.log(result));

Test:

public async addSchedule(schedule: Object): Promise<Schedule> source

Add Schedule

Params:

NameTypeAttributeDescription
schedule Object
  • nullable: false

The user, must have id

schedule.attributes Object
  • nullable: false

Hashmap to add for a schedule

schedule.mobileUser User
  • optional
  • nullable: false

The user, must have id

schedule.mobileUser.id Number
  • optional
  • nullable: false

The user id

Return:

Promise<Schedule>

Promise object that returns one object or hashmap

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { userService, Schedule, User } from 'clinical6';
const schedule = new Schedule({ updatedAt: '2018-06-02' });

// You can add a schedule using the `addSchedule` method
userService.addSchedule(schedule).then(result => console.log(result));

// Additionally, you can do the same thing using `User.addSchedule()`
user.addSchedule(schedule).then(result => console.log(result));

Test:

public async confirm(token: String, cacheMode: String): Promise source

Confirms user with token

Params:

NameTypeAttributeDescription
token String

Token to confirm user with

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing required parameters

Example:

import { userService.confirm('1afji13jiifjadif0ijadf');

Test:

public async delete(user: User, cacheMode: String): Promise source

Call a DELETE request on the main obj.type expecting JSON API information.

Override:

JsonApiService#delete

Params:

NameTypeAttributeDescription
user User

User object in which to update

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise

Message

Example:

import { mobileUserService } from 'clinical6';

// You will be able to delete a User using `delete`.
mobileUserService.delete({ id: 23 });
// This will also clear the local storage of this type and id

Test:

public deleteCurrent(): Promise source

this method was deprecated.

Removes the current user from the system. This action cannot be undone.

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token

Decorators:

  • deprecate

Example:

Delete User
import { userService } from 'clinical6';
userService.deleteCurrent(32);

Test:

public async deleteProfileAttribute(id: Number): Promise source

this method was deprecated.

Deletes the profile attribute value with the given ID.

Params:

NameTypeAttributeDescription
id Number

The ID value of the profile attribute

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Decorators:

  • deprecate

Example:

Delete Profile Attribute
import { userService } from 'clinical6';
userService.deleteProfileAttribute(3);
Success Response
{
  "status": "ok",
  "message": "Profile value was successfully deleted"
}
Failure, Not Found
{
  "error_detail": {
    "ProfileValue": [
      "not_found"
    ]
  },
  "friendly_error": "Profile value not found using the value:-1",
  "internal_code": 50364,
  "more_info": "",
  "status": "fail",
  "message": "Profile value not found using the value:-1"
}

Test:

public deleteRelated(id: Number): Promise source

this method was deprecated.

Removes a related mobile user.

Params:

NameTypeAttributeDescription
id Number

The ID value of the related mobile user to remove.

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Decorators:

  • deprecate

Example:

Delete User
import { userService } from 'clinical6';
userService.deleteRelated(32);
Success Response
{
  "invited": []
}
Failure, Mobile User Not Found
{
  "error_detail": {
    "id": "invalid_value"
  },
  "friendly_error": "Mobile User not found using the value:id",
  "internal_code": 50364,
  "more_info": "",
  "status": "fail",
  "message": "Mobile User not found using the value:id"
}

Test:

public disable(id: Number): Promise source

this method was deprecated.

Disables a related mobile user.

Params:

NameTypeAttributeDescription
id Number

The ID value of the related mobile user to disable.

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Decorators:

  • deprecate

Example:

Disable User
import { userService } from 'clinical6';
userService.disable(32);
Failure, Mobile User Not Found
{
  "error_detail": {
    "id": "invalid_value"
  },
  "friendly_error": "Mobile User not found using the value:id",
  "internal_code": 50364,
  "more_info": "",
  "status": "fail",
  "message": "Mobile User not found using the value:id"
}

Test:

public disableCurrent(): Promise source

this method was deprecated.

Disables the current user's account. This action will revoke the user's access to the system. The method does not delete any data related to the user.

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token

Decorators:

  • deprecate

Example:

Disable User
import { userService } from 'clinical6';
userService.disableCurrent(32);

Test:

public emailAccountName(emailAddress: String): Promise source

this method was deprecated.

Sends user's account name via email. This method does not require an access token.

Params:

NameTypeAttributeDescription
emailAddress String

The email address of the account.

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing required parameters

Decorators:

  • deprecate

Example:

Email Account Name
import { userService } from 'clinical6';
userService.emailAccountName();

Test:

public emailPassword(emailAddress: String): Promise source

this method was deprecated.

Starts the reset password process and sends an email to the user with instructions.

Params:

NameTypeAttributeDescription
emailAddress String

Email address to send the reset password email to.

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing required parameters

Decorators:

  • deprecate

Example:

Email Password
import { userService } from 'clinical6';
userService.emailPassword();

Test:

public enable(id: Number): Promise source

this method was deprecated.

Enable a related mobile user.

Params:

NameTypeAttributeDescription
id Number

The ID value of the related mobile user to enable.

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Decorators:

  • deprecate

Example:

Enable User
import { userService } from 'clinical6';
userService.enableUser(19);
Success Response
{
  "invited": []
}
Failure, Mobile User Not Found
{
  "error_detail": {
    "id": "invalid_value"
  },
  "friendly_error": "Mobile User not found using the value:id",
  "internal_code": 50364,
  "more_info": "",
  "status": "fail",
  "message": "Mobile User not found using the value:id"
}

Test:

public async get(params: Object, cacheMode: String): Promise<User[]|User> source

Call a GET request expecting JSON API information.

Override:

JsonApiService#get

Params:

NameTypeAttributeDescription
params Object
  • optional

Parameters used to get information from server (such as id)

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<User[]|User>

Promise object that returns one User or a key:User hashtable

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { mobileUserService } from 'clinical6';

// You will be able to access these mobile users using the `get` method.
mobileUserService.get().then(users => console.log(users));

// Additionally, you can retrieve the subcategories for a specific mobile user with the `get`
// method, using the ID of the desired mobile user as a parameter.
mobileUserService.get({id: 23}).then(users => console.log(users));

// This method will also pull back the `user.profile` should it exist for the user or list of users

Test:

public async getAllProfileAttributes(apiKey: String): Promise source

this method was deprecated.

Returns all the values for the given profile attribute.

Params:

NameTypeAttributeDescription
apiKey String

The API key value for the profile attribute.

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Decorators:

  • deprecate

Example:

Get All Profile Attributes
import { userService } from 'clinical6';
userService.getAllProfileAttributes('fj103jaf08j23jfds').then(attr => console.log(attr));

Test:

public async getAwardedBadges(awardee: Object, awardedBadge: Object, cacheMode: String): Promise<Badge[]|Badge> source

Get User Badges

Params:

NameTypeAttributeDescription
awardee Object
  • nullable: false

The user, must have id

awardee.id Number
  • nullable: false

The user id

awardedBadge Object
  • optional

Filters to modify result (date, entry_group_id)

awardedBadge.id Number
  • optional

Pulling back a specific badge via id from the user

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<Badge[]|Badge>

Promise object that returns one object or hashmap

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { mobileUserService, User } from 'clinical6';

// You can get entries using the `getAwardedBadges` method
mobileUserService.getAwardedBadges(new User({ id: 5 })).then(entry => console.log(entry));

const filters = { entry_group_id: 7, date: '2018-06-02'};
mobileUserService.getAwardedBadges({ id: 5 }, filter).then(entry => console.log(entry));

// Additionally, you can do the same thing using `User.getAwardedBadges()`
const user = new User({ id: 5, ... });
user.getAwardedBadges().then(entry => console.log(entry));
user.getAwardedBadges(filter).then(entry => console.log(entry));

Test:

public async getDataGroup(user: Object, params: Object, cacheMode: String): Promise<FlowDataGroup> source

Get Flow Data Group for a user. This method can get back data with or without a Flow Data Group ID. This endpoint does not support filters and can only process the page URL params.

Params:

NameTypeAttributeDescription
user Object
  • optional

User - if not defined, use logged in user

user.id Number
  • optional
  • nullable: false

User ID must exist

user.type String
  • optional
  • nullable: false

User type ('mobile_users' or 'users') must exist

params Object
  • optional
  • nullable: false

Parameters used to get information from server (such as id)

params.page Object
  • optional
  • nullable: false

Pagination information

params.page.number Number
  • optional

Number of pages of data to get back

params.page.size Number
  • optional

Number of results per page to get back

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<FlowDataGroup>

Promise object that returns one object

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { userService, FlowDataGroup } from 'clinical6';
userService.getDataGroup({ id: 24 });
const capturedValueGroup = new FlowDataGroup( {id: 24 });
userService.getDataGroup(capturedValueGroup);

Test:

public async getEntries(user: Object, filters: Object, cacheMode: String): Promise<Entry[]|Entry> source

Get eDiary entries

Params:

NameTypeAttributeDescription
user Object
  • nullable: false

The mobile user, must have id

user.id Number
  • nullable: false

The mobile user id

filters Object
  • optional

Filters to modify result (date, entry_group_id)

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<Entry[]|Entry>

Promise object that returns one object or hashmap

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { mobileUserService, User } from 'clinical6';

// You can get entries using the `getEntries` method
mobileUserService.getEntries({ id: 5 }).then(entry => console.log(entry));

const filters = { entry_group_id: 7, date: '2018-06-02'};
mobileUserService.getEntries({ id: 5 }, filter).then(entry => console.log(entry));

// Additionally, you can do the same thing using `User.getEntries()`
const user = new User({ id: 5, ... });
user.getEntries().then(entry => console.log(entry));
user.getEntries(filter).then(entry => console.log(entry));

Test:

public async getInvitationStatus(user: User, attributes: Object, relationships: Object): Promise<User> source

Invite a user.

Params:

NameTypeAttributeDescription
user User

The user in which to invite (required)

user.email String
  • nullable: false

The email address of the invited user. (required)

attributes Object

A list of optional attributes not found in user or profile. This can contain any key/value.

attributes.invitation_token String

The token used for accepting an invitation

relationships Object
  • optional

A list of optional relationships not found in user or profile. This can contain any key/value.

Return:

Promise<User>

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

Get Invitation Status
import { userService, User } from 'clinical6';
const user = new User({ email: 'john.brown@parallel6.com' });
let status = await userService.getInvitationStatus(user, { invitation_token: 'asdf1234' });
Get Default User Invitation Status
import { userService } from 'clinical6';
// first param will default to clinical6.user
let status = await userService.getInvitationStatus(undefined, { invitation_token: 'asdf1234' });

Test:

public async getNotifications(user: Object, cacheMode: String): Promise<Notification[] source

Get Notifications

Params:

NameTypeAttributeDescription
user Object
  • optional
  • nullable: false

The user, must have id

user.id Number
  • optional
  • nullable: false

The user id

user.type String
  • optional
  • nullable: false

The user type

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<Notification[]

Promise object that returns a list of Notifications

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { mobileUserService, User } from 'clinical6';

// You can get entries using the `getNotifications` method
mobileUserService.getNotifications().then(notification => console.log(notification));

const user = new User({ id: 5, ... });
mobileUserService.getNotifications(user).then(notification => console.log(notification));

// Additionally, you can do the same thing using `User.getNotifications()`
const user = new User({ id: 5, ... });
user.getNotifications().then(notification => console.log(notification));

Test:

public async getProfile(user: Object, cacheMode: String): Promise<Profile> source

Get the profile of a user (or current user if null).

Params:

NameTypeAttributeDescription
user Object
  • optional

Parameters used to get information from server (such as id)

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<Profile>

Promise object that returns one User or a key:User hashtable

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { mobileUserService, User } from 'clinical6';

// You will be able to access these mobile users using the `getProfile` method.
mobileUserService.getProfile().then(users => console.log(users));

// Additionally, you can retrieve the profile for a specific mobile user with the `getProfile`
// method, using the ID of the desired mobile user as a parameter.
mobileUserService.getProfile(new User({id: 23})).then(users => console.log(users));

// using the default `type`
mobileUserService.getProfile({id: 23}).then(users => console.log(users));

Test:

public getProfileAttributes(includeHidden: Boolean, includeValues: Boolean): Promise source

this method was deprecated.

Gets all the custom attributes for the profile along with its values. This is here for ordering and labeling profile attributes.

Params:

NameTypeAttributeDescription
includeHidden Boolean
  • optional
  • default: false

Optional parameter which determines whether the response should include the hidden attributes (Encrypted Data).

includeValues Boolean
  • optional
  • default: false

Optional parameter which determiens whether the response should include the existing values of each attribute.

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token

Decorators:

  • deprecate

Example:

Get Profile Attributes
import { userService } from 'clinical6';
userService.getProfileAttributes();
Success, both false
{
  "status": "ok",
  "content": [
    {
      "id": 2,
      "api_key": "dummy_774",
      "name": "dummy_773",
      "attribute_type": "list",
      "options": null,
      "created_at": "2016-10-07T00:54:37.000Z",
      "updated_at": "2016-10-07T00:54:37.000Z",
      "is_visible": true,
      "allow_multiple_values": null,
      "is_recurrent_capture": false
    },
    {
      "id": 3,
      "api_key": "dummy_776",
      "name": "dummy_775",
      "attribute_type": "list",
      "options": null,
      "created_at": "2016-10-07T00:54:37.000Z",
      "updated_at": "2016-10-07T00:54:37.000Z",
      "is_visible": true,
      "allow_multiple_values": null,
      "is_recurrent_capture": false
    },
    {
      "id": 4,
      "api_key": "dummy_778",
      "name": "dummy_777",
      "attribute_type": "list",
      "options": null,
      "created_at": "2016-10-07T00:54:37.000Z",
      "updated_at": "2016-10-07T00:54:37.000Z",
      "is_visible": true,
      "allow_multiple_values": null,
      "is_recurrent_capture": false
    }
  ],
  "total_pages": 1
}
Success, include_hidden true
{
  "status": "ok",
  "content": [
    {
      "id": 14,
      "api_key": "dummy_798",
      "name": "dummy_797",
      "attribute_type": "list",
      "options": null,
      "created_at": "2016-10-07T00:54:38.000Z",
      "updated_at": "2016-10-07T00:54:38.000Z",
      "is_visible": true,
      "allow_multiple_values": null,
      "is_recurrent_capture": false
    },
    {
      "id": 15,
      "api_key": "dummy_800",
      "name": "dummy_799",
      "attribute_type": "list",
      "options": null,
      "created_at": "2016-10-07T00:54:38.000Z",
      "updated_at": "2016-10-07T00:54:38.000Z",
      "is_visible": true,
      "allow_multiple_values": null,
      "is_recurrent_capture": false
    },
    {
      "id": 16,
      "api_key": "dummy_802",
      "name": "dummy_801",
      "attribute_type": "list",
      "options": null,
      "created_at": "2016-10-07T00:54:38.000Z",
      "updated_at": "2016-10-07T00:54:38.000Z",
      "is_visible": true,
      "allow_multiple_values": null,
      "is_recurrent_capture": false
    },
    {
      "id": 17,
      "api_key": "dummy_804",
      "name": "dummy_803",
      "attribute_type": "list",
      "options": null,
      "created_at": "2016-10-07T00:54:38.000Z",
      "updated_at": "2016-10-07T00:54:38.000Z",
      "is_visible": false,
      "allow_multiple_values": null,
      "is_recurrent_capture": false
    },
    {
      "id": 18,
      "api_key": "dummy_806",
      "name": "dummy_805",
      "attribute_type": "list",
      "options": null,
      "created_at": "2016-10-07T00:54:38.000Z",
      "updated_at": "2016-10-07T00:54:38.000Z",
      "is_visible": false,
      "allow_multiple_values": null,
      "is_recurrent_capture": false
    },
    {
      "id": 19,
      "api_key": "dummy_808",
      "name": "dummy_807",
      "attribute_type": "list",
      "options": null,
      "created_at": "2016-10-07T00:54:38.000Z",
      "updated_at": "2016-10-07T00:54:38.000Z",
      "is_visible": false,
      "allow_multiple_values": null,
      "is_recurrent_capture": false
    }
  ],
  "total_pages": 1
}

Test:

public async getRegistrationStatus(attributes: Object, meta: String): Promise<String> source

Returns the registration status of the user.

Params:

NameTypeAttributeDescription
attributes Object

The a mobile user or object

attributes.accountName String

Account name to login.

attributes.email String

Email to login.

meta String
  • optional

Meta data to be passed back

meta.passwordSet Boolean
  • optional

If the password is set

Return:

Promise<String>

A Promise with the status

Example:

import { mobileUserService } from 'clinical6';

mobileUserService.getRegistrationStatus({ account_name: 'asdf' });
mobileUserService.getRegistrationStatus({ email: 'asdf@asdf.com'});

Test:

public getRelatedMobileUsers(): Promise<{followed_users: User[], followers: User[]}> source

this method was deprecated.

Retrieves all the related mobile users.

Return:

Promise<{followed_users: User[], followers: User[]}>

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token

Decorators:

  • deprecate

Example:

Get Related Mobile Users
import { userService } from 'clinical6';
userService.getRelatedMobileUsers().then(related => {
 console.log('followed_users', related.followed_users);
 console.log('followers', related.followers);
});

Test:

public async getSchedules(user: Object, cacheMode: String): Promise<Schedule[]|Schedule> source

Get Schedules for a user based on an id.

Params:

NameTypeAttributeDescription
user Object
  • optional

User - if not defined, use logged in user

user.id Number
  • optional
  • nullable: false

User ID must exist

user.type String
  • optional
  • nullable: false

User type ('mobile_users' or 'users') must exist

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<Schedule[]|Schedule>

Promise object that returns a schedule or list of schedules

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { userService } from 'clinical6';
userService.getSchedules(); // current user
userService.getSchedules({ id: 24, type: 'mobile_users' }); // user with id 24

Test:

public async getSession(token: String, cacheMode: String): Promise source

Get the session of the logged in user.

Params:

NameTypeAttributeDescription
token String
  • optional

Access token

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If token is not a string

Example:

import { mobileUserService } from 'clinical6';
mobileUserService.getSession();

Test:

public async getSites(user: Object, cacheMode: String): Promise<Site[]|Site> source

Get User Sites

Params:

NameTypeAttributeDescription
user Object
  • optional
  • nullable: false

The user, must have id and type

user.id Number
  • optional
  • nullable: false

The user id

user.type String
  • optional
  • nullable: false

User type ('mobile_users' or 'users') must exist

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<Site[]|Site>

Promise object that returns one object or hashmap

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { mobileUserService, User } from 'clinical6';

// You can get entries using the `getSites` method
mobileUserService.getSites({ id: 5, type: 'mobile_users' }).then(sites => console.log(sites));

mobileUserService.getSites({ id: 5, type: 'mobile_users' }, filter).then(sites => console.log(sites));

// Additionally, you can do the same thing using `User.getSites()`
const user = new User({ id: 5, type: 'mobile_user', ... });
user.getSites().then(sites => console.log(sites));
user.getSites(filter).then(sites => console.log(sites));

Test:

public async insert(user: User, cacheMode: String): Promise<User> source

Call a POST request on the main obj.type expecting JSON API information.

Override:

JsonApiService#insert

Params:

NameTypeAttributeDescription
user User

User object in which to insert

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<User>

Inserted user

Example:

import { User, mobileUserService } from 'clinical6';
const user = new User({...});

// you can insert a user using the `insert` method.
mobileUserService.insert(mobileUser).then(user => console.log(user));

// you could also just call `save` on the user if it doesn't have an id, which will also
// invoke the `insert` method
user.save();

Test:

public async insertProfileAttribute(key: String, val: String | Number): Promise source

this method was deprecated.

Inserts a new value for the given profile attribute.

Params:

NameTypeAttributeDescription
key String

The key value for the profile.

val String | Number

The value of the attribute.

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Decorators:

  • deprecate

Example:

Create Profile Attribute
import { userService } from 'clinical6';
userService.insertProfileAttribute('make', 'Toyota');
Success Response
{
  "status": "ok",
  "id": 6,
  "content": {
    "id": 6,
    "value": "new_value",
    "profile_attribute_id": 23,
    "profile_id": 150,
    "created_at": "2016-10-07T00:54:38.460Z",
    "updated_at": "2016-10-07T00:54:38.460Z",
    "recurrent_capture_id": null,
    "recurrent_capture_type": null
  }
}
Failure, Exists
{
  "error_detail": "This attribute has an existing value, use update method to overwrite it'",
  "friendly_error": null,
  "internal_code": 50367,
  "more_info": "",
  "status": "fail",
  "message": null
}

Test:

public async invite(user: User, attributes: Object, relationships: Object): Promise<User> source

Invite a user.

Params:

NameTypeAttributeDescription
user User

The user in which to invite (required)

user.email String
  • nullable: false

The email address of the invited user. (required)

user.profile Profile

The user's profile that contains information like first name, last name, and phone

user.role String
  • optional

The user's role

attributes Object
  • optional

A list of optional attributes not found in user or profile. This can contain any key/value.

attributes.invitation_token String
  • optional

The token used for accepting an invitation

attributes.password String
  • optional

A password chosen for the user

attributes.relationship String
  • optional

A relationship of the user to patient ('father', 'mother', 'uncle', 'aunt', etc)

relationships Object
  • optional

A list of optional relationships not found in user or profile. This can contain any key/value.

relationships.site Site
  • optional

The user's site

relationships.user_role Role
  • optional

The user's role (especially used if not defined in the user object)

relationships.language Language
  • optional

The user's language (especially used if not defined in the user profile)

Return:

Promise<User>

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

Invite Simple
import { userService, User } from 'clinical6';
const user = new User({ email: 'john.brown@parallel6.com' });
user.profile.firstName = 'John';
user.profile.lastName = 'Brown';
userService.invite(user);
Invite With Site, Role, Language, Token and Password
import { userService, Site, Role, Language, User } from 'clinical6';
const user = new User({ email: 'john.brown@parallel6.com' });
user.profile.firstName = 'John';
user.profile.lastName = 'Brown';
userService.invite(user, {
 invitation_token: 'asdf12124',
 password: 'mypassword@1'
}, {
 followed: new User({ id: 283 }),
 language: new Language({ id: 43 }),
 site: new Site({ id: 5 }),
 user_role: new Role({ id: 23 })
});

Test:

public async register(attributes: Object, device: Device): Promise<User> source

Register a device for guest, a username, or email

Params:

NameTypeAttributeDescription
attributes Object

User object in which to insert

attributes.guest String
  • optional

Guest must be true or false (null)

attributes.account_name String
  • optional

Either use account name or email

attributes.email String
  • optional

Either use account name or email

attributes.password String
  • optional

Password must exist if guest is false

device Device
  • optional

Device with id to register

Return:

Promise<User>

Registered Mobile User

Example:

import { mobileUserService } from 'clinical6';
const user = new User({...});

// you can register a guest using the `register` method.
mobileUserService.register({ guest: true }, device)
 .then(user => console.log(user));

// Register using an account name
mobileUserService.register({ account_name: 'abc', password: 'asdf' }, device)
 .then(user => console.log(user));

// Register using an email address
mobileUserService.register({ email: 'test@test.com', password: 'asdf' }, device)
 .then(user => console.log(user));

Test:

public async removeAwardedBadge(awardedBadge: Object, cacheMode: String): Promise<AwardedBadge> source

Remove Awarded Badge

Params:

NameTypeAttributeDescription
awardedBadge Object
  • nullable: false

The mobile user, must have id

awardedBadge.attributes Object
  • nullable: false

Hashmap to add for award badge

awardedBadge.user User
  • nullable: false

The mobile user, must have id

awardedBadge.user.id Number
  • nullable: false

The mobile user id

awardedBadge.badge Badge
  • nullable: false

The mobile user, must have id

awardedBadge.badge.id Number
  • nullable: false

The mobile user id

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<AwardedBadge>

Promise object that returns one object or hashmap

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { userService, AwardedBadge, Badge, User } from 'clinical6';
const data = new AwardedBadge({ updatedAt: '2018-06-02' });
data.awardee = new User({ id: 5, ... });
data.badge = new Badge({ id: 5, ... });

// You can add an awarded badge using the `removeAwardedBadge` method
userService.removeAwardedBadge(data).then(data => console.log(data));

// Additionally, you can do the same thing using `User.removeAwardedBadge()`
user.removeAwardedBadge(badge).then(data => console.log(data));

Test:

public async requestPasswordReset(attributes: Object): Promise source

Starts the reset password process and sends an email to the user with instructions.

Params:

NameTypeAttributeDescription
attributes Object

The authorization object

attributes.account_name String

Account name to login.

attributes.email String

Email to login.

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing required parameters

Example:

Mobile User
import { mobileUserService } from 'clinical6';
mobileUserService.requestPasswordReset({ email: 'test@test.com' });
mobileUserService.requestPasswordReset({ account_name: 'jsmith' });
User
import { userService } from 'clinical6';
userService.requestPasswordReset({ email: 'test@test.com' });

Test:

public resendInvite(id: Number, options: any): Promise source

this method was deprecated.

Resends an invite to a related mobile user.

Params:

NameTypeAttributeDescription
id Number
  • nullable: false

The id of the related mobile user to resend the invite to.

options any
  • optional

Additional options submitted to the server

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Decorators:

  • deprecate

Example:

Resend Invite
import { userService } from 'clinical6';
userService.resendInvite(23);
Resend Invite
import { userService } from 'clinical6';
userService.resendInvite(23, {});

Test:

public async resetPassword(attributes: Object, device: Device): Promise<User> source

Allows users to complete the Password reset flow.

Params:

NameTypeAttributeDescription
attributes Object

The authorization object

attributes.reset_password_token String
  • nullable: false

Token from request password reset email

attributes.password String
  • nullable: false

New password to reset to.

attributes.email String
  • optional

Email to login.

device Device
  • optional

Reset with this device (Default to saved device).

device.id Number
  • nullable: false

Reset with this device (Default to saved device).

Return:

Promise<User>

Promise object that returns the user if successful

Throw:

Clinical6Error

If missing required parameters

Example:

import { mobileUserService } from 'clinical6';
mobileUserService.resetPassword({ reset_password_token: 'a820348103828f8as0d8f', password: 'password1234'});

Test:

public resetPasswordSimple(newPassword: String, newPasswordConf: String, oldPassword: String): Promise source

this method was deprecated.

Sends user's account name via email. This method does not require an access token.

Params:

NameTypeAttributeDescription
newPassword String
  • nullable: false

New password for the account.

newPasswordConf String
  • nullable: false

Confirmation of the new password.

oldPassword String
  • nullable: false

New password for the account.

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Decorators:

  • deprecate

Example:

Reset Password Simple
import { userService } from 'clinical6';
userService.resetPasswordSimple('test', 'test', 'test2');
Failure, Mismatched Passwords
{
  "error_detail": "Review the new_password and new_password_confirmation parameters",
  "friendly_error": "Password and confirmation do not match",
  "internal_code": 50362,
  "more_info": "",
  "status": "fail",
  "message": "Password and confirmation do not match"
}

Test:

public async revokeConsent(user: User, cacheMode: String): Promise source

This method revokes the consent for a user.

Params:

NameTypeAttributeDescription
user User

User object in which to revoke consent for

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise

Message

Throw:

Clinical6Error

If missing required parameters

Test:

public async saveProfile(param: Object, options: String): Promise<Profile> source

Update Profile

Params:

NameTypeAttributeDescription
param Object
  • nullable: false

The user or profile

options String
  • optional

Modify the nature of the call and response

options.cacheMode String
  • optional

Override the caching method for this call

options.meta Object
  • optional

Pass and retrieve through reference meta data

Return:

Promise<Profile>

Promise object that returns one object or hashmap

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { mobileUserService, Profile, User } from 'clinical6';

// You can update a profile using the `saveProfile` method

// Update profile using the Current User, `clinical6.user`
mobileUserService.saveProfile().then(profile => console.log(profile));

// Update profile using a User object
const user1 = new User({ ... }); // user must have a related profile, which it does by default
mobileUserService.saveProfile(user1).then(profile => console.log(profile));

// Update profile using a Profile object
const profile = new Profile({ ... }); // profile must have a related user
mobileUserService.saveProfile(profile).then(profile => console.log(profile));

// Update profile using a Profile object and apply meta data
const profile = new Profile({ ... }); // profile must have a related user
mobileUserService.saveProfile(profile, { meta: { something: 23 }}).then(profile => console.log(profile));

// Updating just one attribute on the logged in user
mobileUserService.saveProfile({
 profile: { zipCode: 51038 }
}).then(profile => console.log(profile));

// Updating just one attribute on a different user
const user2 = new User({ ... });
mobileUserService.saveProfile({
 profile: { zipCode: 51038 },
 user: user2
}).then(profile => console.log(profile));

// Additionally, you can do the same thing using `User.saveProfile()`
const user3 = new User({ ... }); // user must have a related profile, which it does by default
user3.saveProfile().then(profile => console.log(profile));

Test:

public async sendConfirmation(email: String): Promise source

Sends a confirmation email to an email address

Params:

NameTypeAttributeDescription
email String

Email address to send the reset password email to.

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing required parameters

Example:

import { mobileUserService } from 'clinical6';
mobileUserService.sendConfirmation('test@test.com');

Test:

public setPin(json: Object): Promise source

this method was deprecated.

Sets the pin value for an invited user. This method will set the initial value of a PIN. In some workflows it is also possible to specify account_name if it is pre-provisioned.

Params:

NameTypeAttributeDescription
json Object

The JSON value with the attributes to provide for set pin.

json.pin Number
  • nullable: false

The PIN

json.pin_confirmation Number
  • nullable: false

The PIN Confirmation

json.account_name String
  • optional

The Account Name

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Decorators:

  • deprecate

Example:

Set Pin
import { userService } from 'clinical6';
userService.setPin({
 pin: 123456,
 pin_confirmation: 123456
});
Set Pin with Account Name
import { userService } from 'clinical6';
userService.setPin({
 pin: 123456,
 pin_confirmation: 123456,
 account_name
});

Test:

public async signIn(attributes: Object, device: Device, cacheMode: String): Promise<Session> source

Sign in user with account name.

Params:

NameTypeAttributeDescription
attributes Object

The authorization object

attributes.account_name String

Account name to login.

attributes.email String

Email to login.

attributes.password String

Login with this password.

device Device
  • optional

Login with this device (Default to saved device).

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<Session>

Promise returning a session with a user and authenticationToken and logging in future calls

Throw:

Clinical6Error

If missing required parameters

Example:

import { mobileUserService } from 'clinical6';
mobileUserService.signIn({ account_name: 'jsmith', password: 'password1234'});
mobileUserService.signIn({ email: 'jsmith@gmail.com', password: 'password1234'});

Test:

public async signOut(): Promise source

Detaches the device from the mobile_user. If the current mobile_user is a guest, his information will be destroyed. After this method is executed the device won't have any access_token associated and won't be able to make other requests until it signs in. Destroys a user's session

This method does not require access token.

Return:

Promise

Promise object that returns success or failure

Test:

public signUp(username: String, password: String, profile: Object): Promise source

this method was deprecated.

Sign up a user with a user profile. The Client#device fields uuid, technology, version, and pushId are required to exist sign in to occur

In order to sign up for a new user account, profile information and credentials can be used to execute the signUp method:

Params:

NameTypeAttributeDescription
username String

The username associated with the user account

password String

The password for the user

profile Object

The user profile to register for the user

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing required parameters and device info

Decorators:

  • deprecate

Example:

Sign Up
import { UserService } from 'clinical6';

const userService = new UserService();
userService.signUp(username, pw, profile).then(function(data){
  // User is created and an authtotken is passed back
}, function(err){
  // error
});
Success Response
{
  "status": "ok",
  "auth_token": "93a46e8f956ea7be0cd6a087629e8550",
  "verification_status": "unverified",
  "encryption_key": "87206e2605a4bcfeb213e3c702c55190"
}

Test:

public async unlockUser(email: String, unlockToken: String): Promise source

Unlocks a user

Params:

NameTypeAttributeDescription
email String

Email address of the user to unlock.

unlockToken String

Unlock token to unlock the user.

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing required parameters

Example:

import { mobileUserService } from 'clinical6';
mobileUserService.unlockUser('test@test.com', 'fakeToken123');

Test:

public update(user: User, options: String): Promise<User> source

Call a PATCH request on the main obj.type expecting JSON API information.

Override:

JsonApiService#update

Params:

NameTypeAttributeDescription
user User

User object in which to update

options String
  • optional

Modify the nature of the call and response

options.cacheMode String
  • optional

Override the caching method for this call

options.meta Object
  • optional

Pass and retrieve through reference meta data

Return:

Promise<User>

Updated user

Example:

import { User, mobileUserService } from 'clinical6';
const user = new User({...});

// you can update a user using the `update` method.
mobileUserService.update(user).then(user => console.log(user));

// you could also just call `save` on the user if it has an id, which will also
// invoke the `update` method
user.save();

Test:

public async updateAwardedBadge(awardedBadge: Object, cacheMode: String): Promise<AwardedBadge> source

Update Awarded Badge

Params:

NameTypeAttributeDescription
awardedBadge Object
  • nullable: false

The mobile user, must have id

awardedBadge.attributes Object
  • nullable: false

Hashmap to add for award badge

awardedBadge.user User
  • nullable: false

The mobile user, must have id

awardedBadge.user.id Number
  • nullable: false

The mobile user id

awardedBadge.badge Badge
  • nullable: false

The mobile user, must have id

awardedBadge.badge.id Number
  • nullable: false

The mobile user id

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<AwardedBadge>

Promise object that returns one object or hashmap

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { userService, AwardedBadge, Badge, User } from 'clinical6';
const data = new AwardedBadge({ updatedAt: '2018-06-02' });
data.awardee = new User({ id: 5, ... });
data.badge = new Badge({ id: 5, ... });

// You can update an awarded badge using the `updateAwardedBadge` method
userService.updateAwardedBadge(data).then(awardedBadge => console.log(awardedBadge));

// Additionally, you can do the same thing using `User.updateAwardedBadge()`
user.updateAwardedBadge(data).then(awardedBadge => console.log(awardedBadge));

Test:

public async updateProfileAttribute(profile: Object, id: Number): Promise source

this method was deprecated.

Updates the profile information for the current, authenticated user.

Params:

NameTypeAttributeDescription
profile Object

Profile object that is used to update an existing profile.

id Number

The profile ID value of the profile to update.

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Decorators:

  • deprecate

Example:

Update Profile Attribute
import { userService } from 'clinical6';
userService.updateProfileAttribute({
 "email": "test@test.com"
}, 23);
Success Response
{
  "status": "ok",
  "id": 2,
  "content": {
    "id": 2,
    "value": "new_value",
    "profile_attribute_id": 20,
    "profile_id": 146,
    "created_at": "2016-10-07T00:54:38.000Z",
    "updated_at": "2016-10-07T00:54:38.175Z",
    "recurrent_capture_id": null,
    "recurrent_capture_type": null
  }
}
Failure, Not Found
{
  "error_detail": {
    "ProfileValue": [
      "not_found"
    ]
  },
  "friendly_error": "Profile value not found using the value:-1",
  "internal_code": 50364,
  "more_info": "",
  "status": "fail",
  "message": "Profile value not found using the value:-1"
}

Test:

public async updateSchedule(schedule: Object, cacheMode: String): Promise<Schedule> source

Update Schedule

Params:

NameTypeAttributeDescription
schedule Object
  • nullable: false

The mobile user, must have id

schedule.attributes Object
  • nullable: false

Hashmap to add for a schedule

schedule.mobileUser User
  • optional
  • nullable: false

The mobile user, must have id

schedule.mobileUser.id Number
  • optional
  • nullable: false

The mobile user id

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<Schedule>

Promise object that returns one object or hashmap

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { userService, Schedule } from 'clinical6';
const data = new Schedule({ updatedAt: '2018-06-02' });

// You can update a schedule using the `updateSchedule` method
userService.updateSchedule(data).then(schedule => console.log(schedule));

// Additionally, you can do the same thing using `User.updateSchedule()`
user.updateSchedule(data).then(schedule => console.log(schedule));

Test:

Private Methods

private _loginGetSession(response: Session | User, device: Device): Session source

Get and Login Session From Response

Params:

NameTypeAttributeDescription
response Session | User

Session or User object from server with authentication token and user information

device Device

Mobile user's device

Return:

Session

Current logged in session

private _loginGetUser(response: Session | User, device: Device): User source

Get and Login User From Response

Params:

NameTypeAttributeDescription
response Session | User

Session or User object from server with authentication token and user information

device Device

Mobile user's device

Return:

User

Current logged in user