Manual Reference Source Test
public class | source

CohortAssignment

Helper class representing an cohortAssignment.

Example:

// To get a list of Cohort Assignments you must have the cohort first, then get it based on this cohort
import { clinical6, CohortAssignment } from 'clinical6';
const cohort = new Cohort({...}); // get the cohort in some way
cohort.getAssignments().then(a => console.log(a)); // use getAssignments
clinical6.getChildren(cohort, CohortAssignment).then(a => console.log(a)); // or using get children

// To get a single cohort, you can also use clinical6
clinical6.get({ id: 5, type: 'cohort_assignments'});

// To save or insert, you can either use the .save() capability or clinical6
myCohortAssignment.save(); // insert if no id, save if id
clinical6.insert(new CohortAssignment({...}));
clinical6.update(myCohortAssignment);

// To delete, use clinical6 or .delete();
myCohortAssignment.delete();
clinical6.delete(myCohortAssignment);

Test:

Static Member Summary

Static Public Members
public static get

Constructor Summary

Public Constructor
public

Constructor for helper class representing an CohortAssignment

Member Summary

Public Members
public get
public set
public get
public set

Method Summary

Public Methods
public

Deletes a cohortAssignment

public

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

Inherited Summary

From class CohortAssignmentModel
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 CohortAssignment

Override:

CohortAssignmentModel#constructor

Params:

NameTypeAttributeDescription
json Object

json api response from server

Public Members

public get cohort: Cohort[] source

public set cohort: Cohort[] source

public get user: User source

public set user: User source

Public Methods

public delete(): Promise source

Deletes a cohortAssignment

Return:

Promise

Returns a promise via ajax call.

Example:

import { CohortAssignment, Client } from 'clinical6';

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

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

Test:

public save(): Promise<CohortAssignment> source

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

Return:

Promise<CohortAssignment>

Returns a promise via ajax call.

Example:

import { CohortAssignment, clinical6 } from 'clinical6';

// Insert is different from other inserts.  Uses mobile application key
const cohortAssignment = new CohortAssignment({...});
cohortAssignment.save();

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

// Updates existing cohortAssignment (has existing id)
clinical6.get(CohortAssignment).then(cohortAssignments => cohortAssignments[0].save());

Test: