@kenyaemr/esm-billing-app 5.4.1-pre.1936 → 5.4.1-pre.1941

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.
Files changed (36) hide show
  1. package/.turbo/turbo-build.log +71 -71
  2. package/dist/22.js +1 -0
  3. package/dist/22.js.map +1 -0
  4. package/dist/300.js +1 -1
  5. package/dist/423.js +1 -0
  6. package/dist/423.js.map +1 -0
  7. package/dist/917.js +2 -0
  8. package/dist/917.js.map +1 -0
  9. package/dist/kenyaemr-esm-billing-app.js +1 -1
  10. package/dist/kenyaemr-esm-billing-app.js.buildmanifest.json +84 -84
  11. package/dist/kenyaemr-esm-billing-app.js.map +1 -1
  12. package/dist/main.js +2 -2
  13. package/dist/main.js.map +1 -1
  14. package/dist/routes.json +1 -1
  15. package/package.json +1 -1
  16. package/src/billable-services/billiable-item/order-actions/components/base-order-button.component.tsx +42 -0
  17. package/src/billable-services/billiable-item/order-actions/components/lab-order-button.component.tsx +51 -0
  18. package/src/billable-services/billiable-item/order-actions/components/medication-order-button.component.tsx +84 -0
  19. package/src/billable-services/billiable-item/order-actions/components/order-action-button.component.tsx +29 -0
  20. package/src/billable-services/billiable-item/order-actions/hooks/useBillStatus.ts +12 -0
  21. package/src/billable-services/billiable-item/order-actions/hooks/useLabOrderAction.ts +27 -0
  22. package/src/billable-services/billiable-item/order-actions/hooks/useMedicationOrderAction.ts +106 -0
  23. package/src/billable-services/billiable-item/order-actions/hooks/useModalHandler.ts +66 -0
  24. package/src/billable-services/billiable-item/order-actions/styles/order-action.scss +0 -0
  25. package/src/index.ts +2 -2
  26. package/src/routes.json +3 -3
  27. package/translations/en.json +2 -5
  28. package/dist/138.js +0 -2
  29. package/dist/138.js.map +0 -1
  30. package/dist/308.js +0 -1
  31. package/dist/308.js.map +0 -1
  32. package/dist/614.js +0 -1
  33. package/dist/614.js.map +0 -1
  34. package/src/billable-services/billiable-item/test-order/test-order-action.component.tsx +0 -134
  35. package/src/billable-services/billiable-item/test-order/test-order-action.test.tsx +0 -178
  36. /package/dist/{138.js.LICENSE.txt → 917.js.LICENSE.txt} +0 -0
