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

RuleService

Extends:

AbstractServiceJsonApiService → RuleService

Service handling Rule calls with specific endpoints.

Constructor Summary

Public Constructor
public

Update type to be rules

Member Summary

Public Members
public

Method Summary

Public Methods
public

async delete(rule: Rule, cacheMode: String): Promise

public

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

public
this method was deprecated. Returns all reminder events.
public
this method was deprecated. Returns all the vents for a given rule that occur on the supplied date. If the date is in the future, new events may be created depending on the rules and their schedule.
public
this method was deprecated. Returns all reminder events. Requires a rule ID to filter the events to return.
public
this method was deprecated. Returns the most recent events for all rules. This method requires a rule ID in order to filter the recent events by rules. Optionally, the time unit can be specified to filter the events to return.
public
this method was deprecated. Returns the next event for a given rule. If there is not a next event a 404 status will be returned.
public
this method was deprecated. Returns the most recent events for all rules. Optionally, the time unit can be specified to filter the events to return.
public

getUpcomingEvents(ruleId: String, timeUnit: String): Promise

this method was deprecated. Returns the events that will occur soon for the given rule ID. Optionally, the time unit can be specified to filter the events to return.
public

async insert(rule: Rule, cacheMode: String): Promise<Rule>

public

markEvent(ruleId: String, eventId: String, eventAction: String): Promise

this method was deprecated. Marks the event depending on the action given. The results can vary depending on the time this method is called. If an invalid action is given, it will be interpreted as 'ignored'. Event action is either 'completed' or 'ignored'. Passes parameters in URL.
public

markEventByObj(ruleId: String, eventChange: Object): Promise

this method was deprecated. Marks the event depending on the action given. The results can vary depending on the time this method is called. If an invalid action is given, it will be interpreted as 'ignored'. Event action is either 'completed' or 'ignored'. Events will be marked based off of the supplied eventChange object. The event ID and event action will be passed through the eventChange object and not by URL parameters.
public

async update(rule: Rule, cacheMode: String): Promise<Rule>

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 rules

Override:

JsonApiService#constructor

Public Members

public type: String source

Override:

AbstractService#type

Public Methods

public async delete(rule: Rule, cacheMode: String): Promise source

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

Override:

JsonApiService#delete

Params:

NameTypeAttributeDescription
rule Rule

Rule object in which to update

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise

Message

Example:

import { ruleService } from 'clinical6';

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

Test:

public async get(params: Object, cacheMode: String): Promise<Rule[]|Rule> 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<Rule[]|Rule>

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

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { ruleService } from 'clinical6';

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

// Additionally, you can retrieve the subcategories for a specific rule with the `get`
// method, using the ID of the desired rule as a parameter.
ruleService.get(23).then(rule => console.log(rule));

Test:

public getEvents(ruleId: String): Promise source

this method was deprecated. Returns all reminder events.

Params:

NameTypeAttributeDescription
ruleId String

The rule ID to check for events. (optional)

Return:

Promise

Promise object that returns success or failure

Decorators:

  • deprecate

public getEventsByDate(ruleId: String, date: String): Promise source

this method was deprecated. Returns all the vents for a given rule that occur on the supplied date. If the date is in the future, new events may be created depending on the rules and their schedule.

Params:

NameTypeAttributeDescription
ruleId String

The rule ID to check for events.

date String

The date that will be used to filter the events. Use ISO8601 format YYYY-MM-DD.

Return:

Promise

Promise object that returns success or failure

Decorators:

  • deprecate

Test:

public getEventsByRule(ruleId: String): Promise source

this method was deprecated. Returns all reminder events. Requires a rule ID to filter the events to return.

Params:

NameTypeAttributeDescription
ruleId String

The rule ID to check for events. (required)

Return:

Promise

Promise object that returns success or failure

Decorators:

  • deprecate

Test:

public getFilteredRecentEvents(ruleId: String, timeUnit: String): Promise source

