Skip to content

Commit

Permalink
POC-115: Family Testing report improvements
Browse files Browse the repository at this point in the history
---------

Co-authored-by: jecihjoy <[email protected]>
  • Loading branch information
hiqedme and jecihjoy authored Apr 4, 2023
1 parent f0cb0cf commit f1f5448
Show file tree
Hide file tree
Showing 16 changed files with 881 additions and 308 deletions.
4 changes: 3 additions & 1 deletion src/app/clinic-dashboard/hiv/hiv-program.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
FieldsetModule,
ButtonModule,
GrowlModule,
AccordionModule
AccordionModule,
DialogModule
} from 'primeng/primeng';
import { AgGridModule } from 'ag-grid-angular/main';
import { DateTimePickerModule } from '@ampath-kenya/ngx-openmrs-formentry';
Expand Down Expand Up @@ -102,6 +103,7 @@ import { ClinicDashboardCovid19ReportComponent } from './covid-19-report/clinic-
TabViewModule,
FieldsetModule,
ButtonModule,
DialogModule,
GrowlModule,
AccordionModule,
ChartModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { SelectDepartmentService } from './../../../../shared/services/select-department.service';
import { DataAnalyticsDashboardService } from './../../../services/data-analytics-dashboard.services';
import { LocalStorageService } from './../../../../utils/local-storage.service';
import { DepartmentProgramsConfigService } from './../../../../etl-api/department-programs-config.service';
import { FamilyTestingService } from './../../../../etl-api/family-testing-resource.service';
import { FamilyTestingBaseComponent } from './../../../../hiv-care-lib/family-testing/family-testing-base.component';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Location } from '@angular/common';
import { take } from 'rxjs/operators';
import * as _ from 'lodash';
import * as rison from 'rison-node';

