{"version":3,"sources":["webpack:///src/C:/BuildAgent/work/709799f7b218f10/src/pages/patients/patients-dashboard/patients-census-status.ts","webpack:///./src/pages/patients/patients-dashboard/patients-census-status.html"],"names":["PatientsCensusStatus","patientService","router","toastrService","bindingEngine","selectedBranches","isLoading","isError","statusCensus","isAuthorized","patientReportsRoutes","hasPermission","this","_patientService","_router","_toastrService","_bindingEngine","initSubscriptions","getStatusCensus","_locationSubscription","collectionObserver","subscribe","status","change","Math","abs","Number","selectedStatusId","params","statuses","toString","locationIds","queryString","navigate","error","title","message","url","window","open","dispose","defaultBinding","toView","module","exports"],"mappings":"0/CAmBaA,EAAb,WAeI,WACIC,EACAC,EACAC,EACAC,I,4FAA4B,SAjBzB,KAAAC,iBAA6B,GAM7B,KAAAC,WAAqB,EACrB,KAAAC,SAAmB,EACnB,KAAAC,aAAgC,GAChC,KAAAC,cAAwB,EACxB,KAAAC,qBAAsC,uBACtC,KAAAC,eAAyB,EAQ5BC,KAAKC,gBAAkBZ,EACvBW,KAAKE,QAAUZ,EACfU,KAAKG,eAAiBZ,EACtBS,KAAKI,eAAiBZ,CACzB,C,UAzBL,O,EAAA,E,EAAA,kCA4BQQ,KAAKK,oBACLL,KAAKM,iBACR,GA9BL,0CAgC4B,WACpBN,KAAKO,sBAAwBP,KAAKI,eAAeI,mBAAmBR,KAAKP,kBAAkBgB,WAAU,WACjG,EAAKH,iBACR,GACJ,GApCL,wC,8JAwCYN,KAAKL,SAAU,EACfK,KAAKH,cAAe,EACpBG,KAAKN,WAAY,GACXM,KAAKC,gB,gBACa,O,SAAMD,KAAKC,gBAAgBK,gBAAgBN,KAAKP,kB,OAApEO,KAAKJ,a,sEAGTI,KAAKL,SAAU,EACE,MAAb,KAAEe,SACFV,KAAKH,cAAe,G,8BAIxBG,KAAKN,WAAY,E,4EAExB,GAvDL,wCAyD6BiB,GACrB,OAAOC,KAAKC,IAAIC,OAAOH,GAC1B,GA3DL,6CA6DkCI,GAC1B,GAAIA,EAAkB,CAClB,IAAIC,EAAkC,CAClCC,SAAU,CAACF,EAAiBG,YAC5BC,YAAanB,KAAKP,kBAElB2B,EAAc,2BAAiBJ,GACnChB,KAAKE,QAAQmB,SAAb,oDAAmED,GACtE,MACGpB,KAAKG,eAAemB,MAAM,CACtBC,MAAO,QACPC,QAAS,gEAGpB,GA3EL,iDA8EQ,IAAIR,EAAS,CACTG,YAAanB,KAAKP,kBAElB2B,EAAc,2BAAiBJ,GAC/BS,EAAM,6CAAH,OAAgDL,GACvDM,OAAOC,KAAKF,EACf,GApFL,iC,MAuFkC,QAA1B,EAAAzB,KAAKO,6BAAqB,SAAEqB,SAC/B,I,8BAxFL,KAEI,GADC,mBAAS,CAAEC,eAAgB,cAAYC,S,+DAD/B1C,EAAoB,GAFhC,wBAAc,0BACd,a,uBAiBsC,mB,OAAA,IAAf,sCAAe,SACjB,mBADiB,OACjB,IAAN,oBAAM,SACc,mBADd,OACc,IAAb,kCAAa,SACA,mBADA,OACA,IAAb,kCAAa,YAnBvBA,E,gFCnBb2C,EAAOC,QAAU,4wG","file":"chunk.0979a3c4105e65e47b87.js","sourcesContent":["import {\r\n bindable,\r\n bindingMode,\r\n BindingEngine,\r\n Disposable,\r\n autoinject,\r\n buildQueryString,\r\n customElement\r\n} from \"aurelia-framework\";\r\nimport { Router, RouteConfig } from \"aurelia-router\";\r\n\r\nimport { IGetCensusByStatusQuery } from \"../../../interfaces/i-census-by-status\";\r\nimport { IStatusCensus } from \"../../../interfaces/i-get-patient\";\r\nimport { PatientsService } from \"../../../services/patient-service\";\r\nimport { ToastrService } from \"../../../services/toastr-service\";\r\nimport { patientReportsRoutes } from \"../../reports/patient-reports/patient-reports-routes\";\r\n\r\n@customElement(\"patients-census-status\")\r\n@autoinject\r\nexport class PatientsCensusStatus {\r\n @bindable({ defaultBinding: bindingMode.toView })\r\n public selectedBranches: string[] = [];\r\n private readonly _patientService: PatientsService;\r\n private _router: Router;\r\n private _toastrService: ToastrService;\r\n private _locationSubscription: Disposable;\r\n private _bindingEngine: BindingEngine;\r\n public isLoading: boolean = false;\r\n public isError: boolean = false;\r\n public statusCensus: IStatusCensus[] = [];\r\n public isAuthorized: boolean = true;\r\n public patientReportsRoutes: RouteConfig[] = patientReportsRoutes;\r\n public hasPermission: boolean = false;\r\n\r\n public constructor(\r\n patientService: PatientsService,\r\n router: Router,\r\n toastrService: ToastrService,\r\n bindingEngine: BindingEngine\r\n ) {\r\n this._patientService = patientService;\r\n this._router = router;\r\n this._toastrService = toastrService;\r\n this._bindingEngine = bindingEngine;\r\n }\r\n\r\n public attached() {\r\n this.initSubscriptions();\r\n this.getStatusCensus();\r\n }\r\n\r\n public initSubscriptions() {\r\n this._locationSubscription = this._bindingEngine.collectionObserver(this.selectedBranches).subscribe(() => {\r\n this.getStatusCensus();\r\n });\r\n }\r\n\r\n public async getStatusCensus() {\r\n try {\r\n this.isError = false;\r\n this.isAuthorized = true;\r\n this.isLoading = true;\r\n if (!!this._patientService) {\r\n this.statusCensus = await this._patientService.getStatusCensus(this.selectedBranches);\r\n }\r\n } catch (e) {\r\n this.isError = true;\r\n if (e.status === 403) {\r\n this.isAuthorized = false;\r\n }\r\n throw e;\r\n } finally {\r\n this.isLoading = false;\r\n }\r\n }\r\n\r\n public getPositiveChange(change: number) {\r\n return Math.abs(Number(change));\r\n }\r\n\r\n public navigateToStatusReport(selectedStatusId: string) {\r\n if (selectedStatusId) {\r\n let params: IGetCensusByStatusQuery = {\r\n statuses: [selectedStatusId.toString()],\r\n locationIds: this.selectedBranches\r\n };\r\n let queryString = buildQueryString(params);\r\n this._router.navigate(`/reports/patient-reports/census-by-status?${queryString}`);\r\n } else {\r\n this._toastrService.error({\r\n title: \"Error\",\r\n message: \"There was a problem while redirecting you. Please report it.\"\r\n });\r\n }\r\n }\r\n\r\n public navigateToViewReportLink() {\r\n let params = {\r\n locationIds: this.selectedBranches\r\n };\r\n let queryString = buildQueryString(params);\r\n let url = `/reports/patient-reports/census-by-status?${queryString}`;\r\n window.open(url);\r\n }\r\n\r\n public detached() {\r\n this._locationSubscription?.dispose();\r\n }\r\n}\r\n","module.exports = \"\\r\\n\";"],"sourceRoot":""}