@@ -1,178 +0,0 @@
1
- import React from 'react';
2
- import { screen, render, act } from '@testing-library/react';
3
- import TestOrderAction from './test-order-action.component';
4
- import { Order } from '@openmrs/esm-patient-common-lib';
5
- import * as resource from './test-order-action.resource';
6
- import userEvent from '@testing-library/user-event';
7
- import { launchWorkspace, showModal } from '@openmrs/esm-framework';
8
- import { createMedicationDispenseProps } from './dispense.resource';
9
- import { useStockItemQuantity } from '../useBillableItem';
10
-
11
- jest.mock('./test-order-action.resource');
12
- jest.mock('../useBillableItem', () => ({
13
- useStockItemQuantity: jest.fn(),
14
- }));
15
- jest.mock('./dispense.resource', () => ({
16
- createMedicationDispenseProps: jest.fn(() => ({
17
- whenHandedOver: '2025-02-19T12:35:53+00:00',
18
- })),
19
- }));
20
-
21
- const mockTestProps = {
22
- order: { uuid: '123', patient: { uuid: '456' } } as Order,
23
- patientUuid: 'patient-uuid-123',
24
- encounterUuid: 'encounter-uuid-456',
25
- medicationRequestBundle: {
26
- request: {
27
- id: 'med-request-789',
28
- medicationReference: { reference: 'Medication/med-123' },
29
- medicationCodeableConcept: { coding: [{ code: 'med-code-123' }] },
30
- subject: { reference: 'Patient/patient-uuid-123' },
31
- dispenseRequest: {
32
- quantity: {
33
- value: 30,
34
- code: 'TAB',
35
- unit: 'tablets',
36
- system: 'http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm',
37
- },
38
- },
39
- dosageInstruction: [
40
- {
41
- text: 'Take 1 tablet daily',
42
- timing: { code: 'daily' },
43
- route: { coding: [{ code: 'PO' }] },
44
- doseAndRate: [
45
- {
46
- doseQuantity: {
47
- value: 1,
48
- code: 'TAB',
49
- unit: 'tablet',
50
- },
51
- },
52
- ],
53
- additionalInstruction: [{ text: 'with food' }],
54
- },
55
- ],
56
- },
57
- },
58
- quantityRemaining: 30,
59
- session: {
60
- currentProvider: {
61
- uuid: 'provider-uuid-123',
62
- },
63
- sessionLocation: {
64
- uuid: 'location-uuid-456',
65
- },
66
- },
67
- providers: [
68
- {
69
- uuid: 'provider-uuid-123',
70
- display: 'Dr. Test Provider',
71
- },
72
- ],
73
- closeable: true,
74
- } as Record<string, unknown>;
75
-
76
- const testProps = {
77
- order: { uuid: '123', patient: { uuid: '456' } } as Order,
78
- };
79
-
80
- describe('TestOrderAction', () => {
81
- beforeEach(() => {
82
- jest.resetAllMocks();
83
- jest.clearAllMocks();
84
- });
85
-
86
- test('should render loading when isLoading is true', () => {
87
- jest.spyOn(resource, 'useTestOrderBillStatus').mockReturnValue({ isLoading: true, hasPendingPayment: false });
88
- jest.spyOn(resource, 'useOrderBill').mockReturnValue({
89
- itemHasBill: [],
90
- });
91
- (useStockItemQuantity as jest.Mock).mockReturnValue({
92
- stockItemQuantity: 5,
93
- stockItemUuid: 'some-uuid',
94
- isLoading: false,
95
- error: undefined,
96
- });
97
- render(<TestOrderAction {...testProps} />);
98
- expect(screen.getByText('Verifying bill status...')).toBeInTheDocument();
99
- });
100
-
101
- test("should display `Unsettled bill for test` when there's a pending payment", () => {
102
- jest.spyOn(resource, 'useTestOrderBillStatus').mockReturnValueOnce({ isLoading: false, hasPendingPayment: true });
103
- jest.spyOn(resource, 'useOrderBill').mockReturnValueOnce({
104
- itemHasBill: [],
105
- });
106
- (useStockItemQuantity as jest.Mock).mockReturnValueOnce({
107
- stockItemQuantity: 5,
108
- stockItemUuid: 'some-uuid',
109
- isLoading: false,
110
- error: undefined,
111
- });
112
- render(<TestOrderAction {...testProps} />);
113
- expect(screen.getByText('Unsettled bill')).toBeInTheDocument();
114
- });
115
-
116
- test("should display `Pick Lab Request` when there's no pending payment", async () => {
117
- const user = userEvent.setup();
118
- jest.spyOn(resource, 'useTestOrderBillStatus').mockReturnValueOnce({ isLoading: false, hasPendingPayment: false });
119
- jest.spyOn(resource, 'useOrderBill').mockReturnValueOnce({
120
- itemHasBill: [],
121
- });
122
- (useStockItemQuantity as jest.Mock).mockReturnValueOnce({
123
- stockItemQuantity: 5,
124
- stockItemUuid: 'some-uuid',
125
- isLoading: false,
126
- error: undefined,
127
- });
128
- render(<TestOrderAction {...testProps} />);
129
- const pickLabRequestMenuItem = screen.getByText('Pick Lab Request');
130
- await act(async () => {
131
- await user.click(pickLabRequestMenuItem);
132
- });
133
-
134
- expect(screen.queryByText('Unsettled bill.')).not.toBeInTheDocument();
135
- expect(showModal).toBeCalledWith('pickup-lab-request-modal', {
136
- closeModal: expect.any(Function),
137
- order: { patient: { uuid: '456' }, uuid: '123' },
138
- });
139
- });
140
-
141
- test('should not render the dispense form if closeable is false', () => {
142
- jest.spyOn(resource, 'useTestOrderBillStatus').mockReturnValue({ isLoading: false, hasPendingPayment: false });
143
- jest.spyOn(resource, 'useOrderBill').mockReturnValue({
144
- itemHasBill: [],
145
- });
146
- (useStockItemQuantity as jest.Mock).mockReturnValue({
147
- stockItemQuantity: 5,
148
- stockItemUuid: 'some-uuid',
149
- isLoading: false,
150
- error: undefined,
151
- });
152
- render(<TestOrderAction {...testProps} closeable={false} />);
153
- expect(screen.queryByText('Dispense')).not.toBeInTheDocument();
154
- });
155
-
156
- test('should launch the dispense form when dispense order is part of props', async () => {
157
- const user = userEvent.setup();
158
- jest.spyOn(resource, 'useTestOrderBillStatus').mockReturnValueOnce({ isLoading: false, hasPendingPayment: false });
159
- jest.spyOn(resource, 'useOrderBill').mockReturnValueOnce({
160
- itemHasBill: [],
161
- });
162
- (useStockItemQuantity as jest.Mock).mockReturnValueOnce({
163
- stockItemQuantity: 5,
164
- stockItemUuid: 'some-uuid',
165
- isLoading: false,
166
- error: undefined,
167
- });
168
- render(<TestOrderAction {...mockTestProps} />);
169
- const dispenseButton = screen.getByRole('button', { name: 'Dispense' });
170
- expect(dispenseButton).toBeInTheDocument();
171
-
172
- await act(async () => {
173
- await user.click(dispenseButton);
174
- });
175
- const dispenseFormProps = createMedicationDispenseProps(mockTestProps);
176
- expect(launchWorkspace).toHaveBeenCalledWith('dispense-workspace', dispenseFormProps);
177
- });
178
- });
File without changes