formanitor 0.0.36 → 0.0.38

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/dist/index.mjs CHANGED
@@ -94,6 +94,13 @@ function validateForm(values, fields) {
94
94
  }
95
95
 
96
96
  // src/core/rules.ts
97
+ function tokenListContainsString(text, needle) {
98
+ if (typeof text !== "string") return false;
99
+ const want = String(needle).trim();
100
+ if (!want) return false;
101
+ const parts = text.split(",").map((p) => p.trim()).filter(Boolean);
102
+ return parts.includes(want);
103
+ }
97
104
  function evaluateCondition(value, condition) {
98
105
  switch (condition.op) {
99
106
  case "==":
@@ -112,7 +119,13 @@ function evaluateCondition(value, condition) {
112
119
  case "in":
113
120
  return Array.isArray(condition.value) && condition.value.includes(value);
114
121
  case "contains":
115
- return Array.isArray(value) && value.includes(condition.value);
122
+ if (Array.isArray(value)) {
123
+ return value.includes(condition.value);
124
+ }
125
+ if (typeof value === "string") {
126
+ return tokenListContainsString(value, condition.value);
127
+ }
128
+ return false;
116
129
  default:
117
130
  return false;
118
131
  }
@@ -232,8 +245,47 @@ var FormStore = class {
232
245
  values[field.id] = field.defaultValue;
233
246
  } else {
234
247
  if (field.type === "repeatable") values[field.id] = [];
235
- else if (field.type === "checkbox") values[field.id] = [];
248
+ else if (field.type === "checkbox" || field.type === "multiselect") values[field.id] = [];
236
249
  else if (field.type === "smart_textarea") values[field.id] = { text: "", extractedKeywords: [] };
250
+ else if (field.type === "suggestion_textarea" || field.type === "complaint_chips") values[field.id] = "";
251
+ else if (field.type === "lens_assessment")
252
+ values[field.id] = {
253
+ notes: "",
254
+ assessmentKey: void 0,
255
+ locs: {
256
+ OD: { NO: 0, NC: 0, C: 0, PSC: 0 },
257
+ OS: { NO: 0, NC: 0, C: 0, PSC: 0 }
258
+ }
259
+ };
260
+ else if (field.type === "functional_impairment_score")
261
+ values[field.id] = {
262
+ reading: 0,
263
+ nightDriving: 0,
264
+ glare: 0,
265
+ occupation: 0,
266
+ adl: 0
267
+ };
268
+ else if (field.type === "biometry_iol_workup")
269
+ values[field.id] = {
270
+ axialLengthOD: "",
271
+ axialLengthOS: "",
272
+ k1k2AxisOD: "",
273
+ k1k2AxisOS: "",
274
+ anteriorChamberDepthOD: "",
275
+ anteriorChamberDepthOS: "",
276
+ iolPowerOD: "",
277
+ iolPowerOS: "",
278
+ targetRefractionOD: "",
279
+ targetRefractionOS: "",
280
+ formula: "SRK/T",
281
+ method: "optical_biometry",
282
+ cornealTopoUploaded: false,
283
+ specularMicroscopyDone: false,
284
+ endothelialCount: ""
285
+ };
286
+ else if (field.type === "surgical_risk_flags")
287
+ values[field.id] = { OD: [], OS: [] };
288
+ else if (field.type === "toggle") values[field.id] = false;
237
289
  else values[field.id] = null;
238
290
  }
239
291
  });
@@ -3123,6 +3175,19 @@ var BEFORE_AFTER_NORMALIZATION_MAP = {
3123
3175
  AF: "AFTER FOOD",
3124
3176
  BF: "BEFORE FOOD"
3125
3177
  };
3178
+ var ROUTE_OPTIONS = [
3179
+ { label: "Select route", value: "" },
3180
+ { label: "Per Os", value: "Per Os" },
3181
+ { label: "Intravenous", value: "Intravenous" },
3182
+ { label: "Intramuscular", value: "Intramuscular" },
3183
+ { label: "Subcutaneous", value: "Subcutaneous" },
3184
+ { label: "Sublingual", value: "Sublingual" },
3185
+ { label: "Intranasal", value: "Intranasal" },
3186
+ { label: "Topical", value: "Topical" },
3187
+ { label: "Per Rectum", value: "Per Rectum" },
3188
+ { label: "Inhalation", value: "Inhalation" },
3189
+ { label: "ID Intradermal", value: "ID Intradermal" }
3190
+ ];
3126
3191
  function mapToMedication(result) {
3127
3192
  return {
3128
3193
  id: result.id,
@@ -3133,6 +3198,7 @@ function mapToMedication(result) {
3133
3198
  duration_value: "3",
3134
3199
  duration_unit: "days",
3135
3200
  before_after: "AFTER FOOD",
3201
+ route: "",
3136
3202
  morning: "0",
3137
3203
  afternoon: "0",
3138
3204
  night: "0",
@@ -3150,6 +3216,7 @@ function mapAIMedicationToMedication(ai) {
3150
3216
  duration_value: "3",
3151
3217
  duration_unit: "days",
3152
3218
  before_after: "AFTER FOOD",
3219
+ route: "",
3153
3220
  morning: "1",
3154
3221
  afternoon: "0",
3155
3222
  night: "1",
@@ -3166,6 +3233,7 @@ function createCustomMedication(name, customId) {
3166
3233
  duration_value: "3",
3167
3234
  duration_unit: "days",
3168
3235
  before_after: "AFTER FOOD",
3236
+ route: "",
3169
3237
  morning: "0",
3170
3238
  afternoon: "0",
3171
3239
  night: "0",
@@ -3199,6 +3267,7 @@ function mapFrequentItemToMedication(item) {
3199
3267
  duration_value,
3200
3268
  duration_unit,
3201
3269
  before_after,
3270
+ route: item.route ?? "",
3202
3271
  morning: item.morning ?? "0",
3203
3272
  afternoon: item.afternoon ?? "0",
3204
3273
  night: item.night ?? "0",
@@ -3266,7 +3335,9 @@ function MedicationCard({
3266
3335
  /* @__PURE__ */ jsx("option", { value: "as_needed", children: "As needed" }),
3267
3336
  /* @__PURE__ */ jsx("option", { value: "fort_night", children: "Fort night" }),
3268
3337
  /* @__PURE__ */ jsx("option", { value: "at_bed_time", children: "At Bed time" }),
3269
- /* @__PURE__ */ jsx("option", { value: "sos", children: "SOS only" })
3338
+ /* @__PURE__ */ jsx("option", { value: "sos", children: "SOS only" }),
3339
+ /* @__PURE__ */ jsx("option", { value: "biweekly", children: "Biweekly" }),
3340
+ /* @__PURE__ */ jsx("option", { value: "stat", children: "STAT" })
3270
3341
  ]
3271
3342
  }
3272
3343
  ),
@@ -3327,6 +3398,15 @@ function MedicationCard({
3327
3398
  onChange: (e) => set("before_after", e.target.value),
3328
3399
  children: BEFORE_AFTER_OPTIONS.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.label))
3329
3400
  }
3401
+ ),
3402
+ /* @__PURE__ */ jsx(
3403
+ "select",
3404
+ {
3405
+ className: "text-xs border border-border rounded px-2 py-1 bg-white shrink-0",
3406
+ value: med.route ?? "",
3407
+ onChange: (e) => set("route", e.target.value),
3408
+ children: ROUTE_OPTIONS.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value))
3409
+ }
3330
3410
  )
3331
3411
  ] }),
3332
3412
  /* @__PURE__ */ jsxs(
@@ -6037,6 +6117,12 @@ var tableCellClass = "border border-[#E0E0E0] px-1.5 py-1 text-center align-midd
6037
6117
  var selectClass = "w-full border border-[#D0D0D0] rounded-md bg-white px-2 py-1 text-xs focus-visible:outline-none focus-visible:ring-0";
6038
6118
  var numberInputClass = "w-full border border-[#D0D0D0] rounded-md bg-white px-2 py-1 text-xs text-right focus-visible:outline-none focus-visible:ring-0";
6039
6119
  var textInputClass = "w-full border border-[#D0D0D0] rounded-md bg-white px-2 py-1 text-xs focus-visible:outline-none focus-visible:ring-0";
6120
+ var refractionTableClass = "w-full table-fixed border-collapse text-xs";
6121
+ var refractionHeaderCellClass = "border border-[#E0E0E0] bg-[#F7F7F7] px-1 py-1 text-center font-semibold text-[11px]";
6122
+ var refractionDataCellClass = "border border-[#E0E0E0] p-0 text-center align-middle min-w-0";
6123
+ var refractionLabelCellClass = "border border-[#E0E0E0] px-2 py-1 text-left align-middle font-semibold whitespace-nowrap";
6124
+ var refractionInputClass = "h-7 w-full min-w-0 border-0 rounded-none bg-transparent px-1 py-0.5 text-xs text-right shadow-none ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 disabled:opacity-50";
6125
+ var refractionSelectClass = "box-border h-7 w-full min-w-0 max-w-full cursor-pointer border-0 rounded-none bg-transparent px-1 py-0.5 pr-6 text-xs shadow-none focus-visible:outline-none focus-visible:ring-0 disabled:opacity-50";
6040
6126
  var OphthalmologyWidget = ({ fieldId }) => {
6041
6127
  const { fieldDef, value, setValue, disabled } = useField(fieldId);
6042
6128
  const safe = useMemo(() => ensureValue(value), [value]);
@@ -6268,34 +6354,45 @@ var OphthalmologyWidget = ({ fieldId }) => {
6268
6354
  ] }),
6269
6355
  /* @__PURE__ */ jsxs("section", { className: sectionWrapperClass, children: [
6270
6356
  /* @__PURE__ */ jsx("div", { className: sectionHeaderClass, children: /* @__PURE__ */ jsx("span", { children: "Current Glass Prescription" }) }),
6271
- /* @__PURE__ */ jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxs("table", { className: tableBaseClass, children: [
6357
+ /* @__PURE__ */ jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxs("table", { className: refractionTableClass, children: [
6358
+ /* @__PURE__ */ jsxs("colgroup", { children: [
6359
+ /* @__PURE__ */ jsx("col", { className: "w-[10%]" }),
6360
+ /* @__PURE__ */ jsx("col", { className: "w-[7%]" }),
6361
+ /* @__PURE__ */ jsx("col", { className: "w-[7%]" }),
6362
+ /* @__PURE__ */ jsx("col", { className: "w-[6%]" }),
6363
+ /* @__PURE__ */ jsx("col", { className: "w-[25%]" }),
6364
+ /* @__PURE__ */ jsx("col", { className: "w-[7%]" }),
6365
+ /* @__PURE__ */ jsx("col", { className: "w-[7%]" }),
6366
+ /* @__PURE__ */ jsx("col", { className: "w-[6%]" }),
6367
+ /* @__PURE__ */ jsx("col", { className: "w-[25%]" })
6368
+ ] }),
6272
6369
  /* @__PURE__ */ jsxs("thead", { children: [
6273
6370
  /* @__PURE__ */ jsxs("tr", { children: [
6274
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass }),
6275
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, colSpan: 4, children: "Right Eye" }),
6276
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, colSpan: 4, children: "Left Eye" })
6371
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass }),
6372
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, colSpan: 4, children: "Right Eye" }),
6373
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, colSpan: 4, children: "Left Eye" })
6277
6374
  ] }),
6278
6375
  /* @__PURE__ */ jsxs("tr", { children: [
6279
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass }),
6280
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6281
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6282
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6283
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
6284
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6285
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6286
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6287
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "V/A" })
6376
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass }),
6377
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
6378
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
6379
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
6380
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "V/A" }),
6381
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
6382
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
6383
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
6384
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "V/A" })
6288
6385
  ] })
6289
6386
  ] }),
