-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
POC-737: Development of MOH Registers
- Loading branch information
1 parent
69e9cf5
commit 0f9f49e
Showing
43 changed files
with
2,408 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
54 changes: 54 additions & 0 deletions
54
src/app/data-analytics-dashboard/hiv/registers/anc-register/anc-register.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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">×</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> |
24 changes: 24 additions & 0 deletions
24
src/app/data-analytics-dashboard/hiv/registers/anc-register/anc-register.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
161 changes: 161 additions & 0 deletions
161
src/app/data-analytics-dashboard/hiv/registers/anc-register/anc-register.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
Empty file.
Oops, something went wrong.