Site
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: []
}
}
}
});
Constructor Summary
Public Constructor | ||
public |
constructor(json: Object) 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 |
|
Public Constructors
public constructor(json: Object) source
Constructor for helper class representing an Site
Override:
SiteModel#constructorParams:
Name | Type | Attribute | Description |
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 siteLanguages: SiteLanguage[] source
public set siteLanguages: SiteLanguage[] source
Public Methods
public delete(): Promise source
Deletes a site
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 });
public async getContacts(): Promise source
Gets the site contacts associated to this site.
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() });
public getMembers(params: Object, options: String): Promise source
Gets the site members associated to this site.
Params:
Name | Type | Attribute | Description |
params | Object |
|
Parameters used to get information from server |
params.id | Number |
|
Id to get data from the server |
params.type | String |
|
Type to be used for storage |
params.filters | Object |
|
Filters to be used for get |
options | String |
|
Modify the nature of the call and response |
options.url | String |
|
Override the url for this call |
options.cacheMode | String |
|
Override the caching method for this call |
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() });
public async getSiteLanguages(options: String): Promise source
Gets the supported languages associated to this site.
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() });
public save(): Promise<Site> source
Saves a site (insert if id doesn't exist, update if it does)
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());