6290
6387
  /* @__PURE__ */ jsx("tbody", { children: /* @__PURE__ */ jsxs("tr", { children: [
6291
- /* @__PURE__ */ jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Current Glass" }),
6292
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6388
+ /* @__PURE__ */ jsx("td", { className: refractionLabelCellClass, children: "Current Glass" }),
6389
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6293
6390
  Input,
6294
6391
  {
6295
6392
  disabled,
6296
6393
  type: "number",
6297
6394
  step: "0.25",
6298
- className: numberInputClass,
6395
+ className: refractionInputClass,
6299
6396
  value: safe.current_glass_prescription.right_eye.sph ?? "",
6300
6397
  onChange: (e) => setRefractionField(
6301
6398
  "current_glass_prescription",
@@ -6306,13 +6403,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6306
6403
  )
6307
6404
  }
6308
6405
  ) }),
6309
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6406
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6310
6407
  Input,
6311
6408
  {
6312
6409
  disabled,
6313
6410
  type: "number",
6314
6411
  step: "0.25",
6315
- className: numberInputClass,
6412
+ className: refractionInputClass,
6316
6413
  value: safe.current_glass_prescription.right_eye.cyl ?? "",
6317
6414
  onChange: (e) => setRefractionField(
6318
6415
  "current_glass_prescription",
@@ -6323,12 +6420,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6323
6420
  )
6324
6421
  }
6325
6422
  ) }),
6326
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6423
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6327
6424
  Input,
6328
6425
  {
6329
6426
  disabled,
6330
6427
  type: "number",
6331
- className: numberInputClass,
6428
+ className: refractionInputClass,
6332
6429
  value: safe.current_glass_prescription.right_eye.axis ?? "",
6333
6430
  onChange: (e) => setRefractionField(
6334
6431
  "current_glass_prescription",
@@ -6339,11 +6436,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6339
6436
  )
6340
6437
  }
6341
6438
  ) }),
6342
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6439
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6343
6440
  "select",
6344
6441
  {
6345
6442
  disabled,
6346
- className: selectClass,
6443
+ className: refractionSelectClass,
6347
6444
  value: safe.current_glass_prescription.right_eye.va,
6348
6445
  onChange: (e) => setRefractionField(
6349
6446
  "current_glass_prescription",
@@ -6355,13 +6452,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6355
6452
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsx("option", { value: opt, children: opt }, opt || "blank"))
6356
6453
  }
6357
6454
  ) }),
6358
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6455
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6359
6456
  Input,
6360
6457
  {
6361
6458
  disabled,
6362
6459
  type: "number",
6363
6460
  step: "0.25",
6364
- className: numberInputClass,
6461
+ className: refractionInputClass,
6365
6462
  value: safe.current_glass_prescription.left_eye.sph ?? "",
6366
6463
  onChange: (e) => setRefractionField(
6367
6464
  "current_glass_prescription",
@@ -6372,13 +6469,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6372
6469
  )
6373
6470
  }
6374
6471
  ) }),
6375
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6472
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6376
6473
  Input,
6377
6474
  {
6378
6475
  disabled,
6379
6476
  type: "number",
6380
6477
  step: "0.25",
6381
- className: numberInputClass,
6478
+ className: refractionInputClass,
6382
6479
  value: safe.current_glass_prescription.left_eye.cyl ?? "",
6383
6480
  onChange: (e) => setRefractionField(
6384
6481
  "current_glass_prescription",
@@ -6389,12 +6486,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6389
6486
  )
6390
6487
  }
6391
6488
  ) }),
6392
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6489
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6393
6490
  Input,
6394
6491
  {
6395
6492
  disabled,
6396
6493
  type: "number",
6397
- className: numberInputClass,
6494
+ className: refractionInputClass,
6398
6495
  value: safe.current_glass_prescription.left_eye.axis ?? "",
6399
6496
  onChange: (e) => setRefractionField(
6400
6497
  "current_glass_prescription",
@@ -6405,11 +6502,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6405
6502
  )
6406
6503
  }
6407
6504
  ) }),
6408
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6505
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6409
6506
  "select",
6410
6507
  {
6411
6508
  disabled,
6412
- className: selectClass,
6509
+ className: refractionSelectClass,
6413
6510
  value: safe.current_glass_prescription.left_eye.va,
6414
6511
  onChange: (e) => setRefractionField(
6415
6512
  "current_glass_prescription",
@@ -6518,37 +6615,50 @@ var OphthalmologyWidget = ({ fieldId }) => {
6518
6615
  ] }),
6519
6616
  /* @__PURE__ */ jsxs("section", { className: sectionWrapperClass, children: [
6520
6617
  /* @__PURE__ */ jsx("div", { className: sectionHeaderClass, children: /* @__PURE__ */ jsx("span", { children: "Refraction (Distance)" }) }),
6521
- /* @__PURE__ */ jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxs("table", { className: tableBaseClass, children: [
6618
+ /* @__PURE__ */ jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxs("table", { className: refractionTableClass, children: [
6619
+ /* @__PURE__ */ jsxs("colgroup", { children: [
6620
+ /* @__PURE__ */ jsx("col", { className: "w-[10%]" }),
6621
+ /* @__PURE__ */ jsx("col", { className: "w-[7%]" }),
6622
+ /* @__PURE__ */ jsx("col", { className: "w-[7%]" }),
6623
+ /* @__PURE__ */ jsx("col", { className: "w-[6%]" }),
6624
+ /* @__PURE__ */ jsx("col", { className: "w-[13%]" }),
6625
+ /* @__PURE__ */ jsx("col", { className: "w-[12%]" }),
6626
+ /* @__PURE__ */ jsx("col", { className: "w-[7%]" }),
6627
+ /* @__PURE__ */ jsx("col", { className: "w-[7%]" }),
6628
+ /* @__PURE__ */ jsx("col", { className: "w-[6%]" }),
6629
+ /* @__PURE__ */ jsx("col", { className: "w-[13%]" }),
6630
+ /* @__PURE__ */ jsx("col", { className: "w-[12%]" })
6631
+ ] }),
6522
6632
  /* @__PURE__ */ jsxs("thead", { children: [
6523
6633
  /* @__PURE__ */ jsxs("tr", { children: [
6524
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass }),
6525
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Right Eye" }),
6526
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Left Eye" })
6634
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass }),
6635
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, colSpan: 5, children: "Right Eye" }),
6636
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, colSpan: 5, children: "Left Eye" })
6527
6637
  ] }),
6528
6638
  /* @__PURE__ */ jsxs("tr", { children: [
6529
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass }),
6530
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6531
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6532
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6533
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
6534
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "P/D" }),
6535
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6536
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6537
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6538
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
6539
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "P/D" })
6639
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass }),
6640
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
6641
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
6642
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
6643
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "V/A" }),
6644
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "P/D" }),
6645
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
6646
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
6647
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
6648
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "V/A" }),
6649
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "P/D" })
6540
6650
  ] })
6541
6651
  ] }),
6542
6652
  /* @__PURE__ */ jsxs("tbody", { children: [
6543
6653
  /* @__PURE__ */ jsxs("tr", { children: [
6544
- /* @__PURE__ */ jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Distance" }),
6545
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6654
+ /* @__PURE__ */ jsx("td", { className: refractionLabelCellClass, children: "Distance" }),
6655
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6546
6656
  Input,
6547
6657
  {
6548
6658
  disabled,
6549
6659
  type: "number",
6550
6660
  step: "0.25",
6551
- className: numberInputClass,
6661
+ className: refractionInputClass,
6552
6662
  value: safe.refraction.right_eye.sph ?? "",
6553
6663
  onChange: (e) => setRefractionField(
6554
6664
  "refraction",
@@ -6559,13 +6669,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6559
6669
  )
6560
6670
  }
6561
6671
  ) }),
6562
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6672
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6563
6673
  Input,
6564
6674
  {
6565
6675
  disabled,
6566
6676
  type: "number",
6567
6677
  step: "0.25",
6568
- className: numberInputClass,
6678
+ className: refractionInputClass,
6569
6679
  value: safe.refraction.right_eye.cyl ?? "",
6570
6680
  onChange: (e) => setRefractionField(
6571
6681
  "refraction",
@@ -6576,12 +6686,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6576
6686
  )
6577
6687
  }
6578
6688
  ) }),
6579
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6689
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6580
6690
  Input,
6581
6691
  {
6582
6692
  disabled,
6583
6693
  type: "number",
6584
- className: numberInputClass,
6694
+ className: refractionInputClass,
6585
6695
  value: safe.refraction.right_eye.axis ?? "",
6586
6696
  onChange: (e) => setRefractionField(
6587
6697
  "refraction",
@@ -6592,11 +6702,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6592
6702
  )
6593
6703
  }
6594
6704
  ) }),
6595
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6705
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6596
6706
  "select",
6597
6707
  {
6598
6708
  disabled,
6599
- className: selectClass,
6709
+ className: refractionSelectClass,
6600
6710
  value: safe.refraction.right_eye.va,
6601
6711
  onChange: (e) => setRefractionField(
6602
6712
  "refraction",
@@ -6608,7 +6718,7 @@ var OphthalmologyWidget = ({ fieldId }) => {
6608
6718
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsx("option", { value: opt, children: opt }, opt || "blank"))
6609
6719
  }
6610
6720
  ) }),
6611
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6721
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6612
6722
  Input,
6613
6723
  {
6614
6724
  disabled,
@@ -6616,18 +6726,18 @@ var OphthalmologyWidget = ({ fieldId }) => {
6616
6726
  min: 10,
6617
6727
  max: 45,
6618
6728
  step: "1",
6619
- className: numberInputClass,
6729
+ className: refractionInputClass,
6620
6730
  value: safe.refraction.right_eye.pd ?? "",
6621
6731
  onChange: (e) => setRefractionField("refraction", "right_eye", "pd", e.target.value, "int")
6622
6732
  }
6623
6733
  ) }),
6624
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6734
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6625
6735
  Input,
6626
6736
  {
6627
6737
  disabled,
6628
6738
  type: "number",
6629
6739
  step: "0.25",
6630
- className: numberInputClass,
6740
+ className: refractionInputClass,
6631
6741
  value: safe.refraction.left_eye.sph ?? "",
6632
6742
  onChange: (e) => setRefractionField(
6633
6743
  "refraction",
@@ -6638,13 +6748,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6638
6748
  )
6639
6749
  }
6640
6750
  ) }),
6641
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6751
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6642
6752
  Input,
6643
6753
  {
6644
6754
  disabled,
6645
6755
  type: "number",
6646
6756
  step: "0.25",
6647
- className: numberInputClass,
6757
+ className: refractionInputClass,
6648
6758
  value: safe.refraction.left_eye.cyl ?? "",
6649
6759
  onChange: (e) => setRefractionField(
6650
6760
  "refraction",
@@ -6655,12 +6765,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6655
6765
  )
6656
6766
  }
6657
6767
  ) }),
6658
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6768
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6659
6769
  Input,
6660
6770
  {
6661
6771
  disabled,
6662
6772
  type: "number",
6663
- className: numberInputClass,
6773
+ className: refractionInputClass,
6664
6774
  value: safe.refraction.left_eye.axis ?? "",
6665
6775
  onChange: (e) => setRefractionField(
6666
6776
  "refraction",
@@ -6671,11 +6781,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6671
6781
  )
6672
6782
  }
6673
6783
  ) }),
6674
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6784
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6675
6785
  "select",
6676
6786
  {
6677
6787
  disabled,
6678
- className: selectClass,
6788
+ className: refractionSelectClass,
6679
6789
  value: safe.refraction.left_eye.va,
6680
6790
  onChange: (e) => setRefractionField(
6681
6791
  "refraction",
@@ -6687,7 +6797,7 @@ var OphthalmologyWidget = ({ fieldId }) => {
6687
6797
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsx("option", { value: opt, children: opt }, opt || "blank"))
6688
6798
  }
6689
6799
  ) }),
6690
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6800
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6691
6801
  Input,
6692
6802
  {
6693
6803
  disabled,
@@ -6695,32 +6805,32 @@ var OphthalmologyWidget = ({ fieldId }) => {
6695
6805
  min: 10,
6696
6806
  max: 45,
6697
6807
  step: "1",
6698
- className: numberInputClass,
6808
+ className: refractionInputClass,
6699
6809
  value: safe.refraction.left_eye.pd ?? "",
6700
6810
  onChange: (e) => setRefractionField("refraction", "left_eye", "pd", e.target.value, "int")
6701
6811
  }
6702
6812
  ) })
6703
6813
  ] }),
6704
6814
  /* @__PURE__ */ jsxs("tr", { children: [
6705
- /* @__PURE__ */ jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Add" }),
6706
- /* @__PURE__ */ jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsx(
6815
+ /* @__PURE__ */ jsx("td", { className: refractionLabelCellClass, children: "Add" }),
6816
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsx(
6707
6817
  Input,
6708
6818
  {
6709
6819
  disabled,
6710
6820
  type: "number",
6711
6821
  step: "0.25",
6712
- className: numberInputClass,
6822
+ className: refractionInputClass,
6713
6823
  value: safe.refraction.add.right ?? "",
6714
6824
  onChange: (e) => setRefractionAdd("refraction", "right", e.target.value)
6715
6825
  }
6716
6826
  ) }),
6717
- /* @__PURE__ */ jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsx(
6827
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsx(
6718
6828
  Input,
6719
6829
  {
6720
6830
  disabled,
6721
6831
  type: "number",
6722
6832
  step: "0.25",
6723
- className: numberInputClass,
6833
+ className: refractionInputClass,
6724
6834
  value: safe.refraction.add.left ?? "",
6725
6835
  onChange: (e) => setRefractionAdd("refraction", "left", e.target.value)
6726
6836
  }
@@ -6731,37 +6841,50 @@ var OphthalmologyWidget = ({ fieldId }) => {
6731
6841
  ] }),
6732
6842
  /* @__PURE__ */ jsxs("section", { className: sectionWrapperClass, children: [
6733
6843
  /* @__PURE__ */ jsx("div", { className: sectionHeaderClass, children: /* @__PURE__ */ jsx("span", { children: "Dilated Refraction" }) }),
6734
- /* @__PURE__ */ jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxs("table", { className: tableBaseClass, children: [
6844
+ /* @__PURE__ */ jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxs("table", { className: refractionTableClass, children: [
6845
+ /* @__PURE__ */ jsxs("colgroup", { children: [
6846
+ /* @__PURE__ */ jsx("col", { className: "w-[10%]" }),
6847
+ /* @__PURE__ */ jsx("col", { className: "w-[7%]" }),
6848
+ /* @__PURE__ */ jsx("col", { className: "w-[7%]" }),
6849
+ /* @__PURE__ */ jsx("col", { className: "w-[6%]" }),
6850
+ /* @__PURE__ */ jsx("col", { className: "w-[8%]" }),
6851
+ /* @__PURE__ */ jsx("col", { className: "w-[17%]" }),
6852
+ /* @__PURE__ */ jsx("col", { className: "w-[7%]" }),
6853
+ /* @__PURE__ */ jsx("col", { className: "w-[7%]" }),
6854
+ /* @__PURE__ */ jsx("col", { className: "w-[6%]" }),
6855
+ /* @__PURE__ */ jsx("col", { className: "w-[8%]" }),
6856
+ /* @__PURE__ */ jsx("col", { className: "w-[17%]" })
6857
+ ] }),
6735
6858
  /* @__PURE__ */ jsxs("thead", { children: [
6736
6859
  /* @__PURE__ */ jsxs("tr", { children: [
6737
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass }),
6738
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Right Eye" }),
6739
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Left Eye" })
6860
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass }),
6861
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, colSpan: 5, children: "Right Eye" }),
6862
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, colSpan: 5, children: "Left Eye" })
6740
6863
  ] }),
6741
6864
  /* @__PURE__ */ jsxs("tr", { children: [
6742
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass }),
6743
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6744
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6745
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6746
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Prism" }),
6747
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
6748
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6749
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6750
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6751
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Prism" }),
6752
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "V/A" })
6865
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass }),
6866
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
6867
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
6868
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
6869
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Prism" }),
6870
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "V/A" }),
6871
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
6872
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
6873
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
6874
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Prism" }),
6875
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "V/A" })
6753
6876
  ] })
6754
6877
  ] }),
6755
6878
  /* @__PURE__ */ jsxs("tbody", { children: [
6756
6879
  /* @__PURE__ */ jsxs("tr", { children: [
6757
- /* @__PURE__ */ jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Dilated" }),
6758
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6880
+ /* @__PURE__ */ jsx("td", { className: refractionLabelCellClass, children: "Dilated" }),
6881
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6759
6882
  Input,
6760
6883
  {
6761
6884
  disabled,
6762
6885
  type: "number",
6763
6886
  step: "0.25",
6764
- className: numberInputClass,
6887
+ className: refractionInputClass,
6765
6888
  value: safe.dilated_refraction.right_eye.sph ?? "",
6766
6889
  onChange: (e) => setRefractionField(
6767
6890
  "dilated_refraction",
@@ -6772,13 +6895,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6772
6895
  )
6773
6896
  }
6774
6897
  ) }),
6775
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6898
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6776
6899
  Input,
6777
6900
  {
6778
6901
  disabled,
6779
6902
  type: "number",
6780
6903
  step: "0.25",
6781
- className: numberInputClass,
6904
+ className: refractionInputClass,
6782
6905
  value: safe.dilated_refraction.right_eye.cyl ?? "",
6783
6906
  onChange: (e) => setRefractionField(
6784
6907
  "dilated_refraction",
@@ -6789,12 +6912,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6789
6912
  )
6790
6913
  }
6791
6914
  ) }),
6792
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6915
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6793
6916
  Input,
6794
6917
  {
6795
6918
  disabled,
6796
6919
  type: "number",
6797
- className: numberInputClass,
6920
+ className: refractionInputClass,
6798
6921
  value: safe.dilated_refraction.right_eye.axis ?? "",
6799
6922
  onChange: (e) => setRefractionField(
6800
6923
  "dilated_refraction",
@@ -6805,13 +6928,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6805
6928
  )
6806
6929
  }
6807
6930
  ) }),
6808
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6931
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6809
6932
  Input,
6810
6933
  {
6811
6934
  disabled,
6812
6935
  type: "number",
6813
6936
  step: "0.25",
6814
- className: numberInputClass,
6937
+ className: refractionInputClass,
6815
6938
  value: safe.dilated_refraction.right_eye.prism ?? "",
6816
6939
  onChange: (e) => setRefractionField(
6817
6940
  "dilated_refraction",
@@ -6822,11 +6945,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6822
6945
  )
6823
6946
  }
6824
6947
  ) }),
6825
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6948
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6826
6949
  "select",
6827
6950
  {
6828
6951
  disabled,
6829
- className: selectClass,
6952
+ className: refractionSelectClass,
6830
6953
  value: safe.dilated_refraction.right_eye.va,
6831
6954
  onChange: (e) => setRefractionField(
6832
6955
  "dilated_refraction",
@@ -6838,13 +6961,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6838
6961
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsx("option", { value: opt, children: opt }, opt || "blank"))
6839
6962
  }
6840
6963
  ) }),
6841
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6964
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6842
6965
  Input,
6843
6966
  {
6844
6967
  disabled,
6845
6968
  type: "number",
6846
6969
  step: "0.25",
6847
- className: numberInputClass,
6970
+ className: refractionInputClass,
6848
6971
  value: safe.dilated_refraction.left_eye.sph ?? "",
6849
6972
  onChange: (e) => setRefractionField(
6850
6973
  "dilated_refraction",
@@ -6855,13 +6978,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6855
6978
  )
6856
6979
  }
6857
6980
  ) }),
6858
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6981
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6859
6982
  Input,
6860
6983
  {
6861
6984
  disabled,
6862
6985
  type: "number",
6863
6986
  step: "0.25",
6864
- className: numberInputClass,
6987
+ className: refractionInputClass,
6865
6988
  value: safe.dilated_refraction.left_eye.cyl ?? "",
6866
6989
  onChange: (e) => setRefractionField(
6867
6990
  "dilated_refraction",
@@ -6872,12 +6995,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6872
6995
  )
6873
6996
  }
6874
6997
  ) }),
6875
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6998
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6876
6999
  Input,
6877
7000
  {
6878
7001
  disabled,
6879
7002
  type: "number",
6880
- className: numberInputClass,
7003
+ className: refractionInputClass,
6881
7004
  value: safe.dilated_refraction.left_eye.axis ?? "",
6882
7005
  onChange: (e) => setRefractionField(
6883
7006
  "dilated_refraction",
@@ -6888,13 +7011,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6888
7011
  )
6889
7012
  }
6890
7013
  ) }),
6891
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7014
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6892
7015
  Input,
6893
7016
  {
6894
7017
  disabled,
6895
7018
  type: "number",
6896
7019
  step: "0.25",
6897
- className: numberInputClass,
7020
+ className: refractionInputClass,
6898
7021
  value: safe.dilated_refraction.left_eye.prism ?? "",
6899
7022
  onChange: (e) => setRefractionField(
6900
7023
  "dilated_refraction",
@@ -6905,11 +7028,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6905
7028
  )
6906
7029
  }
6907
7030
  ) }),
6908
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7031
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6909
7032
  "select",
6910
7033
  {
6911
7034
  disabled,
6912
- className: selectClass,
7035
+ className: refractionSelectClass,
6913
7036
  value: safe.dilated_refraction.left_eye.va,
6914
7037
  onChange: (e) => setRefractionField(
6915
7038
  "dilated_refraction",
@@ -6923,25 +7046,25 @@ var OphthalmologyWidget = ({ fieldId }) => {
6923
7046
  ) })
6924
7047
  ] }),
6925
7048
  /* @__PURE__ */ jsxs("tr", { children: [
6926
- /* @__PURE__ */ jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Add" }),
6927
- /* @__PURE__ */ jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsx(
7049
+ /* @__PURE__ */ jsx("td", { className: refractionLabelCellClass, children: "Add" }),
7050
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsx(
6928
7051
  Input,
6929
7052
  {
6930
7053
  disabled,
6931
7054
  type: "number",
6932
7055
  step: "0.25",
6933
- className: numberInputClass,
7056
+ className: refractionInputClass,
6934
7057
  value: safe.dilated_refraction.add.right ?? "",
6935
7058
  onChange: (e) => setRefractionAdd("dilated_refraction", "right", e.target.value)
6936
7059
  }
6937
7060
  ) }),
6938
- /* @__PURE__ */ jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsx(
7061
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsx(
6939
7062
  Input,
6940
7063
  {
6941
7064
  disabled,
6942
7065
  type: "number",
6943
7066
  step: "0.25",
6944
- className: numberInputClass,
7067
+ className: refractionInputClass,
6945
7068
  value: safe.dilated_refraction.add.left ?? "",
6946
7069
  onChange: (e) => setRefractionAdd("dilated_refraction", "left", e.target.value)
6947
7070
  }
@@ -6952,37 +7075,50 @@ var OphthalmologyWidget = ({ fieldId }) => {
6952
7075
  ] }),
6953
7076
  /* @__PURE__ */ jsxs("section", { className: sectionWrapperClass, children: [
6954
7077
  /* @__PURE__ */ jsx("div", { className: sectionHeaderClass, children: /* @__PURE__ */ jsx("span", { children: "Glass Power Prescription" }) }),
6955
- /* @__PURE__ */ jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxs("table", { className: tableBaseClass, children: [
7078
+ /* @__PURE__ */ jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxs("table", { className: refractionTableClass, children: [
7079
+ /* @__PURE__ */ jsxs("colgroup", { children: [
7080
+ /* @__PURE__ */ jsx("col", { className: "w-[10%]" }),
7081
+ /* @__PURE__ */ jsx("col", { className: "w-[7%]" }),
7082
+ /* @__PURE__ */ jsx("col", { className: "w-[7%]" }),
7083
+ /* @__PURE__ */ jsx("col", { className: "w-[6%]" }),
7084
+ /* @__PURE__ */ jsx("col", { className: "w-[8%]" }),
7085
+ /* @__PURE__ */ jsx("col", { className: "w-[17%]" }),
7086
+ /* @__PURE__ */ jsx("col", { className: "w-[7%]" }),
7087
+ /* @__PURE__ */ jsx("col", { className: "w-[7%]" }),
7088
+ /* @__PURE__ */ jsx("col", { className: "w-[6%]" }),
7089
+ /* @__PURE__ */ jsx("col", { className: "w-[8%]" }),
7090
+ /* @__PURE__ */ jsx("col", { className: "w-[17%]" })
7091
+ ] }),
6956
7092
  /* @__PURE__ */ jsxs("thead", { children: [
6957
7093
  /* @__PURE__ */ jsxs("tr", { children: [
6958
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass }),
6959
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Right Eye" }),
6960
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Left Eye" })
7094
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass }),
7095
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, colSpan: 5, children: "Right Eye" }),
7096
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, colSpan: 5, children: "Left Eye" })
6961
7097
  ] }),
6962
7098
  /* @__PURE__ */ jsxs("tr", { children: [
6963
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass }),
6964
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6965
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6966
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6967
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Prism" }),
6968
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
6969
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6970
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6971
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6972
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Prism" }),
6973
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "V/A" })
7099
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass }),
7100
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
7101
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
7102
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
7103
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Prism" }),
7104
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "V/A" }),
7105
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
7106
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
7107
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
7108
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "Prism" }),
7109
+ /* @__PURE__ */ jsx("th", { className: refractionHeaderCellClass, children: "V/A" })
6974
7110
  ] })
6975
7111
  ] }),
6976
7112
  /* @__PURE__ */ jsxs("tbody", { children: [
6977
7113
  /* @__PURE__ */ jsxs("tr", { children: [
6978
- /* @__PURE__ */ jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Glass Power" }),
6979
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7114
+ /* @__PURE__ */ jsx("td", { className: refractionLabelCellClass, children: "Glass Power" }),
7115
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6980
7116
  Input,
6981
7117
  {
6982
7118
  disabled,
6983
7119
  type: "number",
6984
7120
  step: "0.25",
6985
- className: numberInputClass,
7121
+ className: refractionInputClass,
6986
7122
  value: safe.glass_power_prescription.right_eye.sph ?? "",
6987
7123
  onChange: (e) => setRefractionField(
6988
7124
  "glass_power_prescription",
@@ -6993,13 +7129,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6993
7129
  )
6994
7130
  }
6995
7131
  ) }),
6996
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7132
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6997
7133
  Input,
6998
7134
  {
6999
7135
  disabled,
7000
7136
  type: "number",
7001
7137
  step: "0.25",
7002
- className: numberInputClass,
7138
+ className: refractionInputClass,
7003
7139
  value: safe.glass_power_prescription.right_eye.cyl ?? "",
7004
7140
  onChange: (e) => setRefractionField(
7005
7141
  "glass_power_prescription",
@@ -7010,12 +7146,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
7010
7146
  )
7011
7147
  }
7012
7148
  ) }),
7013
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7149
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
7014
7150
  Input,
7015
7151
  {
7016
7152
  disabled,
7017
7153
  type: "number",
7018
- className: numberInputClass,
7154
+ className: refractionInputClass,
7019
7155
  value: safe.glass_power_prescription.right_eye.axis ?? "",
7020
7156
  onChange: (e) => setRefractionField(
7021
7157
  "glass_power_prescription",
@@ -7026,13 +7162,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
7026
7162
  )
7027
7163
  }
7028
7164
  ) }),
7029
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7165
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
7030
7166
  Input,
7031
7167
  {
7032
7168
  disabled,
7033
7169
  type: "number",
7034
7170
  step: "0.25",
7035
- className: numberInputClass,
7171
+ className: refractionInputClass,
7036
7172
  value: safe.glass_power_prescription.right_eye.prism ?? "",
7037
7173
  onChange: (e) => setRefractionField(
7038
7174
  "glass_power_prescription",
@@ -7043,11 +7179,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
7043
7179
  )
7044
7180
  }
7045
7181
  ) }),
7046
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7182
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
7047
7183
  "select",
7048
7184
  {
7049
7185
  disabled,
7050
- className: selectClass,
7186
+ className: refractionSelectClass,
7051
7187
  value: safe.glass_power_prescription.right_eye.va,
7052
7188
  onChange: (e) => setRefractionField(
7053
7189
  "glass_power_prescription",
@@ -7059,13 +7195,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
7059
7195
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsx("option", { value: opt, children: opt }, opt || "blank"))
7060
7196
  }
7061
7197
  ) }),
7062
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7198
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
7063
7199
  Input,
7064
7200
  {
7065
7201
  disabled,
7066
7202
  type: "number",
7067
7203
  step: "0.25",
7068
- className: numberInputClass,
7204
+ className: refractionInputClass,
7069
7205
  value: safe.glass_power_prescription.left_eye.sph ?? "",
7070
7206
  onChange: (e) => setRefractionField(
7071
7207
  "glass_power_prescription",
@@ -7076,13 +7212,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
7076
7212
  )
7077
7213
  }
7078
7214
  ) }),
7079
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7215
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
7080
7216
  Input,
7081
7217
  {
7082
7218
  disabled,
7083
7219
  type: "number",
7084
7220
  step: "0.25",
7085
- className: numberInputClass,
7221
+ className: refractionInputClass,
7086
7222
  value: safe.glass_power_prescription.left_eye.cyl ?? "",
7087
7223
  onChange: (e) => setRefractionField(
7088
7224
  "glass_power_prescription",
@@ -7093,12 +7229,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
7093
7229
  )
7094
7230
  }
7095
7231
  ) }),
7096
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7232
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
7097
7233
  Input,
7098
7234
  {
7099
7235
  disabled,
7100
7236
  type: "number",
7101
- className: numberInputClass,
7237
+ className: refractionInputClass,
7102
7238
  value: safe.glass_power_prescription.left_eye.axis ?? "",
7103
7239
  onChange: (e) => setRefractionField(
7104
7240
  "glass_power_prescription",
@@ -7109,13 +7245,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
7109
7245
  )
7110
7246
  }
7111
7247
  ) }),
7112
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7248
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
7113
7249
  Input,
7114
7250
  {
7115
7251
  disabled,
7116
7252
  type: "number",
7117
7253
  step: "0.25",
7118
- className: numberInputClass,
7254
+ className: refractionInputClass,
7119
7255
  value: safe.glass_power_prescription.left_eye.prism ?? "",
7120
7256
  onChange: (e) => setRefractionField(
7121
7257
  "glass_power_prescription",
@@ -7126,11 +7262,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
7126
7262
  )
7127
7263
  }
7128
7264
  ) }),
7129
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7265
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
7130
7266
  "select",
7131
7267
  {
7132
7268
  disabled,
7133
- className: selectClass,
7269
+ className: refractionSelectClass,
7134
7270
  value: safe.glass_power_prescription.left_eye.va,
7135
7271
  onChange: (e) => setRefractionField(
7136
7272
  "glass_power_prescription",
@@ -7144,25 +7280,25 @@ var OphthalmologyWidget = ({ fieldId }) => {
7144
7280
  ) })
7145
7281
  ] }),
