consumerportal
Version:
mydna Custimised for you
183 lines (152 loc) • 4.22 kB
text/typescript
/// <reference path="../../includes.ts" />
module appMemorySrvc {
export interface IMemoryKeys {
patientCases:string;
}
export interface IAppMemoryService {
/*
the generic flags methods can be used for any temp memory
so far it is used to identitfy if the path transition was valid.
*/
setGenericFlag(val: boolean): any;
getGenericFlag(): any;
setUserInfo(val: any): any;
getUserInfo(): any;
setRegistrationUserinfo(data: any): any;
getRegistrationUserinfo(): any;
setLoginPageMessage(data: any):any;
getLoginPageMessage(): any;
setContactDetails(data: any):any;
getContactDetails():any;
setEmailPreferences(data:any):any;
getEmailPreferences():any;
getFutureMedicationsFromMemory():any;
setFutureMedicationsToMemory(data:any):any;
clearAllMemory():any;
setPatientMedicationsToMemory(data:any):any;
getPatientMedicationsFromMemory():any;
setNews(data:any):any;
getNews():any;
getPatientGenoTypesFromMemory():any;
setPatientGenoTypesToMemory(data:any):any;
getSelectedMedicationCat():any;
setSelectedMedicationCat(name:string):void;
}
export class AppMemoryService implements IAppMemoryService {
static $inject = [
'$rootScope'
];
GenericFlagValue: boolean;
UserInfo: any;
RegistrationUserinfo: any;
LoginPageMessage: any;
ContactDetails:any;
EmailPreferences:any;
FutureMedicationsInMemory:any;
PatientMedicationsInMemory:any;
News:any;
PatientGenoTypes:any;
SelectedMedicationCat:string;
/*
//LoginPageMessage
{
sourceRoute: '', where you are sending the object from can be used for debugging
description : '', description message like on signin successfull
body: "" this is the message that will be displayed for the user
}
*/
constructor($rootScope: angular.IRootScopeService) {
const vm = this;
vm.GenericFlagValue = false;
vm.UserInfo = "";
vm.LoginPageMessage = {
status: false
};
$rootScope.$on('changeUser', () => {
this.clearAllMemory();
});
}
setGenericFlag(val) {
this.GenericFlagValue = val;
}
getGenericFlag() {
return this.GenericFlagValue;
}
setUserInfo(data) {
this.UserInfo = data;
}
getUserInfo() {
return this.UserInfo;
}
setRegistrationUserinfo(data) {
this.RegistrationUserinfo = data;
}
getRegistrationUserinfo() {
return this.RegistrationUserinfo;
}
setLoginPageMessage(data) {
this.LoginPageMessage = data;
}
getLoginPageMessage() {
return this.LoginPageMessage;
}
setContactDetails(data){
this.ContactDetails = data;
}
getContactDetails(){
return this.ContactDetails;
}
setEmailPreferences(data){
this.EmailPreferences = data;
}
getEmailPreferences(){
return this.EmailPreferences;
}
setFutureMedicationsToMemory(data){
this.FutureMedicationsInMemory = data;
}
getFutureMedicationsFromMemory(){
return this.FutureMedicationsInMemory;
}
setPatientMedicationsToMemory(data){
this.PatientMedicationsInMemory = data;
}
getPatientMedicationsFromMemory(){
return this.PatientMedicationsInMemory;
}
setSelectedMedicationCat(data) {
this.SelectedMedicationCat = data;
}
getSelectedMedicationCat(){
return this.SelectedMedicationCat;
}
setNews(data){
this.News = data;
}
getNews(){
return this.News;
}
setPatientGenoTypesToMemory(data){
this.PatientGenoTypes = data;
}
getPatientGenoTypesFromMemory(){
return this.PatientGenoTypes;
}
clearAllMemory(){
this.GenericFlagValue = false;
this.UserInfo = "";
this.RegistrationUserinfo = "";
//this.LoginPageMessage = "" ;
this.ContactDetails = "" ;
this.EmailPreferences = "";
this.FutureMedicationsInMemory ="";
this.PatientMedicationsInMemory="";
this.News="";
this.PatientGenoTypes="";
//this.SelectedMedicationCat = null;
}
}
angular
.module('appMemorySrvc', [])
.service('appMemorySrvc', AppMemoryService);
}