@mieweb/ui 0.11.0-dev.29 → 0.11.0-dev.30
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/MIGRATION.md +67 -0
- package/README.md +10 -0
- package/dist/EncounterMdyEditor-3SQY4MK2.js +286 -0
- package/dist/EncounterMdyEditor-3SQY4MK2.js.map +1 -0
- package/dist/EncounterMdyEditor-73PTTIRY.cjs +288 -0
- package/dist/EncounterMdyEditor-73PTTIRY.cjs.map +1 -0
- package/dist/chunk-25MPUVTM.js +339 -0
- package/dist/chunk-25MPUVTM.js.map +1 -0
- package/dist/{chunk-2VISTX7O.js → chunk-3NOVISM6.js} +3 -3
- package/dist/{chunk-2VISTX7O.js.map → chunk-3NOVISM6.js.map} +1 -1
- package/dist/{chunk-6GKIISNZ.cjs → chunk-3Y3ZCDNF.cjs} +176 -63
- package/dist/chunk-3Y3ZCDNF.cjs.map +1 -0
- package/dist/{chunk-AK4LHJPC.js → chunk-4JXO5JTE.js} +84 -3
- package/dist/chunk-4JXO5JTE.js.map +1 -0
- package/dist/chunk-4NB4WOGU.cjs +666 -0
- package/dist/chunk-4NB4WOGU.cjs.map +1 -0
- package/dist/{chunk-434L5RYF.js → chunk-4P27Y52M.js} +3 -3
- package/dist/{chunk-434L5RYF.js.map → chunk-4P27Y52M.js.map} +1 -1
- package/dist/{chunk-PRA2V5BP.cjs → chunk-5KGYTNOA.cjs} +7 -7
- package/dist/{chunk-PRA2V5BP.cjs.map → chunk-5KGYTNOA.cjs.map} +1 -1
- package/dist/chunk-5LNLB2XT.js +634 -0
- package/dist/chunk-5LNLB2XT.js.map +1 -0
- package/dist/chunk-5YOT4DVH.js +31 -0
- package/dist/chunk-5YOT4DVH.js.map +1 -0
- package/dist/chunk-7HFZL5V5.js +2425 -0
- package/dist/chunk-7HFZL5V5.js.map +1 -0
- package/dist/{chunk-XZNHS7YQ.cjs → chunk-7XC6E4BT.cjs} +3 -3
- package/dist/{chunk-XZNHS7YQ.cjs.map → chunk-7XC6E4BT.cjs.map} +1 -1
- package/dist/{chunk-JM4YFLO4.js → chunk-AIJYZP7M.js} +3 -3
- package/dist/{chunk-JM4YFLO4.js.map → chunk-AIJYZP7M.js.map} +1 -1
- package/dist/chunk-BBLEGF5L.js +66 -0
- package/dist/chunk-BBLEGF5L.js.map +1 -0
- package/dist/{chunk-MBDT2MGR.js → chunk-BIQIE3VW.js} +4 -4
- package/dist/{chunk-MBDT2MGR.js.map → chunk-BIQIE3VW.js.map} +1 -1
- package/dist/chunk-FSLI5IKP.cjs +54 -0
- package/dist/chunk-FSLI5IKP.cjs.map +1 -0
- package/dist/chunk-GADJASST.js +3 -0
- package/dist/chunk-GADJASST.js.map +1 -0
- package/dist/chunk-IXUIOR4K.cjs +2457 -0
- package/dist/chunk-IXUIOR4K.cjs.map +1 -0
- package/dist/chunk-K2BY7YPJ.cjs +4 -0
- package/dist/chunk-K2BY7YPJ.cjs.map +1 -0
- package/dist/{chunk-H3P7POFC.cjs → chunk-MA3Y6AYA.cjs} +3 -3
- package/dist/{chunk-H3P7POFC.cjs.map → chunk-MA3Y6AYA.cjs.map} +1 -1
- package/dist/chunk-QO4A6U73.cjs +342 -0
- package/dist/chunk-QO4A6U73.cjs.map +1 -0
- package/dist/{chunk-43QBEF6N.js → chunk-QR7B6UPR.js} +176 -63
- package/dist/chunk-QR7B6UPR.js.map +1 -0
- package/dist/chunk-SMPLM6K3.js +4107 -0
- package/dist/chunk-SMPLM6K3.js.map +1 -0
- package/dist/chunk-SV6YGK4U.cjs +88 -0
- package/dist/chunk-SV6YGK4U.cjs.map +1 -0
- package/dist/{chunk-MQ5WJ3NO.js → chunk-UDUYZDTA.js} +14 -72
- package/dist/chunk-UDUYZDTA.js.map +1 -0
- package/dist/{chunk-ZLBNYCYT.cjs → chunk-XPVQI3MM.cjs} +84 -3
- package/dist/chunk-XPVQI3MM.cjs.map +1 -0
- package/dist/{chunk-AQUHEKXL.cjs → chunk-XQHDQ64G.cjs} +4 -4
- package/dist/{chunk-AQUHEKXL.cjs.map → chunk-XQHDQ64G.cjs.map} +1 -1
- package/dist/chunk-Z2OOJGHL.cjs +4155 -0
- package/dist/chunk-Z2OOJGHL.cjs.map +1 -0
- package/dist/{chunk-QKW2QCGI.cjs → chunk-ZK2R6UGF.cjs} +13 -72
- package/dist/chunk-ZK2R6UGF.cjs.map +1 -0
- package/dist/components/ActionPlan/index.cjs +4 -4
- package/dist/components/ActionPlan/index.js +2 -2
- package/dist/components/AlertDialog/index.d.cts +1 -1
- package/dist/components/AlertDialog/index.d.ts +1 -1
- package/dist/components/EmailEditor/index.cjs +13 -12
- package/dist/components/EmailEditor/index.js +4 -3
- package/dist/components/MediaEditor/index.cjs +7 -7
- package/dist/components/MediaEditor/index.js +2 -2
- package/dist/components/RichTextEditor/index.cjs +5 -4
- package/dist/components/RichTextEditor/index.d.cts +34 -0
- package/dist/components/RichTextEditor/index.d.ts +34 -0
- package/dist/components/RichTextEditor/index.js +2 -1
- package/dist/components/SuperChat/index.cjs +10 -9
- package/dist/components/SuperChat/index.cjs.map +1 -1
- package/dist/components/SuperChat/index.js +2 -1
- package/dist/components/SuperChat/index.js.map +1 -1
- package/dist/components/Textarea/index.cjs +6 -5
- package/dist/components/Textarea/index.js +3 -2
- package/dist/esheet.cjs +4237 -25
- package/dist/esheet.cjs.map +1 -1
- package/dist/esheet.d.cts +753 -6
- package/dist/esheet.d.ts +753 -6
- package/dist/esheet.js +4099 -21
- package/dist/esheet.js.map +1 -1
- package/dist/index.cjs +204 -3072
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +71 -9
- package/dist/index.d.ts +71 -9
- package/dist/index.js +38 -2968
- package/dist/index.js.map +1 -1
- package/dist/kerebron.cjs +7 -268
- package/dist/kerebron.cjs.map +1 -1
- package/dist/kerebron.d.cts +7 -1
- package/dist/kerebron.d.ts +7 -1
- package/dist/kerebron.js +6 -270
- package/dist/kerebron.js.map +1 -1
- package/dist/model-WFFZRQMY.js +18 -0
- package/dist/model-WFFZRQMY.js.map +1 -0
- package/dist/model-Y7WRIGGA.cjs +79 -0
- package/dist/model-Y7WRIGGA.cjs.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/tailwind-preset.cjs +4 -4
- package/dist/tailwind-preset.js +1 -1
- package/package.json +30 -9
- package/dist/chunk-43QBEF6N.js.map +0 -1
- package/dist/chunk-6GKIISNZ.cjs.map +0 -1
- package/dist/chunk-AK4LHJPC.js.map +0 -1
- package/dist/chunk-MQ5WJ3NO.js.map +0 -1
- package/dist/chunk-QKW2QCGI.cjs.map +0 -1
- package/dist/chunk-SFSBYC46.js +0 -1596
- package/dist/chunk-SFSBYC46.js.map +0 -1
- package/dist/chunk-ZIJMLRI3.cjs +0 -1633
- package/dist/chunk-ZIJMLRI3.cjs.map +0 -1
- package/dist/chunk-ZLBNYCYT.cjs.map +0 -1
|
@@ -0,0 +1,4155 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk4NB4WOGU_cjs = require('./chunk-4NB4WOGU.cjs');
|
|
4
|
+
var chunkGLG6UE2H_cjs = require('./chunk-GLG6UE2H.cjs');
|
|
5
|
+
var chunkG7EQ3JPX_cjs = require('./chunk-G7EQ3JPX.cjs');
|
|
6
|
+
var chunkAIJAFPGJ_cjs = require('./chunk-AIJAFPGJ.cjs');
|
|
7
|
+
var chunkPHUTJKHL_cjs = require('./chunk-PHUTJKHL.cjs');
|
|
8
|
+
var chunkXQHDQ64G_cjs = require('./chunk-XQHDQ64G.cjs');
|
|
9
|
+
var chunkFSLI5IKP_cjs = require('./chunk-FSLI5IKP.cjs');
|
|
10
|
+
var chunkUPWIJC6I_cjs = require('./chunk-UPWIJC6I.cjs');
|
|
11
|
+
var chunkPINIBEIU_cjs = require('./chunk-PINIBEIU.cjs');
|
|
12
|
+
var chunkMJWFNV3L_cjs = require('./chunk-MJWFNV3L.cjs');
|
|
13
|
+
var chunk7AECNMYV_cjs = require('./chunk-7AECNMYV.cjs');
|
|
14
|
+
var chunkLC3JL2HB_cjs = require('./chunk-LC3JL2HB.cjs');
|
|
15
|
+
var chunkZ5S5JEJD_cjs = require('./chunk-Z5S5JEJD.cjs');
|
|
16
|
+
var chunkGF2BE4FB_cjs = require('./chunk-GF2BE4FB.cjs');
|
|
17
|
+
var chunkCPDNX3LS_cjs = require('./chunk-CPDNX3LS.cjs');
|
|
18
|
+
var chunkNNEFAUHV_cjs = require('./chunk-NNEFAUHV.cjs');
|
|
19
|
+
var chunkFHY3K6PL_cjs = require('./chunk-FHY3K6PL.cjs');
|
|
20
|
+
var chunkFSGEDDF2_cjs = require('./chunk-FSGEDDF2.cjs');
|
|
21
|
+
var chunkAOHJILLU_cjs = require('./chunk-AOHJILLU.cjs');
|
|
22
|
+
var chunkCW75IKA6_cjs = require('./chunk-CW75IKA6.cjs');
|
|
23
|
+
var chunkSCV7C55E_cjs = require('./chunk-SCV7C55E.cjs');
|
|
24
|
+
var chunkL7L5S2HO_cjs = require('./chunk-L7L5S2HO.cjs');
|
|
25
|
+
var chunkZ3WMDVMR_cjs = require('./chunk-Z3WMDVMR.cjs');
|
|
26
|
+
var chunk7E46YDOT_cjs = require('./chunk-7E46YDOT.cjs');
|
|
27
|
+
var chunkANMX7YDL_cjs = require('./chunk-ANMX7YDL.cjs');
|
|
28
|
+
var chunkS5RVSXDV_cjs = require('./chunk-S5RVSXDV.cjs');
|
|
29
|
+
var React4 = require('react');
|
|
30
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
31
|
+
var reactDom = require('react-dom');
|
|
32
|
+
var lucideReact = require('lucide-react');
|
|
33
|
+
|
|
34
|
+
function _interopNamespace(e) {
|
|
35
|
+
if (e && e.__esModule) return e;
|
|
36
|
+
var n = Object.create(null);
|
|
37
|
+
if (e) {
|
|
38
|
+
Object.keys(e).forEach(function (k) {
|
|
39
|
+
if (k !== 'default') {
|
|
40
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
41
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () { return e[k]; }
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
n.default = e;
|
|
49
|
+
return Object.freeze(n);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var React4__namespace = /*#__PURE__*/_interopNamespace(React4);
|
|
53
|
+
|
|
54
|
+
var TYPE_ORDER = ["drug", "food", "environmental", "other"];
|
|
55
|
+
var ALLERGY_TYPE_LABELS = {
|
|
56
|
+
drug: "Drug",
|
|
57
|
+
food: "Food",
|
|
58
|
+
environmental: "Environmental",
|
|
59
|
+
other: "Other"
|
|
60
|
+
};
|
|
61
|
+
var SEVERITY_BADGE = {
|
|
62
|
+
severe: "danger",
|
|
63
|
+
moderate: "warning",
|
|
64
|
+
mild: "secondary"
|
|
65
|
+
};
|
|
66
|
+
var DEFAULT_ACTIONS = ["correct", "note", "remove"];
|
|
67
|
+
var ACTION_META = {
|
|
68
|
+
correct: { label: "Correct", icon: chunkL7L5S2HO_cjs.Pencil },
|
|
69
|
+
note: { label: "Notes", icon: chunkL7L5S2HO_cjs.StickyNote },
|
|
70
|
+
remove: { label: "Remove", icon: chunkL7L5S2HO_cjs.Ban }
|
|
71
|
+
};
|
|
72
|
+
function AllergyRow({
|
|
73
|
+
allergy,
|
|
74
|
+
actions,
|
|
75
|
+
readOnly,
|
|
76
|
+
drag,
|
|
77
|
+
onMove,
|
|
78
|
+
onAction
|
|
79
|
+
}) {
|
|
80
|
+
const m = chunkFSLI5IKP_cjs.useMessages();
|
|
81
|
+
const handleRowKeyDown = (e) => {
|
|
82
|
+
if (e.target !== e.currentTarget) return;
|
|
83
|
+
if (e.altKey && (e.key === "ArrowUp" || e.key === "ArrowDown")) {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
onMove?.(allergy, e.key === "ArrowUp" ? -1 : 1);
|
|
86
|
+
} else if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
const list = e.currentTarget.closest("ul");
|
|
89
|
+
if (!list) return;
|
|
90
|
+
const rows = Array.from(
|
|
91
|
+
list.querySelectorAll("li[data-allergy-id]")
|
|
92
|
+
);
|
|
93
|
+
const i = rows.indexOf(e.currentTarget);
|
|
94
|
+
rows[e.key === "ArrowUp" ? Math.max(0, i - 1) : Math.min(rows.length - 1, i + 1)]?.focus();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
return (
|
|
98
|
+
// Rows are focus stops when reordering is enabled so drag & drop has a
|
|
99
|
+
// keyboard equivalent (Alt+↑/↓) — 508.
|
|
100
|
+
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/no-noninteractive-tabindex */
|
|
101
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
102
|
+
"li",
|
|
103
|
+
{
|
|
104
|
+
"data-slot": "clinical-list-row",
|
|
105
|
+
"data-allergy-id": allergy.id,
|
|
106
|
+
tabIndex: drag.enabled ? 0 : void 0,
|
|
107
|
+
onKeyDown: drag.enabled ? handleRowKeyDown : void 0,
|
|
108
|
+
"aria-label": drag.enabled ? m("{name}. Alt plus arrow keys to reorder.", {
|
|
109
|
+
name: allergy.allergen
|
|
110
|
+
}) : void 0,
|
|
111
|
+
...drag.rowProps(allergy.id),
|
|
112
|
+
className: chunkS5RVSXDV_cjs.cn(
|
|
113
|
+
"group border-border/60 relative flex min-h-11 flex-wrap items-center gap-x-2 gap-y-1 border-b px-1 py-2",
|
|
114
|
+
"focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none",
|
|
115
|
+
drag.enabled && "cursor-grab active:cursor-grabbing",
|
|
116
|
+
chunkGF2BE4FB_cjs.dragIndicatorClasses(drag, allergy.id)
|
|
117
|
+
),
|
|
118
|
+
children: [
|
|
119
|
+
drag.enabled ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
120
|
+
chunkL7L5S2HO_cjs.GripVertical,
|
|
121
|
+
{
|
|
122
|
+
size: 14,
|
|
123
|
+
"aria-hidden": true,
|
|
124
|
+
className: "text-muted-foreground/50 shrink-0"
|
|
125
|
+
}
|
|
126
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground/60 select-none", children: "\u2022" }),
|
|
127
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
128
|
+
"span",
|
|
129
|
+
{
|
|
130
|
+
className: chunkS5RVSXDV_cjs.cn(
|
|
131
|
+
"text-foreground font-medium",
|
|
132
|
+
allergy.inactive && "text-muted-foreground line-through"
|
|
133
|
+
),
|
|
134
|
+
children: allergy.allergen
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
allergy.code && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
138
|
+
"span",
|
|
139
|
+
{
|
|
140
|
+
className: "text-muted-foreground/70 text-xs",
|
|
141
|
+
title: allergy.code.display,
|
|
142
|
+
children: [
|
|
143
|
+
allergy.code.system,
|
|
144
|
+
" ",
|
|
145
|
+
allergy.code.code
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
allergy.severity && /* @__PURE__ */ jsxRuntime.jsx(chunk7E46YDOT_cjs.Badge, { variant: SEVERITY_BADGE[allergy.severity], size: "sm", children: m(allergy.severity) }),
|
|
150
|
+
allergy.kind === "intolerance" && /* @__PURE__ */ jsxRuntime.jsx(chunk7E46YDOT_cjs.Badge, { variant: "secondary", size: "sm", children: m("intolerance") }),
|
|
151
|
+
allergy.reaction && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground text-sm", children: [
|
|
152
|
+
"\u2014 ",
|
|
153
|
+
allergy.reaction
|
|
154
|
+
] }),
|
|
155
|
+
allergy.onsetDate && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-xs", children: m("since {date}", { date: allergy.onsetDate }) }),
|
|
156
|
+
allergy.inactive && /* @__PURE__ */ jsxRuntime.jsx(chunk7E46YDOT_cjs.Badge, { variant: "secondary", size: "sm", children: m("inactive") }),
|
|
157
|
+
allergy.note && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex w-full basis-full items-center gap-1.5 ps-4", children: [
|
|
158
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkL7L5S2HO_cjs.StickyNote, { size: 12, className: "text-muted-foreground" }),
|
|
159
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-xs", children: allergy.note })
|
|
160
|
+
] }),
|
|
161
|
+
!readOnly && actions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
162
|
+
chunk4NB4WOGU_cjs.RowActionToolbar,
|
|
163
|
+
{
|
|
164
|
+
label: m("Actions for {name}", { name: allergy.allergen }),
|
|
165
|
+
children: actions.map((action) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
166
|
+
chunk4NB4WOGU_cjs.RowIconButton,
|
|
167
|
+
{
|
|
168
|
+
label: m(ACTION_META[action].label),
|
|
169
|
+
icon: ACTION_META[action].icon,
|
|
170
|
+
onClick: () => onAction?.(allergy, action)
|
|
171
|
+
},
|
|
172
|
+
action
|
|
173
|
+
))
|
|
174
|
+
}
|
|
175
|
+
)
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
)
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
var AllergyList = React4__namespace.forwardRef(
|
|
182
|
+
({
|
|
183
|
+
allergies,
|
|
184
|
+
noKnownAllergies,
|
|
185
|
+
onNoKnownAllergiesChange,
|
|
186
|
+
title = "Allergies",
|
|
187
|
+
actions = DEFAULT_ACTIONS,
|
|
188
|
+
onAction,
|
|
189
|
+
onReorder,
|
|
190
|
+
addSearch,
|
|
191
|
+
onAdd,
|
|
192
|
+
readOnly = false,
|
|
193
|
+
className,
|
|
194
|
+
"data-testid": dataTestId,
|
|
195
|
+
...props
|
|
196
|
+
}, ref) => {
|
|
197
|
+
const m = chunkFSLI5IKP_cjs.useMessages();
|
|
198
|
+
const [announcement, setAnnouncement] = chunkCPDNX3LS_cjs.useLiveAnnouncement();
|
|
199
|
+
const groups = TYPE_ORDER.map((type) => ({
|
|
200
|
+
type,
|
|
201
|
+
label: ALLERGY_TYPE_LABELS[type],
|
|
202
|
+
items: allergies.filter((a) => (a.type ?? "other") === type)
|
|
203
|
+
})).filter((g) => g.items.length > 0);
|
|
204
|
+
const empty = allergies.length === 0;
|
|
205
|
+
const typeOf = React4__namespace.useCallback(
|
|
206
|
+
(id) => allergies.find((a) => a.id === id)?.type ?? "other",
|
|
207
|
+
[allergies]
|
|
208
|
+
);
|
|
209
|
+
const drag = chunkGF2BE4FB_cjs.useDragReorder({
|
|
210
|
+
ids: allergies.map((a) => a.id),
|
|
211
|
+
onReorder: readOnly || !onReorder ? void 0 : (ids) => {
|
|
212
|
+
setAnnouncement(m("Allergy list reordered"));
|
|
213
|
+
onReorder(ids);
|
|
214
|
+
},
|
|
215
|
+
canDropOn: (dragged, target) => typeOf(dragged) === typeOf(target)
|
|
216
|
+
});
|
|
217
|
+
const moveAllergy = React4__namespace.useCallback(
|
|
218
|
+
(allergy, dir) => {
|
|
219
|
+
if (readOnly || !onReorder) return;
|
|
220
|
+
const ids = allergies.map((a) => a.id);
|
|
221
|
+
const from = ids.indexOf(allergy.id);
|
|
222
|
+
let to = from + dir;
|
|
223
|
+
while (to >= 0 && to < allergies.length && (allergies[to].type ?? "other") !== (allergy.type ?? "other")) {
|
|
224
|
+
to += dir;
|
|
225
|
+
}
|
|
226
|
+
if (to < 0 || to >= allergies.length) return;
|
|
227
|
+
[ids[from], ids[to]] = [ids[to], ids[from]];
|
|
228
|
+
setAnnouncement(
|
|
229
|
+
m(dir === -1 ? "{name} moved up" : "{name} moved down", {
|
|
230
|
+
name: allergy.allergen
|
|
231
|
+
})
|
|
232
|
+
);
|
|
233
|
+
onReorder(ids);
|
|
234
|
+
},
|
|
235
|
+
[allergies, m, onReorder, readOnly, setAnnouncement]
|
|
236
|
+
);
|
|
237
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
238
|
+
chunkMJWFNV3L_cjs.Card,
|
|
239
|
+
{
|
|
240
|
+
ref,
|
|
241
|
+
padding: "none",
|
|
242
|
+
className: chunkS5RVSXDV_cjs.cn("w-full", className),
|
|
243
|
+
"data-testid": dataTestId,
|
|
244
|
+
...props,
|
|
245
|
+
children: [
|
|
246
|
+
title !== null && /* @__PURE__ */ jsxRuntime.jsx(chunkMJWFNV3L_cjs.CardHeader, { className: "border-border bg-muted/50 border-b px-4 py-3", children: /* @__PURE__ */ jsxRuntime.jsxs("h3", { className: "text-foreground flex items-center gap-2 text-sm font-semibold tracking-wide uppercase", children: [
|
|
247
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
248
|
+
chunkL7L5S2HO_cjs.AlertCircle,
|
|
249
|
+
{
|
|
250
|
+
size: 16,
|
|
251
|
+
className: "text-red-600 dark:text-red-400"
|
|
252
|
+
}
|
|
253
|
+
),
|
|
254
|
+
m(title)
|
|
255
|
+
] }) }),
|
|
256
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkMJWFNV3L_cjs.CardContent, { className: "space-y-5 px-4 py-4", children: [
|
|
257
|
+
empty ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
258
|
+
noKnownAllergies ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-foreground flex items-center gap-1.5 text-sm", children: [
|
|
259
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunk7E46YDOT_cjs.Badge, { variant: "success", size: "sm", children: "\u2713" }),
|
|
260
|
+
m("No known allergies (NKA)")
|
|
261
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: m("Allergy status not recorded.") }),
|
|
262
|
+
!readOnly && onNoKnownAllergiesChange && /* @__PURE__ */ jsxRuntime.jsx(
|
|
263
|
+
chunkANMX7YDL_cjs.Button,
|
|
264
|
+
{
|
|
265
|
+
variant: noKnownAllergies ? "secondary" : "outline",
|
|
266
|
+
size: "sm",
|
|
267
|
+
onClick: () => onNoKnownAllergiesChange(!noKnownAllergies),
|
|
268
|
+
children: noKnownAllergies ? m("Clear no-known-allergies") : m("Confirm: no known allergies")
|
|
269
|
+
}
|
|
270
|
+
)
|
|
271
|
+
] }) : groups.map(({ type, label, items }) => /* @__PURE__ */ jsxRuntime.jsxs("section", { "aria-label": m(label), children: [
|
|
272
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
273
|
+
"h4",
|
|
274
|
+
{
|
|
275
|
+
"data-slot": "clinical-list-heading",
|
|
276
|
+
className: "border-border text-foreground border-b pb-1 text-sm font-semibold tracking-wide uppercase",
|
|
277
|
+
children: m(label)
|
|
278
|
+
}
|
|
279
|
+
),
|
|
280
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "mt-1", children: items.map((allergy) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
281
|
+
AllergyRow,
|
|
282
|
+
{
|
|
283
|
+
allergy,
|
|
284
|
+
actions,
|
|
285
|
+
readOnly,
|
|
286
|
+
drag,
|
|
287
|
+
onMove: moveAllergy,
|
|
288
|
+
onAction
|
|
289
|
+
},
|
|
290
|
+
allergy.id
|
|
291
|
+
)) })
|
|
292
|
+
] }, type)),
|
|
293
|
+
!readOnly && (addSearch || onAdd) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
294
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-xs font-semibold tracking-wide uppercase", children: m("Add allergy") }),
|
|
295
|
+
addSearch,
|
|
296
|
+
onAdd && /* @__PURE__ */ jsxRuntime.jsx(
|
|
297
|
+
chunkANMX7YDL_cjs.Button,
|
|
298
|
+
{
|
|
299
|
+
variant: "outline",
|
|
300
|
+
size: "sm",
|
|
301
|
+
onClick: onAdd,
|
|
302
|
+
leftIcon: /* @__PURE__ */ jsxRuntime.jsx(chunkL7L5S2HO_cjs.Plus, { size: 12 }),
|
|
303
|
+
className: "h-auto rounded-full px-2.5 py-1 text-xs",
|
|
304
|
+
children: m("Add allergy\u2026")
|
|
305
|
+
}
|
|
306
|
+
)
|
|
307
|
+
] })
|
|
308
|
+
] }),
|
|
309
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { "aria-live": "polite", className: "sr-only", children: announcement })
|
|
310
|
+
]
|
|
311
|
+
}
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
);
|
|
315
|
+
AllergyList.displayName = "AllergyList";
|
|
316
|
+
var CodeLookupContext = React4__namespace.createContext(null);
|
|
317
|
+
function CodeLookupProvider({
|
|
318
|
+
component,
|
|
319
|
+
indexUrl = "/codify",
|
|
320
|
+
locale = "en",
|
|
321
|
+
memory,
|
|
322
|
+
children
|
|
323
|
+
}) {
|
|
324
|
+
const value = React4__namespace.useMemo(
|
|
325
|
+
() => ({ component, indexUrl, locale, memory }),
|
|
326
|
+
[component, indexUrl, locale, memory]
|
|
327
|
+
);
|
|
328
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CodeLookupContext.Provider, { value, children });
|
|
329
|
+
}
|
|
330
|
+
function useCodeLookupConfig() {
|
|
331
|
+
return React4__namespace.useContext(CodeLookupContext);
|
|
332
|
+
}
|
|
333
|
+
function newId() {
|
|
334
|
+
return `alg-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
335
|
+
}
|
|
336
|
+
var TYPE_OPTIONS = [
|
|
337
|
+
{ value: "drug", label: "Drug" },
|
|
338
|
+
{ value: "food", label: "Food" },
|
|
339
|
+
{ value: "environmental", label: "Environmental" },
|
|
340
|
+
{ value: "other", label: "Other" }
|
|
341
|
+
];
|
|
342
|
+
function AllergyEditor({
|
|
343
|
+
allergy,
|
|
344
|
+
codeLookup,
|
|
345
|
+
requireCode = false,
|
|
346
|
+
onClose,
|
|
347
|
+
onSave
|
|
348
|
+
}) {
|
|
349
|
+
const m = chunkFSLI5IKP_cjs.useMessages();
|
|
350
|
+
const [draft, setDraft] = React4__namespace.useState(
|
|
351
|
+
() => allergy ?? { id: newId(), allergen: "", type: "drug" }
|
|
352
|
+
);
|
|
353
|
+
const patch = (p) => setDraft((prev) => ({ ...prev, ...p }));
|
|
354
|
+
const bodyRef = React4__namespace.useRef(null);
|
|
355
|
+
React4__namespace.useEffect(() => {
|
|
356
|
+
bodyRef.current?.querySelector("input")?.focus();
|
|
357
|
+
}, []);
|
|
358
|
+
const hasCode = Boolean(draft.code?.system.trim() && draft.code.code.trim());
|
|
359
|
+
const unchangedLegacyAllergen = allergy && !allergy.code && draft.allergen === allergy.allergen && (draft.type ?? "drug") === (allergy.type ?? "drug");
|
|
360
|
+
const canSave = draft.allergen.trim().length > 0 && (!requireCode || hasCode || Boolean(unchangedLegacyAllergen));
|
|
361
|
+
const isDrug = (draft.type ?? "drug") === "drug";
|
|
362
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(chunkLC3JL2HB_cjs.Modal, { open: true, onOpenChange: (o) => !o && onClose(), size: "md", children: [
|
|
363
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkLC3JL2HB_cjs.ModalHeader, { children: [
|
|
364
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkLC3JL2HB_cjs.ModalTitle, { children: allergy ? m("Correct Allergy") : m("Add Allergy") }),
|
|
365
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkLC3JL2HB_cjs.ModalClose, { "aria-label": m("Close") })
|
|
366
|
+
] }),
|
|
367
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkLC3JL2HB_cjs.ModalBody, { className: "space-y-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: bodyRef, className: "contents", children: [
|
|
368
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
369
|
+
chunkG7EQ3JPX_cjs.RadioGroup,
|
|
370
|
+
{
|
|
371
|
+
name: "alg-kind",
|
|
372
|
+
label: m("Mechanism"),
|
|
373
|
+
description: m(
|
|
374
|
+
"A true immune-mediated allergy, or a non-immune intolerance (e.g. GI upset)"
|
|
375
|
+
),
|
|
376
|
+
value: draft.kind ?? "allergy",
|
|
377
|
+
onValueChange: (v) => patch({ kind: v }),
|
|
378
|
+
orientation: "horizontal",
|
|
379
|
+
size: "sm",
|
|
380
|
+
children: [
|
|
381
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkG7EQ3JPX_cjs.Radio, { value: "allergy", label: m("Allergy") }),
|
|
382
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkG7EQ3JPX_cjs.Radio, { value: "intolerance", label: m("Intolerance") })
|
|
383
|
+
]
|
|
384
|
+
}
|
|
385
|
+
),
|
|
386
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
387
|
+
chunkUPWIJC6I_cjs.Select,
|
|
388
|
+
{
|
|
389
|
+
label: m("Type"),
|
|
390
|
+
options: TYPE_OPTIONS.map((option) => ({
|
|
391
|
+
...option,
|
|
392
|
+
label: m(option.label)
|
|
393
|
+
})),
|
|
394
|
+
value: draft.type ?? "drug",
|
|
395
|
+
onValueChange: (v) => {
|
|
396
|
+
const type = v;
|
|
397
|
+
patch({
|
|
398
|
+
type,
|
|
399
|
+
...type !== (draft.type ?? "drug") && { code: void 0 }
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
),
|
|
404
|
+
codeLookup && (isDrug || requireCode) ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
405
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "alg-search", children: m("Allergen") }),
|
|
406
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
407
|
+
codeLookup.component,
|
|
408
|
+
{
|
|
409
|
+
indexUrl: codeLookup.indexUrl,
|
|
410
|
+
locale: codeLookup.locale,
|
|
411
|
+
domains: isDrug ? ["med"] : ["condition"],
|
|
412
|
+
searchCodetypes: isDrug ? void 0 : ["SNOMED US"],
|
|
413
|
+
bare: true,
|
|
414
|
+
clearOnSelect: false,
|
|
415
|
+
placeholder: isDrug ? m("Search drug allergens \u2014 e.g. penicillin") : m("Search SNOMED allergen substances"),
|
|
416
|
+
initialQuery: allergy?.allergen || void 0,
|
|
417
|
+
initialSearch: allergy ? !allergy.code : void 0,
|
|
418
|
+
onSelect: (result) => {
|
|
419
|
+
if (requireCode && (!result.codetype.trim() || !result.fullcode.trim()))
|
|
420
|
+
return;
|
|
421
|
+
patch({
|
|
422
|
+
allergen: result.label,
|
|
423
|
+
code: {
|
|
424
|
+
system: result.codetype,
|
|
425
|
+
code: result.fullcode,
|
|
426
|
+
display: result.label
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
},
|
|
430
|
+
onFreeText: requireCode ? void 0 : (text) => patch({ allergen: text, code: void 0 })
|
|
431
|
+
}
|
|
432
|
+
),
|
|
433
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-xs", children: draft.code ? m("Coded: {system} {code}", {
|
|
434
|
+
system: draft.code.system,
|
|
435
|
+
code: draft.code.code
|
|
436
|
+
}) : draft.allergen ? m('Uncoded free text: "{name}"', {
|
|
437
|
+
name: draft.allergen
|
|
438
|
+
}) : requireCode ? m("Pick a catalog result to code the allergen") : m(
|
|
439
|
+
"Pick a result to code the allergen, or press Enter for free text"
|
|
440
|
+
) })
|
|
441
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
442
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "alg-name", children: m("Allergen") }),
|
|
443
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
444
|
+
chunkZ5S5JEJD_cjs.Input,
|
|
445
|
+
{
|
|
446
|
+
id: "alg-name",
|
|
447
|
+
value: draft.allergen,
|
|
448
|
+
readOnly: requireCode,
|
|
449
|
+
onChange: (e) => patch({ allergen: e.target.value, code: void 0 })
|
|
450
|
+
}
|
|
451
|
+
)
|
|
452
|
+
] }),
|
|
453
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
454
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "alg-reaction", children: m("Reaction") }),
|
|
455
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
456
|
+
chunkZ5S5JEJD_cjs.Input,
|
|
457
|
+
{
|
|
458
|
+
id: "alg-reaction",
|
|
459
|
+
value: draft.reaction ?? "",
|
|
460
|
+
onChange: (e) => patch({ reaction: e.target.value })
|
|
461
|
+
}
|
|
462
|
+
)
|
|
463
|
+
] }),
|
|
464
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
465
|
+
chunkG7EQ3JPX_cjs.RadioGroup,
|
|
466
|
+
{
|
|
467
|
+
name: "alg-severity",
|
|
468
|
+
label: m("Severity"),
|
|
469
|
+
value: draft.severity ?? "",
|
|
470
|
+
onValueChange: (v) => patch({ severity: v || void 0 }),
|
|
471
|
+
orientation: "horizontal",
|
|
472
|
+
size: "sm",
|
|
473
|
+
children: [
|
|
474
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkG7EQ3JPX_cjs.Radio, { value: "mild", label: m("Mild") }),
|
|
475
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkG7EQ3JPX_cjs.Radio, { value: "moderate", label: m("Moderate") }),
|
|
476
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkG7EQ3JPX_cjs.Radio, { value: "severe", label: m("Severe") })
|
|
477
|
+
]
|
|
478
|
+
}
|
|
479
|
+
),
|
|
480
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
481
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "alg-onset", children: m("Onset date") }),
|
|
482
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
483
|
+
chunkPHUTJKHL_cjs.DateInput,
|
|
484
|
+
{
|
|
485
|
+
id: "alg-onset",
|
|
486
|
+
value: draft.onsetDate ?? "",
|
|
487
|
+
onChange: (v) => patch({ onsetDate: v })
|
|
488
|
+
}
|
|
489
|
+
)
|
|
490
|
+
] }),
|
|
491
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
492
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "alg-note", children: m("Note") }),
|
|
493
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
494
|
+
chunkXQHDQ64G_cjs.Textarea,
|
|
495
|
+
{
|
|
496
|
+
id: "alg-note",
|
|
497
|
+
value: draft.note ?? "",
|
|
498
|
+
onChange: (e) => patch({ note: e.target.value }),
|
|
499
|
+
rows: 2
|
|
500
|
+
}
|
|
501
|
+
)
|
|
502
|
+
] })
|
|
503
|
+
] }) }),
|
|
504
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkLC3JL2HB_cjs.ModalFooter, { children: [
|
|
505
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkANMX7YDL_cjs.Button, { variant: "secondary", onClick: onClose, children: m("Cancel") }),
|
|
506
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
507
|
+
chunkANMX7YDL_cjs.Button,
|
|
508
|
+
{
|
|
509
|
+
onClick: () => {
|
|
510
|
+
onSave({ ...draft, allergen: draft.allergen.trim() });
|
|
511
|
+
onClose();
|
|
512
|
+
},
|
|
513
|
+
disabled: !canSave,
|
|
514
|
+
children: m("Save")
|
|
515
|
+
}
|
|
516
|
+
)
|
|
517
|
+
] })
|
|
518
|
+
] });
|
|
519
|
+
}
|
|
520
|
+
function AllergyManager({
|
|
521
|
+
allergies: controlled,
|
|
522
|
+
defaultAllergies,
|
|
523
|
+
onChange,
|
|
524
|
+
noKnownAllergies,
|
|
525
|
+
onNoKnownAllergiesChange,
|
|
526
|
+
title = "Allergies",
|
|
527
|
+
codeLookup,
|
|
528
|
+
requireCode = false,
|
|
529
|
+
inlineAddSearch = false,
|
|
530
|
+
readOnly = false,
|
|
531
|
+
className,
|
|
532
|
+
"data-testid": dataTestId
|
|
533
|
+
}) {
|
|
534
|
+
const m = chunkFSLI5IKP_cjs.useMessages();
|
|
535
|
+
const isControlled = controlled !== void 0;
|
|
536
|
+
const [internal, setInternal] = React4__namespace.useState(
|
|
537
|
+
defaultAllergies ?? []
|
|
538
|
+
);
|
|
539
|
+
const allergies = isControlled ? controlled : internal;
|
|
540
|
+
const ambientCodeLookup = useCodeLookupConfig();
|
|
541
|
+
const effectiveCodeLookup = codeLookup === false ? void 0 : codeLookup ?? ambientCodeLookup ?? void 0;
|
|
542
|
+
const [dialog, setDialog] = React4__namespace.useState(null);
|
|
543
|
+
const [noteDraft, setNoteDraft] = React4__namespace.useState("");
|
|
544
|
+
const commit = (next) => {
|
|
545
|
+
if (!isControlled) setInternal(next);
|
|
546
|
+
if (next.length > 0 && noKnownAllergies) {
|
|
547
|
+
onNoKnownAllergiesChange?.(false);
|
|
548
|
+
}
|
|
549
|
+
onChange?.(next);
|
|
550
|
+
};
|
|
551
|
+
const handleAction = (allergy, action) => {
|
|
552
|
+
switch (action) {
|
|
553
|
+
case "remove":
|
|
554
|
+
commit(allergies.filter((a) => a.id !== allergy.id));
|
|
555
|
+
break;
|
|
556
|
+
case "correct":
|
|
557
|
+
setDialog({ kind: "correct", allergy });
|
|
558
|
+
break;
|
|
559
|
+
case "note":
|
|
560
|
+
setNoteDraft(allergy.note ?? "");
|
|
561
|
+
setDialog({ kind: "note", allergy });
|
|
562
|
+
break;
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
const addSearch = inlineAddSearch && effectiveCodeLookup && !readOnly ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
566
|
+
effectiveCodeLookup.component,
|
|
567
|
+
{
|
|
568
|
+
indexUrl: effectiveCodeLookup.indexUrl,
|
|
569
|
+
locale: effectiveCodeLookup.locale,
|
|
570
|
+
domains: ["med"],
|
|
571
|
+
bare: true,
|
|
572
|
+
clearOnSelect: true,
|
|
573
|
+
placeholder: m(
|
|
574
|
+
"Search drug allergens to add \u2014 use Add allergy\u2026 for food/environmental"
|
|
575
|
+
),
|
|
576
|
+
onSelect: (result) => {
|
|
577
|
+
if (requireCode && (!result.codetype.trim() || !result.fullcode.trim()))
|
|
578
|
+
return;
|
|
579
|
+
commit([
|
|
580
|
+
...allergies,
|
|
581
|
+
{
|
|
582
|
+
id: newId(),
|
|
583
|
+
allergen: result.label,
|
|
584
|
+
type: "drug",
|
|
585
|
+
code: {
|
|
586
|
+
system: result.codetype,
|
|
587
|
+
code: result.fullcode,
|
|
588
|
+
display: result.label
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
]);
|
|
592
|
+
},
|
|
593
|
+
onFreeText: requireCode ? void 0 : (text) => (
|
|
594
|
+
// this search bar is explicitly for drug allergens — free-text
|
|
595
|
+
// entries carry type 'drug' like the coded path
|
|
596
|
+
commit([
|
|
597
|
+
...allergies,
|
|
598
|
+
{ id: newId(), allergen: text, type: "drug" }
|
|
599
|
+
])
|
|
600
|
+
)
|
|
601
|
+
}
|
|
602
|
+
) : void 0;
|
|
603
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
604
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
605
|
+
AllergyList,
|
|
606
|
+
{
|
|
607
|
+
allergies,
|
|
608
|
+
noKnownAllergies,
|
|
609
|
+
onNoKnownAllergiesChange,
|
|
610
|
+
title,
|
|
611
|
+
onAction: handleAction,
|
|
612
|
+
onReorder: (ids) => commit(
|
|
613
|
+
[...allergies].sort((a, b) => ids.indexOf(a.id) - ids.indexOf(b.id))
|
|
614
|
+
),
|
|
615
|
+
addSearch,
|
|
616
|
+
onAdd: requireCode && !effectiveCodeLookup ? void 0 : () => setDialog({ kind: "add" }),
|
|
617
|
+
readOnly,
|
|
618
|
+
className,
|
|
619
|
+
"data-testid": dataTestId
|
|
620
|
+
}
|
|
621
|
+
),
|
|
622
|
+
dialog && (dialog.kind === "correct" || dialog.kind === "add") && /* @__PURE__ */ jsxRuntime.jsx(
|
|
623
|
+
AllergyEditor,
|
|
624
|
+
{
|
|
625
|
+
allergy: dialog.kind === "correct" ? dialog.allergy : void 0,
|
|
626
|
+
codeLookup: effectiveCodeLookup,
|
|
627
|
+
requireCode,
|
|
628
|
+
onClose: () => setDialog(null),
|
|
629
|
+
onSave: (saved) => {
|
|
630
|
+
if (dialog.kind === "correct") {
|
|
631
|
+
commit(allergies.map((a) => a.id === saved.id ? saved : a));
|
|
632
|
+
} else {
|
|
633
|
+
commit([...allergies, saved]);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
},
|
|
637
|
+
dialog.kind === "correct" ? dialog.allergy.id : "add"
|
|
638
|
+
),
|
|
639
|
+
dialog?.kind === "note" && /* @__PURE__ */ jsxRuntime.jsxs(chunkLC3JL2HB_cjs.Modal, { open: true, onOpenChange: (o) => !o && setDialog(null), size: "md", children: [
|
|
640
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkLC3JL2HB_cjs.ModalHeader, { children: [
|
|
641
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkLC3JL2HB_cjs.ModalTitle, { children: m("Allergy Notes") }),
|
|
642
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkLC3JL2HB_cjs.ModalClose, { "aria-label": m("Close") })
|
|
643
|
+
] }),
|
|
644
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkLC3JL2HB_cjs.ModalBody, { className: "space-y-4", children: [
|
|
645
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: dialog.allergy.allergen }),
|
|
646
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
647
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "alg-note-dlg", children: m("Note") }),
|
|
648
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
649
|
+
chunkXQHDQ64G_cjs.Textarea,
|
|
650
|
+
{
|
|
651
|
+
id: "alg-note-dlg",
|
|
652
|
+
value: noteDraft,
|
|
653
|
+
onChange: (e) => setNoteDraft(e.target.value),
|
|
654
|
+
rows: 4
|
|
655
|
+
}
|
|
656
|
+
)
|
|
657
|
+
] })
|
|
658
|
+
] }),
|
|
659
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkLC3JL2HB_cjs.ModalFooter, { children: [
|
|
660
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkANMX7YDL_cjs.Button, { variant: "secondary", onClick: () => setDialog(null), children: m("Cancel") }),
|
|
661
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
662
|
+
chunkANMX7YDL_cjs.Button,
|
|
663
|
+
{
|
|
664
|
+
onClick: () => {
|
|
665
|
+
commit(
|
|
666
|
+
allergies.map(
|
|
667
|
+
(a) => a.id === dialog.allergy.id ? { ...a, note: noteDraft.trim() || void 0 } : a
|
|
668
|
+
)
|
|
669
|
+
);
|
|
670
|
+
setDialog(null);
|
|
671
|
+
},
|
|
672
|
+
children: m("Save")
|
|
673
|
+
}
|
|
674
|
+
)
|
|
675
|
+
] })
|
|
676
|
+
] })
|
|
677
|
+
] });
|
|
678
|
+
}
|
|
679
|
+
function orderTypeForCodetype(codetype) {
|
|
680
|
+
const ct = codetype.toUpperCase();
|
|
681
|
+
if (["RXNORM", "FDB", "FDB MEDNAME", "NDC", "CVX"].includes(ct)) {
|
|
682
|
+
return "medication";
|
|
683
|
+
}
|
|
684
|
+
if (ct.startsWith("LOINC") || ct.endsWith("ORDER")) return "lab";
|
|
685
|
+
return "procedure";
|
|
686
|
+
}
|
|
687
|
+
function contextOrderSearch(ctx) {
|
|
688
|
+
const ContextOrderSearch = ({
|
|
689
|
+
domains,
|
|
690
|
+
preferDomains,
|
|
691
|
+
preferCodetypes,
|
|
692
|
+
billableOnly,
|
|
693
|
+
placeholder,
|
|
694
|
+
onPick,
|
|
695
|
+
onFreeText
|
|
696
|
+
}) => {
|
|
697
|
+
const Lookup = ctx.component;
|
|
698
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
699
|
+
Lookup,
|
|
700
|
+
{
|
|
701
|
+
indexUrl: ctx.indexUrl,
|
|
702
|
+
locale: ctx.locale,
|
|
703
|
+
domains,
|
|
704
|
+
preferDomains,
|
|
705
|
+
preferCodetypes,
|
|
706
|
+
billableOnly,
|
|
707
|
+
bare: true,
|
|
708
|
+
clearOnSelect: true,
|
|
709
|
+
placeholder,
|
|
710
|
+
onSelect: (result) => onPick({
|
|
711
|
+
fullid: result.fullid,
|
|
712
|
+
label: result.label,
|
|
713
|
+
codetype: result.codetype,
|
|
714
|
+
fullcode: result.fullcode
|
|
715
|
+
}),
|
|
716
|
+
onFreeText
|
|
717
|
+
}
|
|
718
|
+
);
|
|
719
|
+
};
|
|
720
|
+
return ContextOrderSearch;
|
|
721
|
+
}
|
|
722
|
+
function isConditionCodetype(codetype) {
|
|
723
|
+
const ct = codetype.toUpperCase();
|
|
724
|
+
return ct === "ICD10" || ct === "ICD9" || ct === "SNOMED US" || ct === "OSHA" || ct === "FMCSA" || ct === "NFPA" || ct === "FAA";
|
|
725
|
+
}
|
|
726
|
+
var ORDER_TYPE_SEARCH_DOMAINS = {
|
|
727
|
+
medication: ["med", "vaccine"],
|
|
728
|
+
lab: ["lab"],
|
|
729
|
+
imaging: ["procedure"],
|
|
730
|
+
procedure: ["procedure"],
|
|
731
|
+
referral: ["procedure"]
|
|
732
|
+
};
|
|
733
|
+
var ORDER_TYPE_PLACEHOLDERS = {
|
|
734
|
+
auto: "Search medications, labs, imaging, procedures\u2026",
|
|
735
|
+
medication: 'Search medications\u2026 (try "lasix")',
|
|
736
|
+
lab: 'Search labs\u2026 (try "a1c")',
|
|
737
|
+
imaging: 'Search imaging\u2026 (try "chest x")',
|
|
738
|
+
procedure: "Search procedures\u2026",
|
|
739
|
+
referral: "Search referrals & consults\u2026"
|
|
740
|
+
};
|
|
741
|
+
var ORDER_TYPE_META = {
|
|
742
|
+
medication: { label: "Medication", icon: chunkL7L5S2HO_cjs.Pill },
|
|
743
|
+
lab: { label: "Lab", icon: chunkL7L5S2HO_cjs.TestTube2 },
|
|
744
|
+
imaging: { label: "Imaging", icon: chunkL7L5S2HO_cjs.Scan },
|
|
745
|
+
procedure: { label: "Procedure", icon: chunkL7L5S2HO_cjs.Stethoscope },
|
|
746
|
+
referral: { label: "Referral", icon: chunkL7L5S2HO_cjs.Send }
|
|
747
|
+
};
|
|
748
|
+
var ACTION_META2 = {
|
|
749
|
+
refine: { label: "Refine (more specific)", icon: chunkL7L5S2HO_cjs.Pencil },
|
|
750
|
+
revise: { label: "Revise (prior was wrong)", icon: chunkL7L5S2HO_cjs.RefreshCw },
|
|
751
|
+
"add-order": { label: "Add order", icon: chunkL7L5S2HO_cjs.Plus }
|
|
752
|
+
};
|
|
753
|
+
function OrderContent({ order }) {
|
|
754
|
+
const m = chunkFSLI5IKP_cjs.useMessages();
|
|
755
|
+
const meta = ORDER_TYPE_META[order.type];
|
|
756
|
+
const Icon = meta.icon;
|
|
757
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground flex items-center gap-2 text-sm", children: [
|
|
758
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkGLG6UE2H_cjs.Tooltip, { content: m(meta.label), children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: 14 }) }),
|
|
759
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: m(meta.label) }),
|
|
760
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground", children: order.display }),
|
|
761
|
+
order.priority && order.priority !== "routine" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
762
|
+
chunk7E46YDOT_cjs.Badge,
|
|
763
|
+
{
|
|
764
|
+
variant: order.priority === "stat" ? "danger" : "warning",
|
|
765
|
+
size: "sm",
|
|
766
|
+
children: m(order.priority)
|
|
767
|
+
}
|
|
768
|
+
),
|
|
769
|
+
order.detail && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs", children: order.detail }),
|
|
770
|
+
order.timing && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs", children: order.timing })
|
|
771
|
+
] });
|
|
772
|
+
}
|
|
773
|
+
function OrderRow({
|
|
774
|
+
order,
|
|
775
|
+
drag,
|
|
776
|
+
controls
|
|
777
|
+
}) {
|
|
778
|
+
const m = chunkFSLI5IKP_cjs.useMessages();
|
|
779
|
+
const interactive = Boolean(
|
|
780
|
+
controls?.moveWithin || controls?.moveToProblem || controls?.edit || controls?.editStart || controls?.remove
|
|
781
|
+
);
|
|
782
|
+
const canEdit = Boolean(controls?.edit || controls?.editStart);
|
|
783
|
+
const [editing, setEditing] = React4__namespace.useState(null);
|
|
784
|
+
const [menuOpen, setMenuOpen] = React4__namespace.useState(false);
|
|
785
|
+
const pick = (fn) => () => {
|
|
786
|
+
setMenuOpen(false);
|
|
787
|
+
fn();
|
|
788
|
+
};
|
|
789
|
+
const beginEdit = () => {
|
|
790
|
+
if (controls?.editStart?.(order)) return;
|
|
791
|
+
if (controls?.edit) {
|
|
792
|
+
setEditing({ display: order.display, detail: order.detail ?? "" });
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
const saveEdit = () => {
|
|
796
|
+
if (!editing) return;
|
|
797
|
+
const display = editing.display.trim();
|
|
798
|
+
if (display) {
|
|
799
|
+
controls?.edit?.(order, {
|
|
800
|
+
display,
|
|
801
|
+
detail: editing.detail.trim() || void 0
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
setEditing(null);
|
|
805
|
+
};
|
|
806
|
+
const handleKeyDown = (e) => {
|
|
807
|
+
if (e.target !== e.currentTarget || !controls) return;
|
|
808
|
+
if (e.altKey && (e.key === "ArrowUp" || e.key === "ArrowDown")) {
|
|
809
|
+
e.preventDefault();
|
|
810
|
+
controls.moveWithin?.(order, e.key === "ArrowUp" ? -1 : 1);
|
|
811
|
+
} else if (e.altKey && (e.key === "ArrowLeft" || e.key === "ArrowRight")) {
|
|
812
|
+
e.preventDefault();
|
|
813
|
+
const back = chunkZ3WMDVMR_cjs.isRtl(e.currentTarget) ? "ArrowRight" : "ArrowLeft";
|
|
814
|
+
const adj = controls.adjacentProblem(order, e.key === back ? -1 : 1);
|
|
815
|
+
if (adj) controls.moveToProblem?.(order, adj.concernId);
|
|
816
|
+
} else if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
817
|
+
e.preventDefault();
|
|
818
|
+
const list = e.currentTarget.closest("ul");
|
|
819
|
+
if (!list) return;
|
|
820
|
+
const rows = Array.from(
|
|
821
|
+
list.querySelectorAll("li[data-order-id]")
|
|
822
|
+
);
|
|
823
|
+
const i = rows.indexOf(e.currentTarget);
|
|
824
|
+
rows[e.key === "ArrowUp" ? Math.max(0, i - 1) : Math.min(rows.length - 1, i + 1)]?.focus();
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
return (
|
|
828
|
+
// Order rows are focus stops so the drag interactions have a full keyboard
|
|
829
|
+
// equivalent: Alt+↑/↓ reorders, Alt+←/→ moves between problems (508).
|
|
830
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
831
|
+
"li",
|
|
832
|
+
{
|
|
833
|
+
"data-order-id": order.orderId,
|
|
834
|
+
tabIndex: interactive && !editing ? 0 : void 0,
|
|
835
|
+
onKeyDown: interactive && !editing ? handleKeyDown : void 0,
|
|
836
|
+
"aria-label": interactive && !editing ? m(
|
|
837
|
+
"{name}. Alt plus up or down to reorder; Alt plus left or right to move to another problem.",
|
|
838
|
+
{ name: order.display }
|
|
839
|
+
) : void 0,
|
|
840
|
+
...editing ? {} : drag.rowProps(order),
|
|
841
|
+
className: chunkS5RVSXDV_cjs.cn(
|
|
842
|
+
"group/order relative flex items-center gap-1.5 py-1",
|
|
843
|
+
"focus-visible:ring-ring rounded focus-visible:ring-2 focus-visible:outline-none",
|
|
844
|
+
drag.enabled && !editing && "cursor-grab active:cursor-grabbing",
|
|
845
|
+
drag.draggingId === order.orderId && "opacity-40",
|
|
846
|
+
drag.over?.type === "order" && drag.over.id === order.orderId && (drag.over.after ? "shadow-[inset_0_-2px_0_0_var(--color-primary-500,#3b82f6)]" : "shadow-[inset_0_2px_0_0_var(--color-primary-500,#3b82f6)]")
|
|
847
|
+
),
|
|
848
|
+
children: [
|
|
849
|
+
drag.enabled && !editing && /* @__PURE__ */ jsxRuntime.jsx(
|
|
850
|
+
chunkL7L5S2HO_cjs.GripVertical,
|
|
851
|
+
{
|
|
852
|
+
size: 12,
|
|
853
|
+
"aria-hidden": true,
|
|
854
|
+
className: "text-muted-foreground/40 shrink-0"
|
|
855
|
+
}
|
|
856
|
+
),
|
|
857
|
+
editing ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
858
|
+
"div",
|
|
859
|
+
{
|
|
860
|
+
role: "form",
|
|
861
|
+
"aria-label": m("Edit order {name}", { name: order.display }),
|
|
862
|
+
className: "flex flex-1 flex-wrap items-center gap-1.5",
|
|
863
|
+
children: [
|
|
864
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-40 flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
865
|
+
chunkZ5S5JEJD_cjs.Input,
|
|
866
|
+
{
|
|
867
|
+
autoFocus: true,
|
|
868
|
+
size: "sm",
|
|
869
|
+
value: editing.display,
|
|
870
|
+
onChange: (e) => setEditing(
|
|
871
|
+
(prev) => prev ? { ...prev, display: e.target.value } : prev
|
|
872
|
+
),
|
|
873
|
+
onKeyDown: (e) => {
|
|
874
|
+
if (e.key === "Enter") saveEdit();
|
|
875
|
+
else if (e.key === "Escape") setEditing(null);
|
|
876
|
+
},
|
|
877
|
+
"aria-label": m("Order description"),
|
|
878
|
+
className: "h-7"
|
|
879
|
+
}
|
|
880
|
+
) }),
|
|
881
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-40", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
882
|
+
chunkZ5S5JEJD_cjs.Input,
|
|
883
|
+
{
|
|
884
|
+
size: "sm",
|
|
885
|
+
value: editing.detail,
|
|
886
|
+
onChange: (e) => setEditing(
|
|
887
|
+
(prev) => prev ? { ...prev, detail: e.target.value } : prev
|
|
888
|
+
),
|
|
889
|
+
onKeyDown: (e) => {
|
|
890
|
+
if (e.key === "Enter") saveEdit();
|
|
891
|
+
else if (e.key === "Escape") setEditing(null);
|
|
892
|
+
},
|
|
893
|
+
placeholder: m("detail (sig, timing\u2026)"),
|
|
894
|
+
"aria-label": m("Order detail"),
|
|
895
|
+
className: "h-7 text-xs"
|
|
896
|
+
}
|
|
897
|
+
) }),
|
|
898
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
899
|
+
chunkANMX7YDL_cjs.Button,
|
|
900
|
+
{
|
|
901
|
+
variant: "outline",
|
|
902
|
+
size: "sm",
|
|
903
|
+
onClick: saveEdit,
|
|
904
|
+
disabled: !editing.display.trim(),
|
|
905
|
+
className: "h-7 text-xs",
|
|
906
|
+
children: m("Save")
|
|
907
|
+
}
|
|
908
|
+
),
|
|
909
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
910
|
+
chunkANMX7YDL_cjs.Button,
|
|
911
|
+
{
|
|
912
|
+
variant: "ghost",
|
|
913
|
+
size: "sm",
|
|
914
|
+
onClick: () => setEditing(null),
|
|
915
|
+
className: "h-7 text-xs",
|
|
916
|
+
children: m("Cancel")
|
|
917
|
+
}
|
|
918
|
+
)
|
|
919
|
+
]
|
|
920
|
+
}
|
|
921
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
922
|
+
/* @__PURE__ */ jsxRuntime.jsx(OrderContent, { order }),
|
|
923
|
+
interactive && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
924
|
+
chunk4NB4WOGU_cjs.RowActionToolbar,
|
|
925
|
+
{
|
|
926
|
+
label: m("Actions for {name}", { name: order.display }),
|
|
927
|
+
group: "order",
|
|
928
|
+
children: [
|
|
929
|
+
canEdit && /* @__PURE__ */ jsxRuntime.jsx(
|
|
930
|
+
chunk4NB4WOGU_cjs.RowIconButton,
|
|
931
|
+
{
|
|
932
|
+
label: m("Edit"),
|
|
933
|
+
icon: chunkL7L5S2HO_cjs.Pencil,
|
|
934
|
+
size: "sm",
|
|
935
|
+
onClick: beginEdit
|
|
936
|
+
}
|
|
937
|
+
),
|
|
938
|
+
(controls?.moveWithin || controls?.moveToProblem && controls.targets.some(
|
|
939
|
+
(t) => t.concernId !== order.concernId
|
|
940
|
+
)) && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
941
|
+
chunkPINIBEIU_cjs.Dropdown,
|
|
942
|
+
{
|
|
943
|
+
open: menuOpen,
|
|
944
|
+
onOpenChange: setMenuOpen,
|
|
945
|
+
trigger: /* @__PURE__ */ jsxRuntime.jsx(
|
|
946
|
+
chunkANMX7YDL_cjs.Button,
|
|
947
|
+
{
|
|
948
|
+
variant: "ghost",
|
|
949
|
+
size: "icon",
|
|
950
|
+
"aria-label": m("Move {name}", { name: order.display }),
|
|
951
|
+
className: "h-7 w-7 shrink-0",
|
|
952
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(chunkL7L5S2HO_cjs.MoreVertical, { size: 14 })
|
|
953
|
+
}
|
|
954
|
+
),
|
|
955
|
+
placement: "bottom-end",
|
|
956
|
+
children: [
|
|
957
|
+
controls?.moveWithin && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
958
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
959
|
+
chunkPINIBEIU_cjs.DropdownItem,
|
|
960
|
+
{
|
|
961
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(chunkL7L5S2HO_cjs.ChevronUp, { size: 14 }),
|
|
962
|
+
onClick: pick(() => controls.moveWithin?.(order, -1)),
|
|
963
|
+
children: m("Move up")
|
|
964
|
+
}
|
|
965
|
+
),
|
|
966
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
967
|
+
chunkPINIBEIU_cjs.DropdownItem,
|
|
968
|
+
{
|
|
969
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(chunkL7L5S2HO_cjs.ChevronDown, { size: 14 }),
|
|
970
|
+
onClick: pick(() => controls.moveWithin?.(order, 1)),
|
|
971
|
+
children: m("Move down")
|
|
972
|
+
}
|
|
973
|
+
)
|
|
974
|
+
] }),
|
|
975
|
+
controls?.moveToProblem && controls.targets.some(
|
|
976
|
+
(t) => t.concernId !== order.concernId
|
|
977
|
+
) && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
978
|
+
controls.moveWithin && /* @__PURE__ */ jsxRuntime.jsx(chunkPINIBEIU_cjs.DropdownSeparator, {}),
|
|
979
|
+
controls.targets.filter((t) => t.concernId !== order.concernId).map((t) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
980
|
+
chunkPINIBEIU_cjs.DropdownItem,
|
|
981
|
+
{
|
|
982
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(chunkL7L5S2HO_cjs.Link, { size: 14 }),
|
|
983
|
+
onClick: pick(
|
|
984
|
+
() => controls.moveToProblem?.(order, t.concernId)
|
|
985
|
+
),
|
|
986
|
+
children: m("Move to: {name}", { name: t.label })
|
|
987
|
+
},
|
|
988
|
+
t.concernId
|
|
989
|
+
))
|
|
990
|
+
] })
|
|
991
|
+
]
|
|
992
|
+
}
|
|
993
|
+
),
|
|
994
|
+
controls?.remove && /* @__PURE__ */ jsxRuntime.jsx(
|
|
995
|
+
chunk4NB4WOGU_cjs.RowIconButton,
|
|
996
|
+
{
|
|
997
|
+
label: m("Remove"),
|
|
998
|
+
icon: chunkL7L5S2HO_cjs.Trash2,
|
|
999
|
+
size: "sm",
|
|
1000
|
+
onClick: () => controls.remove?.(order)
|
|
1001
|
+
}
|
|
1002
|
+
)
|
|
1003
|
+
]
|
|
1004
|
+
}
|
|
1005
|
+
)
|
|
1006
|
+
] })
|
|
1007
|
+
]
|
|
1008
|
+
}
|
|
1009
|
+
)
|
|
1010
|
+
);
|
|
1011
|
+
}
|
|
1012
|
+
function AddOrderForm({
|
|
1013
|
+
id,
|
|
1014
|
+
problemText,
|
|
1015
|
+
onSubmit,
|
|
1016
|
+
onCancel,
|
|
1017
|
+
renderSearch
|
|
1018
|
+
}) {
|
|
1019
|
+
const m = chunkFSLI5IKP_cjs.useMessages();
|
|
1020
|
+
const [type, setType] = React4__namespace.useState(
|
|
1021
|
+
renderSearch ? "auto" : "medication"
|
|
1022
|
+
);
|
|
1023
|
+
const [display, setDisplay] = React4__namespace.useState("");
|
|
1024
|
+
const inputRef = React4__namespace.useRef(null);
|
|
1025
|
+
React4__namespace.useEffect(() => {
|
|
1026
|
+
inputRef.current?.focus();
|
|
1027
|
+
}, []);
|
|
1028
|
+
const submit = () => {
|
|
1029
|
+
const text = display.trim();
|
|
1030
|
+
if (!text) return;
|
|
1031
|
+
onSubmit({ type: type === "auto" ? "procedure" : type, display: text });
|
|
1032
|
+
setDisplay("");
|
|
1033
|
+
inputRef.current?.focus();
|
|
1034
|
+
};
|
|
1035
|
+
const handlePick = (pick) => {
|
|
1036
|
+
onSubmit({
|
|
1037
|
+
type: type === "auto" ? orderTypeForCodetype(pick.codetype) : type,
|
|
1038
|
+
display: pick.label,
|
|
1039
|
+
code: {
|
|
1040
|
+
fullid: pick.fullid,
|
|
1041
|
+
codetype: pick.codetype,
|
|
1042
|
+
fullcode: pick.fullcode
|
|
1043
|
+
}
|
|
1044
|
+
});
|
|
1045
|
+
};
|
|
1046
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1047
|
+
"div",
|
|
1048
|
+
{
|
|
1049
|
+
id,
|
|
1050
|
+
role: "form",
|
|
1051
|
+
"aria-label": m("Add order for {name}", { name: problemText }),
|
|
1052
|
+
className: "border-border bg-muted/40 ms-2.5 mt-1.5 flex flex-wrap items-center gap-1.5 rounded-md border border-dashed p-2",
|
|
1053
|
+
children: [
|
|
1054
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1055
|
+
"select",
|
|
1056
|
+
{
|
|
1057
|
+
"aria-label": m("Order type filter"),
|
|
1058
|
+
"data-slot": "select-trigger",
|
|
1059
|
+
value: type,
|
|
1060
|
+
onChange: (e) => setType(e.target.value),
|
|
1061
|
+
onKeyDown: (e) => {
|
|
1062
|
+
if (e.key === "Escape") onCancel();
|
|
1063
|
+
},
|
|
1064
|
+
className: chunkS5RVSXDV_cjs.cn(
|
|
1065
|
+
"border-border bg-background text-foreground rounded-md border px-1.5 text-sm",
|
|
1066
|
+
renderSearch ? "h-10" : "h-8",
|
|
1067
|
+
"focus:ring-ring focus:ring-2 focus:outline-none"
|
|
1068
|
+
),
|
|
1069
|
+
children: [
|
|
1070
|
+
renderSearch && /* @__PURE__ */ jsxRuntime.jsx("option", { value: "auto", children: m("Auto") }),
|
|
1071
|
+
Object.keys(ORDER_TYPE_META).map((t) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: t, children: m(ORDER_TYPE_META[t].label) }, t))
|
|
1072
|
+
]
|
|
1073
|
+
}
|
|
1074
|
+
),
|
|
1075
|
+
renderSearch ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-64 flex-1", children: renderSearch({
|
|
1076
|
+
domains: type === "auto" ? void 0 : ORDER_TYPE_SEARCH_DOMAINS[type],
|
|
1077
|
+
placeholder: m(ORDER_TYPE_PLACEHOLDERS[type]),
|
|
1078
|
+
onPick: handlePick,
|
|
1079
|
+
onFreeText: (text) => {
|
|
1080
|
+
const t = text.trim();
|
|
1081
|
+
if (!t) return;
|
|
1082
|
+
onSubmit({
|
|
1083
|
+
type: type === "auto" ? "procedure" : type,
|
|
1084
|
+
display: t
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
}) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1088
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-48 flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1089
|
+
chunkZ5S5JEJD_cjs.Input,
|
|
1090
|
+
{
|
|
1091
|
+
ref: inputRef,
|
|
1092
|
+
size: "sm",
|
|
1093
|
+
value: display,
|
|
1094
|
+
onChange: (e) => setDisplay(e.target.value),
|
|
1095
|
+
onKeyDown: (e) => {
|
|
1096
|
+
if (e.key === "Enter") submit();
|
|
1097
|
+
else if (e.key === "Escape") onCancel();
|
|
1098
|
+
},
|
|
1099
|
+
placeholder: m("e.g. lisinopril 10 mg tablet \u2014 1 po daily"),
|
|
1100
|
+
"aria-label": m("Order description")
|
|
1101
|
+
}
|
|
1102
|
+
) }),
|
|
1103
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1104
|
+
chunkANMX7YDL_cjs.Button,
|
|
1105
|
+
{
|
|
1106
|
+
variant: "outline",
|
|
1107
|
+
size: "sm",
|
|
1108
|
+
onClick: submit,
|
|
1109
|
+
disabled: !display.trim(),
|
|
1110
|
+
leftIcon: /* @__PURE__ */ jsxRuntime.jsx(chunkL7L5S2HO_cjs.Plus, { size: 12 }),
|
|
1111
|
+
className: "h-8",
|
|
1112
|
+
children: m("Add")
|
|
1113
|
+
}
|
|
1114
|
+
)
|
|
1115
|
+
] }),
|
|
1116
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1117
|
+
chunkANMX7YDL_cjs.Button,
|
|
1118
|
+
{
|
|
1119
|
+
variant: "ghost",
|
|
1120
|
+
size: "sm",
|
|
1121
|
+
onClick: onCancel,
|
|
1122
|
+
className: renderSearch ? "h-10" : "h-8",
|
|
1123
|
+
children: m("Done")
|
|
1124
|
+
}
|
|
1125
|
+
)
|
|
1126
|
+
]
|
|
1127
|
+
}
|
|
1128
|
+
);
|
|
1129
|
+
}
|
|
1130
|
+
var Assessment = React4__namespace.forwardRef(
|
|
1131
|
+
({
|
|
1132
|
+
concerns,
|
|
1133
|
+
items,
|
|
1134
|
+
orders = [],
|
|
1135
|
+
title = "Assessment & plan",
|
|
1136
|
+
showPlan = true,
|
|
1137
|
+
onShowPlanChange,
|
|
1138
|
+
onAction,
|
|
1139
|
+
rowActions = [
|
|
1140
|
+
...Object.keys(ACTION_META2),
|
|
1141
|
+
"remove",
|
|
1142
|
+
"move"
|
|
1143
|
+
],
|
|
1144
|
+
orderActions = ["edit", "remove", "move"],
|
|
1145
|
+
addModes,
|
|
1146
|
+
addFormLabel = "Add concern or order",
|
|
1147
|
+
addFormStart,
|
|
1148
|
+
onRemoveAssessment,
|
|
1149
|
+
onAddOrder,
|
|
1150
|
+
onAddAssessment,
|
|
1151
|
+
onLinkOrder,
|
|
1152
|
+
onEditOrderStart,
|
|
1153
|
+
onEditOrder,
|
|
1154
|
+
onRemoveOrder,
|
|
1155
|
+
onReorderItems,
|
|
1156
|
+
onReorderOrders,
|
|
1157
|
+
renderOrderSearch,
|
|
1158
|
+
readOnly = false,
|
|
1159
|
+
defaultAddMode = "auto",
|
|
1160
|
+
billableOnly = false,
|
|
1161
|
+
className,
|
|
1162
|
+
"data-testid": dataTestId,
|
|
1163
|
+
...props
|
|
1164
|
+
}, ref) => {
|
|
1165
|
+
const m = chunkFSLI5IKP_cjs.useMessages();
|
|
1166
|
+
const instanceId = React4__namespace.useId();
|
|
1167
|
+
const [addingFor, setAddingFor] = React4__namespace.useState(null);
|
|
1168
|
+
const requestedAddModes = addModes ?? [
|
|
1169
|
+
"auto",
|
|
1170
|
+
"problem",
|
|
1171
|
+
"order"
|
|
1172
|
+
];
|
|
1173
|
+
const availableAddModes = requestedAddModes.filter((mode) => {
|
|
1174
|
+
if (mode === "problem") return Boolean(onAddAssessment);
|
|
1175
|
+
if (mode === "order") return Boolean(onAddOrder);
|
|
1176
|
+
return Boolean(onAddAssessment && onAddOrder);
|
|
1177
|
+
});
|
|
1178
|
+
const initialAddMode = availableAddModes.includes(defaultAddMode) ? defaultAddMode : availableAddModes[0] ?? defaultAddMode;
|
|
1179
|
+
const [selectedAddMode, setSelectedAddMode] = React4__namespace.useState(initialAddMode);
|
|
1180
|
+
const addMode = availableAddModes.includes(selectedAddMode) ? selectedAddMode : availableAddModes[0] ?? defaultAddMode;
|
|
1181
|
+
const [pendingFreeText, setPendingFreeText] = React4__namespace.useState(
|
|
1182
|
+
null
|
|
1183
|
+
);
|
|
1184
|
+
React4__namespace.useEffect(() => {
|
|
1185
|
+
if (addMode !== "auto") setPendingFreeText(null);
|
|
1186
|
+
}, [addMode]);
|
|
1187
|
+
const [announcement, setAnnouncement] = chunkCPDNX3LS_cjs.useLiveAnnouncement();
|
|
1188
|
+
const ambientCodeLookup = useCodeLookupConfig();
|
|
1189
|
+
const effectiveRenderOrderSearch = renderOrderSearch === false ? void 0 : renderOrderSearch ?? (ambientCodeLookup ? contextOrderSearch(ambientCodeLookup) : void 0);
|
|
1190
|
+
const concernById = React4__namespace.useMemo(
|
|
1191
|
+
() => new Map(concerns.map((c) => [c.concernId, c])),
|
|
1192
|
+
[concerns]
|
|
1193
|
+
);
|
|
1194
|
+
const assertionOf = (item) => concernById.get(item.concernId)?.assertions.find((a) => a.id === item.assertionId);
|
|
1195
|
+
const unlinkedOrders = orders.filter(
|
|
1196
|
+
(o) => !o.concernId || !items.some((i) => i.concernId === o.concernId)
|
|
1197
|
+
);
|
|
1198
|
+
const toolbarActions = rowActions.filter(
|
|
1199
|
+
(action) => action in ACTION_META2 && (action === "add-order" ? Boolean(onAddOrder || onAction) : Boolean(onAction))
|
|
1200
|
+
);
|
|
1201
|
+
const showConcernToolbar = toolbarActions.length > 0 || rowActions.includes("remove") && Boolean(onRemoveAssessment);
|
|
1202
|
+
const drag = chunkGF2BE4FB_cjs.useDragReorder({
|
|
1203
|
+
ids: items.map((i) => i.concernId),
|
|
1204
|
+
onReorder: readOnly || !rowActions.includes("move") || !onReorderItems ? void 0 : (ids) => {
|
|
1205
|
+
setAnnouncement(m("Assessment concerns reordered"));
|
|
1206
|
+
onReorderItems(ids);
|
|
1207
|
+
}
|
|
1208
|
+
});
|
|
1209
|
+
const problemLabel = React4__namespace.useCallback(
|
|
1210
|
+
(concernId) => concernById.get(concernId)?.assertions.find(
|
|
1211
|
+
(a) => items.some(
|
|
1212
|
+
(i) => i.concernId === concernId && i.assertionId === a.id
|
|
1213
|
+
)
|
|
1214
|
+
)?.text ?? concernId,
|
|
1215
|
+
[concernById, items]
|
|
1216
|
+
);
|
|
1217
|
+
const orderControls = readOnly ? void 0 : {
|
|
1218
|
+
moveWithin: orderActions.includes("move") && onReorderOrders ? (order, dir) => {
|
|
1219
|
+
const planIds = orders.filter((o) => o.concernId === order.concernId).map((o) => o.orderId);
|
|
1220
|
+
const i = planIds.indexOf(order.orderId);
|
|
1221
|
+
const target = planIds[i + dir];
|
|
1222
|
+
if (!target) return;
|
|
1223
|
+
onReorderOrders(
|
|
1224
|
+
chunkGF2BE4FB_cjs.reorderIds(
|
|
1225
|
+
orders.map((o) => o.orderId),
|
|
1226
|
+
order.orderId,
|
|
1227
|
+
target,
|
|
1228
|
+
dir === 1
|
|
1229
|
+
)
|
|
1230
|
+
);
|
|
1231
|
+
setAnnouncement(
|
|
1232
|
+
m(dir === -1 ? "{name} moved up" : "{name} moved down", {
|
|
1233
|
+
name: order.display
|
|
1234
|
+
})
|
|
1235
|
+
);
|
|
1236
|
+
} : void 0,
|
|
1237
|
+
moveToProblem: orderActions.includes("move") && onLinkOrder ? (order, concernId) => {
|
|
1238
|
+
onLinkOrder(order, concernId);
|
|
1239
|
+
setAnnouncement(
|
|
1240
|
+
m("{name} moved to {target}", {
|
|
1241
|
+
name: order.display,
|
|
1242
|
+
target: problemLabel(concernId)
|
|
1243
|
+
})
|
|
1244
|
+
);
|
|
1245
|
+
} : void 0,
|
|
1246
|
+
edit: orderActions.includes("edit") && onEditOrder ? (order, changes) => {
|
|
1247
|
+
onEditOrder(order, changes);
|
|
1248
|
+
setAnnouncement(
|
|
1249
|
+
m("{name} updated", { name: changes.display })
|
|
1250
|
+
);
|
|
1251
|
+
} : void 0,
|
|
1252
|
+
editStart: orderActions.includes("edit") ? onEditOrderStart : void 0,
|
|
1253
|
+
remove: orderActions.includes("remove") && onRemoveOrder ? (order) => {
|
|
1254
|
+
onRemoveOrder(order);
|
|
1255
|
+
setAnnouncement(m("{name} removed", { name: order.display }));
|
|
1256
|
+
} : void 0,
|
|
1257
|
+
adjacentProblem: (order, dir) => {
|
|
1258
|
+
const i = items.findIndex((it) => it.concernId === order.concernId);
|
|
1259
|
+
const adj = items[i + dir];
|
|
1260
|
+
return adj ? { concernId: adj.concernId, label: problemLabel(adj.concernId) } : null;
|
|
1261
|
+
},
|
|
1262
|
+
targets: items.map((it) => ({
|
|
1263
|
+
concernId: it.concernId,
|
|
1264
|
+
label: problemLabel(it.concernId)
|
|
1265
|
+
}))
|
|
1266
|
+
};
|
|
1267
|
+
const orderDragEnabled = !readOnly && orderActions.includes("move") && Boolean(onReorderOrders || onLinkOrder);
|
|
1268
|
+
const [draggingOrderId, setDraggingOrderId] = React4__namespace.useState(
|
|
1269
|
+
null
|
|
1270
|
+
);
|
|
1271
|
+
const draggingOrderRef = React4__namespace.useRef(null);
|
|
1272
|
+
const [orderOver, setOrderOver] = React4__namespace.useState(null);
|
|
1273
|
+
const resetOrderDrag = () => {
|
|
1274
|
+
draggingOrderRef.current = null;
|
|
1275
|
+
setDraggingOrderId(null);
|
|
1276
|
+
setOrderOver(null);
|
|
1277
|
+
};
|
|
1278
|
+
const dropOnOrder = (dragged, target, after) => {
|
|
1279
|
+
if (dragged.concernId !== target.concernId && target.concernId) {
|
|
1280
|
+
onLinkOrder?.(dragged, target.concernId);
|
|
1281
|
+
setAnnouncement(
|
|
1282
|
+
m("{name} moved to {target}", {
|
|
1283
|
+
name: dragged.display,
|
|
1284
|
+
target: problemLabel(target.concernId)
|
|
1285
|
+
})
|
|
1286
|
+
);
|
|
1287
|
+
} else {
|
|
1288
|
+
setAnnouncement(m("{name} reordered", { name: dragged.display }));
|
|
1289
|
+
}
|
|
1290
|
+
onReorderOrders?.(
|
|
1291
|
+
chunkGF2BE4FB_cjs.reorderIds(
|
|
1292
|
+
orders.map((o) => o.orderId),
|
|
1293
|
+
dragged.orderId,
|
|
1294
|
+
target.orderId,
|
|
1295
|
+
after
|
|
1296
|
+
)
|
|
1297
|
+
);
|
|
1298
|
+
};
|
|
1299
|
+
const orderDrag = {
|
|
1300
|
+
enabled: orderDragEnabled,
|
|
1301
|
+
draggingId: draggingOrderId,
|
|
1302
|
+
over: orderOver,
|
|
1303
|
+
rowProps: (order) => orderDragEnabled ? {
|
|
1304
|
+
draggable: true,
|
|
1305
|
+
onDragStart: (e) => {
|
|
1306
|
+
e.stopPropagation();
|
|
1307
|
+
e.dataTransfer.effectAllowed = "move";
|
|
1308
|
+
e.dataTransfer.setData("text/plain", order.orderId);
|
|
1309
|
+
draggingOrderRef.current = order.orderId;
|
|
1310
|
+
setDraggingOrderId(order.orderId);
|
|
1311
|
+
},
|
|
1312
|
+
onDragEnd: (e) => {
|
|
1313
|
+
e.stopPropagation();
|
|
1314
|
+
resetOrderDrag();
|
|
1315
|
+
},
|
|
1316
|
+
onDragOver: (e) => {
|
|
1317
|
+
const dragged = draggingOrderRef.current;
|
|
1318
|
+
if (!dragged || dragged === order.orderId) return;
|
|
1319
|
+
e.preventDefault();
|
|
1320
|
+
e.stopPropagation();
|
|
1321
|
+
e.dataTransfer.dropEffect = "move";
|
|
1322
|
+
const r = e.currentTarget.getBoundingClientRect();
|
|
1323
|
+
const after = e.clientY > r.top + r.height / 2;
|
|
1324
|
+
setOrderOver({ type: "order", id: order.orderId, after });
|
|
1325
|
+
},
|
|
1326
|
+
onDrop: (e) => {
|
|
1327
|
+
const draggedId = draggingOrderRef.current ?? e.dataTransfer.getData("text/plain");
|
|
1328
|
+
const dragged = orders.find((o) => o.orderId === draggedId);
|
|
1329
|
+
if (!dragged || dragged.orderId === order.orderId) return;
|
|
1330
|
+
e.preventDefault();
|
|
1331
|
+
e.stopPropagation();
|
|
1332
|
+
const r = e.currentTarget.getBoundingClientRect();
|
|
1333
|
+
const after = e.clientY > r.top + r.height / 2;
|
|
1334
|
+
dropOnOrder(dragged, order, after);
|
|
1335
|
+
resetOrderDrag();
|
|
1336
|
+
}
|
|
1337
|
+
} : {}
|
|
1338
|
+
};
|
|
1339
|
+
const blockProps = (concernId) => {
|
|
1340
|
+
const itemProps = drag.rowProps(concernId);
|
|
1341
|
+
if (!orderDragEnabled) return itemProps;
|
|
1342
|
+
return {
|
|
1343
|
+
...itemProps,
|
|
1344
|
+
onDragOver: (e) => {
|
|
1345
|
+
const draggingOrder = draggingOrderRef.current;
|
|
1346
|
+
if (draggingOrder) {
|
|
1347
|
+
const dragged = orders.find((o) => o.orderId === draggingOrder);
|
|
1348
|
+
if (dragged?.concernId === concernId) return;
|
|
1349
|
+
e.preventDefault();
|
|
1350
|
+
e.dataTransfer.dropEffect = "move";
|
|
1351
|
+
setOrderOver({ type: "concern", concernId });
|
|
1352
|
+
return;
|
|
1353
|
+
}
|
|
1354
|
+
itemProps.onDragOver?.(e);
|
|
1355
|
+
},
|
|
1356
|
+
onDragLeave: (e) => {
|
|
1357
|
+
if (draggingOrderRef.current) {
|
|
1358
|
+
setOrderOver(
|
|
1359
|
+
(prev) => prev?.type === "concern" && prev.concernId === concernId ? null : prev
|
|
1360
|
+
);
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
itemProps.onDragLeave?.(e);
|
|
1364
|
+
},
|
|
1365
|
+
onDrop: (e) => {
|
|
1366
|
+
const payload = draggingOrderRef.current ?? e.dataTransfer.getData("text/plain");
|
|
1367
|
+
const dragged = orders.find((o) => o.orderId === payload);
|
|
1368
|
+
if (dragged) {
|
|
1369
|
+
e.preventDefault();
|
|
1370
|
+
if (dragged.concernId !== concernId) {
|
|
1371
|
+
onLinkOrder?.(dragged, concernId);
|
|
1372
|
+
setAnnouncement(
|
|
1373
|
+
m("{name} moved to {target}", {
|
|
1374
|
+
name: dragged.display,
|
|
1375
|
+
target: problemLabel(concernId)
|
|
1376
|
+
})
|
|
1377
|
+
);
|
|
1378
|
+
}
|
|
1379
|
+
resetOrderDrag();
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1382
|
+
itemProps.onDrop?.(e);
|
|
1383
|
+
}
|
|
1384
|
+
};
|
|
1385
|
+
};
|
|
1386
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1387
|
+
chunkMJWFNV3L_cjs.Card,
|
|
1388
|
+
{
|
|
1389
|
+
ref,
|
|
1390
|
+
padding: "none",
|
|
1391
|
+
className: chunkS5RVSXDV_cjs.cn("w-full", className),
|
|
1392
|
+
"data-testid": dataTestId,
|
|
1393
|
+
...props,
|
|
1394
|
+
children: [
|
|
1395
|
+
title !== null && /* @__PURE__ */ jsxRuntime.jsxs(chunkMJWFNV3L_cjs.CardHeader, { className: "border-border bg-muted/50 flex flex-row items-center justify-between border-b px-4 py-3", children: [
|
|
1396
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-foreground text-sm font-semibold tracking-wide uppercase", children: m(title) }),
|
|
1397
|
+
onShowPlanChange && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1398
|
+
chunk7AECNMYV_cjs.Checkbox,
|
|
1399
|
+
{
|
|
1400
|
+
size: "sm",
|
|
1401
|
+
checked: showPlan,
|
|
1402
|
+
onChange: (e) => onShowPlanChange(e.target.checked),
|
|
1403
|
+
label: m("Show plan")
|
|
1404
|
+
}
|
|
1405
|
+
)
|
|
1406
|
+
] }),
|
|
1407
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkMJWFNV3L_cjs.CardContent, { className: "space-y-4 px-4 py-4", children: [
|
|
1408
|
+
items.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: m("No problems assessed this visit.") }),
|
|
1409
|
+
/* @__PURE__ */ jsxRuntime.jsx("ol", { className: "space-y-3", children: items.map((item, index) => {
|
|
1410
|
+
const assertion = assertionOf(item);
|
|
1411
|
+
if (!assertion) return null;
|
|
1412
|
+
const linkedOrders = orders.filter(
|
|
1413
|
+
(o) => o.concernId === item.concernId
|
|
1414
|
+
);
|
|
1415
|
+
const bp = blockProps(item.concernId);
|
|
1416
|
+
const formOpen = addingFor === item.concernId;
|
|
1417
|
+
const addOrderFormId = `${instanceId}-add-order-${item.concernId}`;
|
|
1418
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1419
|
+
"li",
|
|
1420
|
+
{
|
|
1421
|
+
"data-slot": "assessment-problem",
|
|
1422
|
+
"data-concern-id": item.concernId,
|
|
1423
|
+
...bp,
|
|
1424
|
+
draggable: drag.enabled && !formOpen,
|
|
1425
|
+
className: chunkS5RVSXDV_cjs.cn(
|
|
1426
|
+
"group border-border/60 relative rounded-md border px-3 py-2",
|
|
1427
|
+
drag.enabled && !formOpen && "cursor-grab active:cursor-grabbing",
|
|
1428
|
+
chunkGF2BE4FB_cjs.dragIndicatorClasses(drag, item.concernId),
|
|
1429
|
+
orderOver?.type === "concern" && orderOver.concernId === item.concernId && "ring-primary-400 bg-primary-50/50 dark:bg-primary-950/50 ring-2"
|
|
1430
|
+
),
|
|
1431
|
+
children: [
|
|
1432
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1433
|
+
"div",
|
|
1434
|
+
{
|
|
1435
|
+
className: chunkS5RVSXDV_cjs.cn(
|
|
1436
|
+
"flex flex-wrap items-center gap-x-2 gap-y-1",
|
|
1437
|
+
drag.enabled && formOpen && "cursor-grab active:cursor-grabbing"
|
|
1438
|
+
),
|
|
1439
|
+
draggable: drag.enabled && formOpen,
|
|
1440
|
+
onDragStart: formOpen ? bp.onDragStart : void 0,
|
|
1441
|
+
onDragEnd: formOpen ? bp.onDragEnd : void 0,
|
|
1442
|
+
children: [
|
|
1443
|
+
drag.enabled && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1444
|
+
chunkL7L5S2HO_cjs.GripVertical,
|
|
1445
|
+
{
|
|
1446
|
+
size: 14,
|
|
1447
|
+
"aria-hidden": true,
|
|
1448
|
+
className: "text-muted-foreground/50 shrink-0"
|
|
1449
|
+
}
|
|
1450
|
+
),
|
|
1451
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground text-sm font-semibold tabular-nums", children: [
|
|
1452
|
+
index + 1,
|
|
1453
|
+
"."
|
|
1454
|
+
] }),
|
|
1455
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground font-medium", children: assertion.text }),
|
|
1456
|
+
assertion.verificationStatus !== "confirmed" && /* @__PURE__ */ jsxRuntime.jsx(chunk7E46YDOT_cjs.Badge, { variant: "warning", size: "sm", children: m(assertion.verificationStatus) }),
|
|
1457
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunk4NB4WOGU_cjs.CodingChips, { coding: assertion.coding }),
|
|
1458
|
+
!readOnly && showConcernToolbar && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1459
|
+
chunk4NB4WOGU_cjs.RowActionToolbar,
|
|
1460
|
+
{
|
|
1461
|
+
label: m("Actions for {name}", {
|
|
1462
|
+
name: assertion.text
|
|
1463
|
+
}),
|
|
1464
|
+
align: "top",
|
|
1465
|
+
className: chunkS5RVSXDV_cjs.cn(
|
|
1466
|
+
"pointer-fine:group-has-[[data-order-id]:hover]:pointer-events-none",
|
|
1467
|
+
"pointer-fine:group-has-[[data-order-id]:hover]:opacity-0",
|
|
1468
|
+
"pointer-fine:group-has-[[data-order-id]:focus-within]:pointer-events-none",
|
|
1469
|
+
"pointer-fine:group-has-[[data-order-id]:focus-within]:opacity-0"
|
|
1470
|
+
),
|
|
1471
|
+
children: [
|
|
1472
|
+
toolbarActions.map((action) => {
|
|
1473
|
+
const meta = ACTION_META2[action];
|
|
1474
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1475
|
+
chunk4NB4WOGU_cjs.RowIconButton,
|
|
1476
|
+
{
|
|
1477
|
+
label: m(meta.label),
|
|
1478
|
+
icon: meta.icon,
|
|
1479
|
+
size: "sm",
|
|
1480
|
+
expanded: action === "add-order" && onAddOrder ? addingFor === item.concernId : void 0,
|
|
1481
|
+
controls: action === "add-order" && onAddOrder ? addOrderFormId : void 0,
|
|
1482
|
+
onClick: () => {
|
|
1483
|
+
if (action === "add-order" && onAddOrder) {
|
|
1484
|
+
setAddingFor(
|
|
1485
|
+
(prev) => prev === item.concernId ? null : item.concernId
|
|
1486
|
+
);
|
|
1487
|
+
} else {
|
|
1488
|
+
onAction?.(item, action);
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
},
|
|
1492
|
+
action
|
|
1493
|
+
);
|
|
1494
|
+
}),
|
|
1495
|
+
rowActions.includes("remove") && onRemoveAssessment && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1496
|
+
chunk4NB4WOGU_cjs.RowIconButton,
|
|
1497
|
+
{
|
|
1498
|
+
label: m("Remove {name} from assessment", {
|
|
1499
|
+
name: assertion.text
|
|
1500
|
+
}),
|
|
1501
|
+
icon: chunkL7L5S2HO_cjs.Trash2,
|
|
1502
|
+
size: "sm",
|
|
1503
|
+
onClick: () => {
|
|
1504
|
+
onRemoveAssessment(item);
|
|
1505
|
+
setAnnouncement(
|
|
1506
|
+
m("{name} removed from assessment", {
|
|
1507
|
+
name: assertion.text
|
|
1508
|
+
})
|
|
1509
|
+
);
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
)
|
|
1513
|
+
]
|
|
1514
|
+
}
|
|
1515
|
+
)
|
|
1516
|
+
]
|
|
1517
|
+
}
|
|
1518
|
+
),
|
|
1519
|
+
item.note && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground mt-1 ps-6 text-sm", children: item.note }),
|
|
1520
|
+
showPlan && linkedOrders.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1521
|
+
"ul",
|
|
1522
|
+
{
|
|
1523
|
+
"aria-label": m("Plan for {name}", {
|
|
1524
|
+
name: assertion.text
|
|
1525
|
+
}),
|
|
1526
|
+
className: "border-border ms-2.5 mt-1.5 border-s ps-4",
|
|
1527
|
+
children: linkedOrders.map((order) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1528
|
+
OrderRow,
|
|
1529
|
+
{
|
|
1530
|
+
order,
|
|
1531
|
+
drag: orderDrag,
|
|
1532
|
+
controls: orderControls
|
|
1533
|
+
},
|
|
1534
|
+
order.orderId
|
|
1535
|
+
))
|
|
1536
|
+
}
|
|
1537
|
+
),
|
|
1538
|
+
!readOnly && onAddOrder && addingFor === item.concernId && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1539
|
+
AddOrderForm,
|
|
1540
|
+
{
|
|
1541
|
+
id: addOrderFormId,
|
|
1542
|
+
problemText: assertion.text,
|
|
1543
|
+
onSubmit: (order) => {
|
|
1544
|
+
onAddOrder(item, order);
|
|
1545
|
+
setAnnouncement(
|
|
1546
|
+
m("{name} added to {target}", {
|
|
1547
|
+
name: order.display,
|
|
1548
|
+
target: assertion.text
|
|
1549
|
+
})
|
|
1550
|
+
);
|
|
1551
|
+
setAddingFor(null);
|
|
1552
|
+
},
|
|
1553
|
+
onCancel: () => setAddingFor(null),
|
|
1554
|
+
renderSearch: effectiveRenderOrderSearch
|
|
1555
|
+
}
|
|
1556
|
+
)
|
|
1557
|
+
]
|
|
1558
|
+
},
|
|
1559
|
+
item.concernId
|
|
1560
|
+
);
|
|
1561
|
+
}) }),
|
|
1562
|
+
!readOnly && availableAddModes.length > 0 && effectiveRenderOrderSearch && (onAddAssessment || onAddOrder) && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1563
|
+
"div",
|
|
1564
|
+
{
|
|
1565
|
+
role: "form",
|
|
1566
|
+
"aria-label": m(addFormLabel),
|
|
1567
|
+
className: "border-border bg-muted/40 flex flex-col items-stretch gap-2 rounded-md border border-dashed p-2 sm:flex-row sm:flex-wrap sm:items-end",
|
|
1568
|
+
children: [
|
|
1569
|
+
addFormStart,
|
|
1570
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1571
|
+
"select",
|
|
1572
|
+
{
|
|
1573
|
+
"aria-label": m("What to add"),
|
|
1574
|
+
"data-slot": "select-trigger",
|
|
1575
|
+
value: addMode,
|
|
1576
|
+
onChange: (e) => {
|
|
1577
|
+
setSelectedAddMode(e.target.value);
|
|
1578
|
+
setPendingFreeText(null);
|
|
1579
|
+
},
|
|
1580
|
+
className: chunkS5RVSXDV_cjs.cn(
|
|
1581
|
+
"border-border bg-background text-foreground h-10 rounded-md border px-1.5 text-sm",
|
|
1582
|
+
"focus:ring-ring focus:ring-2 focus:outline-none"
|
|
1583
|
+
),
|
|
1584
|
+
children: [
|
|
1585
|
+
availableAddModes.includes("auto") && /* @__PURE__ */ jsxRuntime.jsx("option", { value: "auto", children: m("Add (auto)") }),
|
|
1586
|
+
availableAddModes.includes("problem") && onAddAssessment && /* @__PURE__ */ jsxRuntime.jsx("option", { value: "problem", children: m("Add concern") }),
|
|
1587
|
+
availableAddModes.includes("order") && onAddOrder && /* @__PURE__ */ jsxRuntime.jsx("option", { value: "order", children: m("Add order") })
|
|
1588
|
+
]
|
|
1589
|
+
}
|
|
1590
|
+
),
|
|
1591
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-64 flex-1", children: effectiveRenderOrderSearch({
|
|
1592
|
+
domains: addMode === "problem" ? ["condition", "occupational"] : addMode === "order" ? ["med", "lab", "procedure", "vaccine"] : void 0,
|
|
1593
|
+
// auto: everything — the pick decides
|
|
1594
|
+
// auto: concerns rank ahead of orders — surveillance
|
|
1595
|
+
// programs first (rare, high-value hits like "dot" or
|
|
1596
|
+
// "hearing"), then diagnoses, then meds/labs/procedures.
|
|
1597
|
+
// concern mode: programs still lead the diagnoses.
|
|
1598
|
+
preferDomains: addMode === "auto" ? ["occupational", "condition"] : addMode === "problem" ? ["occupational"] : void 0,
|
|
1599
|
+
// assessments code in ICD-10: boost it over SNOMED
|
|
1600
|
+
preferCodetypes: addMode !== "order" ? ["ICD10"] : void 0,
|
|
1601
|
+
billableOnly: addMode !== "order" && billableOnly,
|
|
1602
|
+
placeholder: m(
|
|
1603
|
+
addMode === "problem" ? 'Search diagnoses & programs\u2026 (try "chf" or "hearing conservation")' : addMode === "order" ? "Search medications, labs, imaging, procedures\u2026" : "Add concern or order\u2026 (a diagnosis or surveillance program becomes a concern; meds, labs & imaging become orders)"
|
|
1604
|
+
),
|
|
1605
|
+
onPick: (pick) => {
|
|
1606
|
+
const asProblem = addMode === "problem" || addMode === "auto" && isConditionCodetype(pick.codetype) && Boolean(onAddAssessment);
|
|
1607
|
+
if (asProblem) {
|
|
1608
|
+
onAddAssessment?.({
|
|
1609
|
+
label: pick.label,
|
|
1610
|
+
code: {
|
|
1611
|
+
fullid: pick.fullid,
|
|
1612
|
+
codetype: pick.codetype,
|
|
1613
|
+
fullcode: pick.fullcode
|
|
1614
|
+
}
|
|
1615
|
+
});
|
|
1616
|
+
} else {
|
|
1617
|
+
onAddOrder?.(null, {
|
|
1618
|
+
type: orderTypeForCodetype(pick.codetype),
|
|
1619
|
+
display: pick.label,
|
|
1620
|
+
code: {
|
|
1621
|
+
fullid: pick.fullid,
|
|
1622
|
+
codetype: pick.codetype,
|
|
1623
|
+
fullcode: pick.fullcode
|
|
1624
|
+
}
|
|
1625
|
+
});
|
|
1626
|
+
}
|
|
1627
|
+
},
|
|
1628
|
+
onFreeText: (text) => {
|
|
1629
|
+
if (addMode === "problem") {
|
|
1630
|
+
onAddAssessment?.({ label: text });
|
|
1631
|
+
} else if (addMode === "order") {
|
|
1632
|
+
onAddOrder?.(null, {
|
|
1633
|
+
type: "procedure",
|
|
1634
|
+
display: text
|
|
1635
|
+
});
|
|
1636
|
+
} else {
|
|
1637
|
+
setPendingFreeText(text);
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
}) }),
|
|
1641
|
+
addMode === "auto" && pendingFreeText !== null && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1642
|
+
"div",
|
|
1643
|
+
{
|
|
1644
|
+
role: "group",
|
|
1645
|
+
"aria-label": m('Add "{name}" as', { name: pendingFreeText }),
|
|
1646
|
+
className: "flex w-full flex-wrap items-center gap-1.5 ps-1",
|
|
1647
|
+
children: [
|
|
1648
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground text-sm", children: [
|
|
1649
|
+
m("Add"),
|
|
1650
|
+
" ",
|
|
1651
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-foreground font-medium", children: [
|
|
1652
|
+
"\u201C",
|
|
1653
|
+
pendingFreeText,
|
|
1654
|
+
"\u201D"
|
|
1655
|
+
] }),
|
|
1656
|
+
" ",
|
|
1657
|
+
m("as:")
|
|
1658
|
+
] }),
|
|
1659
|
+
onAddAssessment && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1660
|
+
chunkANMX7YDL_cjs.Button,
|
|
1661
|
+
{
|
|
1662
|
+
variant: "outline",
|
|
1663
|
+
size: "sm",
|
|
1664
|
+
className: "h-7 text-xs",
|
|
1665
|
+
onClick: () => {
|
|
1666
|
+
onAddAssessment({ label: pendingFreeText });
|
|
1667
|
+
setPendingFreeText(null);
|
|
1668
|
+
},
|
|
1669
|
+
children: m("Concern")
|
|
1670
|
+
}
|
|
1671
|
+
),
|
|
1672
|
+
onAddOrder && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1673
|
+
chunkANMX7YDL_cjs.Button,
|
|
1674
|
+
{
|
|
1675
|
+
variant: "outline",
|
|
1676
|
+
size: "sm",
|
|
1677
|
+
className: "h-7 text-xs",
|
|
1678
|
+
onClick: () => {
|
|
1679
|
+
onAddOrder(null, {
|
|
1680
|
+
type: "procedure",
|
|
1681
|
+
display: pendingFreeText
|
|
1682
|
+
});
|
|
1683
|
+
setPendingFreeText(null);
|
|
1684
|
+
},
|
|
1685
|
+
children: m("Order")
|
|
1686
|
+
}
|
|
1687
|
+
),
|
|
1688
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1689
|
+
chunkANMX7YDL_cjs.Button,
|
|
1690
|
+
{
|
|
1691
|
+
variant: "ghost",
|
|
1692
|
+
size: "sm",
|
|
1693
|
+
className: "h-7 text-xs",
|
|
1694
|
+
onClick: () => setPendingFreeText(null),
|
|
1695
|
+
children: m("Cancel")
|
|
1696
|
+
}
|
|
1697
|
+
)
|
|
1698
|
+
]
|
|
1699
|
+
}
|
|
1700
|
+
)
|
|
1701
|
+
]
|
|
1702
|
+
}
|
|
1703
|
+
),
|
|
1704
|
+
showPlan && unlinkedOrders.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1705
|
+
"section",
|
|
1706
|
+
{
|
|
1707
|
+
"aria-label": m("Orders not linked to a concern"),
|
|
1708
|
+
className: "rounded-md border border-amber-300 bg-amber-50 px-3 py-2 dark:border-amber-700 dark:bg-amber-950",
|
|
1709
|
+
children: [
|
|
1710
|
+
/* @__PURE__ */ jsxRuntime.jsxs("h4", { className: "flex items-center gap-1.5 text-sm font-semibold text-amber-900 dark:text-amber-200", children: [
|
|
1711
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkL7L5S2HO_cjs.AlertCircle, { size: 14 }),
|
|
1712
|
+
m("Orders not linked to a concern")
|
|
1713
|
+
] }),
|
|
1714
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "mt-1", children: unlinkedOrders.map((order) => (
|
|
1715
|
+
// Same row component as linked orders: focusable, Alt+arrow
|
|
1716
|
+
// keyboard moves, and the Move menu (508 parity with drag)
|
|
1717
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1718
|
+
OrderRow,
|
|
1719
|
+
{
|
|
1720
|
+
order,
|
|
1721
|
+
drag: orderDrag,
|
|
1722
|
+
controls: orderControls
|
|
1723
|
+
},
|
|
1724
|
+
order.orderId
|
|
1725
|
+
)
|
|
1726
|
+
)) })
|
|
1727
|
+
]
|
|
1728
|
+
}
|
|
1729
|
+
)
|
|
1730
|
+
] }),
|
|
1731
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { "aria-live": "polite", className: "sr-only", children: announcement })
|
|
1732
|
+
]
|
|
1733
|
+
}
|
|
1734
|
+
);
|
|
1735
|
+
}
|
|
1736
|
+
);
|
|
1737
|
+
Assessment.displayName = "Assessment";
|
|
1738
|
+
var MODE_META = {
|
|
1739
|
+
add: { title: "Add problem", changeType: void 0 },
|
|
1740
|
+
observe: { title: "Progress observation", changeType: void 0 },
|
|
1741
|
+
refine: { title: "Refine problem", changeType: "refinement" },
|
|
1742
|
+
revise: { title: "Revise problem", changeType: "revision" },
|
|
1743
|
+
relate: { title: "Relate problem", changeType: void 0 }
|
|
1744
|
+
};
|
|
1745
|
+
var CODING_SYSTEMS = ["SNOMED", "ICD-10-CM", "ICD-11"];
|
|
1746
|
+
var VERIFICATION_OPTIONS = [
|
|
1747
|
+
{ value: "unconfirmed", label: "Unconfirmed" },
|
|
1748
|
+
{ value: "provisional", label: "Provisional" },
|
|
1749
|
+
{ value: "differential", label: "Differential" },
|
|
1750
|
+
{ value: "confirmed", label: "Confirmed" }
|
|
1751
|
+
];
|
|
1752
|
+
var RELATIONSHIP_OPTIONS = [
|
|
1753
|
+
{ value: "caused-by", label: "Caused by" },
|
|
1754
|
+
{ value: "evolved-from", label: "Evolved from" },
|
|
1755
|
+
{ value: "differential-sibling", label: "Differential sibling" },
|
|
1756
|
+
{ value: "complication-of", label: "Complication of" }
|
|
1757
|
+
];
|
|
1758
|
+
var SEVERITIES = ["mild", "moderate", "severe"];
|
|
1759
|
+
var CONFIDENCES = ["low", "medium", "high"];
|
|
1760
|
+
function normalizeConditionCodingSystem(codetype) {
|
|
1761
|
+
const ct = codetype.toUpperCase().replace(/[^A-Z0-9]/g, "");
|
|
1762
|
+
if (ct === "ICD10" || ct === "ICD10CM") return "ICD-10-CM";
|
|
1763
|
+
if (ct === "ICD11") return "ICD-11";
|
|
1764
|
+
if (ct === "SNOMED" || ct === "SNOMEDCT" || ct === "SNOMEDUS") {
|
|
1765
|
+
return "SNOMED";
|
|
1766
|
+
}
|
|
1767
|
+
return codetype;
|
|
1768
|
+
}
|
|
1769
|
+
function withSinglePrimary(coding) {
|
|
1770
|
+
if (coding.length === 0) return coding;
|
|
1771
|
+
const primaryIndex = coding.findIndex((entry) => entry.primary);
|
|
1772
|
+
const selectedIndex = primaryIndex >= 0 ? primaryIndex : 0;
|
|
1773
|
+
return coding.map((entry, index) => ({
|
|
1774
|
+
...entry,
|
|
1775
|
+
primary: index === selectedIndex
|
|
1776
|
+
}));
|
|
1777
|
+
}
|
|
1778
|
+
function contextConditionCodeSearch(ctx) {
|
|
1779
|
+
const ContextConditionCodeSearch = ({
|
|
1780
|
+
placeholder,
|
|
1781
|
+
onPick,
|
|
1782
|
+
onFreeText
|
|
1783
|
+
}) => {
|
|
1784
|
+
const Lookup = ctx.component;
|
|
1785
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1786
|
+
Lookup,
|
|
1787
|
+
{
|
|
1788
|
+
indexUrl: ctx.indexUrl,
|
|
1789
|
+
locale: ctx.locale,
|
|
1790
|
+
domains: ["condition"],
|
|
1791
|
+
preferCodetypes: ["ICD10"],
|
|
1792
|
+
bare: true,
|
|
1793
|
+
clearOnSelect: false,
|
|
1794
|
+
placeholder,
|
|
1795
|
+
onSelect: (result) => onPick({
|
|
1796
|
+
fullid: result.fullid,
|
|
1797
|
+
label: result.label,
|
|
1798
|
+
codetype: result.codetype,
|
|
1799
|
+
fullcode: result.fullcode
|
|
1800
|
+
}),
|
|
1801
|
+
onFreeText
|
|
1802
|
+
}
|
|
1803
|
+
);
|
|
1804
|
+
};
|
|
1805
|
+
return ContextConditionCodeSearch;
|
|
1806
|
+
}
|
|
1807
|
+
function FieldFlag({
|
|
1808
|
+
label,
|
|
1809
|
+
value,
|
|
1810
|
+
onChange,
|
|
1811
|
+
hasValue
|
|
1812
|
+
}) {
|
|
1813
|
+
const m = chunkFSLI5IKP_cjs.useMessages();
|
|
1814
|
+
const unknown = value?.known === false;
|
|
1815
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1816
|
+
"span",
|
|
1817
|
+
{
|
|
1818
|
+
role: "group",
|
|
1819
|
+
"aria-label": m("Certainty for {label}", { label }),
|
|
1820
|
+
className: "flex items-center gap-1",
|
|
1821
|
+
children: [
|
|
1822
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1823
|
+
"button",
|
|
1824
|
+
{
|
|
1825
|
+
type: "button",
|
|
1826
|
+
"aria-pressed": unknown,
|
|
1827
|
+
onClick: () => onChange(
|
|
1828
|
+
unknown ? void 0 : { known: false, reason: "asked-unknown" }
|
|
1829
|
+
),
|
|
1830
|
+
className: chunkS5RVSXDV_cjs.cn(
|
|
1831
|
+
"rounded-full border px-2 py-0.5 text-[11px] font-medium transition-colors",
|
|
1832
|
+
unknown ? "border-warning/50 bg-warning/10 text-warning-800 dark:text-warning-200" : "border-border text-muted-foreground hover:text-foreground"
|
|
1833
|
+
),
|
|
1834
|
+
children: m("Unknown")
|
|
1835
|
+
}
|
|
1836
|
+
),
|
|
1837
|
+
hasValue && !unknown && CONFIDENCES.map((c) => {
|
|
1838
|
+
const active = value?.known !== false && value?.confidence === c;
|
|
1839
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1840
|
+
"button",
|
|
1841
|
+
{
|
|
1842
|
+
type: "button",
|
|
1843
|
+
"aria-pressed": active,
|
|
1844
|
+
"aria-label": m("{label} confidence {confidence}", {
|
|
1845
|
+
label,
|
|
1846
|
+
confidence: m(c)
|
|
1847
|
+
}),
|
|
1848
|
+
onClick: () => onChange(active ? void 0 : { known: true, confidence: c }),
|
|
1849
|
+
className: chunkS5RVSXDV_cjs.cn(
|
|
1850
|
+
"rounded-full border px-1.5 py-0.5 text-[11px] transition-colors",
|
|
1851
|
+
active ? "border-primary-400 bg-primary-100 text-primary-900 dark:border-primary-600 dark:bg-primary-950 dark:text-primary-200" : "border-border text-muted-foreground hover:text-foreground"
|
|
1852
|
+
),
|
|
1853
|
+
children: m(c)
|
|
1854
|
+
},
|
|
1855
|
+
c
|
|
1856
|
+
);
|
|
1857
|
+
})
|
|
1858
|
+
]
|
|
1859
|
+
}
|
|
1860
|
+
);
|
|
1861
|
+
}
|
|
1862
|
+
function ObservationHistory({ concern }) {
|
|
1863
|
+
const m = chunkFSLI5IKP_cjs.useMessages();
|
|
1864
|
+
const observations = concern?.observations;
|
|
1865
|
+
if (!observations?.length) return null;
|
|
1866
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("section", { "aria-label": m("Past observations"), className: "space-y-1", children: [
|
|
1867
|
+
/* @__PURE__ */ jsxRuntime.jsx("h4", { className: "text-muted-foreground text-xs font-semibold tracking-wide uppercase", children: m("Observations") }),
|
|
1868
|
+
/* @__PURE__ */ jsxRuntime.jsx("ol", { className: "border-border max-h-40 space-y-1.5 overflow-y-auto rounded-md border p-2", children: [...observations].reverse().map((o) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "flex flex-wrap gap-x-2 text-sm", children: [
|
|
1869
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-xs tabular-nums", children: o.date }),
|
|
1870
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground flex-1", children: o.text }),
|
|
1871
|
+
o.author && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground text-xs", children: [
|
|
1872
|
+
"\u2014 ",
|
|
1873
|
+
o.author
|
|
1874
|
+
] })
|
|
1875
|
+
] }, o.id)) })
|
|
1876
|
+
] });
|
|
1877
|
+
}
|
|
1878
|
+
function ConditionEditor({
|
|
1879
|
+
mode,
|
|
1880
|
+
open,
|
|
1881
|
+
onOpenChange,
|
|
1882
|
+
concern,
|
|
1883
|
+
relatableConcerns = [],
|
|
1884
|
+
onSave,
|
|
1885
|
+
onRelate,
|
|
1886
|
+
onAddObservation,
|
|
1887
|
+
renderCodeSearch,
|
|
1888
|
+
className,
|
|
1889
|
+
"data-testid": dataTestId
|
|
1890
|
+
}) {
|
|
1891
|
+
const m = chunkFSLI5IKP_cjs.useMessages();
|
|
1892
|
+
const prior = concern ? chunk4NB4WOGU_cjs.currentAssertion(concern) : void 0;
|
|
1893
|
+
const ambientCodeLookup = useCodeLookupConfig();
|
|
1894
|
+
const effectiveRenderCodeSearch = renderCodeSearch === false ? void 0 : renderCodeSearch ?? (ambientCodeLookup ? contextConditionCodeSearch(ambientCodeLookup) : void 0);
|
|
1895
|
+
const [text, setText] = React4__namespace.useState("");
|
|
1896
|
+
const [coding, setCoding] = React4__namespace.useState([]);
|
|
1897
|
+
const [verification, setVerification] = React4__namespace.useState("confirmed");
|
|
1898
|
+
const [severity, setSeverity] = React4__namespace.useState();
|
|
1899
|
+
const [onsetDate, setOnsetDate] = React4__namespace.useState("");
|
|
1900
|
+
const [onsetFuzzy, setOnsetFuzzy] = React4__namespace.useState("");
|
|
1901
|
+
const [note, setNote] = React4__namespace.useState("");
|
|
1902
|
+
const [progression, setProgression] = React4__namespace.useState(false);
|
|
1903
|
+
const [fields, setFields] = React4__namespace.useState({});
|
|
1904
|
+
const [relType, setRelType] = React4__namespace.useState("caused-by");
|
|
1905
|
+
const [relTarget, setRelTarget] = React4__namespace.useState("");
|
|
1906
|
+
const [observation, setObservation] = React4__namespace.useState("");
|
|
1907
|
+
React4__namespace.useEffect(() => {
|
|
1908
|
+
if (!open) return;
|
|
1909
|
+
setText(prior?.text ?? "");
|
|
1910
|
+
setCoding(withSinglePrimary(prior?.coding ?? []));
|
|
1911
|
+
setVerification(
|
|
1912
|
+
mode === "add" ? "unconfirmed" : prior?.verificationStatus ?? "confirmed"
|
|
1913
|
+
);
|
|
1914
|
+
setSeverity(prior?.severity);
|
|
1915
|
+
const priorOnsetDate = prior?.onset?.date;
|
|
1916
|
+
setOnsetDate(priorOnsetDate ? chunkCW75IKA6_cjs.dateToDisplayFormat(priorOnsetDate) : "");
|
|
1917
|
+
setOnsetFuzzy(priorOnsetDate ? "" : prior?.onset?.fuzzy ?? "");
|
|
1918
|
+
setNote("");
|
|
1919
|
+
setProgression(false);
|
|
1920
|
+
setFields(prior?.uncertainty?.fields ?? {});
|
|
1921
|
+
setRelType("caused-by");
|
|
1922
|
+
setRelTarget("");
|
|
1923
|
+
setObservation("");
|
|
1924
|
+
}, [open, mode, prior]);
|
|
1925
|
+
const setField = (field) => (f) => setFields((prev) => {
|
|
1926
|
+
const next = { ...prev };
|
|
1927
|
+
if (f) next[field] = f;
|
|
1928
|
+
else delete next[field];
|
|
1929
|
+
return next;
|
|
1930
|
+
});
|
|
1931
|
+
const updateCoding = (i, patch) => setCoding((prev) => prev.map((c, j) => j === i ? { ...c, ...patch } : c));
|
|
1932
|
+
const codingUnknown = fields.coding?.known === false;
|
|
1933
|
+
const hasInvalidOnsetDate = fields.onset?.known !== false && Boolean(onsetDate) && !chunkCW75IKA6_cjs.isValidDate(onsetDate);
|
|
1934
|
+
const handleCodePick = (pick) => {
|
|
1935
|
+
const system = normalizeConditionCodingSystem(pick.codetype);
|
|
1936
|
+
setCoding(
|
|
1937
|
+
(prev) => prev.some((c) => c.system === system && c.code === pick.fullcode) ? prev : withSinglePrimary([
|
|
1938
|
+
...prev,
|
|
1939
|
+
{ system, code: pick.fullcode, display: pick.label }
|
|
1940
|
+
])
|
|
1941
|
+
);
|
|
1942
|
+
setText((prev) => prev || pick.label);
|
|
1943
|
+
setFields((prev) => {
|
|
1944
|
+
if (prev.coding?.known !== false) return prev;
|
|
1945
|
+
const next = { ...prev };
|
|
1946
|
+
delete next.coding;
|
|
1947
|
+
return next;
|
|
1948
|
+
});
|
|
1949
|
+
};
|
|
1950
|
+
const handleSave = () => {
|
|
1951
|
+
if (mode === "relate") {
|
|
1952
|
+
if (!relTarget) return;
|
|
1953
|
+
onRelate?.({ type: relType, concernId: relTarget });
|
|
1954
|
+
onOpenChange(false);
|
|
1955
|
+
return;
|
|
1956
|
+
}
|
|
1957
|
+
if (mode === "observe") {
|
|
1958
|
+
if (!observation.trim()) return;
|
|
1959
|
+
onAddObservation?.(observation.trim());
|
|
1960
|
+
onOpenChange(false);
|
|
1961
|
+
return;
|
|
1962
|
+
}
|
|
1963
|
+
if (!text.trim() || hasInvalidOnsetDate) return;
|
|
1964
|
+
if (observation.trim()) onAddObservation?.(observation.trim());
|
|
1965
|
+
const uncertainty = Object.keys(fields).length > 0 ? { fields } : void 0;
|
|
1966
|
+
onSave?.({
|
|
1967
|
+
text: text.trim(),
|
|
1968
|
+
// write the trimmed values back — whitespace in codes breaks equality
|
|
1969
|
+
// checks downstream. A field marked explicitly unknown must not carry a
|
|
1970
|
+
// value (e.g. one seeded from the prior assertion): value + "unknown"
|
|
1971
|
+
// would be contradictory, so unknown wins and the value is dropped.
|
|
1972
|
+
coding: fields.coding?.known === false ? [] : withSinglePrimary(
|
|
1973
|
+
coding.filter((c) => c.code.trim()).map((c) => ({
|
|
1974
|
+
...c,
|
|
1975
|
+
code: c.code.trim(),
|
|
1976
|
+
display: c.display?.trim() || void 0,
|
|
1977
|
+
mappedFrom: c.mappedFrom?.trim() || void 0
|
|
1978
|
+
}))
|
|
1979
|
+
),
|
|
1980
|
+
verificationStatus: verification,
|
|
1981
|
+
changeType: mode === "refine" ? progression ? "progression" : "refinement" : MODE_META[mode].changeType,
|
|
1982
|
+
supersedes: prior?.id,
|
|
1983
|
+
severity: fields.severity?.known === false ? void 0 : severity,
|
|
1984
|
+
onset: fields.onset?.known === false ? void 0 : onsetDate || onsetFuzzy ? {
|
|
1985
|
+
date: onsetDate ? chunkCW75IKA6_cjs.displayFormatToDateString(onsetDate) : void 0,
|
|
1986
|
+
fuzzy: onsetFuzzy || void 0
|
|
1987
|
+
} : void 0,
|
|
1988
|
+
uncertainty,
|
|
1989
|
+
note: note.trim() || void 0
|
|
1990
|
+
});
|
|
1991
|
+
onOpenChange(false);
|
|
1992
|
+
};
|
|
1993
|
+
const saveDisabled = mode === "relate" ? !relTarget : mode === "observe" ? !observation.trim() : !text.trim() || hasInvalidOnsetDate;
|
|
1994
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1995
|
+
chunkLC3JL2HB_cjs.Modal,
|
|
1996
|
+
{
|
|
1997
|
+
open,
|
|
1998
|
+
onOpenChange,
|
|
1999
|
+
size: "2xl",
|
|
2000
|
+
className,
|
|
2001
|
+
children: [
|
|
2002
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkLC3JL2HB_cjs.ModalHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(chunkLC3JL2HB_cjs.ModalTitle, { children: [
|
|
2003
|
+
m(MODE_META[mode].title),
|
|
2004
|
+
prior ? ` \u2014 ${prior.text}` : ""
|
|
2005
|
+
] }) }),
|
|
2006
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkLC3JL2HB_cjs.ModalBody, { "data-testid": dataTestId, className: "space-y-5", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-5", children: [
|
|
2007
|
+
mode === "revise" && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2008
|
+
"div",
|
|
2009
|
+
{
|
|
2010
|
+
role: "alert",
|
|
2011
|
+
className: "border-warning/30 bg-warning/10 text-warning-800 dark:text-warning-200 flex items-start gap-2 rounded-md border px-3 py-2 text-sm",
|
|
2012
|
+
children: [
|
|
2013
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkL7L5S2HO_cjs.AlertTriangle, { size: 16 }),
|
|
2014
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: m(
|
|
2015
|
+
"Revising marks the prior assertion refuted (it was never true) \u2014 history is preserved on the timeline. Use Refine instead if the prior was correct but less specific."
|
|
2016
|
+
) })
|
|
2017
|
+
]
|
|
2018
|
+
}
|
|
2019
|
+
),
|
|
2020
|
+
mode === "relate" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2021
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2022
|
+
chunkUPWIJC6I_cjs.Select,
|
|
2023
|
+
{
|
|
2024
|
+
label: m("Relationship"),
|
|
2025
|
+
options: RELATIONSHIP_OPTIONS.map((option) => ({
|
|
2026
|
+
...option,
|
|
2027
|
+
label: m(option.label)
|
|
2028
|
+
})),
|
|
2029
|
+
value: relType,
|
|
2030
|
+
onValueChange: (v) => setRelType(v)
|
|
2031
|
+
}
|
|
2032
|
+
),
|
|
2033
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2034
|
+
chunkUPWIJC6I_cjs.Select,
|
|
2035
|
+
{
|
|
2036
|
+
label: m("Related problem"),
|
|
2037
|
+
placeholder: m("Select a problem\u2026"),
|
|
2038
|
+
options: relatableConcerns.filter((c) => c.concernId !== concern?.concernId).map((c) => ({
|
|
2039
|
+
value: c.concernId,
|
|
2040
|
+
label: chunk4NB4WOGU_cjs.currentAssertion(c)?.text ?? c.concernId
|
|
2041
|
+
})),
|
|
2042
|
+
value: relTarget,
|
|
2043
|
+
onValueChange: setRelTarget
|
|
2044
|
+
}
|
|
2045
|
+
)
|
|
2046
|
+
] }) : mode === "observe" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2047
|
+
/* @__PURE__ */ jsxRuntime.jsx(ObservationHistory, { concern }),
|
|
2048
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2049
|
+
chunkXQHDQ64G_cjs.Textarea,
|
|
2050
|
+
{
|
|
2051
|
+
label: m("New observation"),
|
|
2052
|
+
value: observation,
|
|
2053
|
+
onChange: (e) => setObservation(e.target.value),
|
|
2054
|
+
placeholder: m(
|
|
2055
|
+
"e.g. BP improving on current regimen; patient reports better sleep"
|
|
2056
|
+
),
|
|
2057
|
+
rows: 3,
|
|
2058
|
+
autoFocus: true
|
|
2059
|
+
}
|
|
2060
|
+
)
|
|
2061
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2062
|
+
(mode === "refine" || mode === "revise") && /* @__PURE__ */ jsxRuntime.jsx(ObservationHistory, { concern }),
|
|
2063
|
+
mode === "add" && effectiveRenderCodeSearch && !text.trim() ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
2064
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-foreground block text-sm font-medium", children: [
|
|
2065
|
+
m("Problem name"),
|
|
2066
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-destructive ms-1", "aria-hidden": "true", children: "*" })
|
|
2067
|
+
] }),
|
|
2068
|
+
effectiveRenderCodeSearch({
|
|
2069
|
+
placeholder: m(
|
|
2070
|
+
"Search conditions \u2014 or type a name and press Enter\u2026"
|
|
2071
|
+
),
|
|
2072
|
+
onPick: handleCodePick,
|
|
2073
|
+
onFreeText: (t) => setText(t.trim())
|
|
2074
|
+
}),
|
|
2075
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-xs", children: m(
|
|
2076
|
+
"Picking a code fills the name and coding together; free text is fine \u2014 codes can be added any time."
|
|
2077
|
+
) })
|
|
2078
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2079
|
+
chunkZ5S5JEJD_cjs.Input,
|
|
2080
|
+
{
|
|
2081
|
+
label: m("Problem name"),
|
|
2082
|
+
required: true,
|
|
2083
|
+
value: text,
|
|
2084
|
+
onChange: (e) => setText(e.target.value),
|
|
2085
|
+
placeholder: m(
|
|
2086
|
+
"e.g. Type 1 diabetes mellitus with neuropathy"
|
|
2087
|
+
)
|
|
2088
|
+
}
|
|
2089
|
+
),
|
|
2090
|
+
mode === "refine" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2091
|
+
chunk7AECNMYV_cjs.Checkbox,
|
|
2092
|
+
{
|
|
2093
|
+
size: "sm",
|
|
2094
|
+
checked: progression,
|
|
2095
|
+
onChange: (e) => setProgression(e.target.checked),
|
|
2096
|
+
label: m(
|
|
2097
|
+
"Disease progressed (e.g. new complication) rather than a more specific diagnosis"
|
|
2098
|
+
)
|
|
2099
|
+
}
|
|
2100
|
+
),
|
|
2101
|
+
/* @__PURE__ */ jsxRuntime.jsxs("fieldset", { className: "space-y-3", children: [
|
|
2102
|
+
/* @__PURE__ */ jsxRuntime.jsx("legend", { className: "sr-only", children: m("Coding") }),
|
|
2103
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [
|
|
2104
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex flex-wrap items-center gap-2 text-sm font-medium", children: [
|
|
2105
|
+
m("Coding"),
|
|
2106
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2107
|
+
FieldFlag,
|
|
2108
|
+
{
|
|
2109
|
+
label: m("Coding"),
|
|
2110
|
+
value: fields.coding,
|
|
2111
|
+
onChange: setField("coding"),
|
|
2112
|
+
hasValue: coding.length > 0
|
|
2113
|
+
}
|
|
2114
|
+
)
|
|
2115
|
+
] }),
|
|
2116
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2117
|
+
chunkANMX7YDL_cjs.Button,
|
|
2118
|
+
{
|
|
2119
|
+
variant: "ghost",
|
|
2120
|
+
size: "sm",
|
|
2121
|
+
disabled: codingUnknown,
|
|
2122
|
+
onClick: () => setCoding((prev) => [
|
|
2123
|
+
...prev,
|
|
2124
|
+
{
|
|
2125
|
+
system: "SNOMED",
|
|
2126
|
+
code: "",
|
|
2127
|
+
primary: prev.length === 0
|
|
2128
|
+
}
|
|
2129
|
+
]),
|
|
2130
|
+
leftIcon: /* @__PURE__ */ jsxRuntime.jsx(chunkL7L5S2HO_cjs.Plus, { size: 12 }),
|
|
2131
|
+
className: "h-8 shrink-0 text-xs",
|
|
2132
|
+
children: m("Add code")
|
|
2133
|
+
}
|
|
2134
|
+
)
|
|
2135
|
+
] }),
|
|
2136
|
+
effectiveRenderCodeSearch && !(mode === "add" && !text.trim()) && /* @__PURE__ */ jsxRuntime.jsx("div", { children: effectiveRenderCodeSearch({
|
|
2137
|
+
placeholder: m("Search codes \u2014 ICD-10-CM / SNOMED\u2026"),
|
|
2138
|
+
onPick: handleCodePick,
|
|
2139
|
+
onFreeText: (t) => setText((prev) => prev || t)
|
|
2140
|
+
}) }),
|
|
2141
|
+
coding.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-xs", children: m(
|
|
2142
|
+
"Optional \u2014 a name-only problem is valid. Codes can be added any time."
|
|
2143
|
+
) }),
|
|
2144
|
+
coding.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2145
|
+
"div",
|
|
2146
|
+
{
|
|
2147
|
+
"aria-hidden": "true",
|
|
2148
|
+
"data-slot": "condition-coding-header",
|
|
2149
|
+
className: "text-muted-foreground hidden grid-cols-[minmax(8rem,1.1fr)_minmax(7rem,0.9fr)_minmax(10rem,1.5fr)_5.5rem_2.5rem] items-center gap-2 px-1 text-xs font-medium sm:!grid",
|
|
2150
|
+
children: [
|
|
2151
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: m("System") }),
|
|
2152
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: m("Code") }),
|
|
2153
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: m("Display") }),
|
|
2154
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-center", children: m("Primary code") }),
|
|
2155
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: m("Actions") })
|
|
2156
|
+
]
|
|
2157
|
+
}
|
|
2158
|
+
),
|
|
2159
|
+
coding.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2160
|
+
chunkG7EQ3JPX_cjs.RadioGroup,
|
|
2161
|
+
{
|
|
2162
|
+
name: "primary-coding",
|
|
2163
|
+
label: m("Primary display code"),
|
|
2164
|
+
value: String(
|
|
2165
|
+
Math.max(
|
|
2166
|
+
0,
|
|
2167
|
+
coding.findIndex((entry) => entry.primary)
|
|
2168
|
+
)
|
|
2169
|
+
),
|
|
2170
|
+
onValueChange: (value) => {
|
|
2171
|
+
const selectedIndex = Number(value);
|
|
2172
|
+
setCoding(
|
|
2173
|
+
(prev) => prev.map((entry, index) => ({
|
|
2174
|
+
...entry,
|
|
2175
|
+
primary: index === selectedIndex
|
|
2176
|
+
}))
|
|
2177
|
+
);
|
|
2178
|
+
},
|
|
2179
|
+
size: "sm",
|
|
2180
|
+
className: "gap-2 [&_[data-slot=radio-group-items]]:gap-2 sm:[&_[data-slot=radio-group-legend]]:sr-only",
|
|
2181
|
+
children: coding.map((c, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2182
|
+
"div",
|
|
2183
|
+
{
|
|
2184
|
+
"data-slot": "condition-coding-row",
|
|
2185
|
+
className: "border-border/70 grid grid-cols-1 gap-2 rounded-md border p-2 sm:grid-cols-[minmax(8rem,1.1fr)_minmax(7rem,0.9fr)_minmax(10rem,1.5fr)_5.5rem_2.5rem] sm:items-center sm:border-0 sm:p-0",
|
|
2186
|
+
children: [
|
|
2187
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
2188
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-xs sm:hidden", children: m("System") }),
|
|
2189
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2190
|
+
chunkUPWIJC6I_cjs.Select,
|
|
2191
|
+
{
|
|
2192
|
+
"aria-label": m("Coding system {index}", {
|
|
2193
|
+
index: i + 1
|
|
2194
|
+
}),
|
|
2195
|
+
options: CODING_SYSTEMS.map((s) => ({
|
|
2196
|
+
value: s,
|
|
2197
|
+
label: s
|
|
2198
|
+
})),
|
|
2199
|
+
value: c.system,
|
|
2200
|
+
onValueChange: (v) => updateCoding(i, { system: v }),
|
|
2201
|
+
disabled: codingUnknown
|
|
2202
|
+
}
|
|
2203
|
+
)
|
|
2204
|
+
] }),
|
|
2205
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
2206
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-xs sm:hidden", children: m("Code") }),
|
|
2207
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2208
|
+
chunkZ5S5JEJD_cjs.Input,
|
|
2209
|
+
{
|
|
2210
|
+
"aria-label": m("Code {index}", { index: i + 1 }),
|
|
2211
|
+
value: c.code,
|
|
2212
|
+
onChange: (e) => updateCoding(i, { code: e.target.value }),
|
|
2213
|
+
placeholder: m("Code"),
|
|
2214
|
+
disabled: codingUnknown,
|
|
2215
|
+
className: "font-mono"
|
|
2216
|
+
}
|
|
2217
|
+
)
|
|
2218
|
+
] }),
|
|
2219
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
2220
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-xs sm:hidden", children: m("Display") }),
|
|
2221
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2222
|
+
chunkZ5S5JEJD_cjs.Input,
|
|
2223
|
+
{
|
|
2224
|
+
"aria-label": m("Display {index}", { index: i + 1 }),
|
|
2225
|
+
value: c.display ?? "",
|
|
2226
|
+
onChange: (e) => updateCoding(i, { display: e.target.value }),
|
|
2227
|
+
placeholder: m("Display"),
|
|
2228
|
+
disabled: codingUnknown
|
|
2229
|
+
}
|
|
2230
|
+
)
|
|
2231
|
+
] }),
|
|
2232
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-h-10 items-center gap-1.5 text-xs sm:justify-center", children: [
|
|
2233
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2234
|
+
chunkG7EQ3JPX_cjs.Radio,
|
|
2235
|
+
{
|
|
2236
|
+
value: String(i),
|
|
2237
|
+
"aria-label": m("Primary code: {system} {code}", {
|
|
2238
|
+
system: c.system,
|
|
2239
|
+
code: c.code || m("row {index}", { index: i + 1 })
|
|
2240
|
+
}),
|
|
2241
|
+
disabled: codingUnknown
|
|
2242
|
+
}
|
|
2243
|
+
),
|
|
2244
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sm:sr-only", children: m("Primary code") })
|
|
2245
|
+
] }),
|
|
2246
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2247
|
+
chunkANMX7YDL_cjs.Button,
|
|
2248
|
+
{
|
|
2249
|
+
variant: "ghost",
|
|
2250
|
+
size: "icon",
|
|
2251
|
+
"aria-label": m("Remove code {index}", {
|
|
2252
|
+
index: i + 1
|
|
2253
|
+
}),
|
|
2254
|
+
disabled: codingUnknown,
|
|
2255
|
+
onClick: () => setCoding(
|
|
2256
|
+
(prev) => withSinglePrimary(
|
|
2257
|
+
prev.filter((_, index) => index !== i)
|
|
2258
|
+
)
|
|
2259
|
+
),
|
|
2260
|
+
className: "h-10 w-10 justify-self-start sm:justify-self-center",
|
|
2261
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(chunkL7L5S2HO_cjs.Trash2, { size: 14 })
|
|
2262
|
+
}
|
|
2263
|
+
)
|
|
2264
|
+
]
|
|
2265
|
+
},
|
|
2266
|
+
i
|
|
2267
|
+
))
|
|
2268
|
+
}
|
|
2269
|
+
)
|
|
2270
|
+
] }),
|
|
2271
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2272
|
+
chunkUPWIJC6I_cjs.Select,
|
|
2273
|
+
{
|
|
2274
|
+
label: m("Verification status"),
|
|
2275
|
+
options: VERIFICATION_OPTIONS.map((option) => ({
|
|
2276
|
+
...option,
|
|
2277
|
+
label: m(option.label)
|
|
2278
|
+
})),
|
|
2279
|
+
value: verification,
|
|
2280
|
+
onValueChange: (v) => setVerification(v)
|
|
2281
|
+
}
|
|
2282
|
+
),
|
|
2283
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-end gap-x-4 gap-y-2", children: [
|
|
2284
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
2285
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "block text-sm font-medium", children: m("Severity") }),
|
|
2286
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2287
|
+
"div",
|
|
2288
|
+
{
|
|
2289
|
+
role: "group",
|
|
2290
|
+
"aria-label": m("Severity"),
|
|
2291
|
+
className: "border-border inline-flex items-center overflow-hidden rounded-md border",
|
|
2292
|
+
children: SEVERITIES.map((s) => {
|
|
2293
|
+
const active = severity === s;
|
|
2294
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2295
|
+
"button",
|
|
2296
|
+
{
|
|
2297
|
+
type: "button",
|
|
2298
|
+
"aria-pressed": active,
|
|
2299
|
+
disabled: fields.severity?.known === false,
|
|
2300
|
+
onClick: () => setSeverity(active ? void 0 : s),
|
|
2301
|
+
className: chunkS5RVSXDV_cjs.cn(
|
|
2302
|
+
"border-border border-s px-2.5 py-1 text-xs font-medium capitalize transition-colors first:border-s-0",
|
|
2303
|
+
"disabled:opacity-40",
|
|
2304
|
+
active ? "bg-primary-600 text-white" : "bg-background text-muted-foreground hover:text-foreground"
|
|
2305
|
+
),
|
|
2306
|
+
children: m(s)
|
|
2307
|
+
},
|
|
2308
|
+
s
|
|
2309
|
+
);
|
|
2310
|
+
})
|
|
2311
|
+
}
|
|
2312
|
+
)
|
|
2313
|
+
] }),
|
|
2314
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
2315
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "block text-sm font-medium", children: m("Certainty") }),
|
|
2316
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2317
|
+
FieldFlag,
|
|
2318
|
+
{
|
|
2319
|
+
label: m("Severity"),
|
|
2320
|
+
value: fields.severity,
|
|
2321
|
+
onChange: setField("severity"),
|
|
2322
|
+
hasValue: Boolean(severity)
|
|
2323
|
+
}
|
|
2324
|
+
)
|
|
2325
|
+
] })
|
|
2326
|
+
] }),
|
|
2327
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
2328
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2 text-sm font-medium", children: [
|
|
2329
|
+
m("Onset"),
|
|
2330
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2331
|
+
FieldFlag,
|
|
2332
|
+
{
|
|
2333
|
+
label: m("Onset"),
|
|
2334
|
+
value: fields.onset,
|
|
2335
|
+
onChange: setField("onset"),
|
|
2336
|
+
hasValue: Boolean(onsetDate || onsetFuzzy)
|
|
2337
|
+
}
|
|
2338
|
+
)
|
|
2339
|
+
] }),
|
|
2340
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 items-end gap-2 sm:grid-cols-[minmax(10rem,0.8fr)_auto_minmax(14rem,1.2fr)]", children: [
|
|
2341
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2342
|
+
chunkPHUTJKHL_cjs.DateInput,
|
|
2343
|
+
{
|
|
2344
|
+
"aria-label": m("Onset date (exact)"),
|
|
2345
|
+
value: onsetDate,
|
|
2346
|
+
onChange: (value) => {
|
|
2347
|
+
setOnsetDate(value);
|
|
2348
|
+
if (value) setOnsetFuzzy("");
|
|
2349
|
+
},
|
|
2350
|
+
disabled: fields.onset?.known === false,
|
|
2351
|
+
validateOnBlur: true,
|
|
2352
|
+
error: hasInvalidOnsetDate ? m("Please enter a valid date (MM/DD/YYYY)") : void 0,
|
|
2353
|
+
width: "full"
|
|
2354
|
+
}
|
|
2355
|
+
),
|
|
2356
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground pb-3 text-center text-xs", children: m("or") }),
|
|
2357
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2358
|
+
chunkZ5S5JEJD_cjs.Input,
|
|
2359
|
+
{
|
|
2360
|
+
"aria-label": m("Onset (fuzzy)"),
|
|
2361
|
+
value: onsetFuzzy,
|
|
2362
|
+
onChange: (e) => {
|
|
2363
|
+
setOnsetFuzzy(e.target.value);
|
|
2364
|
+
if (e.target.value) setOnsetDate("");
|
|
2365
|
+
},
|
|
2366
|
+
disabled: fields.onset?.known === false,
|
|
2367
|
+
placeholder: m(
|
|
2368
|
+
'Fuzzy \u2014 "since her twenties", "~3 months ago"'
|
|
2369
|
+
)
|
|
2370
|
+
}
|
|
2371
|
+
)
|
|
2372
|
+
] })
|
|
2373
|
+
] }),
|
|
2374
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2375
|
+
chunkXQHDQ64G_cjs.Textarea,
|
|
2376
|
+
{
|
|
2377
|
+
label: m("Note"),
|
|
2378
|
+
value: note,
|
|
2379
|
+
onChange: (e) => setNote(e.target.value),
|
|
2380
|
+
placeholder: m(
|
|
2381
|
+
"e.g. patient thinks it started after the fall, not sure"
|
|
2382
|
+
),
|
|
2383
|
+
rows: 2
|
|
2384
|
+
}
|
|
2385
|
+
),
|
|
2386
|
+
Object.keys(fields).length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-muted-foreground flex items-center gap-1.5 text-xs", children: [
|
|
2387
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkL7L5S2HO_cjs.HelpCircle, { size: 12 }),
|
|
2388
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
2389
|
+
m("Uncertainty recorded:"),
|
|
2390
|
+
" ",
|
|
2391
|
+
Object.entries(fields).map(
|
|
2392
|
+
([k, f]) => f?.known === false ? m("{field} unknown", { field: m(k) }) : m("{confidence} confidence in {field}", {
|
|
2393
|
+
confidence: m(f?.confidence ?? "unspecified"),
|
|
2394
|
+
field: m(k)
|
|
2395
|
+
})
|
|
2396
|
+
).join(", ")
|
|
2397
|
+
] })
|
|
2398
|
+
] })
|
|
2399
|
+
] })
|
|
2400
|
+
] }) }),
|
|
2401
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkLC3JL2HB_cjs.ModalFooter, { children: [
|
|
2402
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkANMX7YDL_cjs.Button, { variant: "secondary", onClick: () => onOpenChange(false), children: m("Cancel") }),
|
|
2403
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkANMX7YDL_cjs.Button, { onClick: handleSave, disabled: saveDisabled, children: m(
|
|
2404
|
+
mode === "relate" ? "Relate" : mode === "observe" ? "Add observation" : "Save"
|
|
2405
|
+
) }),
|
|
2406
|
+
mode !== "relate" && mode !== "observe" && !text.trim() && /* @__PURE__ */ jsxRuntime.jsx(chunk7E46YDOT_cjs.Badge, { variant: "outline", size: "sm", className: "text-muted-foreground", children: m("name required") })
|
|
2407
|
+
] })
|
|
2408
|
+
]
|
|
2409
|
+
}
|
|
2410
|
+
);
|
|
2411
|
+
}
|
|
2412
|
+
ConditionEditor.displayName = "ConditionEditor";
|
|
2413
|
+
function getDefaultPresets(labels = {}) {
|
|
2414
|
+
const {
|
|
2415
|
+
today = "Today",
|
|
2416
|
+
thisWeek = "This Week",
|
|
2417
|
+
thisMonth = "This Month",
|
|
2418
|
+
lastMonth = "Last Month",
|
|
2419
|
+
last24Hours = "Last 24 Hours",
|
|
2420
|
+
last7Days = "Last 7 Days",
|
|
2421
|
+
last30Days = "Last 30 Days"
|
|
2422
|
+
} = labels;
|
|
2423
|
+
return [
|
|
2424
|
+
{ key: "today", label: today },
|
|
2425
|
+
{ key: "this-week", label: thisWeek },
|
|
2426
|
+
{ key: "this-month", label: thisMonth },
|
|
2427
|
+
{ key: "last-month", label: lastMonth },
|
|
2428
|
+
{ key: "last-24-hours", label: last24Hours },
|
|
2429
|
+
{ key: "last-7-days", label: last7Days },
|
|
2430
|
+
{ key: "last-30-days", label: last30Days }
|
|
2431
|
+
];
|
|
2432
|
+
}
|
|
2433
|
+
function getExtendedPresets(labels = {}) {
|
|
2434
|
+
const {
|
|
2435
|
+
today = "Today",
|
|
2436
|
+
yesterday = "Yesterday",
|
|
2437
|
+
thisWeek = "This Week",
|
|
2438
|
+
lastWeek = "Last Week",
|
|
2439
|
+
thisMonth = "This Month",
|
|
2440
|
+
lastMonth = "Last Month",
|
|
2441
|
+
thisQuarter = "This Quarter",
|
|
2442
|
+
lastQuarter = "Last Quarter",
|
|
2443
|
+
thisYear = "This Year",
|
|
2444
|
+
lastYear = "Last Year",
|
|
2445
|
+
last24Hours = "Last 24 Hours",
|
|
2446
|
+
last7Days = "Last 7 Days",
|
|
2447
|
+
last30Days = "Last 30 Days",
|
|
2448
|
+
last90Days = "Last 90 Days",
|
|
2449
|
+
last365Days = "Last 365 Days"
|
|
2450
|
+
} = labels;
|
|
2451
|
+
return [
|
|
2452
|
+
{ key: "today", label: today },
|
|
2453
|
+
{ key: "yesterday", label: yesterday },
|
|
2454
|
+
{ key: "last-24-hours", label: last24Hours },
|
|
2455
|
+
{ key: "this-week", label: thisWeek },
|
|
2456
|
+
{ key: "last-week", label: lastWeek },
|
|
2457
|
+
{ key: "last-7-days", label: last7Days },
|
|
2458
|
+
{ key: "this-month", label: thisMonth },
|
|
2459
|
+
{ key: "last-month", label: lastMonth },
|
|
2460
|
+
{ key: "last-30-days", label: last30Days },
|
|
2461
|
+
{ key: "this-quarter", label: thisQuarter },
|
|
2462
|
+
{ key: "last-quarter", label: lastQuarter },
|
|
2463
|
+
{ key: "last-90-days", label: last90Days },
|
|
2464
|
+
{ key: "this-year", label: thisYear },
|
|
2465
|
+
{ key: "last-year", label: lastYear },
|
|
2466
|
+
{ key: "last-365-days", label: last365Days }
|
|
2467
|
+
];
|
|
2468
|
+
}
|
|
2469
|
+
function endOfDay(d) {
|
|
2470
|
+
return new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23, 59, 59, 999);
|
|
2471
|
+
}
|
|
2472
|
+
function calculateDateRange(presetKey) {
|
|
2473
|
+
const now = /* @__PURE__ */ new Date();
|
|
2474
|
+
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
2475
|
+
switch (presetKey) {
|
|
2476
|
+
case "today":
|
|
2477
|
+
return { start: today, end: endOfDay(today) };
|
|
2478
|
+
case "yesterday": {
|
|
2479
|
+
const yesterday = new Date(today);
|
|
2480
|
+
yesterday.setDate(today.getDate() - 1);
|
|
2481
|
+
return { start: yesterday, end: endOfDay(yesterday) };
|
|
2482
|
+
}
|
|
2483
|
+
case "this-week": {
|
|
2484
|
+
const dayOfWeek = today.getDay();
|
|
2485
|
+
const sunday = new Date(today);
|
|
2486
|
+
sunday.setDate(today.getDate() - dayOfWeek);
|
|
2487
|
+
const saturday = new Date(sunday);
|
|
2488
|
+
saturday.setDate(sunday.getDate() + 6);
|
|
2489
|
+
return { start: sunday, end: endOfDay(saturday) };
|
|
2490
|
+
}
|
|
2491
|
+
case "last-week": {
|
|
2492
|
+
const dayOfWeek = today.getDay();
|
|
2493
|
+
const lastSunday = new Date(today);
|
|
2494
|
+
lastSunday.setDate(today.getDate() - dayOfWeek - 7);
|
|
2495
|
+
const lastSaturday = new Date(lastSunday);
|
|
2496
|
+
lastSaturday.setDate(lastSunday.getDate() + 6);
|
|
2497
|
+
return { start: lastSunday, end: endOfDay(lastSaturday) };
|
|
2498
|
+
}
|
|
2499
|
+
case "this-month": {
|
|
2500
|
+
const firstDay = new Date(now.getFullYear(), now.getMonth(), 1);
|
|
2501
|
+
const lastDay = new Date(now.getFullYear(), now.getMonth() + 1, 0);
|
|
2502
|
+
return { start: firstDay, end: endOfDay(lastDay) };
|
|
2503
|
+
}
|
|
2504
|
+
case "last-month": {
|
|
2505
|
+
const firstDay = new Date(now.getFullYear(), now.getMonth() - 1, 1);
|
|
2506
|
+
const lastDay = new Date(now.getFullYear(), now.getMonth(), 0);
|
|
2507
|
+
return { start: firstDay, end: endOfDay(lastDay) };
|
|
2508
|
+
}
|
|
2509
|
+
case "this-quarter": {
|
|
2510
|
+
const quarter = Math.floor(now.getMonth() / 3);
|
|
2511
|
+
const firstDay = new Date(now.getFullYear(), quarter * 3, 1);
|
|
2512
|
+
const lastDay = new Date(now.getFullYear(), quarter * 3 + 3, 0);
|
|
2513
|
+
return { start: firstDay, end: endOfDay(lastDay) };
|
|
2514
|
+
}
|
|
2515
|
+
case "last-quarter": {
|
|
2516
|
+
const quarter = Math.floor(now.getMonth() / 3);
|
|
2517
|
+
const firstDay = new Date(now.getFullYear(), (quarter - 1) * 3, 1);
|
|
2518
|
+
const lastDay = new Date(now.getFullYear(), quarter * 3, 0);
|
|
2519
|
+
return { start: firstDay, end: endOfDay(lastDay) };
|
|
2520
|
+
}
|
|
2521
|
+
case "this-year": {
|
|
2522
|
+
const firstDay = new Date(now.getFullYear(), 0, 1);
|
|
2523
|
+
const lastDay = new Date(now.getFullYear(), 11, 31);
|
|
2524
|
+
return { start: firstDay, end: endOfDay(lastDay) };
|
|
2525
|
+
}
|
|
2526
|
+
case "last-year": {
|
|
2527
|
+
const firstDay = new Date(now.getFullYear() - 1, 0, 1);
|
|
2528
|
+
const lastDay = new Date(now.getFullYear() - 1, 11, 31);
|
|
2529
|
+
return { start: firstDay, end: endOfDay(lastDay) };
|
|
2530
|
+
}
|
|
2531
|
+
case "last-24-hours":
|
|
2532
|
+
return {
|
|
2533
|
+
start: new Date(now.getTime() - 24 * 60 * 60 * 1e3),
|
|
2534
|
+
end: now
|
|
2535
|
+
};
|
|
2536
|
+
case "last-7-days":
|
|
2537
|
+
return {
|
|
2538
|
+
start: new Date(now.getTime() - 7 * 24 * 60 * 60 * 1e3),
|
|
2539
|
+
end: now
|
|
2540
|
+
};
|
|
2541
|
+
case "last-30-days":
|
|
2542
|
+
return {
|
|
2543
|
+
start: new Date(now.getTime() - 30 * 24 * 60 * 60 * 1e3),
|
|
2544
|
+
end: now
|
|
2545
|
+
};
|
|
2546
|
+
case "last-90-days":
|
|
2547
|
+
return {
|
|
2548
|
+
start: new Date(now.getTime() - 90 * 24 * 60 * 60 * 1e3),
|
|
2549
|
+
end: now
|
|
2550
|
+
};
|
|
2551
|
+
case "last-365-days":
|
|
2552
|
+
return {
|
|
2553
|
+
start: new Date(now.getTime() - 365 * 24 * 60 * 60 * 1e3),
|
|
2554
|
+
end: now
|
|
2555
|
+
};
|
|
2556
|
+
default:
|
|
2557
|
+
return { start: null, end: null };
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
function formatDateRange(range) {
|
|
2561
|
+
if (!range.start && !range.end) return "";
|
|
2562
|
+
const formatDate = (d) => {
|
|
2563
|
+
if (!d) return "";
|
|
2564
|
+
return d.toLocaleDateString("en-US", {
|
|
2565
|
+
month: "short",
|
|
2566
|
+
day: "numeric",
|
|
2567
|
+
year: "numeric"
|
|
2568
|
+
});
|
|
2569
|
+
};
|
|
2570
|
+
if (range.start && range.end) {
|
|
2571
|
+
return `${formatDate(range.start)} - ${formatDate(range.end)}`;
|
|
2572
|
+
}
|
|
2573
|
+
return formatDate(range.start || range.end);
|
|
2574
|
+
}
|
|
2575
|
+
function DateRangePicker({
|
|
2576
|
+
value,
|
|
2577
|
+
onChange,
|
|
2578
|
+
presets,
|
|
2579
|
+
activePreset,
|
|
2580
|
+
placeholder = "Pick a date range",
|
|
2581
|
+
className,
|
|
2582
|
+
align = "auto",
|
|
2583
|
+
showPresets = true,
|
|
2584
|
+
variant = "desktop",
|
|
2585
|
+
labels = {}
|
|
2586
|
+
}) {
|
|
2587
|
+
const finalPresets = presets || getDefaultPresets(labels);
|
|
2588
|
+
const [isCalendarOpen, setIsCalendarOpen] = React4__namespace.useState(false);
|
|
2589
|
+
const [leftMonth, setLeftMonth] = React4__namespace.useState(
|
|
2590
|
+
() => value?.start?.getMonth() ?? (/* @__PURE__ */ new Date()).getMonth()
|
|
2591
|
+
);
|
|
2592
|
+
const [leftYear, setLeftYear] = React4__namespace.useState(
|
|
2593
|
+
() => value?.start?.getFullYear() ?? (/* @__PURE__ */ new Date()).getFullYear()
|
|
2594
|
+
);
|
|
2595
|
+
const [rangeStart, setRangeStart] = React4__namespace.useState(
|
|
2596
|
+
value?.start ?? null
|
|
2597
|
+
);
|
|
2598
|
+
const [rangeEnd, setRangeEnd] = React4__namespace.useState(
|
|
2599
|
+
value?.end ?? null
|
|
2600
|
+
);
|
|
2601
|
+
const [selectingEnd, setSelectingEnd] = React4__namespace.useState(false);
|
|
2602
|
+
const [hoverDate, setHoverDate] = React4__namespace.useState(null);
|
|
2603
|
+
const calendarRef = React4__namespace.useRef(null);
|
|
2604
|
+
const triggerRef = React4__namespace.useRef(null);
|
|
2605
|
+
const [resolvedAlign, setResolvedAlign] = React4__namespace.useState(
|
|
2606
|
+
align === "end" ? "end" : "start"
|
|
2607
|
+
);
|
|
2608
|
+
const isMobileVariant = variant === "mobile";
|
|
2609
|
+
const isResponsive = variant === "responsive";
|
|
2610
|
+
const focusTrapRef = chunkNNEFAUHV_cjs.useFocusTrap(
|
|
2611
|
+
isMobileVariant && isCalendarOpen
|
|
2612
|
+
);
|
|
2613
|
+
const rightMonth = leftMonth === 11 ? 0 : leftMonth + 1;
|
|
2614
|
+
const rightYear = leftMonth === 11 ? leftYear + 1 : leftYear;
|
|
2615
|
+
React4__namespace.useEffect(() => {
|
|
2616
|
+
if (!value) {
|
|
2617
|
+
setRangeStart(null);
|
|
2618
|
+
setRangeEnd(null);
|
|
2619
|
+
return;
|
|
2620
|
+
}
|
|
2621
|
+
setRangeStart(value.start ?? null);
|
|
2622
|
+
setRangeEnd(value.end ?? null);
|
|
2623
|
+
}, [value]);
|
|
2624
|
+
const wrapperRef = React4__namespace.useRef(null);
|
|
2625
|
+
const outsideRefs = React4__namespace.useMemo(
|
|
2626
|
+
() => [wrapperRef, calendarRef],
|
|
2627
|
+
[calendarRef]
|
|
2628
|
+
);
|
|
2629
|
+
chunkFSGEDDF2_cjs.useClickOutside(
|
|
2630
|
+
outsideRefs,
|
|
2631
|
+
() => {
|
|
2632
|
+
setIsCalendarOpen(false);
|
|
2633
|
+
setSelectingEnd(false);
|
|
2634
|
+
},
|
|
2635
|
+
isCalendarOpen
|
|
2636
|
+
);
|
|
2637
|
+
const { anchorRef, floatingRef, style } = chunkAOHJILLU_cjs.useAnchoredPosition({
|
|
2638
|
+
open: !isMobileVariant && isCalendarOpen,
|
|
2639
|
+
placement: resolvedAlign === "end" ? "bottom-end" : "bottom-start"
|
|
2640
|
+
});
|
|
2641
|
+
chunkFHY3K6PL_cjs.useEscapeKey(() => {
|
|
2642
|
+
setIsCalendarOpen(false);
|
|
2643
|
+
setSelectingEnd(false);
|
|
2644
|
+
triggerRef.current?.focus();
|
|
2645
|
+
}, isCalendarOpen);
|
|
2646
|
+
React4__namespace.useEffect(() => {
|
|
2647
|
+
if (chunkSCV7C55E_cjs.isStorybookDocsMode()) return;
|
|
2648
|
+
if (isMobileVariant && isCalendarOpen) {
|
|
2649
|
+
const prev = document.body.style.overflow;
|
|
2650
|
+
document.body.style.overflow = "hidden";
|
|
2651
|
+
return () => {
|
|
2652
|
+
document.body.style.overflow = prev;
|
|
2653
|
+
};
|
|
2654
|
+
}
|
|
2655
|
+
}, [isMobileVariant, isCalendarOpen]);
|
|
2656
|
+
React4__namespace.useLayoutEffect(() => {
|
|
2657
|
+
if (isMobileVariant || !isCalendarOpen) return;
|
|
2658
|
+
if (align === "start" || align === "end") {
|
|
2659
|
+
setResolvedAlign(align);
|
|
2660
|
+
return;
|
|
2661
|
+
}
|
|
2662
|
+
if (typeof window === "undefined") return;
|
|
2663
|
+
const trigger = triggerRef.current;
|
|
2664
|
+
if (!trigger) return;
|
|
2665
|
+
const rect = trigger.getBoundingClientRect();
|
|
2666
|
+
const estimatedPopupWidth = showPresets ? 840 : 640;
|
|
2667
|
+
const margin = 8;
|
|
2668
|
+
const overflowsRight = rect.left + estimatedPopupWidth > window.innerWidth - margin;
|
|
2669
|
+
const fitsLeftAligned = rect.right - estimatedPopupWidth >= margin;
|
|
2670
|
+
setResolvedAlign(overflowsRight && fitsLeftAligned ? "end" : "start");
|
|
2671
|
+
}, [align, isCalendarOpen, isMobileVariant, showPresets]);
|
|
2672
|
+
const handlePresetSelect = (presetKey) => {
|
|
2673
|
+
const range = calculateDateRange(presetKey);
|
|
2674
|
+
setRangeStart(range.start);
|
|
2675
|
+
setRangeEnd(range.end);
|
|
2676
|
+
setSelectingEnd(false);
|
|
2677
|
+
setIsCalendarOpen(false);
|
|
2678
|
+
if (range.start) {
|
|
2679
|
+
setLeftMonth(range.start.getMonth());
|
|
2680
|
+
setLeftYear(range.start.getFullYear());
|
|
2681
|
+
}
|
|
2682
|
+
onChange(range, presetKey);
|
|
2683
|
+
};
|
|
2684
|
+
const handleDayClick = (day, month, year) => {
|
|
2685
|
+
const clicked = new Date(year, month, day);
|
|
2686
|
+
if (!selectingEnd) {
|
|
2687
|
+
setRangeStart(clicked);
|
|
2688
|
+
setRangeEnd(null);
|
|
2689
|
+
setSelectingEnd(true);
|
|
2690
|
+
} else {
|
|
2691
|
+
let start = rangeStart;
|
|
2692
|
+
let end = clicked;
|
|
2693
|
+
if (end < start) {
|
|
2694
|
+
[start, end] = [end, start];
|
|
2695
|
+
}
|
|
2696
|
+
setRangeStart(start);
|
|
2697
|
+
setRangeEnd(end);
|
|
2698
|
+
setSelectingEnd(false);
|
|
2699
|
+
if (variant !== "mobile") {
|
|
2700
|
+
setIsCalendarOpen(false);
|
|
2701
|
+
}
|
|
2702
|
+
onChange({ start, end });
|
|
2703
|
+
}
|
|
2704
|
+
};
|
|
2705
|
+
const toggleCalendar = () => {
|
|
2706
|
+
if (!isCalendarOpen) {
|
|
2707
|
+
if (value?.start) {
|
|
2708
|
+
setRangeStart(value.start);
|
|
2709
|
+
setRangeEnd(value.end ?? null);
|
|
2710
|
+
setLeftMonth(value.start.getMonth());
|
|
2711
|
+
setLeftYear(value.start.getFullYear());
|
|
2712
|
+
} else {
|
|
2713
|
+
const now = /* @__PURE__ */ new Date();
|
|
2714
|
+
setLeftMonth(now.getMonth());
|
|
2715
|
+
setLeftYear(now.getFullYear());
|
|
2716
|
+
}
|
|
2717
|
+
setSelectingEnd(false);
|
|
2718
|
+
}
|
|
2719
|
+
setIsCalendarOpen(!isCalendarOpen);
|
|
2720
|
+
};
|
|
2721
|
+
const goToPrevMonth = () => {
|
|
2722
|
+
if (leftMonth === 0) {
|
|
2723
|
+
setLeftMonth(11);
|
|
2724
|
+
setLeftYear(leftYear - 1);
|
|
2725
|
+
} else {
|
|
2726
|
+
setLeftMonth(leftMonth - 1);
|
|
2727
|
+
}
|
|
2728
|
+
};
|
|
2729
|
+
const goToNextMonth = () => {
|
|
2730
|
+
if (leftMonth === 11) {
|
|
2731
|
+
setLeftMonth(0);
|
|
2732
|
+
setLeftYear(leftYear + 1);
|
|
2733
|
+
} else {
|
|
2734
|
+
setLeftMonth(leftMonth + 1);
|
|
2735
|
+
}
|
|
2736
|
+
};
|
|
2737
|
+
const getDaysInMonth = (month, year) => new Date(year, month + 1, 0).getDate();
|
|
2738
|
+
const getFirstDayOfMonth = (month, year) => new Date(year, month, 1).getDay();
|
|
2739
|
+
const isSameDay = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
2740
|
+
const isInRange = (date) => {
|
|
2741
|
+
const start = rangeStart;
|
|
2742
|
+
const end = selectingEnd ? hoverDate : rangeEnd;
|
|
2743
|
+
if (!start || !end) return false;
|
|
2744
|
+
const [lo, hi] = start <= end ? [start, end] : [end, start];
|
|
2745
|
+
return date > lo && date < hi;
|
|
2746
|
+
};
|
|
2747
|
+
const isStart = (date) => {
|
|
2748
|
+
if (!rangeStart) return false;
|
|
2749
|
+
return isSameDay(date, rangeStart);
|
|
2750
|
+
};
|
|
2751
|
+
const isEnd = (date) => {
|
|
2752
|
+
const end = selectingEnd ? hoverDate : rangeEnd;
|
|
2753
|
+
if (!end) return false;
|
|
2754
|
+
return isSameDay(date, end);
|
|
2755
|
+
};
|
|
2756
|
+
const isToday = (date) => {
|
|
2757
|
+
const today = /* @__PURE__ */ new Date();
|
|
2758
|
+
return isSameDay(date, today);
|
|
2759
|
+
};
|
|
2760
|
+
const displayValue = value ? formatDateRange(value) : "";
|
|
2761
|
+
const monthNames = React4__namespace.useMemo(
|
|
2762
|
+
() => Array.from(
|
|
2763
|
+
{ length: 12 },
|
|
2764
|
+
(_, i) => new Intl.DateTimeFormat(void 0, { month: "long" }).format(
|
|
2765
|
+
new Date(2e3, i, 1)
|
|
2766
|
+
)
|
|
2767
|
+
),
|
|
2768
|
+
[]
|
|
2769
|
+
);
|
|
2770
|
+
const weekdayNames = React4__namespace.useMemo(
|
|
2771
|
+
() => Array.from(
|
|
2772
|
+
{ length: 7 },
|
|
2773
|
+
(_, i) => new Intl.DateTimeFormat(void 0, { weekday: "short" }).format(
|
|
2774
|
+
new Date(1970, 0, 4 + i)
|
|
2775
|
+
)
|
|
2776
|
+
),
|
|
2777
|
+
[]
|
|
2778
|
+
);
|
|
2779
|
+
const renderMonthGrid = (month, year) => {
|
|
2780
|
+
const daysInMonth = getDaysInMonth(month, year);
|
|
2781
|
+
const firstDay = getFirstDayOfMonth(month, year);
|
|
2782
|
+
const prevMonth = month === 0 ? 11 : month - 1;
|
|
2783
|
+
const prevYear = month === 0 ? year - 1 : year;
|
|
2784
|
+
const daysInPrevMonth = getDaysInMonth(prevMonth, prevYear);
|
|
2785
|
+
const cells = [];
|
|
2786
|
+
for (let i = firstDay - 1; i >= 0; i--) {
|
|
2787
|
+
cells.push({
|
|
2788
|
+
day: daysInPrevMonth - i,
|
|
2789
|
+
month: prevMonth,
|
|
2790
|
+
year: prevYear,
|
|
2791
|
+
isCurrentMonth: false
|
|
2792
|
+
});
|
|
2793
|
+
}
|
|
2794
|
+
for (let i = 1; i <= daysInMonth; i++) {
|
|
2795
|
+
cells.push({ day: i, month, year, isCurrentMonth: true });
|
|
2796
|
+
}
|
|
2797
|
+
const nextMonth = month === 11 ? 0 : month + 1;
|
|
2798
|
+
const nextYear = month === 11 ? year + 1 : year;
|
|
2799
|
+
const remaining = 42 - cells.length;
|
|
2800
|
+
for (let i = 1; i <= remaining; i++) {
|
|
2801
|
+
cells.push({
|
|
2802
|
+
day: i,
|
|
2803
|
+
month: nextMonth,
|
|
2804
|
+
year: nextYear,
|
|
2805
|
+
isCurrentMonth: false
|
|
2806
|
+
});
|
|
2807
|
+
}
|
|
2808
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-[280px]", "data-slot": "date-range-grid", children: [
|
|
2809
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-1 grid grid-cols-7", "data-slot": "date-range-weekdays", children: weekdayNames.map((dayName) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2810
|
+
"div",
|
|
2811
|
+
{
|
|
2812
|
+
className: "text-muted-foreground py-1 text-center text-xs font-medium",
|
|
2813
|
+
"data-slot": "date-range-weekday",
|
|
2814
|
+
children: dayName
|
|
2815
|
+
},
|
|
2816
|
+
dayName
|
|
2817
|
+
)) }),
|
|
2818
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-7", "data-slot": "date-range-day-grid", children: cells.map((cell, index) => {
|
|
2819
|
+
const date = new Date(cell.year, cell.month, cell.day);
|
|
2820
|
+
const inRange = isInRange(date);
|
|
2821
|
+
const start = isStart(date);
|
|
2822
|
+
const end = isEnd(date);
|
|
2823
|
+
const today = isToday(date);
|
|
2824
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2825
|
+
"button",
|
|
2826
|
+
{
|
|
2827
|
+
type: "button",
|
|
2828
|
+
"data-slot": "date-range-day",
|
|
2829
|
+
onClick: () => handleDayClick(cell.day, cell.month, cell.year),
|
|
2830
|
+
onMouseEnter: () => {
|
|
2831
|
+
if (selectingEnd) {
|
|
2832
|
+
setHoverDate(date);
|
|
2833
|
+
}
|
|
2834
|
+
},
|
|
2835
|
+
className: chunkS5RVSXDV_cjs.cn(
|
|
2836
|
+
"relative h-9 w-10 text-center text-sm",
|
|
2837
|
+
"focus:ring-ring focus:z-10 focus:ring-2 focus:outline-none",
|
|
2838
|
+
"transition-colors",
|
|
2839
|
+
// Not current month — dimmed
|
|
2840
|
+
!cell.isCurrentMonth && "text-muted-foreground/50",
|
|
2841
|
+
// Current month — normal
|
|
2842
|
+
cell.isCurrentMonth && "text-foreground",
|
|
2843
|
+
// Hover
|
|
2844
|
+
"hover:bg-muted",
|
|
2845
|
+
// In range background
|
|
2846
|
+
inRange && "bg-muted",
|
|
2847
|
+
// Start date
|
|
2848
|
+
start && "bg-foreground text-background hover:bg-foreground rounded-s-md font-semibold",
|
|
2849
|
+
// End date
|
|
2850
|
+
end && !start && "border-foreground text-foreground rounded-e-md border font-semibold",
|
|
2851
|
+
// Today indicator (only if not start/end)
|
|
2852
|
+
today && !start && !end && "font-semibold"
|
|
2853
|
+
),
|
|
2854
|
+
children: cell.day
|
|
2855
|
+
},
|
|
2856
|
+
index
|
|
2857
|
+
);
|
|
2858
|
+
}) })
|
|
2859
|
+
] });
|
|
2860
|
+
};
|
|
2861
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2862
|
+
"div",
|
|
2863
|
+
{
|
|
2864
|
+
ref: (node) => {
|
|
2865
|
+
wrapperRef.current = node;
|
|
2866
|
+
anchorRef.current = node;
|
|
2867
|
+
},
|
|
2868
|
+
className: chunkS5RVSXDV_cjs.cn("relative inline-block", className),
|
|
2869
|
+
"data-slot": "date-range-picker",
|
|
2870
|
+
children: [
|
|
2871
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2872
|
+
"button",
|
|
2873
|
+
{
|
|
2874
|
+
ref: triggerRef,
|
|
2875
|
+
type: "button",
|
|
2876
|
+
onClick: toggleCalendar,
|
|
2877
|
+
"aria-expanded": isCalendarOpen,
|
|
2878
|
+
"aria-haspopup": "dialog",
|
|
2879
|
+
"data-slot": "date-range-trigger",
|
|
2880
|
+
className: chunkS5RVSXDV_cjs.cn(
|
|
2881
|
+
"border-input bg-background hover:bg-muted",
|
|
2882
|
+
"inline-flex w-[300px] items-center gap-2 rounded-md border px-4 py-2 text-start text-sm font-normal",
|
|
2883
|
+
"focus:ring-ring focus:ring-2 focus:outline-none",
|
|
2884
|
+
"transition-colors",
|
|
2885
|
+
!displayValue && "text-muted-foreground"
|
|
2886
|
+
),
|
|
2887
|
+
children: [
|
|
2888
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Calendar, { className: "h-4 w-4", "data-slot": "date-range-trigger-icon" }),
|
|
2889
|
+
displayValue || placeholder
|
|
2890
|
+
]
|
|
2891
|
+
}
|
|
2892
|
+
),
|
|
2893
|
+
isMobileVariant && isCalendarOpen && // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
2894
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2895
|
+
"div",
|
|
2896
|
+
{
|
|
2897
|
+
"data-slot": "date-range-mobile-overlay",
|
|
2898
|
+
className: "fixed inset-0 z-50 flex items-end justify-center bg-black/40",
|
|
2899
|
+
onClick: (event) => {
|
|
2900
|
+
if (event.target !== event.currentTarget) return;
|
|
2901
|
+
setIsCalendarOpen(false);
|
|
2902
|
+
setSelectingEnd(false);
|
|
2903
|
+
setHoverDate(null);
|
|
2904
|
+
if (triggerRef.current instanceof HTMLElement) {
|
|
2905
|
+
triggerRef.current.focus();
|
|
2906
|
+
}
|
|
2907
|
+
},
|
|
2908
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2909
|
+
"div",
|
|
2910
|
+
{
|
|
2911
|
+
ref: (node) => {
|
|
2912
|
+
calendarRef.current = node;
|
|
2913
|
+
focusTrapRef.current = node;
|
|
2914
|
+
},
|
|
2915
|
+
className: "bg-background animate-in slide-in-from-bottom max-h-[90vh] w-full max-w-md overflow-y-auto rounded-t-2xl px-6 pt-4 pb-6 shadow-xl",
|
|
2916
|
+
role: "dialog",
|
|
2917
|
+
"aria-modal": "true",
|
|
2918
|
+
"aria-labelledby": "mobile-date-range-title",
|
|
2919
|
+
"data-slot": "date-range-mobile-sheet",
|
|
2920
|
+
children: [
|
|
2921
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2922
|
+
"div",
|
|
2923
|
+
{
|
|
2924
|
+
className: "bg-muted mx-auto mb-4 h-1 w-10 rounded-full",
|
|
2925
|
+
"data-slot": "date-range-mobile-handle"
|
|
2926
|
+
}
|
|
2927
|
+
),
|
|
2928
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2929
|
+
"h3",
|
|
2930
|
+
{
|
|
2931
|
+
id: "mobile-date-range-title",
|
|
2932
|
+
className: "mb-4 text-lg font-semibold",
|
|
2933
|
+
"data-slot": "date-range-mobile-title",
|
|
2934
|
+
children: placeholder
|
|
2935
|
+
}
|
|
2936
|
+
),
|
|
2937
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2938
|
+
"div",
|
|
2939
|
+
{
|
|
2940
|
+
className: "mb-3 flex items-center justify-center gap-4",
|
|
2941
|
+
"data-slot": "date-range-month-header",
|
|
2942
|
+
children: [
|
|
2943
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2944
|
+
"button",
|
|
2945
|
+
{
|
|
2946
|
+
type: "button",
|
|
2947
|
+
onClick: goToPrevMonth,
|
|
2948
|
+
className: "hover:bg-muted rounded-md p-1 transition-colors",
|
|
2949
|
+
"aria-label": "Previous month",
|
|
2950
|
+
"data-slot": "date-range-nav",
|
|
2951
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-4 w-4 rtl:-scale-x-100" })
|
|
2952
|
+
}
|
|
2953
|
+
),
|
|
2954
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2955
|
+
"div",
|
|
2956
|
+
{
|
|
2957
|
+
className: "text-sm font-medium",
|
|
2958
|
+
"data-slot": "date-range-month-label",
|
|
2959
|
+
children: [
|
|
2960
|
+
monthNames[leftMonth],
|
|
2961
|
+
" ",
|
|
2962
|
+
leftYear
|
|
2963
|
+
]
|
|
2964
|
+
}
|
|
2965
|
+
),
|
|
2966
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2967
|
+
"button",
|
|
2968
|
+
{
|
|
2969
|
+
type: "button",
|
|
2970
|
+
onClick: goToNextMonth,
|
|
2971
|
+
className: "hover:bg-muted rounded-md p-1 transition-colors",
|
|
2972
|
+
"aria-label": "Next month",
|
|
2973
|
+
"data-slot": "date-range-nav",
|
|
2974
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4 rtl:-scale-x-100" })
|
|
2975
|
+
}
|
|
2976
|
+
)
|
|
2977
|
+
]
|
|
2978
|
+
}
|
|
2979
|
+
),
|
|
2980
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2981
|
+
"div",
|
|
2982
|
+
{
|
|
2983
|
+
className: "flex justify-center",
|
|
2984
|
+
onMouseLeave: () => setHoverDate(null),
|
|
2985
|
+
children: renderMonthGrid(leftMonth, leftYear)
|
|
2986
|
+
}
|
|
2987
|
+
),
|
|
2988
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2989
|
+
"button",
|
|
2990
|
+
{
|
|
2991
|
+
type: "button",
|
|
2992
|
+
"data-slot": "date-range-mobile-done",
|
|
2993
|
+
onClick: () => {
|
|
2994
|
+
setIsCalendarOpen(false);
|
|
2995
|
+
setSelectingEnd(false);
|
|
2996
|
+
if (triggerRef.current instanceof HTMLElement) {
|
|
2997
|
+
triggerRef.current.focus();
|
|
2998
|
+
}
|
|
2999
|
+
},
|
|
3000
|
+
className: "border-input hover:bg-muted mt-6 w-full rounded-lg border py-3 text-sm font-medium transition-colors",
|
|
3001
|
+
children: labels?.done ?? "Done"
|
|
3002
|
+
}
|
|
3003
|
+
)
|
|
3004
|
+
]
|
|
3005
|
+
}
|
|
3006
|
+
)
|
|
3007
|
+
}
|
|
3008
|
+
),
|
|
3009
|
+
!isMobileVariant && isCalendarOpen && reactDom.createPortal(
|
|
3010
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3011
|
+
"div",
|
|
3012
|
+
{
|
|
3013
|
+
ref: (node) => {
|
|
3014
|
+
calendarRef.current = node;
|
|
3015
|
+
floatingRef.current = node;
|
|
3016
|
+
},
|
|
3017
|
+
style,
|
|
3018
|
+
className: chunkS5RVSXDV_cjs.cn(
|
|
3019
|
+
"overflow-auto",
|
|
3020
|
+
"bg-background border-border rounded-lg border shadow-lg"
|
|
3021
|
+
),
|
|
3022
|
+
role: "dialog",
|
|
3023
|
+
"aria-label": "Choose date range",
|
|
3024
|
+
"data-slot": "date-range-popup",
|
|
3025
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex", children: [
|
|
3026
|
+
showPresets && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3027
|
+
"div",
|
|
3028
|
+
{
|
|
3029
|
+
className: chunkS5RVSXDV_cjs.cn(
|
|
3030
|
+
"border-border flex w-[200px] shrink-0 flex-col gap-0.5 border-e p-3",
|
|
3031
|
+
isResponsive && "hidden md:flex"
|
|
3032
|
+
),
|
|
3033
|
+
"data-slot": "date-range-presets",
|
|
3034
|
+
children: finalPresets.map((preset) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3035
|
+
"button",
|
|
3036
|
+
{
|
|
3037
|
+
type: "button",
|
|
3038
|
+
onClick: () => handlePresetSelect(preset.key),
|
|
3039
|
+
"data-slot": "date-range-preset",
|
|
3040
|
+
className: chunkS5RVSXDV_cjs.cn(
|
|
3041
|
+
"rounded-md px-3 py-1.5 text-start text-sm transition-colors",
|
|
3042
|
+
"hover:bg-muted",
|
|
3043
|
+
activePreset === preset.key && "bg-primary-800 text-white"
|
|
3044
|
+
),
|
|
3045
|
+
children: preset.label
|
|
3046
|
+
},
|
|
3047
|
+
preset.key
|
|
3048
|
+
))
|
|
3049
|
+
}
|
|
3050
|
+
),
|
|
3051
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-4", "data-slot": "date-range-calendar", children: [
|
|
3052
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3053
|
+
"p",
|
|
3054
|
+
{
|
|
3055
|
+
className: "text-muted-foreground mb-4 text-sm",
|
|
3056
|
+
"data-slot": "date-range-subtitle",
|
|
3057
|
+
children: "Select a start and end date from the calendar."
|
|
3058
|
+
}
|
|
3059
|
+
),
|
|
3060
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3061
|
+
"div",
|
|
3062
|
+
{
|
|
3063
|
+
className: "flex gap-8",
|
|
3064
|
+
onMouseLeave: () => setHoverDate(null),
|
|
3065
|
+
"data-slot": "date-range-calendars",
|
|
3066
|
+
children: [
|
|
3067
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
3068
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3069
|
+
"div",
|
|
3070
|
+
{
|
|
3071
|
+
className: "mb-3 flex items-center",
|
|
3072
|
+
"data-slot": "date-range-month-header",
|
|
3073
|
+
children: [
|
|
3074
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3075
|
+
"button",
|
|
3076
|
+
{
|
|
3077
|
+
type: "button",
|
|
3078
|
+
onClick: goToPrevMonth,
|
|
3079
|
+
className: "hover:bg-muted rounded-md p-1 transition-colors",
|
|
3080
|
+
"aria-label": "Previous month",
|
|
3081
|
+
"data-slot": "date-range-nav",
|
|
3082
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-4 w-4 rtl:-scale-x-100" })
|
|
3083
|
+
}
|
|
3084
|
+
),
|
|
3085
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3086
|
+
"div",
|
|
3087
|
+
{
|
|
3088
|
+
className: "flex-1 text-center text-sm font-medium",
|
|
3089
|
+
"data-slot": "date-range-month-label",
|
|
3090
|
+
children: [
|
|
3091
|
+
monthNames[leftMonth],
|
|
3092
|
+
" ",
|
|
3093
|
+
leftYear
|
|
3094
|
+
]
|
|
3095
|
+
}
|
|
3096
|
+
),
|
|
3097
|
+
isResponsive && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3098
|
+
"button",
|
|
3099
|
+
{
|
|
3100
|
+
type: "button",
|
|
3101
|
+
onClick: goToNextMonth,
|
|
3102
|
+
className: "hover:bg-muted rounded-md p-1 transition-colors md:hidden",
|
|
3103
|
+
"aria-label": "Next month",
|
|
3104
|
+
"data-slot": "date-range-nav",
|
|
3105
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4 rtl:-scale-x-100" })
|
|
3106
|
+
}
|
|
3107
|
+
)
|
|
3108
|
+
]
|
|
3109
|
+
}
|
|
3110
|
+
),
|
|
3111
|
+
renderMonthGrid(leftMonth, leftYear)
|
|
3112
|
+
] }),
|
|
3113
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkS5RVSXDV_cjs.cn(isResponsive && "hidden md:block"), children: [
|
|
3114
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3115
|
+
"div",
|
|
3116
|
+
{
|
|
3117
|
+
className: "mb-3 flex items-center",
|
|
3118
|
+
"data-slot": "date-range-month-header",
|
|
3119
|
+
children: [
|
|
3120
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3121
|
+
"div",
|
|
3122
|
+
{
|
|
3123
|
+
className: "flex-1 text-center text-sm font-medium",
|
|
3124
|
+
"data-slot": "date-range-month-label",
|
|
3125
|
+
children: [
|
|
3126
|
+
monthNames[rightMonth],
|
|
3127
|
+
" ",
|
|
3128
|
+
rightYear
|
|
3129
|
+
]
|
|
3130
|
+
}
|
|
3131
|
+
),
|
|
3132
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3133
|
+
"button",
|
|
3134
|
+
{
|
|
3135
|
+
type: "button",
|
|
3136
|
+
onClick: goToNextMonth,
|
|
3137
|
+
className: "hover:bg-muted rounded-md p-1 transition-colors",
|
|
3138
|
+
"aria-label": "Next month",
|
|
3139
|
+
"data-slot": "date-range-nav",
|
|
3140
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4 rtl:-scale-x-100" })
|
|
3141
|
+
}
|
|
3142
|
+
)
|
|
3143
|
+
]
|
|
3144
|
+
}
|
|
3145
|
+
),
|
|
3146
|
+
renderMonthGrid(rightMonth, rightYear)
|
|
3147
|
+
] })
|
|
3148
|
+
]
|
|
3149
|
+
}
|
|
3150
|
+
)
|
|
3151
|
+
] })
|
|
3152
|
+
] })
|
|
3153
|
+
}
|
|
3154
|
+
),
|
|
3155
|
+
document.body
|
|
3156
|
+
)
|
|
3157
|
+
]
|
|
3158
|
+
}
|
|
3159
|
+
);
|
|
3160
|
+
}
|
|
3161
|
+
function DateRangeFilter({
|
|
3162
|
+
value: _value,
|
|
3163
|
+
onChange,
|
|
3164
|
+
presets,
|
|
3165
|
+
activePreset,
|
|
3166
|
+
variant = "outline",
|
|
3167
|
+
className,
|
|
3168
|
+
labels = {}
|
|
3169
|
+
}) {
|
|
3170
|
+
const finalPresets = presets || getDefaultPresets(labels);
|
|
3171
|
+
const activeLabel = finalPresets.find((p) => p.key === activePreset)?.label;
|
|
3172
|
+
const handlePresetSelect = (presetKey) => {
|
|
3173
|
+
const range = calculateDateRange(presetKey);
|
|
3174
|
+
onChange(range, presetKey);
|
|
3175
|
+
};
|
|
3176
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3177
|
+
chunkPINIBEIU_cjs.Dropdown,
|
|
3178
|
+
{
|
|
3179
|
+
trigger: /* @__PURE__ */ jsxRuntime.jsxs(chunkANMX7YDL_cjs.Button, { variant, size: "md", className, children: [
|
|
3180
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Calendar, { className: "me-2 h-4 w-4" }),
|
|
3181
|
+
activeLabel || labels.filter || "Filter by Date",
|
|
3182
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "ms-2 h-3 w-3" })
|
|
3183
|
+
] }),
|
|
3184
|
+
className: "w-56",
|
|
3185
|
+
"data-slot": "date-range-filter",
|
|
3186
|
+
children: finalPresets.map((preset) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3187
|
+
chunkPINIBEIU_cjs.DropdownItem,
|
|
3188
|
+
{
|
|
3189
|
+
onClick: () => handlePresetSelect(preset.key),
|
|
3190
|
+
className: chunkS5RVSXDV_cjs.cn(
|
|
3191
|
+
activePreset === preset.key && "bg-primary/10 text-primary"
|
|
3192
|
+
),
|
|
3193
|
+
children: preset.label
|
|
3194
|
+
},
|
|
3195
|
+
preset.key
|
|
3196
|
+
))
|
|
3197
|
+
}
|
|
3198
|
+
);
|
|
3199
|
+
}
|
|
3200
|
+
var GROUP_ORDER = [
|
|
3201
|
+
"unreconciled",
|
|
3202
|
+
"taking",
|
|
3203
|
+
"taking-noncompliant",
|
|
3204
|
+
"not-taking",
|
|
3205
|
+
"unknown"
|
|
3206
|
+
];
|
|
3207
|
+
var MEDICATION_STATUS_LABELS = {
|
|
3208
|
+
unreconciled: "Unreconciled",
|
|
3209
|
+
taking: "Taking as Directed",
|
|
3210
|
+
"taking-noncompliant": "Not Taking as Directed",
|
|
3211
|
+
"not-taking": "Not Taking",
|
|
3212
|
+
unknown: "Unknown"
|
|
3213
|
+
};
|
|
3214
|
+
var DEFAULT_ACTIONS2 = [
|
|
3215
|
+
"open",
|
|
3216
|
+
"correct",
|
|
3217
|
+
"refill",
|
|
3218
|
+
"add-task",
|
|
3219
|
+
"note",
|
|
3220
|
+
"remove"
|
|
3221
|
+
];
|
|
3222
|
+
var ACTION_META3 = {
|
|
3223
|
+
open: { label: "Open", icon: chunkL7L5S2HO_cjs.ExternalLink },
|
|
3224
|
+
correct: { label: "Correct", icon: chunkL7L5S2HO_cjs.Pencil },
|
|
3225
|
+
refill: { label: "Refill", icon: chunkL7L5S2HO_cjs.RefreshCw },
|
|
3226
|
+
"add-task": { label: "Add Task", icon: chunkL7L5S2HO_cjs.CalendarCheck },
|
|
3227
|
+
note: { label: "Notes", icon: chunkL7L5S2HO_cjs.StickyNote },
|
|
3228
|
+
remove: { label: "Remove", icon: chunkL7L5S2HO_cjs.Ban },
|
|
3229
|
+
"move-up": { label: "Move Up", icon: chunkL7L5S2HO_cjs.ChevronUp },
|
|
3230
|
+
"move-down": { label: "Move Down", icon: chunkL7L5S2HO_cjs.ChevronDown }
|
|
3231
|
+
};
|
|
3232
|
+
var STATUS_BUTTON_META = [
|
|
3233
|
+
{ status: "taking", label: "Taking", icon: chunkL7L5S2HO_cjs.ThumbsUp },
|
|
3234
|
+
{
|
|
3235
|
+
status: "taking-noncompliant",
|
|
3236
|
+
label: "Taking \u2013 Noncompliant",
|
|
3237
|
+
icon: chunkL7L5S2HO_cjs.HandMetal
|
|
3238
|
+
},
|
|
3239
|
+
{ status: "not-taking", label: "Not Taking", icon: chunkL7L5S2HO_cjs.ThumbsDown },
|
|
3240
|
+
{ status: "unknown", label: "Unknown", icon: chunkL7L5S2HO_cjs.HelpCircle }
|
|
3241
|
+
];
|
|
3242
|
+
function MedicationRow({
|
|
3243
|
+
medication,
|
|
3244
|
+
actions,
|
|
3245
|
+
readOnly,
|
|
3246
|
+
drag,
|
|
3247
|
+
onMove,
|
|
3248
|
+
onStatusChange,
|
|
3249
|
+
onAction
|
|
3250
|
+
}) {
|
|
3251
|
+
const m = chunkFSLI5IKP_cjs.useMessages();
|
|
3252
|
+
const handleRowKeyDown = (e) => {
|
|
3253
|
+
if (e.target !== e.currentTarget) return;
|
|
3254
|
+
if (e.altKey && (e.key === "ArrowUp" || e.key === "ArrowDown")) {
|
|
3255
|
+
e.preventDefault();
|
|
3256
|
+
onMove?.(medication, e.key === "ArrowUp" ? -1 : 1);
|
|
3257
|
+
} else if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
3258
|
+
e.preventDefault();
|
|
3259
|
+
const list = e.currentTarget.closest("ul");
|
|
3260
|
+
if (!list) return;
|
|
3261
|
+
const rows = Array.from(
|
|
3262
|
+
list.querySelectorAll("li[data-medication-id]")
|
|
3263
|
+
);
|
|
3264
|
+
const i = rows.indexOf(e.currentTarget);
|
|
3265
|
+
rows[e.key === "ArrowUp" ? Math.max(0, i - 1) : Math.min(rows.length - 1, i + 1)]?.focus();
|
|
3266
|
+
}
|
|
3267
|
+
};
|
|
3268
|
+
return (
|
|
3269
|
+
// Rows are focus stops when reordering is enabled so drag & drop has a
|
|
3270
|
+
// keyboard equivalent (Alt+↑/↓) — 508.
|
|
3271
|
+
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/no-noninteractive-tabindex */
|
|
3272
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3273
|
+
"li",
|
|
3274
|
+
{
|
|
3275
|
+
"data-slot": "clinical-list-row",
|
|
3276
|
+
"data-medication-id": medication.id,
|
|
3277
|
+
tabIndex: drag.enabled ? 0 : void 0,
|
|
3278
|
+
onKeyDown: drag.enabled ? handleRowKeyDown : void 0,
|
|
3279
|
+
"aria-label": drag.enabled ? m("{name}. Alt plus arrow keys to reorder.", {
|
|
3280
|
+
name: medication.name
|
|
3281
|
+
}) : void 0,
|
|
3282
|
+
...drag.rowProps(medication.id),
|
|
3283
|
+
className: chunkS5RVSXDV_cjs.cn(
|
|
3284
|
+
"group border-border/60 relative flex min-h-11 flex-wrap items-center gap-x-2 gap-y-1 border-b px-1 py-2",
|
|
3285
|
+
"focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none",
|
|
3286
|
+
drag.enabled && "cursor-grab active:cursor-grabbing",
|
|
3287
|
+
chunkGF2BE4FB_cjs.dragIndicatorClasses(drag, medication.id)
|
|
3288
|
+
),
|
|
3289
|
+
children: [
|
|
3290
|
+
drag.enabled ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3291
|
+
chunkL7L5S2HO_cjs.GripVertical,
|
|
3292
|
+
{
|
|
3293
|
+
size: 14,
|
|
3294
|
+
"aria-hidden": true,
|
|
3295
|
+
className: "text-muted-foreground/50 shrink-0"
|
|
3296
|
+
}
|
|
3297
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground/60 select-none", children: "\u2022" }),
|
|
3298
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground font-medium", children: medication.name }),
|
|
3299
|
+
medication.code && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3300
|
+
"span",
|
|
3301
|
+
{
|
|
3302
|
+
className: "text-muted-foreground/70 text-xs",
|
|
3303
|
+
title: medication.code.display,
|
|
3304
|
+
children: [
|
|
3305
|
+
medication.code.system,
|
|
3306
|
+
" ",
|
|
3307
|
+
medication.code.code
|
|
3308
|
+
]
|
|
3309
|
+
}
|
|
3310
|
+
),
|
|
3311
|
+
medication.sig && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-sm", children: medication.sig }),
|
|
3312
|
+
medication.expired && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-bold text-red-600 dark:text-red-400", children: m("EXPIRED") }),
|
|
3313
|
+
medication.discontinuedDate && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground text-sm", children: [
|
|
3314
|
+
m("Discontinued on:"),
|
|
3315
|
+
" ",
|
|
3316
|
+
medication.discontinuedDate
|
|
3317
|
+
] }),
|
|
3318
|
+
(medication.note || medication.task) && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex w-full basis-full flex-col gap-0.5 ps-4", children: [
|
|
3319
|
+
medication.note && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground flex items-center gap-1.5 text-xs", children: [
|
|
3320
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkL7L5S2HO_cjs.StickyNote, { size: 12 }),
|
|
3321
|
+
medication.note
|
|
3322
|
+
] }),
|
|
3323
|
+
medication.task && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground flex items-center gap-1.5 text-xs", children: [
|
|
3324
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkL7L5S2HO_cjs.CalendarCheck, { size: 12 }),
|
|
3325
|
+
m("Task:"),
|
|
3326
|
+
" ",
|
|
3327
|
+
medication.task
|
|
3328
|
+
] })
|
|
3329
|
+
] }),
|
|
3330
|
+
!readOnly && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3331
|
+
chunk4NB4WOGU_cjs.RowActionToolbar,
|
|
3332
|
+
{
|
|
3333
|
+
label: m("Actions for {name}", { name: medication.name }),
|
|
3334
|
+
children: [
|
|
3335
|
+
actions.includes("open") && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3336
|
+
chunk4NB4WOGU_cjs.RowIconButton,
|
|
3337
|
+
{
|
|
3338
|
+
label: m(ACTION_META3.open.label),
|
|
3339
|
+
icon: ACTION_META3.open.icon,
|
|
3340
|
+
onClick: () => onAction?.(medication, "open")
|
|
3341
|
+
}
|
|
3342
|
+
),
|
|
3343
|
+
STATUS_BUTTON_META.map(({ status, label, icon }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3344
|
+
chunk4NB4WOGU_cjs.RowIconButton,
|
|
3345
|
+
{
|
|
3346
|
+
label: m(label),
|
|
3347
|
+
icon,
|
|
3348
|
+
active: medication.status === status,
|
|
3349
|
+
onClick: () => onStatusChange?.(medication, status)
|
|
3350
|
+
},
|
|
3351
|
+
status
|
|
3352
|
+
)),
|
|
3353
|
+
actions.filter((a) => a !== "open").map((action) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3354
|
+
chunk4NB4WOGU_cjs.RowIconButton,
|
|
3355
|
+
{
|
|
3356
|
+
label: m(ACTION_META3[action].label),
|
|
3357
|
+
icon: ACTION_META3[action].icon,
|
|
3358
|
+
onClick: () => onAction?.(medication, action)
|
|
3359
|
+
},
|
|
3360
|
+
action
|
|
3361
|
+
))
|
|
3362
|
+
]
|
|
3363
|
+
}
|
|
3364
|
+
)
|
|
3365
|
+
]
|
|
3366
|
+
}
|
|
3367
|
+
)
|
|
3368
|
+
);
|
|
3369
|
+
}
|
|
3370
|
+
var MedicationList = React4__namespace.forwardRef(
|
|
3371
|
+
({
|
|
3372
|
+
medications,
|
|
3373
|
+
title = "Presenting medications",
|
|
3374
|
+
onStatusChange,
|
|
3375
|
+
onAction,
|
|
3376
|
+
onReorder,
|
|
3377
|
+
actions = DEFAULT_ACTIONS2,
|
|
3378
|
+
quickAddOptions,
|
|
3379
|
+
onQuickAdd,
|
|
3380
|
+
onAddOther,
|
|
3381
|
+
readOnly = false,
|
|
3382
|
+
reconciledMessage = "All medications reconciled.",
|
|
3383
|
+
emptyMessage = "No medications recorded.",
|
|
3384
|
+
addSearch,
|
|
3385
|
+
className,
|
|
3386
|
+
"data-testid": dataTestId,
|
|
3387
|
+
...props
|
|
3388
|
+
}, ref) => {
|
|
3389
|
+
const m = chunkFSLI5IKP_cjs.useMessages();
|
|
3390
|
+
const [announcement, setAnnouncement] = chunkCPDNX3LS_cjs.useLiveAnnouncement();
|
|
3391
|
+
const handleStatusChange = React4__namespace.useCallback(
|
|
3392
|
+
(medication, status) => {
|
|
3393
|
+
setAnnouncement(
|
|
3394
|
+
m("{name} marked {status}", {
|
|
3395
|
+
name: medication.name,
|
|
3396
|
+
status: m(MEDICATION_STATUS_LABELS[status])
|
|
3397
|
+
})
|
|
3398
|
+
);
|
|
3399
|
+
onStatusChange?.(medication, status);
|
|
3400
|
+
},
|
|
3401
|
+
[m, onStatusChange, setAnnouncement]
|
|
3402
|
+
);
|
|
3403
|
+
const groups = GROUP_ORDER.map((status) => ({
|
|
3404
|
+
status,
|
|
3405
|
+
label: MEDICATION_STATUS_LABELS[status],
|
|
3406
|
+
items: medications.filter((m2) => m2.status === status)
|
|
3407
|
+
})).filter((g) => g.items.length > 0 || g.status === "unreconciled");
|
|
3408
|
+
const statusById = React4__namespace.useMemo(
|
|
3409
|
+
() => new Map(medications.map((m2) => [m2.id, m2.status])),
|
|
3410
|
+
[medications]
|
|
3411
|
+
);
|
|
3412
|
+
const statusOf = React4__namespace.useCallback(
|
|
3413
|
+
(id) => statusById.get(id),
|
|
3414
|
+
[statusById]
|
|
3415
|
+
);
|
|
3416
|
+
const drag = chunkGF2BE4FB_cjs.useDragReorder({
|
|
3417
|
+
ids: medications.map((m2) => m2.id),
|
|
3418
|
+
onReorder: readOnly || !onReorder ? void 0 : (ids) => {
|
|
3419
|
+
setAnnouncement(m("Medication list reordered"));
|
|
3420
|
+
onReorder(ids);
|
|
3421
|
+
},
|
|
3422
|
+
canDropOn: (dragged, target) => statusOf(dragged) === statusOf(target)
|
|
3423
|
+
});
|
|
3424
|
+
const moveMedication = React4__namespace.useCallback(
|
|
3425
|
+
(medication, dir) => {
|
|
3426
|
+
if (readOnly || !onReorder) return;
|
|
3427
|
+
const ids = medications.map((m2) => m2.id);
|
|
3428
|
+
const from = ids.indexOf(medication.id);
|
|
3429
|
+
let to = from + dir;
|
|
3430
|
+
while (to >= 0 && to < medications.length && medications[to].status !== medication.status) {
|
|
3431
|
+
to += dir;
|
|
3432
|
+
}
|
|
3433
|
+
if (to < 0 || to >= medications.length) return;
|
|
3434
|
+
[ids[from], ids[to]] = [ids[to], ids[from]];
|
|
3435
|
+
setAnnouncement(
|
|
3436
|
+
m(dir === -1 ? "{name} moved up" : "{name} moved down", {
|
|
3437
|
+
name: medication.name
|
|
3438
|
+
})
|
|
3439
|
+
);
|
|
3440
|
+
onReorder(ids);
|
|
3441
|
+
},
|
|
3442
|
+
[m, medications, onReorder, readOnly, setAnnouncement]
|
|
3443
|
+
);
|
|
3444
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3445
|
+
chunkMJWFNV3L_cjs.Card,
|
|
3446
|
+
{
|
|
3447
|
+
ref,
|
|
3448
|
+
padding: "none",
|
|
3449
|
+
className: chunkS5RVSXDV_cjs.cn("w-full", className),
|
|
3450
|
+
"data-testid": dataTestId,
|
|
3451
|
+
...props,
|
|
3452
|
+
children: [
|
|
3453
|
+
title !== null && /* @__PURE__ */ jsxRuntime.jsx(chunkMJWFNV3L_cjs.CardHeader, { className: "border-border bg-muted/50 border-b px-4 py-3", children: /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-foreground text-sm font-semibold tracking-wide uppercase", children: m(title) }) }),
|
|
3454
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkMJWFNV3L_cjs.CardContent, { className: "space-y-6 px-4 py-4", children: [
|
|
3455
|
+
groups.map(({ status, label, items }) => /* @__PURE__ */ jsxRuntime.jsxs("section", { "aria-label": m(label), children: [
|
|
3456
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3457
|
+
"h4",
|
|
3458
|
+
{
|
|
3459
|
+
"data-slot": "clinical-list-heading",
|
|
3460
|
+
className: "border-border text-foreground border-b pb-1 text-sm font-semibold tracking-wide uppercase",
|
|
3461
|
+
children: m(label)
|
|
3462
|
+
}
|
|
3463
|
+
),
|
|
3464
|
+
items.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "mt-1", children: items.map((medication) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3465
|
+
MedicationRow,
|
|
3466
|
+
{
|
|
3467
|
+
medication,
|
|
3468
|
+
actions,
|
|
3469
|
+
readOnly,
|
|
3470
|
+
drag,
|
|
3471
|
+
onMove: moveMedication,
|
|
3472
|
+
onStatusChange: handleStatusChange,
|
|
3473
|
+
onAction
|
|
3474
|
+
},
|
|
3475
|
+
medication.id
|
|
3476
|
+
)) }) : medications.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground mt-2 text-sm", children: m(emptyMessage) }) : /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-muted-foreground mt-2 flex items-center gap-1.5 text-sm", children: [
|
|
3477
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunk7E46YDOT_cjs.Badge, { variant: "success", size: "sm", children: "\u2713" }),
|
|
3478
|
+
m(reconciledMessage)
|
|
3479
|
+
] })
|
|
3480
|
+
] }, status)),
|
|
3481
|
+
!readOnly && (addSearch || quickAddOptions?.length || onAddOther) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
3482
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-xs font-semibold tracking-wide uppercase", children: m("Add medication") }),
|
|
3483
|
+
addSearch,
|
|
3484
|
+
(quickAddOptions?.length || onAddOther) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [
|
|
3485
|
+
quickAddOptions?.map((name) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3486
|
+
chunkANMX7YDL_cjs.Button,
|
|
3487
|
+
{
|
|
3488
|
+
variant: "ghost",
|
|
3489
|
+
size: "sm",
|
|
3490
|
+
onClick: () => onQuickAdd?.(name),
|
|
3491
|
+
leftIcon: /* @__PURE__ */ jsxRuntime.jsx(chunkL7L5S2HO_cjs.Plus, { size: 12 }),
|
|
3492
|
+
className: "border-border h-auto rounded-full border px-2.5 py-1 text-xs",
|
|
3493
|
+
children: name
|
|
3494
|
+
},
|
|
3495
|
+
name
|
|
3496
|
+
)),
|
|
3497
|
+
onAddOther && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3498
|
+
chunkANMX7YDL_cjs.Button,
|
|
3499
|
+
{
|
|
3500
|
+
variant: "outline",
|
|
3501
|
+
size: "sm",
|
|
3502
|
+
onClick: onAddOther,
|
|
3503
|
+
leftIcon: /* @__PURE__ */ jsxRuntime.jsx(chunkL7L5S2HO_cjs.Plus, { size: 12 }),
|
|
3504
|
+
className: "h-auto rounded-full px-2.5 py-1 text-xs",
|
|
3505
|
+
children: m("Other\u2026")
|
|
3506
|
+
}
|
|
3507
|
+
)
|
|
3508
|
+
] })
|
|
3509
|
+
] })
|
|
3510
|
+
] }),
|
|
3511
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { "aria-live": "polite", className: "sr-only", children: announcement })
|
|
3512
|
+
]
|
|
3513
|
+
}
|
|
3514
|
+
);
|
|
3515
|
+
}
|
|
3516
|
+
);
|
|
3517
|
+
MedicationList.displayName = "MedicationList";
|
|
3518
|
+
var DOSE_FORMS = [
|
|
3519
|
+
"tablet",
|
|
3520
|
+
"capsule",
|
|
3521
|
+
"solution",
|
|
3522
|
+
"suspension",
|
|
3523
|
+
"syrup",
|
|
3524
|
+
"cream",
|
|
3525
|
+
"ointment",
|
|
3526
|
+
"gel",
|
|
3527
|
+
"patch",
|
|
3528
|
+
"suppository",
|
|
3529
|
+
"spray",
|
|
3530
|
+
"drops",
|
|
3531
|
+
"inhaler",
|
|
3532
|
+
"injection",
|
|
3533
|
+
"lozenge",
|
|
3534
|
+
"powder",
|
|
3535
|
+
"film"
|
|
3536
|
+
];
|
|
3537
|
+
var FORM_TO_UNIT = {
|
|
3538
|
+
tablet: "tablet",
|
|
3539
|
+
capsule: "capsule",
|
|
3540
|
+
solution: "milliliter",
|
|
3541
|
+
suspension: "milliliter",
|
|
3542
|
+
syrup: "milliliter",
|
|
3543
|
+
cream: "gram",
|
|
3544
|
+
ointment: "gram",
|
|
3545
|
+
gel: "gram",
|
|
3546
|
+
patch: "patch",
|
|
3547
|
+
suppository: "suppository",
|
|
3548
|
+
spray: "spray",
|
|
3549
|
+
drops: "milliliter",
|
|
3550
|
+
inhaler: "each",
|
|
3551
|
+
injection: "milliliter",
|
|
3552
|
+
lozenge: "each",
|
|
3553
|
+
powder: "gram",
|
|
3554
|
+
film: "each"
|
|
3555
|
+
};
|
|
3556
|
+
function doseFormToQuantityUnit(doseForm) {
|
|
3557
|
+
const normalized = doseForm.toLowerCase().trim();
|
|
3558
|
+
return (FORM_TO_UNIT[normalized] ?? normalized) || void 0;
|
|
3559
|
+
}
|
|
3560
|
+
function parseMedicationLabel(label) {
|
|
3561
|
+
const lower = label.toLowerCase();
|
|
3562
|
+
const strengthMatch = lower.match(
|
|
3563
|
+
/(\d{1,7}(?:\.\d{1,4})?(?:\s{0,4}\/\s{0,4}\d{1,7}(?:\.\d{1,4})?)?)\s{0,4}(mg\/ml|mcg\/ml|mg|mcg|g|ml|units?|%|meq)\b/
|
|
3564
|
+
);
|
|
3565
|
+
const doseForm = DOSE_FORMS.find((f) => lower.includes(f));
|
|
3566
|
+
return {
|
|
3567
|
+
strength: strengthMatch ? `${strengthMatch[1].replace(/\s+/g, "")} ${strengthMatch[2]}` : void 0,
|
|
3568
|
+
doseForm
|
|
3569
|
+
};
|
|
3570
|
+
}
|
|
3571
|
+
var SIG_ROUTES = [
|
|
3572
|
+
[/\bby mouth\b|\boral(ly)?\b|\bpo\b/, "oral"],
|
|
3573
|
+
[/\bsublingual(ly)?\b|\bunder the tongue\b|\bsl\b/, "sublingual"],
|
|
3574
|
+
[/\bsubcutaneous(ly)?\b|\bsubq\b|\bsc\b|\bsq\b/, "subcutaneous"],
|
|
3575
|
+
[/\bintramuscular(ly)?\b|\bim\b/, "intramuscular"],
|
|
3576
|
+
[/\bintravenous(ly)?\b|\biv\b/, "intravenous"],
|
|
3577
|
+
[/\binhal(e|ation|ed)\b|\bpuffs?\b|\bnebuliz/, "inhalation"],
|
|
3578
|
+
[/\beyes?\b|\bophthalmic\b/, "ophthalmic"],
|
|
3579
|
+
[/\bears?\b|\botic\b/, "otic"],
|
|
3580
|
+
[/\bnostrils?\b|\bnasal(ly)?\b|\bintranasal/, "nasal"],
|
|
3581
|
+
[/\brectal(ly)?\b|\bpr\b/, "rectal"],
|
|
3582
|
+
[/\btransdermal\b|\bto (the )?skin\b|\bapply\b|\btopical(ly)?\b/, "topical"]
|
|
3583
|
+
];
|
|
3584
|
+
var SIG_FREQUENCIES = [
|
|
3585
|
+
[/\bevery other day\b|\bqod\b/, "Every other day"],
|
|
3586
|
+
[/\btwice (a |per )?day\b|\btwice daily\b|\bbid\b/, "Twice daily"],
|
|
3587
|
+
[
|
|
3588
|
+
/\b(three times|3 times)( a| per)? day\b|\b(three times|3 times) daily\b|\btid\b/,
|
|
3589
|
+
"Three times daily"
|
|
3590
|
+
],
|
|
3591
|
+
[
|
|
3592
|
+
/\b(four times|4 times)( a| per)? day\b|\b(four times|4 times) daily\b|\bqid\b/,
|
|
3593
|
+
"Four times daily"
|
|
3594
|
+
],
|
|
3595
|
+
[/\bevery morning\b|\bqam\b/, "Every morning"],
|
|
3596
|
+
[/\b(at )?bedtime\b|\bqhs\b|\bat night\b/, "Every bedtime"],
|
|
3597
|
+
[/\bweekly\b|\bonce a week\b|\bevery week\b/, "Weekly"],
|
|
3598
|
+
[
|
|
3599
|
+
/\bonce (a |per )?day\b|\bonce daily\b|\bdaily\b|\bevery day\b|\bqd\b/,
|
|
3600
|
+
"Once daily"
|
|
3601
|
+
]
|
|
3602
|
+
];
|
|
3603
|
+
function parseSig(sig) {
|
|
3604
|
+
const lower = sig.toLowerCase();
|
|
3605
|
+
const route = SIG_ROUTES.find(([re]) => re.test(lower))?.[1];
|
|
3606
|
+
const frequency = SIG_FREQUENCIES.find(([re]) => re.test(lower))?.[1];
|
|
3607
|
+
const prn = /\bas needed\b|\bprn\b/.test(lower);
|
|
3608
|
+
return { route, frequency, prn };
|
|
3609
|
+
}
|
|
3610
|
+
function labelToMedicationFields(label) {
|
|
3611
|
+
const { strength, doseForm } = parseMedicationLabel(label);
|
|
3612
|
+
return {
|
|
3613
|
+
...strength && { strength },
|
|
3614
|
+
...doseForm && {
|
|
3615
|
+
doseForm,
|
|
3616
|
+
quantityUnit: doseFormToQuantityUnit(doseForm)
|
|
3617
|
+
}
|
|
3618
|
+
};
|
|
3619
|
+
}
|
|
3620
|
+
function lookupToMedicationFields(result) {
|
|
3621
|
+
return {
|
|
3622
|
+
name: result.label,
|
|
3623
|
+
code: {
|
|
3624
|
+
system: result.codetype,
|
|
3625
|
+
code: result.fullcode,
|
|
3626
|
+
display: result.label
|
|
3627
|
+
},
|
|
3628
|
+
...labelToMedicationFields(result.label)
|
|
3629
|
+
};
|
|
3630
|
+
}
|
|
3631
|
+
function newId2() {
|
|
3632
|
+
return `med-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
3633
|
+
}
|
|
3634
|
+
function MedicationEditor({
|
|
3635
|
+
open,
|
|
3636
|
+
medication,
|
|
3637
|
+
codeLookup,
|
|
3638
|
+
requireCode = false,
|
|
3639
|
+
onClose,
|
|
3640
|
+
onSave
|
|
3641
|
+
}) {
|
|
3642
|
+
const m = chunkFSLI5IKP_cjs.useMessages();
|
|
3643
|
+
const ambientCodeLookup = useCodeLookupConfig();
|
|
3644
|
+
const effectiveCodeLookup = codeLookup === false ? void 0 : codeLookup ?? ambientCodeLookup ?? void 0;
|
|
3645
|
+
const [draft, setDraft] = React4__namespace.useState(
|
|
3646
|
+
() => medication ?? {
|
|
3647
|
+
id: newId2(),
|
|
3648
|
+
name: "",
|
|
3649
|
+
status: "unreconciled"
|
|
3650
|
+
}
|
|
3651
|
+
);
|
|
3652
|
+
const bodyRef = React4__namespace.useRef(null);
|
|
3653
|
+
React4__namespace.useEffect(() => {
|
|
3654
|
+
const input = bodyRef.current?.querySelector("input");
|
|
3655
|
+
input?.focus();
|
|
3656
|
+
}, []);
|
|
3657
|
+
const patch = (p) => setDraft((prev) => ({ ...prev, ...p }));
|
|
3658
|
+
const handleCodeSelect = (result) => {
|
|
3659
|
+
if (requireCode && (!result.codetype.trim() || !result.fullcode.trim()))
|
|
3660
|
+
return;
|
|
3661
|
+
patch(lookupToMedicationFields(result));
|
|
3662
|
+
};
|
|
3663
|
+
const handleSigChange = (sig) => {
|
|
3664
|
+
const { route, frequency, prn } = parseSig(sig);
|
|
3665
|
+
patch({ sig, route, frequency, prn: prn || void 0 });
|
|
3666
|
+
};
|
|
3667
|
+
const hasCode = Boolean(draft.code?.system.trim() && draft.code.code.trim());
|
|
3668
|
+
const unchangedLegacyName = medication && !medication.code && draft.name === medication.name;
|
|
3669
|
+
const canSave = draft.name.trim().length > 0 && (!requireCode || hasCode || Boolean(unchangedLegacyName));
|
|
3670
|
+
if (!open) return null;
|
|
3671
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(chunkLC3JL2HB_cjs.Modal, { open: true, onOpenChange: (o) => !o && onClose(), size: "lg", children: [
|
|
3672
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkLC3JL2HB_cjs.ModalHeader, { children: [
|
|
3673
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkLC3JL2HB_cjs.ModalTitle, { children: medication ? m("Correct Medication") : m("Add Medication") }),
|
|
3674
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkLC3JL2HB_cjs.ModalClose, { "aria-label": m("Close") })
|
|
3675
|
+
] }),
|
|
3676
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkLC3JL2HB_cjs.ModalBody, { className: "space-y-5", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: bodyRef, className: "contents", children: [
|
|
3677
|
+
/* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-3", "aria-label": m("Medication"), children: [
|
|
3678
|
+
effectiveCodeLookup ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
3679
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "med-search", children: m("Medication") }),
|
|
3680
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3681
|
+
effectiveCodeLookup.component,
|
|
3682
|
+
{
|
|
3683
|
+
indexUrl: effectiveCodeLookup.indexUrl,
|
|
3684
|
+
locale: effectiveCodeLookup.locale,
|
|
3685
|
+
domains: ["med"],
|
|
3686
|
+
bare: true,
|
|
3687
|
+
clearOnSelect: false,
|
|
3688
|
+
placeholder: m("Search RxNorm / FDB \u2014 e.g. lisinopril"),
|
|
3689
|
+
initialQuery: medication?.name || void 0,
|
|
3690
|
+
initialSearch: medication ? !medication.code : void 0,
|
|
3691
|
+
onSelect: handleCodeSelect,
|
|
3692
|
+
onFreeText: requireCode ? void 0 : (text) => patch({ name: text, code: void 0 })
|
|
3693
|
+
}
|
|
3694
|
+
),
|
|
3695
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-xs", children: draft.code ? m("Coded: {system} {code}", {
|
|
3696
|
+
system: draft.code.system,
|
|
3697
|
+
code: draft.code.code
|
|
3698
|
+
}) : draft.name ? m(
|
|
3699
|
+
'Uncoded free text: "{name}" \u2014 pick a result to code it',
|
|
3700
|
+
{ name: draft.name }
|
|
3701
|
+
) : requireCode ? m("Pick a catalog result to code the medication") : m(
|
|
3702
|
+
"Pick a result to code the medication, or press Enter for free text"
|
|
3703
|
+
) })
|
|
3704
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
3705
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "med-name", children: m("Medication") }),
|
|
3706
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3707
|
+
chunkZ5S5JEJD_cjs.Input,
|
|
3708
|
+
{
|
|
3709
|
+
id: "med-name",
|
|
3710
|
+
value: draft.name,
|
|
3711
|
+
readOnly: requireCode,
|
|
3712
|
+
onChange: (e) => patch({ name: e.target.value, code: void 0 })
|
|
3713
|
+
}
|
|
3714
|
+
)
|
|
3715
|
+
] }),
|
|
3716
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
3717
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
3718
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "med-strength", children: m("Strength") }),
|
|
3719
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3720
|
+
chunkZ5S5JEJD_cjs.Input,
|
|
3721
|
+
{
|
|
3722
|
+
id: "med-strength",
|
|
3723
|
+
value: draft.strength ?? "",
|
|
3724
|
+
onChange: (e) => patch({ strength: e.target.value })
|
|
3725
|
+
}
|
|
3726
|
+
)
|
|
3727
|
+
] }),
|
|
3728
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
3729
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "med-form", children: m("Dose form") }),
|
|
3730
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3731
|
+
chunkZ5S5JEJD_cjs.Input,
|
|
3732
|
+
{
|
|
3733
|
+
id: "med-form",
|
|
3734
|
+
value: draft.doseForm ?? "",
|
|
3735
|
+
onChange: (e) => {
|
|
3736
|
+
const doseForm = e.target.value;
|
|
3737
|
+
patch({
|
|
3738
|
+
doseForm,
|
|
3739
|
+
quantityUnit: doseFormToQuantityUnit(doseForm)
|
|
3740
|
+
});
|
|
3741
|
+
}
|
|
3742
|
+
}
|
|
3743
|
+
)
|
|
3744
|
+
] })
|
|
3745
|
+
] })
|
|
3746
|
+
] }),
|
|
3747
|
+
/* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-3", "aria-label": m("Dispensing"), children: [
|
|
3748
|
+
/* @__PURE__ */ jsxRuntime.jsx("h4", { className: "text-muted-foreground text-xs font-semibold tracking-wide uppercase", children: m("Dispensing") }),
|
|
3749
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-3 gap-3", children: [
|
|
3750
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
3751
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkAIJAFPGJ_cjs.Label, { htmlFor: "med-qty", children: [
|
|
3752
|
+
m("Quantity"),
|
|
3753
|
+
draft.quantityUnit ? ` (${draft.quantityUnit}s)` : ""
|
|
3754
|
+
] }),
|
|
3755
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3756
|
+
chunkZ5S5JEJD_cjs.Input,
|
|
3757
|
+
{
|
|
3758
|
+
id: "med-qty",
|
|
3759
|
+
inputMode: "decimal",
|
|
3760
|
+
value: draft.quantity ?? "",
|
|
3761
|
+
onChange: (e) => patch({ quantity: e.target.value })
|
|
3762
|
+
}
|
|
3763
|
+
)
|
|
3764
|
+
] }),
|
|
3765
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
3766
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "med-days", children: m("Days supply") }),
|
|
3767
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3768
|
+
chunkZ5S5JEJD_cjs.Input,
|
|
3769
|
+
{
|
|
3770
|
+
id: "med-days",
|
|
3771
|
+
inputMode: "numeric",
|
|
3772
|
+
value: draft.daysSupply ?? "",
|
|
3773
|
+
onChange: (e) => patch({ daysSupply: e.target.value })
|
|
3774
|
+
}
|
|
3775
|
+
)
|
|
3776
|
+
] }),
|
|
3777
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
3778
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "med-refills", children: m("Refills") }),
|
|
3779
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3780
|
+
chunkZ5S5JEJD_cjs.Input,
|
|
3781
|
+
{
|
|
3782
|
+
id: "med-refills",
|
|
3783
|
+
inputMode: "numeric",
|
|
3784
|
+
value: draft.refills ?? "",
|
|
3785
|
+
onChange: (e) => patch({ refills: e.target.value })
|
|
3786
|
+
}
|
|
3787
|
+
)
|
|
3788
|
+
] })
|
|
3789
|
+
] }),
|
|
3790
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3791
|
+
chunkG7EQ3JPX_cjs.RadioGroup,
|
|
3792
|
+
{
|
|
3793
|
+
name: "med-substitution",
|
|
3794
|
+
label: m("Substitution"),
|
|
3795
|
+
value: draft.substitution ?? "0",
|
|
3796
|
+
onValueChange: (v) => patch({ substitution: v }),
|
|
3797
|
+
orientation: "horizontal",
|
|
3798
|
+
size: "sm",
|
|
3799
|
+
children: [
|
|
3800
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkG7EQ3JPX_cjs.Radio, { value: "0", label: m("Substitution permitted") }),
|
|
3801
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkG7EQ3JPX_cjs.Radio, { value: "1", label: m("Dispense as written (DAW)") })
|
|
3802
|
+
]
|
|
3803
|
+
}
|
|
3804
|
+
)
|
|
3805
|
+
] }),
|
|
3806
|
+
/* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-3", "aria-label": m("Directions"), children: [
|
|
3807
|
+
/* @__PURE__ */ jsxRuntime.jsx("h4", { className: "text-muted-foreground text-xs font-semibold tracking-wide uppercase", children: m("Directions") }),
|
|
3808
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
3809
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "med-sig", children: m("Sig (patient directions)") }),
|
|
3810
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3811
|
+
chunkXQHDQ64G_cjs.Textarea,
|
|
3812
|
+
{
|
|
3813
|
+
id: "med-sig",
|
|
3814
|
+
value: draft.sig ?? "",
|
|
3815
|
+
onChange: (e) => handleSigChange(e.target.value),
|
|
3816
|
+
rows: 2
|
|
3817
|
+
}
|
|
3818
|
+
),
|
|
3819
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-xs", "aria-live": "polite", children: draft.route || draft.frequency || draft.prn ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3820
|
+
m("Derived:"),
|
|
3821
|
+
" ",
|
|
3822
|
+
[
|
|
3823
|
+
draft.route && m("route {route}", { route: draft.route }),
|
|
3824
|
+
draft.frequency && m(draft.frequency.toLowerCase()),
|
|
3825
|
+
draft.prn && m("PRN (as needed)")
|
|
3826
|
+
].filter(Boolean).join(" \xB7 ")
|
|
3827
|
+
] }) : m("Route, frequency, and PRN are derived from the directions") })
|
|
3828
|
+
] })
|
|
3829
|
+
] }),
|
|
3830
|
+
/* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-3", "aria-label": m("Dates and context"), children: [
|
|
3831
|
+
/* @__PURE__ */ jsxRuntime.jsx("h4", { className: "text-muted-foreground text-xs font-semibold tracking-wide uppercase", children: m("Dates & context") }),
|
|
3832
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
3833
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
3834
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "med-start", children: m("Start date") }),
|
|
3835
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3836
|
+
chunkPHUTJKHL_cjs.DateInput,
|
|
3837
|
+
{
|
|
3838
|
+
id: "med-start",
|
|
3839
|
+
value: draft.startDate ?? "",
|
|
3840
|
+
onChange: (v) => patch({ startDate: v })
|
|
3841
|
+
}
|
|
3842
|
+
)
|
|
3843
|
+
] }),
|
|
3844
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
3845
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "med-end", children: m("End date") }),
|
|
3846
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3847
|
+
chunkPHUTJKHL_cjs.DateInput,
|
|
3848
|
+
{
|
|
3849
|
+
id: "med-end",
|
|
3850
|
+
value: draft.endDate ?? "",
|
|
3851
|
+
onChange: (v) => patch({ endDate: v })
|
|
3852
|
+
}
|
|
3853
|
+
)
|
|
3854
|
+
] })
|
|
3855
|
+
] }),
|
|
3856
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
3857
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "med-indication", children: m("Indication") }),
|
|
3858
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3859
|
+
chunkZ5S5JEJD_cjs.Input,
|
|
3860
|
+
{
|
|
3861
|
+
id: "med-indication",
|
|
3862
|
+
value: draft.indication ?? "",
|
|
3863
|
+
onChange: (e) => patch({ indication: e.target.value })
|
|
3864
|
+
}
|
|
3865
|
+
)
|
|
3866
|
+
] }),
|
|
3867
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
3868
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "med-pharmacy-notes", children: m("Pharmacy notes") }),
|
|
3869
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3870
|
+
chunkXQHDQ64G_cjs.Textarea,
|
|
3871
|
+
{
|
|
3872
|
+
id: "med-pharmacy-notes",
|
|
3873
|
+
value: draft.pharmacyNotes ?? "",
|
|
3874
|
+
onChange: (e) => patch({ pharmacyNotes: e.target.value }),
|
|
3875
|
+
rows: 2
|
|
3876
|
+
}
|
|
3877
|
+
)
|
|
3878
|
+
] })
|
|
3879
|
+
] })
|
|
3880
|
+
] }) }),
|
|
3881
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkLC3JL2HB_cjs.ModalFooter, { children: [
|
|
3882
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkANMX7YDL_cjs.Button, { variant: "secondary", onClick: onClose, children: m("Cancel") }),
|
|
3883
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3884
|
+
chunkANMX7YDL_cjs.Button,
|
|
3885
|
+
{
|
|
3886
|
+
onClick: () => {
|
|
3887
|
+
onSave({ ...draft, name: draft.name.trim() });
|
|
3888
|
+
onClose();
|
|
3889
|
+
},
|
|
3890
|
+
disabled: !canSave,
|
|
3891
|
+
children: m("Save")
|
|
3892
|
+
}
|
|
3893
|
+
)
|
|
3894
|
+
] })
|
|
3895
|
+
] });
|
|
3896
|
+
}
|
|
3897
|
+
var MANAGED_ACTIONS = [
|
|
3898
|
+
"correct",
|
|
3899
|
+
"add-task",
|
|
3900
|
+
"note",
|
|
3901
|
+
"remove"
|
|
3902
|
+
];
|
|
3903
|
+
function newId3() {
|
|
3904
|
+
return `med-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
3905
|
+
}
|
|
3906
|
+
function MedicationDialog({
|
|
3907
|
+
dialog,
|
|
3908
|
+
onClose,
|
|
3909
|
+
onSave
|
|
3910
|
+
}) {
|
|
3911
|
+
const m = chunkFSLI5IKP_cjs.useMessages();
|
|
3912
|
+
const [form, setForm] = React4__namespace.useState(
|
|
3913
|
+
() => dialog.kind === "note" ? { note: dialog.medication.note ?? "" } : { task: dialog.medication.task ?? "" }
|
|
3914
|
+
);
|
|
3915
|
+
const set = (key) => (e) => setForm((prev) => ({ ...prev, [key]: e.target.value }));
|
|
3916
|
+
const handleSave = () => {
|
|
3917
|
+
onSave(form);
|
|
3918
|
+
onClose();
|
|
3919
|
+
};
|
|
3920
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(chunkLC3JL2HB_cjs.Modal, { open: true, onOpenChange: (open) => !open && onClose(), size: "md", children: [
|
|
3921
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkLC3JL2HB_cjs.ModalHeader, { children: [
|
|
3922
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkLC3JL2HB_cjs.ModalTitle, { children: dialog.kind === "note" ? m("Medication Notes") : m("Add Task") }),
|
|
3923
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkLC3JL2HB_cjs.ModalClose, { "aria-label": m("Close") })
|
|
3924
|
+
] }),
|
|
3925
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkLC3JL2HB_cjs.ModalBody, { className: "space-y-4", children: [
|
|
3926
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground text-sm", children: dialog.medication.name }),
|
|
3927
|
+
dialog.kind === "note" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
3928
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "med-note", children: m("Note") }),
|
|
3929
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3930
|
+
chunkXQHDQ64G_cjs.Textarea,
|
|
3931
|
+
{
|
|
3932
|
+
id: "med-note",
|
|
3933
|
+
value: form.note,
|
|
3934
|
+
onChange: set("note"),
|
|
3935
|
+
rows: 4
|
|
3936
|
+
}
|
|
3937
|
+
)
|
|
3938
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
|
|
3939
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "med-task", children: m("Task") }),
|
|
3940
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3941
|
+
chunkXQHDQ64G_cjs.Textarea,
|
|
3942
|
+
{
|
|
3943
|
+
id: "med-task",
|
|
3944
|
+
value: form.task,
|
|
3945
|
+
onChange: set("task"),
|
|
3946
|
+
rows: 3,
|
|
3947
|
+
placeholder: m("Follow-up task for this medication")
|
|
3948
|
+
}
|
|
3949
|
+
)
|
|
3950
|
+
] })
|
|
3951
|
+
] }),
|
|
3952
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkLC3JL2HB_cjs.ModalFooter, { children: [
|
|
3953
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkANMX7YDL_cjs.Button, { variant: "secondary", onClick: onClose, children: m("Cancel") }),
|
|
3954
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkANMX7YDL_cjs.Button, { onClick: handleSave, children: m("Save") })
|
|
3955
|
+
] })
|
|
3956
|
+
] });
|
|
3957
|
+
}
|
|
3958
|
+
function MedicationReconciliation({
|
|
3959
|
+
medications: controlledMedications,
|
|
3960
|
+
defaultMedications,
|
|
3961
|
+
onChange,
|
|
3962
|
+
title = "Presenting medications",
|
|
3963
|
+
quickAddOptions,
|
|
3964
|
+
actions = MANAGED_ACTIONS,
|
|
3965
|
+
onAction,
|
|
3966
|
+
codeLookup,
|
|
3967
|
+
requireCode = false,
|
|
3968
|
+
inlineAddSearch = false,
|
|
3969
|
+
readOnly = false,
|
|
3970
|
+
reconciledMessage,
|
|
3971
|
+
emptyMessage,
|
|
3972
|
+
className,
|
|
3973
|
+
"data-testid": dataTestId
|
|
3974
|
+
}) {
|
|
3975
|
+
const m = chunkFSLI5IKP_cjs.useMessages();
|
|
3976
|
+
const isControlled = controlledMedications !== void 0;
|
|
3977
|
+
const [internal, setInternal] = React4__namespace.useState(
|
|
3978
|
+
defaultMedications ?? []
|
|
3979
|
+
);
|
|
3980
|
+
const medications = isControlled ? controlledMedications : internal;
|
|
3981
|
+
const ambientCodeLookup = useCodeLookupConfig();
|
|
3982
|
+
const effectiveCodeLookup = codeLookup === false ? void 0 : codeLookup ?? ambientCodeLookup ?? void 0;
|
|
3983
|
+
const [dialog, setDialog] = React4__namespace.useState(null);
|
|
3984
|
+
const commit = (next) => {
|
|
3985
|
+
if (!isControlled) setInternal(next);
|
|
3986
|
+
onChange?.(next);
|
|
3987
|
+
};
|
|
3988
|
+
const patchMedication = (id, patch) => {
|
|
3989
|
+
commit(medications.map((m2) => m2.id === id ? { ...m2, ...patch } : m2));
|
|
3990
|
+
};
|
|
3991
|
+
const moveMedication = (med, direction) => {
|
|
3992
|
+
const meds = [...medications];
|
|
3993
|
+
const group = meds.filter((m2) => m2.status === med.status);
|
|
3994
|
+
const groupIndex = group.findIndex((m2) => m2.id === med.id);
|
|
3995
|
+
const swapWith = group[groupIndex + direction];
|
|
3996
|
+
if (!swapWith) return;
|
|
3997
|
+
const i = meds.findIndex((m2) => m2.id === med.id);
|
|
3998
|
+
const j = meds.findIndex((m2) => m2.id === swapWith.id);
|
|
3999
|
+
[meds[i], meds[j]] = [meds[j], meds[i]];
|
|
4000
|
+
commit(meds);
|
|
4001
|
+
};
|
|
4002
|
+
const handleAction = (med, action) => {
|
|
4003
|
+
switch (action) {
|
|
4004
|
+
case "remove":
|
|
4005
|
+
commit(medications.filter((m2) => m2.id !== med.id));
|
|
4006
|
+
break;
|
|
4007
|
+
case "move-up":
|
|
4008
|
+
moveMedication(med, -1);
|
|
4009
|
+
break;
|
|
4010
|
+
case "move-down":
|
|
4011
|
+
moveMedication(med, 1);
|
|
4012
|
+
break;
|
|
4013
|
+
case "correct":
|
|
4014
|
+
case "note":
|
|
4015
|
+
case "add-task":
|
|
4016
|
+
setDialog({ kind: action, medication: med });
|
|
4017
|
+
break;
|
|
4018
|
+
default:
|
|
4019
|
+
onAction?.(med, action);
|
|
4020
|
+
break;
|
|
4021
|
+
}
|
|
4022
|
+
};
|
|
4023
|
+
const addMedication = (name, sig) => {
|
|
4024
|
+
commit([
|
|
4025
|
+
...medications,
|
|
4026
|
+
{ id: newId3(), name, sig: void 0, status: "unreconciled" }
|
|
4027
|
+
]);
|
|
4028
|
+
};
|
|
4029
|
+
const handleDialogSave = (form) => {
|
|
4030
|
+
if (!dialog) return;
|
|
4031
|
+
switch (dialog.kind) {
|
|
4032
|
+
case "note":
|
|
4033
|
+
patchMedication(dialog.medication.id, {
|
|
4034
|
+
note: form.note.trim() || void 0
|
|
4035
|
+
});
|
|
4036
|
+
break;
|
|
4037
|
+
case "add-task":
|
|
4038
|
+
patchMedication(dialog.medication.id, {
|
|
4039
|
+
task: form.task.trim() || void 0
|
|
4040
|
+
});
|
|
4041
|
+
break;
|
|
4042
|
+
}
|
|
4043
|
+
};
|
|
4044
|
+
const editorOpen = dialog?.kind === "correct" || dialog?.kind === "add";
|
|
4045
|
+
const editorTarget = dialog?.kind === "correct" ? dialog.medication : void 0;
|
|
4046
|
+
const handleEditorSave = (med) => {
|
|
4047
|
+
if (dialog?.kind === "correct") {
|
|
4048
|
+
commit(medications.map((m2) => m2.id === med.id ? med : m2));
|
|
4049
|
+
} else {
|
|
4050
|
+
commit([...medications, { ...med, status: "unreconciled" }]);
|
|
4051
|
+
}
|
|
4052
|
+
};
|
|
4053
|
+
const addSearch = inlineAddSearch && effectiveCodeLookup && !readOnly ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4054
|
+
effectiveCodeLookup.component,
|
|
4055
|
+
{
|
|
4056
|
+
indexUrl: effectiveCodeLookup.indexUrl,
|
|
4057
|
+
locale: effectiveCodeLookup.locale,
|
|
4058
|
+
domains: ["med"],
|
|
4059
|
+
bare: true,
|
|
4060
|
+
clearOnSelect: true,
|
|
4061
|
+
placeholder: m("Search medications to add"),
|
|
4062
|
+
onSelect: (result) => {
|
|
4063
|
+
if (requireCode && (!result.codetype.trim() || !result.fullcode.trim()))
|
|
4064
|
+
return;
|
|
4065
|
+
commit([
|
|
4066
|
+
...medications,
|
|
4067
|
+
{
|
|
4068
|
+
id: newId3(),
|
|
4069
|
+
name: result.label,
|
|
4070
|
+
status: "unreconciled",
|
|
4071
|
+
...lookupToMedicationFields(result)
|
|
4072
|
+
}
|
|
4073
|
+
]);
|
|
4074
|
+
},
|
|
4075
|
+
onFreeText: requireCode ? void 0 : (text) => addMedication(text)
|
|
4076
|
+
}
|
|
4077
|
+
) : void 0;
|
|
4078
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4079
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4080
|
+
MedicationList,
|
|
4081
|
+
{
|
|
4082
|
+
medications,
|
|
4083
|
+
title,
|
|
4084
|
+
readOnly,
|
|
4085
|
+
actions,
|
|
4086
|
+
onStatusChange: (med, status) => patchMedication(med.id, { status }),
|
|
4087
|
+
onAction: handleAction,
|
|
4088
|
+
onReorder: (ids) => commit(
|
|
4089
|
+
[...medications].sort(
|
|
4090
|
+
(a, b) => ids.indexOf(a.id) - ids.indexOf(b.id)
|
|
4091
|
+
)
|
|
4092
|
+
),
|
|
4093
|
+
quickAddOptions: requireCode ? void 0 : quickAddOptions,
|
|
4094
|
+
onQuickAdd: (name) => addMedication(name),
|
|
4095
|
+
onAddOther: requireCode && !effectiveCodeLookup ? void 0 : () => setDialog({ kind: "add" }),
|
|
4096
|
+
addSearch,
|
|
4097
|
+
reconciledMessage,
|
|
4098
|
+
emptyMessage,
|
|
4099
|
+
className,
|
|
4100
|
+
"data-testid": dataTestId
|
|
4101
|
+
}
|
|
4102
|
+
),
|
|
4103
|
+
dialog && (dialog.kind === "note" || dialog.kind === "add-task") && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4104
|
+
MedicationDialog,
|
|
4105
|
+
{
|
|
4106
|
+
dialog,
|
|
4107
|
+
onClose: () => setDialog(null),
|
|
4108
|
+
onSave: handleDialogSave
|
|
4109
|
+
},
|
|
4110
|
+
dialog.kind + dialog.medication.id
|
|
4111
|
+
),
|
|
4112
|
+
editorOpen && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4113
|
+
MedicationEditor,
|
|
4114
|
+
{
|
|
4115
|
+
open: true,
|
|
4116
|
+
medication: editorTarget,
|
|
4117
|
+
codeLookup: codeLookup === false ? false : effectiveCodeLookup,
|
|
4118
|
+
requireCode,
|
|
4119
|
+
onClose: () => setDialog(null),
|
|
4120
|
+
onSave: handleEditorSave
|
|
4121
|
+
},
|
|
4122
|
+
editorTarget?.id ?? "add"
|
|
4123
|
+
)
|
|
4124
|
+
] });
|
|
4125
|
+
}
|
|
4126
|
+
|
|
4127
|
+
exports.ALLERGY_TYPE_LABELS = ALLERGY_TYPE_LABELS;
|
|
4128
|
+
exports.AllergyList = AllergyList;
|
|
4129
|
+
exports.AllergyManager = AllergyManager;
|
|
4130
|
+
exports.Assessment = Assessment;
|
|
4131
|
+
exports.CodeLookupContext = CodeLookupContext;
|
|
4132
|
+
exports.CodeLookupProvider = CodeLookupProvider;
|
|
4133
|
+
exports.ConditionEditor = ConditionEditor;
|
|
4134
|
+
exports.DateRangeFilter = DateRangeFilter;
|
|
4135
|
+
exports.DateRangePicker = DateRangePicker;
|
|
4136
|
+
exports.MEDICATION_STATUS_LABELS = MEDICATION_STATUS_LABELS;
|
|
4137
|
+
exports.MedicationEditor = MedicationEditor;
|
|
4138
|
+
exports.MedicationList = MedicationList;
|
|
4139
|
+
exports.MedicationReconciliation = MedicationReconciliation;
|
|
4140
|
+
exports.ORDER_TYPE_META = ORDER_TYPE_META;
|
|
4141
|
+
exports.ORDER_TYPE_SEARCH_DOMAINS = ORDER_TYPE_SEARCH_DOMAINS;
|
|
4142
|
+
exports.calculateDateRange = calculateDateRange;
|
|
4143
|
+
exports.doseFormToQuantityUnit = doseFormToQuantityUnit;
|
|
4144
|
+
exports.getDefaultPresets = getDefaultPresets;
|
|
4145
|
+
exports.getExtendedPresets = getExtendedPresets;
|
|
4146
|
+
exports.isConditionCodetype = isConditionCodetype;
|
|
4147
|
+
exports.labelToMedicationFields = labelToMedicationFields;
|
|
4148
|
+
exports.lookupToMedicationFields = lookupToMedicationFields;
|
|
4149
|
+
exports.normalizeConditionCodingSystem = normalizeConditionCodingSystem;
|
|
4150
|
+
exports.orderTypeForCodetype = orderTypeForCodetype;
|
|
4151
|
+
exports.parseMedicationLabel = parseMedicationLabel;
|
|
4152
|
+
exports.parseSig = parseSig;
|
|
4153
|
+
exports.useCodeLookupConfig = useCodeLookupConfig;
|
|
4154
|
+
//# sourceMappingURL=chunk-Z2OOJGHL.cjs.map
|
|
4155
|
+
//# sourceMappingURL=chunk-Z2OOJGHL.cjs.map
|