Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/AMPATH/ng2-amrs into ampa…
Browse files Browse the repository at this point in the history
…th/master
  • Loading branch information
drizzentic committed Sep 12, 2023
2 parents c7d52ed + ae733c4 commit d6d9571
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
7 changes: 5 additions & 2 deletions src/app/etl-api/clinical-notes-resource.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export class ClinicalNotesResourceService {
public getClinicalNotes(
patientUuid: string,
startIndex: number,
limit: number
limit: number,
isHEIActive: boolean
) {
const api =
this.appSettingsService.getEtlServer() +
Expand All @@ -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 });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -25,6 +27,8 @@ export class ClinicalNotesComponent implements OnInit, OnDestroy {

public notes: Array<any> = [];

public isHEIActive = false;

private helper: ClinicalNotesHelperService;

private subscription: Subscription;
Expand All @@ -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();
}
Expand All @@ -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;
});
});
});
}

Expand All @@ -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;
Expand All @@ -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) => {
Expand Down

0 comments on commit d6d9571

Please sign in to comment.