consumerportal
Version:
mydna Custimised for you
98 lines (83 loc) • 3.04 kB
text/typescript
/// <reference path="../../includes.ts" />
module medsBrowserCtrl{
import IMedicationService = services.IMedicationService;
import IFutureMedication = services.IFutureMedication;
import IPatientMedication = services.IPatientMedication;
import IModalService = app.IModalService;
interface IMedsBrowserController {
getFutureMedications(): any;
showMeds(k: any): any;
showMedDetails(medId: any, alerType:any, category: string): any;
}
interface IMedsBrowserScope extends angular.IScope {
$sce: angular.ISCEService;
}
class MedsBrowserController implements IMedsBrowserController {
static $inject = [
'mydnaApis',
'errorHandlerSrvc',
'apiSrvc',
'scrollerSrvc',
'$scope',
'locationSrvc',
'$sce',
'appMemorySrvc',
'medicationService',
'modalService'
];
FutureMedications: IFutureMedication;
frm: any = {};
selectedMedicines: any;
Disclaimer: string;
ModalMedicine: any;
constructor(
private mydnaApis: ImyDNAApis,
private errorHandlerSrvc: errorHandlerSrvc.IErrorHandlerService,
private apiSrvc: apiSrvc.IApiService,
private scrollerSrvc: scrollerSrvc.IScrollerService,
private $scope: IMedsBrowserScope,
private locationSrvc: locationSrvc.ILocationService,
private $sce: angular.ISCEService,
private appMemorySrvc: appMemorySrvc.IAppMemoryService,
private medicationService: IMedicationService,
private modalService: IModalService
){
const vm = this;
vm.selectedMedicines = this.appMemorySrvc.getSelectedMedicationCat() || {};
vm.Disclaimer = "";
vm.ModalMedicine = null;
$scope.$sce = $sce;
this.getFutureMedications();
}
getFutureMedications(){
this.$scope.$emit("disable-on-save-on");
this.medicationService.future().then((values: IFutureMedication) => {
this.FutureMedications = values;
this.frm.Category = this.FutureMedications.Categories[0];
this.showMeds(this.frm.Category);
this.Disclaimer = this.mydnaApis.MedsDisclaimer;
this.$scope.$emit("disable-on-save-off");
});
}
showMedDetails(medId, alertType, category: string){
this.ModalMedicine = null;
this.$scope.$emit("disable-on-save-on");
this.medicationService.medication(medId).then((data: IPatientMedication) => {
this.$scope.$emit("disable-on-save-off");
let med: any = data.Medication;
this.modalService.add('modal-notification', {
title: med.DisplayName,
content: `
<p>${med.CommonUsage}</p>
<div class="title">Impact of test results:</div>
<p>${data.Comment}</p>`
});
});
}
showMeds(key) {
this.frm.Category = key;
this.selectedMedicines = this.frm.Category;
}
}
angular.module('app').controller('medsBrowserCtrl', MedsBrowserController);
}