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

EventService

Extends:

AbstractServiceJsonApiService → EventService

Service handling Event calls with specific endpoints.

Constructor Summary

Public Constructor
public

Update type to be events

Method Summary

Public Methods
public

delete(event: Event, cacheMode: String): Promise

public

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

public

insert(event: Event, cacheMode: String): Promise<Event>

public

trackEvents(resource: String, action: String, context: Object): Promise

this method was deprecated. Track an event done by a mobile user This controller allows the client to report actions that the user has taken in order to respond with the correct callbacks
public

update(event: Event, cacheMode: String): Promise<Event>

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 events

Override:

JsonApiService#constructor

Public Methods

public delete(event: Event, cacheMode: String): Promise source

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

Override:

JsonApiService#delete

Params:

NameTypeAttributeDescription
event Event

Event object in which to update

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise

Message

Example:

import { eventService } from 'clinical6';

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

Test:

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

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

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { eventService } from 'clinical6';

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

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

Test:

public insert(event: Event, cacheMode: String): Promise<Event> source

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

Override:

JsonApiService#insert

Params:

NameTypeAttributeDescription
event Event

Key from server

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<Event>

Inserted event

Example:

import { Event, eventService } from 'clinical6';
const event = new Event({...});

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

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

Test:

public trackEvents(resource: String, action: String, context: Object): Promise source

this method was deprecated. Track an event done by a mobile user This controller allows the client to report actions that the user has taken in order to respond with the correct callbacks

Params:

NameTypeAttributeDescription
resource String
  • nullable: false

The resource to be tracked

action String
  • nullable: false

The resource to be tracked

context Object
  • optional
  • nullable: false

Hash of fields that provide context for the action

context.value String
  • optional
  • nullable: false

The value (example: "approved")

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Decorators:

  • deprecate

Example:

import { eventService } from 'clinical6';
eventService.trackEvents('callback', 'patient');
eventService.trackEvents('callback', 'patient', { value: 'approved' });

Test:

public update(event: Event, cacheMode: String): Promise<Event> source

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

Override:

JsonApiService#update

Params:

NameTypeAttributeDescription
event Event

Event object in which to update

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<Event>

Updated event

Example:

import { Event, eventService } from 'clinical6';
const event = new Event({...});

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

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

Test: