UNPKG

acr-assist-simulator-module

Version:

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.7.4.

1,316 lines (1,289 loc) 822 kB
import { __values, __extends } from 'tslib'; import { Injectable, NgModule, InjectionToken, Inject, Component, Input, Output, EventEmitter, ViewChild, Directive, ElementRef, HostListener } from '@angular/core'; import { BehaviorSubject } from 'rxjs/BehaviorSubject'; import { isArray } from 'util'; import { CommonModule } from '@angular/common'; import { Subject } from 'rxjs/internal/Subject'; import { DomSanitizer } from '@angular/platform-browser'; import { FormBuilder, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms'; import { SlideComponent } from 'ngx-bootstrap/carousel/slide.component'; import { CarouselComponent } from 'ngx-bootstrap/carousel/carousel.component'; import { CarouselConfig } from 'ngx-bootstrap/carousel/carousel.config'; import { DragScrollModule } from 'ngx-drag-scroll'; import { AngularDateTimePickerModule } from 'angular2-datetimepicker'; import { DurationPickerModule } from 'ngx-duration-picker'; import { Http } from '@angular/http'; import 'rxjs/add/operator/map'; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var SimulatorState = /** @class */ (function () { function SimulatorState() { this.nonRelevantDataElementIds = []; this.endPointId = ''; this.selectedDecisionPointId = ''; this.selectedDecisionPointLabel = ''; this.selectedBranchLabel = ''; } return SimulatorState; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var DataElementValues = /** @class */ (function () { function DataElementValues(values) { this.values = values; } /** * @param {?} key * @param {?} value * @return {?} */ DataElementValues.prototype.addOrUpdate = /** * @param {?} key * @param {?} value * @return {?} */ function (key, value) { this.values[key] = value; }; /** * @param {?} key * @return {?} */ DataElementValues.prototype.get = /** * @param {?} key * @return {?} */ function (key) { return this.values[key]; }; /** * @param {?} key * @return {?} */ DataElementValues.prototype.delete = /** * @param {?} key * @return {?} */ function (key) { return this.values.delete(key); }; /** * @return {?} */ DataElementValues.prototype.getAll = /** * @return {?} */ function () { return this.values; }; return DataElementValues; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var ArithmeticExpression = /** @class */ (function () { function ArithmeticExpression() { } return ArithmeticExpression; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var /** @type {?} */ expressionParser = require('expr-eval').Parser; var SimulatorEngineService = /** @class */ (function () { function SimulatorEngineService() { this.endOfRoadReached = false; this.lastConditionMetBranchLevel = 1; this.nonRelevantDataElementIds = new Array(); this.simulatorStateChanged = new BehaviorSubject(new SimulatorState()); this.dataElementValues = new Map(); this.dataElementTexts = new Map(); this.nonRelevantDataElementIds = new Array(); } /** * @return {?} */ SimulatorEngineService.prototype.getTemplate = /** * @return {?} */ function () { return this.template; }; /** * @return {?} */ SimulatorEngineService.prototype.getAllDataElementValues = /** * @return {?} */ function () { return this.dataElementValues; }; /** * @return {?} */ SimulatorEngineService.prototype.getAllDataElementTexts = /** * @return {?} */ function () { return this.dataElementTexts; }; /** * @param {?} dataElementId * @return {?} */ SimulatorEngineService.prototype.getDataElementValue = /** * @param {?} dataElementId * @return {?} */ function (dataElementId) { return this.dataElementValues[dataElementId]; }; /** * @param {?} dataElementId * @return {?} */ SimulatorEngineService.prototype.getDataElementText = /** * @param {?} dataElementId * @return {?} */ function (dataElementId) { return this.dataElementTexts[dataElementId]; }; /** * @param {?} dataElementId * @param {?} value * @param {?} text * @return {?} */ SimulatorEngineService.prototype.addOrUpdateDataElement = /** * @param {?} dataElementId * @param {?} value * @param {?} text * @return {?} */ function (dataElementId, value, text) { this.dataElementValues[dataElementId] = value; this.dataElementTexts[dataElementId] = text; this.evaluateDecisionPoints(); }; /** * @param {?} decisionPoint * @param {?} branchingLevel * @return {?} */ SimulatorEngineService.prototype.evaluateDecisionPoint = /** * @param {?} decisionPoint * @param {?} branchingLevel * @return {?} */ function (decisionPoint, branchingLevel) { var /** @type {?} */ currentBranchCount = 0; var /** @type {?} */ totalBranchesInDecisionPoint = decisionPoint.branches.length; try { for (var _a = __values(decisionPoint.branches), _b = _a.next(); !_b.done; _b = _a.next()) { var branch = _b.value; currentBranchCount++; var /** @type {?} */ conditionMet = false; if (this.endOfRoadReached) { break; } if (branch.compositeCondition !== undefined) { conditionMet = branch.compositeCondition.evaluate(new DataElementValues(this.dataElementValues)); } else if (branch.condition !== undefined) { conditionMet = branch.condition.evaluate(new DataElementValues(this.dataElementValues)); } if (conditionMet) { this.lastConditionMetBranchLevel = branchingLevel; // if (nonRelevantDataElementIds === undefined) { // nonRelevantDataElementIds = new Array<string>(); // } // if (branch.notRelevantDataElements !== undefined) { // for (const nonRelevantDataElementReference of branch.notRelevantDataElements.dataElementReferences) { // nonRelevantDataElementIds.push(nonRelevantDataElementReference.dataElementId); // } // } if (branch.decisionPoints !== undefined) { try { for (var _c = __values(branch.decisionPoints), _d = _c.next(); !_d.done; _d = _c.next()) { var branchDecisionPoint = _d.value; var /** @type {?} */ newBranchingLevel = branchingLevel + 1; // this.evaluateDecisionPoint(branchDecisionPoint, newBranchingLevel, nonRelevantDataElementIds); this.evaluateDecisionPoint(branchDecisionPoint, newBranchingLevel); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_d && !_d.done && (_e = _c.return)) _e.call(_c); } finally { if (e_1) throw e_1.error; } } } else if (branch.endPointRef !== undefined) { var /** @type {?} */ simulatorState = new SimulatorState(); simulatorState.endPointId = branch.endPointRef.endPointId; // simulatorState.nonRelevantDataElementIds = nonRelevantDataElementIds; simulatorState.selectedBranchLabel = branch.label; simulatorState.selectedDecisionPointId = decisionPoint.id; simulatorState.selectedDecisionPointLabel = decisionPoint.label; // this.resetValuesOfNonRelevantDataElements(nonRelevantDataElementIds); this.simulatorStateChanged.next(simulatorState); this.endOfRoadReached = true; break; } } else { if (currentBranchCount >= totalBranchesInDecisionPoint) { this.endOfRoadReached = true; var /** @type {?} */ simulatorState = new SimulatorState(); // simulatorState.nonRelevantDataElementIds = nonRelevantDataElementIds; // this.resetValuesOfNonRelevantDataElements(nonRelevantDataElementIds); this.simulatorStateChanged.next(simulatorState); return; } else { continue; } } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_b && !_b.done && (_f = _a.return)) _f.call(_a); } finally { if (e_2) throw e_2.error; } } var e_2, _f, e_1, _e; }; /** * @param {?} nonRelevantDataElementIds * @return {?} */ SimulatorEngineService.prototype.resetValuesOfNonRelevantDataElements = /** * @param {?} nonRelevantDataElementIds * @return {?} */ function (nonRelevantDataElementIds) { // console.log(this.template.dataElements); if (nonRelevantDataElementIds !== undefined) { try { for (var nonRelevantDataElementIds_1 = __values(nonRelevantDataElementIds), nonRelevantDataElementIds_1_1 = nonRelevantDataElementIds_1.next(); !nonRelevantDataElementIds_1_1.done; nonRelevantDataElementIds_1_1 = nonRelevantDataElementIds_1.next()) { var nonRelevantDataElementId = nonRelevantDataElementIds_1_1.value; var /** @type {?} */ defaultValue = void 0; try { for (var _a = __values(this.template.dataElements), _b = _a.next(); !_b.done; _b = _a.next()) { var dataElement = _b.value; if (dataElement.id === nonRelevantDataElementId) { defaultValue = dataElement.defaultValue; break; } } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { if (_b && !_b.done && (_c = _a.return)) _c.call(_a); } finally { if (e_3) throw e_3.error; } } this.dataElementValues[nonRelevantDataElementId] = defaultValue; } } catch (e_4_1) { e_4 = { error: e_4_1 }; } finally { try { if (nonRelevantDataElementIds_1_1 && !nonRelevantDataElementIds_1_1.done && (_d = nonRelevantDataElementIds_1.return)) _d.call(nonRelevantDataElementIds_1); } finally { if (e_4) throw e_4.error; } } } var e_4, _d, e_3, _c; }; /** * @param {?} elementId * @param {?} decisionPoint * @param {?} branchingLevel * @return {?} */ SimulatorEngineService.prototype.evaluateComputedElementDecisionPoint = /** * @param {?} elementId * @param {?} decisionPoint * @param {?} branchingLevel * @return {?} */ function (elementId, decisionPoint, branchingLevel) { var /** @type {?} */ currentBranchCount = 0; var /** @type {?} */ totalBranchesInDecisionPoint = decisionPoint.branches.length; try { for (var _a = __values(decisionPoint.branches), _b = _a.next(); !_b.done; _b = _a.next()) { var branch = _b.value; currentBranchCount++; var /** @type {?} */ conditionMet = false; if (this.endOfRoadReached) { break; } if (branch.compositeCondition !== undefined) { conditionMet = branch.compositeCondition.evaluate(new DataElementValues(this.dataElementValues)); } else if (branch.condition !== undefined) { conditionMet = branch.condition.evaluate(new DataElementValues(this.dataElementValues)); } if (conditionMet) { this.lastConditionMetBranchLevel = branchingLevel; if (branch.decisionPoints !== undefined) { try { for (var _c = __values(branch.decisionPoints), _d = _c.next(); !_d.done; _d = _c.next()) { var branchDecisionPoint = _d.value; var /** @type {?} */ newBranchingLevel = branchingLevel + 1; this.evaluateComputedElementDecisionPoint(elementId, branchDecisionPoint, newBranchingLevel); } } catch (e_5_1) { e_5 = { error: e_5_1 }; } finally { try { if (_d && !_d.done && (_e = _c.return)) _e.call(_c); } finally { if (e_5) throw e_5.error; } } } else if (branch.computedValue !== undefined) { this.dataElementValues[elementId] = branch.computedValue.expressionText; this.endOfRoadReached = true; if (branch.computedValue instanceof ArithmeticExpression) { this.dataElementValues[elementId] = this.evaluateArithmeticExpression(branch.computedValue.expressionText); this.endOfRoadReached = true; } else { this.dataElementValues[elementId] = branch.computedValue.expressionText; this.endOfRoadReached = true; } break; } } else { if (currentBranchCount >= totalBranchesInDecisionPoint) { this.endOfRoadReached = true; this.dataElementValues[elementId] = undefined; return; } else { continue; } } } } catch (e_6_1) { e_6 = { error: e_6_1 }; } finally { try { if (_b && !_b.done && (_f = _a.return)) _f.call(_a); } finally { if (e_6) throw e_6.error; } } var e_6, _f, e_5, _e; }; /** * @param {?} computedValue * @return {?} */ SimulatorEngineService.prototype.evaluateArithmeticExpression = /** * @param {?} computedValue * @return {?} */ function (computedValue) { var /** @type {?} */ startIndex = 0; var /** @type {?} */ endIndex = 0; var _loop_1 = function () { startIndex = computedValue.indexOf('{'); endIndex = computedValue.indexOf('}'); if (startIndex !== -1 && endIndex !== -1) { var /** @type {?} */ dataElementId = computedValue.substring(startIndex + 1, endIndex); var /** @type {?} */ replacingValue = computedValue.substring(startIndex, endIndex + 1); var /** @type {?} */ dataElementValue = this_1.dataElementValues[dataElementId]; if (isArray(dataElementValue)) { var /** @type {?} */ sum_1 = 0; dataElementValue.forEach(function (val) { sum_1 += +val; }); dataElementValue = sum_1; } computedValue = computedValue.replace(replacingValue, dataElementValue); } }; var this_1 = this; while (startIndex !== -1 && endIndex !== -1) { _loop_1(); } return expressionParser.evaluate(computedValue).toString(); }; /** * @return {?} */ SimulatorEngineService.prototype.evaluateComputedExpressions = /** * @return {?} */ function () { this.endOfRoadReached = false; try { for (var _a = __values(this.template.dataElements), _b = _a.next(); !_b.done; _b = _a.next()) { var element = _b.value; if (element.dataElementType === 'ComputedDataElement') { var /** @type {?} */ computedElement = /** @type {?} */ (element); try { for (var _c = __values(computedElement.decisionPoints), _d = _c.next(); !_d.done; _d = _c.next()) { var decisionPoint = _d.value; this.evaluateComputedElementDecisionPoint(element.id, decisionPoint, 1); if (this.dataElementValues[element.id] === undefined && decisionPoint.defaultBranch && decisionPoint.defaultBranch.computedValue) { this.dataElementValues[element.id] = decisionPoint.defaultBranch.computedValue.expressionText; } this.endOfRoadReached = false; } } catch (e_7_1) { e_7 = { error: e_7_1 }; } finally { try { if (_d && !_d.done && (_e = _c.return)) _e.call(_c); } finally { if (e_7) throw e_7.error; } } } } } catch (e_8_1) { e_8 = { error: e_8_1 }; } finally { try { if (_b && !_b.done && (_f = _a.return)) _f.call(_a); } finally { if (e_8) throw e_8.error; } } var e_8, _f, e_7, _e; }; /** * @param {?} dataelement * @param {?=} nonRelevantDataElementIds * @return {?} */ SimulatorEngineService.prototype.evaluateConditionalProperty = /** * @param {?} dataelement * @param {?=} nonRelevantDataElementIds * @return {?} */ function (dataelement, nonRelevantDataElementIds) { if (nonRelevantDataElementIds === void 0) { nonRelevantDataElementIds = []; } if (dataelement.conditionalProperties !== undefined) { var /** @type {?} */ conditionMet = false; try { for (var _a = __values(dataelement.conditionalProperties), _b = _a.next(); !_b.done; _b = _a.next()) { var conditionalProperty = _b.value; if (conditionalProperty.condition !== undefined) { conditionMet = conditionalProperty.condition.evaluate(new DataElementValues(this.dataElementValues)); } else if (conditionalProperty.compositeCondition !== undefined) { conditionMet = conditionalProperty.compositeCondition.evaluate(new DataElementValues(this.dataElementValues)); } if (conditionMet) { if (nonRelevantDataElementIds === undefined) { this.nonRelevantDataElementIds = new Array(); } if (conditionalProperty.isRelevant === 'false') { this.nonRelevantDataElementIds.push(dataelement.id); } else { dataelement.displaySequence = conditionalProperty.DisplaySequence; dataelement.isRequired = conditionalProperty.isRequired !== undefined ? (conditionalProperty.isRequired.toLowerCase() === 'true' ? true : false) : true; if (conditionalProperty.Minimum !== undefined && conditionalProperty.Minimum != null) { dataelement.minimum = +conditionalProperty.Minimum; } if (conditionalProperty.Maximum !== undefined && conditionalProperty.Maximum != null) { dataelement.maximum = +conditionalProperty.Maximum; } if (dataelement.dataElementType === 'ChoiceDataElement') { (/** @type {?} */ (dataelement)).ChoiceNotRelevant = conditionalProperty.ChoiceNotRelevant; } if (dataelement.dataElementType === 'MultiChoiceDataElement') { (/** @type {?} */ (dataelement)).ChoiceNotRelevant = conditionalProperty.ChoiceNotRelevant; } if (dataelement.dataElementType === 'DurationDataElement') { (/** @type {?} */ (dataelement)).MinimumDay = +conditionalProperty.MinimumDay; (/** @type {?} */ (dataelement)).MaximumDay = +conditionalProperty.MaximumDay; (/** @type {?} */ (dataelement)).MinimumHours = +conditionalProperty.MinimumHours; (/** @type {?} */ (dataelement)).MaximumHours = +conditionalProperty.MaximumHours; (/** @type {?} */ (dataelement)).MinimumMinutes = +conditionalProperty.MinimumMinutes; (/** @type {?} */ (dataelement)).MaxmimumMinutes = +conditionalProperty.MaxmimumMinutes; } } return this.nonRelevantDataElementIds; } else { if (dataelement.dataElementType === 'ChoiceDataElement') { (/** @type {?} */ (dataelement)).ChoiceNotRelevant = new Array(); } if (dataelement.dataElementType === 'MultiChoiceDataElement') { (/** @type {?} */ (dataelement)).ChoiceNotRelevant = new Array(); } } } } catch (e_9_1) { e_9 = { error: e_9_1 }; } finally { try { if (_b && !_b.done && (_c = _a.return)) _c.call(_a); } finally { if (e_9) throw e_9.error; } } } var e_9, _c; }; /** * @return {?} */ SimulatorEngineService.prototype.isCondtionMet = /** * @return {?} */ function () { try { for (var _a = __values(this.template.dataElements), _b = _a.next(); !_b.done; _b = _a.next()) { var dataelement = _b.value; if (dataelement.conditionalProperties !== undefined) { var /** @type {?} */ conditionMet = false; try { for (var _c = __values(dataelement.conditionalProperties), _d = _c.next(); !_d.done; _d = _c.next()) { var conditionalProperty = _d.value; if (conditionalProperty.condition !== undefined) { conditionMet = conditionalProperty.condition.evaluate(new DataElementValues(this.dataElementValues)); } else if (conditionalProperty.compositeCondition !== undefined) { conditionMet = conditionalProperty.compositeCondition.evaluate(new DataElementValues(this.dataElementValues)); } if (conditionMet) { return true; } return false; } } catch (e_10_1) { e_10 = { error: e_10_1 }; } finally { try { if (_d && !_d.done && (_e = _c.return)) _e.call(_c); } finally { if (e_10) throw e_10.error; } } } } } catch (e_11_1) { e_11 = { error: e_11_1 }; } finally { try { if (_b && !_b.done && (_f = _a.return)) _f.call(_a); } finally { if (e_11) throw e_11.error; } } var e_11, _f, e_10, _e; }; /** * @return {?} */ SimulatorEngineService.prototype.evaluateDecisionAndConditionalProperty = /** * @return {?} */ function () { this.nonRelevantDataElementIds = new Array(); this.RevertConditionValues(); try { for (var _a = __values(this.template.dataElements), _b = _a.next(); !_b.done; _b = _a.next()) { var dataelement = _b.value; this.evaluateConditionalProperty(dataelement, new Array()); } } catch (e_12_1) { e_12 = { error: e_12_1 }; } finally { try { if (_b && !_b.done && (_c = _a.return)) _c.call(_a); } finally { if (e_12) throw e_12.error; } } this.resetValuesOfNonRelevantDataElements(this.nonRelevantDataElementIds); return this.nonRelevantDataElementIds; var e_12, _c; }; /** * @return {?} */ SimulatorEngineService.prototype.RevertConditionValues = /** * @return {?} */ function () { try { for (var _a = __values(this.template.dataElements), _b = _a.next(); !_b.done; _b = _a.next()) { var dataelement = _b.value; dataelement.isRequired = dataelement.isRequiredOverrider; dataelement.displaySequence = dataelement.displaySequenceOverrider; if (dataelement.dataElementType === 'NumericDataElement') { (/** @type {?} */ (dataelement)).minimum = +(/** @type {?} */ (dataelement)).minimumOverrider; (/** @type {?} */ (dataelement)).maximum = +(/** @type {?} */ (dataelement)).maximumOverrider; } if (dataelement.dataElementType === 'IntegerDataElement') { (/** @type {?} */ (dataelement)).minimum = +(/** @type {?} */ (dataelement)).minimumOverrider; (/** @type {?} */ (dataelement)).maximum = +(/** @type {?} */ (dataelement)).maximumOverrider; } if (dataelement.dataElementType === 'DurationDataElement') { (/** @type {?} */ (dataelement)).MinimumDay = +(/** @type {?} */ (dataelement)).MinimumDayOverrider; (/** @type {?} */ (dataelement)).MaximumDay = +(/** @type {?} */ (dataelement)).MaximumDayOverrider; (/** @type {?} */ (dataelement)).MinimumHours = +(/** @type {?} */ (dataelement)).MinimumHoursOverrider; (/** @type {?} */ (dataelement)).MaximumHours = +(/** @type {?} */ (dataelement)).MaximumHoursOverrider; (/** @type {?} */ (dataelement)).MinimumMinutes = +(/** @type {?} */ (dataelement)).MinimumMinutesOverrider; (/** @type {?} */ (dataelement)).MaxmimumMinutes = +(/** @type {?} */ (dataelement)).MaxmimumMinutesOverrider; } } } catch (e_13_1) { e_13 = { error: e_13_1 }; } finally { try { if (_b && !_b.done && (_c = _a.return)) _c.call(_a); } finally { if (e_13) throw e_13.error; } } var e_13, _c; }; /** * @return {?} */ SimulatorEngineService.prototype.evaluateDecisionPoints = /** * @return {?} */ function () { this.evaluateComputedExpressions(); this.endOfRoadReached = false; try { for (var _a = __values(this.template.rules.decisionPoints), _b = _a.next(); !_b.done; _b = _a.next()) { var decisionPoint = _b.value; this.evaluateDecisionPoint(decisionPoint, 1); } } catch (e_14_1) { e_14 = { error: e_14_1 }; } finally { try { if (_b && !_b.done && (_c = _a.return)) _c.call(_a); } finally { if (e_14) throw e_14.error; } } var e_14, _c; }; /** * @param {?} template * @return {?} */ SimulatorEngineService.prototype.initialize = /** * @param {?} template * @return {?} */ function (template) { this.template = template; try { for (var _a = __values(this.template.dataElements), _b = _a.next(); !_b.done; _b = _a.next()) { var dataElement = _b.value; this.dataElementValues[dataElement.id] = dataElement.currentValue; } } catch (e_15_1) { e_15 = { error: e_15_1 }; } finally { try { if (_b && !_b.done && (_c = _a.return)) _c.call(_a); } finally { if (e_15) throw e_15.error; } } var e_15, _c; }; SimulatorEngineService.decorators = [ { type: Injectable }, ]; /** @nocollapse */ SimulatorEngineService.ctorParameters = function () { return []; }; return SimulatorEngineService; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var CoreModule = /** @class */ (function () { function CoreModule() { } /** * @return {?} */ CoreModule.forRoot = /** * @return {?} */ function () { return { ngModule: CoreModule, providers: [SimulatorEngineService] }; }; CoreModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule ], declarations: [] },] }, ]; return CoreModule; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var Template = /** @class */ (function () { function Template() { } return Template; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var Metadata = /** @class */ (function () { function Metadata() { } return Metadata; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var Diagram = /** @class */ (function () { function Diagram() { } return Diagram; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var ArrayCheckerService = /** @class */ (function () { function ArrayCheckerService() { } /** * @param {?} item * @return {?} */ ArrayCheckerService.prototype.isArray = /** * @param {?} item * @return {?} */ function (item) { return item instanceof Array; }; ArrayCheckerService.decorators = [ { type: Injectable }, ]; /** @nocollapse */ ArrayCheckerService.ctorParameters = function () { return []; }; return ArrayCheckerService; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var DiagramService = /** @class */ (function () { function DiagramService(arrayCheckerSeviceService) { this.arrayCheckerSeviceService = arrayCheckerSeviceService; } /** * @param {?} diagramJSON * @return {?} */ DiagramService.prototype.returnDiagram = /** * @param {?} diagramJSON * @return {?} */ function (diagramJSON) { var /** @type {?} */ diagram = new Diagram(); if (diagramJSON.Attr) { diagram.displaySequence = diagramJSON.Attr.DisplaySequence; diagram.keyDiagram = diagramJSON.Attr.IsKeyDiagram ? diagramJSON.Attr.IsKeyDiagram : false; } else { diagram.displaySequence = undefined; diagram.keyDiagram = false; } diagram.label = diagramJSON.Label; diagram.location = diagramJSON.Location; return diagram; }; /** * @param {?} diagramsAsJSON * @return {?} */ DiagramService.prototype.returnDiagrams = /** * @param {?} diagramsAsJSON * @return {?} */ function (diagramsAsJSON) { var /** @type {?} */ diagrams = new Array(); if (diagramsAsJSON !== undefined) { if (this.arrayCheckerSeviceService.isArray(diagramsAsJSON)) { try { for (var diagramsAsJSON_1 = __values(diagramsAsJSON), diagramsAsJSON_1_1 = diagramsAsJSON_1.next(); !diagramsAsJSON_1_1.done; diagramsAsJSON_1_1 = diagramsAsJSON_1.next()) { var diagram = diagramsAsJSON_1_1.value; diagrams.push(this.returnDiagram(diagram)); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (diagramsAsJSON_1_1 && !diagramsAsJSON_1_1.done && (_a = diagramsAsJSON_1.return)) _a.call(diagramsAsJSON_1); } finally { if (e_1) throw e_1.error; } } } else { diagrams.push(this.returnDiagram(diagramsAsJSON)); } } return diagrams; var e_1, _a; }; DiagramService.decorators = [ { type: Injectable }, ]; /** @nocollapse */ DiagramService.ctorParameters = function () { return [ { type: ArrayCheckerService } ]; }; return DiagramService; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var /** @type {?} */ CreationServiceInjectorToken = new InjectionToken('one'); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var DecisionPoint = /** @class */ (function () { function DecisionPoint() { } return DecisionPoint; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var Branch = /** @class */ (function () { function Branch() { } return Branch; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var EndPointRef = /** @class */ (function () { function EndPointRef() { } return EndPointRef; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var DataElementRef = /** @class */ (function () { function DataElementRef() { } return DataElementRef; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var NotRelevantDataElements = /** @class */ (function () { function NotRelevantDataElements() { } return NotRelevantDataElements; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var EqualCondition = /** @class */ (function () { function EqualCondition(conditionType) { this.conditionType = conditionType; } /** * @param {?} dataElementValues * @return {?} */ EqualCondition.prototype.evaluate = /** * @param {?} dataElementValues * @return {?} */ function (dataElementValues) { var /** @type {?} */ value = dataElementValues.get(this.conditionType.dataElementId); if (value !== undefined) { return value.toUpperCase() === this.conditionType.comparisonValue.toUpperCase(); } return false; }; return EqualCondition; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var ConditionType = /** @class */ (function () { function ConditionType() { } return ConditionType; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var GreaterThanCondition = /** @class */ (function () { function GreaterThanCondition(conditionType) { this.conditionType = conditionType; } /** * @param {?} dataElementValues * @return {?} */ GreaterThanCondition.prototype.evaluate = /** * @param {?} dataElementValues * @return {?} */ function (dataElementValues) { var /** @type {?} */ value = /** @type {?} */ (+dataElementValues.get(this.conditionType.dataElementId)); var /** @type {?} */ comparisonValue = -1; if (isNaN(this.conditionType.comparisonValue)) { comparisonValue = /** @type {?} */ (+dataElementValues.get(this.conditionType.comparisonValue)); } else { comparisonValue = /** @type {?} */ (+this.conditionType.comparisonValue); } return value > comparisonValue; }; return GreaterThanCondition; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var LessThanCondition = /** @class */ (function () { function LessThanCondition(conditionType) { this.conditionType = conditionType; } /** * @param {?} dataElementValues * @return {?} */ LessThanCondition.prototype.evaluate = /** * @param {?} dataElementValues * @return {?} */ function (dataElementValues) { var /** @type {?} */ value = /** @type {?} */ (+dataElementValues.get(this.conditionType.dataElementId)); var /** @type {?} */ comparisonValue = -1; if (isNaN(this.conditionType.comparisonValue)) { comparisonValue = /** @type {?} */ (+dataElementValues.get(this.conditionType.comparisonValue)); } else { comparisonValue = /** @type {?} */ (+this.conditionType.comparisonValue); } return value < comparisonValue; }; return LessThanCondition; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var GreaterThanOrEqualsCondition = /** @class */ (function () { function GreaterThanOrEqualsCondition(conditionType) { this.conditionType = conditionType; } /** * @param {?} dataElementValues * @return {?} */ GreaterThanOrEqualsCondition.prototype.evaluate = /** * @param {?} dataElementValues * @return {?} */ function (dataElementValues) { var /** @type {?} */ value = /** @type {?} */ (+dataElementValues.get(this.conditionType.dataElementId)); var /** @type {?} */ comparisonValue = -1; if (isNaN(this.conditionType.comparisonValue)) { comparisonValue = /** @type {?} */ (+dataElementValues.get(this.conditionType.comparisonValue)); } else { comparisonValue = /** @type {?} */ (+this.conditionType.comparisonValue); } return value >= comparisonValue; }; return GreaterThanOrEqualsCondition; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var LessThanOrEqualsCondition = /** @class */ (function () { function LessThanOrEqualsCondition(conditionType) { this.conditionType = conditionType; } /** * @param {?} dataElementValues * @return {?} */ LessThanOrEqualsCondition.prototype.evaluate = /** * @param {?} dataElementValues * @return {?} */ function (dataElementValues) { var /** @type {?} */ value = /** @type {?} */ (+dataElementValues.get(this.conditionType.dataElementId)); var /** @type {?} */ comparisonValue = -1; if (isNaN(this.conditionType.comparisonValue)) { comparisonValue = /** @type {?} */ (+dataElementValues.get(this.conditionType.comparisonValue)); } else { comparisonValue = /** @type {?} */ (+this.conditionType.comparisonValue); } return value <= comparisonValue; }; return LessThanOrEqualsCondition; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var ContainsCondition = /** @class */ (function () { function ContainsCondition(conditionType) { this.conditionType = conditionType; } /** * @param {?} dataElementValues * @return {?} */ ContainsCondition.prototype.evaluate = /** * @param {?} dataElementValues * @return {?} */ function (dataElementValues) { var /** @type {?} */ returnValue = false; var /** @type {?} */ value = dataElementValues.get(this.conditionType.dataElementId); if (value !== undefined) { for (var /** @type {?} */ counter = 0; counter < value.length; counter++) { var /** @type {?} */ value1 = value[counter]; if (value1.toUpperCase() === this.conditionType.comparisonValue.toUpperCase()) { returnValue = true; } } } return returnValue; }; return ContainsCondition; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var AndCondition = /** @class */ (function () { function AndCondition() { this.conditions = []; this.conditionType = 'AndCondition'; } /** * @param {?} dataElementValues * @return {?} */ AndCondition.prototype.evaluate = /** * @param {?} dataElementValues * @return {?} */ function (dataElementValues) { var /** @type {?} */ returnValue = true; for (var /** @type {?} */ conditionCounter = 0; conditionCounter < this.conditions.length; conditionCounter++) { var /** @type {?} */ condition = this.conditions[conditionCounter]; var /** @type {?} */ executedCondition = condition.evaluate(dataElementValues); returnValue = (!executedCondition) ? false : (returnValue && executedCondition); if (!returnValue) { break; } } return returnValue; }; return AndCondition; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var OrCondition = /** @class */ (function () { function OrCondition() { this.conditions = []; this.conditionType = 'OrCondition'; } /** * @param {?} dataElementValues * @return {?} */ OrCondition.prototype.evaluate = /** * @param {?} dataElementValues * @return {?} */ function (dataElementValues) { var /** @type {?} */ returnValue = false; for (var /** @type {?} */ conditionCounter = 0; conditionCounter < this.conditions.length; conditionCounter++) { var /** @type {?} */ condition = this.conditions[conditionCounter]; var /** @type {?} */ executedCondition = condition.evaluate(dataElementValues); returnValue = (returnValue || executedCondition); if (returnValue) { break; } } return returnValue; }; return OrCondition; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var NotCondition = /** @class */ (function () { function NotCondition() { this.conditions = []; this.conditionType = 'NotCondition'; } /** * @param {?} dataElementValues * @return {?} */ NotCondition.prototype.evaluate = /** * @param {?} dataElementValues * @return {?} */ function (dataElementValues) { var /** @type {?} */ results = new Array(); try { for (var _a = __values(this.conditions), _b = _a.next(); !_b.done; _b = _a.next()) { var condition = _b.value; results.push(condition.evaluate(dataElementValues)); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_b && !_b.done && (_c = _a.return)) _c.call(_a); } finally { if (e_1) throw e_1.error; } } return !(results[0]); var e_1, _c; }; return NotCondition; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var ConditionsCreationService = /** @class */ (function () { function ConditionsCreationService(arrayCheckerService) { this.arrayCheckerService = arrayCheckerService; } /** * @param {?} conditionJSON * @return {?} */ ConditionsCreationService.prototype.returnConditionType = /** * @param {?} conditionJSON * @return {?} */ function (conditionJSON) { var /** @type {?} */ conditionType = new ConditionType(); conditionType.comparisonValue = conditionJSON.Attr.ComparisonValue; conditionType.dataElementId = conditionJSON.Attr.DataElementId; return conditionType; }; /** * @param {?} branchJSON * @return {?} */ ConditionsCreationService.prototype.returnCondition = /** * @param {?} branchJSON * @return {?} */ function (branchJSON) { var /** @type {?} */ condition; if (branchJSON.hasOwnProperty('EqualCondition')) { condition = new EqualCondition(this.returnConditionType(branchJSON.EqualCondition)); } if (branchJSON.hasOwnProperty('GreaterThanCondition')) { condition = new GreaterThanCondition(this.returnConditionType(branchJSON.GreaterThanCondition)); } if (branchJSON.hasOwnProperty('LessThanCondition')) { condition = new LessThanCondition(this.returnConditionType(branchJSON.LessThanCondition)); } if (branchJSON.hasOwnProperty('GreaterThanOrEqualsCondition')) { condition = new GreaterThanOrEqualsCondition(this.returnConditionType(branchJSON.GreaterThanOrEqualsCondition)); } if (branchJSON.hasOwnProperty('LessThanOrEqualsCondition')) { condition = new LessThanOrEqualsCondition(this.returnConditionType(branchJSON.LessThanOrEqualsCondition)); } if (branchJSON.hasOwnProperty('ContainsCondition')) { condition = new ContainsCondition(this.returnConditionType(branchJSON.ContainsCondition)); } // if (condition !== undefined) { // condition.IsRelevant = branchJSON.IsRelevant !== undefined // ? branchJSON.IsRelevant : false; // } // condition.IsRelevant = branchJSON.IsRelevant !== undefined // ? branchJSON.IsRelevant : true; return condition; }; /** * @param {?} compositeElementJSON * @return {?} */ ConditionsCreationService.prototype.isComposite = /** * @param {?} compositeElementJSON * @return {?} */ function (compositeElementJSON) { return compositeElementJSON.hasOwnProperty('AndCondition') || compositeElementJSON.hasOwnProperty('OrCondition') || compositeElementJSON.hasOwnProperty('NotCondition'); }; /** * @param {?} conditionIdentifier * @param {?} conditionJSON * @return {?} */ ConditionsCreationService.prototype.returnConditionFromJSON = /** * @param {?} conditionIdentifier * @param {?} conditionJSON * @return {?} */ function (conditionIdentifier, conditionJSON) { var /** @type {?} */ condition; if (conditionIdentifier === 'EqualCondition') { condition = new EqualCondition(this.returnConditionType(conditionJSON)); } if (conditionIdentifier === 'GreaterThanCondition') { condition = new GreaterThanCondition(this.returnConditionType(conditionJSON)); } if (conditionIdentifier === 'LessThanCondition') { condition = new LessThanCondition(this.returnConditionType(conditionJSON)); } if (conditionIdentifier === 'GreaterT