Skip to content

Commit f1f5448

Browse files
hiqedmejecihjoy
andauthored
POC-115: Family Testing report improvements
--------- Co-authored-by: jecihjoy <jecihjoy@gmail.com>
1 parent f0cb0cf commit f1f5448

16 files changed

+881
-308
lines changed

src/app/clinic-dashboard/hiv/hiv-program.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import {
1515
FieldsetModule,
1616
ButtonModule,
1717
GrowlModule,
18-
AccordionModule
18+
AccordionModule,
19+
DialogModule
1920
} from 'primeng/primeng';
2021
import { AgGridModule } from 'ag-grid-angular/main';
2122
import { DateTimePickerModule } from '@ampath-kenya/ngx-openmrs-formentry';
@@ -102,6 +103,7 @@ import { ClinicDashboardCovid19ReportComponent } from './covid-19-report/clinic-
102103
TabViewModule,
103104
FieldsetModule,
104105
ButtonModule,
106+
DialogModule,
105107
GrowlModule,
106108
AccordionModule,
107109
ChartModule,
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import { SelectDepartmentService } from './../../../../shared/services/select-department.service';
2+
import { DataAnalyticsDashboardService } from './../../../services/data-analytics-dashboard.services';
3+
import { LocalStorageService } from './../../../../utils/local-storage.service';
4+
import { DepartmentProgramsConfigService } from './../../../../etl-api/department-programs-config.service';
5+
import { FamilyTestingService } from './../../../../etl-api/family-testing-resource.service';
6+
import { FamilyTestingBaseComponent } from './../../../../hiv-care-lib/family-testing/family-testing-base.component';
7+
import { Component, OnInit } from '@angular/core';
8+
import { ActivatedRoute, Router } from '@angular/router';
9+
import { Location } from '@angular/common';
10+
import { take } from 'rxjs/operators';
11+
import * as _ from 'lodash';
12+
import * as rison from 'rison-node';
13+
14+
@Component({
15+
selector: 'app-contact-testing',
16+
templateUrl:
17+
'./../../../../hiv-care-lib/family-testing/family-testing-base.component.html',
18+
styleUrls: [
19+
'./../../../../hiv-care-lib/family-testing/family-testing-base.component.css'
20+
]
21+
})
22+
export class ContactTestingComponent
23+
extends FamilyTestingBaseComponent
24+
implements OnInit {
25+
public enabledControls = 'familyTestingControls,locationControl';
26+
constructor(
27+
public router: Router,
28+
public route: ActivatedRoute,
29+
public familyTestingService: FamilyTestingService,
30+
public departmentProgramService: DepartmentProgramsConfigService,
31+
public localStorage: LocalStorageService,
32+
private dataAnalyticsDashboardService: DataAnalyticsDashboardService,
33+
public _selectDepartmentService: SelectDepartmentService,
34+
public location: Location
35+
) {
36+
super(
37+
router,
38+
route,
39+
familyTestingService,
40+
departmentProgramService,
41+
localStorage,
42+
location,
43+
_selectDepartmentService
44+
);
45+
}
46+
47+
ngOnInit() {
48+
this.getCurrentDepartment();
49+
this.loadReportParamsFromUrl();
50+
}
51+
52+
public generateReport() {
53+
this.storeUrlParams();
54+
this.locationUuid = this.getSelectedLocations(this.locationUuids);
55+
super.generateReport();
56+
}
57+
58+
public storeUrlParams() {
59+
this.setSelectedLocation();
60+
const state = {
61+
locationUuids: this.getSelectedLocations(this.locationUuids),
62+
eligible: this.isEligible,
63+
childStatus: this.childStatus,
64+
elicitedClients: this.elicitedClients,
65+
start_date: this.elicitedStartDate,
66+
end_date: this.elicitedEndDate,
67+
program_type: this.programs
68+
};
69+
const stateUrl = rison.encode(state);
70+
const path = this.router.parseUrl(this.location.path());
71+
path.queryParams = {
72+
state: stateUrl
73+
};
74+
75+
this.location.replaceState(path.toString());
76+
}
77+
78+
public loadReportParamsFromUrl() {
79+
const path = this.router.parseUrl(this.location.path());
80+
if (path.queryParams['state']) {
81+
const state = rison.decode(path.queryParams['state']);
82+
this.locationUuid = state.locations;
83+
(this.isEligible = state.eligible),
84+
(this.childStatus = state.childStatus),
85+
(this.elicitedClients = state.elicitedClients),
86+
(this.elicitedStartDate = state.start_date),
87+
(this.elicitedEndDate = state.end_date),
88+
(this.programs = state.program_type);
89+
}
90+
91+
if (path.queryParams['state']) {
92+
this.generateReport();
93+
}
94+
}
95+
96+
public setSelectedLocation() {
97+
this.dataAnalyticsDashboardService
98+
.getSelectedLocations()
99+
.pipe(take(1))
100+
.subscribe((data) => {
101+
if (data) {
102+
this.locationUuids = data.locations;
103+
}
104+
});
105+
}
106+
107+
private getSelectedLocations(locationUuids: Array<any>): string {
108+
return locationUuids.map((location) => location.value).join(',');
109+
}
110+
}

src/app/data-analytics-dashboard/hiv/data-analytics-hiv.module.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import { OncologyProgramModule } from './../../oncology-care-lib/oncology-care-l
3333
import { IPTReportComponent } from './ipt-report/ipt-report.component';
3434
import { DataAnalyticsMonthlyReportComponent } from './monthly-reports-dashboard/data-analytics-monthly-reports.component';
3535
import { DataAnalyticsHivGainsAndLossesComponent } from './hiv-monthly-gains-and-losses/data-analytics-hiv-gains-and-losses.component';
36+
import { ContactTestingComponent } from './contact-testing/contact-testing/contact-testing.component';
37+
import { DialogModule } from 'primeng/primeng';
3638

3739
@NgModule({
3840
imports: [
@@ -49,7 +51,8 @@ import { DataAnalyticsHivGainsAndLossesComponent } from './hiv-monthly-gains-and
4951
ChangeDepartmentModule,
5052
KibanaLibModule,
5153
ReportingUtilitiesModule,
52-
OncologyProgramModule
54+
OncologyProgramModule,
55+
DialogModule
5356
],
5457
exports: [
5558
RouterModule,
@@ -74,7 +77,8 @@ import { DataAnalyticsHivGainsAndLossesComponent } from './hiv-monthly-gains-and
7477
MOH412HIVDataAnalyticsPatientListComponent,
7578
IPTReportComponent,
7679
DataAnalyticsMonthlyReportComponent,
77-
DataAnalyticsHivGainsAndLossesComponent
80+
DataAnalyticsHivGainsAndLossesComponent,
81+
ContactTestingComponent
7882
],
7983
providers: [
8084
DataAnalyticsDashboardService,

src/app/data-analytics-dashboard/hiv/data-analytics-hiv.routes.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ import { IPTReportComponent } from './ipt-report/ipt-report.component';
3636
import { ClinicFlowProviderStatsPatientListComponent } from './../../hiv-care-lib/clinic-flow/clinic-flow-provider-stats-patient-list.component';
3737
import { DataAnalyticsHivGainsAndLossesComponent } from './hiv-monthly-gains-and-losses/data-analytics-hiv-gains-and-losses.component';
3838
import { PatientGainsAndLosesPatientListComponent } from './../../hiv-care-lib/patient-gains-and-loses/patient-gains-and-loses-patient-list/patient-gains-and-loses-patient-list.component';
39+
import { ContactTestingComponent } from './contact-testing/contact-testing/contact-testing.component';
40+
import { FamilyTestingContactComponent } from 'src/app/hiv-care-lib/family-testing/family-testing-contact-list.component';
41+
import { AddContactTraceComponent } from 'src/app/hiv-care-lib/family-testing/contact-trace/add-contact-trace.component';
42+
import { EditContactTraceComponent } from 'src/app/hiv-care-lib/family-testing/contact-trace/edit-contact-trace.component';
3943
const routes: Routes = [
4044
{
4145
path: 'clinic-flow',
@@ -246,6 +250,27 @@ const routes: Routes = [
246250
data: { multipleLocation: true }
247251
}
248252
]
253+
},
254+
{
255+
path: 'family-testing',
256+
children: [
257+
{
258+
path: '',
259+
component: ContactTestingComponent
260+
},
261+
{
262+
path: 'contact-list',
263+
component: FamilyTestingContactComponent
264+
},
265+
{
266+
path: 'contact-list/add-contact-trace',
267+
component: AddContactTraceComponent
268+
},
269+
{
270+
path: 'contact-list/edit-contact-trace',
271+
component: EditContactTraceComponent
272+
}
273+
]
249274
}
250275
];
251276

src/app/etl-api/family-testing-resource.service.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ export class FamilyTestingService {
2121
return this.appSettingsService.getOpenmrsRestbaseurl().trim();
2222
}
2323

24-
public getFamilyTestingReportData(patientId: string): Observable<any> {
24+
public getFamilyTestingReportData(params: any): Observable<any> {
25+
const urlParams = this.getUrlRequestParams(params);
26+
2527
return this.http
26-
.get(`${this.url}patient-family-history?patientUuid=${patientId}`)
28+
.get(`${this.url}patient-family-history`, {
29+
params: urlParams
30+
})
2731
.pipe(
2832
catchError((err: any) => {
2933
const error: any = err;
@@ -42,8 +46,8 @@ export class FamilyTestingService {
4246
public getUrlRequestParams(params): HttpParams {
4347
let urlParams: HttpParams = new HttpParams();
4448

45-
if (params.locationUuid && params.locationUuid !== '') {
46-
urlParams = urlParams.set('locationUuid', params.locationUuid);
49+
if (params.locationUuids && params.locationUuids !== '') {
50+
urlParams = urlParams.set('locationUuids', params.locationUuids);
4751
}
4852

4953
if (params.isEligible && params.isEligible !== '') {
@@ -59,21 +63,27 @@ export class FamilyTestingService {
5963
}
6064

6165
if (params.programType && params.programType !== '') {
62-
urlParams = urlParams.set('program_type', params.programType);
66+
urlParams = urlParams.set('programType', params.programType);
6367
}
68+
6469
if (params.childStatus && params.childStatus !== '') {
6570
urlParams = urlParams.set('child_status', params.childStatus);
6671
}
6772
if (params.elicitedClients && params.elicitedClients !== '') {
6873
urlParams = urlParams.set('elicited_clients', params.elicitedClients);
6974
}
75+
if (params.patientUuid && params.patientUuid !== '') {
76+
urlParams = urlParams.set('patientUuid', params.patientUuid);
77+
}
78+
urlParams = urlParams.set('startIndex', params.startIndex);
7079

7180
return urlParams;
7281
}
7382

7483
public getFamilyTreePatientList(params): Observable<any> {
7584
const urlParams = this.getUrlRequestParams(params);
7685
const url = this.url + 'family-history-patient-list';
86+
7787
return this.http
7888
.get(url, {
7989
params: urlParams

src/app/hiv-care-lib/family-testing/contact-list/contact-list.component.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ export class ContactListComponent implements OnInit {
4646
width: 150
4747
},
4848
{
49-
field: 'test_result_value',
49+
field: 'reported_test_date',
50+
headerName: 'Reported test date',
51+
width: 150
52+
},
53+
54+
{
55+
field: 'modified_fm_status',
5056
headerName: 'Current test results',
5157
width: 150
5258
},
@@ -80,7 +86,7 @@ export class ContactListComponent implements OnInit {
8086

8187
public getFamilyTestingContactListData(patientId: string) {
8288
this.familyTestingService
83-
.getFamilyTestingReportData(patientId)
89+
.getFamilyTestingReportData({ patientUuid: patientId })
8490
.subscribe((data) => {
8591
if (data.result && data.result.length > 0) {
8692
this.getContacts(data.result);

0 commit comments

Comments
 (0)