From ae733c48a201fe89f6ff86d206e9390eb4c11b6d Mon Sep 17 00:00:00 2001 From: Henry Korir <5462699+henrykorir@users.noreply.github.com> Date: Tue, 12 Sep 2023 12:11:52 +0300 Subject: [PATCH] Poc 397 fixes (#1664) * POC-397: fixes * POC-397: fixes * POC-397: fixes * POC-397: fixes * POC-397: fixes * POC-397: fixes * POC-397: fix clinical notes --- .../clinical-notes-resource.service.ts | 7 +++- .../clinical-notes.component.ts | 41 ++++++++++++------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/app/etl-api/clinical-notes-resource.service.ts b/src/app/etl-api/clinical-notes-resource.service.ts index 7a10bb3ce..59260434b 100644 --- a/src/app/etl-api/clinical-notes-resource.service.ts +++ b/src/app/etl-api/clinical-notes-resource.service.ts @@ -15,7 +15,8 @@ export class ClinicalNotesResourceService { public getClinicalNotes( patientUuid: string, startIndex: number, - limit: number + limit: number, + isHEIActive: boolean ) { const api = this.appSettingsService.getEtlServer() + @@ -32,7 +33,9 @@ export class ClinicalNotesResourceService { const params: HttpParams = new HttpParams() .set('startIndex', (startIndex as any) as string) - .set('limit', (limit as any) as string); + .set('limit', (limit as any) as string) + .set('includeNonClinicalEncounter', 'false') + .set('isHEIActive', (isHEIActive as any) as string); return this.http.get(api, { params: params }); } diff --git a/src/app/patient-dashboard/common/clinical-notes/clinical-notes.component.ts b/src/app/patient-dashboard/common/clinical-notes/clinical-notes.component.ts index 9d030d231..c6d9bb6c4 100644 --- a/src/app/patient-dashboard/common/clinical-notes/clinical-notes.component.ts +++ b/src/app/patient-dashboard/common/clinical-notes/clinical-notes.component.ts @@ -6,6 +6,8 @@ import { AppFeatureAnalytics } from '../../../shared/app-analytics/app-feature-a import { ClinicalNotesResourceService } from '../../../etl-api/clinical-notes-resource.service'; import { ClinicalNotesHelperService } from './clinical-notes.helper'; import { Subscription } from 'rxjs'; +import { PatientResourceService } from 'src/app/openmrs-api/patient-resource.service'; +import * as Moment from 'moment'; @Component({ selector: 'app-clinical-notes', @@ -25,6 +27,8 @@ export class ClinicalNotesComponent implements OnInit, OnDestroy { public notes: Array = []; + public isHEIActive = false; + private helper: ClinicalNotesHelperService; private subscription: Subscription; @@ -36,7 +40,8 @@ export class ClinicalNotesComponent implements OnInit, OnDestroy { constructor( private route: ActivatedRoute, private notesResource: ClinicalNotesResourceService, - private appFeatureAnalytics: AppFeatureAnalytics + private appFeatureAnalytics: AppFeatureAnalytics, + private patientResourceService: PatientResourceService ) { this.helper = new ClinicalNotesHelperService(); } @@ -51,16 +56,24 @@ export class ClinicalNotesComponent implements OnInit, OnDestroy { this.subscription = this.route.parent.params.subscribe((params: Params) => { this.patientUuid = params['patient_uuid']; - this.getNotes(0, 10, (err, notes) => { - if (err) { - console.error(err); - return; - } - - this.notes = notes; - - this.fetching = false; - }); + this.patientResourceService + .getPatientByUuid(this.patientUuid) + .subscribe((result) => { + this.isHEIActive = + Moment().diff(Moment(result.person.birthdate), 'months') <= 18 + ? true + : false; + this.getNotes(0, 10, this.isHEIActive, (err, notes) => { + if (err) { + console.error(err); + return; + } + + this.notes = notes; + + this.fetching = false; + }); + }); }); } @@ -76,7 +89,7 @@ export class ClinicalNotesComponent implements OnInit, OnDestroy { this.fetching = false; - this.getNotes(this.nextStartIndex, 10, (err, notes) => { + this.getNotes(this.nextStartIndex, 10, this.isHEIActive, (err, notes) => { if (err) { console.error(err); return; @@ -92,9 +105,9 @@ export class ClinicalNotesComponent implements OnInit, OnDestroy { }); } - public getNotes(startIndex: number, limit: number, cb) { + public getNotes(startIndex: number, limit: number, isHEIACTIVE: boolean, cb) { this.isBusy = this.notesResource - .getClinicalNotes(this.patientUuid, startIndex, limit) + .getClinicalNotes(this.patientUuid, startIndex, limit, this.isHEIActive) .pipe(take(1)) .subscribe( (data: any) => {