Manual Reference Source Test
public class | source

Site

Mixin Extends:

SiteModel, Helper

Helper class representing an site.

Example:

import { Site, clinical6 } from 'clinical6';

// Typically use clinical6.get(Site)
clinical6.get(Site).then(sites => console.log(sites));

const site = new Site({
  data: {
    id: '15',
    type: 'trials__sites',
    attributes: {
      site_id: '922176',
      name: 'Frankie Hermann',
      email: 'lisa@kulas.info',
      phone_number: null,
      fax_number: null
    },
    relationships: {
      contact: {
        data: null
      },
      location: {
        data: {
          id: '98',
          type: 'locations'
        }
      },
      agreement_templates: {
        data: []
      }
    }
  }
});

Test:

Static Member Summary

Static Public Members
public static get

Constructor Summary

Public Constructor
public

Constructor for helper class representing an Site

Member Summary

Public Members
public get
public set
public get
public set
public get
public set
public get
public set

Method Summary

Public Methods
public

Deletes a site

public

async getContacts(): Promise

Gets the site contacts associated to this site.

public

getMembers(params: Object, options: String): Promise

Gets the site members associated to this site.

public

async getSiteLanguages(options: String): Promise

Gets the supported languages associated to this site.

public

Saves a site (insert if id doesn't exist, update if it does)

Inherited Summary

From class SiteModel
public
public
public
public
public
public
public
public
public
public
public

Static Public Members

public static get type: String source

Public Constructors

public constructor(json: Object) source

Constructor for helper class representing an Site

Override:

SiteModel#constructor

Params:

NameTypeAttributeDescription
json Object

json api response from server

Public Members

public get agreementTemplates: AgreementTemplate[] source

public set agreementTemplates: AgreementTemplate[] source

public get contacts: SiteContact[] source

public set contacts: SiteContact[] source

public get location: Location source

public set location: Location source

public get siteLanguages: SiteLanguage[] source

public set siteLanguages: SiteLanguage[] source

Public Methods

public delete(): Promise source

Deletes a site

Return:

Promise

Returns a promise via ajax call.

Example:

import { Site, Client } from 'clinical6';

// Removes site from server and local storage
const site = new Site({...});
site.delete();

// No longer in storage
Client.instance.storageUtility.has('sites', { id: 1 });

Test:

public async getContacts(): Promise source

Gets the site contacts associated to this site.

Return:

Promise

Promise with data (array or object)

Example:

import { Site, clinical6 } from 'clinical6';
const site = new Site({ id: 23 });
site.getContacts();

// Combined with clinical6.get
clinical6.get(Site).then(sites => { sites[0].getContacts() });

Test:

public getMembers(params: Object, options: String): Promise source

Gets the site members associated to this site.

Params:

NameTypeAttributeDescription
params Object
  • optional

Parameters used to get information from server

params.id Number
  • optional

Id to get data from the server

params.type String
  • optional

Type to be used for storage

params.filters Object
  • optional

Filters to be used for get

options String
  • optional

Modify the nature of the call and response

options.url String
  • optional

Override the url for this call

options.cacheMode String
  • optional

Override the caching method for this call

Return:

Promise

Promise with data (array or object)

Example:

import { Site, clinical6 } from 'clinical6';
const site = new Site({ id: 23 });
site.getMembers({ id: 5 });
site.getMembers({ filters: { member_type: 'patient' }});

// Combined with clinical6.get
clinical6.get(Site).then(sites => { sites[0].getMembers() });

Test:

public async getSiteLanguages(options: String): Promise source

Gets the supported languages associated to this site.

Params:

NameTypeAttributeDescription
options String
  • optional

Modify the nature of the call and response

options.url String
  • optional

Override the url for this call

options.cacheMode String
  • optional

Override the caching method for this call

Return:

Promise

Promise with data (array or object)

Example:

import { Site, clinical6 } from 'clinical6';
const site = new Site({ id: 23 });
site.getSiteLanguages({ id: 5 });

// Combined with clinical6.get
clinical6.get(Site).then(sites => { sites[0].getSiteLanguages() });

Test:

public save(): Promise<Site> source

Saves a site (insert if id doesn't exist, update if it does)

Return:

Promise<Site>

Returns a promise via ajax call.

Example:

import { Site, clinical6 } from 'clinical6';

// Insert is different from other inserts.  Uses mobile application key
const site = new Site({
  "title": "You are a winner"
});
site.save();

// After you have the authtoken and then you've logged in

// Updates existing site (has existing id)
clinical6.get(Site).then(sites => sites[0].save());

Test: