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

FlowService

Extends:

AbstractServiceJsonApiService → FlowService

Service handling Flow process calls with specific endpoints.

The Clinical6 server can create flows or multi page forms that enable the colleciton of data. The SDK allows you to retrieve the information stored about each flow process so that it can be integrated into the app.

Constructor Summary

Public Constructor
public

Update type to be data_collection__captured_value_groups

Member Summary

Public Members
public

Method Summary

Public Methods
public

collect(flow: Flow, options: Object): Promise

Collects data from the flow process via a id.

public

collectFields(flow: Flow, fields: Object[]): Promise

Collects data outside the flow process.

public

async deleteKeyValue(keyValue: Object, cacheMode: String): Promise<any>

Delete (soft delete / hide) a flow process value resource given an id

public

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

public

Get Flow Data Group based on an id.

public

getFlow(permanentLink: String, page: Number, perPage: Number): Promise<Flow>

Gets the flow process from a id.

public

Gets input data for a flow.

public

Gets the input data for a specific input id.

public

Call a GET request expecting JSON API information.

public

insert(flow: Object, cacheMode: String): Promise<Flow>

public

insertKeyValue(keyValue: FlowKeyValue, cacheMode: String): Promise<FlowKeyValue

Inserts the process values to start a flow data group / captured value group.

public

transition(flow: Flow, transition: String, options: Object): Promise

Transitions flow from one status to another.

public

update(flow: Object, cacheMode: String): Promise<Flow>

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 data_collection__captured_value_groups

Override:

JsonApiService#constructor

Public Members

public type: String source

Override:

AbstractService#type

Public Methods

public collect(flow: Flow, options: Object): Promise source

Collects data from the flow process via a id.

Should really use the Flow methods instead that call this method.

Params:

NameTypeAttributeDescription
flow Flow
  • nullable: false

Flow process to which collect from

flow.id String
  • nullable: false

The permanent link for the requested flow process.

flow.fields Object[]
  • nullable: true

Collected data from users

options Object
  • optional
  • nullable: true

Various options to change the way data is saved.

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { flowService } from 'clinical6';
flowService.getFlow('favorite_flow').then(flow => {
 flowService.collect(flow);  // not the best way to do this.
 flow.collect();  // this is the way to do this
});

Test:

public collectFields(flow: Flow, fields: Object[]): Promise source

Collects data outside the flow process. This is used for per step saves.

Should really use the Flow methods instead that call this method.

Params:

NameTypeAttributeDescription
flow Flow
  • nullable: false

Flow process to which collect from

flow.id String
  • nullable: false

The permanent link for the requested flow process.

fields Object[]
  • nullable: false

Collected data from users

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

public async deleteKeyValue(keyValue: Object, cacheMode: String): Promise<any> source

Delete (soft delete / hide) a flow process value resource given an id

http://clinical6-docs.s3-website-us-east-1.amazonaws.com/apidoc/v3data_collectionflow_process_values/destroy.html

Params:

NameTypeAttributeDescription
keyValue Object
  • nullable: false

The process value object used to save information

keyValue.id Number
  • nullable: false

The flow id, must be a number

cacheMode String
  • optional
  • nullable: true

A string to indicate how this is cached.

Return:

Promise<any>

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { FlowKeyValue, flowService } from 'clinical6';

const v = new FlowKeyValue({ id: 5 });
const response = await flowService.deleteKeyValue(v);
import { flowService } from 'clinical6';

const response = await flowService.deleteKeyValue({ id: 5 });

Test:

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

params.id Number
  • optional

Id of the flow

params.permanentLink Number
  • optional

permanentLink of the flow

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<Flow[]|Flow>

Promise object that returns one flow or an array

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { flowService } from 'clinical6';

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

// Additionally, you can retrieve a specific flow with the `get` method, using the permanent link of the desired flow
// as a parameter.
flowService.get({ permanentLink: 'favorite_flow' }).then(flow => console.log(flow));

Test:

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

Get Flow Data Group based on an id.

Params:

NameTypeAttributeDescription
params Object
  • nullable: false

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

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

Decorators:

  • deprecate

Example:

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

Test:

public getFlow(permanentLink: String, page: Number, perPage: Number): Promise<Flow> source

Gets the flow process from a id.

The best way to pull back a flow process is by using the id or resource provided by the server. To get a collection of Flows or Sections which may contain Flows is using the StatusService#getSections method. This will automatically call the Section#connectChildren method if it has children which calls the Section#getData method calling this method (FlowService#getFlow).

Params:

NameTypeAttributeDescription
permanentLink String
  • nullable: false

The permanent link for the requested flow process.

page Number
  • optional
  • default: 1
  • nullable: true

The page number of the results given.

perPage Number
  • optional
  • default: 0
  • nullable: true

The number of content to return per page.

Return:

Promise<Flow>

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { flowService } from 'clinical6';
flowService.getFlow('favorite_flow');

