Skip to content

Commit

Permalink
POC-768 (#1761)
Browse files Browse the repository at this point in the history
* POC-768: Group Manager Bug

* Fix prettier issues

* Fix lint issues

---------

Co-authored-by: Alfred Mutai <[email protected]>
  • Loading branch information
sainingo and Alfred-Mutai authored Jul 21, 2024
1 parent eb5d787 commit 2ec29c4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ <h4 class="text">Group Summary</h4>
</ng-container>
</td>
</tr>
<tr>
<tr *ngIf="validOTZProgram">
<td>
<strong>Group Activity: </strong>
<span *ngIf="landmark">{{ groupActivity?.value }}</span>
<span *ngIf="groupActivity">{{ groupActivity?.value }}</span>
</td>
</tr>
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ export class GroupDetailSummaryComponent implements OnInit, OnDestroy {
public showUpdateGroupModal(modal) {
let program = null;
let provider = null;
const context = this.validOTZProgram;
this.program
? (program = this.program)
: (program = { name: null, value: null });
Expand All @@ -571,7 +572,7 @@ export class GroupDetailSummaryComponent implements OnInit, OnDestroy {
groupProgram: { label: program['name'], value: program['uuid'] },
provider: { label: provider.person.display, value: provider.person.uuid },
address: this.landmark.value,
groupActivity: this.groupActivity.value,
groupActivity: context ? this.groupActivity.value : null,
groupUuid: this.group.uuid,
actionButtonText: 'Save Changes'
};
Expand Down
11 changes: 1 addition & 10 deletions src/app/group-manager/group-detail/group-detail.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,7 @@ <h4 class="modal-title pull-left">Add Membership</h4>
<div class="alert alert-danger" *ngIf="enrollmentErrorMessage">
{{ enrollmentErrorMessage }}
</div>
<div
class="alert alert-info"
*ngIf="showEnrollmentButton && showOTZEnrollmentMsg"
>
<div class="alert alert-info" *ngIf="showEnrollmentButton">
<button
class="btn btn-xs btn-primary pull-right"
(click)="enrollPatienttoProgram()"
Expand All @@ -252,12 +249,6 @@ <h4 class="modal-title pull-left">Add Membership</h4>
</button>
The patient is not enrolled in this program.
</div>
<div
class="alert alert-info"
*ngIf="showEnrollmentButton && !showOTZEnrollmentMsg"
>
Patient is not eligible for OTZ enrollment
</div>

<busy
*ngIf="validatingEnrollment"
Expand Down
27 changes: 23 additions & 4 deletions src/app/group-manager/group-detail/group-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,10 @@ export class GroupDetailComponent implements OnInit, OnDestroy, AfterViewInit {
(group) => !group.voided
);
}
const targetProgramUuid = '203571d6-a4f2-4953-9e8b-e1105e2340f5';
const checkOTZProgram = programsEnrolled.some(
(program) => program.programUuid === targetProgramUuid
);
const validation = this.communityGroupMemberService.validateMemberEnrollment(
programsEnrolled,
currentGroupsEnrolled,
Expand All @@ -778,9 +782,17 @@ export class GroupDetailComponent implements OnInit, OnDestroy, AfterViewInit {
this.validatingEnrollment = false;
this.showEnrollmentAlert('Patient already enrolled in this group!');
break;
case !validation.notEnrolledInGroupProgram.found:
case !validation.notEnrolledInGroupProgram.found &&
checkOTZProgram &&
this.isOtzProgram:
this.validatingEnrollment = false;
this.validateAge(patient);
if (this.showOTZEnrollmentMsg) {
this.showEnrollButton(patient);
}
break;
case !validation.notEnrolledInGroupProgram.found:
this.validatingEnrollment = false;
this.showEnrollButton(patient);
break;
case validation.enrolledInAnotherGroupInSameProgram.found:
Expand Down Expand Up @@ -839,12 +851,16 @@ export class GroupDetailComponent implements OnInit, OnDestroy, AfterViewInit {
}

private validateAge(patient) {
if (patient._person.age > 9 && patient._person.age <= 24) {
const age = patient._person.age;

if (age > 9 && age <= 24) {
this.showOTZEnrollmentMsg = true;
} else {
this.showOTZEnrollmentMsg = false;
return;
}

this.showEnrollmentAlert('Patient is not eligible for OTZ enrollment!');
}

private enrollPatientToGroup(group: Group, patient: Patient) {
this.communityGroupMemberService
.createMember(group.uuid, patient.uuid)
Expand All @@ -859,6 +875,9 @@ export class GroupDetailComponent implements OnInit, OnDestroy, AfterViewInit {

private showEnrollmentAlert(msg: string) {
this.enrollmentErrorMessage = msg;
setTimeout(() => {
this.enrollmentErrorMessage = '';
}, 5000);
}

private transferPatientFromGroup(groupToEnroll, groupToUnenroll, patient) {
Expand Down

0 comments on commit 2ec29c4

Please sign in to comment.