@kenyaemr/esm-etims-app 5.4.5-pre.1109
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/turbo-build.log +6 -0
- package/README.md +3 -0
- package/dist/1067.js +1 -0
- package/dist/1067.js.map +1 -0
- package/dist/1072.js +1 -0
- package/dist/1072.js.map +1 -0
- package/dist/1148.js +1 -0
- package/dist/1148.js.map +1 -0
- package/dist/1278.js +1 -0
- package/dist/1278.js.map +1 -0
- package/dist/1442.js +1 -0
- package/dist/1442.js.map +1 -0
- package/dist/15.js +1 -0
- package/dist/15.js.map +1 -0
- package/dist/1620.js +1 -0
- package/dist/1620.js.map +1 -0
- package/dist/1638.js +1 -0
- package/dist/1638.js.map +1 -0
- package/dist/1789.js +1 -0
- package/dist/1789.js.map +1 -0
- package/dist/1831.js +1 -0
- package/dist/1831.js.map +1 -0
- package/dist/1844.js +1 -0
- package/dist/1844.js.map +1 -0
- package/dist/1946.js +1 -0
- package/dist/1946.js.map +1 -0
- package/dist/2007.js +1 -0
- package/dist/2007.js.map +1 -0
- package/dist/2115.js +1 -0
- package/dist/2115.js.map +1 -0
- package/dist/2131.js +1 -0
- package/dist/2131.js.map +1 -0
- package/dist/2152.js +1 -0
- package/dist/2152.js.map +1 -0
- package/dist/2202.js +1 -0
- package/dist/2202.js.map +1 -0
- package/dist/2394.js +1 -0
- package/dist/2394.js.map +1 -0
- package/dist/2534.js +1 -0
- package/dist/2534.js.map +1 -0
- package/dist/2537.js +1 -0
- package/dist/2537.js.map +1 -0
- package/dist/2556.js +1 -0
- package/dist/2556.js.map +1 -0
- package/dist/2621.js +1 -0
- package/dist/2621.js.map +1 -0
- package/dist/2648.js +1 -0
- package/dist/2648.js.map +1 -0
- package/dist/2795.js +1 -0
- package/dist/2795.js.map +1 -0
- package/dist/2842.js +1 -0
- package/dist/2842.js.map +1 -0
- package/dist/2916.js +1 -0
- package/dist/2916.js.map +1 -0
- package/dist/2924.js +1 -0
- package/dist/2924.js.map +1 -0
- package/dist/2929.js +1 -0
- package/dist/2929.js.map +1 -0
- package/dist/2947.js +1 -0
- package/dist/2947.js.map +1 -0
- package/dist/2971.js +1 -0
- package/dist/2971.js.map +1 -0
- package/dist/3284.js +1 -0
- package/dist/3284.js.map +1 -0
- package/dist/3285.js +1 -0
- package/dist/3285.js.map +1 -0
- package/dist/3335.js +1 -0
- package/dist/3335.js.map +1 -0
- package/dist/335.js +1 -0
- package/dist/335.js.map +1 -0
- package/dist/3378.js +1 -0
- package/dist/3378.js.map +1 -0
- package/dist/338.js +1 -0
- package/dist/338.js.map +1 -0
- package/dist/3504.js +1 -0
- package/dist/3504.js.map +1 -0
- package/dist/3544.js +1 -0
- package/dist/3544.js.map +1 -0
- package/dist/356.js +1 -0
- package/dist/356.js.map +1 -0
- package/dist/3569.js +1 -0
- package/dist/3569.js.map +1 -0
- package/dist/3723.js +1 -0
- package/dist/3723.js.map +1 -0
- package/dist/3745.js +1 -0
- package/dist/3745.js.map +1 -0
- package/dist/3813.js +1 -0
- package/dist/3813.js.map +1 -0
- package/dist/393.js +6 -0
- package/dist/393.js.map +1 -0
- package/dist/3949.js +1 -0
- package/dist/3949.js.map +1 -0
- package/dist/3953.js +1 -0
- package/dist/3953.js.map +1 -0
- package/dist/3989.js +1 -0
- package/dist/3989.js.map +1 -0
- package/dist/4178.js +1 -0
- package/dist/4178.js.map +1 -0
- package/dist/4303.js +1 -0
- package/dist/4303.js.map +1 -0
- package/dist/4308.js +1 -0
- package/dist/4308.js.map +1 -0
- package/dist/4487.js +11 -0
- package/dist/4487.js.map +1 -0
- package/dist/4588.js +1 -0
- package/dist/4588.js.map +1 -0
- package/dist/4637.js +1 -0
- package/dist/4637.js.map +1 -0
- package/dist/466.js +1 -0
- package/dist/466.js.map +1 -0
- package/dist/4817.js +1 -0
- package/dist/4817.js.map +1 -0
- package/dist/4818.js +1 -0
- package/dist/4818.js.map +1 -0
- package/dist/500.js +1 -0
- package/dist/500.js.map +1 -0
- package/dist/5086.js +1 -0
- package/dist/5086.js.map +1 -0
- package/dist/5117.js +1 -0
- package/dist/5117.js.map +1 -0
- package/dist/5159.js +1 -0
- package/dist/5159.js.map +1 -0
- package/dist/5285.js +1 -0
- package/dist/5285.js.map +1 -0
- package/dist/5361.js +1 -0
- package/dist/5361.js.map +1 -0
- package/dist/5366.js +1 -0
- package/dist/5366.js.map +1 -0
- package/dist/5484.js +1 -0
- package/dist/5484.js.map +1 -0
- package/dist/5598.js +1 -0
- package/dist/5598.js.map +1 -0
- package/dist/5676.js +1 -0
- package/dist/5676.js.map +1 -0
- package/dist/5694.js +1 -0
- package/dist/5694.js.map +1 -0
- package/dist/5731.js +5 -0
- package/dist/5731.js.map +1 -0
- package/dist/5743.js +1 -0
- package/dist/5743.js.map +1 -0
- package/dist/5825.js +1 -0
- package/dist/5825.js.map +1 -0
- package/dist/5932.js +1 -0
- package/dist/5932.js.map +1 -0
- package/dist/5941.js +1 -0
- package/dist/5941.js.map +1 -0
- package/dist/5967.js +1 -0
- package/dist/5967.js.map +1 -0
- package/dist/6104.js +1 -0
- package/dist/6104.js.map +1 -0
- package/dist/624.js +1 -0
- package/dist/624.js.map +1 -0
- package/dist/6259.js +1 -0
- package/dist/6259.js.map +1 -0
- package/dist/6273.js +1 -0
- package/dist/6273.js.map +1 -0
- package/dist/6337.js +1 -0
- package/dist/6337.js.map +1 -0
- package/dist/6427.js +1 -0
- package/dist/6427.js.map +1 -0
- package/dist/647.js +1 -0
- package/dist/647.js.map +1 -0
- package/dist/6478.js +7 -0
- package/dist/6478.js.map +1 -0
- package/dist/6508.js +1 -0
- package/dist/6508.js.map +1 -0
- package/dist/6567.js +1 -0
- package/dist/6567.js.map +1 -0
- package/dist/6634.js +1 -0
- package/dist/6634.js.map +1 -0
- package/dist/6868.js +1 -0
- package/dist/6868.js.map +1 -0
- package/dist/689.js +1 -0
- package/dist/689.js.map +1 -0
- package/dist/7022.js +1 -0
- package/dist/7022.js.map +1 -0
- package/dist/7101.js +1 -0
- package/dist/7101.js.map +1 -0
- package/dist/7209.js +1 -0
- package/dist/7209.js.map +1 -0
- package/dist/7293.js +1 -0
- package/dist/7293.js.map +1 -0
- package/dist/7360.js +1 -0
- package/dist/7360.js.map +1 -0
- package/dist/7453.js +1 -0
- package/dist/7453.js.map +1 -0
- package/dist/7478.js +1 -0
- package/dist/7478.js.map +1 -0
- package/dist/7782.js +1 -0
- package/dist/7782.js.map +1 -0
- package/dist/7808.js +1 -0
- package/dist/7808.js.map +1 -0
- package/dist/7876.js +1 -0
- package/dist/7876.js.map +1 -0
- package/dist/8028.js +1 -0
- package/dist/8028.js.map +1 -0
- package/dist/8196.js +1 -0
- package/dist/8196.js.map +1 -0
- package/dist/820.js +1 -0
- package/dist/820.js.map +1 -0
- package/dist/8240.js +1 -0
- package/dist/8240.js.map +1 -0
- package/dist/8458.js +1 -0
- package/dist/8458.js.map +1 -0
- package/dist/8472.js +1 -0
- package/dist/8472.js.map +1 -0
- package/dist/8602.js +1 -0
- package/dist/8602.js.map +1 -0
- package/dist/8607.js +1 -0
- package/dist/8607.js.map +1 -0
- package/dist/8640.js +1 -0
- package/dist/8640.js.map +1 -0
- package/dist/8762.js +1 -0
- package/dist/8762.js.map +1 -0
- package/dist/9060.js +1 -0
- package/dist/9060.js.map +1 -0
- package/dist/9061.js +1 -0
- package/dist/9061.js.map +1 -0
- package/dist/9087.js +1 -0
- package/dist/9087.js.map +1 -0
- package/dist/9168.js +1 -0
- package/dist/9168.js.map +1 -0
- package/dist/9213.js +1 -0
- package/dist/9213.js.map +1 -0
- package/dist/9286.js +1 -0
- package/dist/9286.js.map +1 -0
- package/dist/9425.js +1 -0
- package/dist/9520.js +1 -0
- package/dist/9520.js.map +1 -0
- package/dist/9547.js +1 -0
- package/dist/9547.js.map +1 -0
- package/dist/9612.js +1 -0
- package/dist/9612.js.map +1 -0
- package/dist/9632.js +1 -0
- package/dist/9632.js.map +1 -0
- package/dist/9771.js +1 -0
- package/dist/9771.js.map +1 -0
- package/dist/9774.js +1 -0
- package/dist/9774.js.map +1 -0
- package/dist/9806.js +1 -0
- package/dist/9806.js.map +1 -0
- package/dist/9885.js +1 -0
- package/dist/9885.js.map +1 -0
- package/dist/992.js +1 -0
- package/dist/992.js.map +1 -0
- package/dist/kenyaemr-esm-etims-app.js +3 -0
- package/dist/kenyaemr-esm-etims-app.js.buildmanifest.json +3354 -0
- package/dist/kenyaemr-esm-etims-app.js.map +1 -0
- package/dist/main.js +3 -0
- package/dist/main.js.map +1 -0
- package/dist/routes.json +1 -0
- package/package.json +48 -0
- package/rspack.config.js +1 -0
- package/src/components/header/header.component.tsx +22 -0
- package/src/components/header/header.scss +6 -0
- package/src/components/side-menu/left-panel.component.tsx +22 -0
- package/src/components/side-menu/left-panel.scss +34 -0
- package/src/components/user-menu-link/etims-nav-link.scss +29 -0
- package/src/components/user-menu-link/user-menu-link.component.tsx +25 -0
- package/src/config-schema.ts +1 -0
- package/src/credit-note/etims-credit-note-dashboard.component.tsx +23 -0
- package/src/credit-note/etims-credit-note-dashboard.scss +8 -0
- package/src/credit-note/etims-credit-note-table.component.tsx +284 -0
- package/src/credit-note/etims-credit-note-table.scss +16 -0
- package/src/credit-note/etims-credit-note.resource.ts +96 -0
- package/src/credit-note/etims-credit-note.types.ts +56 -0
- package/src/credit-note/etims-credit-note.workspace.scss +76 -0
- package/src/credit-note/etims-credit-note.workspace.tsx +267 -0
- package/src/declarations.d.ts +2 -0
- package/src/global-properties/etims-global-properties-dashboard.component.tsx +141 -0
- package/src/global-properties/etims-global-properties-dashboard.scss +62 -0
- package/src/global-properties/etims-global-properties-form.workspace.scss +74 -0
- package/src/global-properties/etims-global-properties-form.workspace.tsx +244 -0
- package/src/global-properties/etims-global-properties.resource.ts +60 -0
- package/src/index.ts +100 -0
- package/src/item-mapping/etims-item-mapping-dashboard.component.tsx +29 -0
- package/src/item-mapping/etims-item-mapping-dashboard.scss +42 -0
- package/src/item-mapping/etims-item-mapping-form.fields.tsx +136 -0
- package/src/item-mapping/etims-item-mapping-form.schema.ts +35 -0
- package/src/item-mapping/etims-item-mapping-form.workspace.scss +54 -0
- package/src/item-mapping/etims-item-mapping-form.workspace.tsx +555 -0
- package/src/item-mapping/etims-item-mapping-table.component.tsx +398 -0
- package/src/item-mapping/etims-item-mapping-table.scss +20 -0
- package/src/item-mapping/etims-item-mapping.resource.ts +318 -0
- package/src/item-mapping/etims-item-mapping.types.ts +92 -0
- package/src/item-mapping/register-item-mapping.modal.tsx +113 -0
- package/src/item-mapping/void-item-mapping.modal.tsx +80 -0
- package/src/left-panel-link.component.tsx +39 -0
- package/src/left-panel-link.scss +12 -0
- package/src/reference-data/etims-catalog-table.component.tsx +178 -0
- package/src/reference-data/etims-catalog-table.scss +16 -0
- package/src/reference-data/etims-code-table.component.tsx +87 -0
- package/src/reference-data/etims-item-class-table.component.tsx +86 -0
- package/src/reference-data/etims-reference-data-dashboard.component.tsx +38 -0
- package/src/reference-data/etims-reference-data-dashboard.scss +11 -0
- package/src/reference-data/etims-reference-data.resource.ts +40 -0
- package/src/reference-data/etims-reference-data.types.ts +38 -0
- package/src/reference-data/etims-sync-meta.modal.tsx +62 -0
- package/src/root.component.tsx +38 -0
- package/src/root.scss +11 -0
- package/src/routes.json +117 -0
- package/src/status/etims-status-dashboard.component.tsx +212 -0
- package/src/status/etims-status-dashboard.scss +116 -0
- package/src/status/etims-status.resource.ts +20 -0
- package/src/status/etims-status.types.ts +30 -0
- package/src/transaction/confirm-transaction-action.modal.tsx +113 -0
- package/src/transaction/etims-transaction-dashboard.component.tsx +23 -0
- package/src/transaction/etims-transaction-dashboard.scss +8 -0
- package/src/transaction/etims-transaction-details.workspace.scss +76 -0
- package/src/transaction/etims-transaction-details.workspace.tsx +201 -0
- package/src/transaction/etims-transaction-table.component.tsx +450 -0
- package/src/transaction/etims-transaction-table.scss +20 -0
- package/src/transaction/etims-transaction.resource.ts +180 -0
- package/src/transaction/etims-transaction.types.ts +78 -0
- package/src/transaction/override-reconciliation.modal.scss +7 -0
- package/src/transaction/override-reconciliation.modal.tsx +203 -0
- package/translations/am.json +129 -0
- package/translations/en.json +129 -0
- package/translations/fr.json +130 -0
- package/translations/sw.json +129 -0
- package/tsconfig.json +5 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import React, { useMemo, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
ButtonSet,
|
|
5
|
+
ComboBox,
|
|
6
|
+
Form,
|
|
7
|
+
InlineLoading,
|
|
8
|
+
InlineNotification,
|
|
9
|
+
RadioButton,
|
|
10
|
+
RadioButtonGroup,
|
|
11
|
+
Tag,
|
|
12
|
+
TextArea,
|
|
13
|
+
} from '@carbon/react';
|
|
14
|
+
import {
|
|
15
|
+
showSnackbar,
|
|
16
|
+
useDebounce,
|
|
17
|
+
useLayoutType,
|
|
18
|
+
Workspace2,
|
|
19
|
+
type Workspace2DefinitionProps,
|
|
20
|
+
} from '@openmrs/esm-framework';
|
|
21
|
+
import classNames from 'classnames';
|
|
22
|
+
import { useTranslation } from 'react-i18next';
|
|
23
|
+
import { createEtimsAmendment, hasConfirmedSale, parseLineItemName, useBillSearch } from './etims-credit-note.resource';
|
|
24
|
+
import type { BillLineItem, BillSearchResult, EtimsAmendmentType } from './etims-credit-note.types';
|
|
25
|
+
import styles from './etims-credit-note.workspace.scss';
|
|
26
|
+
|
|
27
|
+
type EtimsCreditNoteWorkspaceProps = {
|
|
28
|
+
bill?: BillSearchResult | null;
|
|
29
|
+
mutateCreditNotes?: () => void;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const billToString = (bill?: BillSearchResult | null) => {
|
|
33
|
+
if (!bill) {
|
|
34
|
+
return '';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const parts = [bill.receiptNumber ?? `#${bill.id ?? ''}`, bill.patient?.display].filter(Boolean);
|
|
38
|
+
return parts.join(' · ');
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const lineItemToString = (lineItem?: BillLineItem | null) => {
|
|
42
|
+
if (!lineItem) {
|
|
43
|
+
return '';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const name = parseLineItemName(lineItem.billableService || lineItem.item) || lineItem.display || lineItem.uuid;
|
|
47
|
+
const quantity = lineItem.quantity ?? 1;
|
|
48
|
+
const price = lineItem.price ?? 0;
|
|
49
|
+
const suffix = `${quantity} × ${price}`;
|
|
50
|
+
return `${name} (${suffix})`;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const EtimsCreditNoteWorkspace: React.FC<Workspace2DefinitionProps<EtimsCreditNoteWorkspaceProps, {}, {}>> = ({
|
|
54
|
+
closeWorkspace,
|
|
55
|
+
workspaceProps,
|
|
56
|
+
}) => {
|
|
57
|
+
const { t } = useTranslation();
|
|
58
|
+
const isTablet = useLayoutType() === 'tablet';
|
|
59
|
+
|
|
60
|
+
const [searchTerm, setSearchTerm] = useState('');
|
|
61
|
+
const debouncedSearchTerm = useDebounce(searchTerm, 300);
|
|
62
|
+
const { bills, isLoading: isSearching } = useBillSearch(debouncedSearchTerm);
|
|
63
|
+
|
|
64
|
+
const [selectedBill, setSelectedBill] = useState<BillSearchResult | null>(workspaceProps?.bill ?? null);
|
|
65
|
+
const [creditType, setCreditType] = useState<EtimsAmendmentType>('FULL_CREDIT');
|
|
66
|
+
const [selectedLineItem, setSelectedLineItem] = useState<BillLineItem | null>(null);
|
|
67
|
+
const [reason, setReason] = useState('');
|
|
68
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
69
|
+
|
|
70
|
+
const mutateCreditNotes = workspaceProps?.mutateCreditNotes;
|
|
71
|
+
const lineItems = useMemo(() => selectedBill?.lineItems ?? [], [selectedBill]);
|
|
72
|
+
const isConfirmedSale = hasConfirmedSale(selectedBill);
|
|
73
|
+
const isPartial = creditType === 'PARTIAL_CREDIT';
|
|
74
|
+
|
|
75
|
+
const mergedBills = useMemo(() => {
|
|
76
|
+
if (!selectedBill || bills.some((bill) => bill.uuid === selectedBill.uuid)) {
|
|
77
|
+
return bills;
|
|
78
|
+
}
|
|
79
|
+
return [selectedBill, ...bills];
|
|
80
|
+
}, [bills, selectedBill]);
|
|
81
|
+
|
|
82
|
+
const canSubmit =
|
|
83
|
+
Boolean(selectedBill) &&
|
|
84
|
+
isConfirmedSale &&
|
|
85
|
+
reason.trim().length > 0 &&
|
|
86
|
+
(!isPartial || Boolean(selectedLineItem)) &&
|
|
87
|
+
!isSubmitting;
|
|
88
|
+
|
|
89
|
+
const handleBillSelect = (bill: BillSearchResult | null) => {
|
|
90
|
+
setSelectedBill(bill);
|
|
91
|
+
setSelectedLineItem(null);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const onSubmit = async (event: React.FormEvent) => {
|
|
95
|
+
event.preventDefault();
|
|
96
|
+
if (!selectedBill || !canSubmit) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
setIsSubmitting(true);
|
|
101
|
+
try {
|
|
102
|
+
const result = await createEtimsAmendment({
|
|
103
|
+
type: creditType,
|
|
104
|
+
billUuid: selectedBill.uuid,
|
|
105
|
+
reason: reason.trim(),
|
|
106
|
+
billLineItemUuid: isPartial ? selectedLineItem?.uuid : undefined,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
showSnackbar({
|
|
110
|
+
kind: 'success',
|
|
111
|
+
title: t('creditNoteEnqueued', 'Credit note enqueued'),
|
|
112
|
+
subtitle: t('creditNoteEnqueuedMessage', 'Credit note for bill {{billId}} is now {{status}}.', {
|
|
113
|
+
billId: result?.billId ?? selectedBill.id ?? '',
|
|
114
|
+
status: result?.status ?? 'PENDING',
|
|
115
|
+
}),
|
|
116
|
+
});
|
|
117
|
+
mutateCreditNotes?.();
|
|
118
|
+
closeWorkspace({ discardUnsavedChanges: true });
|
|
119
|
+
} catch (error) {
|
|
120
|
+
showSnackbar({
|
|
121
|
+
kind: 'error',
|
|
122
|
+
title: t('creditNoteError', 'Unable to create credit note'),
|
|
123
|
+
subtitle: (error as Error)?.message,
|
|
124
|
+
});
|
|
125
|
+
} finally {
|
|
126
|
+
setIsSubmitting(false);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const hasUnsavedChanges = Boolean(selectedBill) || reason.trim().length > 0;
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<Workspace2 title={t('createCreditNote', 'Create credit note')} hasUnsavedChanges={hasUnsavedChanges}>
|
|
134
|
+
<Form onSubmit={onSubmit} className={styles.form}>
|
|
135
|
+
<div className={styles.formContainer}>
|
|
136
|
+
<InlineNotification
|
|
137
|
+
kind="info"
|
|
138
|
+
lowContrast
|
|
139
|
+
hideCloseButton
|
|
140
|
+
title={t('creditNoteInfo', 'Credit note')}
|
|
141
|
+
subtitle={t(
|
|
142
|
+
'creditNoteInfoMessage',
|
|
143
|
+
'Search for the patient whose confirmed eTIMS invoice you want to credit. The scheduler submits the credit note to KRA once it is enqueued.',
|
|
144
|
+
)}
|
|
145
|
+
/>
|
|
146
|
+
|
|
147
|
+
<div className={styles.searchField}>
|
|
148
|
+
<ComboBox<BillSearchResult>
|
|
149
|
+
id="creditNoteBill"
|
|
150
|
+
titleText={t('bill', 'Bill')}
|
|
151
|
+
placeholder={t('searchBillsByPatient', 'Search by patient name or identifier')}
|
|
152
|
+
items={mergedBills}
|
|
153
|
+
itemToString={billToString}
|
|
154
|
+
selectedItem={selectedBill}
|
|
155
|
+
shouldFilterItem={() => true}
|
|
156
|
+
onInputChange={(value) => {
|
|
157
|
+
if (value !== billToString(selectedBill)) {
|
|
158
|
+
setSearchTerm(value);
|
|
159
|
+
}
|
|
160
|
+
}}
|
|
161
|
+
onChange={({ selectedItem }) => handleBillSelect(selectedItem ?? null)}
|
|
162
|
+
/>
|
|
163
|
+
<div className={styles.searchStatus}>
|
|
164
|
+
{isSearching ? <InlineLoading description={t('searching', 'Searching...')} /> : null}
|
|
165
|
+
</div>
|
|
166
|
+
</div>
|
|
167
|
+
|
|
168
|
+
{selectedBill ? (
|
|
169
|
+
<div className={styles.billSummary}>
|
|
170
|
+
<div className={styles.summaryRow}>
|
|
171
|
+
<span className={styles.summaryLabel}>{t('patient', 'Patient')}</span>
|
|
172
|
+
<span>{selectedBill.patient?.display ?? '--'}</span>
|
|
173
|
+
</div>
|
|
174
|
+
<div className={styles.summaryRow}>
|
|
175
|
+
<span className={styles.summaryLabel}>{t('receiptNumber', 'Receipt number')}</span>
|
|
176
|
+
<span>{selectedBill.receiptNumber ?? '--'}</span>
|
|
177
|
+
</div>
|
|
178
|
+
<div className={styles.summaryRow}>
|
|
179
|
+
<span className={styles.summaryLabel}>{t('etimsStatus', 'eTIMS status')}</span>
|
|
180
|
+
<Tag type={isConfirmedSale ? 'green' : 'red'} size="sm">
|
|
181
|
+
{selectedBill.etims?.status ?? t('noEtimsSale', 'No eTIMS sale')}
|
|
182
|
+
</Tag>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
) : null}
|
|
186
|
+
|
|
187
|
+
{selectedBill && !isConfirmedSale ? (
|
|
188
|
+
<InlineNotification
|
|
189
|
+
kind="warning"
|
|
190
|
+
lowContrast
|
|
191
|
+
hideCloseButton
|
|
192
|
+
title={t('noConfirmedSale', 'No confirmed sale')}
|
|
193
|
+
subtitle={t(
|
|
194
|
+
'noConfirmedSaleMessage',
|
|
195
|
+
'A credit note can only be raised against a bill whose eTIMS sale is CONFIRMED.',
|
|
196
|
+
)}
|
|
197
|
+
/>
|
|
198
|
+
) : null}
|
|
199
|
+
|
|
200
|
+
<RadioButtonGroup
|
|
201
|
+
legendText={t('creditType', 'Credit type')}
|
|
202
|
+
name="creditType"
|
|
203
|
+
valueSelected={creditType}
|
|
204
|
+
onChange={(value) => {
|
|
205
|
+
setCreditType(value as EtimsAmendmentType);
|
|
206
|
+
setSelectedLineItem(null);
|
|
207
|
+
}}>
|
|
208
|
+
<RadioButton id="credit-full" labelText={t('fullCredit', 'Full credit')} value="FULL_CREDIT" />
|
|
209
|
+
<RadioButton id="credit-partial" labelText={t('partialCredit', 'Partial credit')} value="PARTIAL_CREDIT" />
|
|
210
|
+
</RadioButtonGroup>
|
|
211
|
+
|
|
212
|
+
{isPartial ? (
|
|
213
|
+
<>
|
|
214
|
+
<ComboBox<BillLineItem>
|
|
215
|
+
id="creditNoteLineItem"
|
|
216
|
+
titleText={t('lineItem', 'Line item')}
|
|
217
|
+
placeholder={t('selectLineItem', 'Select the credited line')}
|
|
218
|
+
items={lineItems}
|
|
219
|
+
itemToString={lineItemToString}
|
|
220
|
+
selectedItem={selectedLineItem}
|
|
221
|
+
onChange={({ selectedItem }) => setSelectedLineItem(selectedItem ?? null)}
|
|
222
|
+
disabled={!selectedBill}
|
|
223
|
+
/>
|
|
224
|
+
<InlineNotification
|
|
225
|
+
kind="info"
|
|
226
|
+
lowContrast
|
|
227
|
+
hideCloseButton
|
|
228
|
+
title={t('partialCredit', 'Partial credit')}
|
|
229
|
+
subtitle={t(
|
|
230
|
+
'partialCreditHint',
|
|
231
|
+
'Partial credit applies to a single line that was voided after the sale was confirmed. No replacement sale follows.',
|
|
232
|
+
)}
|
|
233
|
+
/>
|
|
234
|
+
</>
|
|
235
|
+
) : null}
|
|
236
|
+
|
|
237
|
+
<TextArea
|
|
238
|
+
id="creditNoteReason"
|
|
239
|
+
labelText={t('reason', 'Reason')}
|
|
240
|
+
placeholder={t('creditNoteReasonPlaceholder', 'Why is this credit note being raised?')}
|
|
241
|
+
value={reason}
|
|
242
|
+
onChange={(event) => setReason(event.target.value)}
|
|
243
|
+
rows={3}
|
|
244
|
+
/>
|
|
245
|
+
</div>
|
|
246
|
+
|
|
247
|
+
<ButtonSet className={classNames({ [styles.tablet]: isTablet, [styles.desktop]: !isTablet })}>
|
|
248
|
+
<Button className={styles.buttonContainer} kind="secondary" onClick={() => closeWorkspace()}>
|
|
249
|
+
{t('cancel', 'Cancel')}
|
|
250
|
+
</Button>
|
|
251
|
+
<Button className={styles.buttonContainer} disabled={!canSubmit} kind="primary" type="submit">
|
|
252
|
+
{isSubmitting ? (
|
|
253
|
+
<span className={styles.inlineLoading}>
|
|
254
|
+
{t('submitting', 'Submitting...')}
|
|
255
|
+
<InlineLoading status="active" />
|
|
256
|
+
</span>
|
|
257
|
+
) : (
|
|
258
|
+
t('createCreditNote', 'Create credit note')
|
|
259
|
+
)}
|
|
260
|
+
</Button>
|
|
261
|
+
</ButtonSet>
|
|
262
|
+
</Form>
|
|
263
|
+
</Workspace2>
|
|
264
|
+
);
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
export default EtimsCreditNoteWorkspace;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import React, { useMemo, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
DataTable,
|
|
5
|
+
DataTableSkeleton,
|
|
6
|
+
Table,
|
|
7
|
+
TableBody,
|
|
8
|
+
TableCell,
|
|
9
|
+
TableContainer,
|
|
10
|
+
TableHead,
|
|
11
|
+
TableHeader,
|
|
12
|
+
TableRow,
|
|
13
|
+
TableToolbar,
|
|
14
|
+
TableToolbarContent,
|
|
15
|
+
TableToolbarSearch,
|
|
16
|
+
} from '@carbon/react';
|
|
17
|
+
import { Edit } from '@carbon/react/icons';
|
|
18
|
+
import { ErrorState, launchWorkspace2, useDebounce, UserHasAccess } from '@openmrs/esm-framework';
|
|
19
|
+
import { useTranslation } from 'react-i18next';
|
|
20
|
+
import Header from '../components/header/header.component';
|
|
21
|
+
import { etimsPropertyKeys, useEtimsGlobalProperties } from './etims-global-properties.resource';
|
|
22
|
+
import styles from './etims-global-properties-dashboard.scss';
|
|
23
|
+
|
|
24
|
+
const labels: Record<keyof typeof etimsPropertyKeys, string> = {
|
|
25
|
+
enabled: 'eTIMS enabled',
|
|
26
|
+
environment: 'Environment',
|
|
27
|
+
baseUrl: 'Base URL',
|
|
28
|
+
businessPin: 'Business PIN',
|
|
29
|
+
branchId: 'Branch ID',
|
|
30
|
+
connectTimeout: 'Connect timeout',
|
|
31
|
+
readTimeout: 'Read timeout',
|
|
32
|
+
maxAttempts: 'Maximum attempts',
|
|
33
|
+
retryInterval: 'Retry interval',
|
|
34
|
+
invoiceNumberSource: 'Invoice number source',
|
|
35
|
+
localInvoiceNumberStart: 'Local invoice number start',
|
|
36
|
+
paymentModeMappingFile: 'Payment mode mapping file',
|
|
37
|
+
apiKey: 'API key',
|
|
38
|
+
sandboxValidatedContractVersion: 'Sandbox validated contract version',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const EtimsGlobalPropertiesDashboard: React.FC = () => {
|
|
42
|
+
const { t } = useTranslation();
|
|
43
|
+
const { properties, error, isLoading, mutate } = useEtimsGlobalProperties();
|
|
44
|
+
const [searchTerm, setSearchTerm] = useState('');
|
|
45
|
+
const debouncedSearchTerm = useDebounce(searchTerm, 400);
|
|
46
|
+
const rows = useMemo(() => {
|
|
47
|
+
const configs = Object.entries(etimsPropertyKeys).map(([name, property]) => {
|
|
48
|
+
const recordedValue = properties.find((candidate) => candidate.property === property)?.value;
|
|
49
|
+
return {
|
|
50
|
+
id: name,
|
|
51
|
+
name: labels[name as keyof typeof etimsPropertyKeys],
|
|
52
|
+
property,
|
|
53
|
+
value: name === 'apiKey' && recordedValue ? '••••••••' : recordedValue || '—',
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
if (debouncedSearchTerm === '') {
|
|
58
|
+
return configs;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return configs.filter((config) => config.name.toLowerCase().includes(debouncedSearchTerm.toLowerCase()));
|
|
62
|
+
}, [properties, debouncedSearchTerm]);
|
|
63
|
+
const headers = [
|
|
64
|
+
{ key: 'name', header: t('name', 'Name') },
|
|
65
|
+
{ key: 'property', header: t('property', 'Property') },
|
|
66
|
+
{ key: 'value', header: t('recordedValue', 'Recorded value') },
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
const openConfiguration = () =>
|
|
70
|
+
launchWorkspace2('etims-global-properties-form', {
|
|
71
|
+
mutateProperties: mutate,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const renderContent = () => {
|
|
75
|
+
if (isLoading) {
|
|
76
|
+
return <DataTableSkeleton headers={headers} rowCount={14} showHeader showToolbar />;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (error) {
|
|
80
|
+
return <ErrorState error={error} headerTitle={t('etimsGlobalProperties', 'eTIMS global properties')} />;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<div className={styles.container}>
|
|
85
|
+
<DataTable rows={rows} headers={headers} size="sm" useZebraStyles>
|
|
86
|
+
{({ rows: tableRows, headers: tableHeaders, getHeaderProps, getRowProps, getTableProps }) => (
|
|
87
|
+
<TableContainer
|
|
88
|
+
title={t('etimsGlobalProperties', 'eTIMS global properties')}
|
|
89
|
+
description={t(
|
|
90
|
+
'etimsGlobalPropertiesDescription',
|
|
91
|
+
'Review the global properties used by the eTIMS integration.',
|
|
92
|
+
)}>
|
|
93
|
+
<TableToolbar>
|
|
94
|
+
<TableToolbarContent>
|
|
95
|
+
<TableToolbarSearch
|
|
96
|
+
onChange={(event) => setSearchTerm(typeof event === 'string' ? event : event.target.value)}
|
|
97
|
+
size="sm"
|
|
98
|
+
persistent
|
|
99
|
+
placeholder={t('searchForGlobalProperties', 'Search for global properties')}
|
|
100
|
+
/>
|
|
101
|
+
<Button size="sm" renderIcon={Edit} onClick={openConfiguration}>
|
|
102
|
+
{t('configure', 'Configure')}
|
|
103
|
+
</Button>
|
|
104
|
+
</TableToolbarContent>
|
|
105
|
+
</TableToolbar>
|
|
106
|
+
<Table {...getTableProps()} aria-label={t('etimsGlobalProperties', 'eTIMS global properties')}>
|
|
107
|
+
<TableHead>
|
|
108
|
+
<TableRow>
|
|
109
|
+
{tableHeaders.map((header) => (
|
|
110
|
+
<TableHeader {...getHeaderProps({ header })}>{header.header}</TableHeader>
|
|
111
|
+
))}
|
|
112
|
+
</TableRow>
|
|
113
|
+
</TableHead>
|
|
114
|
+
<TableBody>
|
|
115
|
+
{tableRows.map((row) => (
|
|
116
|
+
<TableRow {...getRowProps({ row })}>
|
|
117
|
+
{row.cells.map((cell) => (
|
|
118
|
+
<TableCell key={cell.id}>{cell.value}</TableCell>
|
|
119
|
+
))}
|
|
120
|
+
</TableRow>
|
|
121
|
+
))}
|
|
122
|
+
</TableBody>
|
|
123
|
+
</Table>
|
|
124
|
+
</TableContainer>
|
|
125
|
+
)}
|
|
126
|
+
</DataTable>
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<>
|
|
133
|
+
<Header title={t('etimsGlobalProperties', 'eTIMS global properties')} />
|
|
134
|
+
<UserHasAccess privilege="Manage eTIMS Configuration">
|
|
135
|
+
<div className={styles.dashboard}>{renderContent()}</div>
|
|
136
|
+
</UserHasAccess>
|
|
137
|
+
</>
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export default EtimsGlobalPropertiesDashboard;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
@use '@carbon/colors';
|
|
2
|
+
@use '@carbon/layout';
|
|
3
|
+
@use '@carbon/type';
|
|
4
|
+
|
|
5
|
+
.container {
|
|
6
|
+
margin: layout.$layout-01;
|
|
7
|
+
border: 1px solid colors.$gray-20;
|
|
8
|
+
|
|
9
|
+
:global(.cds--table-toolbar) {
|
|
10
|
+
position: relative !important;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.form {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
gap: layout.$spacing-05;
|
|
18
|
+
max-width: 64rem;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.intro {
|
|
22
|
+
@include type.type-style('body-01');
|
|
23
|
+
color: colors.$gray-70;
|
|
24
|
+
margin: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.section {
|
|
28
|
+
background: colors.$white;
|
|
29
|
+
border: 1px solid colors.$gray-20;
|
|
30
|
+
padding: layout.$spacing-05;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.sectionTitle {
|
|
34
|
+
@include type.type-style('heading-compact-02');
|
|
35
|
+
margin: 0 0 layout.$spacing-05;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.fields {
|
|
39
|
+
display: grid;
|
|
40
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
41
|
+
gap: layout.$spacing-05;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.fullWidth {
|
|
45
|
+
grid-column: 1 / -1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.actions {
|
|
49
|
+
display: flex;
|
|
50
|
+
justify-content: flex-end;
|
|
51
|
+
|
|
52
|
+
button {
|
|
53
|
+
width: 50%;
|
|
54
|
+
max-width: none;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
:global(.omrs-breakpoint-lt-tablet) {
|
|
59
|
+
.fields {
|
|
60
|
+
grid-template-columns: 1fr;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
@use '@carbon/colors';
|
|
2
|
+
@use '@carbon/layout';
|
|
3
|
+
@use '@carbon/type';
|
|
4
|
+
|
|
5
|
+
.form {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
justify-content: space-between;
|
|
9
|
+
height: 100%;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.formContainer {
|
|
13
|
+
margin: layout.$spacing-05;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
gap: layout.$spacing-05;
|
|
17
|
+
overflow-y: auto;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.intro {
|
|
21
|
+
@include type.type-style('body-01');
|
|
22
|
+
color: colors.$gray-70;
|
|
23
|
+
margin: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.section {
|
|
27
|
+
background: colors.$white;
|
|
28
|
+
border: 1px solid colors.$gray-20;
|
|
29
|
+
padding: layout.$spacing-05;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.sectionTitle {
|
|
33
|
+
@include type.type-style('heading-compact-02');
|
|
34
|
+
margin: 0 0 layout.$spacing-05;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.fields {
|
|
38
|
+
display: grid;
|
|
39
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
40
|
+
gap: layout.$spacing-05;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.fullWidth {
|
|
44
|
+
grid-column: 1 / -1;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.tablet {
|
|
48
|
+
padding: layout.$spacing-06 layout.$spacing-05;
|
|
49
|
+
background-color: colors.$white;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.desktop {
|
|
53
|
+
padding: 0;
|
|
54
|
+
|
|
55
|
+
& button {
|
|
56
|
+
max-width: 50% !important;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.buttonContainer {
|
|
61
|
+
max-width: 50%;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.inlineLoading {
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
gap: layout.$spacing-03;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
:global(.omrs-breakpoint-lt-tablet) {
|
|
71
|
+
.fields {
|
|
72
|
+
grid-template-columns: 1fr;
|
|
73
|
+
}
|
|
74
|
+
}
|