Test:

public getInputDataByFlow(flow: Flow): Promise source

Gets input data for a flow.

Should really use the Flow methods instead that call this method.

Params:

NameTypeAttributeDescription
flow Flow
  • nullable: false

Flow process from which data comes

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { flowService } from 'clinical6';
flowService.getFlow('favorite_flow').then(flow => {
 flowService.getInputDataByFlow(flow);
});

public getInputDataById(inputId: String): Promise source

Gets the input data for a specific input id.

Should really use the Flow methods instead that call this method.

Params:

NameTypeAttributeDescription
inputId String
  • nullable: false

Flow Input ID of the input from which data comes

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

public getKeyValue(params: Object, cacheMode: String): Promise<FlowKeyValue[]|FlowKeyValue> source

Call a GET request expecting JSON API information.

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<FlowKeyValue[]|FlowKeyValue>

Promise object that returns one keyValue or a keyValue array

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { flowService } from 'clinical6';

// You will be able to access these keyValues using the `getKeyValue` method.
flowService.getKeyValue().then(keyValues => console.log(keyValues));

// Additionally, you can retrieve a specific keyValue with the `getKeyValue`
// method, using the ID of the desired keyValue as a parameter.
flowService.getKeyValue({id: 23}).then(keyValue => console.log(keyValue));

Test:

public insert(flow: Object, cacheMode: String): Promise<Flow> source

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

Override:

JsonApiService#insert

Params:

NameTypeAttributeDescription
flow Object
  • optional

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

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<Flow>

Inserted flow

Example:

import { Flow, flowService } from 'clinical6';
const flow = new Flow({...});

// you can insert a flow using the `insert` method.
flowService.insert(flow).then(flow => console.log(flow));

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

Test:

public insertKeyValue(keyValue: FlowKeyValue, cacheMode: String): Promise<FlowKeyValue source

Inserts the process values to start a flow data group / captured value group. This is how a flow starts and generates a captured value group id. If the group id already exists, this should also save it (though this is going to change)

http://clinical6-docs.s3-website-us-east-1.amazonaws.com/apidoc/v3data_collectionflow_process_values/create.html

Params:

NameTypeAttributeDescription
keyValue FlowKeyValue
  • nullable: false

The process value object used to save information

keyValue.flow Flow
  • nullable: false

The flow being started

keyValue.flow.id Number
  • nullable: false

The flow id, must be a number

keyValue.flow.entry Entry
  • optional
  • nullable: true

The flow entry

keyValue.flow.entry.id Number
  • nullable: false

The flow entry id, must be a number

keyValue.owner Object
  • nullable: false

The owner of the data being collected

keyValue.owner.type String
  • nullable: false

The owner type, defaults to current logged in user type ('mobile_users' or 'users')

keyValue.owner.id String
  • nullable: false

The owner id, defaults to current logged in user's id

keyValue.flowDataGroup Object
  • optional
  • nullable: false

The flow data group (captured value group)

keyValue.flowDataGroup.id Number
  • nullable: false

The flow data group id (captured value group id)

cacheMode String
  • optional
  • nullable: true

A string to indicate how this is cached.

Return:

Promise<FlowKeyValue

Promise object that returns the resulting flow process value (with flow data group id / captured value group id)

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { Flow, FlowDataGroup, FlowKeyValue, flowService } from 'clinical6';

const v = new FlowKeyValue(requestJsonApi);
v.flow = new Flow({ id: 94 });
v.flow.store();
v.owner = new User({ id: 59 });
v.owner.store();
v.flowDataGroup = new FlowDataGroup({ id: 23 });
v.flowDataGroup.store();
v['56'] = 'male';
v['57'] = 15;
const response = await flowService.insertKeyValue(v);

Test:

public transition(flow: Flow, transition: String, options: Object): Promise source

Transitions flow from one status to another.

Should really use the Flow methods instead that call this method, such as Flow#transition, Flow#start or Flow#complete. Additionally, some of the FlowStep transition methods will trigger this as well.

Params:

NameTypeAttributeDescription
flow Flow
  • nullable: false

Flow process to which collect from

flow.id String
  • nullable: false

The permanent link for the requested flow process.

transition String
  • nullable: false

the action to be applied to transition the flow

options Object
  • optional
  • nullable: true

Various options to change the way the transition occurs

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { flowService } from 'clinical6';
flowService.getFlow('favorite_flow').then(flow => {
 flowService.transition(flow, 'accept');
});

public update(flow: Object, cacheMode: String): Promise<Flow> source

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

Override:

JsonApiService#update

Params:

NameTypeAttributeDescription
flow Object
  • optional

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

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<Flow>

Inserted flow

Example:

import { Flow, flowService } from 'clinical6';
const flow = new Flow({...});

// you can insert a flow using the `insert` method.
flowService.insert(flow).then(flow => console.log(flow));

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

Test: