Skip to content

Commit

Permalink
POC-534
Browse files Browse the repository at this point in the history
  • Loading branch information
KenstateAllied committed Mar 12, 2024
2 parents 6e8b0f1 + 206de8f commit 79b33af
Show file tree
Hide file tree
Showing 24 changed files with 505 additions and 429 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/app/constants/model.constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Model } from '../interfaces/model.interface';

const STANDARD_CARE_MODEL: Model = {
uuid: 'f0faccb7-657e-413c-abad-54f13409d106',
name: 'STANDARD CARE MODEL'
};

export const Models = {
STANDARD_CARE_MODEL
};
23 changes: 23 additions & 0 deletions src/app/constants/program.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,32 @@ const PMTCT_PROGRAM: Program = {
dept: 'HIV',
compatibleWithOtherDeptPrograms: false
};
const STANDARD_CARE_MODEL: Program = {
uuid: 'f0faccb7-657e-413c-abad-54f13409d106',
name: 'STANDARD CARE MODEL',
dept: 'HIV',
compatibleWithOtherDeptPrograms: false
};
const AHD_MODEL: Program = {
uuid: '4545685e-65f6-48c4-a6b4-860cea88c4d4',
name: 'ADVANCED HIV DISEASE MODEL',
dept: 'HIV',
compatibleWithOtherDeptPrograms: false
};
const VIREMIA_MODEL: Program = {
uuid: '30521f4d-0708-4644-9e88-a108a830a5fd',
name: 'VIREMIA MODEL',
dept: 'HIV',
compatibleWithOtherDeptPrograms: false
};

const STANDARD_HIV_PROGRAM: Program = {
uuid: '781d85b0-1359-11df-a1f1-0026b9348838',
name: 'STANDARD HIV TREATMENT',
dept: 'HIV',
compatibleWithOtherDeptPrograms: false
};

