@openmrs/esm-billing-app 1.2.1-pre.1879 → 1.3.0

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.
@@ -127,9 +127,9 @@
127
127
  "rendered": true,
128
128
  "initial": false,
129
129
  "entry": false,
130
- "size": 17235,
130
+ "size": 18782,
131
131
  "sizes": {
132
- "javascript": 17235
132
+ "javascript": 18782
133
133
  },
134
134
  "names": [],
135
135
  "idHints": [],
@@ -143,7 +143,7 @@
143
143
  "auxiliaryFiles": [
144
144
  "1877.js.map"
145
145
  ],
146
- "hash": "4046db07f7ba16b4",
146
+ "hash": "24d615079518f592",
147
147
  "childrenByOrder": {}
148
148
  },
149
149
  {
@@ -151,10 +151,10 @@
151
151
  "rendered": true,
152
152
  "initial": true,
153
153
  "entry": true,
154
- "size": 5561583,
154
+ "size": 5561090,
155
155
  "sizes": {
156
156
  "consume-shared": 210,
157
- "javascript": 5561037,
157
+ "javascript": 5560544,
158
158
  "runtime": 13411,
159
159
  "share-init": 336
160
160
  },
@@ -171,7 +171,7 @@
171
171
  "auxiliaryFiles": [
172
172
  "main.js.map"
173
173
  ],
174
- "hash": "345e80db8e2c4d9b",
174
+ "hash": "9533672256712833",
175
175
  "childrenByOrder": {}
176
176
  },
177
177
  {
@@ -856,9 +856,9 @@
856
856
  "rendered": true,
857
857
  "initial": false,
858
858
  "entry": false,
859
- "size": 19296,
859
+ "size": 20612,
860
860
  "sizes": {
861
- "javascript": 19296
861
+ "javascript": 20612
862
862
  },
863
863
  "names": [],
864
864
  "idHints": [],
@@ -872,7 +872,7 @@
872
872
  "auxiliaryFiles": [
873
873
  "5145.js.map"
874
874
  ],
875
- "hash": "02bc290ce89208ed",
875
+ "hash": "8ce91e7134a27952",
876
876
  "childrenByOrder": {}
877
877
  },
878
878
  {
@@ -1626,7 +1626,7 @@
1626
1626
  "auxiliaryFiles": [
1627
1627
  "9655.js.map"
1628
1628
  ],
1629
- "hash": "7a469c142e1856f6",
1629
+ "hash": "662fed6e03f90c25",
1630
1630
  "childrenByOrder": {}
1631
1631
  },
1632
1632
  {
@@ -1658,10 +1658,10 @@
1658
1658
  "rendered": true,
1659
1659
  "initial": false,
1660
1660
  "entry": false,
1661
- "size": 1628122,
1661
+ "size": 1627629,
1662
1662
  "sizes": {
1663
1663
  "consume-shared": 42,
1664
- "javascript": 1628080
1664
+ "javascript": 1627587
1665
1665
  },
1666
1666
  "names": [],
1667
1667
  "idHints": [],
@@ -1674,7 +1674,7 @@
1674
1674
  "auxiliaryFiles": [
1675
1675
  "990.js.map"
1676
1676
  ],
1677
- "hash": "dae014f89f92bf85",
1677
+ "hash": "de747c285b3365e4",
1678
1678
  "childrenByOrder": {}
1679
1679
  }
1680
1680
  ]
package/dist/routes.json CHANGED
@@ -1 +1 @@
1
- {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"billing":">=2.3.0-0","webservices.rest":">=2.24.0"},"pages":[{"component":"billableServicesHome","route":"billable-services"}],"extensions":[{"component":"billingDashboardLink","name":"billing-dashboard-link","slot":"homepage-dashboard-slot","meta":{"name":"billing","title":"billing","slot":"billing-dashboard-slot"}},{"component":"root","name":"billing-dashboard-root","slot":"billing-dashboard-slot"},{"name":"billing-patient-summary","component":"billingPatientSummary","slot":"patient-chart-billing-dashboard-slot","order":10,"meta":{"columnSpan":4}},{"name":"visit-bills-panel","component":"visitBillsPanel","slot":"visit-summary-panels","meta":{"title":"Bills"}},{"name":"billing-summary-dashboard-link","component":"billingSummaryDashboardLink","slot":"patient-chart-dashboard-slot","order":11,"meta":{"columns":1,"columnSpan":1,"slot":"patient-chart-billing-dashboard-slot","path":"billing-history"}},{"name":"billable-services-app-menu-item","component":"billableServicesAppMenuItem","slot":"app-menu-item-slot","meta":{"name":"Billable Services"}},{"name":"billing-checkin-form","slot":"extra-visit-attribute-slot","component":"billingCheckInForm"},{"slot":"system-admin-page-card-link-slot","component":"billableServicesCardLink","name":"billable-services-admin-card-link"},{"name":"patient-banner-billing-tags","component":"visitAttributeTags","slot":"patient-banner-tags-slot","order":2},{"name":"patient-banner-payment-status-tag","component":"patientPaymentStatusTag","slot":"patient-banner-tags-slot","order":3},{"name":"billable-services-left-panel-link","component":"billableServicesLeftPanelLink","slot":"billable-services-left-panel-slot","order":0},{"name":"billing-settings-left-panel-menu","component":"billingSettingsLeftPanelMenu","slot":"billable-services-left-panel-slot","order":1},{"name":"discount-requests-left-panel-link","component":"discountRequestsLeftPanelLink","slot":"billable-services-left-panel-slot","order":2},{"name":"refund-requests-left-panel-link","component":"refundRequestsLeftPanelLink","slot":"billable-services-left-panel-slot","order":3}],"modals":[{"name":"add-cash-point-modal","component":"addCashPointModal"},{"name":"payment-mode-form-modal","component":"paymentModeFormModal"},{"name":"delete-payment-mode-modal","component":"deletePaymentModeModal"},{"name":"edit-bill-item-modal","component":"editBillLineItemModal"},{"name":"edit-bill-line-item-modal","component":"editBillLineItemModal"},{"name":"require-billing-modal","component":"requirePaymentModal"},{"name":"delete-line-item-confirmation-modal","component":"deleteLineItemConfirmationModal"},{"name":"finalize-bill-confirmation-modal","component":"finalizeBillConfirmationModal"},{"name":"delete-bill-confirmation-modal","component":"deleteBillConfirmationModal"},{"name":"request-discount-modal","component":"requestDiscountModal"},{"name":"review-bill-discounts-modal","component":"reviewBillDiscountsModal"},{"name":"request-refund-modal","component":"requestRefundModal"},{"name":"review-bill-refunds-modal","component":"reviewBillRefundsModal"}],"workspaces2":[{"name":"billing-form-workspace","component":"billingFormWorkspace","window":"billing-form-window"},{"name":"billable-service-form","component":"billableServiceFormWorkspace","window":"billable-service-form-window"}],"workspaceWindows2":[{"name":"billing-form-window","group":"billingFormWorkspaceGroup"},{"name":"billable-service-form-window","group":"billingFormWorkspaceGroup","width":"wider"}],"workspaceGroups2":[{"name":"billingFormWorkspaceGroup","overlay":false}],"version":"1.2.1-pre.1879"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"billing":">=2.3.0-0","webservices.rest":">=2.24.0"},"pages":[{"component":"billableServicesHome","route":"billable-services"}],"extensions":[{"component":"billingDashboardLink","name":"billing-dashboard-link","slot":"homepage-dashboard-slot","meta":{"name":"billing","title":"billing","slot":"billing-dashboard-slot"}},{"component":"root","name":"billing-dashboard-root","slot":"billing-dashboard-slot"},{"name":"billing-patient-summary","component":"billingPatientSummary","slot":"patient-chart-billing-dashboard-slot","order":10,"meta":{"columnSpan":4}},{"name":"visit-bills-panel","component":"visitBillsPanel","slot":"visit-summary-panels","meta":{"title":"Bills"}},{"name":"billing-summary-dashboard-link","component":"billingSummaryDashboardLink","slot":"patient-chart-dashboard-slot","order":11,"meta":{"columns":1,"columnSpan":1,"slot":"patient-chart-billing-dashboard-slot","path":"billing-history"}},{"name":"billable-services-app-menu-item","component":"billableServicesAppMenuItem","slot":"app-menu-item-slot","meta":{"name":"Billable Services"}},{"name":"billing-checkin-form","slot":"extra-visit-attribute-slot","component":"billingCheckInForm"},{"slot":"system-admin-page-card-link-slot","component":"billableServicesCardLink","name":"billable-services-admin-card-link"},{"name":"patient-banner-billing-tags","component":"visitAttributeTags","slot":"patient-banner-tags-slot","order":2},{"name":"patient-banner-payment-status-tag","component":"patientPaymentStatusTag","slot":"patient-banner-tags-slot","order":3},{"name":"billable-services-left-panel-link","component":"billableServicesLeftPanelLink","slot":"billable-services-left-panel-slot","order":0},{"name":"billing-settings-left-panel-menu","component":"billingSettingsLeftPanelMenu","slot":"billable-services-left-panel-slot","order":1},{"name":"discount-requests-left-panel-link","component":"discountRequestsLeftPanelLink","slot":"billable-services-left-panel-slot","order":2},{"name":"refund-requests-left-panel-link","component":"refundRequestsLeftPanelLink","slot":"billable-services-left-panel-slot","order":3}],"modals":[{"name":"add-cash-point-modal","component":"addCashPointModal"},{"name":"payment-mode-form-modal","component":"paymentModeFormModal"},{"name":"delete-payment-mode-modal","component":"deletePaymentModeModal"},{"name":"edit-bill-item-modal","component":"editBillLineItemModal"},{"name":"edit-bill-line-item-modal","component":"editBillLineItemModal"},{"name":"require-billing-modal","component":"requirePaymentModal"},{"name":"delete-line-item-confirmation-modal","component":"deleteLineItemConfirmationModal"},{"name":"finalize-bill-confirmation-modal","component":"finalizeBillConfirmationModal"},{"name":"delete-bill-confirmation-modal","component":"deleteBillConfirmationModal"},{"name":"request-discount-modal","component":"requestDiscountModal"},{"name":"review-bill-discounts-modal","component":"reviewBillDiscountsModal"},{"name":"request-refund-modal","component":"requestRefundModal"},{"name":"review-bill-refunds-modal","component":"reviewBillRefundsModal"}],"workspaces2":[{"name":"billing-form-workspace","component":"billingFormWorkspace","window":"billing-form-window"},{"name":"billable-service-form","component":"billableServiceFormWorkspace","window":"billable-service-form-window"}],"workspaceWindows2":[{"name":"billing-form-window","group":"billingFormWorkspaceGroup"},{"name":"billable-service-form-window","group":"billingFormWorkspaceGroup","width":"wider"}],"workspaceGroups2":[{"name":"billingFormWorkspaceGroup","overlay":false}],"version":"1.3.0"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-billing-app",
3
- "version": "1.2.1-pre.1879",
3
+ "version": "1.3.0",
4
4
  "description": "O3 frontend module for handling billing concerns in healthcare settings",
5
5
  "browser": "dist/openmrs-esm-billing-app.js",
6
6
  "main": "src/index.ts",
@@ -106,6 +106,5 @@
106
106
  "*.{ts,tsx}": "eslint --cache --fix --max-warnings 0",
107
107
  "*.{css,scss,ts,tsx}": "prettier --write --list-different"
108
108
  },
109
- "packageManager": "yarn@4.10.3",
110
- "stableVersion": "1.2.0"
109
+ "packageManager": "yarn@4.10.3"
111
110
  }
@@ -1,4 +1,4 @@
1
- import useSWR, { mutate } from 'swr';
1
+ import useSWR from 'swr';
2
2
  import { type OpenmrsResource, openmrsFetch, restBaseUrl, useOpenmrsFetchAll, useConfig } from '@openmrs/esm-framework';
3
3
  import { apiBasePath } from '../constants';
4
4
  import type {
@@ -92,9 +92,6 @@ export const createBillableService = async (payload: CreateBillableServicePayloa
92
92
  },
93
93
  });
94
94
 
95
- // Revalidate the billable services cache using the exact URL
96
- await mutate(`${apiBasePath}${BILLABLE_SERVICES_URL}`);
97
-
98
95
  return response;
99
96
  };
100
97
 
@@ -108,9 +105,6 @@ export const updateBillableService = async (uuid: string, payload: UpdateBillabl
108
105
  },
109
106
  });
110
107
 
111
- // Revalidate the billable services cache using the exact URL
112
- await mutate(`${apiBasePath}${BILLABLE_SERVICES_URL}`);
113
-
114
108
  return response;
115
109
  };
116
110
 
@@ -40,6 +40,7 @@ interface FilterableTableHeaderProps {
40
40
  layout: LayoutType;
41
41
  handleSearch: (e: React.ChangeEvent<HTMLInputElement>) => void;
42
42
  isValidating: boolean;
43
+ launchBillableServiceForm: () => void;
43
44
  responsiveSize: 'sm' | 'md' | 'lg';
44
45
  t: (key: string, fallback: string) => string;
45
46
  }
@@ -78,8 +79,10 @@ const BillableServices = () => {
78
79
  ];
79
80
 
80
81
  const launchBillableServiceForm = useCallback(() => {
81
- launchWorkspace2('billable-service-form');
82
- }, []);
82
+ launchWorkspace2('billable-service-form', {
83
+ onWorkspaceClose: mutate,
84
+ });
85
+ }, [mutate]);
83
86
 
