@openmrs/esm-billing-app 1.0.2-pre.78 → 1.0.2-pre.786
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +16 -2
- package/README.md +54 -9
- package/__mocks__/bills.mock.ts +12 -0
- package/__mocks__/react-i18next.js +6 -5
- package/dist/1119.js +1 -1
- package/dist/1146.js +1 -2
- package/dist/1146.js.map +1 -1
- package/dist/1197.js +1 -1
- package/dist/1856.js +1 -0
- package/dist/1856.js.map +1 -0
- package/dist/2146.js +1 -1
- package/dist/2177.js +2 -0
- package/dist/2177.js.LICENSE.txt +9 -0
- package/dist/2177.js.map +1 -0
- package/dist/2524.js +1 -0
- package/dist/2524.js.map +1 -0
- package/dist/2690.js +1 -1
- package/dist/3041.js +1 -0
- package/dist/3041.js.map +1 -0
- package/dist/3099.js +1 -1
- package/dist/3584.js +1 -1
- package/dist/4055.js +1 -1
- package/dist/4132.js +1 -1
- package/dist/4225.js +1 -0
- package/dist/4225.js.map +1 -0
- package/dist/4300.js +1 -1
- package/dist/4335.js +1 -1
- package/dist/4618.js +1 -1
- package/dist/4652.js +1 -1
- package/dist/4724.js +1 -0
- package/dist/4724.js.map +1 -0
- package/dist/4739.js +1 -1
- package/dist/4739.js.map +1 -1
- package/dist/4944.js +1 -1
- package/dist/5173.js +1 -1
- package/dist/5241.js +1 -1
- package/dist/5422.js +1 -0
- package/dist/5422.js.map +1 -0
- package/dist/5442.js +1 -1
- package/dist/5661.js +1 -1
- package/dist/6022.js +1 -1
- package/dist/6468.js +1 -1
- package/dist/6540.js +1 -1
- package/dist/6540.js.map +1 -1
- package/dist/6606.js +1 -0
- package/dist/6606.js.map +1 -0
- package/dist/6679.js +1 -1
- package/dist/6840.js +1 -1
- package/dist/6859.js +1 -1
- package/dist/7097.js +1 -1
- package/dist/7159.js +1 -1
- package/dist/723.js +1 -1
- package/dist/7452.js +2 -0
- package/dist/7452.js.map +1 -0
- package/dist/7617.js +1 -1
- package/dist/795.js +1 -1
- package/dist/8163.js +1 -1
- package/dist/8349.js +1 -1
- package/dist/8618.js +1 -1
- package/dist/890.js +1 -1
- package/dist/8930.js +2 -0
- package/dist/{6525.js.LICENSE.txt → 8930.js.LICENSE.txt} +16 -4
- package/dist/8930.js.map +1 -0
- package/dist/9214.js +1 -1
- package/dist/942.js +1 -0
- package/dist/942.js.map +1 -0
- package/dist/9538.js +1 -1
- package/dist/9569.js +1 -1
- package/dist/961.js +1 -1
- package/dist/961.js.map +1 -1
- package/dist/986.js +1 -1
- package/dist/9879.js +1 -1
- package/dist/9895.js +1 -1
- package/dist/9900.js +1 -1
- package/dist/9913.js +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-billing-app.js +1 -1
- package/dist/openmrs-esm-billing-app.js.buildmanifest.json +368 -262
- package/dist/openmrs-esm-billing-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/e2e/README.md +19 -18
- package/e2e/core/test.ts +1 -1
- package/e2e/fixtures/api.ts +1 -1
- package/e2e/specs/sample-test.spec.ts +0 -1
- package/e2e/support/github/Dockerfile +1 -1
- package/package.json +13 -10
- package/src/bill-history/bill-history.component.tsx +17 -25
- package/src/bill-history/bill-history.scss +4 -94
- package/src/bill-history/bill-history.test.tsx +37 -78
- package/src/bill-item-actions/bill-item-actions.scss +0 -4
- package/src/bill-item-actions/{edit-bill-item.component.tsx → edit-bill-item.modal.tsx} +100 -78
- package/src/bill-item-actions/edit-bill-item.test.tsx +116 -31
- package/src/billable-services/bill-waiver/bill-selection.component.tsx +2 -2
- package/src/billable-services/bill-waiver/patient-bills.component.tsx +3 -3
- package/src/billable-services/billable-service.resource.ts +17 -9
- package/src/billable-services/billable-services-home.component.tsx +1 -1
- package/src/billable-services/billable-services.component.tsx +142 -145
- package/src/billable-services/billable-services.scss +3 -0
- package/src/billable-services/billable-services.test.tsx +2 -45
- package/src/billable-services/cash-point/add-cash-point.modal.tsx +168 -0
- package/src/billable-services/cash-point/cash-point-configuration.component.tsx +18 -192
- package/src/billable-services/cash-point/cash-point-configuration.scss +1 -5
- package/src/billable-services/create-edit/add-billable-service.component.tsx +345 -298
- package/src/billable-services/create-edit/add-billable-service.scss +5 -6
- package/src/billable-services/create-edit/add-billable-service.test.tsx +37 -36
- package/src/billable-services/create-edit/edit-billable-service.modal.tsx +51 -0
- package/src/billable-services/payment-modes/add-payment-mode.modal.tsx +121 -0
- package/src/billable-services/payment-modes/delete-payment-mode.modal.tsx +72 -0
- package/src/billable-services/payment-modes/payment-modes-config.component.tsx +125 -0
- package/src/billable-services/{payyment-modes → payment-modes}/payment-modes-config.scss +5 -4
- package/src/billing-form/billing-checkin-form.component.tsx +2 -3
- package/src/billing-form/billing-checkin-form.test.tsx +97 -24
- package/src/billing-form/billing-form.component.tsx +216 -269
- package/src/billing-form/billing-form.scss +143 -0
- package/src/billing.resource.ts +16 -19
- package/src/bills-table/bills-table.test.tsx +98 -54
- package/src/config-schema.ts +52 -24
- package/src/dashboard.meta.ts +4 -2
- package/src/helpers/functions.ts +5 -4
- package/src/index.ts +17 -6
- package/src/invoice/invoice-table.component.tsx +35 -69
- package/src/invoice/invoice-table.scss +1 -5
- package/src/invoice/invoice-table.test.tsx +273 -62
- package/src/invoice/invoice.component.tsx +36 -29
- package/src/invoice/invoice.scss +7 -4
- package/src/invoice/invoice.test.tsx +324 -120
- package/src/invoice/payments/payment-form/payment-form.component.tsx +31 -29
- package/src/invoice/payments/payment-form/payment-form.scss +5 -6
- package/src/invoice/payments/payment-form/payment-form.test.tsx +216 -66
- package/src/invoice/payments/payment-history/payment-history.component.tsx +6 -4
- package/src/invoice/payments/payment-history/payment-history.test.tsx +9 -14
- package/src/invoice/payments/payments.component.tsx +53 -65
- package/src/invoice/payments/payments.test.tsx +282 -0
- package/src/invoice/payments/utils.ts +5 -23
- package/src/invoice/printable-invoice/print-receipt.component.tsx +3 -2
- package/src/invoice/printable-invoice/print-receipt.test.tsx +14 -25
- package/src/invoice/printable-invoice/printable-footer.component.tsx +2 -2
- package/src/invoice/printable-invoice/printable-footer.test.tsx +4 -13
- package/src/invoice/printable-invoice/printable-invoice-header.component.tsx +12 -11
- package/src/invoice/printable-invoice/printable-invoice-header.test.tsx +16 -14
- package/src/invoice/printable-invoice/printable-invoice.component.tsx +19 -33
- package/src/left-panel-link.test.tsx +1 -4
- package/src/metrics-cards/metrics-cards.test.tsx +18 -5
- package/src/modal/require-payment-modal.test.tsx +27 -22
- package/src/modal/{require-payment-modal.component.tsx → require-payment.modal.tsx} +17 -18
- package/src/routes.json +22 -2
- package/src/types/index.ts +26 -17
- package/translations/am.json +70 -21
- package/translations/ar.json +70 -21
- package/translations/ar_SY.json +70 -21
- package/translations/bn.json +75 -26
- package/translations/de.json +70 -21
- package/translations/en.json +70 -21
- package/translations/en_US.json +70 -21
- package/translations/es.json +70 -21
- package/translations/es_MX.json +70 -21
- package/translations/fr.json +83 -34
- package/translations/he.json +70 -21
- package/translations/hi.json +70 -21
- package/translations/hi_IN.json +70 -21
- package/translations/id.json +70 -21
- package/translations/it.json +105 -56
- package/translations/ka.json +70 -21
- package/translations/km.json +70 -21
- package/translations/ku.json +70 -21
- package/translations/ky.json +70 -21
- package/translations/lg.json +70 -21
- package/translations/ne.json +70 -21
- package/translations/pl.json +70 -21
- package/translations/pt.json +70 -21
- package/translations/pt_BR.json +70 -21
- package/translations/qu.json +70 -21
- package/translations/ro_RO.json +214 -165
- package/translations/ru_RU.json +70 -21
- package/translations/si.json +70 -21
- package/translations/sw.json +70 -21
- package/translations/sw_KE.json +70 -21
- package/translations/tr.json +70 -21
- package/translations/tr_TR.json +70 -21
- package/translations/uk.json +70 -21
- package/translations/uz.json +70 -21
- package/translations/uz@Latn.json +70 -21
- package/translations/uz_UZ.json +70 -21
- package/translations/vi.json +70 -21
- package/translations/zh.json +70 -21
- package/translations/zh_CN.json +125 -76
- package/dist/1146.js.LICENSE.txt +0 -21
- package/dist/2352.js +0 -1
- package/dist/2352.js.map +0 -1
- package/dist/246.js +0 -1
- package/dist/246.js.map +0 -1
- package/dist/6525.js +0 -2
- package/dist/6525.js.map +0 -1
- package/dist/8556.js +0 -2
- package/dist/8556.js.map +0 -1
- package/dist/8638.js +0 -1
- package/dist/8638.js.map +0 -1
- package/dist/9968.js +0 -1
- package/dist/9968.js.map +0 -1
- package/src/billable-services/payyment-modes/payment-modes-config.component.tsx +0 -280
- package/src/invoice/payments/payments.component.test.tsx +0 -121
- /package/dist/{8556.js.LICENSE.txt → 7452.js.LICENSE.txt} +0 -0
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
4
|
+
import { type FetchResponse, showSnackbar } from '@openmrs/esm-framework';
|
|
4
5
|
import { type MappedBill } from '../types';
|
|
5
6
|
import { updateBillItems } from '../billing.resource';
|
|
6
|
-
import
|
|
7
|
+
import EditBillLineItemModal from './edit-bill-item.modal';
|
|
8
|
+
|
|
9
|
+
const mockUpdateBillItems = jest.mocked(updateBillItems);
|
|
10
|
+
const mockShowSnackbar = jest.mocked(showSnackbar);
|
|
7
11
|
|
|
8
|
-
// Mock external dependencies
|
|
9
12
|
jest.mock('../billing.resource', () => ({
|
|
10
13
|
updateBillItems: jest.fn(() => Promise.resolve({})),
|
|
11
14
|
}));
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
+
const mockBillableServices = [
|
|
17
|
+
{ name: 'X-Ray Service', uuid: 'xray-uuid-123' },
|
|
18
|
+
{ name: 'Lab Test Service', uuid: 'lab-uuid-456' },
|
|
19
|
+
{ name: 'Consultation Service', uuid: 'consult-uuid-789' },
|
|
20
|
+
];
|
|
16
21
|
|
|
17
22
|
jest.mock('../billable-services/billable-service.resource', () => ({
|
|
18
23
|
useBillableServices: jest.fn(() => ({
|
|
19
|
-
billableServices:
|
|
24
|
+
billableServices: mockBillableServices,
|
|
20
25
|
})),
|
|
21
26
|
}));
|
|
22
27
|
|
|
@@ -41,7 +46,7 @@ const mockBill: MappedBill = {
|
|
|
41
46
|
voided: false,
|
|
42
47
|
voidReason: null,
|
|
43
48
|
priceName: 'Service Price',
|
|
44
|
-
billableService: '
|
|
49
|
+
billableService: 'X-Ray Service',
|
|
45
50
|
priceUuid: 'price-uuid',
|
|
46
51
|
lineItemOrder: 1,
|
|
47
52
|
resourceVersion: '1.0',
|
|
@@ -62,7 +67,7 @@ const mockItem = {
|
|
|
62
67
|
uuid: 'item-uuid',
|
|
63
68
|
quantity: 2,
|
|
64
69
|
price: 100,
|
|
65
|
-
billableService: '
|
|
70
|
+
billableService: 'X-Ray Service',
|
|
66
71
|
paymentStatus: 'UNPAID',
|
|
67
72
|
item: 'Test Service',
|
|
68
73
|
display: 'Test Service',
|
|
@@ -77,61 +82,141 @@ const mockItem = {
|
|
|
77
82
|
describe('ChangeStatus component', () => {
|
|
78
83
|
const closeModalMock = jest.fn();
|
|
79
84
|
|
|
80
|
-
beforeEach(() => {
|
|
81
|
-
jest.clearAllMocks();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
85
|
test('renders the form with correct fields and default values', () => {
|
|
85
|
-
render(<
|
|
86
|
+
render(<EditBillLineItemModal bill={mockBill} item={mockItem} closeModal={closeModalMock} />);
|
|
86
87
|
|
|
87
|
-
expect(screen.getByText('Edit bill line item
|
|
88
|
+
expect(screen.getByText('Edit bill line item')).toBeInTheDocument();
|
|
88
89
|
expect(screen.getByText('John Doe · Main Cashpoint · 123456')).toBeInTheDocument();
|
|
89
90
|
expect(screen.getByRole('spinbutton', { name: /Quantity/ })).toHaveValue(2);
|
|
90
91
|
expect(screen.getByLabelText(/Unit Price/)).toHaveValue('100');
|
|
91
92
|
expect(screen.getByText(/Total/)).toHaveTextContent('200');
|
|
92
93
|
});
|
|
93
94
|
|
|
94
|
-
test('updates total when quantity is changed', () => {
|
|
95
|
-
|
|
95
|
+
test('updates total when quantity is changed', async () => {
|
|
96
|
+
const user = userEvent.setup();
|
|
97
|
+
render(<EditBillLineItemModal bill={mockBill} item={mockItem} closeModal={closeModalMock} />);
|
|
96
98
|
|
|
97
99
|
const quantityInput = screen.getByRole('spinbutton', { name: /Quantity/ });
|
|
98
|
-
|
|
100
|
+
await user.type(quantityInput, '3');
|
|
99
101
|
|
|
100
102
|
expect(screen.getByText(/Total/)).toHaveTextContent('300');
|
|
101
103
|
});
|
|
102
104
|
|
|
103
105
|
test('submits the form and shows a success notification', async () => {
|
|
104
|
-
|
|
106
|
+
const user = userEvent.setup();
|
|
107
|
+
mockUpdateBillItems.mockResolvedValueOnce({} as FetchResponse<any>);
|
|
105
108
|
|
|
106
|
-
render(<
|
|
109
|
+
render(<EditBillLineItemModal bill={mockBill} item={mockItem} closeModal={closeModalMock} />);
|
|
107
110
|
|
|
108
|
-
|
|
111
|
+
await user.click(screen.getByText(/Save/));
|
|
109
112
|
|
|
110
113
|
await waitFor(() => {
|
|
111
|
-
expect(
|
|
114
|
+
expect(mockUpdateBillItems).toHaveBeenCalled();
|
|
112
115
|
expect(showSnackbar).toHaveBeenCalledWith({
|
|
113
|
-
title: '
|
|
114
|
-
subtitle: '
|
|
116
|
+
title: 'Line item updated',
|
|
117
|
+
subtitle: 'The bill line item has been updated successfully',
|
|
115
118
|
kind: 'success',
|
|
116
|
-
timeoutInMs: 3000,
|
|
117
119
|
});
|
|
118
120
|
expect(closeModalMock).toHaveBeenCalled();
|
|
119
121
|
});
|
|
120
122
|
});
|
|
121
123
|
|
|
122
124
|
test('shows error notification when submission fails', async () => {
|
|
123
|
-
|
|
125
|
+
const user = userEvent.setup();
|
|
126
|
+
mockUpdateBillItems.mockRejectedValueOnce({ message: 'Error occurred' });
|
|
124
127
|
|
|
125
|
-
render(<
|
|
128
|
+
render(<EditBillLineItemModal bill={mockBill} item={mockItem} closeModal={closeModalMock} />);
|
|
126
129
|
|
|
127
|
-
|
|
130
|
+
await user.click(screen.getByText(/Save/));
|
|
128
131
|
|
|
129
132
|
await waitFor(() => {
|
|
130
|
-
expect(
|
|
131
|
-
title: '
|
|
133
|
+
expect(mockShowSnackbar).toHaveBeenCalledWith({
|
|
134
|
+
title: 'Failed to update line item',
|
|
132
135
|
kind: 'error',
|
|
133
136
|
subtitle: 'Error occurred',
|
|
134
137
|
});
|
|
135
138
|
});
|
|
136
139
|
});
|
|
140
|
+
|
|
141
|
+
test('preserves billable service UUIDs for other line items when editing', async () => {
|
|
142
|
+
const user = userEvent.setup();
|
|
143
|
+
mockUpdateBillItems.mockResolvedValueOnce({} as FetchResponse<any>);
|
|
144
|
+
|
|
145
|
+
// Bill with multiple line items with different billable services
|
|
146
|
+
const billWithMultipleItems: MappedBill = {
|
|
147
|
+
...mockBill,
|
|
148
|
+
lineItems: [
|
|
149
|
+
{
|
|
150
|
+
uuid: 'item-1',
|
|
151
|
+
quantity: 1,
|
|
152
|
+
price: 100,
|
|
153
|
+
billableService: 'X-Ray Service',
|
|
154
|
+
paymentStatus: 'PENDING',
|
|
155
|
+
item: 'X-Ray',
|
|
156
|
+
display: 'X-Ray',
|
|
157
|
+
voided: false,
|
|
158
|
+
voidReason: null,
|
|
159
|
+
priceName: 'X-Ray Price',
|
|
160
|
+
priceUuid: 'xray-price-uuid',
|
|
161
|
+
lineItemOrder: 1,
|
|
162
|
+
resourceVersion: '1.0',
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
uuid: 'item-2',
|
|
166
|
+
quantity: 2,
|
|
167
|
+
price: 50,
|
|
168
|
+
billableService: 'Lab Test Service',
|
|
169
|
+
paymentStatus: 'PENDING',
|
|
170
|
+
item: 'Lab Test',
|
|
171
|
+
display: 'Lab Test',
|
|
172
|
+
voided: false,
|
|
173
|
+
voidReason: null,
|
|
174
|
+
priceName: 'Lab Price',
|
|
175
|
+
priceUuid: 'lab-price-uuid',
|
|
176
|
+
lineItemOrder: 2,
|
|
177
|
+
resourceVersion: '1.0',
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
uuid: 'item-3',
|
|
181
|
+
quantity: 1,
|
|
182
|
+
price: 200,
|
|
183
|
+
billableService: 'Consultation Service',
|
|
184
|
+
paymentStatus: 'PENDING',
|
|
185
|
+
item: 'Consultation',
|
|
186
|
+
display: 'Consultation',
|
|
187
|
+
voided: false,
|
|
188
|
+
voidReason: null,
|
|
189
|
+
priceName: 'Consult Price',
|
|
190
|
+
priceUuid: 'consult-price-uuid',
|
|
191
|
+
lineItemOrder: 3,
|
|
192
|
+
resourceVersion: '1.0',
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// Editing the Lab Test item (item-2)
|
|
198
|
+
const itemToEdit = billWithMultipleItems.lineItems[1];
|
|
199
|
+
|
|
200
|
+
render(<EditBillLineItemModal bill={billWithMultipleItems} item={itemToEdit} closeModal={closeModalMock} />);
|
|
201
|
+
|
|
202
|
+
await user.click(screen.getByText(/Save/));
|
|
203
|
+
|
|
204
|
+
await waitFor(() => {
|
|
205
|
+
expect(mockUpdateBillItems).toHaveBeenCalled();
|
|
206
|
+
const payload = mockUpdateBillItems.mock.calls[0][0];
|
|
207
|
+
|
|
208
|
+
// Verify that each line item has the correct billable service UUID
|
|
209
|
+
const xrayItem = payload.lineItems.find((li) => li.uuid === 'item-1');
|
|
210
|
+
const consultItem = payload.lineItems.find((li) => li.uuid === 'item-3');
|
|
211
|
+
|
|
212
|
+
// These should NOT have the Lab Test UUID (lab-uuid-456)
|
|
213
|
+
// They should keep their original UUIDs
|
|
214
|
+
expect(xrayItem?.billableService).toBe('xray-uuid-123');
|
|
215
|
+
expect(consultItem?.billableService).toBe('consult-uuid-789');
|
|
216
|
+
|
|
217
|
+
// The edited item should have the Lab Test UUID
|
|
218
|
+
const labItem = payload.lineItems.find((li) => li.uuid === 'item-2');
|
|
219
|
+
expect(labItem?.billableService).toBe('lab-uuid-456');
|
|
220
|
+
});
|
|
221
|
+
});
|
|
137
222
|
});
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
StructuredListWrapper,
|
|
10
10
|
} from '@carbon/react';
|
|
11
11
|
import { useTranslation } from 'react-i18next';
|
|
12
|
-
import { useConfig } from '@openmrs/esm-framework';
|
|
12
|
+
import { getCoreTranslation, useConfig } from '@openmrs/esm-framework';
|
|
13
13
|
import { convertToCurrency } from '../../helpers';
|
|
14
14
|
import { type MappedBill, type LineItem } from '../../types';
|
|
15
15
|
import BillWaiverForm from './bill-waiver-form.component';
|
|
@@ -44,7 +44,7 @@ const PatientBillsSelections: React.FC<{ bills: MappedBill; setPatientUuid: (pat
|
|
|
44
44
|
<StructuredListCell head>{t('quantity', 'Quantity')}</StructuredListCell>
|
|
45
45
|
<StructuredListCell head>{t('unitPrice', 'Unit Price')}</StructuredListCell>
|
|
46
46
|
<StructuredListCell head>{t('total', 'Total')}</StructuredListCell>
|
|
47
|
-
<StructuredListCell head>{
|
|
47
|
+
<StructuredListCell head>{getCoreTranslation('actions')}</StructuredListCell>
|
|
48
48
|
</StructuredListRow>
|
|
49
49
|
</StructuredListHead>
|
|
50
50
|
<StructuredListBody>
|
|
@@ -37,9 +37,9 @@ const PatientBills: React.FC<PatientBillsProps> = ({ patientUuid, bills, setPati
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
const tableHeaders = [
|
|
40
|
-
{ header: 'Date', key: 'date' },
|
|
41
|
-
{ header: 'Billable Service', key: 'billableService' },
|
|
42
|
-
{ header: 'Total Amount', key: 'totalAmount' },
|
|
40
|
+
{ header: t('date', 'Date'), key: 'date' },
|
|
41
|
+
{ header: t('billableService', 'Billable Service'), key: 'billableService' },
|
|
42
|
+
{ header: t('totalAmount', 'Total Amount'), key: 'totalAmount' },
|
|
43
43
|
];
|
|
44
44
|
|
|
45
45
|
const tableRows = bills.map((bill) => ({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import useSWR from 'swr';
|
|
2
2
|
import { type OpenmrsResource, openmrsFetch, restBaseUrl, useOpenmrsFetchAll, useConfig } from '@openmrs/esm-framework';
|
|
3
|
-
import { type ServiceConcept } from '../types';
|
|
4
3
|
import { apiBasePath } from '../constants';
|
|
5
|
-
import { type BillableService } from '../types
|
|
4
|
+
import { type BillableService, type ServiceConcept } from '../types';
|
|
5
|
+
import type { BillingConfig } from '../config-schema';
|
|
6
6
|
|
|
7
7
|
type ResponseObject = {
|
|
8
8
|
results: Array<OpenmrsResource>;
|
|
@@ -22,16 +22,20 @@ export const useBillableServices = () => {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export function useServiceTypes() {
|
|
25
|
-
const
|
|
26
|
-
const serviceConceptUuid =
|
|
25
|
+
const { serviceTypes } = useConfig<BillingConfig>();
|
|
26
|
+
const serviceConceptUuid = serviceTypes.billableService;
|
|
27
27
|
const url = `${restBaseUrl}/concept/${serviceConceptUuid}?v=custom:(setMembers:(uuid,display))`;
|
|
28
28
|
|
|
29
29
|
const { data, error, isLoading } = useSWR<{ data }>(url, openmrsFetch);
|
|
30
30
|
|
|
31
|
+
const sortedServiceTypes = data?.data.setMembers
|
|
32
|
+
? [...data.data.setMembers].sort((a, b) => a.display.localeCompare(b.display))
|
|
33
|
+
: [];
|
|
34
|
+
|
|
31
35
|
return {
|
|
32
|
-
serviceTypes:
|
|
36
|
+
serviceTypes: sortedServiceTypes,
|
|
33
37
|
error,
|
|
34
|
-
isLoading,
|
|
38
|
+
isLoadingServiceTypes: isLoading,
|
|
35
39
|
};
|
|
36
40
|
}
|
|
37
41
|
|
|
@@ -40,14 +44,18 @@ export const usePaymentModes = () => {
|
|
|
40
44
|
|
|
41
45
|
const { data, error, isLoading } = useSWR<{ data: ResponseObject }>(url, openmrsFetch);
|
|
42
46
|
|
|
47
|
+
const sortedPaymentModes = data?.data.results
|
|
48
|
+
? [...data.data.results].sort((a, b) => a.name.localeCompare(b.name))
|
|
49
|
+
: [];
|
|
50
|
+
|
|
43
51
|
return {
|
|
44
|
-
paymentModes:
|
|
52
|
+
paymentModes: sortedPaymentModes,
|
|
45
53
|
error,
|
|
46
|
-
isLoading,
|
|
54
|
+
isLoadingPaymentModes: isLoading,
|
|
47
55
|
};
|
|
48
56
|
};
|
|
49
57
|
|
|
50
|
-
export const
|
|
58
|
+
export const createBillableService = (payload: any) => {
|
|
51
59
|
const url = `${apiBasePath}api/billable-service`;
|
|
52
60
|
return openmrsFetch(url, {
|
|
53
61
|
method: 'POST',
|
|
@@ -9,7 +9,7 @@ import BillWaiver from './bill-waiver/bill-waiver.component';
|
|
|
9
9
|
import BillableServicesDashboard from './dashboard/dashboard.component';
|
|
10
10
|
import BillingHeader from '../billing-header/billing-header.component';
|
|
11
11
|
import CashPointConfiguration from './cash-point/cash-point-configuration.component';
|
|
12
|
-
import PaymentModesConfig from './
|
|
12
|
+
import PaymentModesConfig from './payment-modes/payment-modes-config.component';
|
|
13
13
|
import styles from './billable-services.scss';
|
|
14
14
|
|
|
15
15
|
const BillableServiceHome: React.FC = () => {
|