@kenyaemr/esm-admin-app 5.4.4-pre.142 → 5.4.4-pre.15
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/package.json +1 -1
- package/src/components/confirm-modal/confirmation-operation.test.tsx +8 -19
- package/src/components/dashboard/dashboard.component.tsx +4 -1
- package/src/components/empty-state/empty-state-log.test.tsx +3 -4
- package/src/components/facility-setup/constant/index.ts +3 -0
- package/src/components/facility-setup/facility-info.component.tsx +176 -106
- package/src/components/facility-setup/facility-info.scss +39 -1
- package/src/components/facility-setup/facility-setup.component.tsx +2 -2
- package/src/components/facility-setup/type/index.ts +61 -0
- package/src/components/facility-setup/useFacilityRegistry.ts +29 -0
- package/src/components/global-property/dashboard/global-property-dashboard.component.tsx +23 -0
- package/src/components/global-property/dashboard/global-property-dashboard.scss +6 -0
- package/src/components/global-property/hooks/useGlobalProperty.ts +64 -0
- package/src/components/global-property/index.ts +14 -0
- package/src/components/global-property/modal/delete-global-property-modal.component.tsx +71 -0
- package/src/components/global-property/modal/delete-global-property-modal.test.tsx +131 -0
- package/src/components/global-property/table/global-property-table.component.tsx +249 -0
- package/src/components/global-property/table/global-property-table.scss +34 -0
- package/src/components/global-property/table/global-property-table.test.tsx +198 -0
- package/src/components/global-property/workspace/global-property-form-schema.ts +32 -0
- package/src/components/global-property/workspace/global-property.workspace.scss +40 -0
- package/src/components/global-property/workspace/global-property.workspace.test.tsx +172 -0
- package/src/components/global-property/workspace/global-property.workspace.tsx +260 -0
- package/src/components/hook/healthWorkerRegistry.ts +78 -0
- package/src/components/hook/useProfessionalRegistryEnums.ts +59 -0
- package/src/components/logs-table/operation-log-table.component.tsx +87 -75
- package/src/components/logs-table/operation-log.test.tsx +134 -28
- package/src/components/modal/hwr-confirmation.modal.scss +80 -4
- package/src/components/modal/hwr-confirmation.modal.tsx +118 -128
- package/src/components/modal/hwr-sync.modal.tsx +194 -106
- package/src/components/users/manage-users/user-details/user-detail.scss +167 -39
- package/src/components/users/manage-users/user-details/user-details.component.tsx +130 -122
- package/src/components/users/manage-users/user-management.workspace.scss +233 -95
- package/src/components/users/manage-users/user-management.workspace.tsx +481 -375
- package/src/components/users/userManagementFormSchema.tsx +17 -8
- package/src/config-schema.ts +48 -68
- package/src/index.ts +9 -1
- package/src/root.component.tsx +2 -0
- package/src/routes.json +20 -1
- package/src/types/index.ts +11 -2
- package/translations/am.json +175 -10
- package/translations/en.json +108 -40
- package/translations/fr.json +171 -101
- package/translations/sw.json +312 -147
- package/.turbo/turbo-build.log +0 -6
- package/dist/1074.js +0 -1
- package/dist/1074.js.map +0 -1
- package/dist/12.js +0 -17
- package/dist/12.js.map +0 -1
- package/dist/1201.js +0 -1
- package/dist/1201.js.map +0 -1
- package/dist/1242.js +0 -1
- package/dist/1242.js.map +0 -1
- package/dist/1311.js +0 -1
- package/dist/1311.js.map +0 -1
- package/dist/1462.js +0 -1
- package/dist/1462.js.map +0 -1
- package/dist/1469.js +0 -1
- package/dist/1469.js.map +0 -1
- package/dist/1506.js +0 -13
- package/dist/1506.js.map +0 -1
- package/dist/1718.js +0 -1
- package/dist/1718.js.map +0 -1
- package/dist/1722.js +0 -1
- package/dist/1722.js.map +0 -1
- package/dist/1772.js +0 -1
- package/dist/1772.js.map +0 -1
- package/dist/1889.js +0 -1
- package/dist/1889.js.map +0 -1
- package/dist/1972.js +0 -1
- package/dist/1972.js.map +0 -1
- package/dist/1990.js +0 -1
- package/dist/1990.js.map +0 -1
- package/dist/2016.js +0 -1
- package/dist/2016.js.map +0 -1
- package/dist/2080.js +0 -1
- package/dist/2080.js.map +0 -1
- package/dist/2096.js +0 -1
- package/dist/2096.js.map +0 -1
- package/dist/2153.js +0 -1
- package/dist/2153.js.map +0 -1
- package/dist/216.js +0 -1
- package/dist/216.js.map +0 -1
- package/dist/2270.js +0 -1
- package/dist/2270.js.map +0 -1
- package/dist/2294.js +0 -1
- package/dist/2294.js.map +0 -1
- package/dist/2345.js +0 -1
- package/dist/2345.js.map +0 -1
- package/dist/2402.js +0 -1
- package/dist/2402.js.map +0 -1
- package/dist/2500.js +0 -1
- package/dist/2500.js.map +0 -1
- package/dist/251.js +0 -1
- package/dist/251.js.map +0 -1
- package/dist/257.js +0 -1
- package/dist/257.js.map +0 -1
- package/dist/2586.js +0 -1
- package/dist/2586.js.map +0 -1
- package/dist/2625.js +0 -1
- package/dist/2625.js.map +0 -1
- package/dist/2652.js +0 -1
- package/dist/2652.js.map +0 -1
- package/dist/2685.js +0 -1
- package/dist/2685.js.map +0 -1
- package/dist/2948.js +0 -1
- package/dist/2948.js.map +0 -1
- package/dist/3089.js +0 -1
- package/dist/3089.js.map +0 -1
- package/dist/3190.js +0 -1
- package/dist/3190.js.map +0 -1
- package/dist/3224.js +0 -1
- package/dist/3224.js.map +0 -1
- package/dist/3366.js +0 -1
- package/dist/3366.js.map +0 -1
- package/dist/349.js +0 -1
- package/dist/349.js.map +0 -1
- package/dist/3548.js +0 -1
- package/dist/3548.js.map +0 -1
- package/dist/3571.js +0 -1
- package/dist/3571.js.map +0 -1
- package/dist/3691.js +0 -1
- package/dist/3691.js.map +0 -1
- package/dist/3775.js +0 -1
- package/dist/3775.js.map +0 -1
- package/dist/3816.js +0 -1
- package/dist/3816.js.map +0 -1
- package/dist/3852.js +0 -1
- package/dist/3852.js.map +0 -1
- package/dist/3906.js +0 -1
- package/dist/3906.js.map +0 -1
- package/dist/3963.js +0 -1
- package/dist/3963.js.map +0 -1
- package/dist/405.js +0 -1
- package/dist/405.js.map +0 -1
- package/dist/4296.js +0 -1
- package/dist/4296.js.map +0 -1
- package/dist/4337.js +0 -1
- package/dist/4337.js.map +0 -1
- package/dist/4735.js +0 -1
- package/dist/4735.js.map +0 -1
- package/dist/4744.js +0 -1
- package/dist/4744.js.map +0 -1
- package/dist/4813.js +0 -2
- package/dist/4813.js.map +0 -1
- package/dist/4858.js +0 -1
- package/dist/4858.js.map +0 -1
- package/dist/487.js +0 -1
- package/dist/487.js.map +0 -1
- package/dist/4970.js +0 -1
- package/dist/4970.js.map +0 -1
- package/dist/5202.js +0 -1
- package/dist/5202.js.map +0 -1
- package/dist/5294.js +0 -1
- package/dist/5294.js.map +0 -1
- package/dist/545.js +0 -1
- package/dist/545.js.map +0 -1
- package/dist/552.js +0 -1
- package/dist/552.js.map +0 -1
- package/dist/5592.js +0 -1
- package/dist/5592.js.map +0 -1
- package/dist/5669.js +0 -1
- package/dist/5669.js.map +0 -1
- package/dist/5884.js +0 -1
- package/dist/5884.js.map +0 -1
- package/dist/5940.js +0 -1
- package/dist/5940.js.map +0 -1
- package/dist/6092.js +0 -1
- package/dist/6092.js.map +0 -1
- package/dist/6155.js +0 -1
- package/dist/6155.js.map +0 -1
- package/dist/6178.js +0 -1
- package/dist/6178.js.map +0 -1
- package/dist/6399.js +0 -1
- package/dist/6399.js.map +0 -1
- package/dist/6456.js +0 -1
- package/dist/6466.js +0 -3
- package/dist/6466.js.map +0 -1
- package/dist/6492.js +0 -1
- package/dist/6492.js.map +0 -1
- package/dist/6676.js +0 -1
- package/dist/6676.js.map +0 -1
- package/dist/6800.js +0 -1
- package/dist/6800.js.map +0 -1
- package/dist/6976.js +0 -1
- package/dist/6976.js.map +0 -1
- package/dist/7005.js +0 -1
- package/dist/7005.js.map +0 -1
- package/dist/7201.js +0 -1
- package/dist/7201.js.map +0 -1
- package/dist/7210.js +0 -1
- package/dist/7210.js.map +0 -1
- package/dist/7234.js +0 -1
- package/dist/7234.js.map +0 -1
- package/dist/7261.js +0 -1
- package/dist/7261.js.map +0 -1
- package/dist/7326.js +0 -1
- package/dist/7463.js +0 -1
- package/dist/7463.js.map +0 -1
- package/dist/7528.js +0 -1
- package/dist/7528.js.map +0 -1
- package/dist/7584.js +0 -1
- package/dist/7584.js.map +0 -1
- package/dist/7607.js +0 -1
- package/dist/7717.js +0 -1
- package/dist/7717.js.map +0 -1
- package/dist/7737.js +0 -1
- package/dist/7737.js.map +0 -1
- package/dist/7739.js +0 -1
- package/dist/7739.js.map +0 -1
- package/dist/7765.js +0 -1
- package/dist/7765.js.map +0 -1
- package/dist/7820.js +0 -1
- package/dist/7820.js.map +0 -1
- package/dist/7844.js +0 -1
- package/dist/7844.js.map +0 -1
- package/dist/7866.js +0 -1
- package/dist/7866.js.map +0 -1
- package/dist/7916.js +0 -1
- package/dist/7916.js.map +0 -1
- package/dist/7971.js +0 -1
- package/dist/7971.js.map +0 -1
- package/dist/8159.js +0 -7
- package/dist/8159.js.map +0 -1
- package/dist/8244.js +0 -1
- package/dist/8244.js.map +0 -1
- package/dist/8262.js +0 -1
- package/dist/8262.js.map +0 -1
- package/dist/834.js +0 -1
- package/dist/834.js.map +0 -1
- package/dist/8376.js +0 -1
- package/dist/8376.js.map +0 -1
- package/dist/845.js +0 -1
- package/dist/845.js.map +0 -1
- package/dist/8546.js +0 -1
- package/dist/8546.js.map +0 -1
- package/dist/8570.js +0 -1
- package/dist/8570.js.map +0 -1
- package/dist/87.js +0 -1
- package/dist/87.js.map +0 -1
- package/dist/8727.js +0 -1
- package/dist/8828.js +0 -1
- package/dist/8828.js.map +0 -1
- package/dist/8860.js +0 -1
- package/dist/8860.js.map +0 -1
- package/dist/9036.js +0 -1
- package/dist/9036.js.map +0 -1
- package/dist/9124.js +0 -1
- package/dist/9124.js.map +0 -1
- package/dist/9182.js +0 -1
- package/dist/921.js +0 -1
- package/dist/921.js.map +0 -1
- package/dist/9404.js +0 -1
- package/dist/9404.js.map +0 -1
- package/dist/9406.js +0 -1
- package/dist/9406.js.map +0 -1
- package/dist/9446.js +0 -1
- package/dist/9446.js.map +0 -1
- package/dist/9449.js +0 -1
- package/dist/9449.js.map +0 -1
- package/dist/9566.js +0 -5
- package/dist/9566.js.map +0 -1
- package/dist/9641.js +0 -1
- package/dist/9641.js.map +0 -1
- package/dist/9711.js +0 -1
- package/dist/9711.js.map +0 -1
- package/dist/9801.js +0 -1
- package/dist/9801.js.map +0 -1
- package/dist/9835.js +0 -11
- package/dist/9835.js.map +0 -1
- package/dist/kenyaemr-esm-admin-app.js +0 -5
- package/dist/kenyaemr-esm-admin-app.js.buildmanifest.json +0 -3173
- package/dist/kenyaemr-esm-admin-app.js.map +0 -1
- package/dist/main.js +0 -5
- package/dist/main.js.map +0 -1
- package/dist/routes.json +0 -1
- package/src/components/facility-setup/facility-setup.resource.tsx +0 -7
- package/src/components/hook/healthWorkerAdapter.ts +0 -213
- package/src/components/hook/useFacilityInfo.tsx +0 -37
|
@@ -1,47 +1,153 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import '@testing-library/jest-dom';
|
|
4
|
+
import { vi, describe, it, expect, beforeEach } from 'vitest';
|
|
4
5
|
import LogTable from './operation-log-table.component';
|
|
5
6
|
import { ETLResponse } from '../../types';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
vi.mock('react-i18next', () => ({
|
|
9
|
+
useTranslation: () => ({ t: (key: string, fallback: string) => fallback }),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
vi.mock('@openmrs/esm-framework', () => ({
|
|
13
|
+
useLayoutType: vi.fn(() => 'desktop'),
|
|
14
|
+
usePagination: vi.fn((data) => ({
|
|
15
|
+
results: data,
|
|
16
|
+
currentPage: 1,
|
|
17
|
+
goTo: vi.fn(),
|
|
18
|
+
})),
|
|
19
|
+
formatDate: vi.fn((date: Date) => date.toISOString()),
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
vi.mock('@openmrs/esm-patient-common-lib', () => ({
|
|
23
|
+
CardHeader: ({ title }: { title: string }) => <div>{title}</div>,
|
|
24
|
+
PatientChartPagination: ({ currentItems, totalItems }: { currentItems: number; totalItems: number }) => (
|
|
25
|
+
<div data-testid="pagination">
|
|
26
|
+
{currentItems}/{totalItems}
|
|
27
|
+
</div>
|
|
28
|
+
),
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
vi.mock('../empty-state/empty-state-log.components', () => ({
|
|
32
|
+
default: ({ subTitle }: { subTitle: string }) => <div data-testid="empty-state">{subTitle}</div>,
|
|
33
|
+
}));
|
|
34
|
+
|
|
35
|
+
vi.mock('@carbon/react', async (importOriginal) => {
|
|
36
|
+
const original = await importOriginal<typeof import('@carbon/react')>();
|
|
37
|
+
return {
|
|
38
|
+
...original,
|
|
39
|
+
DataTable: ({
|
|
40
|
+
children,
|
|
41
|
+
rows,
|
|
42
|
+
headers,
|
|
43
|
+
}: {
|
|
44
|
+
children: (props: any) => React.ReactNode;
|
|
45
|
+
rows: any[];
|
|
46
|
+
headers: any[];
|
|
47
|
+
}) => {
|
|
48
|
+
if (typeof children === 'function') {
|
|
49
|
+
const renderRows = rows.map((row) => ({
|
|
50
|
+
...row,
|
|
51
|
+
cells: headers.map((h) => ({
|
|
52
|
+
id: `${row.id}:${h.key}`,
|
|
53
|
+
value: row[h.key],
|
|
54
|
+
info: { header: h.key },
|
|
55
|
+
})),
|
|
56
|
+
}));
|
|
57
|
+
return children({
|
|
58
|
+
rows: renderRows,
|
|
59
|
+
headers,
|
|
60
|
+
getTableProps: () => ({}),
|
|
61
|
+
getHeaderProps: ({ header }: any) => ({ key: header.key }),
|
|
62
|
+
getRowProps: () => ({}),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return children;
|
|
20
66
|
},
|
|
21
|
-
|
|
67
|
+
};
|
|
68
|
+
});
|
|
22
69
|
|
|
23
|
-
|
|
24
|
-
render(<LogTable logData={mockLogData} isLoading={false} />);
|
|
70
|
+
vi.mock('classnames', () => ({ default: (...args: string[]) => args.filter(Boolean).join(' ') }));
|
|
25
71
|
|
|
26
|
-
|
|
27
|
-
headers.forEach((header) => {
|
|
28
|
-
expect(screen.getByText(header)).toBeInTheDocument();
|
|
29
|
-
});
|
|
72
|
+
vi.mock('./operation-log.scss', () => ({ default: {} }));
|
|
30
73
|
|
|
31
|
-
|
|
32
|
-
|
|
74
|
+
const mockLogData: ETLResponse[] = [
|
|
75
|
+
{
|
|
76
|
+
script_name: 'Script A',
|
|
77
|
+
start_time: '2024-01-01T08:00:00Z',
|
|
78
|
+
stop_time: '2024-01-01T09:00:00Z',
|
|
79
|
+
status: 'Success',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
script_name: 'Script B',
|
|
83
|
+
start_time: '2024-01-02T10:00:00Z',
|
|
84
|
+
stop_time: '2024-01-02T11:00:00Z',
|
|
85
|
+
status: 'Failed',
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
describe('LogTable', () => {
|
|
90
|
+
beforeEach(() => {
|
|
91
|
+
vi.clearAllMocks();
|
|
33
92
|
});
|
|
34
93
|
|
|
35
|
-
it('
|
|
36
|
-
render(<LogTable logData={
|
|
94
|
+
it('renders the card header', () => {
|
|
95
|
+
render(<LogTable logData={mockLogData} isLoading={false} />);
|
|
96
|
+
expect(screen.getByText('Facility Info')).toBeInTheDocument();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('shows skeleton while loading with no data', () => {
|
|
100
|
+
render(<LogTable logData={[]} isLoading={true} />);
|
|
101
|
+
expect(screen.getByRole('table')).toBeInTheDocument();
|
|
102
|
+
});
|
|
37
103
|
|
|
104
|
+
it('shows empty state when not loading and no data', () => {
|
|
105
|
+
render(<LogTable logData={[]} isLoading={false} />);
|
|
106
|
+
expect(screen.getByTestId('empty-state')).toBeInTheDocument();
|
|
38
107
|
expect(screen.getByText('No ETL Operation logs found')).toBeInTheDocument();
|
|
39
108
|
});
|
|
40
109
|
|
|
41
|
-
it('
|
|
42
|
-
render(<LogTable logData={
|
|
110
|
+
it('renders table headers when data is present', () => {
|
|
111
|
+
render(<LogTable logData={mockLogData} isLoading={false} />);
|
|
112
|
+
expect(screen.getByText('Procedure')).toBeInTheDocument();
|
|
113
|
+
expect(screen.getByText('Start time')).toBeInTheDocument();
|
|
114
|
+
expect(screen.getByText('End time')).toBeInTheDocument();
|
|
115
|
+
expect(screen.getByText('Completion status')).toBeInTheDocument();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('renders script names in the table', () => {
|
|
119
|
+
render(<LogTable logData={mockLogData} isLoading={false} />);
|
|
120
|
+
expect(screen.getByText('Script A')).toBeInTheDocument();
|
|
121
|
+
expect(screen.getByText('Script B')).toBeInTheDocument();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('renders Success status as a green tag', () => {
|
|
125
|
+
render(<LogTable logData={mockLogData} isLoading={false} />);
|
|
126
|
+
const successTag = screen.getByText('Success');
|
|
127
|
+
expect(successTag).toBeInTheDocument();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('renders Failed status as a red tag', () => {
|
|
131
|
+
render(<LogTable logData={mockLogData} isLoading={false} />);
|
|
132
|
+
const failedTag = screen.getByText('Failed');
|
|
133
|
+
expect(failedTag).toBeInTheDocument();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('renders pagination when data is present', () => {
|
|
137
|
+
render(<LogTable logData={mockLogData} isLoading={false} />);
|
|
138
|
+
expect(screen.getByTestId('pagination')).toBeInTheDocument();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('renders -- for missing start_time', () => {
|
|
142
|
+
const dataWithMissingTime: ETLResponse[] = [
|
|
143
|
+
{ script_name: 'Script C', start_time: '', stop_time: '', status: 'Success' },
|
|
144
|
+
];
|
|
145
|
+
render(<LogTable logData={dataWithMissingTime} isLoading={false} />);
|
|
146
|
+
expect(screen.getAllByText('--').length).toBeGreaterThanOrEqual(2);
|
|
147
|
+
});
|
|
43
148
|
|
|
44
|
-
|
|
45
|
-
|
|
149
|
+
it('does not show empty state when data is present', () => {
|
|
150
|
+
render(<LogTable logData={mockLogData} isLoading={false} />);
|
|
151
|
+
expect(screen.queryByTestId('empty-state')).not.toBeInTheDocument();
|
|
46
152
|
});
|
|
47
153
|
});
|
|
@@ -2,20 +2,96 @@
|
|
|
2
2
|
@use '@carbon/layout';
|
|
3
3
|
@use '@carbon/type';
|
|
4
4
|
|
|
5
|
+
.modalIntro {
|
|
6
|
+
margin-bottom: layout.$spacing-05;
|
|
7
|
+
color: colors.$gray-70;
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
.healthWorkerInfoContainer {
|
|
6
11
|
display: grid;
|
|
7
|
-
grid-template-columns: 0.
|
|
8
|
-
margin: layout.$spacing-02;
|
|
12
|
+
grid-template-columns: 0.4fr 0.6fr;
|
|
13
|
+
margin: layout.$spacing-02 0;
|
|
14
|
+
font-size: 0.875rem;
|
|
9
15
|
}
|
|
16
|
+
|
|
10
17
|
.healthWorkerInfoLabel {
|
|
11
18
|
min-width: layout.$spacing-11;
|
|
12
|
-
font-weight:
|
|
19
|
+
font-weight: 600;
|
|
20
|
+
color: colors.$gray-70;
|
|
13
21
|
}
|
|
22
|
+
|
|
14
23
|
.healthWorkerOverview {
|
|
15
24
|
display: flex;
|
|
16
|
-
|
|
25
|
+
align-items: center;
|
|
26
|
+
margin: layout.$spacing-05 0;
|
|
27
|
+
padding: layout.$spacing-05;
|
|
28
|
+
background-color: colors.$gray-10;
|
|
29
|
+
border-radius: 4px;
|
|
17
30
|
}
|
|
31
|
+
|
|
18
32
|
.healthWorkerPhoto {
|
|
19
33
|
display: flex;
|
|
20
34
|
align-items: center;
|
|
35
|
+
flex-shrink: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.healthWorkerSummary {
|
|
39
|
+
flex: 1;
|
|
40
|
+
margin-left: layout.$spacing-05;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.healthWorkerName {
|
|
44
|
+
margin: 0 0 layout.$spacing-02 0;
|
|
45
|
+
font-size: 1.25rem;
|
|
46
|
+
font-weight: 600;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.healthWorkerSubtitle {
|
|
50
|
+
color: colors.$gray-70;
|
|
51
|
+
font-size: 0.875rem;
|
|
52
|
+
margin-bottom: layout.$spacing-03;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.tagRow {
|
|
56
|
+
display: flex;
|
|
57
|
+
gap: layout.$spacing-02;
|
|
58
|
+
flex-wrap: wrap;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.sectionHeading {
|
|
62
|
+
margin: layout.$spacing-05 0 layout.$spacing-03 0;
|
|
63
|
+
padding-bottom: layout.$spacing-02;
|
|
64
|
+
border-bottom: 1px solid colors.$gray-20;
|
|
65
|
+
font-size: 0.875rem;
|
|
66
|
+
font-weight: 600;
|
|
67
|
+
text-transform: uppercase;
|
|
68
|
+
letter-spacing: 0.04em;
|
|
69
|
+
color: colors.$gray-70;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.licenseList {
|
|
73
|
+
display: flex;
|
|
74
|
+
flex-direction: column;
|
|
75
|
+
gap: layout.$spacing-03;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.licenseCard {
|
|
79
|
+
padding: layout.$spacing-04;
|
|
80
|
+
border: 1px solid colors.$gray-20;
|
|
81
|
+
border-radius: 4px;
|
|
82
|
+
background-color: colors.$white;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.licenseHeader {
|
|
86
|
+
display: flex;
|
|
87
|
+
justify-content: space-between;
|
|
88
|
+
align-items: center;
|
|
89
|
+
margin-bottom: layout.$spacing-03;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.licenseType {
|
|
93
|
+
font-weight: 600;
|
|
94
|
+
text-transform: uppercase;
|
|
95
|
+
font-size: 0.75rem;
|
|
96
|
+
letter-spacing: 0.04em;
|
|
21
97
|
}
|
|
@@ -1,162 +1,152 @@
|
|
|
1
|
-
import { Button, Tag } from '@carbon/react';
|
|
1
|
+
import { Button, Tag, SkeletonText } from '@carbon/react';
|
|
2
2
|
import { ExtensionSlot } from '@openmrs/esm-framework';
|
|
3
|
-
import
|
|
4
|
-
import React from 'react';
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
5
4
|
import { useTranslation } from 'react-i18next';
|
|
6
|
-
import {
|
|
7
|
-
import { NormalizedPractitioner } from '../hook/healthWorkerAdapter';
|
|
8
|
-
import styles from './hwr-confirmation.modal.scss';
|
|
5
|
+
import { ProfessionalRegistryResponse } from '../hook/healthWorkerRegistry';
|
|
9
6
|
import { formatDateTime } from '../../utils/utils';
|
|
10
|
-
|
|
11
|
-
interface HealthWorkerInfoProps {
|
|
12
|
-
label: string;
|
|
13
|
-
value: string | boolean | React.ReactNode;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const HealthWorkerInfo: React.FC<HealthWorkerInfoProps> = ({ label, value }) => {
|
|
17
|
-
return (
|
|
18
|
-
<div className={styles.healthWorkerInfoContainer}>
|
|
19
|
-
<span className={styles.healthWorkerInfoLabel}>{label}</span>
|
|
20
|
-
<span>{value}</span>
|
|
21
|
-
</div>
|
|
22
|
-
);
|
|
23
|
-
};
|
|
7
|
+
import styles from './hwr-confirmation.modal.scss';
|
|
24
8
|
|
|
25
9
|
interface HWRConfirmModalProps {
|
|
26
10
|
onConfirm: () => void;
|
|
27
11
|
close: () => void;
|
|
28
|
-
healthWorker:
|
|
29
|
-
normalizedData: NormalizedPractitioner;
|
|
30
|
-
fhirFormat: boolean;
|
|
12
|
+
healthWorker: ProfessionalRegistryResponse;
|
|
31
13
|
}
|
|
32
14
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
15
|
+
type License = NonNullable<ProfessionalRegistryResponse['professional']['licenses']>[number];
|
|
16
|
+
|
|
17
|
+
const InfoRow: React.FC<{ label: string; value: React.ReactNode }> = ({ label, value }) => (
|
|
18
|
+
<div className={styles.healthWorkerInfoContainer}>
|
|
19
|
+
<span className={styles.healthWorkerInfoLabel}>{label}</span>
|
|
20
|
+
<span>{value || '--'}</span>
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const SectionHeading: React.FC<{ children: React.ReactNode }> = ({ children }) => (
|
|
25
|
+
<div className={styles.sectionHeading}>{children}</div>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const useCurrentLicense = (licenses: Array<License> = []): License | undefined =>
|
|
29
|
+
useMemo(() => {
|
|
30
|
+
if (licenses.length === 0) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
const sorted = [...licenses]
|
|
34
|
+
.filter((l) => l.license_end)
|
|
35
|
+
.sort((a, b) => new Date(b.license_end).getTime() - new Date(a.license_end).getTime());
|
|
36
|
+
const now = Date.now();
|
|
37
|
+
return sorted.find((l) => new Date(l.license_end).getTime() >= now) ?? sorted[0];
|
|
38
|
+
}, [licenses]);
|
|
39
|
+
|
|
40
|
+
const HWRConfirmModal: React.FC<HWRConfirmModalProps> = ({ close, onConfirm, healthWorker }) => {
|
|
40
41
|
const { t } = useTranslation();
|
|
42
|
+
const { professional } = healthWorker;
|
|
43
|
+
const { membership, licenses, contacts, identifiers, professional_details } = professional;
|
|
41
44
|
|
|
42
|
-
const
|
|
45
|
+
const currentLicense = useCurrentLicense(licenses);
|
|
46
|
+
const isLicenseValid = currentLicense?.license_end ? new Date(currentLicense.license_end) > new Date() : false;
|
|
43
47
|
|
|
44
48
|
return (
|
|
45
49
|
<>
|
|
46
50
|
<div className="cds--modal-header">
|
|
47
51
|
<h3 className="cds--modal-header__heading">{t('healthWorkerRegistry', 'Health worker registry')}</h3>
|
|
48
52
|
</div>
|
|
53
|
+
|
|
49
54
|
<div className="cds--modal-content">
|
|
50
|
-
<p>
|
|
55
|
+
<p className={styles.modalIntro}>
|
|
51
56
|
{t(
|
|
52
57
|
'healthWorkerDetailsFound',
|
|
53
|
-
'Health worker
|
|
58
|
+
'Health worker found in the registry. Use this information to pre-fill the registration form?',
|
|
54
59
|
)}
|
|
55
60
|
</p>
|
|
61
|
+
|
|
56
62
|
<div className={styles.healthWorkerOverview}>
|
|
57
63
|
<ExtensionSlot
|
|
58
64
|
className={styles.healthWorkerPhoto}
|
|
59
65
|
name="patient-photo-slot"
|
|
60
|
-
state={{
|
|
61
|
-
patientName: normalizedData.fullName || '',
|
|
62
|
-
}}
|
|
66
|
+
state={{ patientName: membership.full_name || '' }}
|
|
63
67
|
/>
|
|
64
|
-
<div
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
{
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
)}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
<
|
|
128
|
-
label={`${license.license_type} ${t('license', 'License')}`}
|
|
129
|
-
value={license.external_reference_id || '--'}
|
|
130
|
-
/>
|
|
131
|
-
<HealthWorkerInfo
|
|
68
|
+
<div className={styles.healthWorkerSummary}>
|
|
69
|
+
<h4 className={styles.healthWorkerName}>{membership.full_name || '--'}</h4>
|
|
70
|
+
<div className={styles.healthWorkerSubtitle}>
|
|
71
|
+
{membership.specialty || t('practitioner', 'Practitioner')}
|
|
72
|
+
{membership.licensing_body && ` · ${membership.licensing_body}`}
|
|
73
|
+
</div>
|
|
74
|
+
<div className={styles.tagRow}>
|
|
75
|
+
<Tag type={membership.is_active === 1 ? 'green' : 'gray'} size="md">
|
|
76
|
+
{membership.is_active === 1 ? t('active', 'Active') : t('inactive', 'Inactive')}
|
|
77
|
+
</Tag>
|
|
78
|
+
<Tag type={isLicenseValid ? 'green' : 'red'} size="md">
|
|
79
|
+
{isLicenseValid ? t('licenseValid', 'License valid') : t('licenseExpired', 'License expired')}
|
|
80
|
+
</Tag>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<SectionHeading>{t('identity', 'Identity')}</SectionHeading>
|
|
86
|
+
<InfoRow label={t('providerUniqueIdentifier', 'Provider unique identifier')} value={membership.id} />
|
|
87
|
+
<InfoRow label={t('registrationId', 'Registration ID')} value={membership.registration_id} />
|
|
88
|
+
<InfoRow label={t('externalReferenceId', 'External reference ID')} value={membership.external_reference_id} />
|
|
89
|
+
<InfoRow label={t('gender', 'Gender')} value={membership.gender} />
|
|
90
|
+
{identifiers?.identification_number && (
|
|
91
|
+
<InfoRow
|
|
92
|
+
label={t('identificationNumber', 'Identification number')}
|
|
93
|
+
value={`${identifiers.identification_type ?? ''} ${identifiers.identification_number}`.trim()}
|
|
94
|
+
/>
|
|
95
|
+
)}
|
|
96
|
+
|
|
97
|
+
<SectionHeading>{t('licensing', 'Licensing & qualifications')}</SectionHeading>
|
|
98
|
+
<InfoRow label={t('licensingBody', 'Licensing body')} value={membership.licensing_body} />
|
|
99
|
+
<InfoRow label={t('specialty', 'Specialty')} value={membership.specialty} />
|
|
100
|
+
{professional_details?.professional_cadre && (
|
|
101
|
+
<InfoRow
|
|
102
|
+
label={t('professionalCadre', 'Professional cadre')}
|
|
103
|
+
value={professional_details.professional_cadre}
|
|
104
|
+
/>
|
|
105
|
+
)}
|
|
106
|
+
{professional_details?.practice_type && (
|
|
107
|
+
<InfoRow label={t('practiceType', 'Practice type')} value={professional_details.practice_type} />
|
|
108
|
+
)}
|
|
109
|
+
{professional_details?.educational_qualifications && (
|
|
110
|
+
<InfoRow
|
|
111
|
+
label={t('qualification', 'Qualification')}
|
|
112
|
+
value={professional_details.educational_qualifications}
|
|
113
|
+
/>
|
|
114
|
+
)}
|
|
115
|
+
|
|
116
|
+
{licenses && licenses.length > 0 && (
|
|
117
|
+
<>
|
|
118
|
+
<SectionHeading>{t('licenses', 'Licenses')}</SectionHeading>
|
|
119
|
+
<div className={styles.licenseList}>
|
|
120
|
+
{licenses.map((license) => {
|
|
121
|
+
const expired = license.license_end && new Date(license.license_end) < new Date();
|
|
122
|
+
return (
|
|
123
|
+
<div key={license.id} className={styles.licenseCard}>
|
|
124
|
+
<div className={styles.licenseHeader}>
|
|
125
|
+
<span className={styles.licenseType}>{license.license_type}</span>
|
|
126
|
+
<Tag type={expired ? 'red' : 'green'} size="sm">
|
|
127
|
+
{expired ? t('expired', 'Expired') : t('valid', 'Valid')}
|
|
128
|
+
</Tag>
|
|
129
|
+
</div>
|
|
130
|
+
<InfoRow label={t('licenseNumber', 'License no.')} value={license.external_reference_id} />
|
|
131
|
+
<InfoRow
|
|
132
132
|
label={t('validity', 'Validity')}
|
|
133
|
-
value={`${formatDateTime(license.license_start)}
|
|
133
|
+
value={`${formatDateTime(license.license_start)} → ${formatDateTime(license.license_end)}`}
|
|
134
134
|
/>
|
|
135
135
|
</div>
|
|
136
|
-
)
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
<HealthWorkerInfo
|
|
150
|
-
label={t('licenseValid', 'License Validity')}
|
|
151
|
-
value={
|
|
152
|
-
<Tag type={isLicenseValid ? 'green' : 'red'}>
|
|
153
|
-
{isLicenseValid ? t('licenseValid', 'License Valid') : t('licenseExpired', 'License Expired')}
|
|
154
|
-
</Tag>
|
|
155
|
-
}
|
|
156
|
-
/>
|
|
157
|
-
</div>
|
|
158
|
-
</div>
|
|
136
|
+
);
|
|
137
|
+
})}
|
|
138
|
+
</div>
|
|
139
|
+
</>
|
|
140
|
+
)}
|
|
141
|
+
|
|
142
|
+
<SectionHeading>{t('contact', 'Contact')}</SectionHeading>
|
|
143
|
+
<InfoRow label={t('phone', 'Phone')} value={contacts?.phone} />
|
|
144
|
+
<InfoRow label={t('email', 'Email')} value={contacts?.email} />
|
|
145
|
+
{contacts?.postal_address && (
|
|
146
|
+
<InfoRow label={t('postalAddress', 'Postal address')} value={contacts.postal_address} />
|
|
147
|
+
)}
|
|
159
148
|
</div>
|
|
149
|
+
|
|
160
150
|
<div className="cds--modal-footer">
|
|
161
151
|
<Button kind="secondary" onClick={close}>
|
|
162
152
|
{t('cancel', 'Cancel')}
|