@digihmis/esm-administration-app 1.0.0 → 1.0.2

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 (67) hide show
  1. package/dist/145.js +1 -0
  2. package/dist/145.js.map +1 -0
  3. package/dist/153.js +1 -1
  4. package/dist/153.js.map +1 -1
  5. package/dist/402.js +1 -0
  6. package/dist/402.js.map +1 -0
  7. package/dist/594.js +1 -0
  8. package/dist/594.js.map +1 -0
  9. package/dist/598.js +1 -1
  10. package/dist/598.js.map +1 -1
  11. package/dist/625.js +15 -0
  12. package/dist/{916.js.map → 625.js.map} +1 -1
  13. package/dist/{685.js → 631.js} +1 -1
  14. package/dist/631.js.map +1 -0
  15. package/dist/681.js +1 -0
  16. package/dist/681.js.map +1 -0
  17. package/dist/737.js +1 -1
  18. package/dist/737.js.map +1 -1
  19. package/dist/{266.js → 947.js} +1 -1
  20. package/dist/947.js.map +1 -0
  21. package/dist/digihmis-esm-administration-app.js +2 -2
  22. package/dist/digihmis-esm-administration-app.js.buildmanifest.json +140 -140
  23. package/dist/digihmis-esm-administration-app.js.map +1 -1
  24. package/dist/main.js +6 -6
  25. package/dist/main.js.map +1 -1
  26. package/dist/routes.json +1 -1
  27. package/package.json +3 -2
  28. package/release-version.js +4 -4
  29. package/src/billing-management/billing-charge-items/billing-charge-items-modal/billing-charge-items.resource.ts +2 -1
  30. package/src/billing-management/billing-charge-items/billing-charge-items-workspace/billing-charge-items.resource.ts +30 -7
  31. package/src/billing-management/billing-charge-items/billing-charge-items-workspace/billing-charge-service.workspace.tsx +79 -107
  32. package/src/billing-management/billing-charge-items/billing-charge-items-workspace/components/price.component.scss +16 -0
  33. package/src/billing-management/billing-charge-items/billing-charge-items-workspace/components/price.component.tsx +30 -20
  34. package/src/billing-management/billing-charge-items/billing-charge-items-workspace/schemas/form-schemas.ts +19 -14
  35. package/src/billing-management/billing-charge-items/billing-charge-items.component.tsx +26 -35
  36. package/src/billing-management/billing-charge-items/billing-charge-items.resource.ts +1 -1
  37. package/src/billing-management/billing-charge-items/type/index.ts +10 -10
  38. package/src/billing-management/billing-charge-items/utils/index.ts +32 -74
  39. package/src/billing-management/billing-payment-modes/billing-payment-modes.component.tsx +24 -166
  40. package/src/billing-management/billing-payment-modes/billing-payment-modes.resource.ts +24 -14
  41. package/src/billing-management/billing-payment-points/billing-payment-point-modal/billing-delete-payment-point.modal.tsx +1 -1
  42. package/src/billing-management/billing-payment-points/billing-payment-point.resource.ts +1 -1
  43. package/src/billing-management/billing-payment-points/billing-payment-point.scss +47 -0
  44. package/src/billing-management/billing-payment-points/billing-payment-points-workspace/billing-payment-point.resource.ts +18 -23
  45. package/src/billing-management/billing-payment-points/billing-payment-points-workspace/billing-payment-points.workspace.tsx +1 -1
  46. package/src/config-schema.ts +17 -0
  47. package/src/dashboard.meta.ts +8 -0
  48. package/src/document-branding/document-branding-workspace/document-branding.workspace.scss +34 -0
  49. package/src/document-branding/document-branding-workspace/document-branding.workspace.tsx +160 -0
  50. package/src/document-branding/document-branding.component.tsx +185 -0
  51. package/src/document-branding/document-branding.resource.ts +54 -0
  52. package/src/document-branding/document-branding.scss +69 -0
  53. package/src/index.ts +15 -9
  54. package/src/routes.json +34 -13
  55. package/dist/101.js +0 -1
  56. package/dist/101.js.map +0 -1
  57. package/dist/190.js +0 -1
  58. package/dist/190.js.map +0 -1
  59. package/dist/266.js.map +0 -1
  60. package/dist/606.js +0 -1
  61. package/dist/606.js.map +0 -1
  62. package/dist/685.js.map +0 -1
  63. package/dist/747.js +0 -1
  64. package/dist/747.js.map +0 -1
  65. package/dist/916.js +0 -15
  66. package/src/billing-management/billing-charge-items/billing-charge-items-workspace/billing-charge-item.workspace.tsx +0 -212
  67. package/src/billing-management/billing-charge-items/billing-charge-items-workspace/components/stock-search.component.tsx +0 -107
