Skip to content

Commit

Permalink
Merge pull request #486 from udsm-dhis2-lab/feature/improve-lis-menu
Browse files Browse the repository at this point in the history
Add lis price-list module and fix null pointer when setting price of …
  • Loading branch information
josephatJ authored Nov 19, 2024
2 parents 7f06e8c + 1a4e942 commit 50d8b02
Show file tree
Hide file tree
Showing 19 changed files with 167 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ public ItemPrice saveItemPrice(ItemPrice itemPrice) throws APIException {
itemPrice.setPaymentType(paymentType);
if (itemPrice.getPayable() != null && itemPrice.getPayablePaymentMode() == null) {
throw new APIException("Payment mode for payable not provided");
} else {
} else if (itemPrice.getPayablePaymentMode() != null
&& itemPrice.getPayablePaymentMode().getUuid() != null
&& conceptService.getConceptByUuid(itemPrice.getPayablePaymentMode().getUuid()) != null) {
Concept payablePaymentMode = conceptService.getConceptByUuid(itemPrice.getPayablePaymentMode().getUuid());
itemPrice.setPayablePaymentMode(payablePaymentMode);
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/modules/laboratory/laboratory.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
<ng-container *ngIf="params?.LISConfigurations?.isLIS">
<div
*ngIf="showMenuItems"
class="col-2.5 lis-menu"
class="col-2 lis-menu"
style="margin-left: -16px; margin-right: -8px"
>
<div
Expand Down
6 changes: 6 additions & 0 deletions ui/src/app/modules/laboratory/laboratory.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ export class LaboratoryComponent implements OnInit {
id: "general",
icon: "settings",
},
{
name: "Price list",
route: "settings/price-list",
id: "price-list",
icon: "money",
},
],
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { LabConfigurationsComponent } from "./lab-configurations/lab-configurati
import { LabEditUserModalComponent } from "./lab-edit-user-modal/lab-edit-user-modal.component";
import { LabOrdersManagementDashboardComponent } from "./lab-orders-management-dashboard/lab-orders-management-dashboard.component";
import { LabOrdersManagementComponent } from "./lab-orders-management/lab-orders-management.component";
import { LabPriceListHomeComponent } from "./lab-price-list-home/lab-price-list-home.component";
import { LabsSectionManagementComponent } from "./labs-section-management/labs-section-management.component";
import { LbPriceListContainerComponent } from "./lb-price-list-container/lb-price-list-container.component";
import { LoggedinusersComponent } from "./loggedinusers/loggedinusers.component";
Expand Down Expand Up @@ -77,7 +78,8 @@ export const components: any[] = [
AuditLogsComponent,
TestInterpretationsComponent,
TestTargetCreationComponent,
TestTargetListComponent
TestTargetListComponent,
LabPriceListHomeComponent,
];

export const entrySettingComponents: any[] = [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div *ngIf="{ paymentTypes: paymentTypes$ | async } as params">
<mat-progress-bar
*ngIf="!params?.paymentTypes"
mode="indeterminate"
></mat-progress-bar>
<app-price-list
[paymentTypes]="params?.paymentTypes"
[hideDepartmentsSelection]="true"
*ngIf="params?.paymentTypes && params?.paymentTypes.length > 0"
></app-price-list>
<div
class="text-danger text-center"
*ngIf="params?.paymentTypes && params?.paymentTypes.length === 0"
>
<p>Payment types not set</p>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { LabPriceListHomeComponent } from './lab-price-list-home.component';

describe('LabPriceListHomeComponent', () => {
let component: LabPriceListHomeComponent;
let fixture: ComponentFixture<LabPriceListHomeComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [LabPriceListHomeComponent]
})
.compileComponents();

fixture = TestBed.createComponent(LabPriceListHomeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Component, Input, OnInit } from "@angular/core";
import { select, Store } from "@ngrx/store";
import { Observable } from "rxjs";
import { initiatePaymentTypes } from "src/app/store/actions/payment-type.actions";
import { AppState } from "src/app/store/reducers";
import { getAllPaymentTypes } from "src/app/store/selectors/payment-type.selectors";

@Component({
selector: "app-lab-price-list-home",
templateUrl: "./lab-price-list-home.component.html",
styleUrl: "./lab-price-list-home.component.scss",
})
export class LabPriceListHomeComponent implements OnInit {
@Input() paymentCategories: any[];
paymentTypes$: Observable<any>;
constructor(private store: Store<AppState>) {}
ngOnInit(): void {
this.store.dispatch(
initiatePaymentTypes({ paymentCategories: this.paymentCategories })
);

this.paymentTypes$ = this.store.pipe(select(getAllPaymentTypes));
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { LabPriceListHomeContainerComponent } from "./lab-price-list-home-container/lab-price-list-home-container.component";
import { LabSystemSettingsComponent } from "./lab-system-settings/lab-system-settings.component";
import { LabsAndSectionsManagementComponent } from "./labs-and-sections-management/labs-and-sections-management.component";
import { OtherLabConfigurationsComponent } from "./other-lab-configurations/other-lab-configurations.component";
Expand All @@ -12,4 +13,5 @@ export const settingsContainers: any[] = [
LabSystemSettingsComponent,
WorksheetManagementComponent,
SystemLogsComponent,
LabPriceListHomeContainerComponent,
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div
*ngIf="{
paymentCategories: paymentCategories$ | async
} as params"
>
<mat-progress-bar
*ngIf="!params?.paymentCategories"
mode="indeterminate"
></mat-progress-bar>
<app-lab-price-list-home
[paymentCategories]="params?.paymentCategories?.setMembers"
*ngIf="params?.paymentCategories"
></app-lab-price-list-home>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { LabPriceListHomeContainerComponent } from './lab-price-list-home-container.component';

describe('LabPriceListHomeContainerComponent', () => {
let component: LabPriceListHomeContainerComponent;
let fixture: ComponentFixture<LabPriceListHomeContainerComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [LabPriceListHomeContainerComponent]
})
.compileComponents();

fixture = TestBed.createComponent(LabPriceListHomeContainerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Component, OnInit } from "@angular/core";
import { Store } from "@ngrx/store";
import { Observable } from "rxjs";
import { loadConceptByUuid } from "src/app/store/actions";
import { AppState } from "src/app/store/reducers";
import { getConceptById } from "src/app/store/selectors";

@Component({
selector: "app-lab-price-list-home-container",
templateUrl: "./lab-price-list-home-container.component.html",
styleUrl: "./lab-price-list-home-container.component.scss",
})
export class LabPriceListHomeContainerComponent implements OnInit {
paymentCategories$: Observable<any>;
constructor(private store: Store<AppState>) {}
ngOnInit(): void {
// TODO: Save the uuid on global properties, and switch-map accordingly
this.store.dispatch(
loadConceptByUuid({
uuid: "c95c1065-bcea-4a35-aee0-ca62906ec8e2",
fields: "custom:(uuid,display,setMembers:(uuid,display)",
})
);
this.paymentCategories$ = this.store.select(getConceptById, {
id: "c95c1065-bcea-4a35-aee0-ca62906ec8e2",
});
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { NgModule } from "@angular/core";
import { Routes, RouterModule } from "@angular/router";
import { SettingsComponent } from "./settings/settings.component";
import { LabPriceListHomeContainerComponent } from "./containers/lab-price-list-home-container/lab-price-list-home-container.component";

const routes: Routes = [
{
path: "",
component: SettingsComponent,
},
{
path: "price-list",
component: LabPriceListHomeContainerComponent,
},
];

@NgModule({
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/modules/maintenance/models/item-price.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class ItemPrice {
}

get display(): string {
return this.itemPriceDetails?.item?.display;
return this.itemPriceDetails?.item?.display?.replace("TEST_ORDERS:", "");
}

get paymentType(): any {
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/modules/maintenance/models/pricing-item.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { kebabCase } from 'lodash';
import { kebabCase } from "lodash";
export interface PricingItemInterface {
id: string;
uuid: string;
Expand All @@ -18,7 +18,7 @@ export class PricingItem {

get display(): string {
return (
this.itemPriceDetails?.concept?.display ||
this.itemPriceDetails?.concept?.display?.replace("TEST_ORDERS:", "") ||
this.itemPriceDetails?.drug?.display
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@

.price-list-container {
padding: 8px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ export class PriceListComponent implements OnInit, OnChanges {

ngOnInit() {
this.currentDepartmentId = this.departmentId;
this.isDrug = this.currentDepartmentId == "Drug" ? true : false;
this.isDrug =
this.currentDepartmentId && this.currentDepartmentId == "Drug"
? true
: false;

this.loadData();
this.priceListDepartments$ =
Expand Down Expand Up @@ -153,7 +156,7 @@ export class PriceListComponent implements OnInit, OnChanges {
panelClass: "custom-dialog-container",
data: { pricingItems },
});
this.trackActionForAnalytics('Add Price List: Open');
this.trackActionForAnalytics("Add Price List: Open");
// TODO: Find best way in order to stop subscribing here
dialog.afterClosed().subscribe((results) => {
if (results) {
Expand Down Expand Up @@ -213,8 +216,6 @@ export class PriceListComponent implements OnInit, OnChanges {
(pricingItem: PricingItemInterface) => {
this.addingPricingItem = false;
this.store.dispatch(upsertPricingItem({ pricingItem }));


},
() => {
this.addingPricingItem = false;
Expand Down
7 changes: 7 additions & 0 deletions ui/src/app/store/effects/pricing-item.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ export class PricingItemEffects {
prices: priceItem?.prices.map((price) => {
return {
...price,
item: {
...price?.item,
display: price?.item?.display?.replace(
"TEST_ORDERS:",
""
),
},
paymentSchemeUuid: price?.paymentScheme?.uuid,
};
}),
Expand Down

0 comments on commit 50d8b02

Please sign in to comment.