UNPKG

consumerportal

Version:

mydna Custimised for you

117 lines (99 loc) 5.36 kB
/// <reference path="../../includes.ts" /> module app { import IUser = services.IUser; import IAlcoholDetails = services.IAlcoholDetails; import IAlcoholMetric = services.IAlcoholMetric; import IAlcoholConsideration = services.IAlcoholConsideration; class Controller { static $inject = [ '$scope', '$timeout', 'alcoholService', 'modalService', 'user' ]; public details: any; public loaded: boolean = false; public navigation: any[] = this.alcoholService.navigation(); public sensitivity: any; public sideEffects: any; public dependence: any; public bingeDrinking: any; public hangover: any; public light: any; public lightAsian: any; public heavy: any; public heavyAsian: any; public recommendation: string; constructor( $scope: angular.IScope, $timeout: angular.ITimeoutService, private alcoholService: services.IAlcoholService, private modalService: IModalService, public user: IUser ) { alcoholService.details().then((value: IAlcoholDetails) => { this.details = value; console.log(value); let scale2 = [0, 10, 90]; let scale3 = [0, 10, 50, 90]; let scale4 = [0, 10, 33, 57, 90]; let metric: IAlcoholMetric = alcoholService.getMetrics(); let risk: any[] = [ {className: 'none', label: 'No Documented Risk'}, {className: 'mild', label: 'Mild Impact'}, {className: 'moderate', label: 'Moderate Impact'}, {className: 'significant', label: 'Significant Impact'} ]; let consideration: IAlcoholConsideration = alcoholService.getConsideration(); this.recommendation = consideration.Dashboard; this.light = risk[consideration.Light]; this.heavy = risk[consideration.Heavy]; if (consideration.Asian) { if (consideration.Asian.Light) { this.lightAsian = risk[consideration.Asian.Light] } if (consideration.Asian.Heavy) { this.heavyAsian = risk[consideration.Asian.Heavy] } } $timeout(() => { this.sensitivity = { value: scale3[value.Profile.Sensitivity], result: metric.Sensitivity, level: 'okay' }; this.sideEffects = { value: scale4[value.Profile.SideEffects], result: metric.SideEffects, level: 'okay' }; this.dependence = { value: value.Profile.Dependence, result: metric.Dependence, level: 'okay' }; this.bingeDrinking = { value: scale2[value.Profile.BingeDrinking], result: metric.Binge, level: 'okay' }; this.hangover = { value: scale2[value.Profile.Hangover], result: metric.Hangover, level: 'okay' }; }, 500); this.loaded = true; }); } open(hash: string) { window.location.hash = hash; } showLegend() { this.modalService.add('modal-notification.legend', { title: 'Alcohol Recommendation Information', content: ` <p>Drinking alcohol may be harmful to your health and may increase your risk for certain adverse health outcomes, which include certain cancers. The more alcohol you drink, the higher the risk. Non-drinkers are unlikely to have the increased risk.</p> <p>Due to genetic factors or other factors such as smoking, there are many studies to strongly link alcohol drinking and oesophageal cancer risk in the East Asian population. Therefore, the risks quoted here for the East Asian population refer to oesophageal cancer. East Asian populations include Han Chinese, Japanese, and other subgroups of East Asian descent.</p> <p>In the Caucasian population, the figures that are reported in the literature are mainly for upper gastrointestinal cancer. Therefore, the risks quoted here for the Caucasian population refer to upper gastro intestinal cancer.</p> <div class="title">Legend</div> <div><div class="none"></div><div>No Documented Risk</div></div> <div><div class="mild"></div><div>Mild Impact</div><div>The cancer risk is increased 0-2 times</div></div> <div><div class="moderate"></div><div>Moderate Impact</div><div>The cancer risk is increased 3-6 times</div></div> <div><div class="significant"></div><div>Significant Impact</div><div>The cancer risk is increased 7-22 times</div></div> ` }) } } angular .module('app') .controller('alcoholDashboardCtrl', Controller); }