From 35b9e29a94280246557e62d4f9dfce4c08dde672 Mon Sep 17 00:00:00 2001 From: Angie-540 Date: Mon, 12 Jun 2023 21:48:44 +0300 Subject: [PATCH] POC-352 --- ...c-dashboard-pmtct-rri-report.component.css | 0 ...-dashboard-pmtct-rri-report.component.html | 9 + ...ic-dashboard-pmtct-rri-report.component.ts | 37 ++++ .../hiv/hiv-program.module.ts | 4 + .../hiv/hiv-program.routes.ts | 32 +++ src/app/etl-api/etl-api.module.ts | 2 + .../pmtct-calhiv-rri-report.service.spec.ts | 18 ++ .../pmtct-calhiv-rri-report.service.ts | 66 ++++++ .../hei-indicators-filter.component.ts | 1 - .../hei-indicators-report.component.ts | 2 +- src/app/hiv-care-lib/hiv-care-lib.module.ts | 15 ++ .../pmtct-calhiv-filter.component.html | 104 ++++++++++ .../pmtct-calhiv-filter.component.ts | 107 ++++++++++ .../pmtct-calhiv-patient-list.component.html | 40 ++++ .../pmtct-calhiv-patient-list.component.ts | 192 ++++++++++++++++++ .../pmtct-calhiv-pdf-view.component.css | 32 +++ .../pmtct-calhiv-pdf-view.component.html | 62 ++++++ .../pmtct-calhiv-pdf-view.component.ts | 123 +++++++++++ .../pmtct-calhiv-rri-report.component.css | 46 +++++ .../pmtct-calhiv-rri-report.component.html | 53 +++++ .../pmtct-calhiv-rri-report.component.spec.ts | 24 +++ .../pmtct-calhiv-rri-report.component.ts | 123 +++++++++++ .../pmtct-calhiv-tabular.component.css | 0 .../pmtct-calhiv-tabular.component.html | 20 ++ .../pmtct-calhiv-tabular.component.ts | 122 +++++++++++ .../schema/clinic.dashboard.conf.json | 6 + 26 files changed, 1238 insertions(+), 2 deletions(-) create mode 100644 src/app/clinic-dashboard/hiv/clinic-dashboard-pmtct-rri-report/clinic-dashboard-pmtct-rri-report.component.css create mode 100644 src/app/clinic-dashboard/hiv/clinic-dashboard-pmtct-rri-report/clinic-dashboard-pmtct-rri-report.component.html create mode 100644 src/app/clinic-dashboard/hiv/clinic-dashboard-pmtct-rri-report/clinic-dashboard-pmtct-rri-report.component.ts create mode 100644 src/app/etl-api/pmtct-calhiv-rri-report.service.spec.ts create mode 100644 src/app/etl-api/pmtct-calhiv-rri-report.service.ts create mode 100644 src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-filter.component.html create mode 100644 src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-filter.component.ts create mode 100644 src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-patient-list.component.html create mode 100644 src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-patient-list.component.ts create mode 100644 src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-pdf-view.component.css create mode 100644 src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-pdf-view.component.html create mode 100644 src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-pdf-view.component.ts create mode 100644 src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-rri-report.component.css create mode 100644 src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-rri-report.component.html create mode 100644 src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-rri-report.component.spec.ts create mode 100644 src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-rri-report.component.ts create mode 100644 src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-tabular.component.css create mode 100644 src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-tabular.component.html create mode 100644 src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-tabular.component.ts diff --git a/src/app/clinic-dashboard/hiv/clinic-dashboard-pmtct-rri-report/clinic-dashboard-pmtct-rri-report.component.css b/src/app/clinic-dashboard/hiv/clinic-dashboard-pmtct-rri-report/clinic-dashboard-pmtct-rri-report.component.css new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/clinic-dashboard/hiv/clinic-dashboard-pmtct-rri-report/clinic-dashboard-pmtct-rri-report.component.html b/src/app/clinic-dashboard/hiv/clinic-dashboard-pmtct-rri-report/clinic-dashboard-pmtct-rri-report.component.html new file mode 100644 index 000000000..fed7a99f1 --- /dev/null +++ b/src/app/clinic-dashboard/hiv/clinic-dashboard-pmtct-rri-report/clinic-dashboard-pmtct-rri-report.component.html @@ -0,0 +1,9 @@ +
+
+
+ +
+
+
diff --git a/src/app/clinic-dashboard/hiv/clinic-dashboard-pmtct-rri-report/clinic-dashboard-pmtct-rri-report.component.ts b/src/app/clinic-dashboard/hiv/clinic-dashboard-pmtct-rri-report/clinic-dashboard-pmtct-rri-report.component.ts new file mode 100644 index 000000000..fec066426 --- /dev/null +++ b/src/app/clinic-dashboard/hiv/clinic-dashboard-pmtct-rri-report/clinic-dashboard-pmtct-rri-report.component.ts @@ -0,0 +1,37 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { Subscription } from 'rxjs'; +import { Router, ActivatedRoute } from '@angular/router'; +import { ClinicDashboardCacheService } from '../../services/clinic-dashboard-cache.service'; + +@Component({ + selector: 'clinic-dashboard-pmtct-rri-report', + templateUrl: './clinic-dashboard-pmtct-rri-report.component.html', + styleUrls: ['./clinic-dashboard-pmtct-rri-report.component.css'] +}) +export class ClinicDashboardPmtctRriReportComponent implements OnInit { + public selectedClinic = ''; + private subs: Subscription[] = []; + public routeSub: Subscription; + + constructor( + private _router: Router, + private _route: ActivatedRoute, + private _clinicDashboardCacheService: ClinicDashboardCacheService + ) {} + + public ngOnInit() { + this.routeSub = this._route.parent.parent.params.subscribe((params) => { + this._clinicDashboardCacheService.setCurrentClinic( + params['location_uuid'] + ); + }); + + const sub = this._clinicDashboardCacheService + .getCurrentClinic() + .subscribe((location) => { + this.selectedClinic = location; + }); + + this.subs.push(sub); + } +} diff --git a/src/app/clinic-dashboard/hiv/hiv-program.module.ts b/src/app/clinic-dashboard/hiv/hiv-program.module.ts index 5923f61ce..fdafbd2fd 100644 --- a/src/app/clinic-dashboard/hiv/hiv-program.module.ts +++ b/src/app/clinic-dashboard/hiv/hiv-program.module.ts @@ -70,6 +70,8 @@ import { ClinicDashboardRetentionReportComponent } from './retention-report/clin import { ClinicDashboardCaseManagementComponent } from './case-management/clinic-dashboard-case-management.component'; import { PrepReportComponent } from './prep-report/prep-report.component'; import { ClinicDashboardHeiReportComponent } from './clinic-dashboard-hei-indicators-report/clinic-dashboard-hei-report.component'; +import { ClinicDashboardPmtctRriReportComponent } from './clinic-dashboard-pmtct-rri-report/clinic-dashboard-pmtct-rri-report.component'; + import { HIVListsMicroFrontendComponent } from './hiv-lists-microfrontend-report/hiv-lists-microfrontend.component'; import { FamilyTestingComponent } from './family-testing/family-testing.component'; import { AngularMultiSelectModule } from 'angular2-multiselect-dropdown/angular2-multiselect-dropdown'; @@ -133,6 +135,7 @@ import { PreAppointmentOutreachComponent } from '../general/pre-appointment-outr RangeSliderComponent, RouterModule, ClinicDashboardHeiReportComponent, + ClinicDashboardPmtctRriReportComponent, ClinicDashboardGainsAndLossesComponent, MOH412ClinicDashboardComponent, MOH412ClinicDashboardPatientListComponent, @@ -175,6 +178,7 @@ import { PreAppointmentOutreachComponent } from '../general/pre-appointment-outr ClinicDashboardCaseManagementComponent, PrepReportComponent, ClinicDashboardHeiReportComponent, + ClinicDashboardPmtctRriReportComponent, HIVListsMicroFrontendComponent, FamilyTestingComponent, ClinicDashboardGainsAndLossesComponent, diff --git a/src/app/clinic-dashboard/hiv/hiv-program.routes.ts b/src/app/clinic-dashboard/hiv/hiv-program.routes.ts index 7071527a3..2c14ee45b 100644 --- a/src/app/clinic-dashboard/hiv/hiv-program.routes.ts +++ b/src/app/clinic-dashboard/hiv/hiv-program.routes.ts @@ -49,6 +49,11 @@ import { IptReportPatientListComponent } from 'src/app/hiv-care-lib/ipt-report/i import { ClinicDashboardHeiReportComponent } from './clinic-dashboard-hei-indicators-report/clinic-dashboard-hei-report.component'; import { HeiIndicatorsPatientListComponent } from './../../hiv-care-lib/hei-indicators-report/hei-indicators-patient-list.component'; +// pmtct-rri reports +import { PmtctCalhivRriReportComponent } from 'src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-rri-report.component'; +import { PmtctCalhivRriPatientListComponent } from 'src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-patient-list.component'; +import { ClinicDashboardPmtctRriReportComponent } from './clinic-dashboard-pmtct-rri-report/clinic-dashboard-pmtct-rri-report.component'; + import { HIVListsMicroFrontendComponent } from './hiv-lists-microfrontend-report/hiv-lists-microfrontend.component'; import { FamilyTestingBaseComponent } from 'src/app/hiv-care-lib/family-testing/family-testing-base.component'; import { FamilyTestingContactComponent } from 'src/app/hiv-care-lib/family-testing/family-testing-contact-list.component'; @@ -296,6 +301,19 @@ const routes: Routes = [ { path: 'location', component: ClinicFlowLocationStatsComponent }, { path: '', redirectTo: 'summary', pathMatch: 'prefix' } ] + }, + { + path: 'pmtct-rri-report', + children: [ + { path: 'visits', component: ClinicFlowVisitsComponent }, + { path: 'summary', component: ClinicFlowSummaryComponent }, + { + path: 'provider-stats', + component: ClinicFlowProviderStatsComponent + }, + { path: 'location', component: ClinicFlowLocationStatsComponent }, + { path: '', redirectTo: 'summary', pathMatch: 'prefix' } + ] } ] }, @@ -470,6 +488,20 @@ const routes: Routes = [ } ] }, + + { + path: 'pmtct-rri-report', + children: [ + { + path: '', + component: ClinicDashboardPmtctRriReportComponent + }, + { + path: 'patient-list', + component: PmtctCalhivRriPatientListComponent + } + ] + }, { path: 'pre-appoinment-outreach', component: PreAppointmentOutreachComponent diff --git a/src/app/etl-api/etl-api.module.ts b/src/app/etl-api/etl-api.module.ts index 96359d5d6..66ca15eab 100644 --- a/src/app/etl-api/etl-api.module.ts +++ b/src/app/etl-api/etl-api.module.ts @@ -38,6 +38,7 @@ import { HivDifferentiatedCareResourceService } from './hiv-differentiated-care- import { SurgeResourceService } from './surge-resource.service'; import { PatientEducationService } from './patient-education.service'; import { HeiReportService } from './hei-report.service'; +import { PmtctCalhivRriReportService } from './pmtct-calhiv-rri-report.service'; import { CervicalCancerScreeningSummaResourceService } from './cervical-cancer-screening-summary-resource.service'; import { MOH412ResourceService } from './moh-412-resource.service'; import { ClinicFlowResourceService } from './clinic-flow-resource.service'; @@ -86,6 +87,7 @@ import { LocationUnitsService } from './location-units.service'; HivDifferentiatedCareResourceService, SurgeResourceService, HeiReportService, + PmtctCalhivRriReportService, PatientEducationService, CervicalCancerScreeningSummaResourceService, MOH412ResourceService, diff --git a/src/app/etl-api/pmtct-calhiv-rri-report.service.spec.ts b/src/app/etl-api/pmtct-calhiv-rri-report.service.spec.ts new file mode 100644 index 000000000..913f60267 --- /dev/null +++ b/src/app/etl-api/pmtct-calhiv-rri-report.service.spec.ts @@ -0,0 +1,18 @@ +import { TestBed, inject } from '@angular/core/testing'; + +import { PmtctCalhivRriReportService } from './pmtct-calhiv-rri-report.service'; + +describe('PmtctCalhivRriReportService', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [PmtctCalhivRriReportService] + }); + }); + + it('should be created', inject( + [PmtctCalhivRriReportService], + (service: PmtctCalhivRriReportService) => { + expect(service).toBeTruthy(); + } + )); +}); diff --git a/src/app/etl-api/pmtct-calhiv-rri-report.service.ts b/src/app/etl-api/pmtct-calhiv-rri-report.service.ts new file mode 100644 index 000000000..3d9604d77 --- /dev/null +++ b/src/app/etl-api/pmtct-calhiv-rri-report.service.ts @@ -0,0 +1,66 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpParams } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import * as _ from 'lodash'; +import { AppSettingsService } from '../app-settings/app-settings.service'; +import { DataCacheService } from '../shared/services/data-cache.service'; + +@Injectable({ + providedIn: 'root' +}) +export class PmtctCalhivRriReportService { + constructor( + protected http: HttpClient, + protected appSettingsService: AppSettingsService, + private cacheService: DataCacheService + ) {} + + public getBaseUrl(): string { + return this.appSettingsService.getEtlRestbaseurl().trim(); + } + + public getPatientListUrl(): string { + return ( + this.appSettingsService.getEtlRestbaseurl().trim() + + 'pmtct_rri_summary/patient-list' + ); + } + + public getRriIndicatorsReport(payload: any): Observable { + if (!payload) { + return null; + } + let urlParams: HttpParams = new HttpParams() + .set('endDate', payload.endDate) + .set('startDate', payload.startDate); + + if (payload.locationUuids) { + if (payload.locationUuids.length > 0) { + urlParams = urlParams.set('locationUuids', payload.locationUuids); + } + } + const url = this.getBaseUrl() + 'pmtct_rri_summary'; + return this.http.get(url, { + params: urlParams + }); + } + + public getRriMonthlySummaryPatientList(params: any) { + if (!params) { + return null; + } + + const urlParams: HttpParams = new HttpParams() + .set('startDate', params.startDate) + .set('endDate', params.endDate) + .set('locationUuids', params.locationUuids) + .set('indicators', params.indicators) + .set('reportType', params.reportType); + + const url = this.getPatientListUrl(); + + return this.http.get(url, { + params: urlParams + }); + } +} diff --git a/src/app/hiv-care-lib/hei-indicators-report/hei-indicators-filter.component.ts b/src/app/hiv-care-lib/hei-indicators-report/hei-indicators-filter.component.ts index 8f6beb8b2..4dfdd7014 100644 --- a/src/app/hiv-care-lib/hei-indicators-report/hei-indicators-filter.component.ts +++ b/src/app/hiv-care-lib/hei-indicators-report/hei-indicators-filter.component.ts @@ -84,7 +84,6 @@ export class HeiIndicatorsFilterComponent implements OnInit { .endOf('month') .format('YYYY-MM-DD') }; - this.passParamsToUrl(this.params); } diff --git a/src/app/hiv-care-lib/hei-indicators-report/hei-indicators-report.component.ts b/src/app/hiv-care-lib/hei-indicators-report/hei-indicators-report.component.ts index 4af4d77a6..f153fa3a1 100644 --- a/src/app/hiv-care-lib/hei-indicators-report/hei-indicators-report.component.ts +++ b/src/app/hiv-care-lib/hei-indicators-report/hei-indicators-report.component.ts @@ -1,8 +1,8 @@ +import { HeiReportService } from './../../etl-api/hei-report.service'; import { take } from 'rxjs/operators'; import { Component, OnInit, Input } from '@angular/core'; import { Subject } from 'rxjs'; import { Router, ActivatedRoute } from '@angular/router'; -import { HeiReportService } from './../../etl-api/hei-report.service'; import * as Moment from 'moment'; @Component({ diff --git a/src/app/hiv-care-lib/hiv-care-lib.module.ts b/src/app/hiv-care-lib/hiv-care-lib.module.ts index b580110e4..2a59be1e6 100644 --- a/src/app/hiv-care-lib/hiv-care-lib.module.ts +++ b/src/app/hiv-care-lib/hiv-care-lib.module.ts @@ -63,6 +63,11 @@ import { HeiIndicatorsFilterComponent } from './hei-indicators-report/hei-indica import { HeiIndicatorsTabularComponent } from './hei-indicators-report/hei-indicators-tabular-component'; import { HeiIndicatorsPatientListComponent } from './hei-indicators-report/hei-indicators-patient-list.component'; import { HeiIndicatorsPdfViewComponent } from './hei-indicators-report/hei-indicators-pdf-view.component'; +import { PmtctCalhivRriReportComponent } from './pmtct-calhiv-rri-report/pmtct-calhiv-rri-report.component'; +import { PmtctCalhivPdfViewComponent } from './pmtct-calhiv-rri-report/pmtct-calhiv-pdf-view.component'; +import { PmtctCalhivRriFiltersComponent } from './pmtct-calhiv-rri-report/pmtct-calhiv-filter.component'; +import { PmtctCalhivRriTabularComponent } from './pmtct-calhiv-rri-report/pmtct-calhiv-tabular.component'; +import { PmtctCalhivRriPatientListComponent } from './pmtct-calhiv-rri-report/pmtct-calhiv-patient-list.component'; import { HighchartsStatic } from 'angular2-highcharts/dist/HighchartsService'; import { SurgeReportTabularComponent } from './surge-report/surge-report-tabular.component'; import { SurgeReportBaseComponent } from './surge-report/surge-report-base.component'; @@ -212,6 +217,11 @@ import { TxRttReportPatientListComponent } from './tx-rtt-report/tx-rtt-report-p HeiIndicatorsTabularComponent, HeiIndicatorsPatientListComponent, HeiIndicatorsPdfViewComponent, + PmtctCalhivRriReportComponent, + PmtctCalhivRriTabularComponent, + PmtctCalhivPdfViewComponent, + PmtctCalhivRriFiltersComponent, + PmtctCalhivRriPatientListComponent, FamilyTestingBaseComponent, FamilyTestingPatientlistComponent, FamilyTestingTreeComponent, @@ -280,6 +290,11 @@ import { TxRttReportPatientListComponent } from './tx-rtt-report/tx-rtt-report-p HeiIndicatorsTabularComponent, HeiIndicatorsPatientListComponent, HeiIndicatorsPdfViewComponent, + PmtctCalhivRriReportComponent, + PmtctCalhivRriTabularComponent, + PmtctCalhivPdfViewComponent, + PmtctCalhivRriFiltersComponent, + PmtctCalhivRriPatientListComponent, PatientGainsAndLosesPatientListComponent, PatientGainsAndLosesComponent, FamilyTestingBaseComponent, diff --git a/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-filter.component.html b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-filter.component.html new file mode 100644 index 000000000..f2ef50510 --- /dev/null +++ b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-filter.component.html @@ -0,0 +1,104 @@ +
+
+ + + Report filters + + + + +
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+ +
+
+ + Loading report.. +
+
+ \ No newline at end of file diff --git a/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-filter.component.ts b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-filter.component.ts new file mode 100644 index 000000000..a723fdad9 --- /dev/null +++ b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-filter.component.ts @@ -0,0 +1,107 @@ +import { take } from 'rxjs/operators'; +import { Component, OnInit, Output, EventEmitter, Input } from '@angular/core'; +import { Subject } from 'rxjs'; +import { Router, ActivatedRoute } from '@angular/router'; +import * as Moment from 'moment'; + +@Component({ + selector: 'pmtct-calhiv-filters', + templateUrl: './pmtct-calhiv-filter.component.html', + styleUrls: [] +}) +export class PmtctCalhivRriFiltersComponent implements OnInit { + public showLocationsControl = false; + public isMonthMode = true; + public showIsAggregateControl = false; + public endDateString = ''; + public startDateString = ''; + public monthString = ''; + public locationUuid: any; + public locationUuids = []; + public params = { + locationUuids: [], + startDate: '', + endDate: '' + }; + public filterCollapsed = false; + public parentIsBusy = false; + @Output() public selectedFilter: EventEmitter = new EventEmitter(); + @Input() public locations: any; + + constructor(private _router: Router, private _route: ActivatedRoute) {} + + public ngOnInit() { + this._route.queryParams.subscribe( + (params: any) => { + if (params) { + this.params = params; + // cater for endpoints taking long to return data + setTimeout(() => { + this.loadFilterFromUrlParams(params); + }, 1000); + } + }, + (error) => { + console.error('Error', error); + } + ); + } + + public loadFilterFromUrlParams(params) { + const newParams: any = { + startDate: '', + endDate: '', + locationUuids: [] + }; + + if (params.startDate) { + if (params.endDate) { + newParams.endDate = params.endDate; + } + if (params.startDate) { + newParams.startDate = params.startDate; + this.monthString = Moment(params.startDate).format('YYYY-MM'); + } + if (params.locationUuids && params.locationUuids.length > 0) { + this.locations = params.locationUuids; + newParams.locationUuids = params.locationUuids; + } + this.params = newParams; + this.selectedFilter.emit(this.params); + } + } + + public onClickedGenerate() { + this.setQueryParams(); + } + + public setQueryParams() { + this.params = { + locationUuids: this.locations, + + startDate: Moment(this.monthString, 'YYYY-MM') + .startOf('month') + .format('YYYY-MM-DD'), + endDate: Moment(this.monthString, 'YYYY-MM') + .endOf('month') + .format('YYYY-MM-DD') + }; + + this.passParamsToUrl(this.params); + } + + public passParamsToUrl(params) { + const navigationData = { + queryParams: params, + replaceUrl: true + }; + + const currentUrl = this._router.url; + const routeUrl = currentUrl.split('?')[0]; + this._router.navigate([routeUrl], navigationData); + } + + public getQueryParams() { + return this.params; + } +} diff --git a/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-patient-list.component.html b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-patient-list.component.html new file mode 100644 index 000000000..0d65edd35 --- /dev/null +++ b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-patient-list.component.html @@ -0,0 +1,40 @@ +
+
+
+

+ {{ title }} Patient List for {{ params.startDate }} to + {{ params.endDate }} +

+
+
+
+ +
+
+ + + +
+
+
+ \ No newline at end of file diff --git a/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-patient-list.component.ts b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-patient-list.component.ts new file mode 100644 index 000000000..70fb6cf2e --- /dev/null +++ b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-patient-list.component.ts @@ -0,0 +1,192 @@ +import { PmtctCalhivRriReportService } from './../../etl-api/pmtct-calhiv-rri-report.service'; +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Location } from '@angular/common'; + +import * as _ from 'lodash'; +import { Subscription } from 'rxjs'; +import { GridOptions } from 'ag-grid'; + +@Component({ + selector: 'pmtct-calhiv-patient-list', + templateUrl: './pmtct-calhiv-patient-list.component.html', + styleUrls: [] +}) +export class PmtctCalhivRriPatientListComponent implements OnInit { + constructor( + private router: Router, + private route: ActivatedRoute, + private location: Location, + private pmtctCalhivRriReportService: PmtctCalhivRriReportService + ) {} + + public title = ''; + public patients: any = []; + public rowData: any = []; + public patientList: any = []; + public params: any; + public busy: Subscription; + public locationUuids: any; + public gridColumnApi; + public gridOptions: GridOptions = { + enableColResize: true, + enableSorting: true, + enableFilter: true, + showToolPanel: false, + pagination: true, + paginationPageSize: 300, + onGridSizeChanged: () => { + if (this.gridOptions.api) { + this.gridOptions.api.sizeColumnsToFit(); + } + }, + onGridReady: () => { + if (this.gridOptions.api) { + this.gridOptions.api.sizeColumnsToFit(); + } + } + }; + + public rriSummaryColdef: any = []; + + public ngOnInit() { + this.route.queryParams.subscribe( + (params: any) => { + if (params) { + this.getPatientList(params); + this.title = this.translateIndicator(params.indicators); + this.params = params; + } + }, + (error) => { + console.error('Error', error); + } + ); + } + + public getPatientList(params) { + this.busy = this.pmtctCalhivRriReportService + .getRriMonthlySummaryPatientList(params) + .subscribe((result: any) => { + if (result) { + const patients = result.results.results; + this.patients = patients; + this.generateDynamicPatientListCols(); + this.processPatientList(patients); + } + }); + } + + public backToSummary() { + this.navigateBack(); + } + + public generateDynamicPatientListCols() { + const columns = [ + { + headerName: '#', + field: 'no' + }, + { + headerName: 'Patient Uuid', + field: 'patient_uuid', + hide: true + }, + { + headerName: 'Name', + field: 'person_name' + }, + { + headerName: 'Gender', + field: 'gender' + }, + { + headerName: 'Age', + field: 'age' + }, + + { + headerName: 'Date of Birth', + field: 'birth_date' + }, + { + headerName: 'Date of Enrollment', + field: 'enrollment_date' + }, + + { + headerName: 'Location', + field: 'location' + } + ]; + + this.rriSummaryColdef = columns; + } + + public redirectTopatientInfo(patientUuid) { + if (patientUuid === undefined || patientUuid === null) { + return; + } + this.router.navigate([ + '/patient-dashboard/patient/' + + patientUuid + + '/general/general/landing-page' + ]); + } + + public translateIndicator(indicator: string) { + const indicatorArray = indicator.toLowerCase().split('_'); + if (indicator === 'hiv_status') { + return ( + indicatorArray[0].toUpperCase() + + ' ' + + indicatorArray[1].charAt(0).toUpperCase() + + indicatorArray[1].slice(1) + ); + } else { + return indicatorArray + .map((word) => { + return word.charAt(0).toUpperCase() + word.slice(1); + }) + .join(' '); + } + } + + public processPatientList(patients) { + const patientsRow = []; + + _.each(patients, (patient: any, index) => { + patient['no'] = index + 1; + + patientsRow.push(patient); + }); + + this.rowData = patientsRow; + } + + public showColumn(column: string) { + if (this.patients.length > 0) { + const firstRow: any = this.patients[0]; + if (firstRow[column]) { + return true; + } else { + return false; + } + } else { + return false; + } + } + + public navigateBack() { + this.location.back(); + } + + public onCellClicked($event: any) { + const patientUuid = $event.data.patient_uuid; + this.redirectTopatientInfo(patientUuid); + } + + public exportPatientListToCsv() { + this.gridOptions.api.exportDataAsCsv(); + } +} diff --git a/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-pdf-view.component.css b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-pdf-view.component.css new file mode 100644 index 000000000..b2913079a --- /dev/null +++ b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-pdf-view.component.css @@ -0,0 +1,32 @@ +.section-title { + color: #fff; + background-color: #337ab7; + font-weight: bold; + display: block; + width: 100%; + font-size: 18px; +} +td, +th { + padding: 10px; + text-align: left; + font-size: 16px; + border: 1px solid #090909; +} +th { + background-color: #337ab7; + color: white; + font-weight: bold; +} +.section-data { + width: 50%; +} +.value { + color: #337ab7; +} +.value:hover { + cursor: pointer; +} +tr { + padding: 10px; +} diff --git a/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-pdf-view.component.html b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-pdf-view.component.html new file mode 100644 index 000000000..565bcef27 --- /dev/null +++ b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-pdf-view.component.html @@ -0,0 +1,62 @@ +
+
+
+ + + RRI Report + for {{ params.startDate }} to {{ params.endDate }} + +
+ +
+
+
+
+ + + + + + + + +
Locations + {{ location }} +
+
+ + + + + + + + +
+ {{ section.sectionTitle }} +
+ {{ indicator.label }} + + {{ locationData[indicator.indicator] }} +
+
+
+ +
+
+ \ No newline at end of file diff --git a/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-pdf-view.component.ts b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-pdf-view.component.ts new file mode 100644 index 000000000..efbe3aeb4 --- /dev/null +++ b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-pdf-view.component.ts @@ -0,0 +1,123 @@ +import { take } from 'rxjs/operators'; +import { + Component, + OnInit, + Input, + OnChanges, + SimpleChanges +} from '@angular/core'; +import { Subject } from 'rxjs'; +import { Router, ActivatedRoute } from '@angular/router'; +import * as _ from 'lodash'; +import * as moment from 'moment'; +import * as jspdf from 'jspdf'; +import html2canvas from 'html2canvas'; + +@Component({ + selector: 'pmtct-calhiv-pdf-view', + templateUrl: './pmtct-calhiv-pdf-view.component.html', + styleUrls: ['./pmtct-calhiv-pdf-view.component.css'] +}) +export class PmtctCalhivPdfViewComponent implements OnInit, OnChanges { + @Input() rriMonthlySummary = []; + @Input() params: any; + @Input() sectionDefs: any; + public rriSummaryColdef = []; + public data = []; + public reportData: any; + public rrisummaryGridOptions = { + enableColResize: true, + enableSorting: true, + enableFilter: true, + showToolPanel: false, + groupDefaultExpanded: -1, + onGridSizeChanged: () => {}, + onGridReady: () => {} + }; + + public locations = []; + public displayTabluarFilters = true; + public headers = []; + public selectedResult = ''; + + constructor(private _router: Router, private _route: ActivatedRoute) {} + + public ngOnInit() {} + + public ngOnChanges(changes: SimpleChanges) { + if (changes.rriMonthlySummary) { + this.processSummaryData(this.rriMonthlySummary); + } + } + + public processSummaryData(results) { + this.data = results; + this.setRowData(results); + } + + public setRowData(results) { + const sectionDefs = this.sectionDefs; + _.each(results, (result: any) => { + // console.log('result', result); + this.locations.push(result.location); + Object.keys(result).forEach((key, index) => { + _.each(sectionDefs, (sectionDef: any) => { + const indicators = sectionDef.indicators; + _.each(indicators, (indicator: any) => { + const locationData = { + location: result.location, + location_uuid: result.location_uuid + }; + locationData[indicator.indicator] = result[indicator.indicator]; + if (indicator.indicator === key) { + if (indicator.hasOwnProperty('data') === false) { + indicator['data'] = []; + } + indicator['data'].push(locationData); + } + }); + }); + }); + }); + + this.reportData = sectionDefs; + } + + public viewPatientList(data, indicator) { + const params: any = { + locationUuids: data.location_uuid, + indicators: indicator, + startDate: this.params.startDate, + endDate: this.params.endDate + }; + this._router.navigate(['./patient-list'], { + relativeTo: this._route, + queryParams: params + }); + } + + public downloadPdf() { + const data = document.getElementById('contentToConvert'); + html2canvas(data).then((canvas) => { + // Few necessary setting options + const imgWidth = 200; + const pageHeight = 287; + const imgHeight = (canvas.height * imgWidth) / canvas.width; + let heightLeft = imgHeight; + const contentDataURL = canvas.toDataURL('image/png'); + const pdf = new jspdf('P', 'mm', 'a4'); // A4 size page of PDF + let position = 15; + pdf.setFontSize(20); + pdf.text(10, 10, 'RRI Indicators Report'); + pdf.addImage(contentDataURL, 'PNG', 10, position, imgWidth, imgHeight); + heightLeft -= pageHeight; + while (heightLeft >= 0) { + position = heightLeft - imgHeight; + pdf.addPage(); + pdf.addImage(contentDataURL, 'PNG', 10, position, imgWidth, imgHeight); + heightLeft -= pageHeight; + } + pdf.save('RRI Report.pdf'); + }); + } +} diff --git a/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-rri-report.component.css b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-rri-report.component.css new file mode 100644 index 000000000..1ea7cf5ca --- /dev/null +++ b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-rri-report.component.css @@ -0,0 +1,46 @@ +#report-container { + background: #fff; + margin-top: 10px; +} +.oncology-title-header { + padding-top: 5px; + padding-bottom: 5px; +} +#oncology-summary-indicators-table { + margin-top: 10px; +} +.loader { + position: absolute; + left: 0; + width: 100%; + height: 100%; + text-align: center; + z-index: 9; + box-sizing: border-box; + background-color: #fff; + color: #fff; + opacity: 0.8; +} + +.loader .fa:before { + margin-right: 12px; + display: inline-block; +} + +.loader span { + padding: 12px; + background-color: #0d6aad; + border-radius: 6px; + position: relative; + top: 50%; + transform: translateY(-50%); + display: inline-block; +} + +.fa-spin { + width: 16px; + margin-right: 8px; +} +.navigation-btn { + margin-top: 10px; +} diff --git a/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-rri-report.component.html b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-rri-report.component.html new file mode 100644 index 000000000..b36e4d171 --- /dev/null +++ b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-rri-report.component.html @@ -0,0 +1,53 @@ +
+
+
+

+ RRI Report Summary +

+
+ {{ errorObj.message }} +
+
+ {{ busyIndicator.message }} +
+
+
+ +
+
+ + + + + + + + +
+
+
diff --git a/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-rri-report.component.spec.ts b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-rri-report.component.spec.ts new file mode 100644 index 000000000..b171ff4ae --- /dev/null +++ b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-rri-report.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PmtctCalhivRriReportComponent } from './pmtct-calhiv-rri-report.component'; + +describe('PmtctCalhivRriReportComponent', () => { + let component: PmtctCalhivRriReportComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [PmtctCalhivRriReportComponent] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(PmtctCalhivRriReportComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-rri-report.component.ts b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-rri-report.component.ts new file mode 100644 index 000000000..a9461448e --- /dev/null +++ b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-rri-report.component.ts @@ -0,0 +1,123 @@ +import { PmtctCalhivRriReportService } from './../../etl-api/pmtct-calhiv-rri-report.service'; +import { take } from 'rxjs/operators'; +import { Component, OnInit, Input } from '@angular/core'; +import { Subject } from 'rxjs'; +import { Router, ActivatedRoute } from '@angular/router'; +import * as Moment from 'moment'; + +@Component({ + selector: 'pmtct-calhiv-rri-report', + templateUrl: './pmtct-calhiv-rri-report.component.html', + styleUrls: ['./pmtct-calhiv-rri-report.component.css'] +}) +export class PmtctCalhivRriReportComponent implements OnInit { + @Input() locations = ''; + public summaryTitle = 'RRI Monthly Summary Report'; + public params = { + startDate: '', + endDate: '', + locationUuids: '', + displayTabluarFilters: true, + reportName: this.summaryTitle, + _date: Moment().format('MMM YYYY') + }; + + public busyIndicator: any = { + busy: false, + message: 'Please wait...' // default message + }; + public errorObj = { + message: '', + isError: false + }; + public rriSummary: any = []; + public rriOutcomeSummary: any; + public sectionDefs: any; + public outcomeSectionDefs: any; + public currentView = 'pdf'; + + constructor( + private _router: Router, + private _route: ActivatedRoute, + private _pmtctCalhivRriReportService: PmtctCalhivRriReportService + ) {} + + public ngOnInit() {} + + public selectedFilter($event) { + this.setParams($event); + this.getRriSummary(this.params); + } + + public setParams(filterParams: any) { + this.params = { + startDate: filterParams.startDate, + endDate: filterParams.endDate, + locationUuids: filterParams.locationUuids, + displayTabluarFilters: true, + reportName: this.summaryTitle, + _date: Moment(filterParams.startDate).format('MMMM YYYY') + }; + } + + public loading() { + this.busyIndicator = { + busy: true, + message: 'Fetching report...please wait' + }; + } + + public endLoading() { + this.busyIndicator = { + busy: false, + message: '' + }; + } + + public getRriSummary(params: any) { + this.loading(); + this._pmtctCalhivRriReportService.getRriIndicatorsReport(params).subscribe( + (result: any) => { + if (result) { + this.rriSummary = result.result; + this.sectionDefs = result.sectionDefinitions; + this.endLoading(); + } + }, + (err) => { + this.endLoading(); + this.errorObj = { + isError: true, + message: err.error.message ? err.error.message : '' + }; + } + ); + } + + public onTabChanged($event) {} + + public setCellSelectionRri($event, $event2) { + this.viewPatientList($event); + } + + public viewPatientList(data) { + this._route.parent.params.subscribe((result: any) => { + if (result) { + data.location = result.location_uuid; + } + }); + + const params: any = { + locationUuids: data.location, + indicators: data.field, + startDate: this.params.startDate, + endDate: this.params.endDate, + reportName: this.summaryTitle + }; + + this._router.navigate(['./patient-list'], { + relativeTo: this._route, + queryParams: params + }); + } +} diff --git a/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-tabular.component.css b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-tabular.component.css new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-tabular.component.html b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-tabular.component.html new file mode 100644 index 000000000..1100d8cdd --- /dev/null +++ b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-tabular.component.html @@ -0,0 +1,20 @@ +
+
+

+ {{reportTitle}} for {{params.startDate}} to {{params.endDate}} +

+
+ + +
+
+ \ No newline at end of file diff --git a/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-tabular.component.ts b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-tabular.component.ts new file mode 100644 index 000000000..1e424db07 --- /dev/null +++ b/src/app/hiv-care-lib/pmtct-calhiv-rri-report/pmtct-calhiv-tabular.component.ts @@ -0,0 +1,122 @@ +import { take } from 'rxjs/operators'; +import { + Component, + OnInit, + Input, + OnChanges, + SimpleChanges +} from '@angular/core'; +import { Subject } from 'rxjs'; +import { Router, ActivatedRoute } from '@angular/router'; +import * as _ from 'lodash'; +import * as moment from 'moment'; + +@Component({ + selector: 'pmtct-calhiv-tabular', + templateUrl: './pmtct-calhiv-tabular.component.html', + styleUrls: [] +}) +export class PmtctCalhivRriTabularComponent implements OnInit, OnChanges { + @Input() rriMonthlySummary = []; + @Input() params: any; + @Input() sectionDefs: any; + @Input() reportTitle = ''; + @Input() reportType = ''; + public rriSummaryColdef = []; + public data = []; + public rrisummaryGridOptions = { + enableColResize: true, + enableSorting: true, + enableFilter: true, + showToolPanel: false, + groupDefaultExpanded: -1, + onGridSizeChanged: () => {}, + onGridReady: () => {} + }; + + constructor(private _router: Router, private _route: ActivatedRoute) {} + + public ngOnInit() {} + + public ngOnChanges(changes: SimpleChanges) { + if (changes.rriMonthlySummary) { + this.processSummaryData(this.rriMonthlySummary); + } + if (changes.sectionDefs) { + this.generateColumns(this.sectionDefs); + } + } + + public processSummaryData(results) { + this.data = results; + this.setRowData(results); + } + public onCellClicked(event) { + this.goToPatientList(event); + } + + public generateColumns(sectionsData) { + const defs = []; + defs.push({ + headerName: 'Location', + field: 'location', + pinned: 'left' + }); + // tslint:disable-next-line:prefer-for-of + for (let i = 0; i < sectionsData.length; i++) { + const section = sectionsData[i]; + const created: any = {}; + created.headerName = section.sectionTitle; + created.children = []; + // tslint:disable-next-line:prefer-for-of + for (let j = 0; j < section.indicators.length; j++) { + const child: any = { + headerName: section.indicators[j].label, + field: section.indicators[j].indicator + }; + created.children.push(child); + } + defs.push(created); + } + + this.rriSummaryColdef = defs; + } + + public translateIndicator(indicator: string) { + return indicator + .toLowerCase() + .split('_') + .map((word) => { + return word.charAt(0).toUpperCase() + word.slice(1); + }) + .join(' '); + } + + public setRowData(allRowsData) { + const finalRows = []; + _.each(allRowsData, (rowData) => { + const rowObj = {}; + _.each(rowData, (data, index) => { + rowObj[index] = data; + }); + finalRows.push(rowObj); + }); + + this.data = finalRows; + } + + public goToPatientList(data) { + // let queryParams = this.route.snapshot.params; + const params: any = { + locationUuids: data.data.location_uuid, + indicators: data.colDef.field, + startDate: this.params.startDate, + endDate: this.params.endDate + }; + + this._router.navigate(['./patient-list'], { + relativeTo: this._route, + queryParams: params + }); + } +} diff --git a/src/app/shared/dynamic-route/schema/clinic.dashboard.conf.json b/src/app/shared/dynamic-route/schema/clinic.dashboard.conf.json index 8c647994b..1757d4686 100644 --- a/src/app/shared/dynamic-route/schema/clinic.dashboard.conf.json +++ b/src/app/shared/dynamic-route/schema/clinic.dashboard.conf.json @@ -182,6 +182,12 @@ "icon": "fa fa-line-chart", "isSideBarOpen": false }, + { + "url": "pmtct-rri-report", + "label": "Pmtct-Calhiv RRI Report", + "icon": "fa fa-file", + "isSideBarOpen": false + }, { "url": "department-select", "label": "Change Department",