-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
POC-392: Developed Advanced HIV Disease Report
- Loading branch information
Showing
24 changed files
with
1,581 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
src/app/clinic-dashboard/hiv/ahd-report/ahd-report.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { AhdReportBaseComponent } from 'src/app/hiv-care-lib/ahd-monthly-report/ahd-report-base/ahd-report-base.component'; | ||
import { Router, ActivatedRoute } from '@angular/router'; | ||
import { AhdResourceService } from 'src/app/etl-api/ahd-resource.service'; | ||
import * as Moment from 'moment'; | ||
@Component({ | ||
selector: 'ahd-reports', | ||
templateUrl: | ||
'../../../hiv-care-lib/ahd-monthly-report/ahd-report-base/ahd-report-base.component.html' | ||
}) | ||
export class AhdReportComponent | ||
extends AhdReportBaseComponent | ||
implements OnInit { | ||
constructor( | ||
public router: Router, | ||
public route: ActivatedRoute, | ||
public ahdReport: AhdResourceService | ||
) { | ||
super(router, route, ahdReport); | ||
} | ||
public params: any; | ||
public prepReportSummaryData: any = []; | ||
public columnDefs: any = []; | ||
|
||
public statusError = false; | ||
public errorMessage = ''; | ||
public showInfoMessage = false; | ||
public isLoading = false; | ||
ngOnInit() { | ||
this.params = { _month: Moment().format('YYYY-MM-DD') }; | ||
this.route.queryParams.subscribe( | ||
(params: any) => { | ||
if (params && params.month) { | ||
this.isLoading = true; | ||
this.params = params; | ||
this.generateReport(); | ||
} | ||
}, | ||
(error) => { | ||
console.error('Error', error); | ||
this.showInfoMessage = true; | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
src/app/data-analytics-dashboard/hiv/ahd-report/ahd-report.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { Router, ActivatedRoute } from '@angular/router'; | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Location } from '@angular/common'; | ||
import { take } from 'rxjs/operators'; | ||
import * as rison from 'rison-node'; | ||
import * as Moment from 'moment'; | ||
|
||
import { AhdReportBaseComponent } from 'src/app/hiv-care-lib/ahd-monthly-report/ahd-report-base/ahd-report-base.component'; | ||
import { DataAnalyticsDashboardService } from '../../services/data-analytics-dashboard.services'; | ||
import { AhdResourceService } from 'src/app/etl-api/ahd-resource.service'; | ||
|
||
@Component({ | ||
selector: 'ahd-report', | ||
templateUrl: | ||
'../../../hiv-care-lib/ahd-monthly-report/ahd-report-base/ahd-report-base.component.html' | ||
}) | ||
export class AhdReportComponent | ||
extends AhdReportBaseComponent | ||
implements OnInit { | ||
public enabledControls = 'locationControl,monthControl'; | ||
|
||
constructor( | ||
public router: Router, | ||
public route: ActivatedRoute, | ||
public ahdReport: AhdResourceService, | ||
private dataAnalyticsDashboardService: DataAnalyticsDashboardService, | ||
private location: Location | ||
) { | ||
super(router, route, ahdReport); | ||
} | ||
|
||
public ngOnInit() { | ||
this.loadReportParamsFromUrl(); | ||
} | ||
|
||
public generateReport() { | ||
this.setSelectedLocation(); | ||
this.storeParamsInUrl(); | ||
|
||
if (Array.isArray(this.locationUuids) && this.locationUuids.length > 0) { | ||
this.params = { | ||
locationUuids: this.getSelectedLocations(this.locationUuids), | ||
month: this._month | ||
}; | ||
super.generateReport(); | ||
super.showDraftReportAlert(this._month); | ||
} else { | ||
this.errorMessage = 'Locations are required!'; | ||
} | ||
} | ||
|
||
public storeParamsInUrl() { | ||
const state = { | ||
locationUuids: this.getSelectedLocations(this.locationUuids), | ||
month: this._month | ||
}; | ||
const stateUrl = rison.encode(state); | ||
const path = this.router.parseUrl(this.location.path()); | ||
path.queryParams = { | ||
state: stateUrl | ||
}; | ||
|
||
this.location.replaceState(path.toString()); | ||
} | ||
|
||
public loadReportParamsFromUrl() { | ||
const path = this.router.parseUrl(this.location.path()); | ||
if (path.queryParams['state']) { | ||
const state = rison.decode(path.queryParams['state']); | ||
this.locationUuids = state.locations; | ||
this.month = state.month; | ||
} | ||
|
||
if (path.queryParams['state']) { | ||
this.generateReport(); | ||
} | ||
} | ||
|
||
public setSelectedLocation() { | ||
this.dataAnalyticsDashboardService | ||
.getSelectedLocations() | ||
.pipe(take(1)) | ||
.subscribe((data) => { | ||
if (data) { | ||
this.locationUuids = data.locations; | ||
} | ||
}); | ||
} | ||
|
||
private getSelectedLocations(locationUuids: Array<any>): string { | ||
return locationUuids.map((location) => location.value).join(','); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
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 AhdResourceService { | ||
public get url(): string { | ||
return this.appSettingsService.getEtlRestbaseurl().trim(); | ||
} | ||
constructor( | ||
public http: HttpClient, | ||
public appSettingsService: AppSettingsService | ||
) {} | ||
public getAhdMonthlyReport(params: any): Observable<any> { | ||
// tslint:disable-next-line: max-line-length | ||
|
||
const stardDate = this.getDates(params.month).currentMonthFirstDate; | ||
return this.http | ||
.get( | ||
`${this.url}ahd-monthly-summary?endDate=${params.month}&startDate=${stardDate}&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 getDates(currentEndDate) { | ||
// Convert the currentEndDate string to a Date object | ||
const currentDate = new Date(currentEndDate); | ||
|
||
// Get the current month and year | ||
const currentMonth = currentDate.getMonth(); | ||
const currentYear = currentDate.getFullYear(); | ||
|
||
// Calculate the previous month's last date | ||
const previousMonthLastDate = new Date( | ||
currentYear, | ||
currentMonth, | ||
0 | ||
).getDate(); | ||
|
||
// Calculate the current month's end date | ||
const currentMonthEndDate = new Date( | ||
currentYear, | ||
currentMonth + 1, | ||
0 | ||
).getDate(); | ||
|
||
// Calculate the current month's first date | ||
const currentMonthFirstDate = new Date(currentYear, currentMonth, 1); | ||
|
||
// Format the dates as strings in the "YYYY-MM-DD" format | ||
const previousMonthLastDateString = | ||
currentYear + | ||
'-' + | ||
currentMonth.toString().padStart(2, '0') + | ||
'-' + | ||
previousMonthLastDate.toString().padStart(2, '0'); | ||
|
||
const currentMonthEndDateString = currentEndDate; | ||
const currentMonthFirstDateString = | ||
currentMonthFirstDate.getFullYear() + | ||
'-' + | ||
(currentMonthFirstDate.getMonth() + 1).toString().padStart(2, '0') + | ||
'-' + | ||
currentMonthFirstDate.getDate().toString().padStart(2, '0'); | ||
|
||
// Return the formatted dates | ||
return { | ||
currentMonthFirstDate: currentMonthFirstDateString | ||
}; | ||
} | ||
|
||
public getAhdPatientList(params: any, locationUuid: string): Observable<any> { | ||
// tslint:disable-next-line: max-line-length | ||
const stardDate = this.getDates(params.month).currentMonthFirstDate; | ||
|
||
return this.http | ||
.get( | ||
`${this.url}ahd-monthly-summary-patient-list?indicators=${params.indicators}&startDate=${stardDate}&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; | ||
}) | ||
); | ||
} | ||
} |
Empty file.
34 changes: 34 additions & 0 deletions
34
...nthly-report/ahd-monthly-report-patientlist/ahd-monthly-report-patientlist.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<div> | ||
<button class="btn btn-primary" (click)="goBack()"> | ||
<span class="glyphicon glyphicon-arrow-left"></span> | ||
<span>Go back to report view</span> | ||
</button> | ||
</div> | ||
<div class="loader" *ngIf="isLoading"> | ||
<span><i class="fa fa-spinner fa-spin"></i>Loading...</span> | ||
</div> | ||
<h3> | ||
<b>{{ selectedIndicatorGender }} {{ selectedIndicator }}</b> patient list | ||
</h3> | ||
<hr /> | ||
<patient-list | ||
[extraColumns]="extraColumns" | ||
[overrideColumns]="overrideColumns" | ||
[data]="patientData" | ||
></patient-list> | ||
|
||
<div *ngIf="hasLoadedAll"> | ||
<p class="bg-info" style="padding: 4px"> | ||
<b> | ||
<span style="color: green" class="glyphicon glyphicon-ok" | ||
>All records loaded {{ '[ ' + patientData.length + ' ]' }}</span | ||
></b | ||
> | ||
</p> | ||
|
||
<p></p> | ||
</div> | ||
|
||
<div *ngIf="hasError"> | ||
<p class="alert-error alert">Error loading patient list.</p> | ||
</div> |
Oops, something went wrong.