@Component({
selector: 'app-contact-testing',
templateUrl:
'./../../../../hiv-care-lib/family-testing/family-testing-base.component.html',
styleUrls: [
'./../../../../hiv-care-lib/family-testing/family-testing-base.component.css'
]
})
export class ContactTestingComponent
extends FamilyTestingBaseComponent
implements OnInit {
public enabledControls = 'familyTestingControls,locationControl';
constructor(
public router: Router,
public route: ActivatedRoute,
public familyTestingService: FamilyTestingService,
public departmentProgramService: DepartmentProgramsConfigService,
public localStorage: LocalStorageService,
private dataAnalyticsDashboardService: DataAnalyticsDashboardService,
public _selectDepartmentService: SelectDepartmentService,
public location: Location
) {
super(
router,
route,
familyTestingService,
departmentProgramService,
localStorage,
location,
_selectDepartmentService
);
}

ngOnInit() {
this.getCurrentDepartment();
this.loadReportParamsFromUrl();
}

public generateReport() {
this.storeUrlParams();
this.locationUuid = this.getSelectedLocations(this.locationUuids);
super.generateReport();
}

public storeUrlParams() {
this.setSelectedLocation();
const state = {
locationUuids: this.getSelectedLocations(this.locationUuids),
eligible: this.isEligible,
childStatus: this.childStatus,
elicitedClients: this.elicitedClients,
start_date: this.elicitedStartDate,
end_date: this.elicitedEndDate,
program_type: this.programs
};
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.locationUuid = state.locations;
(this.isEligible = state.eligible),
(this.childStatus = state.childStatus),
(this.elicitedClients = state.elicitedClients),
(this.elicitedStartDate = state.start_date),
(this.elicitedEndDate = state.end_date),
(this.programs = state.program_type);
}

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(',');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import { OncologyProgramModule } from './../../oncology-care-lib/oncology-care-l
import { IPTReportComponent } from './ipt-report/ipt-report.component';
import { DataAnalyticsMonthlyReportComponent } from './monthly-reports-dashboard/data-analytics-monthly-reports.component';
import { DataAnalyticsHivGainsAndLossesComponent } from './hiv-monthly-gains-and-losses/data-analytics-hiv-gains-and-losses.component';
import { ContactTestingComponent } from './contact-testing/contact-testing/contact-testing.component';
import { DialogModule } from 'primeng/primeng';

@NgModule({
imports: [
Expand All @@ -49,7 +51,8 @@ import { DataAnalyticsHivGainsAndLossesComponent } from './hiv-monthly-gains-and
ChangeDepartmentModule,
KibanaLibModule,
ReportingUtilitiesModule,
OncologyProgramModule
OncologyProgramModule,
DialogModule
],
exports: [
RouterModule,
Expand All @@ -74,7 +77,8 @@ import { DataAnalyticsHivGainsAndLossesComponent } from './hiv-monthly-gains-and
MOH412HIVDataAnalyticsPatientListComponent,
IPTReportComponent,
DataAnalyticsMonthlyReportComponent,
DataAnalyticsHivGainsAndLossesComponent
DataAnalyticsHivGainsAndLossesComponent,
ContactTestingComponent
],
providers: [
DataAnalyticsDashboardService,
Expand Down
25 changes: 25 additions & 0 deletions src/app/data-analytics-dashboard/hiv/data-analytics-hiv.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ import { IPTReportComponent } from './ipt-report/ipt-report.component';
import { ClinicFlowProviderStatsPatientListComponent } from './../../hiv-care-lib/clinic-flow/clinic-flow-provider-stats-patient-list.component';
import { DataAnalyticsHivGainsAndLossesComponent } from './hiv-monthly-gains-and-losses/data-analytics-hiv-gains-and-losses.component';
import { PatientGainsAndLosesPatientListComponent } from './../../hiv-care-lib/patient-gains-and-loses/patient-gains-and-loses-patient-list/patient-gains-and-loses-patient-list.component';
import { ContactTestingComponent } from './contact-testing/contact-testing/contact-testing.component';
import { FamilyTestingContactComponent } from 'src/app/hiv-care-lib/family-testing/family-testing-contact-list.component';
import { AddContactTraceComponent } from 'src/app/hiv-care-lib/family-testing/contact-trace/add-contact-trace.component';
import { EditContactTraceComponent } from 'src/app/hiv-care-lib/family-testing/contact-trace/edit-contact-trace.component';
const routes: Routes = [
{
path: 'clinic-flow',
Expand Down Expand Up @@ -246,6 +250,27 @@ const routes: Routes = [
data: { multipleLocation: true }
}
]
},
{
path: 'family-testing',
children: [
{
path: '',
component: ContactTestingComponent
},
{
path: 'contact-list',
component: FamilyTestingContactComponent
},
{
path: 'contact-list/add-contact-trace',
component: AddContactTraceComponent
},
{
path: 'contact-list/edit-contact-trace',
component: EditContactTraceComponent
}
]
}
];

Expand Down
20 changes: 15 additions & 5 deletions src/app/etl-api/family-testing-resource.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ export class FamilyTestingService {
return this.appSettingsService.getOpenmrsRestbaseurl().trim();
}

public getFamilyTestingReportData(patientId: string): Observable<any> {
public getFamilyTestingReportData(params: any): Observable<any> {
const urlParams = this.getUrlRequestParams(params);

return this.http
.get(`${this.url}patient-family-history?patientUuid=${patientId}`)
.get(`${this.url}patient-family-history`, {
params: urlParams
})
.pipe(
catchError((err: any) => {
const error: any = err;
Expand All @@ -42,8 +46,8 @@ export class FamilyTestingService {
public getUrlRequestParams(params): HttpParams {
let urlParams: HttpParams = new HttpParams();

if (params.locationUuid && params.locationUuid !== '') {
urlParams = urlParams.set('locationUuid', params.locationUuid);
if (params.locationUuids && params.locationUuids !== '') {
urlParams = urlParams.set('locationUuids', params.locationUuids);
}

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

if (params.programType && params.programType !== '') {
urlParams = urlParams.set('program_type', params.programType);
urlParams = urlParams.set('programType', params.programType);
}

if (params.childStatus && params.childStatus !== '') {
urlParams = urlParams.set('child_status', params.childStatus);
}
if (params.elicitedClients && params.elicitedClients !== '') {
urlParams = urlParams.set('elicited_clients', params.elicitedClients);
}
if (params.patientUuid && params.patientUuid !== '') {
urlParams = urlParams.set('patientUuid', params.patientUuid);
}
urlParams = urlParams.set('startIndex', params.startIndex);

return urlParams;
}

public getFamilyTreePatientList(params): Observable<any> {
const urlParams = this.getUrlRequestParams(params);
const url = this.url + 'family-history-patient-list';

return this.http
.get(url, {
params: urlParams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ export class ContactListComponent implements OnInit {
width: 150
},
{
field: 'test_result_value',
field: 'reported_test_date',
headerName: 'Reported test date',
width: 150
},

{
field: 'modified_fm_status',
headerName: 'Current test results',
width: 150
},
Expand Down Expand Up @@ -80,7 +86,7 @@ export class ContactListComponent implements OnInit {

public getFamilyTestingContactListData(patientId: string) {
this.familyTestingService
.getFamilyTestingReportData(patientId)
.getFamilyTestingReportData({ patientUuid: patientId })
.subscribe((data) => {
if (data.result && data.result.length > 0) {
this.getContacts(data.result);
Expand Down
Loading

0 comments on commit f1f5448

Please sign in to comment.