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-768 #1761

Merged
merged 4 commits into from
Jul 21, 2024
Merged

POC-768 #1761

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 @@ -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
Loading