@openmrs/esm-billing-app 1.1.1 → 1.1.2-pre.1
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/.turbo/cache/53e233a916ffe7d2-meta.json +1 -0
- package/.turbo/cache/53e233a916ffe7d2.tar.zst +0 -0
- package/.turbo/turbo-build.log +44 -0
- package/__mocks__/bills.mock.ts +6 -5
- package/dist/1119.js +1 -1
- package/dist/1197.js +1 -1
- package/dist/1435.js +1 -0
- package/dist/1435.js.map +1 -0
- package/dist/1807.js +1 -0
- package/dist/1807.js.map +1 -0
- package/dist/2146.js +1 -1
- package/dist/2177.js +1 -1
- package/dist/2177.js.map +1 -1
- package/dist/2690.js +1 -1
- package/dist/2704.js +1 -0
- package/dist/2704.js.map +1 -0
- package/dist/3002.js +1 -0
- package/dist/3002.js.map +1 -0
- package/dist/3041.js +1 -1
- package/dist/3041.js.map +1 -1
- package/dist/3099.js +1 -1
- package/dist/3184.js +1 -1
- package/dist/3184.js.map +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 -1
- package/dist/4225.js.map +1 -1
- package/dist/4300.js +1 -1
- package/dist/4335.js +1 -1
- package/dist/439.js +1 -1
- package/dist/4618.js +1 -1
- package/dist/4652.js +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 -1
- package/dist/5422.js.map +1 -1
- package/dist/5442.js +1 -1
- package/dist/5661.js +1 -1
- package/dist/6022.js +1 -1
- package/dist/6404.js +1 -0
- package/dist/6404.js.map +1 -0
- package/dist/6468.js +1 -1
- package/dist/6540.js +1 -1
- package/dist/6540.js.map +1 -1
- package/dist/6589.js +1 -1
- package/dist/6606.js +1 -1
- package/dist/6606.js.map +1 -1
- package/dist/6679.js +1 -1
- package/dist/6792.js +1 -0
- package/dist/6792.js.map +1 -0
- 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/7255.js +1 -1
- package/dist/7255.js.map +1 -1
- package/dist/7617.js +1 -1
- package/dist/795.js +1 -1
- package/dist/8163.js +1 -1
- package/dist/8341.js +2 -0
- package/dist/{1907.js.LICENSE.txt → 8341.js.LICENSE.txt} +0 -15
- package/dist/8341.js.map +1 -0
- package/dist/8349.js +1 -1
- package/dist/8371.js +1 -1
- package/dist/8421.js +1 -0
- package/dist/8421.js.map +1 -0
- package/dist/8618.js +1 -1
- package/dist/890.js +1 -1
- package/dist/9214.js +1 -1
- 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.LICENSE.txt +0 -15
- 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 +284 -259
- package/dist/openmrs-esm-billing-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/e2e/commands/patient-operations.ts +1 -1
- package/e2e/pages/billing-dashboard-page.ts +3 -1
- package/e2e/pages/billing-form-page.ts +5 -0
- package/e2e/pages/invoice-page.ts +10 -0
- package/e2e/specs/billing-dashboard.spec.ts +126 -3
- package/e2e/specs/billing-patient-chart.spec.ts +95 -9
- package/package.json +3 -6
- package/src/bill-history/bill-action-menu.component.tsx +41 -0
- package/src/bill-history/bill-action-menu.scss +3 -0
- package/src/bill-history/bill-history.component.tsx +15 -5
- package/src/bill-history/bill-history.scss +0 -1
- package/src/bill-history/bill-history.test.tsx +78 -1
- package/src/bill-item-actions/edit-bill-item.modal.tsx +1 -1
- package/src/bill-item-actions/edit-bill-item.test.tsx +40 -0
- package/src/billable-services/bill-waiver/bill-waiver.component.tsx +3 -1
- package/src/billing-dashboard/billing-dashboard.component.tsx +3 -16
- package/src/billing-form/billing-checkin-form.component.tsx +116 -57
- package/src/billing-form/billing-checkin-form.scss +26 -2
- package/src/billing-form/billing-checkin-form.test.tsx +51 -1
- package/src/billing-form/billing-form.resource.test.ts +87 -0
- package/src/billing-form/billing-form.resource.ts +33 -0
- package/src/billing-form/billing-form.scss +54 -7
- package/src/billing-form/billing-form.test.tsx +547 -0
- package/src/billing-form/billing-form.workspace.tsx +150 -45
- package/src/billing-form/visit-attributes/visit-attributes-form.component.tsx +25 -2
- package/src/billing-form/visit-attributes/visit-attributes-form.scss +29 -0
- package/src/billing-header/billing-header.component.tsx +1 -34
- package/src/billing-header/billing-header.scss +0 -50
- package/src/billing.resource.test.ts +11 -11
- package/src/billing.resource.ts +42 -12
- package/src/bills-table/bills-table.component.tsx +16 -12
- package/src/bills-table/bills-table.test.tsx +84 -7
- package/src/index.ts +5 -0
- package/src/invoice/invoice.component.tsx +46 -16
- package/src/invoice/invoice.scss +9 -8
- package/src/invoice/invoice.test.tsx +128 -7
- package/src/invoice/line-item-action-menu.component.tsx +2 -2
- package/src/invoice/payments/payments.component.tsx +2 -2
- package/src/invoice/payments/payments.test.tsx +31 -2
- package/src/metrics-cards/metrics.resource.ts +3 -4
- package/src/modal/finalize-bill-confirmation.modal.test.tsx +209 -0
- package/src/modal/finalize-bill-confirmation.modal.tsx +86 -0
- package/src/modal/require-payment.modal.tsx +2 -1
- package/src/routes.json +4 -0
- package/src/types/index.ts +10 -1
- package/tools/setup-tests.ts +7 -6
- package/translations/am.json +28 -0
- package/translations/ar.json +28 -0
- package/translations/ar_SY.json +28 -0
- package/translations/bn.json +28 -0
- package/translations/cs.json +28 -0
- package/translations/de.json +266 -238
- package/translations/en.json +29 -0
- package/translations/en_US.json +28 -0
- package/translations/es.json +28 -0
- package/translations/es_MX.json +28 -0
- package/translations/fr.json +28 -0
- package/translations/he.json +28 -0
- package/translations/hi.json +28 -0
- package/translations/hi_IN.json +28 -0
- package/translations/id.json +28 -0
- package/translations/it.json +28 -0
- package/translations/ka.json +28 -0
- package/translations/km.json +28 -0
- package/translations/ku.json +28 -0
- package/translations/ky.json +28 -0
- package/translations/lg.json +28 -0
- package/translations/ne.json +28 -0
- package/translations/pl.json +28 -0
- package/translations/pt.json +28 -0
- package/translations/pt_BR.json +28 -0
- package/translations/qu.json +28 -0
- package/translations/ro_RO.json +28 -0
- package/translations/ru_RU.json +28 -0
- package/translations/si.json +28 -0
- package/translations/sq.json +28 -0
- package/translations/sw.json +28 -0
- package/translations/sw_KE.json +28 -0
- package/translations/tr.json +28 -0
- package/translations/tr_TR.json +28 -0
- package/translations/uk.json +28 -0
- package/translations/uz.json +28 -0
- package/translations/uz@Latn.json +28 -0
- package/translations/uz_UZ.json +28 -0
- package/translations/vi.json +28 -0
- package/translations/zh.json +268 -240
- package/translations/zh_CN.json +30 -2
- package/translations/zh_TW.json +28 -0
- package/turbo.json +29 -0
- package/dist/1537.js +0 -1
- package/dist/1537.js.map +0 -1
- package/dist/1907.js +0 -2
- package/dist/1907.js.map +0 -1
- package/dist/1981.js +0 -1
- package/dist/1981.js.map +0 -1
- package/dist/2820.js +0 -1
- package/dist/2820.js.map +0 -1
- package/dist/8025.js +0 -1
- package/dist/8025.js.map +0 -1
- package/dist/9727.js +0 -2
- package/dist/9727.js.LICENSE.txt +0 -14
- package/dist/9727.js.map +0 -1
- package/dist/9756.js +0 -1
- package/dist/9756.js.map +0 -1
- package/src/hooks/selectedDateContext.ts +0 -10
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { renderHook } from '@testing-library/react';
|
|
2
|
+
import useSWR from 'swr';
|
|
3
|
+
import { useLastVisitInfo } from './billing-form.resource';
|
|
4
|
+
|
|
5
|
+
jest.mock('swr');
|
|
6
|
+
const mockUseSWR = jest.mocked(useSWR);
|
|
7
|
+
|
|
8
|
+
// Pin "now" so diffDays calculations are deterministic
|
|
9
|
+
const FIXED_NOW = new Date('2026-01-10T12:00:00Z').getTime();
|
|
10
|
+
|
|
11
|
+
describe('useLastVisitInfo', () => {
|
|
12
|
+
beforeAll(() => {
|
|
13
|
+
jest.useFakeTimers();
|
|
14
|
+
jest.setSystemTime(FIXED_NOW);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
afterAll(() => {
|
|
18
|
+
jest.useRealTimers();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('returns null lastVisitInfo when there is no visit data yet', () => {
|
|
22
|
+
mockUseSWR.mockReturnValue({ data: undefined, isLoading: false, error: undefined } as any);
|
|
23
|
+
const { result } = renderHook(() => useLastVisitInfo('patient-uuid'));
|
|
24
|
+
expect(result.current.lastVisitInfo).toBeNull();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('returns null lastVisitInfo when the visits list is empty', () => {
|
|
28
|
+
mockUseSWR.mockReturnValue({ data: { data: { results: [] } }, isLoading: false, error: undefined } as any);
|
|
29
|
+
const { result } = renderHook(() => useLastVisitInfo('patient-uuid'));
|
|
30
|
+
expect(result.current.lastVisitInfo).toBeNull();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('forwards isLoading and error from SWR', () => {
|
|
34
|
+
const error = new Error('Network error');
|
|
35
|
+
mockUseSWR.mockReturnValue({ data: undefined, isLoading: true, error } as any);
|
|
36
|
+
const { result } = renderHook(() => useLastVisitInfo('patient-uuid'));
|
|
37
|
+
expect(result.current.isLoading).toBe(true);
|
|
38
|
+
expect(result.current.error).toBe(error);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('returns correct visit info for a visit 2 days ago', () => {
|
|
42
|
+
const twoDaysAgo = new Date(FIXED_NOW - 2 * 24 * 60 * 60 * 1000).toISOString();
|
|
43
|
+
mockUseSWR.mockReturnValue({
|
|
44
|
+
data: {
|
|
45
|
+
data: {
|
|
46
|
+
results: [
|
|
47
|
+
{
|
|
48
|
+
startDatetime: twoDaysAgo,
|
|
49
|
+
visitType: { display: 'Outpatient' },
|
|
50
|
+
location: { display: 'Main Clinic' },
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
isLoading: false,
|
|
56
|
+
error: undefined,
|
|
57
|
+
} as any);
|
|
58
|
+
const { result } = renderHook(() => useLastVisitInfo('patient-uuid'));
|
|
59
|
+
expect(result.current.lastVisitInfo).toEqual({ diffDays: 2, type: 'Outpatient', location: 'Main Clinic' });
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('returns diffDays of 1 for a visit exactly 1 day ago', () => {
|
|
63
|
+
const oneDayAgo = new Date(FIXED_NOW - 1 * 24 * 60 * 60 * 1000).toISOString();
|
|
64
|
+
mockUseSWR.mockReturnValue({
|
|
65
|
+
data: {
|
|
66
|
+
data: {
|
|
67
|
+
results: [{ startDatetime: oneDayAgo, visitType: { display: 'Inpatient' }, location: { display: 'Ward A' } }],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
isLoading: false,
|
|
71
|
+
error: undefined,
|
|
72
|
+
} as any);
|
|
73
|
+
const { result } = renderHook(() => useLastVisitInfo('patient-uuid'));
|
|
74
|
+
expect(result.current.lastVisitInfo?.diffDays).toBe(1);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('falls back to empty strings when visitType and location are absent', () => {
|
|
78
|
+
const oneDayAgo = new Date(FIXED_NOW - 1 * 24 * 60 * 60 * 1000).toISOString();
|
|
79
|
+
mockUseSWR.mockReturnValue({
|
|
80
|
+
data: { data: { results: [{ startDatetime: oneDayAgo, visitType: null, location: null }] } },
|
|
81
|
+
isLoading: false,
|
|
82
|
+
error: undefined,
|
|
83
|
+
} as any);
|
|
84
|
+
const { result } = renderHook(() => useLastVisitInfo('patient-uuid'));
|
|
85
|
+
expect(result.current.lastVisitInfo).toEqual({ diffDays: 1, type: '', location: '' });
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -1,7 +1,40 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
1
2
|
import useSWR from 'swr';
|
|
2
3
|
import { type OpenmrsResource, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
3
4
|
import { apiBasePath } from '../constants';
|
|
4
5
|
|
|
6
|
+
type LastVisitInfo = {
|
|
7
|
+
diffDays: number;
|
|
8
|
+
type: string;
|
|
9
|
+
location: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const useLastVisitInfo = (
|
|
13
|
+
patientUuid: string,
|
|
14
|
+
): { lastVisitInfo: LastVisitInfo | null; isLoading: boolean; error: any } => {
|
|
15
|
+
const url = `${restBaseUrl}/visit?patient=${patientUuid}&v=default&limit=1&sort=desc:startDatetime`;
|
|
16
|
+
const { data, isLoading, error } = useSWR<{ data: { results: Array<any> } }>(patientUuid ? url : null, openmrsFetch);
|
|
17
|
+
|
|
18
|
+
const lastVisitInfo = useMemo((): LastVisitInfo | null => {
|
|
19
|
+
const results = data?.data?.results;
|
|
20
|
+
if (!results?.length) return null;
|
|
21
|
+
|
|
22
|
+
const visit = results[0];
|
|
23
|
+
const visitDate = new Date(visit.startDatetime);
|
|
24
|
+
if (isNaN(visitDate.getTime())) return null;
|
|
25
|
+
const diffTime = Math.abs(Date.now() - visitDate.getTime());
|
|
26
|
+
const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24));
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
diffDays,
|
|
30
|
+
type: visit.visitType?.display ?? '',
|
|
31
|
+
location: visit.location?.display ?? '',
|
|
32
|
+
};
|
|
33
|
+
}, [data]);
|
|
34
|
+
|
|
35
|
+
return { lastVisitInfo, isLoading, error };
|
|
36
|
+
};
|
|
37
|
+
|
|
5
38
|
export const useBillableItems = () => {
|
|
6
39
|
const url = `${apiBasePath}billableService?v=custom:(uuid,name,shortName,serviceStatus,serviceType:(display),servicePrices:(uuid,name,price,paymentMode))`;
|
|
7
40
|
const { data, isLoading, error } = useSWR<{ data: { results: Array<OpenmrsResource> } }>(url, openmrsFetch);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
@use '@carbon/layout';
|
|
2
|
+
@use '@carbon/type';
|
|
2
3
|
@use '@openmrs/esm-styleguide/src/vars' as *;
|
|
3
4
|
|
|
4
5
|
.tablet {
|
|
@@ -89,15 +90,61 @@
|
|
|
89
90
|
margin-top: layout.$spacing-05;
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
.existingItemsContainer {
|
|
94
|
+
padding: layout.$spacing-05;
|
|
95
|
+
background-color: $ui-01;
|
|
96
|
+
border: 1px solid $ui-03;
|
|
97
|
+
border-radius: layout.$spacing-02;
|
|
98
|
+
|
|
99
|
+
.existingItemRow {
|
|
100
|
+
display: flex;
|
|
101
|
+
justify-content: space-between;
|
|
102
|
+
align-items: center;
|
|
103
|
+
padding: layout.$spacing-03 0;
|
|
104
|
+
border-bottom: 1px solid $ui-03;
|
|
105
|
+
|
|
106
|
+
&:last-of-type {
|
|
107
|
+
border-bottom: none;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.existingItemName {
|
|
111
|
+
@include type.type-style('body-compact-01');
|
|
112
|
+
flex: 1;
|
|
113
|
+
color: $text-02;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.existingItemDetail {
|
|
117
|
+
@include type.type-style('body-compact-01');
|
|
118
|
+
flex: 0 0 auto;
|
|
119
|
+
color: $text-02;
|
|
120
|
+
margin: 0 layout.$spacing-05;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.existingItemTotal {
|
|
124
|
+
@include type.type-style('heading-compact-01');
|
|
125
|
+
flex: 0 0 auto;
|
|
126
|
+
color: $text-02;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.existingItemsSubtotal {
|
|
131
|
+
@include type.type-style('body-compact-01');
|
|
132
|
+
text-align: right;
|
|
133
|
+
padding-top: layout.$spacing-04;
|
|
134
|
+
border-top: 1px solid $ui-03;
|
|
135
|
+
margin-top: layout.$spacing-03;
|
|
97
136
|
color: $text-02;
|
|
98
|
-
font-size: 1rem;
|
|
99
|
-
font-weight: 600;
|
|
100
137
|
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.sectionHeading {
|
|
141
|
+
@include type.type-style('heading-compact-02');
|
|
142
|
+
margin-bottom: layout.$spacing-04;
|
|
143
|
+
color: $text-02;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.selectedItemsContainer {
|
|
147
|
+
margin-top: layout.$spacing-05;
|
|
101
148
|
|
|
102
149
|
.itemCard {
|
|
103
150
|
border: 1px solid $ui-03;
|