7146
7282
  /* @__PURE__ */ jsxs("tr", { children: [
7147
- /* @__PURE__ */ jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Add" }),
7148
- /* @__PURE__ */ jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsx(
7283
+ /* @__PURE__ */ jsx("td", { className: refractionLabelCellClass, children: "Add" }),
7284
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsx(
7149
7285
  Input,
7150
7286
  {
7151
7287
  disabled,
7152
7288
  type: "number",
7153
7289
  step: "0.25",
7154
- className: numberInputClass,
7290
+ className: refractionInputClass,
7155
7291
  value: safe.glass_power_prescription.add.right ?? "",
7156
7292
  onChange: (e) => setRefractionAdd("glass_power_prescription", "right", e.target.value)
7157
7293
  }
7158
7294
  ) }),
7159
- /* @__PURE__ */ jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsx(
7295
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsx(
7160
7296
  Input,
7161
7297
  {
7162
7298
  disabled,
7163
7299
  type: "number",
7164
7300
  step: "0.25",
7165
- className: numberInputClass,
7301
+ className: refractionInputClass,
7166
7302
  value: safe.glass_power_prescription.add.left ?? "",
7167
7303
  onChange: (e) => setRefractionAdd("glass_power_prescription", "left", e.target.value)
7168
7304
  }
@@ -7849,6 +7985,930 @@ var DischargeMedicationOrdersWidget = ({ fieldId }) => {
7849
7985
  showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
7850
7986
  ] });
7851
7987
  };
7988
+ var DEFAULT_TOKEN_SEPARATOR = ", ";
7989
+ function getAppendSeparator(def) {
7990
+ const raw = def.meta && typeof def.meta.appendSeparator === "string" ? def.meta.appendSeparator : DEFAULT_TOKEN_SEPARATOR;
7991
+ return raw;
7992
+ }
7993
+ function getSuggestionTokensFromText(text) {
7994
+ return text.split(",").map((p) => p.trim()).filter(Boolean);
7995
+ }
7996
+ function toggleSuggestionTokenInText(current, token, separator = DEFAULT_TOKEN_SEPARATOR) {
7997
+ const t = String(token).trim();
7998
+ if (!t) return current;
7999
+ const parts = getSuggestionTokensFromText(current);
8000
+ const i = parts.findIndex((p) => p === t);
8001
+ if (i >= 0) {
8002
+ parts.splice(i, 1);
8003
+ } else {
8004
+ parts.push(t);
8005
+ }
8006
+ return parts.join(separator);
8007
+ }
8008
+ function isTokenSelected(text, optionValue) {
8009
+ const t = String(optionValue).trim();
8010
+ if (!t) return false;
8011
+ return getSuggestionTokensFromText(text).some((p) => p === t);
8012
+ }
8013
+ function deriveKnownSuggestionChipValues(text, options) {
8014
+ if (!options.length) return [];
8015
+ const allowed = new Map(options.map((o) => [String(o.value), o.value]));
8016
+ const tokens = getSuggestionTokensFromText(text);
8017
+ const out = [];
8018
+ const seen = /* @__PURE__ */ new Set();
8019
+ for (const t of tokens) {
8020
+ if (!allowed.has(t) || seen.has(t)) continue;
8021
+ seen.add(t);
8022
+ out.push(allowed.get(t));
8023
+ }
8024
+ return out;
8025
+ }
8026
+ function parallelChipArraysEqual(a, b) {
8027
+ if (!Array.isArray(a) || !Array.isArray(b)) return false;
8028
+ if (a.length !== b.length) return false;
8029
+ for (let i = 0; i < a.length; i++) {
8030
+ if (a[i] !== b[i]) return false;
8031
+ }
8032
+ return true;
8033
+ }
8034
+ function isSuggestionField(type) {
8035
+ return type === "suggestion_textarea" || type === "complaint_chips";
8036
+ }
8037
+ var SuggestionTextareaWidget = ({ fieldId }) => {
8038
+ const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
8039
+ const { state } = useForm();
8040
+ const store = useFormStore();
8041
+ const hasVoice = !!(fieldDef?.voice && store.getVoice());
8042
+ const [options, setOptions] = useState([]);
8043
+ const [loading, setLoading] = useState(false);
8044
+ const showError = !!error && (touched || state.submitAttempted);
8045
+ const def = fieldDef && isSuggestionField(fieldDef.type) ? fieldDef : void 0;
8046
+ const textValue = value == null || typeof value === "string" ? value || "" : String(value);
8047
+ const parallelChipFieldId = def?.meta && typeof def.meta.parallelChipFieldId === "string" ? def.meta.parallelChipFieldId.trim() : void 0;
8048
+ useEffect(() => {
8049
+ if (!def) {
8050
+ setOptions([]);
8051
+ return;
8052
+ }
8053
+ if (def.options?.length) {
8054
+ setOptions(def.options);
8055
+ } else if (def.dataSource) {
8056
+ setLoading(true);
8057
+ fetchOptions(def.dataSource.source, def.dataSource.params).then((opts) => setOptions(opts)).finally(() => setLoading(false));
8058
+ } else {
8059
+ setOptions([]);
8060
+ }
8061
+ }, [def]);
8062
+ useEffect(() => {
8063
+ if (!parallelChipFieldId || !def) return;
8064
+ const parallelDef = store.getFieldDef(parallelChipFieldId);
8065
+ if (!parallelDef || parallelDef.type !== "multiselect") return;
8066
+ const next = deriveKnownSuggestionChipValues(textValue, options);
8067
+ const prev = store.getFieldState(parallelChipFieldId).value;
8068
+ if (parallelChipArraysEqual(prev, next)) return;
8069
+ store.setValues({ [parallelChipFieldId]: next }, { touch: false });
8070
+ }, [def, parallelChipFieldId, textValue, options, store]);
8071
+ if (!def) {
8072
+ return null;
8073
+ }
8074
+ const appendSeparator = getAppendSeparator(def);
8075
+ const suggestionsAria = def.meta && typeof def.meta.suggestionsAriaLabel === "string" ? def.meta.suggestionsAriaLabel : "Quick suggestions";
8076
+ const theme = getThemeConfig("textarea", def.theme);
8077
+ const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
8078
+ const labelClass = theme?.labelClassName;
8079
+ const inputClass = cn(theme?.inputClassName, showError && "border-red-500");
8080
+ const height = def.height != null ? typeof def.height === "string" ? Number(def.height) || void 0 : def.height : void 0;
8081
+ const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
8082
+ def.label,
8083
+ " ",
8084
+ def.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
8085
+ ] });
8086
+ const labelEl = theme ? /* @__PURE__ */ jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsx(Label, { children: labelContent });
8087
+ const onChipClick = (optValue) => {
8088
+ if (disabled) return;
8089
+ setValue(toggleSuggestionTokenInText(textValue, String(optValue), appendSeparator));
8090
+ };
8091
+ const hasSuggestions = options.length > 0;
8092
+ const isHighlightLabel = def.theme === "highlight-label";
8093
+ const suggestionShellClass = cn(
8094
+ "flex min-w-0 flex-col overflow-hidden",
8095
+ hasSuggestions && (isHighlightLabel ? "-mt-1 rounded-b-md border-[#D0D0D0] bg-white" : "rounded-md border border-input bg-background")
8096
+ );
8097
+ const chipsRowClass = cn(
8098
+ "flex flex-wrap gap-2 px-3 pb-2 pt-3",
8099
+ hasSuggestions && (isHighlightLabel ? "" : "border-b border-input/70"),
8100
+ disabled && "pointer-events-none opacity-50"
8101
+ );
8102
+ const textareaShellClass = cn(
8103
+ inputClass,
8104
+ hasSuggestions && cn(
8105
+ "mt-0 rounded-t-none rounded-b-md border-0 shadow-none focus-visible:ring-offset-0",
8106
+ isHighlightLabel ? "border-t-0" : "min-h-[80px]"
8107
+ )
8108
+ );
8109
+ const suggestionButtons = loading ? /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "Loading suggestions\u2026" }) : options.map((opt) => {
8110
+ const on = isTokenSelected(textValue, opt.value);
8111
+ return /* @__PURE__ */ jsx(
8112
+ "button",
8113
+ {
8114
+ type: "button",
8115
+ onClick: () => onChipClick(opt.value),
8116
+ className: cn(
8117
+ "inline-flex min-h-8 items-center rounded-full border px-3 py-1 text-xs font-medium leading-none transition-colors",
8118
+ on ? "border-primary bg-primary/10 text-primary" : "border-muted-foreground/30 bg-background hover:bg-muted/60"
8119
+ ),
8120
+ children: opt.label
8121
+ },
8122
+ String(opt.value)
8123
+ );
8124
+ });
8125
+ return /* @__PURE__ */ jsxs("div", { className: wrapperClass, children: [
8126
+ hasVoice ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
8127
+ labelEl,
8128
+ /* @__PURE__ */ jsx(VoiceMicButton, { fieldId, onTranscriptReady: setValue })
8129
+ ] }) : labelEl,
8130
+ def.description && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: def.description }),
8131
+ hasSuggestions ? /* @__PURE__ */ jsxs("div", { className: suggestionShellClass, children: [
8132
+ /* @__PURE__ */ jsx("div", { className: chipsRowClass, role: "group", "aria-label": suggestionsAria, children: suggestionButtons }),
8133
+ /* @__PURE__ */ jsx(
8134
+ Textarea,
8135
+ {
8136
+ id: fieldId,
8137
+ value: textValue,
8138
+ onChange: (e) => setValue(e.target.value),
8139
+ onBlur: setTouched,
8140
+ disabled,
8141
+ className: textareaShellClass,
8142
+ placeholder: def.placeholder,
8143
+ style: height != null && Number.isFinite(height) ? { minHeight: height } : void 0
8144
+ }
8145
+ )
8146
+ ] }) : /* @__PURE__ */ jsx(
8147
+ Textarea,
8148
+ {
8149
+ id: fieldId,
8150
+ value: textValue,
8151
+ onChange: (e) => setValue(e.target.value),
8152
+ onBlur: setTouched,
8153
+ disabled,
8154
+ className: inputClass,
8155
+ placeholder: def.placeholder,
8156
+ style: height != null && Number.isFinite(height) ? { minHeight: height } : void 0
8157
+ }
8158
+ ),
8159
+ showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
8160
+ ] });
8161
+ };
8162
+ var EMPTY_GRADES = { NO: 0, NC: 0, C: 0, PSC: 0 };
8163
+ var LOCS_FIELDS = [
8164
+ { key: "NO", label: "Nuclear Opalescence", max: 4, hint: "0\u20134" },
8165
+ { key: "NC", label: "Nuclear Colour", max: 4, hint: "0\u20134" },
8166
+ { key: "C", label: "Cortical", max: 4, hint: "0\u20134" },
8167
+ { key: "PSC", label: "Posterior Subcapsular", max: 4, hint: "0\u20134" }
8168
+ ];
8169
+ var LOCS_GRID_STYLE = {
8170
+ display: "grid",
8171
+ gridTemplateColumns: "minmax(0, 1fr) minmax(5.5rem, auto) minmax(5.5rem, auto)",
8172
+ columnGap: "1rem",
8173
+ rowGap: "0.5rem",
8174
+ alignItems: "center",
8175
+ width: "100%",
8176
+ minWidth: 0
8177
+ };
8178
+ function parseGrades(raw) {
8179
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
8180
+ const r = raw;
8181
+ const n = (k) => {
8182
+ const v = Number(r[k]);
8183
+ return Number.isFinite(v) ? Math.trunc(v) : 0;
8184
+ };
8185
+ return { NO: n("NO"), NC: n("NC"), C: n("C"), PSC: n("PSC") };
8186
+ }
8187
+ function clampGrade(v) {
8188
+ return Math.max(0, Math.min(4, Math.trunc(v)));
8189
+ }
8190
+ function parseValue(raw) {
8191
+ const locs = {
8192
+ OD: { ...EMPTY_GRADES },
8193
+ OS: { ...EMPTY_GRADES }
8194
+ };
8195
+ if (raw && typeof raw === "object" && !Array.isArray(raw)) {
8196
+ const o = raw;
8197
+ const locsRaw = o.locs;
8198
+ if (locsRaw && typeof locsRaw === "object" && !Array.isArray(locsRaw)) {
8199
+ const L = locsRaw;
8200
+ const od = parseGrades(L.OD);
8201
+ const os = parseGrades(L.OS);
8202
+ if (od)
8203
+ locs.OD = {
8204
+ NO: clampGrade(od.NO),
8205
+ NC: clampGrade(od.NC),
8206
+ C: clampGrade(od.C),
8207
+ PSC: clampGrade(od.PSC)
8208
+ };
8209
+ if (os)
8210
+ locs.OS = {
8211
+ NO: clampGrade(os.NO),
8212
+ NC: clampGrade(os.NC),
8213
+ C: clampGrade(os.C),
8214
+ PSC: clampGrade(os.PSC)
8215
+ };
8216
+ }
8217
+ return {
8218
+ notes: typeof o.notes === "string" ? o.notes : "",
8219
+ assessmentKey: typeof o.assessmentKey === "string" ? o.assessmentKey : void 0,
8220
+ locs
8221
+ };
8222
+ }
8223
+ return { notes: "", assessmentKey: void 0, locs };
8224
+ }
8225
+ function cataractStage(eye, locs) {
8226
+ const g = locs[eye];
8227
+ const total = g.NO + g.NC + g.C + g.PSC;
8228
+ if (total === 0) return "\u2014";
8229
+ if (total <= 4) return "Early";
8230
+ if (total <= 8) return "Moderate";
8231
+ if (total <= 12) return "Advanced";
8232
+ return "Hypermature";
8233
+ }
8234
+ function Stepper({
8235
+ value,
8236
+ max,
8237
+ disabled,
8238
+ ariaLabel,
8239
+ onChange
8240
+ }) {
8241
+ return /* @__PURE__ */ jsxs(
8242
+ "div",
8243
+ {
8244
+ className: "flex items-center gap-1 justify-self-center",
8245
+ role: "group",
8246
+ "aria-label": ariaLabel,
8247
+ children: [
8248
+ /* @__PURE__ */ jsx(
8249
+ "button",
8250
+ {
8251
+ type: "button",
8252
+ disabled,
8253
+ onClick: () => onChange(Math.max(0, value - 1)),
8254
+ className: "h-6 w-6 shrink-0 rounded border border-input text-xs hover:bg-muted disabled:pointer-events-none disabled:opacity-50",
8255
+ children: "-"
8256
+ }
8257
+ ),
8258
+ /* @__PURE__ */ jsx(
8259
+ "input",
8260
+ {
8261
+ type: "number",
8262
+ min: 0,
8263
+ max,
8264
+ disabled,
8265
+ value,
8266
+ "aria-label": ariaLabel,
8267
+ onChange: (e) => onChange(Math.max(0, Math.min(max, Number(e.target.value) || 0))),
8268
+ className: "h-6 w-10 shrink-0 rounded border border-input bg-background px-1 py-0 text-center text-xs disabled:opacity-50"
8269
+ }
8270
+ ),
8271
+ /* @__PURE__ */ jsx(
8272
+ "button",
8273
+ {
8274
+ type: "button",
8275
+ disabled,
8276
+ onClick: () => onChange(Math.min(max, value + 1)),
8277
+ className: "h-6 w-6 shrink-0 rounded border border-input text-xs hover:bg-muted disabled:pointer-events-none disabled:opacity-50",
8278
+ children: "+"
8279
+ }
8280
+ )
8281
+ ]
8282
+ }
8283
+ );
8284
+ }
8285
+ function StageBadge({ stage }) {
8286
+ const cls = {
8287
+ Early: "border border-emerald-200 text-foreground",
8288
+ Moderate: "border border-amber-200 text-foreground",
8289
+ Advanced: "border border-orange-300 text-foreground",
8290
+ Hypermature: "border border-destructive text-foreground",
8291
+ "\u2014": "border border-border text-muted-foreground"
8292
+ };
8293
+ return /* @__PURE__ */ jsx(
8294
+ "span",
8295
+ {
8296
+ className: cn(
8297
+ "rounded-full bg-background px-2 py-0.5 text-[11px] font-medium",
8298
+ cls[stage] ?? "border border-border text-muted-foreground"
8299
+ ),
8300
+ children: stage
8301
+ }
8302
+ );
8303
+ }
8304
+ var DEFAULT_TITLE = "Lens Assessment \u2014 LOCS III";
8305
+ var LensAssessmentWidget = ({ fieldId }) => {
8306
+ const { fieldDef, value, setValue, error, disabled, touched } = useField(fieldId);
8307
+ const { state } = useForm();
8308
+ const showError = !!error && (touched || state.submitAttempted);
8309
+ if (!fieldDef || fieldDef.type !== "lens_assessment") {
8310
+ return null;
8311
+ }
8312
+ const def = fieldDef;
8313
+ const v = parseValue(value);
8314
+ const locs = v.locs ?? { OD: { ...EMPTY_GRADES }, OS: { ...EMPTY_GRADES } };
8315
+ const title = def.meta?.cardTitle || (def.label?.trim() ? def.label : DEFAULT_TITLE);
8316
+ const setPartial = (patch) => {
8317
+ setValue({ ...v, ...patch, locs: patch.locs ?? v.locs ?? locs });
8318
+ };
8319
+ const setLocs = (eye, key, n) => {
8320
+ const next = clampGrade(n);
8321
+ setPartial({
8322
+ locs: {
8323
+ ...locs,
8324
+ [eye]: { ...locs[eye], [key]: next }
8325
+ }
8326
+ });
8327
+ };
8328
+ return /* @__PURE__ */ jsxs(
8329
+ "div",
8330
+ {
8331
+ id: `lens-assessment-${fieldId}`,
8332
+ className: "w-full min-w-0 max-w-full rounded-lg border border-border bg-card p-4 text-card-foreground shadow-sm",
8333
+ children: [
8334
+ /* @__PURE__ */ jsx("h3", { className: "mb-3 text-sm font-semibold text-foreground", children: title }),
8335
+ /* @__PURE__ */ jsxs("div", { style: LOCS_GRID_STYLE, children: [
8336
+ /* @__PURE__ */ jsx("div", { className: "min-w-0", "aria-hidden": true }),
8337
+ /* @__PURE__ */ jsx("div", { className: "w-24 justify-self-center text-center text-xs font-semibold", children: "Right Eye" }),
8338
+ /* @__PURE__ */ jsx("div", { className: "w-24 justify-self-center text-center text-xs font-semibold", children: "Left Eye" }),
8339
+ LOCS_FIELDS.map((f) => /* @__PURE__ */ jsxs("div", { style: { display: "contents" }, children: [
8340
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 text-xs", children: [
8341
+ /* @__PURE__ */ jsx("div", { className: "font-medium", children: f.label }),
8342
+ /* @__PURE__ */ jsx("div", { className: "text-muted-foreground", children: f.hint })
8343
+ ] }),
8344
+ /* @__PURE__ */ jsx(
8345
+ Stepper,
8346
+ {
8347
+ value: locs.OD[f.key],
8348
+ max: f.max,
8349
+ disabled,
8350
+ ariaLabel: `${f.label} right eye`,
8351
+ onChange: (n) => setLocs("OD", f.key, n)
8352
+ }
8353
+ ),
8354
+ /* @__PURE__ */ jsx(
8355
+ Stepper,
8356
+ {
8357
+ value: locs.OS[f.key],
8358
+ max: f.max,
8359
+ disabled,
8360
+ ariaLabel: `${f.label} left eye`,
8361
+ onChange: (n) => setLocs("OS", f.key, n)
8362
+ }
8363
+ )
8364
+ ] }, f.key))
8365
+ ] }),
8366
+ /* @__PURE__ */ jsxs("div", { className: "mt-3 border-t border-border pt-3 text-xs", children: [
8367
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Cataract Stage" }),
8368
+ " ",
8369
+ /* @__PURE__ */ jsxs("span", { className: "ml-1 inline-flex items-center gap-1", children: [
8370
+ "OD ",
8371
+ /* @__PURE__ */ jsx(StageBadge, { stage: cataractStage("OD", locs) })
8372
+ ] }),
8373
+ /* @__PURE__ */ jsxs("span", { className: "ml-2 inline-flex items-center gap-1", children: [
8374
+ "OS ",
8375
+ /* @__PURE__ */ jsx(StageBadge, { stage: cataractStage("OS", locs) })
8376
+ ] })
8377
+ ] }),
8378
+ def.description && /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: def.description }),
8379
+ showError && /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-red-500", children: error })
8380
+ ]
8381
+ }
8382
+ );
8383
+ };
8384
+
8385
+ // src/core/functionalImpairmentScore.ts
8386
+ function clampFunctionalScore03(n) {
8387
+ const v = typeof n === "number" ? n : Number(n);
8388
+ if (!Number.isFinite(v)) return 0;
8389
+ return Math.max(0, Math.min(3, Math.trunc(v)));
8390
+ }
8391
+ function parseFunctionalImpairmentScore(raw) {
8392
+ const base = {
8393
+ reading: 0,
8394
+ nightDriving: 0,
8395
+ glare: 0,
8396
+ occupation: 0,
8397
+ adl: 0
8398
+ };
8399
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return base;
8400
+ const o = raw;
8401
+ for (const k of Object.keys(base)) {
8402
+ base[k] = clampFunctionalScore03(o[k]);
8403
+ }
8404
+ return base;
8405
+ }
8406
+ function functionalImpairmentTotal(v) {
8407
+ return v.reading + v.nightDriving + v.glare + v.occupation + v.adl;
8408
+ }
8409
+ var ITEMS = [
8410
+ { key: "reading", label: "Difficulty reading" },
8411
+ { key: "nightDriving", label: "Night driving difficulty" },
8412
+ { key: "glare", label: "Glare sensitivity" },
8413
+ { key: "occupation", label: "Occupational impact" },
8414
+ { key: "adl", label: "ADL limitation" }
8415
+ ];
8416
+ var SCALE_LABELS = ["None", "Mild", "Moderate", "Severe"];
8417
+ var DEFAULT_TITLE2 = "Functional Impairment Score (Stage 5)";
8418
+ var ITEMS_GRID_STYLE = {
8419
+ display: "grid",
8420
+ gridTemplateColumns: "repeat(auto-fit, minmax(min(100%, 8rem), 1fr))",
8421
+ columnGap: "0.5rem",
8422
+ rowGap: "0.5rem",
8423
+ width: "100%",
8424
+ minWidth: 0
8425
+ };
8426
+ function clamp03(n) {
8427
+ const v = typeof n === "number" ? n : Number(n);
8428
+ if (!Number.isFinite(v)) return 0;
8429
+ return Math.max(0, Math.min(3, Math.trunc(v)));
8430
+ }
8431
+ var FunctionalImpairmentScoreWidget = ({
8432
+ fieldId
8433
+ }) => {
8434
+ const { fieldDef, value, setValue, error, disabled, touched } = useField(fieldId);
8435
+ const { state } = useForm();
8436
+ const showError = !!error && (touched || state.submitAttempted);
8437
+ if (!fieldDef || fieldDef.type !== "functional_impairment_score") {
8438
+ return null;
8439
+ }
8440
+ const def = fieldDef;
8441
+ const v = parseFunctionalImpairmentScore(value);
8442
+ const total = functionalImpairmentTotal(v);
8443
+ const title = def.meta?.cardTitle?.trim() || (def.label?.trim() ? def.label : DEFAULT_TITLE2);
8444
+ const setDim = (key, n) => {
8445
+ setValue({ ...v, [key]: clamp03(n) });
8446
+ };
8447
+ return /* @__PURE__ */ jsxs(
8448
+ "div",
8449
+ {
8450
+ id: `functional-impairment-${fieldId}`,
8451
+ className: "w-full min-w-0 max-w-full rounded-lg border border-border bg-card p-3 text-card-foreground shadow-sm",
8452
+ children: [
8453
+ /* @__PURE__ */ jsx("h3", { className: "mb-2 text-xs font-semibold leading-tight text-foreground sm:text-[13px]", children: title }),
8454
+ /* @__PURE__ */ jsx("div", { style: ITEMS_GRID_STYLE, children: ITEMS.map((it) => /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-1", children: [
8455
+ /* @__PURE__ */ jsx("div", { className: "text-[10px] font-medium leading-snug text-foreground sm:text-[11px]", children: it.label }),
8456
+ /* @__PURE__ */ jsx("div", { className: "flex w-fit max-w-full shrink-0 gap-0.5", children: [0, 1, 2, 3].map((score) => /* @__PURE__ */ jsx(
8457
+ "button",
8458
+ {
8459
+ type: "button",
8460
+ title: SCALE_LABELS[score],
8461
+ disabled,
8462
+ onClick: () => setDim(it.key, score),
8463
+ className: cn(
8464
+ "h-6 w-7 shrink-0 rounded border text-[10px] transition-colors sm:text-[11px]",
8465
+ v[it.key] === score ? "border-primary bg-primary text-primary-foreground" : "border-input hover:bg-muted",
8466
+ disabled && "pointer-events-none opacity-50"
8467
+ ),
8468
+ children: score
8469
+ },
8470
+ score
8471
+ )) })
8472
+ ] }, it.key)) }),
8473
+ /* @__PURE__ */ jsxs("div", { className: "mt-2 flex flex-col gap-1.5 border-t border-border pt-2 sm:flex-row sm:items-center sm:justify-between sm:gap-2", children: [
8474
+ /* @__PURE__ */ jsx("div", { className: "text-[10px] leading-snug text-muted-foreground sm:text-[11px]", children: "Score scale: 0 = none, 3 = severe (each item)" }),
8475
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-1.5 sm:justify-end", children: [
8476
+ /* @__PURE__ */ jsx("span", { className: "text-[10px] text-muted-foreground sm:text-[11px]", children: "Total" }),
8477
+ /* @__PURE__ */ jsxs("span", { className: "text-sm font-bold tabular-nums sm:text-[15px]", children: [
8478
+ total,
8479
+ /* @__PURE__ */ jsx("span", { className: "font-normal text-muted-foreground", children: "/15" })
8480
+ ] })
8481
+ ] })
8482
+ ] }),
8483
+ def.description && /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: def.description }),
8484
+ showError && /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-red-500", children: error })
8485
+ ]
8486
+ }
8487
+ );
8488
+ };
8489
+ var FORMULA_OPTIONS = [
8490
+ "SRK/T",
8491
+ "Barrett Universal II",
8492
+ "Hoffer Q",
8493
+ "Haigis",
8494
+ "Holladay 1",
8495
+ "Holladay 2",
8496
+ "Kane"
8497
+ ];
8498
+ var METHODS = [
8499
+ { value: "optical_biometry", label: "Optical biometry (IOL Master)" },
8500
+ { value: "ascan_immersion", label: "A-scan (immersion)" },
8501
+ { value: "ascan_contact", label: "A-scan (contact)" }
8502
+ ];
8503
+ var EMPTY = {
8504
+ axialLengthOD: "",
8505
+ axialLengthOS: "",
8506
+ k1k2AxisOD: "",
8507
+ k1k2AxisOS: "",
8508
+ anteriorChamberDepthOD: "",
8509
+ anteriorChamberDepthOS: "",
8510
+ iolPowerOD: "",
8511
+ iolPowerOS: "",
8512
+ targetRefractionOD: "",
8513
+ targetRefractionOS: "",
8514
+ formula: "SRK/T",
8515
+ method: "optical_biometry",
8516
+ cornealTopoUploaded: false,
8517
+ specularMicroscopyDone: false,
8518
+ endothelialCount: ""
8519
+ };
8520
+ function str(x) {
8521
+ return typeof x === "string" ? x : "";
8522
+ }
8523
+ function parseValue2(raw) {
8524
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return { ...EMPTY };
8525
+ const o = raw;
8526
+ const m = o.method;
8527
+ const method = m === "ascan_immersion" || m === "ascan_contact" || m === "optical_biometry" ? m : "optical_biometry";
8528
+ const formula = str(o.formula);
8529
+ return {
8530
+ ...EMPTY,
8531
+ axialLengthOD: str(o.axialLengthOD),
8532
+ axialLengthOS: str(o.axialLengthOS),
8533
+ k1k2AxisOD: str(o.k1k2AxisOD),
8534
+ k1k2AxisOS: str(o.k1k2AxisOS),
8535
+ anteriorChamberDepthOD: str(o.anteriorChamberDepthOD),
8536
+ anteriorChamberDepthOS: str(o.anteriorChamberDepthOS),
8537
+ iolPowerOD: str(o.iolPowerOD),
8538
+ iolPowerOS: str(o.iolPowerOS),
8539
+ targetRefractionOD: str(o.targetRefractionOD),
8540
+ targetRefractionOS: str(o.targetRefractionOS),
8541
+ formula: formula || "SRK/T",
8542
+ method,
8543
+ cornealTopoUploaded: o.cornealTopoUploaded === true,
8544
+ specularMicroscopyDone: o.specularMicroscopyDone === true,
8545
+ endothelialCount: str(o.endothelialCount)
8546
+ };
8547
+ }
8548
+ var paramCell = "emr-biometry-param text-[11px] font-semibold leading-snug text-foreground sm:text-xs py-2";
8549
+ var eyeTh = "emr-biometry-eye text-center text-[11px] font-semibold sm:text-xs py-2";
8550
+ function Inp({
8551
+ value,
8552
+ onChange,
8553
+ disabled,
8554
+ placeholder
8555
+ }) {
8556
+ return /* @__PURE__ */ jsx(
8557
+ "input",
8558
+ {
8559
+ value,
8560
+ disabled,
8561
+ placeholder,
8562
+ onChange: (e) => onChange(e.target.value),
8563
+ className: "box-border w-full min-w-0 rounded border border-input bg-background px-2 py-1 text-[11px] sm:text-xs"
8564
+ }
8565
+ );
8566
+ }
8567
+ var DEFAULT_TITLE3 = "Biometry & IOL Workup (Stage 7)";
8568
+ var BiometryIolWorkupWidget = ({ fieldId }) => {
8569
+ const { fieldDef, value, setValue, error, disabled, touched } = useField(fieldId);
8570
+ const { state } = useForm();
8571
+ const showError = !!error && (touched || state.submitAttempted);
8572
+ if (!fieldDef || fieldDef.type !== "biometry_iol_workup") {
8573
+ return null;
8574
+ }
8575
+ const def = fieldDef;
8576
+ const v = parseValue2(value);
8577
+ const title = def.meta?.cardTitle?.trim() || (def.label?.trim() ? def.label : DEFAULT_TITLE3);
8578
+ const patch = (p) => setValue({ ...v, ...p });
8579
+ return /* @__PURE__ */ jsxs(
8580
+ "div",
8581
+ {
8582
+ id: `biometry-iol-${fieldId}`,
8583
+ className: "w-full min-w-0 max-w-full self-stretch rounded-lg border border-border bg-card p-3 text-card-foreground shadow-sm",
8584
+ children: [
8585
+ /* @__PURE__ */ jsx("h3", { className: "mb-2.5 text-sm font-semibold leading-tight text-foreground", children: title }),
8586
+ /* @__PURE__ */ jsx("div", { className: "w-full min-w-0 overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "emr-table emr-table--biometry min-w-full", children: [
8587
+ /* @__PURE__ */ jsxs("colgroup", { children: [
8588
+ /* @__PURE__ */ jsx("col", { style: { width: "32%" } }),
8589
+ /* @__PURE__ */ jsx("col", { style: { width: "34%" } }),
8590
+ /* @__PURE__ */ jsx("col", { style: { width: "34%" } })
8591
+ ] }),
8592
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
8593
+ /* @__PURE__ */ jsx("th", { scope: "col", className: paramCell, children: "Parameter" }),
8594
+ /* @__PURE__ */ jsx("th", { scope: "col", className: eyeTh, children: "Right Eye" }),
8595
+ /* @__PURE__ */ jsx("th", { scope: "col", className: eyeTh, children: "Left Eye" })
8596
+ ] }) }),
8597
+ /* @__PURE__ */ jsxs("tbody", { children: [
8598
+ /* @__PURE__ */ jsxs("tr", { children: [
8599
+ /* @__PURE__ */ jsx("td", { className: paramCell, children: "Axial Length (mm)" }),
8600
+ /* @__PURE__ */ jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsx(
8601
+ Inp,
8602
+ {
8603
+ value: v.axialLengthOD,
8604
+ disabled,
8605
+ placeholder: "e.g. 23.45",
8606
+ onChange: (s) => patch({ axialLengthOD: s })
8607
+ }
8608
+ ) }),
8609
+ /* @__PURE__ */ jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsx(
8610
+ Inp,
8611
+ {
8612
+ value: v.axialLengthOS,
8613
+ disabled,
8614
+ placeholder: "e.g. 23.45",
8615
+ onChange: (s) => patch({ axialLengthOS: s })
8616
+ }
8617
+ ) })
8618
+ ] }),
8619
+ /* @__PURE__ */ jsxs("tr", { children: [
8620
+ /* @__PURE__ */ jsx("td", { className: paramCell, children: "K1 / K2 / Axis" }),
8621
+ /* @__PURE__ */ jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsx(
8622
+ Inp,
8623
+ {
8624
+ value: v.k1k2AxisOD,
8625
+ disabled,
8626
+ placeholder: "44.0 / 44.5 / 90",
8627
+ onChange: (s) => patch({ k1k2AxisOD: s })
8628
+ }
8629
+ ) }),
8630
+ /* @__PURE__ */ jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsx(
8631
+ Inp,
8632
+ {
8633
+ value: v.k1k2AxisOS,
8634
+ disabled,
8635
+ placeholder: "44.0 / 44.5 / 90",
8636
+ onChange: (s) => patch({ k1k2AxisOS: s })
8637
+ }
8638
+ ) })
8639
+ ] }),
8640
+ /* @__PURE__ */ jsxs("tr", { children: [
8641
+ /* @__PURE__ */ jsx("td", { className: `${paramCell} whitespace-nowrap`, children: "Anterior Chamber Depth (mm)" }),
8642
+ /* @__PURE__ */ jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsx(
8643
+ Inp,
8644
+ {
8645
+ value: v.anteriorChamberDepthOD,
8646
+ disabled,
8647
+ onChange: (s) => patch({ anteriorChamberDepthOD: s })
8648
+ }
8649
+ ) }),
8650
+ /* @__PURE__ */ jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsx(
8651
+ Inp,
8652
+ {
8653
+ value: v.anteriorChamberDepthOS,
8654
+ disabled,
8655
+ onChange: (s) => patch({ anteriorChamberDepthOS: s })
8656
+ }
8657
+ ) })
8658
+ ] }),
8659
+ /* @__PURE__ */ jsxs("tr", { children: [
8660
+ /* @__PURE__ */ jsx("td", { className: paramCell, children: "IOL Power (D)" }),
8661
+ /* @__PURE__ */ jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsx(Inp, { value: v.iolPowerOD, disabled, onChange: (s) => patch({ iolPowerOD: s }) }) }),
8662
+ /* @__PURE__ */ jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsx(Inp, { value: v.iolPowerOS, disabled, onChange: (s) => patch({ iolPowerOS: s }) }) })
8663
+ ] }),
8664
+ /* @__PURE__ */ jsxs("tr", { children: [
8665
+ /* @__PURE__ */ jsx("td", { className: paramCell, children: "Target Refraction (D)" }),
8666
+ /* @__PURE__ */ jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsx(
8667
+ Inp,
8668
+ {
8669
+ value: v.targetRefractionOD,
8670
+ disabled,
8671
+ placeholder: "e.g. -0.25",
8672
+ onChange: (s) => patch({ targetRefractionOD: s })
8673
+ }
8674
+ ) }),
8675
+ /* @__PURE__ */ jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsx(
8676
+ Inp,
8677
+ {
8678
+ value: v.targetRefractionOS,
8679
+ disabled,
8680
+ placeholder: "e.g. -0.25",
8681
+ onChange: (s) => patch({ targetRefractionOS: s })
8682
+ }
8683
+ ) })
8684
+ ] }),
8685
+ /* @__PURE__ */ jsxs("tr", { children: [
8686
+ /* @__PURE__ */ jsx("td", { className: paramCell, children: "Formula" }),
8687
+ /* @__PURE__ */ jsx("td", { className: "min-w-0 px-2 py-2 align-middle", colSpan: 2, children: /* @__PURE__ */ jsx(
8688
+ "select",
8689
+ {
8690
+ value: v.formula,
8691
+ disabled,
8692
+ onChange: (e) => patch({ formula: e.target.value }),
8693
+ className: "box-border w-full min-w-0 rounded border border-input bg-background px-2 py-1 text-[11px] sm:text-xs",
8694
+ children: FORMULA_OPTIONS.map((opt) => /* @__PURE__ */ jsx("option", { value: opt, children: opt }, opt))
8695
+ }
8696
+ ) })
8697
+ ] }),
8698
+ /* @__PURE__ */ jsxs("tr", { children: [
8699
+ /* @__PURE__ */ jsx("td", { className: `${paramCell} align-top`, children: "Method" }),
8700
+ /* @__PURE__ */ jsx("td", { className: "min-w-0 px-2 py-2 align-middle", colSpan: 2, children: /* @__PURE__ */ jsx(
8701
+ "div",
8702
+ {
8703
+ role: "radiogroup",
8704
+ "aria-label": "Biometry method",
8705
+ className: "flex w-full flex-wrap items-center justify-center gap-x-3 gap-y-2 text-[11px] sm:gap-x-4 sm:text-xs",
8706
+ children: METHODS.map(({ value: mv, label }) => /* @__PURE__ */ jsxs("label", { className: "flex min-w-0 shrink-0 cursor-pointer items-center gap-1.5", children: [
8707
+ /* @__PURE__ */ jsx(
8708
+ "input",
8709
+ {
8710
+ type: "radio",
8711
+ name: `${fieldId}-biom-method`,
8712
+ value: mv,
8713
+ checked: v.method === mv,
8714
+ disabled,
8715
+ onChange: () => patch({ method: mv }),
8716
+ className: "shrink-0"
8717
+ }
8718
+ ),
8719
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 whitespace-nowrap leading-tight", children: label })
8720
+ ] }, mv))
8721
+ }
8722
+ ) })
8723
+ ] }),
8724
+ /* @__PURE__ */ jsxs("tr", { children: [
8725
+ /* @__PURE__ */ jsx("td", { className: `${paramCell} align-top text-muted-foreground`, children: "Optional workup" }),
8726
+ /* @__PURE__ */ jsx("td", { className: "min-w-0 px-2 py-2 align-middle", colSpan: 2, children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
8727
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-center gap-x-4 gap-y-2 sm:justify-between", children: [
8728
+ /* @__PURE__ */ jsxs("label", { className: "inline-flex min-w-0 cursor-pointer items-center gap-1.5 text-[11px] leading-snug sm:text-xs", children: [
8729
+ /* @__PURE__ */ jsx(
8730
+ "input",
8731
+ {
8732
+ type: "checkbox",
8733
+ className: "shrink-0",
8734
+ checked: v.cornealTopoUploaded,
8735
+ disabled,
8736
+ onChange: (e) => patch({ cornealTopoUploaded: e.target.checked })
8737
+ }
8738
+ ),
8739
+ /* @__PURE__ */ jsx("span", { children: "Corneal topography uploaded" })
8740
+ ] }),
8741
+ /* @__PURE__ */ jsxs("label", { className: "inline-flex min-w-0 cursor-pointer items-center gap-1.5 text-[11px] leading-snug sm:text-xs", children: [
8742
+ /* @__PURE__ */ jsx(
8743
+ "input",
8744
+ {
8745
+ type: "checkbox",
8746
+ className: "shrink-0",
8747
+ checked: v.specularMicroscopyDone,
8748
+ disabled,
8749
+ onChange: (e) => patch({ specularMicroscopyDone: e.target.checked })
8750
+ }
8751
+ ),
8752
+ /* @__PURE__ */ jsx("span", { children: "Specular microscopy done" })
8753
+ ] })
8754
+ ] }),
8755
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-end gap-2 text-[11px] sm:text-xs", children: [
8756
+ /* @__PURE__ */ jsx("span", { className: "shrink-0 text-muted-foreground", children: "Endothelial count:" }),
8757
+ /* @__PURE__ */ jsx(
8758
+ "input",
8759
+ {
8760
+ value: v.endothelialCount,
8761
+ disabled,
8762
+ placeholder: "cells/mm\xB2",
8763
+ onChange: (e) => patch({ endothelialCount: e.target.value }),
8764
+ className: "box-border w-[5.5rem] min-w-0 shrink-0 rounded border border-input bg-background px-2 py-1 text-[11px] sm:text-xs"
8765
+ }
8766
+ )
8767
+ ] })
8768
+ ] }) })
8769
+ ] })
8770
+ ] })
8771
+ ] }) }),
8772
+ def.description && /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: def.description }),
8773
+ showError && /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-red-500", children: error })
8774
+ ]
8775
+ }
8776
+ );
8777
+ };
8778
+ var RISKS = [
8779
+ "Small pupil",
8780
+ "Pseudoexfoliation",
8781
+ "Diabetes",
8782
+ "Shallow AC",
8783
+ "Previous ocular surgery",
8784
+ "Zonular weakness",
8785
+ "Mature/white cataract"
8786
+ ];
8787
+ var DIABETES = "Diabetes";
8788
+ function parseValue3(raw) {
8789
+ const empty = { OD: [], OS: [] };
8790
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return empty;
8791
+ const o = raw;
8792
+ const arr = (x) => Array.isArray(x) ? x.filter((i) => typeof i === "string") : [];
8793
+ let OD = arr(o.OD);
8794
+ let OS = arr(o.OS);
8795
+ const odD = OD.includes(DIABETES);
8796
+ const osD = OS.includes(DIABETES);
8797
+ if (odD !== osD) {
8798
+ if (odD && !osD) OS = [...OS, DIABETES];
8799
+ else if (osD && !odD) OD = [...OD, DIABETES];
8800
+ }
8801
+ return { OD, OS };
8802
+ }
8803
+ function riskTierForCount(n) {
8804
+ if (n === 0) return "Low";
8805
+ if (n <= 2) return "Moderate";
8806
+ return "High";
8807
+ }
8808
+ function tierBadgeClass(tier) {
8809
+ if (tier === "High") return "bg-red-600 text-white";
8810
+ if (tier === "Moderate") return "bg-amber-500 text-white";
8811
+ return "bg-emerald-600 text-white";
8812
+ }
8813
+ var DEFAULT_TITLE4 = "Surgical Risk Flags (Stage 11)";
8814
+ function RiskCol({
8815
+ eye,
8816
+ value,
8817
+ disabled,
8818
+ onToggle
8819
+ }) {
8820
+ const selected = new Set(value[eye]);
8821
+ const tier = riskTierForCount(selected.size);
8822
+ return /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
8823
+ /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center justify-between gap-2", children: [
8824
+ /* @__PURE__ */ jsx("div", { className: "text-xs font-semibold text-foreground", children: eye === "OD" ? "Right Eye (OD)" : "Left Eye (OS)" }),
8825
+ /* @__PURE__ */ jsxs(
8826
+ "span",
8827
+ {
8828
+ className: cn(
8829
+ "whitespace-nowrap rounded-full px-2 py-0.5 text-[11px] font-medium",
8830
+ tierBadgeClass(tier)
8831
+ ),
8832
+ children: [
8833
+ tier,
8834
+ " risk"
8835
+ ]
8836
+ }
8837
+ )
8838
+ ] }),
8839
+ /* @__PURE__ */ jsx("div", { className: "space-y-1.5", children: RISKS.map((r) => /* @__PURE__ */ jsxs(
8840
+ "label",
8841
+ {
8842
+ className: "flex cursor-pointer items-center gap-2 rounded px-2 py-1 text-xs hover:bg-muted/50",
8843
+ children: [
8844
+ /* @__PURE__ */ jsx(
8845
+ "input",
8846
+ {
8847
+ type: "checkbox",
8848
+ className: "shrink-0",
8849
+ checked: selected.has(r),
8850
+ disabled,
8851
+ onChange: () => onToggle(eye, r)
8852
+ }
8853
+ ),
8854
+ /* @__PURE__ */ jsx("span", { children: r })
8855
+ ]
8856
+ },
8857
+ r
8858
+ )) })
8859
+ ] });
8860
+ }
8861
+ var SurgicalRiskFlagsWidget = ({ fieldId }) => {
8862
+ const { fieldDef, value, setValue, error, disabled, touched } = useField(fieldId);
8863
+ const { state } = useForm();
8864
+ const showError = !!error && (touched || state.submitAttempted);
8865
+ if (!fieldDef || fieldDef.type !== "surgical_risk_flags") {
8866
+ return null;
8867
+ }
8868
+ const def = fieldDef;
8869
+ const v = parseValue3(value);
8870
+ const title = def.meta?.cardTitle?.trim() || (def.label?.trim() ? def.label : DEFAULT_TITLE4);
8871
+ const toggleRisk = (eye, risk) => {
8872
+ const next = {
8873
+ OD: [...v.OD],
8874
+ OS: [...v.OS]
8875
+ };
8876
+ if (risk === DIABETES) {
8877
+ const had = next.OD.includes(DIABETES) || next.OS.includes(DIABETES);
8878
+ if (had) {
8879
+ next.OD = next.OD.filter((x) => x !== DIABETES);
8880
+ next.OS = next.OS.filter((x) => x !== DIABETES);
8881
+ } else {
8882
+ if (!next.OD.includes(DIABETES)) next.OD.push(DIABETES);
8883
+ if (!next.OS.includes(DIABETES)) next.OS.push(DIABETES);
8884
+ }
8885
+ setValue(next);
8886
+ return;
8887
+ }
8888
+ const list = next[eye];
8889
+ const i = list.indexOf(risk);
8890
+ if (i === -1) list.push(risk);
8891
+ else list.splice(i, 1);
8892
+ setValue(next);
8893
+ };
8894
+ return /* @__PURE__ */ jsxs(
8895
+ "div",
8896
+ {
8897
+ id: `surgical-risk-flags-${fieldId}`,
8898
+ className: "w-full min-w-0 max-w-full rounded-lg border border-border bg-card p-3 text-card-foreground shadow-sm",
8899
+ children: [
8900
+ /* @__PURE__ */ jsx("h3", { className: "mb-3 text-sm font-semibold leading-tight text-foreground", children: title }),
8901
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-6", children: [
8902
+ /* @__PURE__ */ jsx(RiskCol, { eye: "OD", value: v, disabled, onToggle: toggleRisk }),
8903
+ /* @__PURE__ */ jsx("div", { className: "w-px shrink-0 bg-border", "aria-hidden": true }),
8904
+ /* @__PURE__ */ jsx(RiskCol, { eye: "OS", value: v, disabled, onToggle: toggleRisk })
8905
+ ] }),
8906
+ def.description && /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: def.description }),
8907
+ showError && /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-red-500", children: error })
8908
+ ]
8909
+ }
8910
+ );
8911
+ };
7852
8912
  var FieldRenderer = ({ fieldId }) => {
7853
8913
  const { fieldDef, visible } = useField(fieldId);
7854
8914
  if (!visible || !fieldDef) {
@@ -7940,6 +9000,17 @@ function renderWidget(fieldId, fieldDef) {
7940
9000
  /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium leading-none cursor-pointer select-none", children: fieldDef.label })
7941
9001
  ] });
