UNPKG

consumerportal

Version:

mydna Custimised for you

70 lines (54 loc) 2.44 kB
/// <reference path="../../includes.ts" /> module app { import IUser = services.IUser; import IPatientCase = services.IPatientCase; class Controller { static $inject = [ 'patientService', 'user' ]; public loaded: boolean = false; public patientCase: IPatientCase; public state: string = 'waiting'; constructor( private patientService: services.IPatientService, public user: IUser ) { // TODO deal with delivery pref of pharmacy vs customer patientService.cases().then((cases: IPatientCase[]) => { let pc: IPatientCase = this.patientCase = cases.filter((c: IPatientCase) => { return c.ReportType === 'Diet'})[0]; // todo fix let status = pc.ReportStatus.toUpperCase(); if (pc.TestName === 'WellnessNutrition-DietV2') { if (pc.ReportStatus === 'REPORT AVAILABLE') { this.openUrl('#diet/dashboard'); } else if (status === 'REPORT AVAILABLE TO HEALTH PROFESSIONAL') { this.state = 'tga' } else { this.state = 'processing' } } else if (pc.TestName === 'WellnessNutrition-DietReport') { this.state = 'dietv1' } else if (pc.TestName === 'WeightManagementReport') { if (status === 'REPORT AVAILABLE') { this.state = 'complete' } else if (status === 'REPORT AVAILABLE TO HEALTH PROFESSIONAL') { this.state = 'tga'; } else { this.state = 'processing'; } } this.loaded = true; }); } private openUrl(url: string, newWindow: boolean = false) { window.open(url, newWindow ? "_blank" : "_self"); } openBooking() { this.openUrl('https://app.acuityscheduling.com/schedule.php?owner=14769732', false); } downloadReport() { this.patientService.download(this.patientCase.OrderNumber, this.patientCase.OrderNumber); } } angular.module('app').controller('dietBasicCtrl', Controller); }