@kenyaemr/esm-bed-management-app 1.0.1-pre.11
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/.editorconfig +12 -0
- package/.eslintignore +2 -0
- package/.eslintrc +37 -0
- package/.husky/pre-commit +4 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.prettierignore +14 -0
- package/.turbo.json +18 -0
- package/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs +541 -0
- package/.yarn/plugins/@yarnpkg/plugin-version.cjs +550 -0
- package/.yarn/versions/3d353a50.yml +0 -0
- package/LICENSE +373 -0
- package/README.md +40 -0
- package/dist/207.js +1 -0
- package/dist/207.js.map +1 -0
- package/dist/26.js +2 -0
- package/dist/26.js.LICENSE.txt +32 -0
- package/dist/26.js.map +1 -0
- package/dist/283.js +1 -0
- package/dist/283.js.map +1 -0
- package/dist/294.js +2 -0
- package/dist/294.js.LICENSE.txt +9 -0
- package/dist/294.js.map +1 -0
- package/dist/330.js +2 -0
- package/dist/330.js.LICENSE.txt +44 -0
- package/dist/330.js.map +1 -0
- package/dist/404.js +1 -0
- package/dist/404.js.map +1 -0
- package/dist/455.js +2 -0
- package/dist/455.js.LICENSE.txt +9 -0
- package/dist/455.js.map +1 -0
- package/dist/558.js +2 -0
- package/dist/558.js.LICENSE.txt +14 -0
- package/dist/558.js.map +1 -0
- package/dist/574.js +1 -0
- package/dist/629.js +1 -0
- package/dist/629.js.map +1 -0
- package/dist/637.js +1 -0
- package/dist/637.js.map +1 -0
- package/dist/707.js +1 -0
- package/dist/707.js.map +1 -0
- package/dist/800.js +2 -0
- package/dist/800.js.LICENSE.txt +3 -0
- package/dist/800.js.map +1 -0
- package/dist/850.js +1 -0
- package/dist/850.js.map +1 -0
- package/dist/884.js +1 -0
- package/dist/884.js.map +1 -0
- package/dist/933.js +1 -0
- package/dist/933.js.map +1 -0
- package/dist/esm-kenyaemr-bed-management-app.js +1 -0
- package/dist/esm-kenyaemr-bed-management-app.js.buildmanifest.json +506 -0
- package/dist/esm-kenyaemr-bed-management-app.js.map +1 -0
- package/dist/main.js +1 -0
- package/dist/main.js.map +1 -0
- package/dist/routes.json +1 -0
- package/i18next-parser.config.js +89 -0
- package/jest.config.js +0 -0
- package/package.json +112 -0
- package/src/__mocks__/react-i18next.js +55 -0
- package/src/admin-card-link.component.tsx +27 -0
- package/src/assets/landing-page.png +0 -0
- package/src/assets/logo.svg +1 -0
- package/src/bed-administration/bed-administration-form.component.tsx +326 -0
- package/src/bed-administration/bed-administration-form.scss +0 -0
- package/src/bed-administration/bed-administration-table.component.tsx +317 -0
- package/src/bed-administration/bed-administration-table.scss +112 -0
- package/src/bed-administration/bed-administration-types.ts +20 -0
- package/src/bed-administration/bed-administration.resource.ts +59 -0
- package/src/bed-administration/edit-bed-form.component.tsx +100 -0
- package/src/bed-administration/new-bed-form.component.tsx +112 -0
- package/src/bed-admission/active-patients/active-patients-table.component.tsx +299 -0
- package/src/bed-admission/active-patients/active-visits.resource.ts +171 -0
- package/src/bed-admission/active-patients/admission-action-button-styles.scss +0 -0
- package/src/bed-admission/active-patients/admission-action-button.component.tsx +26 -0
- package/src/bed-admission/active-patients/index.tsx +15 -0
- package/src/bed-admission/active-patients/patient-queues.resource.ts +136 -0
- package/src/bed-admission/active-patients/styles.scss +284 -0
- package/src/bed-admission/active-patients/view-action-menu.component.tsx +33 -0
- package/src/bed-admission/admitted-patients/active-admissions.resource.ts +125 -0
- package/src/bed-admission/admitted-patients/admitted-patients-table.component.tsx +280 -0
- package/src/bed-admission/admitted-patients/admitted-patients.component.tsx +22 -0
- package/src/bed-admission/admitted-patients/location-combo-box.component.tsx +55 -0
- package/src/bed-admission/admitted-patients/styles.scss +284 -0
- package/src/bed-admission/bed-admission-tabs-styles.scss +30 -0
- package/src/bed-admission/bed-admission-tabs.component.tsx +69 -0
- package/src/bed-admission/bed-admission.component.tsx +15 -0
- package/src/bed-admission/bed-admission.resource.ts +52 -0
- package/src/bed-admission/bed-layout/bed-layout-list.component.tsx +101 -0
- package/src/bed-admission/bed-layout/bed-layout.component.tsx +64 -0
- package/src/bed-admission/bed-layout/bed-layout.scss +118 -0
- package/src/bed-admission/bed-layout/min-bed-layout.component.tsx +26 -0
- package/src/bed-admission/bed-tag/bed-tag-administration-table.component.tsx +217 -0
- package/src/bed-admission/bed-tag/bed-tags-admin-form.component.tsx +131 -0
- package/src/bed-admission/bed-tag/edit-tag-form.component.tsx +80 -0
- package/src/bed-admission/bed-tag/new-tag-form.component.tsx +83 -0
- package/src/bed-admission/bed-type/bed-type-admin-form.component.tsx +173 -0
- package/src/bed-admission/bed-type/bed-type-administration-table.component.tsx +222 -0
- package/src/bed-admission/bed-type/edit-bed-type.component.tsx +80 -0
- package/src/bed-admission/bed-type/new-bed-type-form.component.tsx +87 -0
- package/src/bed-admission/createDashboardLink.tsx +47 -0
- package/src/bed-admission/discharged-patients/discharged-patients.componet.tsx +19 -0
- package/src/bed-admission/helpers/functions.ts +102 -0
- package/src/bed-admission/types.ts +133 -0
- package/src/config-schema.ts +31 -0
- package/src/declarations.d.ts +7 -0
- package/src/empty-state/empty-state.component.tsx +69 -0
- package/src/empty-state/empty-state.scss +62 -0
- package/src/header/header.component.tsx +51 -0
- package/src/header/header.scss +72 -0
- package/src/header/illustration.component.tsx +13 -0
- package/src/home.component.tsx +15 -0
- package/src/home.scss +5 -0
- package/src/index.ts +78 -0
- package/src/left-panel/left-panel.component.tsx +33 -0
- package/src/left-panel/left-panel.scss +41 -0
- package/src/left-panel-link.component.tsx +49 -0
- package/src/root.component.tsx +39 -0
- package/src/root.scss +11 -0
- package/src/routes.json +56 -0
- package/src/setup-tests.ts +1 -0
- package/src/summary/summary.component.tsx +74 -0
- package/src/summary/summary.resource.ts +211 -0
- package/src/summary/summary.scss +72 -0
- package/src/types.ts +163 -0
- package/src/ward-card/ward-card.component.tsx +41 -0
- package/src/ward-card/ward-card.scss +51 -0
- package/src/ward-with-beds/ward-with-beds.component.tsx +186 -0
- package/src/ward-with-beds/ward-with-beds.scss +27 -0
- package/src/workspace/allocate-bed-workspace.component.tsx +188 -0
- package/src/workspace/allocate-bed.scss +124 -0
- package/src/workspace/overlay.component.tsx +55 -0
- package/src/workspace/overlay.scss +96 -0
- package/translations/en.json +7 -0
- package/tsconfig.json +23 -0
- package/webpack.config.js +1 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import useSWR from "swr";
|
|
3
|
+
|
|
4
|
+
import { formatDate, openmrsFetch, parseDate } from "@openmrs/esm-framework";
|
|
5
|
+
import { PatientQueue, UuidDisplay } from "../types";
|
|
6
|
+
|
|
7
|
+
export interface MappedPatientQueueEntry {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
patientAge: number;
|
|
11
|
+
patientSex: string;
|
|
12
|
+
patientDob: string;
|
|
13
|
+
patientUuid: string;
|
|
14
|
+
priority: string;
|
|
15
|
+
priorityComment: string;
|
|
16
|
+
status: string;
|
|
17
|
+
waitTime: string;
|
|
18
|
+
locationFrom?: string;
|
|
19
|
+
locationToName?: string;
|
|
20
|
+
visitNumber: string;
|
|
21
|
+
identifiers: Array<UuidDisplay>;
|
|
22
|
+
dateCreated: string;
|
|
23
|
+
creatorUuid: string;
|
|
24
|
+
creatorUsername: string;
|
|
25
|
+
creatorDisplay: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function usePatientQueuesList(
|
|
29
|
+
currentQueueRoomLocationUuid: string,
|
|
30
|
+
status: string
|
|
31
|
+
) {
|
|
32
|
+
const apiUrl = `/ws/rest/v1/patientqueue?v=full&room=${currentQueueRoomLocationUuid}&status=${status}`;
|
|
33
|
+
return usePatientQueueRequest(apiUrl);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function usePatientQueueRequest(apiUrl: string) {
|
|
37
|
+
const { data, error, isLoading, isValidating, mutate } = useSWR<
|
|
38
|
+
{ data: { results: Array<PatientQueue> } },
|
|
39
|
+
Error
|
|
40
|
+
>(apiUrl, openmrsFetch, { refreshInterval: 3000 });
|
|
41
|
+
|
|
42
|
+
const mapppedQueues = data?.data?.results.map((queue: PatientQueue) => {
|
|
43
|
+
return {
|
|
44
|
+
...queue,
|
|
45
|
+
id: queue.uuid,
|
|
46
|
+
name: queue.patient?.person.display,
|
|
47
|
+
patientUuid: queue.patient?.uuid,
|
|
48
|
+
priorityComment: queue.priorityComment,
|
|
49
|
+
priority:
|
|
50
|
+
queue.priorityComment === "Urgent" ? "Priority" : queue.priorityComment,
|
|
51
|
+
priorityLevel: queue.priority,
|
|
52
|
+
waitTime: queue.dateCreated
|
|
53
|
+
? `${dayjs().diff(dayjs(queue.dateCreated), "minutes")}`
|
|
54
|
+
: "--",
|
|
55
|
+
status: queue.status,
|
|
56
|
+
patientAge: queue.patient?.person?.age,
|
|
57
|
+
patientSex: queue.patient?.person?.gender === "M" ? "MALE" : "FEMALE",
|
|
58
|
+
patientDob: queue.patient?.person?.birthdate
|
|
59
|
+
? formatDate(parseDate(queue.patient.person.birthdate), { time: false })
|
|
60
|
+
: "--",
|
|
61
|
+
identifiers: queue.patient?.identifiers,
|
|
62
|
+
locationFrom: queue.locationFrom?.uuid,
|
|
63
|
+
locationTo: queue.locationTo?.uuid,
|
|
64
|
+
locationFromName: queue.locationFrom?.name,
|
|
65
|
+
locationToName: queue.locationTo?.name,
|
|
66
|
+
queueRoom: queue.locationTo?.display,
|
|
67
|
+
visitNumber: queue.visitNumber,
|
|
68
|
+
dateCreated: queue.dateCreated
|
|
69
|
+
? formatDate(parseDate(queue.dateCreated), { time: false })
|
|
70
|
+
: "--",
|
|
71
|
+
creatorUuid: queue.creator?.uuid,
|
|
72
|
+
creatorUsername: queue.creator?.username,
|
|
73
|
+
creatorDisplay: queue.creator?.display,
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
patientQueueEntries: mapppedQueues || [],
|
|
79
|
+
patientQueueCount: mapppedQueues?.length,
|
|
80
|
+
isLoading,
|
|
81
|
+
isError: error,
|
|
82
|
+
isValidating,
|
|
83
|
+
mutate,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function usePatientActiveListRequest(apiUrl: string) {
|
|
88
|
+
const { data, error, isLoading, isValidating, mutate } = useSWR<
|
|
89
|
+
{ data: { results: Array<PatientQueue> } },
|
|
90
|
+
Error
|
|
91
|
+
>(apiUrl, openmrsFetch, { refreshInterval: 3000 });
|
|
92
|
+
|
|
93
|
+
const mapppedQueues = data?.data?.results.map((queue: PatientQueue) => {
|
|
94
|
+
return {
|
|
95
|
+
...queue,
|
|
96
|
+
id: queue.uuid,
|
|
97
|
+
name: queue.patient?.person.display,
|
|
98
|
+
patientUuid: queue.patient?.uuid,
|
|
99
|
+
priorityComment: queue.priorityComment,
|
|
100
|
+
priority:
|
|
101
|
+
queue.priorityComment === "Urgent" ? "Priority" : queue.priorityComment,
|
|
102
|
+
priorityLevel: queue.priority,
|
|
103
|
+
waitTime: queue.dateCreated
|
|
104
|
+
? `${dayjs().diff(dayjs(queue.dateCreated), "minutes")}`
|
|
105
|
+
: "--",
|
|
106
|
+
status: queue.status,
|
|
107
|
+
patientAge: queue.patient?.person?.age,
|
|
108
|
+
patientSex: queue.patient?.person?.gender === "M" ? "MALE" : "FEMALE",
|
|
109
|
+
patientDob: queue.patient?.person?.birthdate
|
|
110
|
+
? formatDate(parseDate(queue.patient.person.birthdate), { time: false })
|
|
111
|
+
: "--",
|
|
112
|
+
identifiers: queue.patient?.identifiers,
|
|
113
|
+
locationFrom: queue.locationFrom?.uuid,
|
|
114
|
+
locationTo: queue.locationTo?.uuid,
|
|
115
|
+
locationFromName: queue.locationFrom?.name,
|
|
116
|
+
locationToName: queue.locationTo?.name,
|
|
117
|
+
queueRoom: queue.locationTo?.display,
|
|
118
|
+
visitNumber: queue.visitNumber,
|
|
119
|
+
dateCreated: queue.dateCreated
|
|
120
|
+
? formatDate(parseDate(queue.dateCreated), { time: false })
|
|
121
|
+
: "--",
|
|
122
|
+
creatorUuid: queue.creator?.uuid,
|
|
123
|
+
creatorUsername: queue.creator?.username,
|
|
124
|
+
creatorDisplay: queue.creator?.display,
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
patientQueueEntries: mapppedQueues || [],
|
|
130
|
+
patientQueueCount: mapppedQueues?.length,
|
|
131
|
+
isLoading,
|
|
132
|
+
isError: error,
|
|
133
|
+
isValidating,
|
|
134
|
+
mutate,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
@use '@carbon/type';
|
|
2
|
+
@use '@carbon/colors';
|
|
3
|
+
@use '@carbon/styles/scss/spacing';
|
|
4
|
+
@import '~@openmrs/esm-styleguide/src/vars';
|
|
5
|
+
|
|
6
|
+
.container {
|
|
7
|
+
background-color: $ui-01;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.displayFlex {
|
|
11
|
+
display: flex;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.section {
|
|
15
|
+
border-right: 1px solid colors.$gray-20;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.activePatientsTable tr:last-of-type {
|
|
19
|
+
td {
|
|
20
|
+
border-bottom: none;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.headerContainer {
|
|
25
|
+
display: flex;
|
|
26
|
+
justify-content: space-between;
|
|
27
|
+
align-items: center;
|
|
28
|
+
background-color: $ui-background;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.headerButtons {
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-flow: column;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.heading {
|
|
37
|
+
font-size: 20px;
|
|
38
|
+
font-weight: bold;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.filterContainer {
|
|
42
|
+
:global(.cds--dropdown__wrapper--inline) {
|
|
43
|
+
gap: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
:global(.cds--list-box__menu-icon) {
|
|
47
|
+
height: 1rem;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
:global(.cds--dropdown--inline) :global(.cds--list-box__field) {
|
|
51
|
+
min-width: 12rem;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.tooltip :global(.cds--tooltip__trigger.cds--tooltip__trigger--definition) {
|
|
56
|
+
border-bottom: none;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.tag {
|
|
60
|
+
margin: 0.25rem 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.priorityTag {
|
|
64
|
+
@extend .tag;
|
|
65
|
+
@include type.type-style('label-01');
|
|
66
|
+
color: #943d00;
|
|
67
|
+
background-color: #ffc9a3;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.backgroundDataFetchingIndicator {
|
|
71
|
+
align-items: center;
|
|
72
|
+
display: flex;
|
|
73
|
+
flex: 1 1 0%;
|
|
74
|
+
justify-content: center;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.search {
|
|
78
|
+
max-width: 16rem;
|
|
79
|
+
|
|
80
|
+
input {
|
|
81
|
+
background-color: $ui-02 !important;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.tableContainer {
|
|
86
|
+
background-color: $ui-01;
|
|
87
|
+
margin: 0 spacing.$spacing-05;
|
|
88
|
+
padding: 0;
|
|
89
|
+
|
|
90
|
+
a {
|
|
91
|
+
text-decoration: none;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
th {
|
|
95
|
+
color: $text-02;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
:global(.cds--data-table) {
|
|
99
|
+
background-color: $ui-03;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
:global(.cds--data-table-content) {
|
|
103
|
+
display: contents;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.toolbarContent {
|
|
107
|
+
height: spacing.$spacing-07;
|
|
108
|
+
margin-bottom: spacing.$spacing-02;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.emptyRow {
|
|
113
|
+
padding: 0 1rem;
|
|
114
|
+
display: flex;
|
|
115
|
+
align-items: center;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.activeVisitsTable tr:last-of-type {
|
|
119
|
+
td {
|
|
120
|
+
border-bottom: none;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.expandedActiveVisitRow {
|
|
125
|
+
:global(.cds--tab-content) {
|
|
126
|
+
padding: 0.5rem 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
td {
|
|
130
|
+
padding: 0.5rem;
|
|
131
|
+
|
|
132
|
+
>div {
|
|
133
|
+
max-height: max-content !important;
|
|
134
|
+
background-color: $ui-02;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
th[colspan] td[colspan]>div:first-child {
|
|
139
|
+
padding: 0 1rem;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.hiddenRow {
|
|
144
|
+
display: none;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.content {
|
|
148
|
+
@include type.type-style('heading-compact-02');
|
|
149
|
+
color: $text-02;
|
|
150
|
+
margin-bottom: 0.5rem;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.helper {
|
|
154
|
+
@include type.type-style('body-compact-01');
|
|
155
|
+
color: $text-02;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.separator {
|
|
159
|
+
@include type.type-style('body-compact-02');
|
|
160
|
+
color: $text-02;
|
|
161
|
+
width: 80%;
|
|
162
|
+
margin: 1.5rem auto;
|
|
163
|
+
overflow: hidden;
|
|
164
|
+
text-align: center;
|
|
165
|
+
|
|
166
|
+
&::before,
|
|
167
|
+
&::after {
|
|
168
|
+
background-color: $text-03;
|
|
169
|
+
content: '';
|
|
170
|
+
display: inline-block;
|
|
171
|
+
height: 1px;
|
|
172
|
+
position: relative;
|
|
173
|
+
vertical-align: middle;
|
|
174
|
+
width: 50%;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
&::before {
|
|
178
|
+
right: 0.5rem;
|
|
179
|
+
margin-left: -50%;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
&::after {
|
|
183
|
+
left: 0.5rem;
|
|
184
|
+
margin-right: -50%;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.tileContainer {
|
|
189
|
+
background-color: $ui-02;
|
|
190
|
+
border-top: 1px solid $ui-03;
|
|
191
|
+
padding: 5rem 0;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.tile {
|
|
195
|
+
margin: auto;
|
|
196
|
+
width: fit-content;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.tileContent {
|
|
200
|
+
display: flex;
|
|
201
|
+
flex-direction: column;
|
|
202
|
+
align-items: center;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.menuItem {
|
|
206
|
+
max-width: none;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.desktopHeading {
|
|
210
|
+
h4 {
|
|
211
|
+
@include type.type-style('heading-compact-02');
|
|
212
|
+
color: $text-02;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.tabletHeading {
|
|
217
|
+
h4 {
|
|
218
|
+
@include type.type-style('heading-03');
|
|
219
|
+
color: $text-02;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.desktopHeading,
|
|
224
|
+
.tabletHeading {
|
|
225
|
+
text-align: left;
|
|
226
|
+
text-transform: capitalize;
|
|
227
|
+
margin-bottom: spacing.$spacing-05;
|
|
228
|
+
|
|
229
|
+
h4:after {
|
|
230
|
+
content: '';
|
|
231
|
+
display: block;
|
|
232
|
+
width: 2rem;
|
|
233
|
+
padding-top: 3px;
|
|
234
|
+
border-bottom: 0.375rem solid var(--brand-03);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.statusContainer {
|
|
239
|
+
display: flex;
|
|
240
|
+
align-items: center;
|
|
241
|
+
|
|
242
|
+
svg {
|
|
243
|
+
margin-right: 0.5rem;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.visitType {
|
|
248
|
+
@include type.type-style('heading-compact-02');
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.headerBtnContainer {
|
|
252
|
+
background-color: $ui-background;
|
|
253
|
+
text-align: right;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.addPatientToListBtn {
|
|
257
|
+
margin-left: spacing.$spacing-05;
|
|
258
|
+
height: spacing.$spacing-09;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.editIcon {
|
|
262
|
+
color: $interactive-01;
|
|
263
|
+
margin-top: 0.5rem;
|
|
264
|
+
cursor: pointer;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.expandedLabQueueVisitRow {
|
|
268
|
+
:global(.cds--tab-content) {
|
|
269
|
+
padding: 0.5rem 0;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
td {
|
|
273
|
+
padding: 0.5rem;
|
|
274
|
+
|
|
275
|
+
>div {
|
|
276
|
+
max-height: max-content !important;
|
|
277
|
+
background-color: $ui-02;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
th[colspan] td[colspan]>div:first-child {
|
|
282
|
+
padding: 0 1rem;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Button, Tooltip } from "@carbon/react";
|
|
2
|
+
import { Dashboard } from "@carbon/react/icons";
|
|
3
|
+
import React, { AnchorHTMLAttributes } from "react";
|
|
4
|
+
import { useTranslation } from "react-i18next";
|
|
5
|
+
import { interpolateUrl, navigate } from "@openmrs/esm-framework";
|
|
6
|
+
|
|
7
|
+
interface NameLinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
8
|
+
to: string;
|
|
9
|
+
from: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const ViewActionsMenu: React.FC<NameLinkProps> = ({ from, to }) => {
|
|
13
|
+
const { t } = useTranslation();
|
|
14
|
+
|
|
15
|
+
const handleNameClick = (event: MouseEvent, to: string) => {
|
|
16
|
+
event.preventDefault();
|
|
17
|
+
navigate({ to });
|
|
18
|
+
localStorage.setItem("fromPage", from);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Tooltip align="bottom" label="View Patient">
|
|
23
|
+
<Button
|
|
24
|
+
kind="ghost"
|
|
25
|
+
onClick={(e) => handleNameClick(e, to)}
|
|
26
|
+
href={interpolateUrl(to)}
|
|
27
|
+
iconDescription={t("viewPatient", "View Patient")}
|
|
28
|
+
renderIcon={(props) => <Dashboard size={16} {...props} />}
|
|
29
|
+
/>
|
|
30
|
+
</Tooltip>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
export default ViewActionsMenu;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import useSWRInfinite from "swr/infinite";
|
|
3
|
+
import dayjs from "dayjs";
|
|
4
|
+
import isToday from "dayjs/plugin/isToday";
|
|
5
|
+
import last from "lodash-es/last";
|
|
6
|
+
import {
|
|
7
|
+
openmrsFetch,
|
|
8
|
+
useSession,
|
|
9
|
+
type FetchResponse,
|
|
10
|
+
} from "@openmrs/esm-framework";
|
|
11
|
+
import { AdmissionLocation } from "../../types";
|
|
12
|
+
|
|
13
|
+
dayjs.extend(isToday);
|
|
14
|
+
|
|
15
|
+
interface VisitResponse {
|
|
16
|
+
results: Array<AdmissionLocation>;
|
|
17
|
+
links: Array<{ rel: "prev" | "next" }>;
|
|
18
|
+
totalCount: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// interface SQLBedAssignmentResponse {
|
|
22
|
+
|
|
23
|
+
// }
|
|
24
|
+
|
|
25
|
+
export interface BedPatientAssignment {
|
|
26
|
+
patientUuid: string;
|
|
27
|
+
age: number;
|
|
28
|
+
gender: string;
|
|
29
|
+
patientName: string;
|
|
30
|
+
ward: string;
|
|
31
|
+
bedNumber: string;
|
|
32
|
+
}
|
|
33
|
+
export function useActiveAdmissions() {
|
|
34
|
+
const session = useSession();
|
|
35
|
+
const sessionLocation = session?.sessionLocation?.uuid;
|
|
36
|
+
|
|
37
|
+
const getUrl = (
|
|
38
|
+
pageIndex,
|
|
39
|
+
previousPageData: FetchResponse<VisitResponse>
|
|
40
|
+
) => {
|
|
41
|
+
if (
|
|
42
|
+
pageIndex &&
|
|
43
|
+
!previousPageData?.data?.links?.some((link) => link.rel === "next")
|
|
44
|
+
) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const url = `/ws/rest/v1/admissionLocation?v=full`;
|
|
49
|
+
const urlSearchParams = new URLSearchParams();
|
|
50
|
+
|
|
51
|
+
if (pageIndex) {
|
|
52
|
+
urlSearchParams.append("startIndex", `${pageIndex * 50}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return url + urlSearchParams.toString();
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const {
|
|
59
|
+
data,
|
|
60
|
+
error,
|
|
61
|
+
isLoading,
|
|
62
|
+
isValidating,
|
|
63
|
+
size: pageNumber,
|
|
64
|
+
setSize,
|
|
65
|
+
mutate,
|
|
66
|
+
} = useSWRInfinite<FetchResponse<VisitResponse>, Error>(
|
|
67
|
+
sessionLocation ? getUrl : null,
|
|
68
|
+
openmrsFetch
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (
|
|
73
|
+
data &&
|
|
74
|
+
data?.[pageNumber - 1]?.data?.links?.some((link) => link.rel === "next")
|
|
75
|
+
) {
|
|
76
|
+
setSize((currentSize) => currentSize + 1);
|
|
77
|
+
}
|
|
78
|
+
}, [data, pageNumber, setSize]);
|
|
79
|
+
|
|
80
|
+
const formattedActiveVisits: any = (data: FetchResponse<VisitResponse>) => {
|
|
81
|
+
const result = data
|
|
82
|
+
? data[0].data?.results?.map((wardEntry) => {
|
|
83
|
+
return wardEntry.bedLayouts;
|
|
84
|
+
})
|
|
85
|
+
: [];
|
|
86
|
+
|
|
87
|
+
const allBeds = [];
|
|
88
|
+
|
|
89
|
+
result?.forEach((elemnt) => {
|
|
90
|
+
elemnt.forEach((b) => {
|
|
91
|
+
allBeds.push(b);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
const finalFinalList = allBeds
|
|
95
|
+
?.filter((b) => b.status === "OCCUPIED")
|
|
96
|
+
.map((bedEntry) => {
|
|
97
|
+
const patient: BedPatientAssignment = {
|
|
98
|
+
patientUuid: bedEntry.patient.uuid,
|
|
99
|
+
age: bedEntry.patient.person.age,
|
|
100
|
+
gender: bedEntry.patient.person.gender,
|
|
101
|
+
patientName: bedEntry.patient.person.preferredName.givenName
|
|
102
|
+
.concat(" ")
|
|
103
|
+
.concat(bedEntry.patient.person.preferredName.familyName),
|
|
104
|
+
ward: bedEntry.location,
|
|
105
|
+
bedNumber: bedEntry.bedNumber,
|
|
106
|
+
};
|
|
107
|
+
return patient;
|
|
108
|
+
});
|
|
109
|
+
return finalFinalList;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
patientQueueEntries: formattedActiveVisits(data),
|
|
114
|
+
isError: error,
|
|
115
|
+
isLoading,
|
|
116
|
+
isValidating,
|
|
117
|
+
patientQueueCount: data?.[0]?.data?.totalCount ?? 0,
|
|
118
|
+
mutate,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export const getOriginFromPathName = (pathname = "") => {
|
|
123
|
+
const from = pathname.split("/");
|
|
124
|
+
return last(from);
|
|
125
|
+
};
|