diff --git a/src/app/data-analytics-dashboard/hiv/data-analytics-hiv.module.ts b/src/app/data-analytics-dashboard/hiv/data-analytics-hiv.module.ts index f0664f9b7..d370a3a9e 100644 --- a/src/app/data-analytics-dashboard/hiv/data-analytics-hiv.module.ts +++ b/src/app/data-analytics-dashboard/hiv/data-analytics-hiv.module.ts @@ -44,6 +44,16 @@ import { TxMmdReportComponent } from './datim-reports/tx-mmd-report.component'; import { TxRttReportComponent } from './datim-reports/tx-rtt-report.component'; import { AhdReportComponent } from './ahd-report/ahd-report.component'; import { PlhivNcdV2ReportComponent } from './plhiv-ncd-v2-report/plhiv-ncd-v2-report.component'; +import { RegistersComponent } from './registers/registers.component'; +import { HeiRegisterComponent } from './registers/hei-register/hei-register.component'; +import { AncRegisterComponent } from './registers/anc-register/anc-register.component'; +import { NutritionRegisterComponent } from './registers/nutrition-register/nutrition-register.component'; +import { MaternityRegisterComponent } from './registers/maternity-register/maternity-register.component'; +import { HtsrefferallinkageRegisterComponent } from './registers/htsrefferallinkage-register/htsrefferallinkage-register.component'; +import { PncRegisterComponent } from './registers/pnc-register/pnc-register.component'; +import { DefaultertracingRegisterComponent } from './registers/defaultertracing-register/defaultertracing-register.component'; +import { PrepdailyRegisterComponent } from './registers/prepdaily-register/prepdaily-register.component'; +import { CntdailyRegisterComponent } from './registers/cntdaily-register/cntdaily-register.component'; @NgModule({ imports: [ @@ -97,7 +107,17 @@ import { PlhivNcdV2ReportComponent } from './plhiv-ncd-v2-report/plhiv-ncd-v2-re TxMmdReportComponent, TxRttReportComponent, PlhivNcdV2ReportComponent, - AhdReportComponent + AhdReportComponent, + RegistersComponent, + HeiRegisterComponent, + AncRegisterComponent, + NutritionRegisterComponent, + MaternityRegisterComponent, + HtsrefferallinkageRegisterComponent, + PncRegisterComponent, + DefaultertracingRegisterComponent, + PrepdailyRegisterComponent, + CntdailyRegisterComponent ], providers: [ DataAnalyticsDashboardService, diff --git a/src/app/data-analytics-dashboard/hiv/data-analytics-hiv.routes.ts b/src/app/data-analytics-dashboard/hiv/data-analytics-hiv.routes.ts index e9e7a5919..cd482d7c5 100644 --- a/src/app/data-analytics-dashboard/hiv/data-analytics-hiv.routes.ts +++ b/src/app/data-analytics-dashboard/hiv/data-analytics-hiv.routes.ts @@ -57,6 +57,16 @@ import { AhdReportComponent } from './ahd-report/ahd-report.component'; import { AhdMonthlyReportPatientlistComponent } from 'src/app/hiv-care-lib/ahd-monthly-report/ahd-monthly-report-patientlist/ahd-monthly-report-patientlist.component'; import { PlhivNcdV2ReportPatientListComponent } from 'src/app/hiv-care-lib/plhiv-ncd-v2-report/plhiv-ncd-v2-report-patient-list/plhiv-ncd-v2-report-patient-list.component'; import { PlhivNcdV2ReportComponent } from './plhiv-ncd-v2-report/plhiv-ncd-v2-report.component'; +import { RegistersComponent } from './registers/registers.component'; +import { HeiRegisterComponent } from './registers/hei-register/hei-register.component'; +import { AncRegisterComponent } from './registers/anc-register/anc-register.component'; +import { NutritionRegisterComponent } from './registers/nutrition-register/nutrition-register.component'; +import { MaternityRegisterComponent } from './registers/maternity-register/maternity-register.component'; +import { HtsrefferallinkageRegisterComponent } from './registers/htsrefferallinkage-register/htsrefferallinkage-register.component'; +import { PncRegisterComponent } from './registers/pnc-register/pnc-register.component'; +import { DefaultertracingRegisterComponent } from './registers/defaultertracing-register/defaultertracing-register.component'; +import { PrepdailyRegisterComponent } from './registers/prepdaily-register/prepdaily-register.component'; +import { CntdailyRegisterComponent } from './registers/cntdaily-register/cntdaily-register.component'; const routes: Routes = [ { @@ -285,6 +295,96 @@ const routes: Routes = [ } ] }, + { + path: 'registers', + children: [ + { + path: '', + component: RegistersComponent + }, + { + path: 'hei-register', + children: [ + { + path: '', + component: HeiRegisterComponent + } + ] + }, + { + path: 'anc-register', + children: [ + { + path: '', + component: AncRegisterComponent + } + ] + }, + { + path: 'nutrition-register', + children: [ + { + path: '', + component: NutritionRegisterComponent + } + ] + }, + { + path: 'maternity-register', + children: [ + { + path: '', + component: MaternityRegisterComponent + } + ] + }, + { + path: 'htsrefferallinkage-register', + children: [ + { + path: '', + component: HtsrefferallinkageRegisterComponent + } + ] + }, + { + path: 'pnc-register', + children: [ + { + path: '', + component: PncRegisterComponent + } + ] + }, + { + path: 'defaultertracing-register', + children: [ + { + path: '', + component: DefaultertracingRegisterComponent + } + ] + }, + { + path: 'prepdaily-register', + children: [ + { + path: '', + component: PrepdailyRegisterComponent + } + ] + }, + { + path: 'cntdaily-register', + children: [ + { + path: '', + component: CntdailyRegisterComponent + } + ] + } + ] + }, { path: 'datim-report', children: [ diff --git a/src/app/data-analytics-dashboard/hiv/registers/anc-register/anc-register.component.css b/src/app/data-analytics-dashboard/hiv/registers/anc-register/anc-register.component.css new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/data-analytics-dashboard/hiv/registers/anc-register/anc-register.component.html b/src/app/data-analytics-dashboard/hiv/registers/anc-register/anc-register.component.html new file mode 100644 index 000000000..40a18d212 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/anc-register/anc-register.component.html @@ -0,0 +1,54 @@ +

+ {{ reportName }} +

+ +
+ Loading... +
+ + +
+ + + + +
+
+ +
+ × +

+ An + error occurred while trying to load the report. Please try again. +

+

+ {{ errorMessage }} +

+
+
+ Viewing a Draft Version of the Report for the chosen month. + This report is likely to change without warning. +
+
+ + + + + +
diff --git a/src/app/data-analytics-dashboard/hiv/registers/anc-register/anc-register.component.spec.ts b/src/app/data-analytics-dashboard/hiv/registers/anc-register/anc-register.component.spec.ts new file mode 100644 index 000000000..dc9a601fd --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/anc-register/anc-register.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AncRegisterComponent } from './anc-register.component'; + +describe('AncRegisterComponent', () => { + let component: AncRegisterComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [AncRegisterComponent] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AncRegisterComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/data-analytics-dashboard/hiv/registers/anc-register/anc-register.component.ts b/src/app/data-analytics-dashboard/hiv/registers/anc-register/anc-register.component.ts new file mode 100644 index 000000000..661cc2895 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/anc-register/anc-register.component.ts @@ -0,0 +1,161 @@ +import { Component, OnInit, Output } from '@angular/core'; +import { Router, ActivatedRoute } from '@angular/router'; +import * as _ from 'lodash'; +import * as Moment from 'moment'; +@Component({ + selector: 'app-anc-register', + templateUrl: './anc-register.component.html', + styleUrls: ['./anc-register.component.css'] +}) +export class AncRegisterComponent implements OnInit { + @Output() + public params: any; + public indicators: string; + public selectedIndicators = []; + public txnewReportSummaryData: any = []; + public columnDefs: any = []; + public reportName = 'ANC Register'; + public currentView = 'monthly'; + public currentViewBelow = 'pdf'; + public month: string; + public year: number; + public quarter: string; + public eDate: string; + public sDate: string; + + public statusError = false; + public errorMessage = ''; + public showInfoMessage = false; + public isLoading = false; + public reportHead: any; + public enabledControls = 'locationControl,monthControl'; + public pinnedBottomRowData: any = []; + public _month: string; + public isReleased = true; + + public _locationUuids: any = []; + public get locationUuids(): Array { + return this._locationUuids; + } + + public set locationUuids(v: Array) { + const locationUuids = []; + _.each(v, (location: any) => { + if (location.value) { + locationUuids.push(location); + } + }); + this._locationUuids = locationUuids; + } + + constructor(public router: Router, public route: ActivatedRoute) { + this.route.queryParams.subscribe((data) => { + data.month === undefined + ? (this._month = Moment() + .subtract(1, 'M') + .endOf('month') + .format('YYYY-MM-DD')) + : (this._month = data.month); + + this.showDraftReportAlert(this._month); + }); + } + + ngOnInit() {} + + public onMonthChange(value): any { + this._month = Moment(value).endOf('month').format('YYYY-MM-DD'); + } + + public generateReport(): any { + this.route.parent.parent.params.subscribe((params: any) => { + this.storeParamsInUrl(params.location_uuid); + }); + this.txnewReportSummaryData = []; + // this.getTxNewReport(this.params); + } + + public storeParamsInUrl(param) { + this.params = { + locationUuids: param, + _month: Moment(this._month).endOf('month').format('YYYY-MM-DD'), + month: Moment(this._month).endOf('month').format('YYYY-MM-DD'), + reportName: this.reportName, + _date: Moment(this._month).format('DD-MM-YYYY') + }; + this.router.navigate([], { + relativeTo: this.route, + queryParams: this.params + }); + } + + // public getTxNewReport(params: any) { + // this.isLoading = true; + // this.txnewReport.getTxNewReport(params).subscribe((data) => { + // if (data.error) { + // this.showInfoMessage = true; + // this.errorMessage = `There has been an error while loading the report, please retry again`; + // this.isLoading = false; + // } else { + // this.showInfoMessage = false; + // this.columnDefs = data.sectionDefinitions; + // this.txnewReportSummaryData = data.result; + // this.calculateTotalSummary(); + // this.isLoading = false; + // this.showDraftReportAlert(this._month); + // } + // }); + // } + + public calculateTotalSummary() { + const totalsRow = []; + if (this.txnewReportSummaryData.length > 0) { + const totalObj = { + location: 'Totals' + }; + _.each(this.txnewReportSummaryData, (row) => { + Object.keys(row).map((key) => { + if (Number.isInteger(row[key]) === true) { + if (totalObj[key]) { + totalObj[key] = row[key] + totalObj[key]; + } else { + totalObj[key] = row[key]; + } + } else { + if (Number.isNaN(totalObj[key])) { + totalObj[key] = 0; + } + if (totalObj[key] === null) { + totalObj[key] = 0; + } + totalObj[key] = 0 + totalObj[key]; + } + }); + }); + totalObj.location = 'Totals'; + totalsRow.push(totalObj); + this.pinnedBottomRowData = totalsRow; + } + } + public onIndicatorSelected(value) { + this.router.navigate(['patient-list'], { + relativeTo: this.route, + queryParams: { + indicators: value.field, + indicatorHeader: value.headerName, + indicatorGender: value.gender, + month: this._month, + locationUuids: value.location, + currentView: this.currentView + } + }); + } + + public showDraftReportAlert(date) { + if (date != null && date >= Moment().endOf('month').format('YYYY-MM-DD')) { + this.isReleased = false; + } else { + this.isReleased = true; + } + } +} diff --git a/src/app/data-analytics-dashboard/hiv/registers/cntdaily-register/cntdaily-register.component.css b/src/app/data-analytics-dashboard/hiv/registers/cntdaily-register/cntdaily-register.component.css new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/data-analytics-dashboard/hiv/registers/cntdaily-register/cntdaily-register.component.html b/src/app/data-analytics-dashboard/hiv/registers/cntdaily-register/cntdaily-register.component.html new file mode 100644 index 000000000..40a18d212 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/cntdaily-register/cntdaily-register.component.html @@ -0,0 +1,54 @@ +

+ {{ reportName }} +

+ +
+ Loading... +
+ + +
+ + + + +
+
+ +
+ × +

+ An + error occurred while trying to load the report. Please try again. +

+

+ {{ errorMessage }} +

+
+
+ Viewing a Draft Version of the Report for the chosen month. + This report is likely to change without warning. +
+
+ + + + + +
diff --git a/src/app/data-analytics-dashboard/hiv/registers/cntdaily-register/cntdaily-register.component.spec.ts b/src/app/data-analytics-dashboard/hiv/registers/cntdaily-register/cntdaily-register.component.spec.ts new file mode 100644 index 000000000..afa8dd874 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/cntdaily-register/cntdaily-register.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CntdailyRegisterComponent } from './cntdaily-register.component'; + +describe('CntdailyRegisterComponent', () => { + let component: CntdailyRegisterComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [CntdailyRegisterComponent] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CntdailyRegisterComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/data-analytics-dashboard/hiv/registers/cntdaily-register/cntdaily-register.component.ts b/src/app/data-analytics-dashboard/hiv/registers/cntdaily-register/cntdaily-register.component.ts new file mode 100644 index 000000000..ac6aed7de --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/cntdaily-register/cntdaily-register.component.ts @@ -0,0 +1,161 @@ +import { Component, OnInit, Output } from '@angular/core'; +import { Router, ActivatedRoute } from '@angular/router'; +import * as _ from 'lodash'; +import * as Moment from 'moment'; +@Component({ + selector: 'app-cntdaily-register', + templateUrl: './cntdaily-register.component.html', + styleUrls: ['./cntdaily-register.component.css'] +}) +export class CntdailyRegisterComponent implements OnInit { + @Output() + public params: any; + public indicators: string; + public selectedIndicators = []; + public txnewReportSummaryData: any = []; + public columnDefs: any = []; + public reportName = 'Care and Treatment Daily Activity'; + public currentView = 'monthly'; + public currentViewBelow = 'pdf'; + public month: string; + public year: number; + public quarter: string; + public eDate: string; + public sDate: string; + + public statusError = false; + public errorMessage = ''; + public showInfoMessage = false; + public isLoading = false; + public reportHead: any; + public enabledControls = 'locationControl,monthControl'; + public pinnedBottomRowData: any = []; + public _month: string; + public isReleased = true; + + public _locationUuids: any = []; + public get locationUuids(): Array { + return this._locationUuids; + } + + public set locationUuids(v: Array) { + const locationUuids = []; + _.each(v, (location: any) => { + if (location.value) { + locationUuids.push(location); + } + }); + this._locationUuids = locationUuids; + } + + constructor(public router: Router, public route: ActivatedRoute) { + this.route.queryParams.subscribe((data) => { + data.month === undefined + ? (this._month = Moment() + .subtract(1, 'M') + .endOf('month') + .format('YYYY-MM-DD')) + : (this._month = data.month); + + this.showDraftReportAlert(this._month); + }); + } + + ngOnInit() {} + + public onMonthChange(value): any { + this._month = Moment(value).endOf('month').format('YYYY-MM-DD'); + } + + public generateReport(): any { + this.route.parent.parent.params.subscribe((params: any) => { + this.storeParamsInUrl(params.location_uuid); + }); + this.txnewReportSummaryData = []; + // this.getTxNewReport(this.params); + } + + public storeParamsInUrl(param) { + this.params = { + locationUuids: param, + _month: Moment(this._month).endOf('month').format('YYYY-MM-DD'), + month: Moment(this._month).endOf('month').format('YYYY-MM-DD'), + reportName: this.reportName, + _date: Moment(this._month).format('DD-MM-YYYY') + }; + this.router.navigate([], { + relativeTo: this.route, + queryParams: this.params + }); + } + + // public getTxNewReport(params: any) { + // this.isLoading = true; + // this.txnewReport.getTxNewReport(params).subscribe((data) => { + // if (data.error) { + // this.showInfoMessage = true; + // this.errorMessage = `There has been an error while loading the report, please retry again`; + // this.isLoading = false; + // } else { + // this.showInfoMessage = false; + // this.columnDefs = data.sectionDefinitions; + // this.txnewReportSummaryData = data.result; + // this.calculateTotalSummary(); + // this.isLoading = false; + // this.showDraftReportAlert(this._month); + // } + // }); + // } + + public calculateTotalSummary() { + const totalsRow = []; + if (this.txnewReportSummaryData.length > 0) { + const totalObj = { + location: 'Totals' + }; + _.each(this.txnewReportSummaryData, (row) => { + Object.keys(row).map((key) => { + if (Number.isInteger(row[key]) === true) { + if (totalObj[key]) { + totalObj[key] = row[key] + totalObj[key]; + } else { + totalObj[key] = row[key]; + } + } else { + if (Number.isNaN(totalObj[key])) { + totalObj[key] = 0; + } + if (totalObj[key] === null) { + totalObj[key] = 0; + } + totalObj[key] = 0 + totalObj[key]; + } + }); + }); + totalObj.location = 'Totals'; + totalsRow.push(totalObj); + this.pinnedBottomRowData = totalsRow; + } + } + public onIndicatorSelected(value) { + this.router.navigate(['patient-list'], { + relativeTo: this.route, + queryParams: { + indicators: value.field, + indicatorHeader: value.headerName, + indicatorGender: value.gender, + month: this._month, + locationUuids: value.location, + currentView: this.currentView + } + }); + } + + public showDraftReportAlert(date) { + if (date != null && date >= Moment().endOf('month').format('YYYY-MM-DD')) { + this.isReleased = false; + } else { + this.isReleased = true; + } + } +} diff --git a/src/app/data-analytics-dashboard/hiv/registers/defaultertracing-register/defaultertracing-register.component.css b/src/app/data-analytics-dashboard/hiv/registers/defaultertracing-register/defaultertracing-register.component.css new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/data-analytics-dashboard/hiv/registers/defaultertracing-register/defaultertracing-register.component.html b/src/app/data-analytics-dashboard/hiv/registers/defaultertracing-register/defaultertracing-register.component.html new file mode 100644 index 000000000..40a18d212 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/defaultertracing-register/defaultertracing-register.component.html @@ -0,0 +1,54 @@ +

+ {{ reportName }} +

+ +
+ Loading... +
+ + +
+ + + + +
+
+ +
+ × +

+ An + error occurred while trying to load the report. Please try again. +

+

+ {{ errorMessage }} +

+
+
+ Viewing a Draft Version of the Report for the chosen month. + This report is likely to change without warning. +
+
+ + + + + +
diff --git a/src/app/data-analytics-dashboard/hiv/registers/defaultertracing-register/defaultertracing-register.component.spec.ts b/src/app/data-analytics-dashboard/hiv/registers/defaultertracing-register/defaultertracing-register.component.spec.ts new file mode 100644 index 000000000..85c755813 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/defaultertracing-register/defaultertracing-register.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { DefaultertracingRegisterComponent } from './defaultertracing-register.component'; + +describe('DefaultertracingRegisterComponent', () => { + let component: DefaultertracingRegisterComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [DefaultertracingRegisterComponent] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(DefaultertracingRegisterComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/data-analytics-dashboard/hiv/registers/defaultertracing-register/defaultertracing-register.component.ts b/src/app/data-analytics-dashboard/hiv/registers/defaultertracing-register/defaultertracing-register.component.ts new file mode 100644 index 000000000..83b012c91 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/defaultertracing-register/defaultertracing-register.component.ts @@ -0,0 +1,161 @@ +import { Component, OnInit, Output } from '@angular/core'; +import { Router, ActivatedRoute } from '@angular/router'; +import * as _ from 'lodash'; +import * as Moment from 'moment'; +@Component({ + selector: 'app-defaultertracing-register', + templateUrl: './defaultertracing-register.component.html', + styleUrls: ['./defaultertracing-register.component.css'] +}) +export class DefaultertracingRegisterComponent implements OnInit { + @Output() + public params: any; + public indicators: string; + public selectedIndicators = []; + public txnewReportSummaryData: any = []; + public columnDefs: any = []; + public reportName = 'Defaulter Tracing Register'; + public currentView = 'monthly'; + public currentViewBelow = 'pdf'; + public month: string; + public year: number; + public quarter: string; + public eDate: string; + public sDate: string; + + public statusError = false; + public errorMessage = ''; + public showInfoMessage = false; + public isLoading = false; + public reportHead: any; + public enabledControls = 'locationControl,monthControl'; + public pinnedBottomRowData: any = []; + public _month: string; + public isReleased = true; + + public _locationUuids: any = []; + public get locationUuids(): Array { + return this._locationUuids; + } + + public set locationUuids(v: Array) { + const locationUuids = []; + _.each(v, (location: any) => { + if (location.value) { + locationUuids.push(location); + } + }); + this._locationUuids = locationUuids; + } + + constructor(public router: Router, public route: ActivatedRoute) { + this.route.queryParams.subscribe((data) => { + data.month === undefined + ? (this._month = Moment() + .subtract(1, 'M') + .endOf('month') + .format('YYYY-MM-DD')) + : (this._month = data.month); + + this.showDraftReportAlert(this._month); + }); + } + + ngOnInit() {} + + public onMonthChange(value): any { + this._month = Moment(value).endOf('month').format('YYYY-MM-DD'); + } + + public generateReport(): any { + this.route.parent.parent.params.subscribe((params: any) => { + this.storeParamsInUrl(params.location_uuid); + }); + this.txnewReportSummaryData = []; + // this.getTxNewReport(this.params); + } + + public storeParamsInUrl(param) { + this.params = { + locationUuids: param, + _month: Moment(this._month).endOf('month').format('YYYY-MM-DD'), + month: Moment(this._month).endOf('month').format('YYYY-MM-DD'), + reportName: this.reportName, + _date: Moment(this._month).format('DD-MM-YYYY') + }; + this.router.navigate([], { + relativeTo: this.route, + queryParams: this.params + }); + } + + // public getTxNewReport(params: any) { + // this.isLoading = true; + // this.txnewReport.getTxNewReport(params).subscribe((data) => { + // if (data.error) { + // this.showInfoMessage = true; + // this.errorMessage = `There has been an error while loading the report, please retry again`; + // this.isLoading = false; + // } else { + // this.showInfoMessage = false; + // this.columnDefs = data.sectionDefinitions; + // this.txnewReportSummaryData = data.result; + // this.calculateTotalSummary(); + // this.isLoading = false; + // this.showDraftReportAlert(this._month); + // } + // }); + // } + + public calculateTotalSummary() { + const totalsRow = []; + if (this.txnewReportSummaryData.length > 0) { + const totalObj = { + location: 'Totals' + }; + _.each(this.txnewReportSummaryData, (row) => { + Object.keys(row).map((key) => { + if (Number.isInteger(row[key]) === true) { + if (totalObj[key]) { + totalObj[key] = row[key] + totalObj[key]; + } else { + totalObj[key] = row[key]; + } + } else { + if (Number.isNaN(totalObj[key])) { + totalObj[key] = 0; + } + if (totalObj[key] === null) { + totalObj[key] = 0; + } + totalObj[key] = 0 + totalObj[key]; + } + }); + }); + totalObj.location = 'Totals'; + totalsRow.push(totalObj); + this.pinnedBottomRowData = totalsRow; + } + } + public onIndicatorSelected(value) { + this.router.navigate(['patient-list'], { + relativeTo: this.route, + queryParams: { + indicators: value.field, + indicatorHeader: value.headerName, + indicatorGender: value.gender, + month: this._month, + locationUuids: value.location, + currentView: this.currentView + } + }); + } + + public showDraftReportAlert(date) { + if (date != null && date >= Moment().endOf('month').format('YYYY-MM-DD')) { + this.isReleased = false; + } else { + this.isReleased = true; + } + } +} diff --git a/src/app/data-analytics-dashboard/hiv/registers/hei-register/hei-register.component.css b/src/app/data-analytics-dashboard/hiv/registers/hei-register/hei-register.component.css new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/data-analytics-dashboard/hiv/registers/hei-register/hei-register.component.html b/src/app/data-analytics-dashboard/hiv/registers/hei-register/hei-register.component.html new file mode 100644 index 000000000..40a18d212 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/hei-register/hei-register.component.html @@ -0,0 +1,54 @@ +

+ {{ reportName }} +

+ +
+ Loading... +
+ + +
+ + + + +
+
+ +
+ × +

+ An + error occurred while trying to load the report. Please try again. +

+

+ {{ errorMessage }} +

+
+
+ Viewing a Draft Version of the Report for the chosen month. + This report is likely to change without warning. +
+
+ + + + + +
diff --git a/src/app/data-analytics-dashboard/hiv/registers/hei-register/hei-register.component.spec.ts b/src/app/data-analytics-dashboard/hiv/registers/hei-register/hei-register.component.spec.ts new file mode 100644 index 000000000..19143ac64 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/hei-register/hei-register.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { HeiRegisterComponent } from './hei-register.component'; + +describe('HeiRegisterComponent', () => { + let component: HeiRegisterComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [HeiRegisterComponent] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(HeiRegisterComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/data-analytics-dashboard/hiv/registers/hei-register/hei-register.component.ts b/src/app/data-analytics-dashboard/hiv/registers/hei-register/hei-register.component.ts new file mode 100644 index 000000000..2a9de1b47 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/hei-register/hei-register.component.ts @@ -0,0 +1,161 @@ +import { Component, OnInit, Output } from '@angular/core'; +import { Router, ActivatedRoute } from '@angular/router'; +import * as _ from 'lodash'; +import * as Moment from 'moment'; +@Component({ + selector: 'app-hei-register', + templateUrl: './hei-register.component.html', + styleUrls: ['./hei-register.component.css'] +}) +export class HeiRegisterComponent implements OnInit { + @Output() + public params: any; + public indicators: string; + public selectedIndicators = []; + public txnewReportSummaryData: any = []; + public columnDefs: any = []; + public reportName = 'HEI Register'; + public currentView = 'monthly'; + public currentViewBelow = 'pdf'; + public month: string; + public year: number; + public quarter: string; + public eDate: string; + public sDate: string; + + public statusError = false; + public errorMessage = ''; + public showInfoMessage = false; + public isLoading = false; + public reportHead: any; + public enabledControls = 'locationControl,monthControl'; + public pinnedBottomRowData: any = []; + public _month: string; + public isReleased = true; + + public _locationUuids: any = []; + public get locationUuids(): Array { + return this._locationUuids; + } + + public set locationUuids(v: Array) { + const locationUuids = []; + _.each(v, (location: any) => { + if (location.value) { + locationUuids.push(location); + } + }); + this._locationUuids = locationUuids; + } + + constructor(public router: Router, public route: ActivatedRoute) { + this.route.queryParams.subscribe((data) => { + data.month === undefined + ? (this._month = Moment() + .subtract(1, 'M') + .endOf('month') + .format('YYYY-MM-DD')) + : (this._month = data.month); + + this.showDraftReportAlert(this._month); + }); + } + + ngOnInit() {} + + public onMonthChange(value): any { + this._month = Moment(value).endOf('month').format('YYYY-MM-DD'); + } + + public generateReport(): any { + this.route.parent.parent.params.subscribe((params: any) => { + this.storeParamsInUrl(params.location_uuid); + }); + this.txnewReportSummaryData = []; + // this.getTxNewReport(this.params); + } + + public storeParamsInUrl(param) { + this.params = { + locationUuids: param, + _month: Moment(this._month).endOf('month').format('YYYY-MM-DD'), + month: Moment(this._month).endOf('month').format('YYYY-MM-DD'), + reportName: this.reportName, + _date: Moment(this._month).format('DD-MM-YYYY') + }; + this.router.navigate([], { + relativeTo: this.route, + queryParams: this.params + }); + } + + // public getTxNewReport(params: any) { + // this.isLoading = true; + // this.txnewReport.getTxNewReport(params).subscribe((data) => { + // if (data.error) { + // this.showInfoMessage = true; + // this.errorMessage = `There has been an error while loading the report, please retry again`; + // this.isLoading = false; + // } else { + // this.showInfoMessage = false; + // this.columnDefs = data.sectionDefinitions; + // this.txnewReportSummaryData = data.result; + // this.calculateTotalSummary(); + // this.isLoading = false; + // this.showDraftReportAlert(this._month); + // } + // }); + // } + + public calculateTotalSummary() { + const totalsRow = []; + if (this.txnewReportSummaryData.length > 0) { + const totalObj = { + location: 'Totals' + }; + _.each(this.txnewReportSummaryData, (row) => { + Object.keys(row).map((key) => { + if (Number.isInteger(row[key]) === true) { + if (totalObj[key]) { + totalObj[key] = row[key] + totalObj[key]; + } else { + totalObj[key] = row[key]; + } + } else { + if (Number.isNaN(totalObj[key])) { + totalObj[key] = 0; + } + if (totalObj[key] === null) { + totalObj[key] = 0; + } + totalObj[key] = 0 + totalObj[key]; + } + }); + }); + totalObj.location = 'Totals'; + totalsRow.push(totalObj); + this.pinnedBottomRowData = totalsRow; + } + } + public onIndicatorSelected(value) { + this.router.navigate(['patient-list'], { + relativeTo: this.route, + queryParams: { + indicators: value.field, + indicatorHeader: value.headerName, + indicatorGender: value.gender, + month: this._month, + locationUuids: value.location, + currentView: this.currentView + } + }); + } + + public showDraftReportAlert(date) { + if (date != null && date >= Moment().endOf('month').format('YYYY-MM-DD')) { + this.isReleased = false; + } else { + this.isReleased = true; + } + } +} diff --git a/src/app/data-analytics-dashboard/hiv/registers/htsrefferallinkage-register/htsrefferallinkage-register.component.css b/src/app/data-analytics-dashboard/hiv/registers/htsrefferallinkage-register/htsrefferallinkage-register.component.css new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/data-analytics-dashboard/hiv/registers/htsrefferallinkage-register/htsrefferallinkage-register.component.html b/src/app/data-analytics-dashboard/hiv/registers/htsrefferallinkage-register/htsrefferallinkage-register.component.html new file mode 100644 index 000000000..40a18d212 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/htsrefferallinkage-register/htsrefferallinkage-register.component.html @@ -0,0 +1,54 @@ +

+ {{ reportName }} +

+ +
+ Loading... +
+ + +
+ + + + +
+
+ +
+ × +

+ An + error occurred while trying to load the report. Please try again. +

+

+ {{ errorMessage }} +

+
+
+ Viewing a Draft Version of the Report for the chosen month. + This report is likely to change without warning. +
+
+ + + + + +
diff --git a/src/app/data-analytics-dashboard/hiv/registers/htsrefferallinkage-register/htsrefferallinkage-register.component.spec.ts b/src/app/data-analytics-dashboard/hiv/registers/htsrefferallinkage-register/htsrefferallinkage-register.component.spec.ts new file mode 100644 index 000000000..925245470 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/htsrefferallinkage-register/htsrefferallinkage-register.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { HtsrefferallinkageRegisterComponent } from './htsrefferallinkage-register.component'; + +describe('HtsrefferallinkageRegisterComponent', () => { + let component: HtsrefferallinkageRegisterComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [HtsrefferallinkageRegisterComponent] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(HtsrefferallinkageRegisterComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/data-analytics-dashboard/hiv/registers/htsrefferallinkage-register/htsrefferallinkage-register.component.ts b/src/app/data-analytics-dashboard/hiv/registers/htsrefferallinkage-register/htsrefferallinkage-register.component.ts new file mode 100644 index 000000000..503ec25fc --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/htsrefferallinkage-register/htsrefferallinkage-register.component.ts @@ -0,0 +1,161 @@ +import { Component, OnInit, Output } from '@angular/core'; +import { Router, ActivatedRoute } from '@angular/router'; +import * as _ from 'lodash'; +import * as Moment from 'moment'; +@Component({ + selector: 'app-htsrefferallinkage-register', + templateUrl: './htsrefferallinkage-register.component.html', + styleUrls: ['./htsrefferallinkage-register.component.css'] +}) +export class HtsrefferallinkageRegisterComponent implements OnInit { + @Output() + public params: any; + public indicators: string; + public selectedIndicators = []; + public txnewReportSummaryData: any = []; + public columnDefs: any = []; + public reportName = 'HTS Lab Refferal & Linkage Register'; + public currentView = 'monthly'; + public currentViewBelow = 'pdf'; + public month: string; + public year: number; + public quarter: string; + public eDate: string; + public sDate: string; + + public statusError = false; + public errorMessage = ''; + public showInfoMessage = false; + public isLoading = false; + public reportHead: any; + public enabledControls = 'locationControl,monthControl'; + public pinnedBottomRowData: any = []; + public _month: string; + public isReleased = true; + + public _locationUuids: any = []; + public get locationUuids(): Array { + return this._locationUuids; + } + + public set locationUuids(v: Array) { + const locationUuids = []; + _.each(v, (location: any) => { + if (location.value) { + locationUuids.push(location); + } + }); + this._locationUuids = locationUuids; + } + + constructor(public router: Router, public route: ActivatedRoute) { + this.route.queryParams.subscribe((data) => { + data.month === undefined + ? (this._month = Moment() + .subtract(1, 'M') + .endOf('month') + .format('YYYY-MM-DD')) + : (this._month = data.month); + + this.showDraftReportAlert(this._month); + }); + } + + ngOnInit() {} + + public onMonthChange(value): any { + this._month = Moment(value).endOf('month').format('YYYY-MM-DD'); + } + + public generateReport(): any { + this.route.parent.parent.params.subscribe((params: any) => { + this.storeParamsInUrl(params.location_uuid); + }); + this.txnewReportSummaryData = []; + // this.getTxNewReport(this.params); + } + + public storeParamsInUrl(param) { + this.params = { + locationUuids: param, + _month: Moment(this._month).endOf('month').format('YYYY-MM-DD'), + month: Moment(this._month).endOf('month').format('YYYY-MM-DD'), + reportName: this.reportName, + _date: Moment(this._month).format('DD-MM-YYYY') + }; + this.router.navigate([], { + relativeTo: this.route, + queryParams: this.params + }); + } + + // public getTxNewReport(params: any) { + // this.isLoading = true; + // this.txnewReport.getTxNewReport(params).subscribe((data) => { + // if (data.error) { + // this.showInfoMessage = true; + // this.errorMessage = `There has been an error while loading the report, please retry again`; + // this.isLoading = false; + // } else { + // this.showInfoMessage = false; + // this.columnDefs = data.sectionDefinitions; + // this.txnewReportSummaryData = data.result; + // this.calculateTotalSummary(); + // this.isLoading = false; + // this.showDraftReportAlert(this._month); + // } + // }); + // } + + public calculateTotalSummary() { + const totalsRow = []; + if (this.txnewReportSummaryData.length > 0) { + const totalObj = { + location: 'Totals' + }; + _.each(this.txnewReportSummaryData, (row) => { + Object.keys(row).map((key) => { + if (Number.isInteger(row[key]) === true) { + if (totalObj[key]) { + totalObj[key] = row[key] + totalObj[key]; + } else { + totalObj[key] = row[key]; + } + } else { + if (Number.isNaN(totalObj[key])) { + totalObj[key] = 0; + } + if (totalObj[key] === null) { + totalObj[key] = 0; + } + totalObj[key] = 0 + totalObj[key]; + } + }); + }); + totalObj.location = 'Totals'; + totalsRow.push(totalObj); + this.pinnedBottomRowData = totalsRow; + } + } + public onIndicatorSelected(value) { + this.router.navigate(['patient-list'], { + relativeTo: this.route, + queryParams: { + indicators: value.field, + indicatorHeader: value.headerName, + indicatorGender: value.gender, + month: this._month, + locationUuids: value.location, + currentView: this.currentView + } + }); + } + + public showDraftReportAlert(date) { + if (date != null && date >= Moment().endOf('month').format('YYYY-MM-DD')) { + this.isReleased = false; + } else { + this.isReleased = true; + } + } +} diff --git a/src/app/data-analytics-dashboard/hiv/registers/maternity-register/maternity-register.component.css b/src/app/data-analytics-dashboard/hiv/registers/maternity-register/maternity-register.component.css new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/data-analytics-dashboard/hiv/registers/maternity-register/maternity-register.component.html b/src/app/data-analytics-dashboard/hiv/registers/maternity-register/maternity-register.component.html new file mode 100644 index 000000000..40a18d212 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/maternity-register/maternity-register.component.html @@ -0,0 +1,54 @@ +

+ {{ reportName }} +

+ +
+ Loading... +
+ + +
+ + + + +
+
+ +
+ × +

+ An + error occurred while trying to load the report. Please try again. +

+

+ {{ errorMessage }} +

+
+
+ Viewing a Draft Version of the Report for the chosen month. + This report is likely to change without warning. +
+
+ + + + + +
diff --git a/src/app/data-analytics-dashboard/hiv/registers/maternity-register/maternity-register.component.spec.ts b/src/app/data-analytics-dashboard/hiv/registers/maternity-register/maternity-register.component.spec.ts new file mode 100644 index 000000000..1a50a56fd --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/maternity-register/maternity-register.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MaternityRegisterComponent } from './maternity-register.component'; + +describe('MaternityRegisterComponent', () => { + let component: MaternityRegisterComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [MaternityRegisterComponent] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MaternityRegisterComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/data-analytics-dashboard/hiv/registers/maternity-register/maternity-register.component.ts b/src/app/data-analytics-dashboard/hiv/registers/maternity-register/maternity-register.component.ts new file mode 100644 index 000000000..8fe1183d4 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/maternity-register/maternity-register.component.ts @@ -0,0 +1,161 @@ +import { Component, OnInit, Output } from '@angular/core'; +import { Router, ActivatedRoute } from '@angular/router'; +import * as _ from 'lodash'; +import * as Moment from 'moment'; +@Component({ + selector: 'app-maternity-register', + templateUrl: './maternity-register.component.html', + styleUrls: ['./maternity-register.component.css'] +}) +export class MaternityRegisterComponent implements OnInit { + @Output() + public params: any; + public indicators: string; + public selectedIndicators = []; + public txnewReportSummaryData: any = []; + public columnDefs: any = []; + public reportName = 'Martenity Register'; + public currentView = 'monthly'; + public currentViewBelow = 'pdf'; + public month: string; + public year: number; + public quarter: string; + public eDate: string; + public sDate: string; + + public statusError = false; + public errorMessage = ''; + public showInfoMessage = false; + public isLoading = false; + public reportHead: any; + public enabledControls = 'locationControl,monthControl'; + public pinnedBottomRowData: any = []; + public _month: string; + public isReleased = true; + + public _locationUuids: any = []; + public get locationUuids(): Array { + return this._locationUuids; + } + + public set locationUuids(v: Array) { + const locationUuids = []; + _.each(v, (location: any) => { + if (location.value) { + locationUuids.push(location); + } + }); + this._locationUuids = locationUuids; + } + + constructor(public router: Router, public route: ActivatedRoute) { + this.route.queryParams.subscribe((data) => { + data.month === undefined + ? (this._month = Moment() + .subtract(1, 'M') + .endOf('month') + .format('YYYY-MM-DD')) + : (this._month = data.month); + + this.showDraftReportAlert(this._month); + }); + } + + ngOnInit() {} + + public onMonthChange(value): any { + this._month = Moment(value).endOf('month').format('YYYY-MM-DD'); + } + + public generateReport(): any { + this.route.parent.parent.params.subscribe((params: any) => { + this.storeParamsInUrl(params.location_uuid); + }); + this.txnewReportSummaryData = []; + // this.getTxNewReport(this.params); + } + + public storeParamsInUrl(param) { + this.params = { + locationUuids: param, + _month: Moment(this._month).endOf('month').format('YYYY-MM-DD'), + month: Moment(this._month).endOf('month').format('YYYY-MM-DD'), + reportName: this.reportName, + _date: Moment(this._month).format('DD-MM-YYYY') + }; + this.router.navigate([], { + relativeTo: this.route, + queryParams: this.params + }); + } + + // public getTxNewReport(params: any) { + // this.isLoading = true; + // this.txnewReport.getTxNewReport(params).subscribe((data) => { + // if (data.error) { + // this.showInfoMessage = true; + // this.errorMessage = `There has been an error while loading the report, please retry again`; + // this.isLoading = false; + // } else { + // this.showInfoMessage = false; + // this.columnDefs = data.sectionDefinitions; + // this.txnewReportSummaryData = data.result; + // this.calculateTotalSummary(); + // this.isLoading = false; + // this.showDraftReportAlert(this._month); + // } + // }); + // } + + public calculateTotalSummary() { + const totalsRow = []; + if (this.txnewReportSummaryData.length > 0) { + const totalObj = { + location: 'Totals' + }; + _.each(this.txnewReportSummaryData, (row) => { + Object.keys(row).map((key) => { + if (Number.isInteger(row[key]) === true) { + if (totalObj[key]) { + totalObj[key] = row[key] + totalObj[key]; + } else { + totalObj[key] = row[key]; + } + } else { + if (Number.isNaN(totalObj[key])) { + totalObj[key] = 0; + } + if (totalObj[key] === null) { + totalObj[key] = 0; + } + totalObj[key] = 0 + totalObj[key]; + } + }); + }); + totalObj.location = 'Totals'; + totalsRow.push(totalObj); + this.pinnedBottomRowData = totalsRow; + } + } + public onIndicatorSelected(value) { + this.router.navigate(['patient-list'], { + relativeTo: this.route, + queryParams: { + indicators: value.field, + indicatorHeader: value.headerName, + indicatorGender: value.gender, + month: this._month, + locationUuids: value.location, + currentView: this.currentView + } + }); + } + + public showDraftReportAlert(date) { + if (date != null && date >= Moment().endOf('month').format('YYYY-MM-DD')) { + this.isReleased = false; + } else { + this.isReleased = true; + } + } +} diff --git a/src/app/data-analytics-dashboard/hiv/registers/nutrition-register/nutrition-register.component.css b/src/app/data-analytics-dashboard/hiv/registers/nutrition-register/nutrition-register.component.css new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/data-analytics-dashboard/hiv/registers/nutrition-register/nutrition-register.component.html b/src/app/data-analytics-dashboard/hiv/registers/nutrition-register/nutrition-register.component.html new file mode 100644 index 000000000..40a18d212 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/nutrition-register/nutrition-register.component.html @@ -0,0 +1,54 @@ +

+ {{ reportName }} +

+ +
+ Loading... +
+ + +
+ + + + +
+
+ +
+ × +

+ An + error occurred while trying to load the report. Please try again. +

+

+ {{ errorMessage }} +

+
+
+ Viewing a Draft Version of the Report for the chosen month. + This report is likely to change without warning. +
+
+ + + + + +
diff --git a/src/app/data-analytics-dashboard/hiv/registers/nutrition-register/nutrition-register.component.spec.ts b/src/app/data-analytics-dashboard/hiv/registers/nutrition-register/nutrition-register.component.spec.ts new file mode 100644 index 000000000..02a62ca91 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/nutrition-register/nutrition-register.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { NutritionRegisterComponent } from './nutrition-register.component'; + +describe('NutritionRegisterComponent', () => { + let component: NutritionRegisterComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [NutritionRegisterComponent] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(NutritionRegisterComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/data-analytics-dashboard/hiv/registers/nutrition-register/nutrition-register.component.ts b/src/app/data-analytics-dashboard/hiv/registers/nutrition-register/nutrition-register.component.ts new file mode 100644 index 000000000..3240e3fd1 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/nutrition-register/nutrition-register.component.ts @@ -0,0 +1,161 @@ +import { Component, OnInit, Output } from '@angular/core'; +import { Router, ActivatedRoute } from '@angular/router'; +import * as _ from 'lodash'; +import * as Moment from 'moment'; +@Component({ + selector: 'app-nutrition-register', + templateUrl: './nutrition-register.component.html', + styleUrls: ['./nutrition-register.component.css'] +}) +export class NutritionRegisterComponent implements OnInit { + @Output() + public params: any; + public indicators: string; + public selectedIndicators = []; + public txnewReportSummaryData: any = []; + public columnDefs: any = []; + public reportName = 'Nutrition Service Register'; + public currentView = 'monthly'; + public currentViewBelow = 'pdf'; + public month: string; + public year: number; + public quarter: string; + public eDate: string; + public sDate: string; + + public statusError = false; + public errorMessage = ''; + public showInfoMessage = false; + public isLoading = false; + public reportHead: any; + public enabledControls = 'locationControl,monthControl'; + public pinnedBottomRowData: any = []; + public _month: string; + public isReleased = true; + + public _locationUuids: any = []; + public get locationUuids(): Array { + return this._locationUuids; + } + + public set locationUuids(v: Array) { + const locationUuids = []; + _.each(v, (location: any) => { + if (location.value) { + locationUuids.push(location); + } + }); + this._locationUuids = locationUuids; + } + + constructor(public router: Router, public route: ActivatedRoute) { + this.route.queryParams.subscribe((data) => { + data.month === undefined + ? (this._month = Moment() + .subtract(1, 'M') + .endOf('month') + .format('YYYY-MM-DD')) + : (this._month = data.month); + + this.showDraftReportAlert(this._month); + }); + } + + ngOnInit() {} + + public onMonthChange(value): any { + this._month = Moment(value).endOf('month').format('YYYY-MM-DD'); + } + + public generateReport(): any { + this.route.parent.parent.params.subscribe((params: any) => { + this.storeParamsInUrl(params.location_uuid); + }); + this.txnewReportSummaryData = []; + // this.getTxNewReport(this.params); + } + + public storeParamsInUrl(param) { + this.params = { + locationUuids: param, + _month: Moment(this._month).endOf('month').format('YYYY-MM-DD'), + month: Moment(this._month).endOf('month').format('YYYY-MM-DD'), + reportName: this.reportName, + _date: Moment(this._month).format('DD-MM-YYYY') + }; + this.router.navigate([], { + relativeTo: this.route, + queryParams: this.params + }); + } + + // public getTxNewReport(params: any) { + // this.isLoading = true; + // this.txnewReport.getTxNewReport(params).subscribe((data) => { + // if (data.error) { + // this.showInfoMessage = true; + // this.errorMessage = `There has been an error while loading the report, please retry again`; + // this.isLoading = false; + // } else { + // this.showInfoMessage = false; + // this.columnDefs = data.sectionDefinitions; + // this.txnewReportSummaryData = data.result; + // this.calculateTotalSummary(); + // this.isLoading = false; + // this.showDraftReportAlert(this._month); + // } + // }); + // } + + public calculateTotalSummary() { + const totalsRow = []; + if (this.txnewReportSummaryData.length > 0) { + const totalObj = { + location: 'Totals' + }; + _.each(this.txnewReportSummaryData, (row) => { + Object.keys(row).map((key) => { + if (Number.isInteger(row[key]) === true) { + if (totalObj[key]) { + totalObj[key] = row[key] + totalObj[key]; + } else { + totalObj[key] = row[key]; + } + } else { + if (Number.isNaN(totalObj[key])) { + totalObj[key] = 0; + } + if (totalObj[key] === null) { + totalObj[key] = 0; + } + totalObj[key] = 0 + totalObj[key]; + } + }); + }); + totalObj.location = 'Totals'; + totalsRow.push(totalObj); + this.pinnedBottomRowData = totalsRow; + } + } + public onIndicatorSelected(value) { + this.router.navigate(['patient-list'], { + relativeTo: this.route, + queryParams: { + indicators: value.field, + indicatorHeader: value.headerName, + indicatorGender: value.gender, + month: this._month, + locationUuids: value.location, + currentView: this.currentView + } + }); + } + + public showDraftReportAlert(date) { + if (date != null && date >= Moment().endOf('month').format('YYYY-MM-DD')) { + this.isReleased = false; + } else { + this.isReleased = true; + } + } +} diff --git a/src/app/data-analytics-dashboard/hiv/registers/pnc-register/pnc-register.component.css b/src/app/data-analytics-dashboard/hiv/registers/pnc-register/pnc-register.component.css new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/data-analytics-dashboard/hiv/registers/pnc-register/pnc-register.component.html b/src/app/data-analytics-dashboard/hiv/registers/pnc-register/pnc-register.component.html new file mode 100644 index 000000000..40a18d212 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/pnc-register/pnc-register.component.html @@ -0,0 +1,54 @@ +

+ {{ reportName }} +

+ +
+ Loading... +
+ + +
+ + + + +
+
+ +
+ × +

+ An + error occurred while trying to load the report. Please try again. +

+

+ {{ errorMessage }} +

+
+
+ Viewing a Draft Version of the Report for the chosen month. + This report is likely to change without warning. +
+
+ + + + + +
diff --git a/src/app/data-analytics-dashboard/hiv/registers/pnc-register/pnc-register.component.spec.ts b/src/app/data-analytics-dashboard/hiv/registers/pnc-register/pnc-register.component.spec.ts new file mode 100644 index 000000000..bc56e4b5d --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/pnc-register/pnc-register.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PncRegisterComponent } from './pnc-register.component'; + +describe('PncRegisterComponent', () => { + let component: PncRegisterComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [PncRegisterComponent] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(PncRegisterComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/data-analytics-dashboard/hiv/registers/pnc-register/pnc-register.component.ts b/src/app/data-analytics-dashboard/hiv/registers/pnc-register/pnc-register.component.ts new file mode 100644 index 000000000..160dead32 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/pnc-register/pnc-register.component.ts @@ -0,0 +1,161 @@ +import { Component, OnInit, Output } from '@angular/core'; +import { Router, ActivatedRoute } from '@angular/router'; +import * as _ from 'lodash'; +import * as Moment from 'moment'; +@Component({ + selector: 'app-pnc-register', + templateUrl: './pnc-register.component.html', + styleUrls: ['./pnc-register.component.css'] +}) +export class PncRegisterComponent implements OnInit { + @Output() + public params: any; + public indicators: string; + public selectedIndicators = []; + public txnewReportSummaryData: any = []; + public columnDefs: any = []; + public reportName = 'PNC Register'; + public currentView = 'monthly'; + public currentViewBelow = 'pdf'; + public month: string; + public year: number; + public quarter: string; + public eDate: string; + public sDate: string; + + public statusError = false; + public errorMessage = ''; + public showInfoMessage = false; + public isLoading = false; + public reportHead: any; + public enabledControls = 'locationControl,monthControl'; + public pinnedBottomRowData: any = []; + public _month: string; + public isReleased = true; + + public _locationUuids: any = []; + public get locationUuids(): Array { + return this._locationUuids; + } + + public set locationUuids(v: Array) { + const locationUuids = []; + _.each(v, (location: any) => { + if (location.value) { + locationUuids.push(location); + } + }); + this._locationUuids = locationUuids; + } + + constructor(public router: Router, public route: ActivatedRoute) { + this.route.queryParams.subscribe((data) => { + data.month === undefined + ? (this._month = Moment() + .subtract(1, 'M') + .endOf('month') + .format('YYYY-MM-DD')) + : (this._month = data.month); + + this.showDraftReportAlert(this._month); + }); + } + + ngOnInit() {} + + public onMonthChange(value): any { + this._month = Moment(value).endOf('month').format('YYYY-MM-DD'); + } + + public generateReport(): any { + this.route.parent.parent.params.subscribe((params: any) => { + this.storeParamsInUrl(params.location_uuid); + }); + this.txnewReportSummaryData = []; + // this.getTxNewReport(this.params); + } + + public storeParamsInUrl(param) { + this.params = { + locationUuids: param, + _month: Moment(this._month).endOf('month').format('YYYY-MM-DD'), + month: Moment(this._month).endOf('month').format('YYYY-MM-DD'), + reportName: this.reportName, + _date: Moment(this._month).format('DD-MM-YYYY') + }; + this.router.navigate([], { + relativeTo: this.route, + queryParams: this.params + }); + } + + // public getTxNewReport(params: any) { + // this.isLoading = true; + // this.txnewReport.getTxNewReport(params).subscribe((data) => { + // if (data.error) { + // this.showInfoMessage = true; + // this.errorMessage = `There has been an error while loading the report, please retry again`; + // this.isLoading = false; + // } else { + // this.showInfoMessage = false; + // this.columnDefs = data.sectionDefinitions; + // this.txnewReportSummaryData = data.result; + // this.calculateTotalSummary(); + // this.isLoading = false; + // this.showDraftReportAlert(this._month); + // } + // }); + // } + + public calculateTotalSummary() { + const totalsRow = []; + if (this.txnewReportSummaryData.length > 0) { + const totalObj = { + location: 'Totals' + }; + _.each(this.txnewReportSummaryData, (row) => { + Object.keys(row).map((key) => { + if (Number.isInteger(row[key]) === true) { + if (totalObj[key]) { + totalObj[key] = row[key] + totalObj[key]; + } else { + totalObj[key] = row[key]; + } + } else { + if (Number.isNaN(totalObj[key])) { + totalObj[key] = 0; + } + if (totalObj[key] === null) { + totalObj[key] = 0; + } + totalObj[key] = 0 + totalObj[key]; + } + }); + }); + totalObj.location = 'Totals'; + totalsRow.push(totalObj); + this.pinnedBottomRowData = totalsRow; + } + } + public onIndicatorSelected(value) { + this.router.navigate(['patient-list'], { + relativeTo: this.route, + queryParams: { + indicators: value.field, + indicatorHeader: value.headerName, + indicatorGender: value.gender, + month: this._month, + locationUuids: value.location, + currentView: this.currentView + } + }); + } + + public showDraftReportAlert(date) { + if (date != null && date >= Moment().endOf('month').format('YYYY-MM-DD')) { + this.isReleased = false; + } else { + this.isReleased = true; + } + } +} diff --git a/src/app/data-analytics-dashboard/hiv/registers/prepdaily-register/prepdaily-register.component.css b/src/app/data-analytics-dashboard/hiv/registers/prepdaily-register/prepdaily-register.component.css new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/data-analytics-dashboard/hiv/registers/prepdaily-register/prepdaily-register.component.html b/src/app/data-analytics-dashboard/hiv/registers/prepdaily-register/prepdaily-register.component.html new file mode 100644 index 000000000..40a18d212 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/prepdaily-register/prepdaily-register.component.html @@ -0,0 +1,54 @@ +

+ {{ reportName }} +

+ +
+ Loading... +
+ + +
+ + + + +
+
+ +
+ × +

+ An + error occurred while trying to load the report. Please try again. +

+

+ {{ errorMessage }} +

+
+
+ Viewing a Draft Version of the Report for the chosen month. + This report is likely to change without warning. +
+
+ + + + + +
diff --git a/src/app/data-analytics-dashboard/hiv/registers/prepdaily-register/prepdaily-register.component.spec.ts b/src/app/data-analytics-dashboard/hiv/registers/prepdaily-register/prepdaily-register.component.spec.ts new file mode 100644 index 000000000..b44182395 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/prepdaily-register/prepdaily-register.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PrepdailyRegisterComponent } from './prepdaily-register.component'; + +describe('PrepdailyRegisterComponent', () => { + let component: PrepdailyRegisterComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [PrepdailyRegisterComponent] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(PrepdailyRegisterComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/data-analytics-dashboard/hiv/registers/prepdaily-register/prepdaily-register.component.ts b/src/app/data-analytics-dashboard/hiv/registers/prepdaily-register/prepdaily-register.component.ts new file mode 100644 index 000000000..c982e94bd --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/prepdaily-register/prepdaily-register.component.ts @@ -0,0 +1,161 @@ +import { Component, OnInit, Output } from '@angular/core'; +import { Router, ActivatedRoute } from '@angular/router'; +import * as _ from 'lodash'; +import * as Moment from 'moment'; +@Component({ + selector: 'app-prepdaily-register', + templateUrl: './prepdaily-register.component.html', + styleUrls: ['./prepdaily-register.component.css'] +}) +export class PrepdailyRegisterComponent implements OnInit { + @Output() + public params: any; + public indicators: string; + public selectedIndicators = []; + public txnewReportSummaryData: any = []; + public columnDefs: any = []; + public reportName = 'PrEP Daily Activity Register'; + public currentView = 'monthly'; + public currentViewBelow = 'pdf'; + public month: string; + public year: number; + public quarter: string; + public eDate: string; + public sDate: string; + + public statusError = false; + public errorMessage = ''; + public showInfoMessage = false; + public isLoading = false; + public reportHead: any; + public enabledControls = 'locationControl,monthControl'; + public pinnedBottomRowData: any = []; + public _month: string; + public isReleased = true; + + public _locationUuids: any = []; + public get locationUuids(): Array { + return this._locationUuids; + } + + public set locationUuids(v: Array) { + const locationUuids = []; + _.each(v, (location: any) => { + if (location.value) { + locationUuids.push(location); + } + }); + this._locationUuids = locationUuids; + } + + constructor(public router: Router, public route: ActivatedRoute) { + this.route.queryParams.subscribe((data) => { + data.month === undefined + ? (this._month = Moment() + .subtract(1, 'M') + .endOf('month') + .format('YYYY-MM-DD')) + : (this._month = data.month); + + this.showDraftReportAlert(this._month); + }); + } + + ngOnInit() {} + + public onMonthChange(value): any { + this._month = Moment(value).endOf('month').format('YYYY-MM-DD'); + } + + public generateReport(): any { + this.route.parent.parent.params.subscribe((params: any) => { + this.storeParamsInUrl(params.location_uuid); + }); + this.txnewReportSummaryData = []; + // this.getTxNewReport(this.params); + } + + public storeParamsInUrl(param) { + this.params = { + locationUuids: param, + _month: Moment(this._month).endOf('month').format('YYYY-MM-DD'), + month: Moment(this._month).endOf('month').format('YYYY-MM-DD'), + reportName: this.reportName, + _date: Moment(this._month).format('DD-MM-YYYY') + }; + this.router.navigate([], { + relativeTo: this.route, + queryParams: this.params + }); + } + + // public getTxNewReport(params: any) { + // this.isLoading = true; + // this.txnewReport.getTxNewReport(params).subscribe((data) => { + // if (data.error) { + // this.showInfoMessage = true; + // this.errorMessage = `There has been an error while loading the report, please retry again`; + // this.isLoading = false; + // } else { + // this.showInfoMessage = false; + // this.columnDefs = data.sectionDefinitions; + // this.txnewReportSummaryData = data.result; + // this.calculateTotalSummary(); + // this.isLoading = false; + // this.showDraftReportAlert(this._month); + // } + // }); + // } + + public calculateTotalSummary() { + const totalsRow = []; + if (this.txnewReportSummaryData.length > 0) { + const totalObj = { + location: 'Totals' + }; + _.each(this.txnewReportSummaryData, (row) => { + Object.keys(row).map((key) => { + if (Number.isInteger(row[key]) === true) { + if (totalObj[key]) { + totalObj[key] = row[key] + totalObj[key]; + } else { + totalObj[key] = row[key]; + } + } else { + if (Number.isNaN(totalObj[key])) { + totalObj[key] = 0; + } + if (totalObj[key] === null) { + totalObj[key] = 0; + } + totalObj[key] = 0 + totalObj[key]; + } + }); + }); + totalObj.location = 'Totals'; + totalsRow.push(totalObj); + this.pinnedBottomRowData = totalsRow; + } + } + public onIndicatorSelected(value) { + this.router.navigate(['patient-list'], { + relativeTo: this.route, + queryParams: { + indicators: value.field, + indicatorHeader: value.headerName, + indicatorGender: value.gender, + month: this._month, + locationUuids: value.location, + currentView: this.currentView + } + }); + } + + public showDraftReportAlert(date) { + if (date != null && date >= Moment().endOf('month').format('YYYY-MM-DD')) { + this.isReleased = false; + } else { + this.isReleased = true; + } + } +} diff --git a/src/app/data-analytics-dashboard/hiv/registers/registers.component.css b/src/app/data-analytics-dashboard/hiv/registers/registers.component.css new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/data-analytics-dashboard/hiv/registers/registers.component.html b/src/app/data-analytics-dashboard/hiv/registers/registers.component.html new file mode 100644 index 000000000..e040fcba0 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/registers.component.html @@ -0,0 +1,27 @@ + +

Loading available dashboards ...

+
+ {{ errorMessage }} +
+ diff --git a/src/app/data-analytics-dashboard/hiv/registers/registers.component.spec.ts b/src/app/data-analytics-dashboard/hiv/registers/registers.component.spec.ts new file mode 100644 index 000000000..769a029a0 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/registers.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { RegistersComponent } from './registers.component'; + +describe('RegistersComponent', () => { + let component: RegistersComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [RegistersComponent] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(RegistersComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/data-analytics-dashboard/hiv/registers/registers.component.ts b/src/app/data-analytics-dashboard/hiv/registers/registers.component.ts new file mode 100644 index 000000000..92750254f --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/registers/registers.component.ts @@ -0,0 +1,79 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +@Component({ + selector: 'app-registers', + templateUrl: './registers.component.html', + styleUrls: ['./registers.component.css'] +}) +export class RegistersComponent implements OnInit { + public isBusy = false; + public errorMessage = ''; + + public dashboards: Array = []; + constructor(public router: Router, public route: ActivatedRoute) {} + + ngOnInit() { + this.dashboards = [ + { + title: 'MOH-408: HEI Register', + description: '', + url: 'hei-register', + icon: 'fa' + }, + { + title: 'MOH-405: ANC Register', + description: '', + url: 'anc-register', + icon: 'fa' + }, + { + title: 'MOH-407: Nutrition Service Register', + description: '', + url: 'nutrition-register', + icon: 'fa' + }, + { + title: 'MOH-333: Martenity Register', + description: '', + url: 'maternity-register', + icon: 'fa' + }, + { + title: 'MOH-362: HTS Lab Refferal & Linkage Register', + description: '', + url: 'htsrefferallinkage-register', + icon: 'fa' + }, + { + title: 'MOH-406: PNC Register', + description: '', + url: 'pnc-register', + icon: 'fa' + }, + { + title: 'Defaulter Tracing Register', + description: '', + url: 'defaultertracing-register', + icon: 'fa' + }, + { + title: 'MOH-267: PrEP Daily Activity Register', + description: '', + url: 'prepdaily-register', + icon: 'fa' + }, + { + title: 'MOH-366: Care and Treatment Daily Activity', + description: '', + url: 'cntdaily-register', + icon: 'fa' + } + ]; + } + public viewDashboard(dashboard: any) { + this.router.navigate([dashboard.url], { + relativeTo: this.route + }); + } +} diff --git a/src/app/shared/dynamic-route/schema/analytics.dashboard.conf.json b/src/app/shared/dynamic-route/schema/analytics.dashboard.conf.json index 0cc6d3a9c..ebd82770a 100644 --- a/src/app/shared/dynamic-route/schema/analytics.dashboard.conf.json +++ b/src/app/shared/dynamic-route/schema/analytics.dashboard.conf.json @@ -114,6 +114,12 @@ "icon": "fa fa-file", "isSideBarOpen": false }, + { + "url": "registers", + "label": "Registers", + "icon": "fa fa-list-alt", + "isSideBarOpen": false + }, { "url": "select-department", "label": "Change Department",