7942
9002
  }
9003
+ case "suggestion_textarea":
9004
+ case "complaint_chips":
9005
+ return /* @__PURE__ */ jsx(SuggestionTextareaWidget, { fieldId });
9006
+ case "lens_assessment":
9007
+ return /* @__PURE__ */ jsx(LensAssessmentWidget, { fieldId });
9008
+ case "functional_impairment_score":
9009
+ return /* @__PURE__ */ jsx(FunctionalImpairmentScoreWidget, { fieldId });
9010
+ case "biometry_iol_workup":
9011
+ return /* @__PURE__ */ jsx(BiometryIolWorkupWidget, { fieldId });
9012
+ case "surgical_risk_flags":
9013
+ return /* @__PURE__ */ jsx(SurgicalRiskFlagsWidget, { fieldId });
7943
9014
  case "static_text": {
7944
9015
  const def = fieldDef;
7945
9016
  const size = def.size ?? "regular";
@@ -8640,6 +9711,84 @@ var ReadOnlyFieldRenderer = ({ fieldDef, value }) => {
8640
9711
  /* @__PURE__ */ jsx("span", { className: `inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${isOn ? "bg-green-100 text-green-800" : "bg-gray-100 text-gray-600"}`, children: isOn ? "Yes" : "No" })
8641
9712
  ] });
