Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC-737: Development of MOH Registers #1742

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ import { TxMmdReportComponent } from './datim-reports/tx-mmd-report.component';
import { TxRttReportComponent } from './datim-reports/tx-rtt-report.component';
import { AhdReportComponent } from './ahd-report/ahd-report.component';
import { PlhivNcdV2ReportComponent } from './plhiv-ncd-v2-report/plhiv-ncd-v2-report.component';
import { RegistersComponent } from './registers/registers.component';
import { HeiRegisterComponent } from './registers/hei-register/hei-register.component';
import { AncRegisterComponent } from './registers/anc-register/anc-register.component';
import { NutritionRegisterComponent } from './registers/nutrition-register/nutrition-register.component';
import { MaternityRegisterComponent } from './registers/maternity-register/maternity-register.component';
import { HtsrefferallinkageRegisterComponent } from './registers/htsrefferallinkage-register/htsrefferallinkage-register.component';
import { PncRegisterComponent } from './registers/pnc-register/pnc-register.component';
import { DefaultertracingRegisterComponent } from './registers/defaultertracing-register/defaultertracing-register.component';
import { PrepdailyRegisterComponent } from './registers/prepdaily-register/prepdaily-register.component';
import { CntdailyRegisterComponent } from './registers/cntdaily-register/cntdaily-register.component';

