diff --git a/src/app/clinic-dashboard/hiv/hiv-program.module.ts b/src/app/clinic-dashboard/hiv/hiv-program.module.ts index f00afd62d..24e5ae9e3 100644 --- a/src/app/clinic-dashboard/hiv/hiv-program.module.ts +++ b/src/app/clinic-dashboard/hiv/hiv-program.module.ts @@ -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'; @@ -102,6 +103,7 @@ import { ClinicDashboardCovid19ReportComponent } from './covid-19-report/clinic- TabViewModule, FieldsetModule, ButtonModule, + DialogModule, GrowlModule, AccordionModule, ChartModule, diff --git a/src/app/data-analytics-dashboard/hiv/contact-testing/contact-testing/contact-testing.component.ts b/src/app/data-analytics-dashboard/hiv/contact-testing/contact-testing/contact-testing.component.ts new file mode 100644 index 000000000..59eebfa50 --- /dev/null +++ b/src/app/data-analytics-dashboard/hiv/contact-testing/contact-testing/contact-testing.component.ts @@ -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): string { + return locationUuids.map((location) => location.value).join(','); + } +} diff --git a/src/app/data-analytics-dashboard/hiv/data-analytics-hiv.module.ts b/src/app/data-analytics-dashboard/hiv/data-analytics-hiv.module.ts index fa9fb082a..b11b1912f 100644 --- a/src/app/data-analytics-dashboard/hiv/data-analytics-hiv.module.ts +++ b/src/app/data-analytics-dashboard/hiv/data-analytics-hiv.module.ts @@ -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: [ @@ -49,7 +51,8 @@ import { DataAnalyticsHivGainsAndLossesComponent } from './hiv-monthly-gains-and ChangeDepartmentModule, KibanaLibModule, ReportingUtilitiesModule, - OncologyProgramModule + OncologyProgramModule, + DialogModule ], exports: [ RouterModule, @@ -74,7 +77,8 @@ import { DataAnalyticsHivGainsAndLossesComponent } from './hiv-monthly-gains-and MOH412HIVDataAnalyticsPatientListComponent, IPTReportComponent, DataAnalyticsMonthlyReportComponent, - DataAnalyticsHivGainsAndLossesComponent + DataAnalyticsHivGainsAndLossesComponent, + ContactTestingComponent ], providers: [ DataAnalyticsDashboardService, diff --git a/src/app/data-analytics-dashboard/hiv/data-analytics-hiv.routes.ts b/src/app/data-analytics-dashboard/hiv/data-analytics-hiv.routes.ts index c62b5e396..63013d903 100644 --- a/src/app/data-analytics-dashboard/hiv/data-analytics-hiv.routes.ts +++ b/src/app/data-analytics-dashboard/hiv/data-analytics-hiv.routes.ts @@ -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', @@ -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 + } + ] } ]; diff --git a/src/app/etl-api/family-testing-resource.service.ts b/src/app/etl-api/family-testing-resource.service.ts index a2c442d8a..923e0b159 100644 --- a/src/app/etl-api/family-testing-resource.service.ts +++ b/src/app/etl-api/family-testing-resource.service.ts @@ -21,9 +21,13 @@ export class FamilyTestingService { return this.appSettingsService.getOpenmrsRestbaseurl().trim(); } - public getFamilyTestingReportData(patientId: string): Observable { + public getFamilyTestingReportData(params: any): Observable { + 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; @@ -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 !== '') { @@ -59,14 +63,19 @@ 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; } @@ -74,6 +83,7 @@ export class FamilyTestingService { public getFamilyTreePatientList(params): Observable { const urlParams = this.getUrlRequestParams(params); const url = this.url + 'family-history-patient-list'; + return this.http .get(url, { params: urlParams diff --git a/src/app/hiv-care-lib/family-testing/contact-list/contact-list.component.ts b/src/app/hiv-care-lib/family-testing/contact-list/contact-list.component.ts index eafd866ee..ded634b2c 100644 --- a/src/app/hiv-care-lib/family-testing/contact-list/contact-list.component.ts +++ b/src/app/hiv-care-lib/family-testing/contact-list/contact-list.component.ts @@ -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 }, @@ -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); diff --git a/src/app/hiv-care-lib/family-testing/family-testing-base.component.html b/src/app/hiv-care-lib/family-testing/family-testing-base.component.html index 4ed951df8..ec5a8dd1e 100644 --- a/src/app/hiv-care-lib/family-testing/family-testing-base.component.html +++ b/src/app/hiv-care-lib/family-testing/family-testing-base.component.html @@ -1,125 +1,59 @@

Index Testing Contact List

-
-
-
-

Report Filters

-
-
-
-
-
- - -
-
- - -
-
- - - -
-
-
-
-
-
- - -
-
- - -
-
- - -
-
-
-
-
- - -
+ + +
+
+ + +
+
@@ -138,8 +72,31 @@

Loading...

+ + + +
+
+

+ {{ indicator.name }}:  {{ indicator.def }} +

+
+
+
+ +
+
diff --git a/src/app/hiv-care-lib/family-testing/family-testing-base.component.ts b/src/app/hiv-care-lib/family-testing/family-testing-base.component.ts index 94ec7c9d9..ed3abe2a6 100644 --- a/src/app/hiv-care-lib/family-testing/family-testing-base.component.ts +++ b/src/app/hiv-care-lib/family-testing/family-testing-base.component.ts @@ -1,11 +1,13 @@ import { take } from 'rxjs/operators'; -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, Output, EventEmitter } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import * as _ from 'lodash'; import * as Moment from 'moment'; import { DepartmentProgramsConfigService } from 'src/app/etl-api/department-programs-config.service'; import { FamilyTestingService } from 'src/app/etl-api/family-testing-resource.service'; import { LocalStorageService } from 'src/app/utils/local-storage.service'; +import { SelectDepartmentService } from './../../shared/services/select-department.service'; +import { Location } from '@angular/common'; @Component({ selector: 'family-testing-base-report', @@ -13,8 +15,10 @@ import { LocalStorageService } from 'src/app/utils/local-storage.service'; styleUrls: ['./family-testing-base.component.css'] }) export class FamilyTestingBaseComponent implements OnInit { + public selectedProgramTagsSelectedAll = false; + public programs: any; public isLoading: boolean; - public enabledControls: Array = []; + public enabledControls = 'familyTestingControls'; public endDate: Date = new Date(); public locationUuid: string; public statusError = false; @@ -26,22 +30,30 @@ export class FamilyTestingBaseComponent implements OnInit { public isEligible = ''; public childStatus = ''; public elicitedClients = ''; + public hasLoadedAll = false; + public limit = 2000; + public startIndex = 0; + public showIndicatorDefinitions = false; public elicitedStartDate = ''; public elicitedEndDate = ''; - public programDropdownSettings: any = { - singleSelection: false, - text: 'Select or enter to search', - selectAllText: 'Select All', - unSelectAllText: 'UnSelect All', - enableSearchFilter: true, - maxHeight: 200 - }; public departmentPrograms: any; - public programs: Array = []; - public program: any = []; - public showSelectedPrograms = true; - public programUuids = []; public disableGenerateButton = false; + public selectedPrograms: any; + public programOptions: Array; + public _locationUuids: any = []; + public get locationUuids(): Array { + return this._locationUuids; + } + + public set locationUuids(v: Array) { + const locationUuids = []; + _.each(v, (location: any) => { + if (location.value) { + locationUuids.push(location); + } + }); + this._locationUuids = locationUuids; + } public isEligibleOptions = [ { @@ -79,90 +91,144 @@ export class FamilyTestingBaseComponent implements OnInit { value: '' }, { - label: 'All Index', + label: 'All screened for contacts', value: 0 }, { - label: 'Index Without Contacts', - value: -1 + label: 'Screened and reviewed for children', + value: 1 }, { - label: 'Index With Contacts', - value: 1 + label: 'Screened not reviewed for children', + value: 2 + }, + { + label: 'Reviewed with Children 19yrs and below', + value: 8 + }, + { + label: 'Reviewed with sexual partners', + value: 9 + }, + { + label: 'Clients not screened', + value: 3 + }, + { + label: 'Children 19yrs and below', + value: 4 + }, + { + label: 'Sexual partners', + value: 5 + }, + { + label: 'Siblings', + value: 6 + }, + { + label: 'Uncategorized contacts', + value: 7 }, { label: 'All contacts', value: '' } ]; + public indicators = [ + { + name: 'All screened for contacts', + def: 'All index clients who have been screened for contacts' + }, + { + name: 'Screened and reviewed for children', + def: + 'All index clients who have been screened for children 19 years and below' + }, + { + name: 'Screened not reviewed for children', + def: + 'All index clients who have been screened but children status was not captured' + }, + { + name: 'Clients not screened', + def: 'Clients without any contact tracing information' + }, + { + name: 'Children 19yrs and below', + def: 'All elicited contacts below 20 years' + }, + { + name: 'Sexual partners', + def: 'Sexual partners elicited' + }, + { + name: 'Siblings', + def: 'Siblings elicited' + }, + { + name: 'Uncategorized contacts', + def: + 'Clients whose relationship to index was not captured, should be used for cleanup' + }, + { name: 'All contacts', def: 'All contacts elicited' }, + { name: 'Eligible for Testing', def: 'Contacts eligible for testing' }, + { name: 'Children Status', def: 'Captured child status' } + ]; + + @Output() public resetPrograms = new EventEmitter(); public ngOnInit() { + this.getCurrentDepartment(); + this.loadReport(); + } + + constructor( + public router: Router, + public route: ActivatedRoute, + public familyTestingService: FamilyTestingService, + public departmentProgramService: DepartmentProgramsConfigService, + public localStorage: LocalStorageService, + public location: Location, + public _selectDepartmentService: SelectDepartmentService + ) {} + + public loadReport() { this.route.queryParams.subscribe((params: any) => { if (_.isEmpty(params)) { this.route.parent.parent.params.subscribe((urlParams: any) => { this.locationUuid = urlParams.location_uuid; - localStorage.setItem( - 'familyTestingSCurrentLocation', - this.locationUuid - ); if (this.locationUuid) { this.resetFilters(); } }); } else { - if ( - localStorage.getItem('familyTestingSCurrentLocation') !== - params.location_uuid - ) { - this.resetFilters(); - localStorage.setItem( - 'familyTestingSCurrentLocation', - this.locationUuid - ); - } else { - this.locationUuid = params.location_uuid ? params.location_uuid : ''; - this.elicitedStartDate = params.start_date ? params.start_date : ''; - this.elicitedEndDate = params.end_date ? params.end_date : ''; - this.isEligible = params.eligible ? params.eligible : ''; - this.childStatus = params.childStatus ? params.childStatus : ''; - this.elicitedClients = params.elicitedClients - ? params.elicitedClients - : ''; - const cachedPrograms = this.localStorage.getItem( - 'familyTestingSelectedPrograms' - ); - this.programUuids = cachedPrograms ? cachedPrograms.split(',') : []; - - if (this.programUuids.length > 0) { - this.disableGenerateButton = true; - } else { - this.disableGenerateButton = false; - } - - this.setParams(); - if (this.locationUuid) { - this.generateReport(); - } + this.locationUuid = params.location_uuid ? params.location_uuid : ''; + this.elicitedStartDate = params.start_date ? params.start_date : ''; + this.elicitedEndDate = params.end_date ? params.end_date : ''; + this.isEligible = params.eligible ? params.eligible : ''; + this.childStatus = params.childStatus ? params.childStatus : ''; + this.elicitedClients = params.elicitedClients + ? params.elicitedClients + : ''; + if (this.locationUuid) { + this.generateReport(); } } }); - this.getDepartmentPrograms(); } - constructor( - public router: Router, - public route: ActivatedRoute, - private familyTestingService: FamilyTestingService, - private departmentProgramService: DepartmentProgramsConfigService, - private localStorage: LocalStorageService - ) {} - public generateReport() { + this.resetStartIndex(); this.setParams(); - this.storeParamsInUrl(); + const path = this.router.parseUrl(this.location.path()); + if (!path.queryParams['state']) { + this.storeParamsInUrl(); + } this.isLoading = true; this.familyTestingService + .getFamilyTreePatientList(this.params) .subscribe((data) => { if (data.error) { @@ -172,13 +238,55 @@ export class FamilyTestingBaseComponent implements OnInit { } else { this.showInfoMessage = false; this.isLoading = false; - this.familyTestingPatientList = data.result; + this.appendData(data.result); + this.checkOrderLimit(data.result.length); } }); } + public checkOrderLimit(resultCount: number): void { + this.hasLoadedAll = false; + if (this.elicitedClients === '3' && resultCount < 300) { + this.hasLoadedAll = true; + } else if (resultCount < this.limit && !(this.elicitedClients === '3')) { + this.hasLoadedAll = true; + } + } + public loadMorePatients() { + if (this.elicitedClients === '3') { + this.startIndex += 300; + } else { + this.startIndex += 2000; + } + this.generateReport(); + } + + private appendData(data) { + if (this.startIndex === 0) { + this.familyTestingPatientList = data; + } else { + this.familyTestingPatientList = this.familyTestingPatientList.concat( + data + ); + } + } + + public openDefinitions() { + this.showIndicatorDefinitions = true; + } + + public onClickCancel(event) { + if (!event) { + this.showIndicatorDefinitions = false; + } + } + + private resetStartIndex() { + this.startIndex = 0; + this.familyTestingPatientList = []; + } + public storeParamsInUrl() { - // store params in url this.router.navigate([], { relativeTo: this.route, queryParams: { @@ -188,16 +296,9 @@ export class FamilyTestingBaseComponent implements OnInit { elicitedClients: this.elicitedClients, start_date: this.elicitedStartDate, end_date: this.elicitedEndDate, - program_type: this.programUuids.toString() + program_type: this.programs } }); - - if (!_.isEmpty(this.programUuids)) { - this.localStorage.setItem( - 'familyTestingSelectedPrograms', - this.programUuids.toString() - ); - } } public onLocationChange(location_uuid) { @@ -208,53 +309,89 @@ export class FamilyTestingBaseComponent implements OnInit { public onPatientSelected(params: any) { this.router.navigate(['contact-list'], { relativeTo: this.route, - queryParams: { patient_uuid: params.patient_uuid } + queryParams: { + patient_uuid: params.patient_uuid, + eligible: this.isEligible, + childStatus: this.childStatus, + elicitedClients: this.elicitedClients, + start_date: this.elicitedStartDate, + end_date: this.elicitedEndDate, + program_type: this.programs + } }); } public onIsEligibleChange($event) { this.isEligible = $event; + this.resetStartIndex(); } public childStatusChange($event) { this.childStatus = $event; + this.resetStartIndex(); } - public onElicitedClientsChange($event) { - this.elicitedClients = $event; + public onElicitedClientsChange(val) { + this.elicitedClients = val; + this.resetStartIndex(); } public getSelectedElicitedStartDate($event) { this.elicitedStartDate = Moment($event).format('YYYY-MM-DD'); + this.resetStartIndex(); } public getSelectedElicitedEndDate($event) { this.elicitedEndDate = Moment($event).format('YYYY-MM-DD'); + this.resetStartIndex(); } public setParams() { - const programUuids = []; - - if (this.program.length > 0) { - this.showSelectedPrograms = true; - _.each(this.program, (program: any) => { - programUuids.push(program.id); - }); - } - - if (_.isEmpty(this.programUuids)) { - this.programUuids = programUuids; - } - this.params = { - locationUuid: this.locationUuid, + locationUuids: this.locationUuid, isEligible: this.isEligible, childStatus: this.childStatus, elicitedClients: this.elicitedClients, start_date: this.elicitedStartDate, end_date: this.elicitedEndDate, - programType: this.programUuids.toString() + startIndex: this.startIndex }; + + if (!_.isUndefined(this.programs)) { + _.extend(this.params, { + programType: this.programs + }); + } + } + + public getCurrentDepartment() { + const department = this._selectDepartmentService.getUserSetDepartment(); + this.getDepartmentPrograms(department); + } + public getDepartmentPrograms(department) { + this.departmentProgramService + .getDepartmentPrograms(department) + .pipe(take(1)) + .subscribe((results) => { + if (results) { + this.programOptions = _.map(results, (result) => { + return { value: result.uuid, label: result.name }; + }); + } + }); + } + + public selectAllPrograms() { + if (this.programOptions.length > 0) { + if (this.selectedProgramTagsSelectedAll === false) { + this.selectedProgramTagsSelectedAll = true; + this.selectedPrograms = this.programOptions; + } else { + this.selectedProgramTagsSelectedAll = false; + this.selectedPrograms = []; + } + } + this.resetStartIndex(); } public resetFilters() { @@ -263,56 +400,33 @@ export class FamilyTestingBaseComponent implements OnInit { this.elicitedClients = ''; this.elicitedStartDate = ''; this.elicitedEndDate = ''; - this.programUuids = []; - this.program = []; - this.localStorage.remove('familyTestingSelectedPrograms'); + this.programs = ''; + this.selectedPrograms = []; this.generateReport(); + this.resetStartIndex(); } - public getDepartmentPrograms() { - this.departmentProgramService - .getDepartmentPrograms('HIV') - .pipe(take(1)) - .subscribe((result) => { - this.departmentPrograms = result; - this.loadProgramFilter(result); - }); - } - - public loadProgramFilter(departmentPrograms) { - const programsArray = []; - _.each(departmentPrograms, (program: any) => { - const programUuid = program.uuid; - const programName = program.name; - const programObj = { - id: programUuid, - itemName: programName - }; - programsArray.push(programObj); - }); + public getSelectedPrograms(programsUuids): string { + this.resetStartIndex(); - this.programs = programsArray; - } + if (!programsUuids || programsUuids.length === 0) { + this.programs = ''; - public loadProgramsFromParams(programs) { - if (programs !== undefined) { - const selectedPrograms = []; - this.getDepartmentPrograms(); - programs = programs.split(','); - _.each(this.departmentPrograms, (p: any) => { - if (programs.includes(p.uuid)) { - selectedPrograms.push(p); - } - }); - this.loadProgramFilter(selectedPrograms); + return this.programs; } - } - public selectProgram($event) {} + let selectedPrograms = ''; - public DeSelectProgram($event) {} + for (let i = 0; i < programsUuids.length; i++) { + if (i === 0) { + selectedPrograms = selectedPrograms + programsUuids[0].value; + } else { + selectedPrograms = selectedPrograms + ',' + programsUuids[i].value; + } + } - public onSelectAllPrograms($event) {} + this.programs = selectedPrograms.length > 0 ? selectedPrograms : undefined; - public onDeSelectAllPrograms($event) {} + return this.programs; + } } diff --git a/src/app/hiv-care-lib/family-testing/family-testing-contact-list.component.html b/src/app/hiv-care-lib/family-testing/family-testing-contact-list.component.html index bc720abbe..ed3ed1abc 100644 --- a/src/app/hiv-care-lib/family-testing/family-testing-contact-list.component.html +++ b/src/app/hiv-care-lib/family-testing/family-testing-contact-list.component.html @@ -6,7 +6,11 @@

-
+
+

This patient has no any elicited contacts

+
+ +
@@ -57,7 +61,7 @@

-
+
Tree to be drawn here
-
-

Patient has no family history information to show

-
-
Loading...
diff --git a/src/app/hiv-care-lib/family-testing/family-testing-contact-list.component.ts b/src/app/hiv-care-lib/family-testing/family-testing-contact-list.component.ts index 046aaad20..cc9ed4cc3 100644 --- a/src/app/hiv-care-lib/family-testing/family-testing-contact-list.component.ts +++ b/src/app/hiv-care-lib/family-testing/family-testing-contact-list.component.ts @@ -38,6 +38,8 @@ export class FamilyTestingContactComponent implements OnInit { public gridOptions: any = { columnDefs: [] }; + public indexHasContacts: boolean; + public params: any; @ViewChild('agGrid') public agGrid: AgGridNg2; @ViewChild('staticModal') @@ -153,11 +155,22 @@ export class FamilyTestingContactComponent implements OnInit { public ngOnInit() { this.route.queryParams.subscribe((params) => { this.patientUuid = params.patient_uuid; + this.params = { + locationUuids: params.location_uuid, + isEligible: params.eligible, + childStatus: params.childStatus, + elicitedClients: params.elicitedClients, + start_date: params.start_date, + end_date: params.end_date, + patientUuid: this.patientUuid + }; this.getFamilyTestingContactListData(this.patientUuid); this.setPatientUuid(this.patientUuid); }); this.gridOptions.columnDefs = this.columnDefs; - this.getPatientEncounters(); + if (this.patientUuid !== undefined) { + this.getPatientEncounters(); + } } constructor( @@ -175,22 +188,31 @@ export class FamilyTestingContactComponent implements OnInit { } public getFamilyTestingContactListData(patientId: string) { - this.isLoading = true; - this.familyTestingService - .getFamilyTestingReportData(patientId) - .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.isLoading = false; - this.familyTestingContactList = data.result; - this.indexName = data.result[0].person_name; - this.indexUuid = data.result[0].patient_uuid; - } - }); + if (this.params['elicitedClients'] === 3) { + this.indexHasContacts = false; + } else { + this.isLoading = true; + this.familyTestingService + .getFamilyTestingReportData(this.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.isLoading = false; + this.familyTestingContactList = data.result; + if (this.familyTestingContactList[0].fm_name === undefined) { + this.indexHasContacts = false; + } else { + this.indexHasContacts = true; + } + this.indexName = data.result[0].person_name; + this.indexUuid = data.result[0].patient_uuid; + } + }); + } } public getPatientEncounters() { diff --git a/src/app/hiv-care-lib/family-testing/family-testing-patient-list.component.html b/src/app/hiv-care-lib/family-testing/family-testing-patient-list.component.html index 4e9e35bb3..f107df0a2 100644 --- a/src/app/hiv-care-lib/family-testing/family-testing-patient-list.component.html +++ b/src/app/hiv-care-lib/family-testing/family-testing-patient-list.component.html @@ -11,7 +11,19 @@

-
+
+
+ +
+
+

{ + if (column.value === undefined || column.value === null) { + return ''; + } else { + return ( + '' + + column.value + + '' + ); + } + } + }, + { + field: 'person_name', + headerName: 'Index Name' + }, + { + field: 'index_gender', + headerName: 'Index Gender', + width: 130 + }, + { + field: 'age', + headerName: 'Index Age', + width: 100 + }, + { + field: 'phone_number', + headerName: 'Index Phone', + width: 120 + }, + { + field: 'status', + headerName: 'Clinical status', + width: 120 + }, + { + field: 'arv_first_regimen_start_date', + headerName: 'ART Initiation Date' + }, + { + field: 'patient_program', + headerName: 'Patient Program', + width: 300 + } + ]; @Output() public patientSelected = new EventEmitter(); - public ngOnInit() { - this.gridOptions.columnDefs = this.columnDefs; - this.gridOptions.groupDefaultExpanded = -1; - this.gridOptions.enableFilter = true; - (this.gridOptions.groupRemoveSingleChildren = false), - (this.gridOptions.groupUseEntireRow = true); - this.setCellSelection(); - } + public ngOnInit() {} constructor( public router: Router, @@ -181,6 +231,19 @@ export class FamilyTestingPatientlistComponent implements OnInit { public location: Location ) {} + public main() { + if (this.patientData.length > 0 && this.patientData[0].hideContactColumns) { + this.gridOptions.columnDefs = this.indexColumns; + } else { + this.gridOptions.columnDefs = this.columnDefs; + this.gridOptions.groupDefaultExpanded = -1; + } + this.gridOptions.enableFilter = true; + this.gridOptions.groupRemoveSingleChildren = false; + this.gridOptions.groupUseEntireRow = true; + this.setCellSelection(); + } + private setCellSelection(col?) { this.gridOptions.rowSelection = 'single'; let selectedIndicator: any; diff --git a/src/app/shared/dynamic-route/schema/analytics.dashboard.conf.json b/src/app/shared/dynamic-route/schema/analytics.dashboard.conf.json index 78fb33f92..5da5a4fd6 100644 --- a/src/app/shared/dynamic-route/schema/analytics.dashboard.conf.json +++ b/src/app/shared/dynamic-route/schema/analytics.dashboard.conf.json @@ -96,6 +96,12 @@ "icon": "fa fa-area-chart", "isSideBarOpen": false }, + { + "url": "family-testing", + "label": "Family Testing", + "icon": "fa fa-users", + "isSideBarOpen": false + }, { "url": "dqa", "label": "DQA Reports", diff --git a/src/app/shared/ngamrs-shared.module.ts b/src/app/shared/ngamrs-shared.module.ts index eb8a7bc98..c98696108 100644 --- a/src/app/shared/ngamrs-shared.module.ts +++ b/src/app/shared/ngamrs-shared.module.ts @@ -75,6 +75,7 @@ import { KibanaVizHostComponent } from './kibana-viz-host/kibana-viz-host.compon import { KibanaVizComponent } from './kibana-viz/kibana-viz.component'; import { SnakeCaseToTitlePipe } from './pipes/snake-case-to-title.pipe'; import { ProgramSnapshotNegativesComponent } from '../patient-dashboard/hiv/program-snapshot-negatives/program-snapshot-negatives.component'; +import { AngularMultiSelectModule } from 'angular2-multiselect-dropdown/angular2-multiselect-dropdown'; @NgModule({ imports: [ @@ -125,7 +126,8 @@ import { ProgramSnapshotNegativesComponent } from '../patient-dashboard/hiv/prog MatButtonModule, MatTooltipModule, PdfViewerModule, - ReactiveFormsModule + ReactiveFormsModule, + AngularMultiSelectModule ], exports: [ NgBusyModule, diff --git a/src/app/shared/report-filters/report-filters.component.html b/src/app/shared/report-filters/report-filters.component.html index 58697f25f..2c7ffa47e 100644 --- a/src/app/shared/report-filters/report-filters.component.html +++ b/src/app/shared/report-filters/report-filters.component.html @@ -160,6 +160,131 @@

+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ + +
+
+ + + Select All + Select None +
+
+
+
+
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+
@@ -308,7 +433,11 @@
-
+