Constructor Summary
Public Constructor | ||
public |
constructor(json: Object) Constructor for helper class representing a User |
Member Summary
Public Members | ||
public get |
|
|
public set |
|
|
public get |
|
|
public set |
|
|
public get |
|
|
public set |
|
|
public set |
|
|
public get |
|
|
public get |
relationships: any |
|
public get |
|
|
public set |
|
|
public get |
|
|
public set |
|
|
public set |
|
|
public get |
|
|
public get |
|
|
public set |
|
Private Members | ||
private |
_cohortAssignments: *[] |
|
private |
_type: * |
Method Summary
Public Methods | ||
public |
async addBadge(badge: Badge, cacheMode: String): Promise<AwardedBadge[]|AwardedBadge> Add Badge |
|
public |
Add eDiary Entry |
|
public |
async addSchedule(schedule: Object): Promise<Schedule> Add Schedule |
|
public |
Removes a related user. |
|
public |
Disables a related user. |
|
public |
Enable a related user. |
|
public |
async getAvailableStrategies(options: String): Promise Gets the consent available strategies associated to this user. |
|
public |
async getAwardedBadges(awardedBadge: Object, cacheMode: String): Promise<AwardedBadge[]|AwardedBadge> Get Awarded Badges |
|
public |
async getCohortAssignments(params: Object, options: String): Promise Gets the cohort assignment associated to this user. |
|
public |
async getCohorts(): Promise<Cohort[]> Gets the list of cohorts after calling this.getCohortAssignments() |
|
public |
async getConsentGrants(options: String): Promise Gets the consent grants associated to this user. |
|
public |
async getDataGroup(dataGroup: Object, cacheMode: String): Promise<FlowDataGroup> Get Flow Data Group for a user based on an id. |
|
public |
Get eDiary entries |
|
public |
async getNotifications(): Promise<Notification[]> Get user notifications |
|
public |
async getProfile(): Promise<Profile> Retrieve a related user profile. |
|
public |
async getRegistrationStatus(): Promise<String> Returns the registration status of the user. |
|
public |
async getSchedules(cacheMode: String): Promise<Schedule[]> Get Schedules |
|
public |
Sends an invitation to this user |
|
public |
Indicates if the password is set |
|
public |
async removeAwardedBadge(awardedBadge: Badge, cacheMode: String): Promise<Any> Add Badge |
|
public |
async requestPasswordReset(): Promise Starts the reset password process and sends an email to the user with instructions. |
|
public |
async resendInvite(options: any): Promise Resends an invite to a related user. |
|
public |
Resets the password given a token and password (and email if user has one). |
|
public |
async revokeConsent(cacheMode: String): Promise Revokes consent for the user |
|
public |
Saves a user (insert if id doesn't exist, update if it does) |
|
public |
async saveProfile(): Promise<Profile> Saves a user's profile (insert if id doesn't exist, update if it does) |
|
public |
async sendConfirmation(): Promise Sends a confirmation email to an email address |
|
public |
toInvitation(attributes: Object, relationships: Object): Invitation Converts the user into an invitation used for sending or accepting an invitation. |
|
public |
async unlockUser(unlockToken: String): Promise Unlocks the user |
Inherited Summary
From class UserModel | ||
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
Public Constructors
public constructor(json: Object) source
Constructor for helper class representing a User
Override:
UserModel#constructorParams:
Name | Type | Attribute | Description |
json | Object | json api response from server |
Public Members
public get cohortAssignments: CohortAssignment[] source
public set cohortAssignments: CohortAssignment[] source
public get relationships: any source
public get siteMember: SiteMember source
public set siteMember: SiteMember source
Private Members
private _cohortAssignments: *[] source
private _type: * source
Public Methods
public async addBadge(badge: Badge, cacheMode: String): Promise<AwardedBadge[]|AwardedBadge> source
Add Badge
Throw:
If missing token or missing required parameters |
Example:
import { Badge, User } from 'clinical6';
const user = new User({ id: 15 });
const badge = new Badge({ id: 5 });
// You will be able to add a badge using the `addBadge` method.
// It returns the "AwardedBadge" relationship
user.addBadge(badge).then(ab => console.log(ab));
public async addEntry(entry: Entry, template: EntryTemplate): Promise<Entry[]|Entry> source
Add eDiary Entry
Params:
Name | Type | Attribute | Description |
entry | Entry |
|
Hashmap to save for entry |
template | EntryTemplate |
|
The entry template, must have id |
Throw:
If missing token or missing required parameters |
Example:
import { userService, User, Entry } from 'clinical6';
const user = new User({ id: 5, ... });
const entry = new Entry({ date: '2018-06-02' });
// You can add an entry using the `addEntry` method
user.addEntry(entry).then(entry => console.log(entry));
public async addSchedule(schedule: Object): Promise<Schedule> source
Add Schedule
Params:
Name | Type | Attribute | Description |
schedule | Object |
|
The user, must have id |
schedule.attributes | Object |
|
Hashmap to add for schedule |
schedule.mobileUser | User |
|
The user, must have id |
schedule.mobileUser.id | Number |
|
The user id |
Throw:
If missing token or missing required parameters |
Example:
import { Schedule, User } from 'clinical6';
const schedule = new Schedule({ updatedAt: '2018-06-02' });
// You can add a schedule using the `addSchedule` method
user.addSchedule(schedule).then(result => console.log(result));
public async delete(): Promise source
Removes a related user.
Example:
client.getRelatedUsers().then(users => {
users[0].delete();
});
public async disable(): Promise source
Disables a related user.
Example:
client.getRelatedUsers().then(users => {
users[0].disable();
});
public async enable(): Promise source
Enable a related user.
Example:
client.getRelatedUsers().then(users => {
users[0].enable();
});
public async getAvailableStrategies(options: String): Promise source
Gets the consent available strategies associated to this user.
Example:
import { User, clinical6 } from 'clinical6';
const user = new User({ id: 23 });
user.getAvailableStrategies();
// Combined with clinical6.get
clinical6.get(User).then(users => { users[0].getAvailableStrategies() });
public async getAwardedBadges(awardedBadge: Object, cacheMode: String): Promise<AwardedBadge[]|AwardedBadge> source
Get Awarded Badges
Throw:
If missing token or missing required parameters |
Example:
import { User } from 'clinical6';
const user = new User({ id: 15 });
// You will be able to access these awardedBadges using the `getAwardedBadges` method.
user.getAwardedBadges().then(awardedBadges => console.log(awardedBadges));
// Get one AwardedBadge
user.getAwardedBadges({ id: 7 }).then(awardedBadges => console.log(awardedBadges));
public async getCohortAssignments(params: Object, options: String): Promise source
Gets the cohort assignment associated to this user.
Params:
Name | Type | Attribute | Description |
params | Object |
|
Parameters used to get information from server |
params.id | Number |
|
Id to get data from the server |
params.type | String |
|
Type to be used for storage |
params.filters | Object |
|
Filters to be used for get |
options | String |
|
Modify the nature of the call and response |
options.url | String |
|
Override the url for this call |
options.cacheMode | String |
|
Override the caching method for this call |
Example:
import { User, clinical6 } from 'clinical6';
const user = new User({ id: 23 });
user.getCohortAssignments({ id: 5 });
// Combined with clinical6.get
clinical6.get(User).then(users => { users[0].getCohortAssignments() });
public async getCohorts(): Promise<Cohort[]> source
Gets the list of cohorts after calling this.getCohortAssignments()
Example:
import { clinical6, Cohort } from 'clinical6';
const users = await clinical6.get(User);
const cohorts = await users[0].getCohorts();
console.log(cohorts);
public async getConsentGrants(options: String): Promise source
Gets the consent grants associated to this user.
Example:
import { User, clinical6 } from 'clinical6';
const user = new User({ id: 23 });
user.getConsentGrants({ id: 5 });
// Combined with clinical6.get
clinical6.get(User).then(users => { users[0].getConsentGrants() });
public async getDataGroup(dataGroup: Object, cacheMode: String): Promise<FlowDataGroup> source
Get Flow Data Group for a user based on an id.
Throw:
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);
public async getEntries(filter: Object, cacheMode: String): Promise<Entry[]|Entry> source
Get eDiary entries
Throw:
If missing token or missing required parameters |
Example:
import { User } from 'clinical6';
const user = new User({ id: 15 });
// You will be able to access these entry groups using the `get` method.
user.getEntries().then(entry => console.log(entry));
const filters = { entry_group_id: 7, date: '2018-06-02'};
user.getEntries(filter).then(entry => console.log(entry));
public async getNotifications(): Promise<Notification[]> source
Get user notifications
Throw:
If missing token or missing required parameters |
Example:
import { User } from 'clinical6';
const user = new User({ id: 15 });
// You will be able to access these notifications using the `get` method.
user.getNotifications().then(notifications => console.log(notifications));
public async getProfile(): Promise<Profile> source
Retrieve a related user profile.
Example:
client.getRelatedUsers().then(users => {
users[0].getProfile().then(profile => console.log(profile));;
});
public async getRegistrationStatus(): Promise<String> source
Returns the registration status of the user.
Example:
import { User } from "clinical6";
const user = new User({...});
user.getRegistrationStatus().then(status => console.log(status));
public async getSchedules(cacheMode: String): Promise<Schedule[]> source
Get Schedules
Params:
Name | Type | Attribute | Description |
cacheMode | String |
|
Override the caching method for this call |
Throw:
If missing token or missing required parameters |
Example:
import { User } from 'clinical6';
const user = new User({ id: 15 });
// You will be able to access these schedules using the `getSchedules` method.
user.getSchedules().then(schedules => console.log(schedules));
public async invite(attributes: Object, relationships: Object): Promise<User> source
Sends an invitation to this user
Params:
Name | Type | Attribute | Description |
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 |
attributes.password | String |
|
A password chosen for the user |
attributes.relationship | String |
|
A relationship of the user to patient ('father', 'mother', 'uncle', 'aunt', etc) |
relationships | Object |
|
A list of optional relationships not found in user or profile. This can contain any key/value. |
relationships.site | Site |
|
The user's site |
relationships.user_role | Role |
|
The user's role (especially used if not defined in the user object) |
relationships.language | Language |
|
The user's language (especially used if not defined in the user profile) |
Example:
import { User } from "clinical6";
const user = new User({...});
user.invite();
public isPasswordSet(): boolean source
Indicates if the password is set
Example:
import { User } from "clinical6";
const user = new User({...});
user.getRegistrationStatus().then(() => {
user.isPasswordSet; // true or false
});
public async removeAwardedBadge(awardedBadge: Badge, cacheMode: String): Promise<Any> source
Add Badge
Throw:
If missing token or missing required parameters |
Example:
import { AwardedBadge, User } from 'clinical6';
const user = new User({ id: 15 });
const awardedBadge = new AwardedBadge({ id: 5 });
// You will be able to add a badge using the `addBadge` method.
// It returns the "AwardedBadge" relationship
user.removeAwardedBadge(awardedBadge).then(data => console.log(data));
public async requestPasswordReset(): Promise source
Starts the reset password process and sends an email to the user with instructions.
Example:
import { User } from 'clinical6';
const user = new User({...});
user.requestPasswordReset();
public async resendInvite(options: any): Promise source
Resends an invite to a related user.
Params:
Name | Type | Attribute | Description |
options | any |
|
Additional options submitted to the server |
Decorators:
- deprecate
Example:
client.getRelatedUsers().then(users => {
users[0].resendInvite({});
});
public async resetPassword(token: String, password: String, device: Device): Promise<User> source
Resets the password given a token and password (and email if user has one).
Params:
Name | Type | Attribute | Description |
token | String |
|
Token from request password reset email |
password | String |
|
New password to reset to. |
device | Device |
|
Reset with this device (Default to saved device). |
device.id | Number |
|
Reset with this device (Default to saved device). |
Example:
import { User } from 'clinical6';
const user = new User({...});
user.resetPassword('adfasdfjkl', 'sekret_password!');
public async revokeConsent(cacheMode: String): Promise source
Revokes consent for the user
Params:
Name | Type | Attribute | Description |
cacheMode | String |
|
Override the caching method for this call |
public async save(): Promise<User> source
Saves a user (insert if id doesn't exist, update if it does)
Example:
import { User, userService } from 'clinical6';
// Inserts new user (no existing id)
const user = new User({
"type": "mobile_users",
"attributes": {
"udid": "this-is-a-udid-string",
"technology": "ios",
"access_token": "cd68fa04e458d6d1a9d29faec6a329d3",
"push_id": null,
"created_at": "2017-05-19T17:21:26.311Z",
"updated_at": "2017-05-19T17:21:26.311Z",
"app_version": null
}
});
user.save();
// Updates existing user (has existing id)
userService.get().then(users => users[0].save());
public async saveProfile(): Promise<Profile> source
Saves a user's profile (insert if id doesn't exist, update if it does)
Example:
import { User, userService } from 'clinical6';
const user = new User({...});
user.profile = new Profile({...});
user.profile.age = 25;
// Updates profile
user.saveProfile();
public async sendConfirmation(): Promise source
Sends a confirmation email to an email address
Example:
import { User } from 'clinical6';
const user = new User({...});
user.sendConfirmation();
public toInvitation(attributes: Object, relationships: Object): Invitation source
Converts the user into an invitation used for sending or accepting an invitation. We've documented some common examples, however any attribute or relationship key / value will be accepted as long as it's not shared between the two. An attribute cannot also be a relationship.
Params:
Name | Type | Attribute | Description |
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 |
attributes.password | String |
|
A password chosen for the user |
attributes.relationship | String |
|
A relationship of the user to patient ('father', 'mother', 'uncle', 'aunt', etc) |
relationships | Object |
|
A list of optional relationships not found in user or profile. This can contain any key/value. |
relationships.site | Site |
|
The user's site |
relationships.user_role | Role |
|
The user's role (especially used if not defined in the user object) |
relationships.language | Language |
|
The user's language (especially used if not defined in the user profile) |
Example:
import { User } from 'clinical6';
const user = new User({ email: 'john.brown@parallel6.com' });
user.profile.firstName = 'John';
user.profile.lastName = 'Brown';
const invitation = user.toInvitation();
console.log(invitation);
import { Site, Role, Language, User } from 'clinical6';
const user = new User({ email: 'john.brown@parallel6.com' });
user.profile.firstName = 'John';
user.profile.lastName = 'Brown';
const invitation = user.toInvitation({
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 })
});
console.log(invitation);