From c2b503e876fa9f05eff6652cd9d508c4b5a48267 Mon Sep 17 00:00:00 2001 From: Alfred-Mutai Date: Mon, 17 Apr 2023 21:37:26 +0300 Subject: [PATCH 1/6] POC-267:System is not Loading Members Under Group Manager --- .../group-detail/group-detail.component.html | 2 +- .../group-detail/group-detail.component.ts | 36 +++++++++++-------- ...roup-manager-search-results.component.html | 19 +++++----- .../group-manager-search-results.component.ts | 19 +++++++++- .../group-manager-search.component.ts | 29 +++++++++++---- .../services/toastr-function.service.spec.ts | 18 ++++++++++ .../services/toastr-function.service.ts | 36 +++++++++++++++++++ 7 files changed, 129 insertions(+), 30 deletions(-) create mode 100644 src/app/shared/services/toastr-function.service.spec.ts create mode 100644 src/app/shared/services/toastr-function.service.ts diff --git a/src/app/group-manager/group-detail/group-detail.component.html b/src/app/group-manager/group-detail/group-detail.component.html index a0f2994c6..31cd5cb7a 100644 --- a/src/app/group-manager/group-detail/group-detail.component.html +++ b/src/app/group-manager/group-detail/group-detail.component.html @@ -12,7 +12,7 @@

- Manage Groups \ {{ group.name }} + Manage Groups weeh \ {{ group.name }}

