Skip to content

Commit

Permalink
v2.18.0-bug fixes (#1692)
Browse files Browse the repository at this point in the history
* change version

* Optimize request

* bug fixes

---------

Co-authored-by: sainingo <sainingo>
  • Loading branch information
sainingo authored Dec 19, 2023
1 parent 70efc3c commit 7ab0fdb
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 40 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-amrs",
"version": "2.17.2",
"version": "2.18.0",
"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0 --port 3000",
Expand Down
16 changes: 11 additions & 5 deletions src/app/etl-api/cohort-otz-module-resource.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ export class CohortOtzModuleResourceService {
return urlParams;
}

public getUrlRequestParamsByLocationUuid(locationUuid: string): HttpParams {
let urlParams: HttpParams = new HttpParams();

if (locationUuid) {
urlParams = urlParams.set('uuid', locationUuid);
}
return urlParams;
}

public getPatientsLatestHivSummaries(payload: string[]) {
if (!payload || payload.length === 0) {
return null;
Expand All @@ -50,12 +59,9 @@ export class CohortOtzModuleResourceService {
});
}

public getCohortSuppressionStatus(payload: string[]) {
if (!payload || payload.length === 0) {
return null;
}
public getCohortSuppressionStatus(locationUuid: string) {
return this.http.get(this.getCohortSuppressionsUrl(), {
params: this.getUrlRequestParams(payload)
params: this.getUrlRequestParamsByLocationUuid(locationUuid)
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ <h2>Group Search</h2>
></group-manager-search-results>
</div>
</div>
<div clas="row" style="margin-top: 15px">
<div class="col-md-12 col-sm-12 col-lg-12 col-xs-12">
<div class="row" style="margin-top: 15px">
<div class="col-md-12 col-sm-12 col-xs-12">
<button
mat-raised-button
(click)="showModal(createGroupModal)"
Expand All @@ -37,6 +37,7 @@ <h2>Group Search</h2>
border-radius: 10px;
color: #31708f;
font-weight: 700;
margin-bottom: 1rem;
"
>
<span class="fa fa-users"></span> Create New Group
Expand All @@ -51,6 +52,7 @@ <h2>Group Search</h2>
color: #31708f;
font-weight: 700;
margin-left: 15px;
margin-bottom: 1rem;
"
>
<span class="fa fa-eye"></span> View All DC Groups In This Facility
Expand All @@ -59,6 +61,7 @@ <h2>Group Search</h2>
class="fa fa-spinner fa-spin"
></i>
</button>

<button
mat-raised-button
(click)="showOTZGroupsInFacilty()"
Expand All @@ -68,6 +71,7 @@ <h2>Group Search</h2>
color: #31708f;
font-weight: 700;
margin-left: 15px;
margin-bottom: 1rem;
"
>
<span class="fa fa-eye"></span> View All OTZ Clubs In This Facility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class GroupManagerSearchComponent implements OnInit, OnDestroy {
hideGroupsInCurrentFacility: boolean;
public isOTZprogram = false;
public filterOTZ = '';
cohortUuids = new Map();

constructor(
private groupService: CommunityGroupService,
Expand Down Expand Up @@ -100,56 +101,62 @@ export class GroupManagerSearchComponent implements OnInit, OnDestroy {
}

public showGroupsInFacilty() {
this.rowData = [];
this.fetchingGroups = true;
this.isOTZprogram = false;
this.filterText = '';
const locationUuid = this.router.url.split('/')[2];
if (locationUuid !== this.previousLocationUuid) {

if (locationUuid === this.previousLocationUuid && this.isOTZprogram) {
this.rowData = [];
this.groupsInCurrentFacility = [];
this.isOTZprogram = false;
this.showDcGroupsInFacility(locationUuid);
} else if (locationUuid !== this.previousLocationUuid) {
this.fetchingGroups = true;
const sub = this.groupService
.getGroupsByLocationUuid(locationUuid)
.subscribe((res) => {
this.groupsInCurrentFacility = res.map((result) => new Group(result));
this.hideGroupsInCurrentFacility = false;
this.fetchingGroups = false;
this.isOTZprogram = false;
this.previousLocationUuid = locationUuid;
this.rowData = this.groupsInCurrentFacility;
});
this.subscription.add(sub);
this.showDcGroupsInFacility(locationUuid);
} else {
this.rowData = this.groupsInCurrentFacility;
}
}

public showDcGroupsInFacility(locationUuid) {
const sub = this.groupService
.getGroupsByLocationUuid(locationUuid)
.subscribe((res) => {
this.groupsInCurrentFacility = res.map((result) => new Group(result));
this.hideGroupsInCurrentFacility = false;
this.fetchingGroups = false;
this.previousLocationUuid = locationUuid;
this.rowData = this.groupsInCurrentFacility;
this.filterText = 'HIV DIFFERENTIATED CARE PROGRAM';
if (this.gridOptions.api) {
this.gridOptions.api.onFilterChanged();
}
});
this.columnDefs = this.generateColumns();
this.subscription.add(sub);
}
public showOTZGroupsInFacilty() {
this.rowData = [];
this.fetchingGroups = true;
this.isOTZprogram = true;
const locationUuid = this.router.url.split('/')[2];
this.fetchingGroups = true;
this.getCohortSuppresionRate(locationUuid);
const sub = this.groupService
.getGroupsByLocationUuid(locationUuid)
.subscribe((res) => {
this.groupsInCurrentFacility = res.map((result) => {
const groupInstance = new Group(result);
const cohortUuid = this.generateCohortUuids([groupInstance]);
this.cohortOtzModuleResourceService
.getCohortSuppressionStatus(Array.from(cohortUuid.keys()))
.subscribe((supressionRate: any) => {
if (supressionRate.result.length > 0) {
groupInstance.viralSuppression =
supressionRate.result[0].suppression_rate_percentage.toFixed(
2
) + '%';
}
});
groupInstance.viralSuppression =
this.cohortUuids.has(groupInstance.openmrsModel.uuid) &&
this.cohortUuids
.get(groupInstance.openmrsModel.uuid)
.suppression_rate_percentage.toFixed(2) + '%';
return groupInstance;
});
this.hideGroupsInCurrentFacility = false;
this.fetchingGroups = false;
this.isOTZprogram = false;
// this.isOTZprogram = false;
this.rowData = this.groupsInCurrentFacility;
this.filterText = 'OTZ PROGRAM';
if (this.gridOptions.api) {
Expand All @@ -161,12 +168,19 @@ export class GroupManagerSearchComponent implements OnInit, OnDestroy {
this.subscription.add(sub);
}

public generateCohortUuids(cohort) {
const patientUuids = new Map();
cohort.forEach((uuid) => {
patientUuids.set(uuid._openmrsModel.uuid, uuid._openmrsModel);
public generateCohortUuids(cohortData) {
cohortData.forEach((cohort) => {
this.cohortUuids.set(cohort.uuid, cohort);
});
return patientUuids;
return this.cohortUuids;
}

public getCohortSuppresionRate(locationUuid: string) {
return this.cohortOtzModuleResourceService
.getCohortSuppressionStatus(locationUuid)
.subscribe((data: any) => {
this.generateCohortUuids(data.result);
});
}

public navigateToGroupDetails(group, newGroup?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export class FamilyTestingContactComponent implements OnInit {
}

public onAddContactClick() {
const defaulterTracingFormV1Uuid = 'bf6d0d9a-e6af-48fd-9245-6d1939adb37d';
const defaulterTracingFormV1Uuid = 'f3ba9242-9bbb-4284-a0c0-56ac6f0cec65';
const url = `/patient-dashboard/patient/${this.patientUuid}/general/general/formentry/${defaulterTracingFormV1Uuid}`;
this.router.navigate([url], {});
}
Expand Down

0 comments on commit 7ab0fdb

Please sign in to comment.