this method was deprecated. Returns the most recent events for all rules. This method requires a rule ID in order to filter the recent events by rules. Optionally, the time unit can be specified to filter the events to return.

Params:

NameTypeAttributeDescription
ruleId String

The rule ID to filter the recent events (required)

timeUnit String

The time cap for recent events. Must be either 'week' or 'month' (optional)

Return:

Promise

Promise object that returns success or failure

Decorators:

  • deprecate

Test:

public getNextEvent(ruleId: String): Promise source

this method was deprecated. Returns the next event for a given rule. If there is not a next event a 404 status will be returned.

Params:

NameTypeAttributeDescription
ruleId String

The rule ID to check for the next event.

Return:

Promise

Promise object that returns success or failure

Decorators:

  • deprecate

public getRecentEvents(timeUnit: String): Promise source

this method was deprecated. Returns the most recent events for all rules. Optionally, the time unit can be specified to filter the events to return.

Params:

NameTypeAttributeDescription
timeUnit String

The time cap for recent events. Must be either 'week' or 'month' (optional)

Return:

Promise

Promise object that returns success or failure

Decorators:

  • deprecate

Test:

public getUpcomingEvents(ruleId: String, timeUnit: String): Promise source

this method was deprecated. Returns the events that will occur soon for the given rule ID. Optionally, the time unit can be specified to filter the events to return.

Params:

NameTypeAttributeDescription
ruleId String

The rule ID to check for upcoming events.

timeUnit String
  • optional

The time cap for recent events. Must be either 'week' or 'month' (optional)

Return:

Promise

Promise object that returns success or failure

Decorators:

  • deprecate

Test:

public async insert(rule: Rule, cacheMode: String): Promise<Rule> source

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

Override:

JsonApiService#insert

Params:

NameTypeAttributeDescription
rule Rule

Key from server

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<Rule>

Inserted rule

Example:

import { Rule, ruleService } from 'clinical6';
const rule = new Rule({...});

// you can insert a rule using the `insert` method.
ruleService.insert(mobileApplicationKey).then(rule => console.log(rule));

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

Test:

public markEvent(ruleId: String, eventId: String, eventAction: String): Promise source

this method was deprecated. Marks the event depending on the action given. The results can vary depending on the time this method is called. If an invalid action is given, it will be interpreted as 'ignored'. Event action is either 'completed' or 'ignored'. Passes parameters in URL.

Params:

NameTypeAttributeDescription
ruleId String

Permanent link of the rule of the event to update.

eventId String

ID value of the event to update.

eventAction String

The optional event action indicates the action to mark the event with. Event action must either be 'completed' or 'ignored'. If no value or an invalid value is provided, the event action will be interpreted as 'ignored'.

Return:

Promise

Promise object that returns success or failure

Decorators:

  • deprecate

Test:

public markEventByObj(ruleId: String, eventChange: Object): Promise source

this method was deprecated. Marks the event depending on the action given. The results can vary depending on the time this method is called. If an invalid action is given, it will be interpreted as 'ignored'. Event action is either 'completed' or 'ignored'. Events will be marked based off of the supplied eventChange object. The event ID and event action will be passed through the eventChange object and not by URL parameters.

Params:

NameTypeAttributeDescription
ruleId String

Permanent link of the rule of the event to update.

eventChange Object

Object with the changes to make for the event

eventChange.id Number

The ID of the event to mark. If no ID value is supplied no change will be made. (optional)

eventChange.event_action String

The optional event action indicates the action to mark the event with. Event action must either be 'completed' or 'ignored'. If no value or an invalid value is provided, the event action will be interpreted as 'ignored'.

Return:

Promise

Promise object that returns success or failure

Decorators:

  • deprecate

Test:

public async update(rule: Rule, cacheMode: String): Promise<Rule> source

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

Override:

JsonApiService#update

Params:

NameTypeAttributeDescription
rule Rule

Rule object in which to update

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<Rule>

Updated rule

Example:

import { Rule, ruleService } from 'clinical6';
const rule = new Rule({...});

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

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