{ - if (cmv.visit.patient.uuid === patient.person.uuid) { - cmv.visit.encounters.forEach((en) => { - if ( - en.encounterType.uuid === drugPickupUuid && - Moment(cmv.visit.startDatetime).format('DD MMMM YYYY') === - Moment(en.encounterDatetime).format('DD MMMM YYYY') - ) { - xx = true; + cohortVisit.cohortMemberVisits.filter((cohortMemberVisit) => { + if (cohortMemberVisit.visit.patient.uuid === personuuid) { + const drugPickupEncounter = cohortMemberVisit.visit.encounters.find( + (encounter) => { + const isDrugPickupEncounter = + encounter.encounterType.uuid === drugPickupUuid; + const isSameDay = Moment( + cohortMemberVisit.visit.startDatetime + ).isSame(encounter.encounterDatetime, 'day'); + return isDrugPickupEncounter && isSameDay; } - }); + ); + if (drugPickupEncounter) { + xx = true; + } } }); @@ -402,12 +406,16 @@ export class GroupDetailComponent implements OnInit, OnDestroy, AfterViewInit { private patientPresent(patient, cohortVisit) { let present = false; + const personuuid = patient.person.uuid; const patientVisit = cohortVisit.cohortMemberVisits.find((v) => { - return v.visit.patient.uuid === patient.person.uuid; + return v.visit.patient.uuid === personuuid; }); - if (patientVisit && this.checkIfDrugPickupFilled(patient, cohortVisit)) { - present = true; + if (patientVisit) { + if (this.checkIfDrugPickupFilled(personuuid, cohortVisit)) { + present = true; + } } + return present; } diff --git a/src/app/group-manager/group-manager-search/group-manager-search-results.component.html b/src/app/group-manager/group-manager-search/group-manager-search-results.component.html index a42b26781..208924895 100644 --- a/src/app/group-manager/group-manager-search/group-manager-search-results.component.html +++ b/src/app/group-manager/group-manager-search/group-manager-search-results.component.html @@ -29,21 +29,24 @@ {{ group.program }} {{ group.facility.display }} {{ group.landmark }} - {{ group.status }} + + {{ group.status }} + - diff --git a/src/app/group-manager/group-manager-search/group-manager-search-results.component.ts b/src/app/group-manager/group-manager-search/group-manager-search-results.component.ts index fb732ac82..631a39ade 100644 --- a/src/app/group-manager/group-manager-search/group-manager-search-results.component.ts +++ b/src/app/group-manager/group-manager-search/group-manager-search-results.component.ts @@ -14,6 +14,7 @@ import * as Moment from 'moment'; import { Subscription } from 'rxjs'; import { DatePickerModalComponent } from '../modals/date-picker-modal.component'; import { Group } from '../../models/group.model'; +import { ToastrFunctionService } from 'src/app/shared/services/toastr-function.service'; @Component({ selector: 'group-manager-search-results', @@ -42,7 +43,8 @@ export class GroupManagerSearchResultsComponent implements OnInit, OnDestroy { constructor( private communityGroupService: CommunityGroupService, - private modalService: BsModalService + private modalService: BsModalService, + private toastrService: ToastrFunctionService ) {} ngOnInit(): void {} @@ -106,6 +108,15 @@ export class GroupManagerSearchResultsComponent implements OnInit, OnDestroy { ); } + public confirmActivate(group: any): void { + const confirmed = window.confirm( + `Are you sure you want to activate group ${group.display}?` + ); + if (confirmed) { + this.activateGroup(group); + } + } + public activateGroup(group) { const index = _.indexOf(this._groups, group); this.communityGroupService.activateGroup(group.uuid).subscribe( @@ -116,6 +127,12 @@ export class GroupManagerSearchResultsComponent implements OnInit, OnDestroy { console.log(error); } ); + + this.toastrService.showToastr( + 'success', + `Group ${group.display} has been activated successully`, + 'Activated!' + ); } ngOnDestroy(): void { diff --git a/src/app/group-manager/group-manager-search/group-manager-search.component.ts b/src/app/group-manager/group-manager-search/group-manager-search.component.ts index fe755fa9c..964abbbc9 100644 --- a/src/app/group-manager/group-manager-search/group-manager-search.component.ts +++ b/src/app/group-manager/group-manager-search/group-manager-search.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit, OnDestroy, TemplateRef } from '@angular/core'; import { CommunityGroupService } from '../../openmrs-api/community-group-resource.service'; +import { ToastrFunctionService } from 'src/app/shared/services/toastr-function.service'; import * as _ from 'lodash'; import { ActivatedRoute, @@ -15,6 +16,7 @@ import { BsModalService, BsModalRef } from 'ngx-bootstrap'; import { Group } from '../../models/group.model'; import { GridOptions, RowNode } from 'ag-grid'; import { ProgramResourceService } from 'src/app/openmrs-api/program-resource.service'; +import { IndividualConfig, ToastrService } from 'ngx-toastr'; @Component({ selector: 'group-manager-search', templateUrl: './group-manager-search.component.html', @@ -49,7 +51,8 @@ export class GroupManagerSearchComponent implements OnInit, OnDestroy { private router: Router, private bsModalService: BsModalService, private route: ActivatedRoute, - private programResourceService: ProgramResourceService + private programResourceService: ProgramResourceService, + private toastrService: ToastrFunctionService ) {} ngOnInit(): void { @@ -243,11 +246,13 @@ export class GroupManagerSearchComponent implements OnInit, OnDestroy { field: 'endDate', cellRenderer: (column) => { if (column.value) { - return ``; + return ` + `; } else { - return ``; + return ``; } } } @@ -277,6 +282,12 @@ export class GroupManagerSearchComponent implements OnInit, OnDestroy { console.log(error); } ); + + this.toastrService.showToastr( + 'success', + `Group ${group.display} has been activated successully`, + 'Activated!' + ); } public gridOnCellClick($event) { @@ -285,7 +296,13 @@ export class GroupManagerSearchComponent implements OnInit, OnDestroy { const actionType = $event.event.target.getAttribute('data-action-type'); switch (actionType) { case 'activate': - return this.activateGroup(data, $event.node); + const confirmed = window.confirm( + `Are you sure you want to activate group ${data.display}?` + ); + if (confirmed) { + return this.activateGroup(data, $event.node); + } + break; case 'disband': return this.disbandGroup(data, $event.node, new Date()); default: diff --git a/src/app/shared/services/toastr-function.service.spec.ts b/src/app/shared/services/toastr-function.service.spec.ts new file mode 100644 index 000000000..b69c85113 --- /dev/null +++ b/src/app/shared/services/toastr-function.service.spec.ts @@ -0,0 +1,18 @@ +import { TestBed, inject } from '@angular/core/testing'; + +import { ToastrFunctionService } from './toastr-function.service'; + +describe('ToastrFunctionService', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [ToastrFunctionService] + }); + }); + + it('should be created', inject( + [ToastrFunctionService], + (service: ToastrFunctionService) => { + expect(service).toBeTruthy(); + } + )); +}); diff --git a/src/app/shared/services/toastr-function.service.ts b/src/app/shared/services/toastr-function.service.ts new file mode 100644 index 000000000..33b1af6dd --- /dev/null +++ b/src/app/shared/services/toastr-function.service.ts @@ -0,0 +1,36 @@ +import { Injectable } from '@angular/core'; +import { ToastrService, IndividualConfig } from 'ngx-toastr'; + +@Injectable({ + providedIn: 'root' +}) +export class ToastrFunctionService { + constructor(private toastr: ToastrService) {} + + public showToastr(type: string, message: string, title: string) { + const options: Partial = { + timeOut: 3000, + progressBar: true, + positionClass: 'toast-top-right', + closeButton: true, + progressAnimation: 'increasing' + }; + + switch (type) { + case 'success': + this.toastr.success(message, title, options); + break; + case 'error': + this.toastr.error(message, title, options); + break; + case 'warning': + this.toastr.warning(message, title, options); + break; + case 'info': + this.toastr.info(message, title, options); + break; + default: + break; + } + } +} From 0ea423359b7e9f14a837095d9816c2d435f65374 Mon Sep 17 00:00:00 2001 From: Alfred-Mutai Date: Mon, 17 Apr 2023 21:50:16 +0300 Subject: [PATCH 2/6] POC-267:System is not Loading Members Under Group Manager --- src/app/group-manager/group-detail/group-detail.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/group-manager/group-detail/group-detail.component.html b/src/app/group-manager/group-detail/group-detail.component.html index 31cd5cb7a..a0f2994c6 100644 --- a/src/app/group-manager/group-detail/group-detail.component.html +++ b/src/app/group-manager/group-detail/group-detail.component.html @@ -12,7 +12,7 @@

- Manage Groups weeh \ {{ group.name }} + Manage Groups \ {{ group.name }}

Date: Mon, 17 Apr 2023 22:07:20 +0300 Subject: [PATCH 3/6] POC-267:System is not Loading Members Under Group Manager --- .../services/toastr-function.service.spec.ts | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 src/app/shared/services/toastr-function.service.spec.ts diff --git a/src/app/shared/services/toastr-function.service.spec.ts b/src/app/shared/services/toastr-function.service.spec.ts deleted file mode 100644 index b69c85113..000000000 --- a/src/app/shared/services/toastr-function.service.spec.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { TestBed, inject } from '@angular/core/testing'; - -import { ToastrFunctionService } from './toastr-function.service'; - -describe('ToastrFunctionService', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [ToastrFunctionService] - }); - }); - - it('should be created', inject( - [ToastrFunctionService], - (service: ToastrFunctionService) => { - expect(service).toBeTruthy(); - } - )); -}); From 764567874e5c2666dbdc123babf661550b73c2cc Mon Sep 17 00:00:00 2001 From: Alfred-Mutai Date: Mon, 24 Apr 2023 11:24:51 +0300 Subject: [PATCH 4/6] POC-267:System is not Loading Members Under Group Manager --- src/app/group-manager/group-detail/group-detail.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/group-manager/group-detail/group-detail.component.ts b/src/app/group-manager/group-detail/group-detail.component.ts index 526e89e09..669f9e68d 100644 --- a/src/app/group-manager/group-detail/group-detail.component.ts +++ b/src/app/group-manager/group-detail/group-detail.component.ts @@ -447,6 +447,7 @@ export class GroupDetailComponent implements OnInit, OnDestroy, AfterViewInit { onGroupDetailsChanged(updatedGroup) { this.group = updatedGroup; this.generateMembersData(this.group.cohortMembers, this.group.cohortVisits); + this.loadGroup(); } private generateColumns(cohortVisits) { From 6fb627dc103f55981e653ad7ae9b2d9055666bbc Mon Sep 17 00:00:00 2001 From: Alfred-Mutai Date: Thu, 27 Apr 2023 10:32:40 +0300 Subject: [PATCH 5/6] POC-267:System is not Loading Members Under Group Manager --- .../group-detail/group-detail.component.html | 10 +-- .../group-detail/group-detail.component.ts | 71 +++++++++++++------ 2 files changed, 57 insertions(+), 24 deletions(-) diff --git a/src/app/group-manager/group-detail/group-detail.component.html b/src/app/group-manager/group-detail/group-detail.component.html index a0f2994c6..380b684a8 100644 --- a/src/app/group-manager/group-detail/group-detail.component.html +++ b/src/app/group-manager/group-detail/group-detail.component.html @@ -153,22 +153,24 @@

Active Members

- + {{ member.patient.person.display }} - + {{ member.phoneNumber.value }} - - + {{ member.startDate | date: 'medium' }}