Skip to content

Commit

Permalink
HIV-388 : Integrating surge report into front end
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldkibet committed Aug 29, 2019
1 parent 2c2b40e commit f1c5f4c
Show file tree
Hide file tree
Showing 31 changed files with 3,485 additions and 130 deletions.
64 changes: 32 additions & 32 deletions ngsw-config.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"index": "/index.html",
"assetGroups": [{
"name": "app",
"installMode": "prefetch",
"updateMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html",
"/*.css",
"/*.js"
]
}
}, {
"name": "assets",
"installMode": "prefetch",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**",
"/*.ttf",
"/*.woff2",
"/*.svg",
"/*.woff",
"/*.png",
"/*.jpg",
"/*.eot",
"/fontawesome*"
]
}
}]
}
"index": "/index.html",
"assetGroups": [{
"name": "app",
"installMode": "prefetch",
"updateMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html",
"/*.css",
"/*.js"
]
}
}, {
"name": "assets",
"installMode": "prefetch",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**",
"/*.ttf",
"/*.woff2",
"/*.svg",
"/*.woff",
"/*.png",
"/*.jpg",
"/*.eot",
"/fontawesome*"
]
}
}]
}
8 changes: 6 additions & 2 deletions src/app/clinic-dashboard/hiv/hiv-program.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ import { HivDifferentiatedCareComponent } from './hiv-differentiated-care-progra
import {
HivDifferentiatedCarePatientListComponent
} from './hiv-differentiated-care-program/hiv-differentiated-care-program-patient-list/hiv-differentiated-care-patient-list.component';
import { SurgeReportComponent } from './surge-report/surge-report.component';
import { ReportingUtilitiesModule } from 'src/app/reporting-utilities/reporting-utilities.module';
@NgModule({
imports: [
clinicDashboardHivRouting,
Expand Down Expand Up @@ -129,7 +131,8 @@ import {
DepartmentProgramFilterModule,
ChangeDepartmentModule,
GeneralModule,
KibanaLibModule
KibanaLibModule,
ReportingUtilitiesModule
],
exports: [
HivSummaryIndicatorComponent,
Expand Down Expand Up @@ -176,7 +179,8 @@ import {
Moh731MonthlyVizComponent,
ClinicKibanaVizComponent,
HivDifferentiatedCareComponent,
HivDifferentiatedCarePatientListComponent
HivDifferentiatedCarePatientListComponent,
SurgeReportComponent
],
providers: [
ClinicalSummaryVisualizationService
Expand Down
11 changes: 11 additions & 0 deletions src/app/clinic-dashboard/hiv/hiv-program.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ import {
DashboardsViewerComponent
} from '../../kibana-lib';
import { HivDifferentiatedCareComponent } from './hiv-differentiated-care-program/hiv-differentiated-care-program.component';
import { SurgeReportComponent } from './surge-report/surge-report.component';
import { SurgeReportPatientListComponent } from 'src/app/hiv-care-lib/surge-report/surge-report-patient-list.component';

const routes: Routes = [
{
path: 'landing-page',
Expand Down Expand Up @@ -183,6 +186,14 @@ const routes: Routes = [
{
path: 'department-select',
component : ChangeDepartmentComponent
},
{
path: 'surge-reports',
component: SurgeReportComponent
},
{
path: 'surge-reports/surge-report-patientlist',
component: SurgeReportPatientListComponent
}
];

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { SurgeReportBaseComponent } from 'src/app/hiv-care-lib/surge-report/surge-report-base.component';
import { SurgeResourceService } from 'src/app/etl-api/surge-resource.service';

@Component({
selector: 'surge-report',
templateUrl: '../../../hiv-care-lib/surge-report/surge-report-base.component.html'
})
export class SurgeReportComponent extends SurgeReportBaseComponent implements OnInit {

public params: any;
public surgeReportSummaryData: any = [];
public columnDefs: any = [];

public statusError = false;
public errorMessage = '';
public showInfoMessage = false;
public isLoading = false;

constructor(public router: Router,
public route: ActivatedRoute,
public surgeReport: SurgeResourceService) {
super(router, route, surgeReport);
}

ngOnInit() {
this.route.queryParams.subscribe(
(params: any) => {
switch (params.currentView) {
case 'daily':
if (params && params._date) {
this.isLoading = true;
this.params = params;
this.getSurgeDailyReport(params);
}
break;
case 'weekly':
if (params && params.year_week) {
this.isLoading = true;
this.params = params;
this.getSurgeWeeklyReport(params);
}
break;
}
},
error => {
console.error('Error', error);
this.showInfoMessage = true;
}
);
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import {take} from 'rxjs/operators';
import { Component, OnInit, OnDestroy, Input } from '@angular/core';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ import { ChangeDepartmentModule } from '../change-department/change-department.m
import {
Moh731MonthlyVizComponent
} from './moh-731-monthly-viz/moh-731-monthly-viz.component';
import { SurgeReportComponent } from './surge/surge-report.component';
import { ReportingUtilitiesModule } from 'src/app/reporting-utilities/reporting-utilities.module';
@NgModule({
imports: [
dataAnalyticsDashboardHivRouting,
Expand All @@ -53,7 +55,8 @@ import {
DataEntryStatisticsModule,
PatientProgramEnrollmentModule,
ChangeDepartmentModule,
KibanaLibModule
KibanaLibModule,
ReportingUtilitiesModule
],
exports: [
RouterModule,
Expand All @@ -68,7 +71,8 @@ import {
Moh731ReportComponent,
Moh731MonthlyVizComponent,
HivCareComparativeAnalyticsComponent,
HivSummaryMonthlyIndicatorsComponent
HivSummaryMonthlyIndicatorsComponent,
SurgeReportComponent
],
providers: [
DataAnalyticsDashboardService,
Expand Down
15 changes: 15 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 @@ -22,6 +22,8 @@ import { Moh731MonthlyVizComponent } from './moh-731-monthly-viz/moh-731-monthly
import {
DashboardsViewerComponent
} from '../../kibana-lib';
import { SurgeReportComponent } from './surge/surge-report.component';
import { SurgeReportPatientListComponent } from 'src/app/hiv-care-lib/surge-report/surge-report-patient-list.component';

const routes: Routes = [
{
Expand Down Expand Up @@ -127,6 +129,19 @@ const routes: Routes = [
{
path: 'select-department',
component: ChangeDepartmentComponent
},
{
path: 'surge',
children: [
{
path: 'surge-report-patientlist',
component: SurgeReportPatientListComponent
},
{
path: '',
component: SurgeReportComponent
}
]
}
];

Expand Down
120 changes: 120 additions & 0 deletions src/app/data-analytics-dashboard/hiv/surge/surge-report.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
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 { SurgeReportBaseComponent } from 'src/app/hiv-care-lib/surge-report/surge-report-base.component';
import { DataAnalyticsDashboardService } from '../../services/data-analytics-dashboard.services';
import { SurgeResourceService } from 'src/app/etl-api/surge-resource.service';



@Component({
selector: 'surge-report',
templateUrl: '../../../hiv-care-lib/surge-report/surge-report-base.component.html',
})
export class SurgeReportComponent extends SurgeReportBaseComponent implements OnInit {

public enabledControls = 'dayControl,locationControl';

constructor(
public router: Router, public route: ActivatedRoute, public surgeReport: SurgeResourceService,
private dataAnalyticsDashboardService: DataAnalyticsDashboardService, private location: Location) {
super(router, route, surgeReport);
}

ngOnInit() {
this.loadParametersFromUrl();
}

public generateReport() {
this.storeParamsInUrl();
super.generateReport();
}

public storeParamsInUrl() {
this.setSelectedLocation();
let state = {};
this.displayTabluarFilters = true;
switch (this.currentView) {
case 'daily':
state = {
'_date': Moment(this.startDate).format('YYYY-MM-DD'),
'locationUuids': this.getSelectedLocations(this.locationUuids),
'displayTabluarFilters': this.displayTabluarFilters,
'currentView': this.currentView,
'reportName': this.reportName
};
break;
case 'weekly':
state = {
'year_week': this.yearWeek,
'locationUuids': this.getSelectedLocations(this.locationUuids),
'displayTabluarFilters': this.displayTabluarFilters,
'currentView': this.currentView,
'reportName': this.reportName
};
break;
}

const stateUrl = rison.encode(state);
const path = this.router.parseUrl(this.location.path());
path.queryParams = {
'state': stateUrl
};

this.params = state;
this.location.replaceState(path.toString());
}

public loadParametersFromUrl() {
const path = this.router.parseUrl(this.location.path());

if (path.queryParams['state']) {
const state = rison.decode(path.queryParams['state']);
switch (state.currentView) {
case 'daily':
this.currentView = 'daily';
this.startDate = Moment(state._date).format('MM-DD-YYYY');
this.generateReport();
break;
case 'weekly':
this.currentView = 'weekly';
this.enabledControls = 'weekControl,locationControl';
this.yearWeek = state.year_week;
this.generateReport();
break;
}
}

}

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(',');
}

public onTabChanged(val) {
if (this.currentView === 'daily') {
this.currentView = 'weekly';
this.enabledControls = 'weekControl,locationControl';
this.surgeReportSummaryData = [];
this.displayTabluarFilters = false;
} else {
this.enabledControls = 'dayControl,locationControl';
this.currentView = 'daily';
this.surgeReportSummaryData = [];
this.displayTabluarFilters = false;
}
}
}
9 changes: 8 additions & 1 deletion src/app/etl-api/etl-api.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ import { CdmSummaryResourceService } from './cdm-summary-resource.service';
import { RadiologyImagingResourceService } from './radiology-imaging-resource.service';
import { HivEnhancedReportService } from './hiv-enhanced-program-report.service';
import { OncologySummaryResourceService } from './oncology-summary-resource.service';
import { KibanaDashboardListService } from './kibana-dashboard-list-service';
import { HivDifferentiatedCareResourceService } from './hiv-differentiated-care-resource.service';
import { SurgeResourceService } from './surge-resource.service';

@NgModule({
imports: [CommonModule, AppSettingsModule],
declarations: [],
Expand Down Expand Up @@ -78,7 +82,10 @@ import { OncologySummaryResourceService } from './oncology-summary-resource.serv
HivEnhancedReportService,
HivEnhancedReportService,
OncologySummaryResourceService,
RadiologyImagingResourceService
RadiologyImagingResourceService,
KibanaDashboardListService,
HivDifferentiatedCareResourceService,
SurgeResourceService
],
exports: []
})
Expand Down
Loading

0 comments on commit f1c5f4c

Please sign in to comment.