-
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-581: Develop Defaulter tracing register in POC
- Loading branch information
1 parent
ca10afe
commit 933c666
Showing
15 changed files
with
1,271 additions
and
637 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/app/etl-api/defaulter-tracing-register-resource.service.spec.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,18 @@ | ||
import { TestBed, inject } from '@angular/core/testing'; | ||
|
||
import { DefaulterTracingRegisterResourceService } from './defaulter-tracing-register-resource.service'; | ||
|
||
describe('DefaulterTracingRegisterResourceService', () => { | ||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
providers: [DefaulterTracingRegisterResourceService] | ||
}); | ||
}); | ||
|
||
it('should be created', inject( | ||
[DefaulterTracingRegisterResourceService], | ||
(service: DefaulterTracingRegisterResourceService) => { | ||
expect(service).toBeTruthy(); | ||
} | ||
)); | ||
}); |
63 changes: 63 additions & 0 deletions
63
src/app/etl-api/defaulter-tracing-register-resource.service.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,63 @@ | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Injectable } from '@angular/core'; | ||
import { AppSettingsService } from '../app-settings/app-settings.service'; | ||
import { catchError, map } from 'rxjs/operators'; | ||
import { Observable } from 'rxjs'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class DefaulterTracingRegisterResourceService { | ||
public get url(): string { | ||
return this.appSettingsService.getEtlRestbaseurl().trim(); | ||
} | ||
|
||
constructor( | ||
public http: HttpClient, | ||
public appSettingsService: AppSettingsService | ||
) {} | ||
|
||
public getDefaulterTracingRegisterMonthlyRegister( | ||
params: any | ||
): Observable<any> { | ||
console.log('params2etl: ', params); | ||
// tslint:disable-next-line: max-line-length | ||
return this.http | ||
.get( | ||
`${this.url}defaulter-tracing-register?&month=${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 getDefaulterTracingRegisterPatientList(params: any): Observable<any> { | ||
// tslint:disable-next-line: max-line-length | ||
return this.http | ||
.get( | ||
`${this.url}defaulter-tracing-register-patient-list?startDate=${params.startDate}&endDate=${params.month}&locationUuids=${params.locationUuids}&indicators=${params.indicators}¤tView=${params.currentView}` | ||
) | ||
.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.
30 changes: 30 additions & 0 deletions
30
...v/defaulter-tracing-register/defaulter-patient-list/defaulter-patient-list.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,30 @@ | ||
<div> | ||
<button class="btn btn-primary" (click)="goBack()"> | ||
<span class="glyphicon glyphicon-arrow-left"></span> | ||
<span> Back</span> | ||
</button> | ||
</div> | ||
<div class="loader" *ngIf="isLoading"> | ||
<span><i class="fa fa-spinner fa-spin"></i>Loading...</span> | ||
</div> | ||
<h3>Defaulter Tracing Register patient list</h3> | ||
<hr /> | ||
<patient-list | ||
[extraColumns]="extraColumns" | ||
[overrideColumns]="overrideColumns" | ||
[data]="patientData" | ||
></patient-list> | ||
<div *ngIf="patientData"> | ||
<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> |
24 changes: 24 additions & 0 deletions
24
...efaulter-tracing-register/defaulter-patient-list/defaulter-patient-list.component.spec.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,24 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { DefaulterPatientListComponent } from './defaulter-patient-list.component'; | ||
|
||
describe('DefaulterPatientListComponent', () => { | ||
let component: DefaulterPatientListComponent; | ||
let fixture: ComponentFixture<DefaulterPatientListComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [DefaulterPatientListComponent] | ||
}).compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(DefaulterPatientListComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
122 changes: 122 additions & 0 deletions
122
...hiv/defaulter-tracing-register/defaulter-patient-list/defaulter-patient-list.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,122 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { ActivatedRoute, Router } from '@angular/router'; | ||
import { Location } from '@angular/common'; | ||
import { DefaulterTracingRegisterResourceService } from 'src/app/etl-api/defaulter-tracing-register-resource.service'; | ||
|
||
@Component({ | ||
selector: 'app-defaulter-patient-list', | ||
templateUrl: './defaulter-patient-list.component.html', | ||
styleUrls: ['./defaulter-patient-list.component.css'] | ||
}) | ||
export class DefaulterPatientListComponent implements OnInit { | ||
public params: any; | ||
public patientData: any; | ||
public extraColumns: Array<any> = []; | ||
public isLoading = true; | ||
public overrideColumns: Array<any> = []; | ||
public selectedIndicator: string; | ||
public selectedIndicatorGender: string; | ||
public hasLoadedAll = false; | ||
public hasError = false; | ||
public selectedMonth: String; | ||
|
||
constructor( | ||
private router: Router, | ||
private route: ActivatedRoute, | ||
private _location: Location, | ||
public dtrResourceService: DefaulterTracingRegisterResourceService | ||
) {} | ||
|
||
ngOnInit() { | ||
this.route.queryParams.subscribe( | ||
(params) => { | ||
if (params && params.month) { | ||
this.params = params; | ||
this.selectedIndicator = params.indicatorHeader; | ||
this.selectedIndicatorGender = params.indicatorGender; | ||
this.getPatientList(params); | ||
} | ||
}, | ||
(error) => { | ||
console.error('Error', error); | ||
} | ||
); | ||
this.addExtraColumns(); | ||
} | ||
|
||
private getPatientList(params: any) { | ||
this.dtrResourceService | ||
.getDefaulterTracingRegisterPatientList(params) | ||
.subscribe((data) => { | ||
this.isLoading = false; | ||
this.patientData = data.results.results; | ||
this.hasLoadedAll = true; | ||
}); | ||
} | ||
|
||
public addExtraColumns() { | ||
const extraColumns = { | ||
phone_number: 'Phone', | ||
enrollment_date: 'Enrolment Date', | ||
last_appointment: 'Last Appointment', | ||
latest_rtc_date: 'Latest RTC Date', | ||
days_since_rtc_date: 'Days since RTC', | ||
arv_first_regimen: 'ARV first regimen', | ||
arv_first_regimen_start_date: 'First ARV start date', | ||
cur_meds: 'Current Regimen', | ||
cur_arv_line: 'Current ARV Line', | ||
arv_start_date: 'ARV Start Date', | ||
latest_vl: 'Latest VL', | ||
vl_category: 'VL Category', | ||
latest_vl_date: 'Latest VL Date', | ||
previous_vl: 'Previous VL', | ||
previous_vl_date: 'Previous VL Date', | ||
ovcid_id: 'OVCID' | ||
}; | ||
|
||
const status = this.selectedIndicatorGender.split(' - ')[0]; | ||
if (status === 'Died') { | ||
Object.assign(extraColumns, { | ||
death_date: 'Death Date', | ||
cause_of_death: 'Cause of Death' | ||
}); | ||
} else if (status === 'Transferred Out') { | ||
Object.assign(extraColumns, { | ||
transfer_out_date_v1: 'Transfer out date' | ||
}); | ||
} | ||
for (const indicator in extraColumns) { | ||
if (indicator) { | ||
this.extraColumns.push({ | ||
headerName: extraColumns[indicator], | ||
field: indicator | ||
}); | ||
} | ||
} | ||
|
||
this.overrideColumns.push( | ||
{ | ||
field: 'identifiers', | ||
cellRenderer: (column) => { | ||
return ( | ||
'<a href="javascript:void(0);" title="Identifiers">' + | ||
column.value + | ||
'</a>' | ||
); | ||
} | ||
}, | ||
{ | ||
field: 'last_appointment', | ||
width: 200 | ||
}, | ||
{ | ||
field: 'cur_prep_meds_names', | ||
width: 160 | ||
} | ||
); | ||
} | ||
|
||
public goBack() { | ||
this._location.back(); | ||
} | ||
} |
Oops, something went wrong.