formanitor 0.0.37 → 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
  });
@@ -6065,6 +6117,12 @@ var tableCellClass = "border border-[#E0E0E0] px-1.5 py-1 text-center align-midd
6065
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";
6066
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";
6067
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";
6068
6126
  var OphthalmologyWidget = ({ fieldId }) => {
6069
6127
  const { fieldDef, value, setValue, disabled } = useField(fieldId);
6070
6128
  const safe = useMemo(() => ensureValue(value), [value]);
@@ -6296,34 +6354,45 @@ var OphthalmologyWidget = ({ fieldId }) => {
6296
6354
  ] }),
6297
6355
  /* @__PURE__ */ jsxs("section", { className: sectionWrapperClass, children: [
6298
6356
  /* @__PURE__ */ jsx("div", { className: sectionHeaderClass, children: /* @__PURE__ */ jsx("span", { children: "Current Glass Prescription" }) }),
6299
- /* @__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
+ ] }),
6300
6369
  /* @__PURE__ */ jsxs("thead", { children: [
6301
6370
  /* @__PURE__ */ jsxs("tr", { children: [
6302
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass }),
6303
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, colSpan: 4, children: "Right Eye" }),
6304
- /* @__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" })
6305
6374
  ] }),
6306
6375
  /* @__PURE__ */ jsxs("tr", { children: [
6307
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass }),
6308
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6309
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6310
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6311
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
6312
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6313
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6314
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6315
- /* @__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" })
6316
6385
  ] })
6317
6386
  ] }),
6318
6387
  /* @__PURE__ */ jsx("tbody", { children: /* @__PURE__ */ jsxs("tr", { children: [
6319
- /* @__PURE__ */ jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Current Glass" }),
6320
- /* @__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(
6321
6390
  Input,
6322
6391
  {
6323
6392
  disabled,
6324
6393
  type: "number",
6325
6394
  step: "0.25",
6326
- className: numberInputClass,
6395
+ className: refractionInputClass,
6327
6396
  value: safe.current_glass_prescription.right_eye.sph ?? "",
6328
6397
  onChange: (e) => setRefractionField(
6329
6398
  "current_glass_prescription",
@@ -6334,13 +6403,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6334
6403
  )
6335
6404
  }
6336
6405
  ) }),
6337
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6406
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6338
6407
  Input,
6339
6408
  {
6340
6409
  disabled,
6341
6410
  type: "number",
6342
6411
  step: "0.25",
6343
- className: numberInputClass,
6412
+ className: refractionInputClass,
6344
6413
  value: safe.current_glass_prescription.right_eye.cyl ?? "",
6345
6414
  onChange: (e) => setRefractionField(
6346
6415
  "current_glass_prescription",
@@ -6351,12 +6420,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6351
6420
  )
6352
6421
  }
6353
6422
  ) }),
6354
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6423
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6355
6424
  Input,
6356
6425
  {
6357
6426
  disabled,
6358
6427
  type: "number",
6359
- className: numberInputClass,
6428
+ className: refractionInputClass,
6360
6429
  value: safe.current_glass_prescription.right_eye.axis ?? "",
6361
6430
  onChange: (e) => setRefractionField(
6362
6431
  "current_glass_prescription",
@@ -6367,11 +6436,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6367
6436
  )
6368
6437
  }
6369
6438
  ) }),
6370
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6439
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6371
6440
  "select",
6372
6441
  {
6373
6442
  disabled,
6374
- className: selectClass,
6443
+ className: refractionSelectClass,
6375
6444
  value: safe.current_glass_prescription.right_eye.va,
6376
6445
  onChange: (e) => setRefractionField(
6377
6446
  "current_glass_prescription",
@@ -6383,13 +6452,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6383
6452
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsx("option", { value: opt, children: opt }, opt || "blank"))
6384
6453
  }
6385
6454
  ) }),
6386
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6455
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6387
6456
  Input,
6388
6457
  {
6389
6458
  disabled,
6390
6459
  type: "number",
6391
6460
  step: "0.25",
6392
- className: numberInputClass,
6461
+ className: refractionInputClass,
6393
6462
  value: safe.current_glass_prescription.left_eye.sph ?? "",
6394
6463
  onChange: (e) => setRefractionField(
6395
6464
  "current_glass_prescription",
@@ -6400,13 +6469,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6400
6469
  )
6401
6470
  }
6402
6471
  ) }),
6403
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6472
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6404
6473
  Input,
6405
6474
  {
6406
6475
  disabled,
6407
6476
  type: "number",
6408
6477
  step: "0.25",
6409
- className: numberInputClass,
6478
+ className: refractionInputClass,
6410
6479
  value: safe.current_glass_prescription.left_eye.cyl ?? "",
6411
6480
  onChange: (e) => setRefractionField(
6412
6481
  "current_glass_prescription",
@@ -6417,12 +6486,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6417
6486
  )
6418
6487
  }
6419
6488
  ) }),
6420
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6489
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6421
6490
  Input,
6422
6491
  {
6423
6492
  disabled,
6424
6493
  type: "number",
6425
- className: numberInputClass,
6494
+ className: refractionInputClass,
6426
6495
  value: safe.current_glass_prescription.left_eye.axis ?? "",
6427
6496
  onChange: (e) => setRefractionField(
6428
6497
  "current_glass_prescription",
@@ -6433,11 +6502,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6433
6502
  )
6434
6503
  }
6435
6504
  ) }),
6436
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6505
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6437
6506
  "select",
6438
6507
  {
6439
6508
  disabled,
6440
- className: selectClass,
6509
+ className: refractionSelectClass,
6441
6510
  value: safe.current_glass_prescription.left_eye.va,
6442
6511
  onChange: (e) => setRefractionField(
6443
6512
  "current_glass_prescription",
@@ -6546,37 +6615,50 @@ var OphthalmologyWidget = ({ fieldId }) => {
6546
6615
  ] }),
6547
6616
  /* @__PURE__ */ jsxs("section", { className: sectionWrapperClass, children: [
6548
6617
  /* @__PURE__ */ jsx("div", { className: sectionHeaderClass, children: /* @__PURE__ */ jsx("span", { children: "Refraction (Distance)" }) }),
6549
- /* @__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
+ ] }),
6550
6632
  /* @__PURE__ */ jsxs("thead", { children: [
6551
6633
  /* @__PURE__ */ jsxs("tr", { children: [
6552
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass }),
6553
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Right Eye" }),
6554
- /* @__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" })
6555
6637
  ] }),
6556
6638
  /* @__PURE__ */ jsxs("tr", { children: [
6557
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass }),
6558
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6559
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6560
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6561
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
6562
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "P/D" }),
6563
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6564
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6565
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6566
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
6567
- /* @__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" })
6568
6650
  ] })
6569
6651
  ] }),
6570
6652
  /* @__PURE__ */ jsxs("tbody", { children: [
6571
6653
  /* @__PURE__ */ jsxs("tr", { children: [
6572
- /* @__PURE__ */ jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Distance" }),
6573
- /* @__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(
6574
6656
  Input,
6575
6657
  {
6576
6658
  disabled,
6577
6659
  type: "number",
6578
6660
  step: "0.25",
6579
- className: numberInputClass,
6661
+ className: refractionInputClass,
6580
6662
  value: safe.refraction.right_eye.sph ?? "",
6581
6663
  onChange: (e) => setRefractionField(
6582
6664
  "refraction",
@@ -6587,13 +6669,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6587
6669
  )
6588
6670
  }
6589
6671
  ) }),
6590
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6672
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6591
6673
  Input,
6592
6674
  {
6593
6675
  disabled,
6594
6676
  type: "number",
6595
6677
  step: "0.25",
6596
- className: numberInputClass,
6678
+ className: refractionInputClass,
6597
6679
  value: safe.refraction.right_eye.cyl ?? "",
6598
6680
  onChange: (e) => setRefractionField(
6599
6681
  "refraction",
@@ -6604,12 +6686,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6604
6686
  )
6605
6687
  }
6606
6688
  ) }),
6607
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6689
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6608
6690
  Input,
6609
6691
  {
6610
6692
  disabled,
6611
6693
  type: "number",
6612
- className: numberInputClass,
6694
+ className: refractionInputClass,
6613
6695
  value: safe.refraction.right_eye.axis ?? "",
6614
6696
  onChange: (e) => setRefractionField(
6615
6697
  "refraction",
@@ -6620,11 +6702,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6620
6702
  )
6621
6703
  }
6622
6704
  ) }),
6623
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6705
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6624
6706
  "select",
6625
6707
  {
6626
6708
  disabled,
6627
- className: selectClass,
6709
+ className: refractionSelectClass,
6628
6710
  value: safe.refraction.right_eye.va,
6629
6711
  onChange: (e) => setRefractionField(
6630
6712
  "refraction",
@@ -6636,7 +6718,7 @@ var OphthalmologyWidget = ({ fieldId }) => {
6636
6718
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsx("option", { value: opt, children: opt }, opt || "blank"))
6637
6719
  }
6638
6720
  ) }),
6639
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6721
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6640
6722
  Input,
6641
6723
  {
6642
6724
  disabled,
@@ -6644,18 +6726,18 @@ var OphthalmologyWidget = ({ fieldId }) => {
6644
6726
  min: 10,
6645
6727
  max: 45,
6646
6728
  step: "1",
6647
- className: numberInputClass,
6729
+ className: refractionInputClass,
6648
6730
  value: safe.refraction.right_eye.pd ?? "",
6649
6731
  onChange: (e) => setRefractionField("refraction", "right_eye", "pd", e.target.value, "int")
6650
6732
  }
6651
6733
  ) }),
6652
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6734
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6653
6735
  Input,
6654
6736
  {
6655
6737
  disabled,
6656
6738
  type: "number",
6657
6739
  step: "0.25",
6658
- className: numberInputClass,
6740
+ className: refractionInputClass,
6659
6741
  value: safe.refraction.left_eye.sph ?? "",
6660
6742
  onChange: (e) => setRefractionField(
6661
6743
  "refraction",
@@ -6666,13 +6748,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6666
6748
  )
6667
6749
  }
6668
6750
  ) }),
6669
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6751
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6670
6752
  Input,
6671
6753
  {
6672
6754
  disabled,
6673
6755
  type: "number",
6674
6756
  step: "0.25",
6675
- className: numberInputClass,
6757
+ className: refractionInputClass,
6676
6758
  value: safe.refraction.left_eye.cyl ?? "",
6677
6759
  onChange: (e) => setRefractionField(
6678
6760
  "refraction",
@@ -6683,12 +6765,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6683
6765
  )
6684
6766
  }
6685
6767
  ) }),
6686
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6768
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6687
6769
  Input,
6688
6770
  {
6689
6771
  disabled,
6690
6772
  type: "number",
6691
- className: numberInputClass,
6773
+ className: refractionInputClass,
6692
6774
  value: safe.refraction.left_eye.axis ?? "",
6693
6775
  onChange: (e) => setRefractionField(
6694
6776
  "refraction",
@@ -6699,11 +6781,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6699
6781
  )
6700
6782
  }
6701
6783
  ) }),
6702
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6784
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6703
6785
  "select",
6704
6786
  {
6705
6787
  disabled,
6706
- className: selectClass,
6788
+ className: refractionSelectClass,
6707
6789
  value: safe.refraction.left_eye.va,
6708
6790
  onChange: (e) => setRefractionField(
6709
6791
  "refraction",
@@ -6715,7 +6797,7 @@ var OphthalmologyWidget = ({ fieldId }) => {
6715
6797
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsx("option", { value: opt, children: opt }, opt || "blank"))
6716
6798
  }
6717
6799
  ) }),
6718
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6800
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6719
6801
  Input,
6720
6802
  {
6721
6803
  disabled,
@@ -6723,32 +6805,32 @@ var OphthalmologyWidget = ({ fieldId }) => {
6723
6805
  min: 10,
6724
6806
  max: 45,
6725
6807
  step: "1",
6726
- className: numberInputClass,
6808
+ className: refractionInputClass,
6727
6809
  value: safe.refraction.left_eye.pd ?? "",
6728
6810
  onChange: (e) => setRefractionField("refraction", "left_eye", "pd", e.target.value, "int")
6729
6811
  }
6730
6812
  ) })
6731
6813
  ] }),
6732
6814
  /* @__PURE__ */ jsxs("tr", { children: [
6733
- /* @__PURE__ */ jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Add" }),
6734
- /* @__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(
6735
6817
  Input,
6736
6818
  {
6737
6819
  disabled,
6738
6820
  type: "number",
6739
6821
  step: "0.25",
6740
- className: numberInputClass,
6822
+ className: refractionInputClass,
6741
6823
  value: safe.refraction.add.right ?? "",
6742
6824
  onChange: (e) => setRefractionAdd("refraction", "right", e.target.value)
6743
6825
  }
6744
6826
  ) }),
6745
- /* @__PURE__ */ jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsx(
6827
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsx(
6746
6828
  Input,
6747
6829
  {
6748
6830
  disabled,
6749
6831
  type: "number",
6750
6832
  step: "0.25",
6751
- className: numberInputClass,
6833
+ className: refractionInputClass,
6752
6834
  value: safe.refraction.add.left ?? "",
6753
6835
  onChange: (e) => setRefractionAdd("refraction", "left", e.target.value)
6754
6836
  }
@@ -6759,37 +6841,50 @@ var OphthalmologyWidget = ({ fieldId }) => {
6759
6841
  ] }),
6760
6842
  /* @__PURE__ */ jsxs("section", { className: sectionWrapperClass, children: [
6761
6843
  /* @__PURE__ */ jsx("div", { className: sectionHeaderClass, children: /* @__PURE__ */ jsx("span", { children: "Dilated Refraction" }) }),
6762
- /* @__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
+ ] }),
6763
6858
  /* @__PURE__ */ jsxs("thead", { children: [
6764
6859
  /* @__PURE__ */ jsxs("tr", { children: [
6765
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass }),
6766
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Right Eye" }),
6767
- /* @__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" })
6768
6863
  ] }),
6769
6864
  /* @__PURE__ */ jsxs("tr", { children: [
6770
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass }),
6771
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6772
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6773
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6774
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Prism" }),
6775
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
6776
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6777
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6778
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6779
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Prism" }),
6780
- /* @__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" })
6781
6876
  ] })
6782
6877
  ] }),
6783
6878
  /* @__PURE__ */ jsxs("tbody", { children: [
6784
6879
  /* @__PURE__ */ jsxs("tr", { children: [
6785
- /* @__PURE__ */ jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Dilated" }),
6786
- /* @__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(
6787
6882
  Input,
6788
6883
  {
6789
6884
  disabled,
6790
6885
  type: "number",
6791
6886
  step: "0.25",
6792
- className: numberInputClass,
6887
+ className: refractionInputClass,
6793
6888
  value: safe.dilated_refraction.right_eye.sph ?? "",
6794
6889
  onChange: (e) => setRefractionField(
6795
6890
  "dilated_refraction",
@@ -6800,13 +6895,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6800
6895
  )
6801
6896
  }
6802
6897
  ) }),
6803
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6898
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6804
6899
  Input,
6805
6900
  {
6806
6901
  disabled,
6807
6902
  type: "number",
6808
6903
  step: "0.25",
6809
- className: numberInputClass,
6904
+ className: refractionInputClass,
6810
6905
  value: safe.dilated_refraction.right_eye.cyl ?? "",
6811
6906
  onChange: (e) => setRefractionField(
6812
6907
  "dilated_refraction",
@@ -6817,12 +6912,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6817
6912
  )
6818
6913
  }
6819
6914
  ) }),
6820
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6915
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6821
6916
  Input,
6822
6917
  {
6823
6918
  disabled,
6824
6919
  type: "number",
6825
- className: numberInputClass,
6920
+ className: refractionInputClass,
6826
6921
  value: safe.dilated_refraction.right_eye.axis ?? "",
6827
6922
  onChange: (e) => setRefractionField(
6828
6923
  "dilated_refraction",
@@ -6833,13 +6928,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6833
6928
  )
6834
6929
  }
6835
6930
  ) }),
6836
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6931
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6837
6932
  Input,
6838
6933
  {
6839
6934
  disabled,
6840
6935
  type: "number",
6841
6936
  step: "0.25",
6842
- className: numberInputClass,
6937
+ className: refractionInputClass,
6843
6938
  value: safe.dilated_refraction.right_eye.prism ?? "",
6844
6939
  onChange: (e) => setRefractionField(
6845
6940
  "dilated_refraction",
@@ -6850,11 +6945,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6850
6945
  )
6851
6946
  }
6852
6947
  ) }),
6853
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6948
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6854
6949
  "select",
6855
6950
  {
6856
6951
  disabled,
6857
- className: selectClass,
6952
+ className: refractionSelectClass,
6858
6953
  value: safe.dilated_refraction.right_eye.va,
6859
6954
  onChange: (e) => setRefractionField(
6860
6955
  "dilated_refraction",
@@ -6866,13 +6961,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6866
6961
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsx("option", { value: opt, children: opt }, opt || "blank"))
6867
6962
  }
6868
6963
  ) }),
6869
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6964
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6870
6965
  Input,
6871
6966
  {
6872
6967
  disabled,
6873
6968
  type: "number",
6874
6969
  step: "0.25",
6875
- className: numberInputClass,
6970
+ className: refractionInputClass,
6876
6971
  value: safe.dilated_refraction.left_eye.sph ?? "",
6877
6972
  onChange: (e) => setRefractionField(
6878
6973
  "dilated_refraction",
@@ -6883,13 +6978,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6883
6978
  )
6884
6979
  }
6885
6980
  ) }),
6886
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6981
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6887
6982
  Input,
6888
6983
  {
6889
6984
  disabled,
6890
6985
  type: "number",
6891
6986
  step: "0.25",
6892
- className: numberInputClass,
6987
+ className: refractionInputClass,
6893
6988
  value: safe.dilated_refraction.left_eye.cyl ?? "",
6894
6989
  onChange: (e) => setRefractionField(
6895
6990
  "dilated_refraction",
@@ -6900,12 +6995,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6900
6995
  )
6901
6996
  }
6902
6997
  ) }),
6903
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
6998
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6904
6999
  Input,
6905
7000
  {
6906
7001
  disabled,
6907
7002
  type: "number",
6908
- className: numberInputClass,
7003
+ className: refractionInputClass,
6909
7004
  value: safe.dilated_refraction.left_eye.axis ?? "",
6910
7005
  onChange: (e) => setRefractionField(
6911
7006
  "dilated_refraction",
@@ -6916,13 +7011,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6916
7011
  )
6917
7012
  }
6918
7013
  ) }),
6919
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7014
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6920
7015
  Input,
6921
7016
  {
6922
7017
  disabled,
6923
7018
  type: "number",
6924
7019
  step: "0.25",
6925
- className: numberInputClass,
7020
+ className: refractionInputClass,
6926
7021
  value: safe.dilated_refraction.left_eye.prism ?? "",
6927
7022
  onChange: (e) => setRefractionField(
6928
7023
  "dilated_refraction",
@@ -6933,11 +7028,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6933
7028
  )
6934
7029
  }
6935
7030
  ) }),
6936
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7031
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
6937
7032
  "select",
6938
7033
  {
6939
7034
  disabled,
6940
- className: selectClass,
7035
+ className: refractionSelectClass,
6941
7036
  value: safe.dilated_refraction.left_eye.va,
6942
7037
  onChange: (e) => setRefractionField(
6943
7038
  "dilated_refraction",
@@ -6951,25 +7046,25 @@ var OphthalmologyWidget = ({ fieldId }) => {
6951
7046
  ) })
6952
7047
  ] }),
6953
7048
  /* @__PURE__ */ jsxs("tr", { children: [
6954
- /* @__PURE__ */ jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Add" }),
6955
- /* @__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(
6956
7051
  Input,
6957
7052
  {
6958
7053
  disabled,
6959
7054
  type: "number",
6960
7055
  step: "0.25",
6961
- className: numberInputClass,
7056
+ className: refractionInputClass,
6962
7057
  value: safe.dilated_refraction.add.right ?? "",
6963
7058
  onChange: (e) => setRefractionAdd("dilated_refraction", "right", e.target.value)
6964
7059
  }
6965
7060
  ) }),
6966
- /* @__PURE__ */ jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsx(
7061
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsx(
6967
7062
  Input,
6968
7063
  {
6969
7064
  disabled,
6970
7065
  type: "number",
6971
7066
  step: "0.25",
6972
- className: numberInputClass,
7067
+ className: refractionInputClass,
6973
7068
  value: safe.dilated_refraction.add.left ?? "",
6974
7069
  onChange: (e) => setRefractionAdd("dilated_refraction", "left", e.target.value)
6975
7070
  }
@@ -6980,37 +7075,50 @@ var OphthalmologyWidget = ({ fieldId }) => {
6980
7075
  ] }),
6981
7076
  /* @__PURE__ */ jsxs("section", { className: sectionWrapperClass, children: [
6982
7077
  /* @__PURE__ */ jsx("div", { className: sectionHeaderClass, children: /* @__PURE__ */ jsx("span", { children: "Glass Power Prescription" }) }),
6983
- /* @__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
+ ] }),
6984
7092
  /* @__PURE__ */ jsxs("thead", { children: [
6985
7093
  /* @__PURE__ */ jsxs("tr", { children: [
6986
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass }),
6987
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Right Eye" }),
6988
- /* @__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" })
6989
7097
  ] }),
6990
7098
  /* @__PURE__ */ jsxs("tr", { children: [
6991
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass }),
6992
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6993
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6994
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6995
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Prism" }),
6996
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
6997
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6998
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6999
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
7000
- /* @__PURE__ */ jsx("th", { className: tableHeaderCellClass, children: "Prism" }),
7001
- /* @__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" })
7002
7110
  ] })
7003
7111
  ] }),
7004
7112
  /* @__PURE__ */ jsxs("tbody", { children: [
7005
7113
  /* @__PURE__ */ jsxs("tr", { children: [
7006
- /* @__PURE__ */ jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Glass Power" }),
7007
- /* @__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(
7008
7116
  Input,
7009
7117
  {
7010
7118
  disabled,
7011
7119
  type: "number",
7012
7120
  step: "0.25",
7013
- className: numberInputClass,
7121
+ className: refractionInputClass,
7014
7122
  value: safe.glass_power_prescription.right_eye.sph ?? "",
7015
7123
  onChange: (e) => setRefractionField(
7016
7124
  "glass_power_prescription",
@@ -7021,13 +7129,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
7021
7129
  )
7022
7130
  }
7023
7131
  ) }),
7024
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7132
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
7025
7133
  Input,
7026
7134
  {
7027
7135
  disabled,
7028
7136
  type: "number",
7029
7137
  step: "0.25",
7030
- className: numberInputClass,
7138
+ className: refractionInputClass,
7031
7139
  value: safe.glass_power_prescription.right_eye.cyl ?? "",
7032
7140
  onChange: (e) => setRefractionField(
7033
7141
  "glass_power_prescription",
@@ -7038,12 +7146,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
7038
7146
  )
7039
7147
  }
7040
7148
  ) }),
7041
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7149
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
7042
7150
  Input,
7043
7151
  {
7044
7152
  disabled,
7045
7153
  type: "number",
7046
- className: numberInputClass,
7154
+ className: refractionInputClass,
7047
7155
  value: safe.glass_power_prescription.right_eye.axis ?? "",
7048
7156
  onChange: (e) => setRefractionField(
7049
7157
  "glass_power_prescription",
@@ -7054,13 +7162,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
7054
7162
  )
7055
7163
  }
7056
7164
  ) }),
7057
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7165
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
7058
7166
  Input,
7059
7167
  {
7060
7168
  disabled,
7061
7169
  type: "number",
7062
7170
  step: "0.25",
7063
- className: numberInputClass,
7171
+ className: refractionInputClass,
7064
7172
  value: safe.glass_power_prescription.right_eye.prism ?? "",
7065
7173
  onChange: (e) => setRefractionField(
7066
7174
  "glass_power_prescription",
@@ -7071,11 +7179,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
7071
7179
  )
7072
7180
  }
7073
7181
  ) }),
7074
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7182
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
7075
7183
  "select",
7076
7184
  {
7077
7185
  disabled,
7078
- className: selectClass,
7186
+ className: refractionSelectClass,
7079
7187
  value: safe.glass_power_prescription.right_eye.va,
7080
7188
  onChange: (e) => setRefractionField(
7081
7189
  "glass_power_prescription",
@@ -7087,13 +7195,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
7087
7195
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsx("option", { value: opt, children: opt }, opt || "blank"))
7088
7196
  }
7089
7197
  ) }),
7090
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7198
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
7091
7199
  Input,
7092
7200
  {
7093
7201
  disabled,
7094
7202
  type: "number",
7095
7203
  step: "0.25",
7096
- className: numberInputClass,
7204
+ className: refractionInputClass,
7097
7205
  value: safe.glass_power_prescription.left_eye.sph ?? "",
7098
7206
  onChange: (e) => setRefractionField(
7099
7207
  "glass_power_prescription",
@@ -7104,13 +7212,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
7104
7212
  )
7105
7213
  }
7106
7214
  ) }),
7107
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7215
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
7108
7216
  Input,
7109
7217
  {
7110
7218
  disabled,
7111
7219
  type: "number",
7112
7220
  step: "0.25",
7113
- className: numberInputClass,
7221
+ className: refractionInputClass,
7114
7222
  value: safe.glass_power_prescription.left_eye.cyl ?? "",
7115
7223
  onChange: (e) => setRefractionField(
7116
7224
  "glass_power_prescription",
@@ -7121,12 +7229,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
7121
7229
  )
7122
7230
  }
7123
7231
  ) }),
7124
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7232
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
7125
7233
  Input,
7126
7234
  {
7127
7235
  disabled,
7128
7236
  type: "number",
7129
- className: numberInputClass,
7237
+ className: refractionInputClass,
7130
7238
  value: safe.glass_power_prescription.left_eye.axis ?? "",
7131
7239
  onChange: (e) => setRefractionField(
7132
7240
  "glass_power_prescription",
@@ -7137,13 +7245,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
7137
7245
  )
7138
7246
  }
7139
7247
  ) }),
7140
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7248
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
7141
7249
  Input,
7142
7250
  {
7143
7251
  disabled,
7144
7252
  type: "number",
7145
7253
  step: "0.25",
7146
- className: numberInputClass,
7254
+ className: refractionInputClass,
7147
7255
  value: safe.glass_power_prescription.left_eye.prism ?? "",
7148
7256
  onChange: (e) => setRefractionField(
7149
7257
  "glass_power_prescription",
@@ -7154,11 +7262,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
7154
7262
  )
7155
7263
  }
7156
7264
  ) }),
7157
- /* @__PURE__ */ jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsx(
7265
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsx(
7158
7266
  "select",
7159
7267
  {
7160
7268
  disabled,
7161
- className: selectClass,
7269
+ className: refractionSelectClass,
7162
7270
  value: safe.glass_power_prescription.left_eye.va,
7163
7271
  onChange: (e) => setRefractionField(
7164
7272
  "glass_power_prescription",
@@ -7172,25 +7280,25 @@ var OphthalmologyWidget = ({ fieldId }) => {
7172
7280
  ) })
7173
7281
  ] }),
7174
7282
  /* @__PURE__ */ jsxs("tr", { children: [
7175
- /* @__PURE__ */ jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Add" }),
7176
- /* @__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(
7177
7285
  Input,
7178
7286
  {
7179
7287
  disabled,
7180
7288
  type: "number",
7181
7289
  step: "0.25",
7182
- className: numberInputClass,
7290
+ className: refractionInputClass,
7183
7291
  value: safe.glass_power_prescription.add.right ?? "",
7184
7292
  onChange: (e) => setRefractionAdd("glass_power_prescription", "right", e.target.value)
7185
7293
  }
7186
7294
  ) }),
7187
- /* @__PURE__ */ jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsx(
7295
+ /* @__PURE__ */ jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsx(
7188
7296
  Input,
7189
7297
  {
7190
7298
  disabled,
7191
7299
  type: "number",
7192
7300
  step: "0.25",
7193
- className: numberInputClass,
7301
+ className: refractionInputClass,
7194
7302
  value: safe.glass_power_prescription.add.left ?? "",
7195
7303
  onChange: (e) => setRefractionAdd("glass_power_prescription", "left", e.target.value)
7196
7304
  }
@@ -7877,6 +7985,930 @@ var DischargeMedicationOrdersWidget = ({ fieldId }) => {
7877
7985
  showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
7878
7986
  ] });
7879
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
+ };
7880
8912
  var FieldRenderer = ({ fieldId }) => {
7881
8913
  const { fieldDef, visible } = useField(fieldId);
7882
8914
  if (!visible || !fieldDef) {
@@ -7968,6 +9000,17 @@ function renderWidget(fieldId, fieldDef) {
7968
9000
  /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium leading-none cursor-pointer select-none", children: fieldDef.label })
7969
9001
  ] });
7970
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 });
7971
9014
  case "static_text": {
7972
9015
  const def = fieldDef;
7973
9016
  const size = def.size ?? "regular";
@@ -8668,6 +9711,84 @@ var ReadOnlyFieldRenderer = ({ fieldDef, value }) => {
8668
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" })
8669
9712
  ] });
8670
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
+ }
8671
9792
  case "static_text": {
8672
9793
  const def = fieldDef;
8673
9794
  const size = def.size ?? "regular";