@@ -40,16 +40,16 @@ const ChargeItemsTable = () => {
40
40
  header: t('name', 'Name'),
41
41
  },
42
42
  {
43
- key: 'status',
44
- header: t('status', 'Status'),
43
+ key: 'serviceType',
44
+ header: t('serviceType', 'Service type'),
45
45
  },
46
46
  {
47
- key: 'type',
48
- header: t('type', 'Type'),
47
+ key: 'prices',
48
+ header: t('prices', 'Prices'),
49
49
  },
50
50
  {
51
- key: 'price',
52
- header: t('price', 'Price'),
51
+ key: 'status',
52
+ header: t('status', 'Status'),
53
53
  },
54
54
  ];
55
55
 
@@ -58,17 +58,22 @@ const ChargeItemsTable = () => {
58
58
  return [];
59
59
  }
60
60
 
61
- return chargeSummaryItems.map((item) => ({
62
- id: item.uuid,
63
- name: item.name || '-',
64
- status: item.serviceStatus === 'ENABLED' ? t('enabled', 'Enabled') : t('disabled', 'Disabled'),
65
- type: item.serviceType?.display || t('stockItem', 'Stock Item'),
66
- price:
67
- item.servicePrices && item.servicePrices.length > 0
68
- ? item.servicePrices.map((p) => `${p.name}: ${p.price}`).join(', ')
69
- : '-',
70
- chargeItem: item,
71
- }));
61
+ const formatMode = (mode: string) =>
62
+ mode ? mode.charAt(0) + mode.slice(1).toLowerCase().replace(/_/g, ' ') : mode;
63
+
64
+ return chargeSummaryItems.map((item) => {
65
+ const perMode = item.prices ?? [];
66
+ return {
67
+ id: item.uuid,
68
+ name: item.name || '-',
69
+ serviceType: item.serviceType?.display || '',
70
+ prices: perMode.length
71
+ ? perMode.map((p) => `${formatMode(p.paymentMode)}: ${p.price}`).join(', ')
72
+ : (item.price ?? '-'),
73
+ status: item.retired ? t('retired', 'Retired') : t('active', 'Active'),
74
+ chargeItem: item,
75
+ };
76
+ });
72
77
  }, [chargeSummaryItems, t]);
73
78
 
74
79
  const paginatedRows = useMemo(() => {
@@ -83,22 +88,11 @@ const ChargeItemsTable = () => {
83
88
  });
84
89
  };
85
90
 
86
- const handleAddChargeItem = () => {
87
- launchWorkspace('billing-charge-item-workspace', {
88
- workspaceTitle: t('addChargeItem', 'Add Charge Item'),
89
- });
90
- };
91
-
92
91
  const handleEdit = (service) => {
93
- Boolean(service?.serviceType?.display)
94
- ? launchWorkspace('billing-charge-service-workspace', {
95
- initialValues: service,
96
- workspaceTitle: t('editServiceChargeItem', 'Edit Service Charge Item'),
97
- })
98
- : launchWorkspace('billing-charge-item-workspace', {
99
- initialValues: service,
100
- workspaceTitle: t('editChargeItem', 'Edit Charge Item'),
101
- });
92
+ launchWorkspace('billing-charge-service-workspace', {
93
+ initialValues: service,
94
+ workspaceTitle: t('editServiceChargeItem', 'Edit Service Charge Item'),
95
+ });
102
96
  };