const HIV_DIFFERENTIATED_CARE_PROGRAM: Program = {
uuid: '334c9e98-173f-4454-a8ce-f80b20b7fdf0',
name: 'HIV DIFFERENTIATED CARE PROGRAM',
Expand Down Expand Up @@ -108,6 +128,9 @@ const NUTRITION_PROGRAM: Program = {
export const Programs = {
PMTCT_PROGRAM,
STANDARD_HIV_PROGRAM,
STANDARD_CARE_MODEL,
AHD_MODEL,
VIREMIA_MODEL,
HIV_DIFFERENTIATED_CARE_PROGRAM,
VIREMIA_PROGRAM,
HIV_TRANSIT_PROGRAM,
Expand Down
4 changes: 4 additions & 0 deletions src/app/interfaces/model.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface Model {
uuid: string;
name: string;
}
7 changes: 6 additions & 1 deletion src/app/openmrs-api/patient-resource.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,14 @@ export class PatientResourceService {
v && v.length > 0 ? v : this.v
);

return this.http.get(url, {
// return this.http.get(url, {
// params: params
// });
const parameters = this.http.get(url, {
params: params
});

return parameters;
}
public saveUpdatePatientIdentifier(
uuid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { FormUuids } from './../../../constants/forms.constants';
export class FormentryReferralsHandlerService {
private PMTCT_PROGRAM: Program = Programs.PMTCT_PROGRAM;
private STANDARD_PROGRAM: Program = Programs.STANDARD_HIV_PROGRAM;

private AHD_MODEL: Program = Programs.AHD_MODEL;
constructor(
public diffCareReferralService: DifferentiatedCareReferralService,
public localStorageService: LocalStorageService,
Expand Down Expand Up @@ -151,6 +151,7 @@ export class FormentryReferralsHandlerService {
enrolledIncompatiblePrograms.push(enrolledProgram);
}
});
console.log('enrolledIncompatiblePrograms', enrolledIncompatiblePrograms);
batchProgramUnenrollments.push(
this.programManagerService.editProgramEnrollments(
'stop',
Expand Down
57 changes: 55 additions & 2 deletions src/app/patient-dashboard/common/formentry/formentry.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { FormSubmissionService } from './form-submission.service';
import { MonthlyScheduleResourceService } from '../../../etl-api/monthly-scheduled-resource.service';
import { Patient } from '../../../models/patient.model';
import { PatientService } from '../../services/patient.service';

import { ProgramManagerService } from '../../../program-manager/program-manager.service';
import { PatientProgramResourceService } from '../../../etl-api/patient-program-resource.service';
import { PersonResourceService } from '../../../openmrs-api/person-resource.service';
import { RetrospectiveDataEntryService } from '../../../retrospective-data-entry/services/retrospective-data-entry.service';
Expand All @@ -54,6 +54,8 @@ import { Covid19StatusSummary } from './../../../interfaces/covid-19-summary.int
// constants
import { FormUuids } from './../../../constants/forms.constants';
import { ProgramManagerService } from 'src/app/program-manager/program-manager.service';
import { ComponentResolver } from 'ag-grid/dist/lib/components/framework/componentResolver';
import { Console } from 'console';

interface RefProgram {
uuid: string;
Expand Down Expand Up @@ -157,6 +159,7 @@ export class FormentryComponent implements OnInit, OnDestroy {
private referralsHandler: FormentryReferralsHandlerService,
private formDataSourceService: FormDataSourceService,
private formSubmissionService: FormSubmissionService,
private programManagerService: ProgramManagerService,
private monthlyScheduleResourceService: MonthlyScheduleResourceService,
private patientService: PatientService,
private patientTransferService: PatientTransferService,
Expand Down Expand Up @@ -511,7 +514,7 @@ export class FormentryComponent implements OnInit, OnDestroy {
if (
encounterProvider.length > 0 &&
this.compiledSchemaWithEncounter &&
this.compiledSchemaWithEncounter.provider !== {}
this.compiledSchemaWithEncounter.provider.length !== 0
) {
let provider = this.compiledSchemaWithEncounter.provider.uuid;
if (retroSettings && retroSettings.enabled) {
Expand Down Expand Up @@ -683,7 +686,56 @@ export class FormentryComponent implements OnInit, OnDestroy {
.subscribe(() => {});
}
}
public enrollPatientToNewModel(data: any): void {
let programToEnroll = '';
let modelSelected = [];
modelSelected = this.form.searchNodeByQuestionId('dsdModel');
if (modelSelected.length === 0) {
modelSelected = this.form.searchNodeByQuestionId('moreIntense'); // moreIntense
}

const modelUuid = modelSelected[0].initialValue.value.uuid;

switch (modelUuid) {
case 'c8b9b024-1a3a-47a4-a2aa-fcaf3053ea27':
programToEnroll = '4545685e-65f6-48c4-a6b4-860cea88c4d4'; // AHD
break;
case '520825cf-d045-4bbf-a7f5-a7018f14dd76':
programToEnroll = 'f0faccb7-657e-413c-abad-54f13409d106'; // Standard
break;
case 'fe239aa1-f5d4-4d15-83a1-ce417e9fb879':
programToEnroll = '30521f4d-0708-4644-9e88-a108a830a5fd'; // viremia
break;
}
console.log('Response:', programToEnroll);
const enrollpayload = {
programUuid: programToEnroll,
patient: this.patient,
dateEnrolled: '',
dateCompleted: '',
location: this.userDefaultPropertiesService.getCurrentUserDefaultLocationObject()
.uuid,
enrollmentUuid: ''
};
console.log('Response:', enrollpayload);
this.referralsHandler
.getPatientProgramVisitConfigs(this.patient, programToEnroll)
.pipe(take(1))
.subscribe((programConfig) => {
console.log('Response:', programConfig);
this.referralsHandler
.unenrollFromIncompatiblePrograms(this.patient, programConfig)
.subscribe((res) => {
this.programManagerService
.enrollPatient(enrollpayload)
.pipe(take(1))
.subscribe((program) => {
console.log('Response:', program);
});
console.log('Response:', res);
});
});
}
public handleProgramManagerRedirects(data: any): void {
const step = ['step', 3];
this.patientTransferService
Expand Down Expand Up @@ -1449,6 +1501,7 @@ export class FormentryComponent implements OnInit, OnDestroy {
this.failedPayloadTypes = null;
// this.showSuccessDialog = true;
this.updatePatientDemographics(response);
this.enrollPatientToNewModel(response);
// handle referrals here
this.handleFormReferrals(response);
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/patient-dashboard/common/forms/form-list.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export class FormListService {
}
// comment out /*item.published && */ for all unretired forms (NOTE : ng-forms build)
const publishedOpenmrsForms = _.filter(unsortArray, (item) => {
return item.published && !item.retired;
// return item.published && !item.retired;
return !item.retired;
});

return publishedOpenmrsForms;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ export class CommonVitalsSource implements VitalSourceInterface {
order: 7,
value: ob.value.display
});
case 'feb271fc-a47a-4c6c-8888-c0b6c6e08ecd':
return this.vitalModel.createVital({
name: 'model',
label: 'Model:',
order: 8,
value: ob.value.display
});
default:
return this.vitalModel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class TodaysVitalsService {
const vitalSource = new source(new Vital({}), this.patient);
for (const obs of obsArray) {
const ob = obs;

if (typeof ob.concept !== 'undefined') {
createdVital = vitalSource.getVitals(ob, this.vitalsDataSource);
if (typeof createdVital !== 'undefined' && createdVital.name) {
Expand All @@ -54,7 +55,9 @@ export class TodaysVitalsService {
)
);
}
console.log('createdVital:', createdVital);
});

this.applyCompounding();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<strong *ngIf="currentEnrollment" style="color: gray">
<span>
Patient enrolled in
{{ toTitleCase(currentEnrollment?.openmrsModel?.display) }}
{{ toTitleCase(modelEnrolled) }}
</span>
<span
*ngIf="
Expand Down
29 changes: 28 additions & 1 deletion src/app/patient-dashboard/common/visit/visit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { BsModalService, BsModalRef } from 'ngx-bootstrap';
import { ViewChild } from '@angular/core';
import { PatientService } from '../../services/patient.service';
import { PatientProgramResourceService } from 'src/app/etl-api/patient-program-resource.service';
import { ObsResourceService } from 'src/app/openmrs-api/obs-resource.service';
import * as moment from 'moment';

@Component({
Expand All @@ -30,6 +31,7 @@ import * as moment from 'moment';
export class VisitComponent implements OnInit, OnDestroy {
public currentProgramConfig = {};
public showVisitStartedMsg = false;
public modelEnrolled: any = 'STANDARD CARE MODEL';
public patients: any;
private subs: Subscription[] = [];
public isRetrospectiveVisit = false;
Expand All @@ -48,6 +50,7 @@ export class VisitComponent implements OnInit, OnDestroy {
public enrolledPrograms: Array<any> = [];
public currentProgramEnrollmentUuid = '';
public currentEnrollment: any = undefined;
public patientAssignedModel: any = 'Anon';
public visit: any;
public visits: Array<any> = [];
public programVisitsObj: any = undefined;
Expand All @@ -74,11 +77,13 @@ export class VisitComponent implements OnInit, OnDestroy {
private communityGroupMemberService: CommunityGroupMemberService,
private bsModalService: BsModalService,
private patientService: PatientService,
private patientProgramResourceService: PatientProgramResourceService
private patientProgramResourceService: PatientProgramResourceService,
private obsResourceService: ObsResourceService
) {}

public ngOnInit() {
this.getPatientUuid();
this.getPatientModel();
// this.isBusy = true;
// app feature analytics
// this.appFeatureAnalytics
Expand Down Expand Up @@ -106,10 +111,32 @@ export class VisitComponent implements OnInit, OnDestroy {
}
}
);
console.log('Sub:', sub);

this.subs.push(sub);
}

public getPatientModel() {
console.log('PatientEnrolled', this.patient.uuid);
const patientUuid = this.patient.uuid;
const patientModelConceptUuid = ['af0c1b76-991c-4a8e-a197-7157d9498a33'];
// '2f0a08cc-af60-443e-9536-65fca9494970',
let patientModel;
this.obsResourceService
.getObsPatientObsByConcept(patientUuid, patientModelConceptUuid)
.subscribe((data) => {
console.log('Model', data);
const results = data['results'];
if (results.length > 0) {
this.modelEnrolled = results[0].value.display;
patientModel = this.modelEnrolled;
console.log('patientModel', patientModel);
return patientModel;
}
});
return patientModel;
}

public checkIfPatientEnrolledInGroup() {
this.isBusy = true;
const DIFFERENTIATED_CARE = '334c9e98-173f-4454-a8ce-f80b20b7fdf0';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<div class="programs" *ngIf="enrolledProgrames.length > 0 && !hasError">
<h4 class="component-title">Patient Care Program Snapshots</h4>

<div
<!--<div
style="margin: 4px 0px; padding: 4px"
class="container-fluid alert alert-info"
>
Do you wish to enroll patient into another program?
<enrollment-shortcut class="pull-right"></enrollment-shortcut>
</div>
</div>-->
<div class="program">
<ng-container *ngFor="let row of enrolledProgrames">
<div class="enrolled">
Expand Down
1 change: 1 addition & 0 deletions src/app/patient-dashboard/programs/program.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class ProgramService {
location: locationUuid
};

console.log('Payload: ', payLoad);
// delete dateCompleted property if the dateCompleted is null at enrollment
if (!payLoad.dateCompleted || enrollmentUuid === '') {
delete payLoad['dateCompleted'];
Expand Down
1 change: 1 addition & 0 deletions src/app/patient-dashboard/services/patient.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class PatientService {
this.encounterResource.getEncountersByPatientUuid(patientUuid)
).subscribe(
(data) => {
console.log('Data:', data);
const patient = data[0];
patient.enrolledPrograms = data[1];
patient.encounters = data[2];
Expand Down
Loading

0 comments on commit 79b33af

Please sign in to comment.