@NgModule({
imports: [
Expand Down Expand Up @@ -97,7 +107,17 @@ import { PlhivNcdV2ReportComponent } from './plhiv-ncd-v2-report/plhiv-ncd-v2-re
TxMmdReportComponent,
TxRttReportComponent,
PlhivNcdV2ReportComponent,
AhdReportComponent
AhdReportComponent,
RegistersComponent,
HeiRegisterComponent,
AncRegisterComponent,
NutritionRegisterComponent,
MaternityRegisterComponent,
HtsrefferallinkageRegisterComponent,
PncRegisterComponent,
DefaultertracingRegisterComponent,
PrepdailyRegisterComponent,
CntdailyRegisterComponent
],
providers: [
DataAnalyticsDashboardService,
Expand Down
100 changes: 100 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 @@ -57,6 +57,16 @@ import { AhdReportComponent } from './ahd-report/ahd-report.component';
import { AhdMonthlyReportPatientlistComponent } from 'src/app/hiv-care-lib/ahd-monthly-report/ahd-monthly-report-patientlist/ahd-monthly-report-patientlist.component';
import { PlhivNcdV2ReportPatientListComponent } from 'src/app/hiv-care-lib/plhiv-ncd-v2-report/plhiv-ncd-v2-report-patient-list/plhiv-ncd-v2-report-patient-list.component';
import { PlhivNcdV2ReportComponent } from './plhiv-ncd-v2-report/plhiv-ncd-v2-report.component';
import { RegistersComponent } from './registers/registers.component';
import { HeiRegisterComponent } from './registers/hei-register/hei-register.component';
import { AncRegisterComponent } from './registers/anc-register/anc-register.component';
import { NutritionRegisterComponent } from './registers/nutrition-register/nutrition-register.component';
import { MaternityRegisterComponent } from './registers/maternity-register/maternity-register.component';
import { HtsrefferallinkageRegisterComponent } from './registers/htsrefferallinkage-register/htsrefferallinkage-register.component';
import { PncRegisterComponent } from './registers/pnc-register/pnc-register.component';
import { DefaultertracingRegisterComponent } from './registers/defaultertracing-register/defaultertracing-register.component';
import { PrepdailyRegisterComponent } from './registers/prepdaily-register/prepdaily-register.component';
import { CntdailyRegisterComponent } from './registers/cntdaily-register/cntdaily-register.component';

const routes: Routes = [
{
Expand Down Expand Up @@ -285,6 +295,96 @@ const routes: Routes = [
}
]
},
{
path: 'registers',
children: [
{
path: '',
component: RegistersComponent
},
{
path: 'hei-register',
children: [
{
path: '',
component: HeiRegisterComponent
}
]
},
{
path: 'anc-register',
children: [
{
path: '',
component: AncRegisterComponent
}
]
},
{
path: 'nutrition-register',
children: [
{
path: '',
component: NutritionRegisterComponent
}
]
},
{
path: 'maternity-register',
children: [
{
path: '',
component: MaternityRegisterComponent
}
]
},
{
path: 'htsrefferallinkage-register',
children: [
{
path: '',
component: HtsrefferallinkageRegisterComponent
}
]
},
{
path: 'pnc-register',
children: [
{
path: '',
component: PncRegisterComponent
}
]
},
{
path: 'defaultertracing-register',
children: [
{
path: '',
component: DefaultertracingRegisterComponent
}
]
},
{
path: 'prepdaily-register',
children: [
{
path: '',
component: PrepdailyRegisterComponent
}
]
},
{
path: 'cntdaily-register',
children: [
{
path: '',
component: CntdailyRegisterComponent
}
]
}
]
},
{
path: 'datim-report',
children: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<h4 class="component-title text-success">
<span class="fa fa-table"></span>{{ reportName }}
</h4>

<div class="loader" *ngIf="isLoading">
<span><i class="fa fa-spinner fa-spin"></i>Loading...</span>
</div>

<p-tabView>
<div>
<p-tabPanel header="Monthly" leftIcon="fa-calendar-o">
<report-filters
[enabledControls]="enabledControls"
[monthString]="_month"
(onMonthChange)="onMonthChange($event)"
[reportName]="reportName"
(generateReport)="generateReport()"
>
</report-filters>
</p-tabPanel>
</div>
</p-tabView>

<div class="alert alert-danger fade in" *ngIf="showInfoMessage">
<a href="#" class="close" data-dismiss="alert">&times;</a>
<h4 *ngIf="!statusError">
<strong><span class="glyphicon glyphicon-warning-sign"></span> </strong> An
error occurred while trying to load the report. Please try again.
</h4>
<p>
<small>{{ errorMessage }}</small>
</p>
</div>
<div *ngIf="!isReleased" class="alert alert-warning">
<strong>Viewing a Draft Version of the Report for the chosen month. </strong>
This report is likely to change without warning.
</div>
<div>
<p-tabView>
<p-tabPanel
header="Report View"
leftIcon="fa-file-pdf-o"
[selected]="currentViewBelow === 'pdf'"
>
<!-- <app-tx-ml-report-view
[SummaryData]="txnewReportSummaryData"
[sectionDefs]="columnDefs"
(CellSelection)="onIndicatorSelected($event)"
[reportDetails]="params"
[reportHeader]="reportName"
></app-tx-ml-report-view> -->
</p-tabPanel>
</p-tabView>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { AncRegisterComponent } from './anc-register.component';

describe('AncRegisterComponent', () => {
let component: AncRegisterComponent;
let fixture: ComponentFixture<AncRegisterComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [AncRegisterComponent]
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(AncRegisterComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
import { Component, OnInit, Output } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import * as _ from 'lodash';
import * as Moment from 'moment';
@Component({
selector: 'app-anc-register',
templateUrl: './anc-register.component.html',
styleUrls: ['./anc-register.component.css']
})
export class AncRegisterComponent implements OnInit {
@Output()
public params: any;
public indicators: string;
public selectedIndicators = [];
public txnewReportSummaryData: any = [];
public columnDefs: any = [];
public reportName = 'ANC Register';
public currentView = 'monthly';
public currentViewBelow = 'pdf';
public month: string;
public year: number;
public quarter: string;
public eDate: string;
public sDate: string;

public statusError = false;
public errorMessage = '';
public showInfoMessage = false;
public isLoading = false;
public reportHead: any;
public enabledControls = 'locationControl,monthControl';
public pinnedBottomRowData: any = [];
public _month: string;
public isReleased = true;

public _locationUuids: any = [];
public get locationUuids(): Array<string> {
return this._locationUuids;
}

public set locationUuids(v: Array<string>) {
const locationUuids = [];
_.each(v, (location: any) => {
if (location.value) {
locationUuids.push(location);
}
});
this._locationUuids = locationUuids;
}

constructor(public router: Router, public route: ActivatedRoute) {
this.route.queryParams.subscribe((data) => {
data.month === undefined
? (this._month = Moment()
.subtract(1, 'M')
.endOf('month')
.format('YYYY-MM-DD'))
: (this._month = data.month);

this.showDraftReportAlert(this._month);
});
}

ngOnInit() {}

public onMonthChange(value): any {
this._month = Moment(value).endOf('month').format('YYYY-MM-DD');
}

public generateReport(): any {
this.route.parent.parent.params.subscribe((params: any) => {
this.storeParamsInUrl(params.location_uuid);
});
this.txnewReportSummaryData = [];
// this.getTxNewReport(this.params);
}

public storeParamsInUrl(param) {
this.params = {
locationUuids: param,
_month: Moment(this._month).endOf('month').format('YYYY-MM-DD'),
month: Moment(this._month).endOf('month').format('YYYY-MM-DD'),
reportName: this.reportName,
_date: Moment(this._month).format('DD-MM-YYYY')
};
this.router.navigate([], {
relativeTo: this.route,
queryParams: this.params
});
}

// public getTxNewReport(params: any) {
// this.isLoading = true;
// this.txnewReport.getTxNewReport(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.columnDefs = data.sectionDefinitions;
// this.txnewReportSummaryData = data.result;
// this.calculateTotalSummary();
// this.isLoading = false;
// this.showDraftReportAlert(this._month);
// }
// });
// }

public calculateTotalSummary() {
const totalsRow = [];
if (this.txnewReportSummaryData.length > 0) {
const totalObj = {
location: 'Totals'
};
_.each(this.txnewReportSummaryData, (row) => {
Object.keys(row).map((key) => {
if (Number.isInteger(row[key]) === true) {
if (totalObj[key]) {
totalObj[key] = row[key] + totalObj[key];
} else {
totalObj[key] = row[key];
}
} else {
if (Number.isNaN(totalObj[key])) {
totalObj[key] = 0;
}
if (totalObj[key] === null) {
totalObj[key] = 0;
}
totalObj[key] = 0 + totalObj[key];
}
});
});
totalObj.location = 'Totals';
totalsRow.push(totalObj);
this.pinnedBottomRowData = totalsRow;
}
}
public onIndicatorSelected(value) {
this.router.navigate(['patient-list'], {
relativeTo: this.route,
queryParams: {
indicators: value.field,
indicatorHeader: value.headerName,
indicatorGender: value.gender,
month: this._month,
locationUuids: value.location,
currentView: this.currentView
}
});
}

public showDraftReportAlert(date) {
if (date != null && date >= Moment().endOf('month').format('YYYY-MM-DD')) {
this.isReleased = false;
} else {
this.isReleased = true;
}
}
}
Loading
Loading