From e7fe89b6e001b6308733fae6888f8854052aaa11 Mon Sep 17 00:00:00 2001 From: Faith Kamau <121166087+hiqedme@users.noreply.github.com> Date: Wed, 5 Jun 2024 15:38:52 +0300 Subject: [PATCH] POC-739 added data for HEI --- .../hei-register/hei-register.component.html | 260 ++++-------------- .../hei-register/hei-register.component.ts | 52 ++-- .../etl-api/hei-register-resource.service.ts | 58 ++++ 3 files changed, 141 insertions(+), 229 deletions(-) create mode 100644 src/app/etl-api/hei-register-resource.service.ts 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 index abed1fc6c..fedc228d4 100644 --- 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 @@ -35,7 +35,7 @@

Viewing a Draft Version of the Report for the chosen month. This report is likely to change without warning. -
+
@@ -61,7 +61,7 @@

First HIV DNA PCR Test at Birth, 6 weeks or First Contact - Second HIV DNA PCR Tes + Second HIV DNA PCR Test Third HIV DNA PCR Test HEI Outcomes at 12 months Confirmatory PCR @@ -79,10 +79,10 @@

Date of Collected enrollment (DD/MM/YYYY) - HEI ID (MFL-YYYY-NNNN) - Infant's Name - DOB (DD/MM/YYYY) - Header + Birth Certificate Number + HEI ID (MFL-YYYY-NNNN) + Infant's Name + DOB (DD/MM/YYYY) Sex Infant Prophylaxis 1=NVP, 2=AZT, 3=NVP &AZT, 4=None, @@ -152,206 +152,54 @@

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + {{a+1}} + {{data.date_enrolled}} + {{data.Birth_Certificate_number}} + {{data.HEI_ID}} + {{data.Infant_name}} + {{data.birth_date}} + Sex + {{null}} + {{data.parent_name}} + {{data.age_in_weeks_on_first_pcr}} + {{date_enrolled}} + {{data.first_pcr_date}} + {{data.age_in_months_on_second_pcr}} + {{data.second_pcr_date}} + {{data.age_in_months_on_third_pcr}} + {{data.third_pcr_date}} + Infant Feeding + {{data.hei_outcome}} + {{data.age_in_months_on_confirm_pcr}} + {{data.confirm_pcr_date}} + {{data.age_in_months_on_first_antibody}} + {{data.first_antibody_date}} + {{null}} + {{null}} + {{null}} + + + {{data.NUPI}} + {{data.gender}} + {{data.Phone_Number}} + {{data.results_pcr_first_pcr}} + {{data.results_pcr_second_pcr}} + {{data.results_pcr_third_pcr}} + {{data.infant_feeding}} + {{data.results_confirm_pcr}} + {{data.results_first_antibody}} + {{null}} + {{null}} + + + + + +

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 index 2a9de1b47..5721caff6 100644 --- 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 @@ -2,6 +2,7 @@ import { Component, OnInit, Output } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; import * as _ from 'lodash'; import * as Moment from 'moment'; +import { HeiRegisterResourceService } from 'src/app/etl-api/hei-register-resource.service'; @Component({ selector: 'app-hei-register', templateUrl: './hei-register.component.html', @@ -12,7 +13,7 @@ export class HeiRegisterComponent implements OnInit { public params: any; public indicators: string; public selectedIndicators = []; - public txnewReportSummaryData: any = []; + public heiRegisterData: any = []; public columnDefs: any = []; public reportName = 'HEI Register'; public currentView = 'monthly'; @@ -48,7 +49,11 @@ export class HeiRegisterComponent implements OnInit { this._locationUuids = locationUuids; } - constructor(public router: Router, public route: ActivatedRoute) { + constructor( + public router: Router, + public route: ActivatedRoute, + public heiRegisterService: HeiRegisterResourceService + ) { this.route.queryParams.subscribe((data) => { data.month === undefined ? (this._month = Moment() @@ -71,8 +76,8 @@ export class HeiRegisterComponent implements OnInit { this.route.parent.parent.params.subscribe((params: any) => { this.storeParamsInUrl(params.location_uuid); }); - this.txnewReportSummaryData = []; - // this.getTxNewReport(this.params); + this.heiRegisterData = []; + this.getHeiRegisterData(this.params); } public storeParamsInUrl(param) { @@ -89,31 +94,32 @@ export class HeiRegisterComponent implements OnInit { }); } - // 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 getHeiRegisterData(params: any) { + this.isLoading = true; + this.heiRegisterService.getHeiRegister(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 { + console.log('HeiDataSummary: ', data); + this.showInfoMessage = false; + this.columnDefs = data.sectionDefinitions; + this.heiRegisterData = data; + // this.calculateTotalSummary(); + this.isLoading = false; + this.showDraftReportAlert(this._month); + } + }); + } public calculateTotalSummary() { const totalsRow = []; - if (this.txnewReportSummaryData.length > 0) { + if (this.heiRegisterData.length > 0) { const totalObj = { location: 'Totals' }; - _.each(this.txnewReportSummaryData, (row) => { + _.each(this.heiRegisterData, (row) => { Object.keys(row).map((key) => { if (Number.isInteger(row[key]) === true) { if (totalObj[key]) { diff --git a/src/app/etl-api/hei-register-resource.service.ts b/src/app/etl-api/hei-register-resource.service.ts new file mode 100644 index 000000000..9fe930f89 --- /dev/null +++ b/src/app/etl-api/hei-register-resource.service.ts @@ -0,0 +1,58 @@ +import { Injectable } from '@angular/core'; +import { AppSettingsService } from '../app-settings/app-settings.service'; +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import * as Moment from 'moment'; +import { catchError, map } from 'rxjs/operators'; +@Injectable({ + providedIn: 'root' +}) +export class HeiRegisterResourceService { + public get url(): string { + return this.appSettingsService.getEtlRestbaseurl().trim(); + } + constructor( + public http: HttpClient, + public appSettingsService: AppSettingsService + ) {} + public getHeiRegister(params: any): Observable { + // tslint:disable-next-line: max-line-length + return this.http + .get( + `${this.url}hei-register?endDate=${params.month}&locationUuids=${params.locationUuids}` + ) + .pipe( + catchError((err: any) => { + const error: any = err; + const errorObj = { + error: error.status, + message: error.statusText + }; + return Observable.of(errorObj); + }), + map((response: Response) => { + return response; + }) + ); + } + public getTxNewPatientList(params: any): Observable { + // tslint:disable-next-line: max-line-length + return this.http + .get( + `${this.url}txnew-summary-patient-list?endDate=${params.month}&locationUuids=${params.locationUuids}&indicators=${params.indicators}` + ) + .pipe( + catchError((err: any) => { + const error: any = err; + const errorObj = { + error: error.status, + message: error.statusText + }; + return Observable.of(errorObj); + }), + map((response: Response) => { + return response; + }) + ); + } +}