Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
sainingo committed Dec 14, 2023
1 parent b254c2e commit 296e053
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<p>Patient not eligible for OTZ Program (age 10 and 24)</p>
</div>
<div *ngIf="isOtzDiscontinued && reasonForDiscontinuation">
<div>
<h2 class="">
OTZ Program (discontinued on
<div class="program-header-wrapper">
<h2 class="program-header">
OTZ Program (Discontinued on
{{ otzDiscontinuationDate | date: 'dd-MM-yyyy' }})
</h2>
<p>
Reason for discontinuation:
<strong>{{ reasonForDiscontinuation }}</strong>
</p>
</div>
<p>
Reason for Discontinuation:
<strong>{{ reasonForDiscontinuation }}</strong>
</p>
</div>
<div *ngIf="!isOtzDiscontinued && isPatientEligibleForOtz" class="enrolled">
<div class="program-header-wrapper">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,7 @@ export class OtzSnapshotComponent implements OnInit {
this.getOtzEnrollments(patient.person.age, patient.enrolledPrograms);
this.getHivSummary(patient);
this.getHistoricalPatientLabResults(patient);
this.encounterResource
.getEncounterByUuid('409b4532-9013-4ceb-8519-adb94136230f')
.subscribe((res) => {
if (res && patient.person.uuid === res.patient.uuid) {
const reasonForDiscontinuation = res.obs.find((obs) => {
return (
obs.concept.uuid === 'a89e3f94-1350-11df-a1f1-0026b9348838'
);
});
if (reasonForDiscontinuation) {
this.isOtzDiscontinued = true;
this.reasonForDiscontinuation =
reasonForDiscontinuation.value.display;
this.otzDiscontinuationDate = res.encounterDatetime;
}
}
});
this.getOtzDiscontinuation(patient);
}
}
);
Expand All @@ -100,9 +84,6 @@ export class OtzSnapshotComponent implements OnInit {
}

private getOtzEnrollments(age, enrolledPrograms) {
if (age > 9 && age <= 24) {
this.isPatientEligibleForOtz = true;
}
const otz = enrolledPrograms.filter(
(program) =>
program.concept.uuid === 'fd90d6b2-7302-4a9c-ad1b-1f93eff77afb'
Expand All @@ -113,6 +94,25 @@ export class OtzSnapshotComponent implements OnInit {
} else {
this.dateCompleted = otz[0].dateCompleted;
}
if (age > 9 && age <= 24) {
this.isPatientEligibleForOtz = true;
}
}

private getOtzDiscontinuation(patient) {
patient.encounters.filter((encounter) => {
console.log(encounter);
const reasonForDiscontinuation = encounter.obs.filter((obs) => {
return obs.concept.uuid === 'a89e3f94-1350-11df-a1f1-0026b9348838';
});
console.log(reasonForDiscontinuation);
if (reasonForDiscontinuation.length > 0) {
this.isOtzDiscontinued = true;
this.reasonForDiscontinuation =
reasonForDiscontinuation[0].value.display;
this.otzDiscontinuationDate = encounter.encounterDatetime;
}
});
}

public getHivSummary(patient) {
Expand Down

0 comments on commit 296e053

Please sign in to comment.