FlowService
Extends:
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 |
Method Summary
Public Methods | ||
public |
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 |
|
|
public |
getDataGroup(params: Object, cacheMode: String): Promise<FlowDataGroup> Get Flow Data Group based on an id. |
|
public |
Gets the flow process from a id. |
|
public |
getInputDataByFlow(flow: Flow): Promise Gets input data for a flow. |
|
public |
getInputDataById(inputId: String): Promise Gets the input data for a specific input id. |
|
public |
getKeyValue(params: Object, cacheMode: String): Promise<FlowKeyValue[]|FlowKeyValue> Call a GET request expecting JSON API information. |
|
public |
|
|
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 |
|
Inherited Summary
From class AbstractService | ||
public get |
|
|
public set |
|
|
public |
|
|
private |
|
From class JsonApiService | ||
public |
options: * |
|
public |
Call a DELETE request on the main obj.type expecting JSON API information. |
|
public |
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 |
Call a POST request on the main obj.type expecting JSON API information. |
|
public |
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#constructorPublic Members
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:
Name | Type | Attribute | Description |
flow | Flow |
|
Flow process to which collect from |
flow.id | String |
|
The permanent link for the requested flow process. |
flow.fields | Object[] |
|
Collected data from users |
options | Object |
|
Various options to change the way data is saved. |
Throw:
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
});
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.
Throw:
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
Throw:
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 });
public get(params: Object, cacheMode: String): Promise<Flow[]|Flow> source
Call a GET request expecting JSON API information.
Override:
JsonApiService#getThrow:
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));
public getDataGroup(params: Object, cacheMode: String): Promise<FlowDataGroup> source
Get Flow Data Group based on an id.
Throw:
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);
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:
Name | Type | Attribute | Description |
permanentLink | String |
|
The permanent link for the requested flow process. |
page | Number |
|
The page number of the results given. |
perPage | Number |
|
The number of content to return per page. |
Throw:
If missing token or missing required parameters |
Example:
import { flowService } from 'clinical6';
flowService.getFlow('favorite_flow');
public getInputDataByFlow(flow: Flow): Promise source
Gets input data for a flow.
Should really use the Flow methods instead that call this method.
Params:
Name | Type | Attribute | Description |
flow | Flow |
|
Flow process from which data comes |
Throw:
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:
Name | Type | Attribute | Description |
inputId | String |
|
Flow Input ID of the input from which data comes |
Throw:
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.
Return:
Promise<FlowKeyValue[]|FlowKeyValue> | Promise object that returns one keyValue or a keyValue array |
Throw:
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));
public insert(flow: Object, cacheMode: String): Promise<Flow> source
Call a POST request on the main obj.type expecting JSON API information.
Override:
JsonApiService#insertExample:
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();
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)
Params:
Name | Type | Attribute | Description |
keyValue | FlowKeyValue |
|
The process value object used to save information |
keyValue.flow | Flow |
|
The flow being started |
keyValue.flow.id | Number |
|
The flow id, must be a number |
keyValue.flow.entry | Entry |
|
The flow entry |
keyValue.flow.entry.id | Number |
|
The flow entry id, must be a number |
keyValue.owner | Object |
|
The owner of the data being collected |
keyValue.owner.type | String |
|
The owner type, defaults to current logged in user type ('mobile_users' or 'users') |
keyValue.owner.id | String |
|
The owner id, defaults to current logged in user's id |
keyValue.flowDataGroup | Object |
|
The flow data group (captured value group) |
keyValue.flowDataGroup.id | Number |
|
The flow data group id (captured value group id) |
cacheMode | String |
|
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:
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);
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:
Name | Type | Attribute | Description |
flow | Flow |
|
Flow process to which collect from |
flow.id | String |
|
The permanent link for the requested flow process. |
transition | String |
|
the action to be applied to transition the flow |
options | Object |
|
Various options to change the way the transition occurs |
Throw:
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#updateExample:
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();