103
97
 
104
98
  const showDeleteChargeItemModal = (chargeItem) => {
@@ -128,9 +122,6 @@ const ChargeItemsTable = () => {
128
122
  <Button kind="ghost" renderIcon={(props) => <Add size={16} {...props} />} onClick={handleAddChargeService}>
129
123
  {t('addChargeService', 'Add Charge Service')}
130
124
  </Button>
131
- <Button kind="ghost" renderIcon={(props) => <Add size={16} {...props} />} onClick={handleAddChargeItem}>
132
- {t('addChargeItem', 'Add Charge Item')}
133
- </Button>
134
125
  </div>
135
126
  </CardHeader>
136
127
  <Layer>
@@ -3,7 +3,7 @@ import useSWR from 'swr';
3
3
  import { type ChargeItemsResponse } from './type';
4
4
 
5
5
  export const useChargeItems = () => {
6
- const url = `${restBaseUrl}/cashier/billableService?v=custom:(uuid,name,shortName,serviceStatus,serviceType:(uuid,display),servicePrices:(uuid,name,paymentMode,price),concept:(uuid,display),stockItem:(uuid,display))`;
6
+ const url = `${restBaseUrl}/digihmisbilling/billableitem`;
7
7
 
8
8
  const { data, isLoading, isValidating, error, mutate } = useSWR<FetchResponse<ChargeItemsResponse>>(
9
9
  url,
@@ -3,22 +3,22 @@ import { OpenmrsResource } from '@openmrs/esm-framework';
3
3
  export interface ChargeItems {
4
4
  uuid: string;
5
5
  name: string;
6
- shortName: string;
7
- serviceStatus: 'ENABLED' | 'DISABLED';
8
- stockItem: OpenmrsResource;
9
- serviceType: {
6
+ price: number | string;
7
+ description?: string;
8
+ retired?: boolean;
9
+ concept: {
10
10
  uuid: string;
11
11
  display: string;
12
12
  };
13
- servicePrices: Array<{
14
- uuid: string;
15
- name: string;
16
- price: number;
17
- }>;
18
- concept: {
13
+ serviceType?: {
19
14
  uuid: string;
20
15
  display: string;
21
16
  };
17
+ prices?: Array<{
18
+ uuid?: string;
19
+ paymentMode: string;
20
+ price: number | string;
21
+ }>;
22
22
  }
23
23
 
24
24
  export interface ChargeItemsResponse {
@@ -1,96 +1,54 @@
1
- import { BillableFormSchema, ServicePriceSchema } from '../billing-charge-items-workspace/schemas/form-schemas';
1
+ import { BillableFormSchema } from '../billing-charge-items-workspace/schemas/form-schemas';
2
2
 
3
3
  export type BillableServicePayload = {
4
4
  name: string;
5
- shortName: string;
6
- serviceType: number | string;
7
- servicePrices: Array<{
8
- paymentMode: string;
9
- price: string | number;
10
- name: string;
11
- }>;
12
- serviceStatus: string;
13
- concept: string | number;
14
- stockItem: string;
5
+ concept?: string;
6
+ serviceType?: string;
7
+ price: string | number;
8
+ description?: string;
15
9
  uuid?: string;
16
10
  };
17
11
 
12
+ /**
13
+ * Map the form to the billable-item create/update payload. Pricing is per payment mode, but the
14
+ * module still stores a fallback default price, so the first configured mode's price is used for it;
15
+ * the per-mode prices are then synced separately as overrides.
16
+ */
18
17
  export const formatBillableServicePayloadForSubmission = (
19
18
  formData: BillableFormSchema,
20
19
  uuid?: string,
21
20
  ): BillableServicePayload => {
22
- const formPayload = {
21
+ const prices = formData.servicePrices ?? [];
22
+ const fallbackPrice = prices.length ? Number(prices[0].price ?? 0) : 0;
23
+ const payload: BillableServicePayload = {
23
24
  name: formData.name,
24
- shortName: formData.shortName,
25
- serviceType: formData.serviceType.uuid,
26
- servicePrices: formData.servicePrices.map((servicePrice) => ({
27
- paymentMode: servicePrice.paymentMode.uuid,
28
- price: servicePrice.price,
29
- name: servicePrice.paymentMode.name,
30
- })),
31
- serviceStatus: formData.serviceStatus,
32
- concept: formData.concept.concept.uuid,
33
- stockItem: formData.stockItem || null,
25
+ concept: formData.concept?.concept?.uuid,
26
+ // Empty string clears the service type on update; a uuid sets it.
27
+ serviceType: formData.serviceType?.uuid ?? '',
28
+ price: fallbackPrice,
29
+ description: formData.description,
34
30
  };
35
-
36
- return uuid ? Object.assign(formPayload, { uuid: uuid }) : formPayload;
31
+ return uuid ? { ...payload, uuid } : payload;
37
32
  };
38
33
 
34
+ /** Map an existing billable item (from the list) back onto the form for editing. */
39
35
  export function mapInputToPayloadSchema(service): BillableFormSchema {
40
- const servicePrices: Array<ServicePriceSchema> = service.servicePrices.map((price: any) => ({
41
- price: price.price,
42
- paymentMode: {
43
- uuid: price.paymentMode?.uuid,
44
- name: price.paymentMode?.name,
45
- },
36
+ const servicePrices = (service?.prices ?? []).map((override: { paymentMode?: string; price?: number | string }) => ({
37
+ paymentMode: { uuid: override?.paymentMode ?? '', name: override?.paymentMode ?? '' },
38
+ price: Number(override?.price ?? 0),
46
39
  }));
47
-
48
- const payload: BillableFormSchema = {
49
- name: service.name,
50
- shortName: service.shortName,
51
- serviceType: {
52
- uuid: service?.serviceType?.uuid,
53
- display: service?.serviceType?.display,
54
- },
55
- servicePrices: servicePrices,
56
- serviceStatus: service.serviceStatus,
57
- concept: {
58
- concept: {
59
- uuid: service?.concept?.uuid,
60
- display: service.concept?.display,
61
- },
62
- conceptName: {
63
- uuid: service?.concept?.uuid,
64
- display: service?.concept?.display,
65
- },
66
- display: service?.concept?.display,
67
- },
68
- stockItem: service?.stockItem?.uuid ?? null,
69
- };
70
-
71
- return payload;
72
- }
73
-
74
- export const formatStockItemToPayload = (stockItem: any): BillableFormSchema => {
75
40
  return {
76
- name: stockItem.commonName,
77
- shortName: stockItem.commonName.length > 1 ? stockItem.commonName : `${stockItem.commonName} `,
78
- serviceType: {
79
- uuid: stockItem.serviceType?.uuid || '',
80
- display: stockItem.serviceType?.display || '',
81
- },
82
- servicePrices: [],
41
+ name: service?.name ?? '',
42
+ description: service?.description ?? '',
83
43
  concept: {
84
44
  concept: {
85
- uuid: stockItem.conceptUuid,
86
- display: stockItem.conceptName,
87
- },
88
- conceptName: {
89
- uuid: stockItem.conceptUuid,
90
- display: stockItem.conceptName,
45
+ uuid: service?.concept?.uuid ?? '',
46
+ display: service?.concept?.display ?? '',
91
47
  },
92
- display: stockItem.conceptName,
93
48
  },
94
- stockItem: stockItem.uuid,
49
+ serviceType: service?.serviceType
50
+ ? { uuid: service.serviceType.uuid, display: service.serviceType.display }
51
+ : null,
52
+ servicePrices,
95
53
  };
96
- };
54
+ }
@@ -1,6 +1,5 @@
1
- import React, { useMemo, useState } from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import {
3
- Button,
4
3
  DataTable,
5
4
  DataTableSkeleton,
6
5
  Table,
@@ -10,88 +9,35 @@ import {
10
9
  TableHead,
11
10
  TableHeader,
12
11
  TableRow,
13
- TableExpandHeader,
14
- TableExpandRow,
15
- TableExpandedRow,
16
12
  Layer,
17
- Pagination,
18
13
  Tile,
19
- IconButton,
20
14
  } from '@carbon/react';
21
- import { Add, Edit, TrashCan } from '@carbon/react/icons';
22
- import { launchWorkspace, useLayoutType, ErrorState, showModal } from '@openmrs/esm-framework';
15
+ import { useLayoutType, ErrorState } from '@openmrs/esm-framework';
23
16
  import { useTranslation } from 'react-i18next';
24
- import startCase from 'lodash-es/startCase';
25
17
  import styles from './billing-payment-modes.scss';
26
18
  import { CardHeader } from '@openmrs/esm-patient-common-lib';
27
- import { PaymentMethod } from './type';
28
19
  import { usePaymentModes } from './billing-payment-modes.resource';
29
20
 
21
+ /**
22
+ * DigiHMIS payment modes are a fixed set (the billing module's PaymentMode enum), so this tab lists
23
+ * them read-only -- there is nothing to add, edit or delete.
24
+ */
30
25
  const PaymentModeTable = () => {
31
26
  const { t } = useTranslation();
32
- const layout = useLayoutType();
33
- const isTablet = layout === 'tablet';
27
+ const isTablet = useLayoutType() === 'tablet';
34
28
  const responsiveSize = isTablet ? 'lg' : 'sm';
35
29
 
36
30
  const { paymentModes, isLoading, error } = usePaymentModes(false);
37
31
 
38
- // Pagination state
39
- const [currentPage, setCurrentPage] = useState(1);
40
- const [currentPageSize, setCurrentPageSize] = useState(10);
41
- const pageSizes = [10, 20, 30, 40, 50];
42
-
43
32
  const headers = [
44
- {
45
- key: 'dateCreated',
46
- header: t('dateCreated', 'Date Created'),
47
- },
48
- {
49
- key: 'name',
50
- header: t('name', 'Name'),
51
- },
52
- {
53
- key: 'description',
54
- header: t('description', 'Description'),
55
- },
56
- {
57
- key: 'retired',
58
- header: t('retired', 'Retired'),
59
- },
33
+ { key: 'name', header: t('name', 'Name') },
34
+ { key: 'description', header: t('code', 'Code') },
60
35
  ];
61
36
 
62
- // Transform payment modes to table rows
63
- const tableRows = useMemo(() => {
64
- if (!paymentModes) {
65
- return [];
66
- }
67
-
68
- return paymentModes.map((mode) => ({
69
- id: mode.uuid,
70
- dateCreated: new Date(mode.auditInfo.dateCreated).toLocaleDateString(),
71
- name: mode.name,
72
- description: mode.description || '-',
73
- retired: mode.retired ? t('yes', 'Yes') : t('no', 'No'),
74
- paymentMode: mode, // Store full object for expandable row
75
- }));
76
- }, [paymentModes, t]);
77
-
78
- // Paginated rows
79
- const paginatedRows = useMemo(() => {
80
- const startIndex = (currentPage - 1) * currentPageSize;
81
- const endIndex = startIndex + currentPageSize;
82
- return tableRows.slice(startIndex, endIndex);
83
- }, [tableRows, currentPage, currentPageSize]);
84
-
85
- const handleAddPaymentMode = () => {
86
- launchWorkspace('payment-mode-workspace');
87
- };
88
-
89
- const showDeletePaymentModeModal = (paymentMode: PaymentMethod) => {
90
- const dispose = showModal('delete-payment-mode-modal', {
91
- closeModal: () => dispose(),
92
- paymentMode,
93
- });
94
- };
37
+ const rows = useMemo(
38
+ () => (paymentModes ?? []).map((mode) => ({ id: mode.uuid, name: mode.name, description: mode.description || '-' })),
39
+ [paymentModes],
40
+ );
95
41
 
96
42
  if (isLoading) {
97
43
  return (
@@ -109,102 +55,41 @@ const PaymentModeTable = () => {
109
55
  return (
110
56
  <div className={styles.section}>
111
57
  <CardHeader title={t('paymentModes', 'Payment Modes')}>
112
- <Button kind="ghost" renderIcon={(props) => <Add size={16} {...props} />} onClick={handleAddPaymentMode}>
113
- {t('addPaymentMode', 'Add Payment Mode')}
114
- </Button>
58
+ <span>{t('builtInPaymentModes', 'Built-in payment modes')}</span>
115
59
  </CardHeader>
116
60
  <Layer>
117
- <DataTable rows={paginatedRows} headers={headers} isSortable size={responsiveSize} useZebraStyles>
118
- {({ rows, headers, getHeaderProps, getRowProps, getTableProps, getExpandedRowProps }) => (
61
+ <DataTable rows={rows} headers={headers} isSortable size={responsiveSize} useZebraStyles>
62
+ {({ rows, headers, getHeaderProps, getRowProps, getTableProps }) => (
119
63
  <TableContainer>
120
64
  <Table {...getTableProps()} aria-label={t('paymentModesTable', 'Payment modes table')}>
121
65
  <TableHead>
122
66
  <TableRow>
123
- <TableExpandHeader />
124
67
  {headers.map((header) => (
125
68
  <TableHeader key={header.key} {...getHeaderProps({ header })}>
126
69
  {header.header}
127
70
  </TableHeader>
128
71
  ))}
129
- <TableHeader>{t('actions', 'Actions')}</TableHeader>
130
72
  </TableRow>
131
73
  </TableHead>
132
74
  <TableBody>
133
- {rows.map((row, index) => {
134
- const paymentMode = paginatedRows[index]?.paymentMode;
135
- return (
136
- <React.Fragment key={row.id}>
137
- <TableExpandRow {...getRowProps({ row })}>
138
- {row.cells.map((cell) => (
139
- <TableCell key={cell.id}>{cell.value}</TableCell>
140
- ))}
141
- <TableCell>
142
- <div style={{ display: 'flex', gap: '0.5rem' }}>
143
- <IconButton
144
- kind="ghost"
145
- size={responsiveSize}
146
- label={t('edit', 'Edit')}
147
- onClick={() =>
148
- launchWorkspace('payment-mode-workspace', {
149
- workspaceTitle: t('editPaymentMode', 'Edit Payment Mode'),
150
- initialPaymentMode: paymentMode,
151
- })
152
- }>
153
- <Edit />
154
- </IconButton>
155
- <IconButton
156
- kind="danger--ghost"
157
- size={responsiveSize}
158
- label={t('delete', 'Delete')}
159
- onClick={() => showDeletePaymentModeModal(paymentMode)}>
160
- <TrashCan />
161
- </IconButton>
162
- </div>
163
- </TableCell>
164
- </TableExpandRow>
165
- <TableExpandedRow
166
- colSpan={headers.length + 2}
167
- className="demo-expanded-td"
168
- {...getExpandedRowProps({ row })}>
169
- {paymentMode && <PaymentModeAttributes paymentMode={paymentMode} />}
170
- </TableExpandedRow>
171
- </React.Fragment>
172
- );
173
- })}
75
+ {rows.map((row) => (
76
+ <TableRow key={row.id} {...getRowProps({ row })}>
77
+ {row.cells.map((cell) => (
78
+ <TableCell key={cell.id}>{cell.value}</TableCell>
79
+ ))}
80
+ </TableRow>
81
+ ))}
174
82
  </TableBody>
175
83
  </Table>
176
- {tableRows.length === 0 ? (
84
+ {rows.length === 0 ? (
177
85
  <div className={styles.tileContainer}>
178
86
  <Tile className={styles.tile}>
179
87
  <div className={styles.tileContent}>
180
88
  <p className={styles.content}>{t('noPaymentModesFound', 'No payment modes found')}</p>
181
- <p className={styles.emptyStateHelperText}>
182
- {t('checkFilters', 'Please check the filters above and try again')}
183
- </p>
184
89
  </div>
185
90
  </Tile>
186
91
  </div>
187
92
  ) : null}
188
- {tableRows.length > 0 && (
189
- <Pagination
190
- forwardText={t('nextPage', 'Next page')}
191
- backwardText={t('previousPage', 'Previous page')}
192
- page={currentPage}
193
- pageSize={currentPageSize}
194
- pageSizes={pageSizes}
195
- totalItems={tableRows.length}
196
- className={styles.pagination}
197
- onChange={({ pageSize, page }) => {
198
- if (pageSize !== currentPageSize) {
199
- setCurrentPageSize(pageSize);
200
- setCurrentPage(1);
201
- }
202
- if (page !== currentPage) {
203
- setCurrentPage(page);
204
- }
205
- }}
206
- />
207
- )}
208
93
  </TableContainer>
209
94
  )}
210
95
  </DataTable>
@@ -213,31 +98,4 @@ const PaymentModeTable = () => {
213
98
  );
214
99
  };
215
100
 
216
- const PaymentModeAttributes: React.FC<{ paymentMode: PaymentMethod }> = ({ paymentMode }) => {
217
- const { t } = useTranslation();
218
- const { attributeTypes } = paymentMode;
219
-
220
- return (
221
- <div className={styles.attributeContainer}>
222
- {attributeTypes.map((attributeType, index) =>
223
- Object.entries(attributeType).map(([key, value]) => {
224
- if (key === 'uuid') {
225
- return null;
226
- }
227
- return <AttributeCard key={`${index}-${key}`} label={key} value={JSON.stringify(value)} />;
228
- }),
229
- )}
230
- </div>
231
- );
232
- };
233
-
234
- const AttributeCard: React.FC<{ label: string; value: string }> = ({ label, value }) => {
235
- return (
236
- <div className={styles.attributeCard}>
237
- <div className={styles.attributeLabel}>{startCase(label).replace(/\s+/g, ' ')}</div>
238
- <div className={styles.attributeValue}>{value.replace(/['"]/g, '')}</div>
239
- </div>
240
- );
241
- };
242
-
243
101
  export default PaymentModeTable;
@@ -1,21 +1,31 @@
1
- import { openmrsFetch, restBaseUrl, useConfig } from '@openmrs/esm-framework';
1
+ import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
2
2
  import useSWR from 'swr';
3
- import { PaymentMethod } from './type';
4
- import { ConfigObject } from '../../config-schema';
5
3
 
4
+ export interface PaymentModeOption {
5
+ uuid: string;
6
+ name: string;
7
+ description?: string;
8
+ }
9
+
10
+ /**
11
+ * The payment modes are a fixed enum in the DigiHMIS billing module, served read-only at
12
+ * /digihmisbilling/paymentmode. The `uuid` carries the enum name (what a visit attribute / payment
13
+ * stores) and `name` its label.
14
+ */
6
15
  export const usePaymentModes = (excludeWaiver: boolean = true) => {
7
- const { excludedPaymentMode } = useConfig<ConfigObject>();
8
- const url = `${restBaseUrl}/cashier/paymentMode?v=full`;
9
- const { data, isLoading, error, mutate } = useSWR<{ data: { results: Array<PaymentMethod> } }>(url, openmrsFetch, {
10
- errorRetryCount: 2,
11
- });
12
- const allowedPaymentModes =
13
- excludedPaymentMode?.length > 0
14
- ? (data?.data?.results.filter((mode) => !excludedPaymentMode.some((excluded) => excluded.uuid === mode.uuid)) ??
15
- [])
16
- : (data?.data?.results ?? []);
16
+ const url = `${restBaseUrl}/digihmisbilling/paymentmode`;
17
+ const { data, isLoading, error, mutate } = useSWR<{
18
+ data: { results: Array<{ value: string; uuid: string; display: string }> };
19
+ }>(url, openmrsFetch);
20
+
21
+ const modes: Array<PaymentModeOption> = (data?.data?.results ?? []).map((mode) => ({
22
+ uuid: mode.uuid ?? mode.value,
23
+ name: mode.display,
24
+ description: mode.value,
25
+ }));
26
+
17
27
  return {
18
- paymentModes: excludeWaiver ? allowedPaymentModes : data?.data?.results,
28
+ paymentModes: excludeWaiver ? modes.filter((mode) => mode.uuid !== 'WAIVER') : modes,
19
29
  isLoading,
20
30
  mutate,
21
31
  error,
@@ -28,7 +28,7 @@ const DeletePaymentPointModal: React.FC<DeletePaymentPointModalProps> = ({ close
28
28
  timeoutInMs: 5000,
29
29
  autoClose: true,
30
30
  });
31
- handleMutation(`${restBaseUrl}/cashier/cashPoint?v=full`);
31
+ handleMutation(`${restBaseUrl}/digihmisbilling/paymentpoint`);
32
32
  closeModal();
33
33
  } catch (error) {
34
34
  showSnackbar({
@@ -3,7 +3,7 @@ import { PaymentPoint } from './type';
3
3
  import useSWR from 'swr';
4
4
 
5
5
  export const usePaymentPoints = () => {
6
- const url = `${restBaseUrl}/cashier/cashPoint?v=full`;
6
+ const url = `${restBaseUrl}/digihmisbilling/paymentpoint`;
7
7
 
8
8
  const { data, isLoading, error, mutate } = useSWR<FetchResponse<{ results: Array<PaymentPoint> }>>(url, openmrsFetch);
9
9
 
@@ -0,0 +1,47 @@
1
+ @use '@carbon/layout';
2
+ @use '@carbon/type';
3
+ @use '@carbon/colors';
4
+
5
+ .section {
6
+ margin-bottom: layout.$spacing-07;
7
+
8
+ &:last-child {
9
+ margin-bottom: 0;
10
+ }
11
+ }
12
+
13
+ .tileContainer {
14
+ border-top: 1px solid colors.$gray-20;
15
+ padding: 3rem 0;
16
+ }
17
+
18
+ .tile {
19
+ margin: auto;
20
+ width: fit-content;
21
+ background: colors.$gray-20;
22
+ }
23
+
24
+ .tileContent {
25
+ display: flex;
26
+ flex-direction: column;
27
+ align-items: center;
28
+ }
29
+
30
+ .content {
31
+ @include type.type-style('heading-compact-02');
32
+ color: colors.$gray-70;
33
+ margin-bottom: layout.$spacing-03;
34
+ }
35
+
36
+ .emptyStateHelperText {
37
+ @include type.type-style('body-compact-01');
38
+ color: colors.$gray-70;
39
+ }
40
+
41
+ .pagination {
42
+ overflow: hidden;
43
+
44
+ &:global(.cds--pagination) {
45
+ border-top: none;
46
+ }
47
+ }