8642
9713
  }
9714
+ case "suggestion_textarea":
9715
+ case "complaint_chips":
9716
+ return /* @__PURE__ */ jsx(ReadOnlyText, { fieldDef, value });
9717
+ case "lens_assessment": {
9718
+ const v = value && typeof value === "object" && !Array.isArray(value) ? value : null;
9719
+ const notes = typeof v?.notes === "string" ? v.notes : "";
9720
+ const key = typeof v?.assessmentKey === "string" ? v.assessmentKey : null;
9721
+ const locs = v?.locs;
9722
+ const locsRecord = locs != null && typeof locs === "object" && !Array.isArray(locs) ? locs : null;
9723
+ const eyeLine = (label, g) => {
9724
+ if (!g || typeof g !== "object") return null;
9725
+ const num = (k) => typeof g[k] === "number" ? g[k] : "\u2014";
9726
+ return /* @__PURE__ */ jsxs("p", { className: "text-xs text-foreground", children: [
9727
+ label,
9728
+ ": NO ",
9729
+ String(num("NO")),
9730
+ ", NC ",
9731
+ String(num("NC")),
9732
+ ", C ",
9733
+ String(num("C")),
9734
+ ", PSC",
9735
+ " ",
9736
+ String(num("PSC"))
9737
+ ] });
9738
+ };
9739
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-2 rounded-md border p-3 text-sm", children: [
9740
+ fieldDef.label && /* @__PURE__ */ jsx("p", { className: "font-medium text-foreground", children: fieldDef.label }),
9741
+ locsRecord ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 border-l-2 border-muted pl-2", children: [
9742
+ eyeLine("Right (OD)", locsRecord.OD),
9743
+ eyeLine("Left (OS)", locsRecord.OS)
9744
+ ] }) : null,
9745
+ key && /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
9746
+ "Assessment (legacy): ",
9747
+ key
9748
+ ] }),
9749
+ notes && /* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap text-foreground", children: notes })
9750
+ ] });
9751
+ }
9752
+ case "functional_impairment_score": {
9753
+ const v = parseFunctionalImpairmentScore(value);
9754
+ const total = functionalImpairmentTotal(v);
9755
+ const lines = [
9756
+ `Reading: ${v.reading}`,
9757
+ `Night driving: ${v.nightDriving}`,
9758
+ `Glare: ${v.glare}`,
9759
+ `Occupation: ${v.occupation}`,
9760
+ `ADL: ${v.adl}`,
9761
+ `Total: ${total}/15`
9762
+ ].join("\n");
9763
+ return /* @__PURE__ */ jsx(ReadOnlyText, { fieldDef, value: lines });
9764
+ }
9765
+ case "biometry_iol_workup": {
9766
+ const v = value && typeof value === "object" && !Array.isArray(value) ? value : {};
9767
+ const s = (k) => typeof v[k] === "string" ? v[k] : "";
9768
+ const b = (k) => v[k] === true;
9769
+ const method = v.method === "ascan_immersion" ? "A-scan (immersion)" : v.method === "ascan_contact" ? "A-scan (contact)" : "Optical biometry (IOL Master)";
9770
+ const lines = [
9771
+ `Axial length OD/OS (mm): ${s("axialLengthOD")} / ${s("axialLengthOS")}`,
9772
+ `K1/K2/Axis OD/OS: ${s("k1k2AxisOD")} / ${s("k1k2AxisOS")}`,
9773
+ `AC depth OD/OS (mm): ${s("anteriorChamberDepthOD")} / ${s("anteriorChamberDepthOS")}`,
9774
+ `IOL power (D) OD/OS: ${s("iolPowerOD")} / ${s("iolPowerOS")}`,
9775
+ `Target refraction (D) OD/OS: ${s("targetRefractionOD")} / ${s("targetRefractionOS")}`,
9776
+ `Formula: ${s("formula") || "\u2014"}`,
9777
+ `Method: ${method}`,
9778
+ `Corneal topography uploaded: ${b("cornealTopoUploaded") ? "Yes" : "No"}`,
9779
+ `Specular microscopy: ${b("specularMicroscopyDone") ? "Yes" : "No"}`,
9780
+ `Endothelial count: ${s("endothelialCount") || "\u2014"}`
9781
+ ].join("\n");
9782
+ return /* @__PURE__ */ jsx(ReadOnlyText, { fieldDef, value: lines });
9783
+ }
9784
+ case "surgical_risk_flags": {
9785
+ const v = value && typeof value === "object" && !Array.isArray(value) ? value : null;
9786
+ const list = (x) => Array.isArray(x) ? x.filter((i) => typeof i === "string").join(", ") : "\u2014";
9787
+ const od = list(v?.OD);
9788
+ const os = list(v?.OS);
9789
+ const lines = [`Right eye (OD): ${od}`, `Left eye (OS): ${os}`].join("\n");
9790
+ return /* @__PURE__ */ jsx(ReadOnlyText, { fieldDef, value: lines });
9791
+ }
8643
9792
  case "static_text": {
8644
9793
  const def = fieldDef;
8645
9794
  const size = def.size ?? "regular";