src/helpers/consent/AvailableStrategy.js
import AvailableStrategyModel from '../../models/consent/AvailableStrategy';
import Helper from '../Helper';
import { aggregate } from '../../utilities/ClassUtility';
/**
* Helper class representing a Consent Available Strategy.
*
* @extends {AvailableStrategyModel}
* @extends {Helper}
*
* @example
* // To get a list of Available Strategies you must have a user first, then get it based on this user
* import { clinical6, AvailableStrategy } from 'clinical6';
* const user = new User({...}); // get the user in some way
* user.getAvailableStrategies().then(a => console.log(a)); // use getAvailableStrategies
* clinical6.getChildren(user, AvailableStrategy).then(a => console.log(a)); // or using get children
*
*/
class AvailableStrategy extends aggregate(AvailableStrategyModel, Helper) {
/**
* Constructor for helper class representing a Consent Form
*
* @param {Object} json - json api response from server
*/
constructor(json = {}) {
super(json);
this.deserializeRelationshipStubs(json);
this.syncRelationships(json);
}
/** @type {String} - The type */
static get type() {
return 'consent__available_strategies';
}
/** @type {ConsentForm[]} */
get consentForms() {
return this._relationships.forms;
}
/** @type {ConsentForm[]} */
set consentForms(forms) {
/** @type {ConsentForm[]} */
this._relationships.forms = forms;
}
/** @type {ConsentStrategy} */
get consentStrategy() {
return this._relationships.strategy;
}
/** @type {ConsentStrategy} */
set consentStrategy(consentStrategy) {
/** @type {ConsentStrategy} */
this._relationships.strategy = consentStrategy;
}
}
export default AvailableStrategy;