84
87
  const searchResults: BillableService[] = useMemo(() => {
85
88
  const flatBillableServices = Array.isArray(billableServices) ? billableServices.flat() : billableServices;
@@ -163,6 +166,7 @@ const BillableServices = () => {
163
166
  <FilterableTableHeader
164
167
  handleSearch={handleSearch}
165
168
  isValidating={isValidating}
169
+ launchBillableServiceForm={launchBillableServiceForm}
166
170
  layout={layout}
167
171
  responsiveSize={responsiveSize}
168
172
  t={t}
@@ -253,7 +257,14 @@ const BillableServices = () => {
253
257
  );
254
258
  };
255
259
 
256
- function FilterableTableHeader({ layout, handleSearch, isValidating, responsiveSize, t }: FilterableTableHeaderProps) {
260
+ function FilterableTableHeader({
261
+ layout,
262
+ handleSearch,
263
+ isValidating,
264
+ launchBillableServiceForm,
265
+ responsiveSize,
266
+ t,
267
+ }: FilterableTableHeaderProps) {
257
268
  return (
258
269
  <>
259
270
  <div className={styles.headerContainer}>
@@ -279,9 +290,7 @@ function FilterableTableHeader({ layout, handleSearch, isValidating, responsiveS
279
290
  size={responsiveSize}
280
291
  kind="primary"
281
292
  renderIcon={(props) => <ArrowRight size={16} {...props} />}
282
- onClick={() => {
283
- launchWorkspace2('billable-service-form', {});
284
- }}
293
+ onClick={launchBillableServiceForm}
285
294
  iconDescription={t('addNewBillableService', 'Add new billable service')}>
286
295
  {t('addNewService', 'Add new service')}
287
296
  </Button>
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { describe, expect, type Mock, it, vi } from 'vitest';
3
3
  import { render, screen } from '@testing-library/react';
4
4
  import userEvent from '@testing-library/user-event';
5
+ import { launchWorkspace2 } from '@openmrs/esm-framework';
5
6
  import BillableServices from './billable-services.component';
6
7
  import { useBillableServices } from './billable-service.resource';
7
8
 
@@ -9,6 +10,8 @@ vi.mock('./billable-service.resource', () => ({
9
10
  useBillableServices: vi.fn(),
10
11
  }));
11
12
 
13
+ const mockLaunchWorkspace2 = launchWorkspace2 as Mock;
14
+
12
15
  describe('BillableService', () => {
13
16
  const mockedUseBillableServices = useBillableServices as Mock;
14
17
 
@@ -135,4 +138,55 @@ describe('BillableService', () => {
135
138
  expect(screen.getByText('No matching services to display')).toBeInTheDocument();
136
139
  expect(screen.getByText('Check the filters above')).toBeInTheDocument();
137
140
  });
141
+
142
+ it('passes mutate as onWorkspaceClose when adding a new service so the table refreshes', async () => {
143
+ const mockMutate = vi.fn();
144
+ mockedUseBillableServices.mockReturnValue({
145
+ billableServices: [
146
+ {
147
+ uuid: '1',
148
+ name: 'Service 1',
149
+ shortName: 'S1',
150
+ serviceType: { display: 'Type 1' },
151
+ serviceStatus: 'ACTIVE',
152
+ servicePrices: [{ name: 'Price 1', price: 100 }],
153
+ },
154
+ ],
155
+ isLoading: false,
156
+ isValidating: false,
157
+ error: null,
158
+ mutate: mockMutate,
159
+ });
160
+
161
+ const user = userEvent.setup();
162
+ render(<BillableServices />);
163
+
164
+ await user.click(screen.getByRole('button', { name: /add new service/i }));
165
+
166
+ expect(mockLaunchWorkspace2).toHaveBeenCalledWith(
167
+ 'billable-service-form',
168
+ expect.objectContaining({ onWorkspaceClose: mockMutate }),
169
+ );
170
+ });
171
+
172
+ it('passes mutate as onWorkspaceClose when adding the first service from the empty state', async () => {
173
+ const mockMutate = vi.fn();
174
+ mockedUseBillableServices.mockReturnValue({
175
+ billableServices: [],
176
+ isLoading: false,
177
+ isValidating: false,
178
+ error: null,
179
+ mutate: mockMutate,
180
+ });
181
+
182
+ const user = userEvent.setup();
183
+ render(<BillableServices />);
184
+
185
+ await user.click(screen.getByRole('button', { name: /record.*billable services/i }));
186
+
187
+ expect(mockLaunchWorkspace2).toHaveBeenCalledWith(
188
+ 'billable-service-form',
189
+ expect.objectContaining({ onWorkspaceClose: mockMutate }),
190
+ );
191
+ });
138
192
  });