formanitor 0.0.37 → 0.0.39

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.cjs CHANGED
@@ -97,6 +97,15 @@ function validateField(value, field) {
97
97
  return `Must be at most ${rules.max}`;
98
98
  }
99
99
  }
100
+ if (field.type === "slider") {
101
+ const num = Number(value);
102
+ if (isNaN(num)) return "Must be a valid number";
103
+ const s = field;
104
+ const min = s.min ?? 0;
105
+ const max = s.max ?? 10;
106
+ if (num < min) return `Must be at least ${min}`;
107
+ if (num > max) return `Must be at most ${max}`;
108
+ }
100
109
  if (typeof value === "string") {
101
110
  if (rules.minLength !== void 0 && value.length < rules.minLength) {
102
111
  return `Must be at least ${rules.minLength} characters`;
@@ -129,6 +138,13 @@ function validateForm(values, fields) {
129
138
  }
130
139
 
131
140
  // src/core/rules.ts
141
+ function tokenListContainsString(text, needle) {
142
+ if (typeof text !== "string") return false;
143
+ const want = String(needle).trim();
144
+ if (!want) return false;
145
+ const parts = text.split(",").map((p) => p.trim()).filter(Boolean);
146
+ return parts.includes(want);
147
+ }
132
148
  function evaluateCondition(value, condition) {
133
149
  switch (condition.op) {
134
150
  case "==":
@@ -147,7 +163,13 @@ function evaluateCondition(value, condition) {
147
163
  case "in":
148
164
  return Array.isArray(condition.value) && condition.value.includes(value);
149
165
  case "contains":
150
- return Array.isArray(value) && value.includes(condition.value);
166
+ if (Array.isArray(value)) {
167
+ return value.includes(condition.value);
168
+ }
169
+ if (typeof value === "string") {
170
+ return tokenListContainsString(value, condition.value);
171
+ }
172
+ return false;
151
173
  default:
152
174
  return false;
153
175
  }
@@ -222,6 +244,227 @@ function applyPrefill(currentValues, fields, prefilledData = {}) {
222
244
  return newValues;
223
245
  }
224
246
 
247
+ // src/core/generalSurgeryPathway.ts
248
+ var defaultGeneralSurgerySmartHistory = () => ({
249
+ pain: {
250
+ site: "",
251
+ onset: "",
252
+ character: "",
253
+ radiation: "",
254
+ associated: "",
255
+ timing: "",
256
+ exacerbating: "",
257
+ severity: 0
258
+ },
259
+ swelling: { duration: "", sizeProgression: "", painfulPainless: "", checks: [] },
260
+ gi: { appetite: "", weightLoss: "", bowelHabits: "", checks: [] },
261
+ breast: { lumpDuration: "", nippleDischarge: "", checks: [] },
262
+ ano: { checks: [] },
263
+ thyroid: { swellingDuration: "", checks: [] },
264
+ systemic: ""
265
+ });
266
+ var defaultGeneralSurgeryExamination = () => ({
267
+ general: [],
268
+ regions: [],
269
+ abdomen: {
270
+ inspection: [],
271
+ palpation: [],
272
+ percussion: [],
273
+ massNotes: "",
274
+ bowelSounds: "none"
275
+ },
276
+ hernia: { site: "", reducible: false, coughImpulse: false, tenderness: false },
277
+ breast: { lumpSizeCm: "", mobile: false, skinInvolvement: false, axillaryNodes: false },
278
+ thyroid: { size: "", mobileDeglutition: false, nodules: false, cervicalNodes: false },
279
+ anorectal: { inspection: "", dreDone: false, proctoscopyDone: false, notes: "" },
280
+ limb: { dilatedVeins: false, ulcer: false, oedema: false }
281
+ });
282
+ var ALL_GS_CONDITIONS = [
283
+ "hernia",
284
+ "appendicitis",
285
+ "gallbladder",
286
+ "breast",
287
+ "thyroid",
288
+ "piles",
289
+ "varicose",
290
+ "ulcer"
291
+ ];
292
+ var defaultGeneralSurgeryGrading = () => ({
293
+ hernia: 0,
294
+ appendicitis: 0,
295
+ gallbladder: 0,
296
+ breast: 0,
297
+ thyroid: 0,
298
+ piles: 0,
299
+ varicose: 0,
300
+ ulcer: 0
301
+ });
302
+ var GS_CONDITION_TRIGGERS = {
303
+ hernia: { regions: ["hernia", "abdomen"], chips: ["swelling_lump", "obstruction"] },
304
+ appendicitis: { regions: ["abdomen"], chips: ["pain", "obstruction"] },
305
+ gallbladder: { regions: ["abdomen"], chips: ["pain"] },
306
+ breast: { regions: ["breast"], chips: ["breast", "swelling_lump"] },
307
+ thyroid: { regions: ["thyroid"], chips: ["thyroid", "swelling_lump"] },
308
+ piles: { regions: ["anorectal"], chips: ["anorectal", "bleeding"] },
309
+ varicose: { regions: ["limb"], chips: ["swelling_lump"] },
310
+ ulcer: { regions: ["limb", "anorectal"], chips: ["ulcer_wound", "discharge"] }
311
+ };
312
+ var GS_CONDITION_LABELS = {
313
+ hernia: "Hernia",
314
+ appendicitis: "Appendicitis",
315
+ gallbladder: "Gallbladder disease",
316
+ breast: "Breast lump (BIRADS)",
317
+ thyroid: "Thyroid nodule (TIRADS)",
318
+ piles: "Haemorrhoids",
319
+ varicose: "Varicose veins (CEAP)",
320
+ ulcer: "Ulcer / wound"
321
+ };
322
+ var GS_GRADE_DESCRIPTIONS = {
323
+ hernia: ["\u2014", "Small reducible", "Large reducible", "Irreducible", "Obstructed", "Strangulated"],
324
+ appendicitis: ["\u2014", "Mild (clinical)", "Confirmed (USG/CT)", "Complicated (mass)", "Abscess", "Perforation"],
325
+ gallbladder: ["\u2014", "Asymptomatic stones", "Symptomatic", "Acute cholecystitis", "Complicated (CBD stone)", "Perforation/empyema"],
326
+ breast: ["\u2014", "BIRADS 1 \u2014 Negative", "BIRADS 2 \u2014 Benign", "BIRADS 3 \u2014 Probably benign", "BIRADS 4 \u2014 Suspicious", "BIRADS 5 \u2014 Malignant"],
327
+ thyroid: ["\u2014", "TIRADS 1 \u2014 Normal", "TIRADS 2 \u2014 Benign", "TIRADS 3 \u2014 Indeterminate", "TIRADS 4 \u2014 Suspicious", "TIRADS 5 \u2014 Highly suspicious"],
328
+ piles: ["\u2014", "Grade 1", "Grade 2", "Grade 3", "Grade 4", "Grade 5"],
329
+ varicose: ["\u2014", "C1 telangiectasia", "C2 varicose", "C3 oedema", "C4 skin changes", "C5-C6 ulcer"],
330
+ ulcer: ["\u2014", "Superficial", "Deep", "Infected", "Necrotic", "Gangrene"]
331
+ };
332
+ function normalizeGeneralSurgerySmartHistory(raw) {
333
+ const d = defaultGeneralSurgerySmartHistory();
334
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return d;
335
+ const v = raw;
336
+ const painIn = v.pain && typeof v.pain === "object" ? v.pain : {};
337
+ const sev = Number(painIn.severity);
338
+ const pain = {
339
+ ...d.pain,
340
+ ...painIn,
341
+ severity: Number.isFinite(sev) ? Math.min(10, Math.max(0, Math.round(sev))) : d.pain.severity
342
+ };
343
+ const str2 = (x) => typeof x === "string" ? x : "";
344
+ const strArr = (x) => Array.isArray(x) ? x.filter((i) => typeof i === "string") : [];
345
+ const swell = v.swelling && typeof v.swelling === "object" ? v.swelling : {};
346
+ const gi = v.gi && typeof v.gi === "object" ? v.gi : {};
347
+ const breast = v.breast && typeof v.breast === "object" ? v.breast : {};
348
+ const ano = v.ano && typeof v.ano === "object" ? v.ano : {};
349
+ const thy = v.thyroid && typeof v.thyroid === "object" ? v.thyroid : {};
350
+ return {
351
+ pain,
352
+ swelling: {
353
+ duration: str2(swell.duration),
354
+ sizeProgression: str2(swell.sizeProgression),
355
+ painfulPainless: str2(swell.painfulPainless),
356
+ checks: strArr(swell.checks)
357
+ },
358
+ gi: {
359
+ appetite: str2(gi.appetite),
360
+ weightLoss: str2(gi.weightLoss),
361
+ bowelHabits: str2(gi.bowelHabits),
362
+ checks: strArr(gi.checks)
363
+ },
364
+ breast: {
365
+ lumpDuration: str2(breast.lumpDuration),
366
+ nippleDischarge: str2(breast.nippleDischarge),
367
+ checks: strArr(breast.checks)
368
+ },
369
+ ano: { checks: strArr(ano.checks) },
370
+ thyroid: {
371
+ swellingDuration: str2(thy.swellingDuration),
372
+ checks: strArr(thy.checks)
373
+ },
374
+ systemic: typeof v.systemic === "string" ? v.systemic : d.systemic
375
+ };
376
+ }
377
+ function normalizeGeneralSurgeryExamination(raw) {
378
+ const d = defaultGeneralSurgeryExamination();
379
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return d;
380
+ const v = raw;
381
+ const strArr = (x) => Array.isArray(x) ? x.filter((i) => typeof i === "string") : [];
382
+ const ab = v.abdomen && typeof v.abdomen === "object" ? v.abdomen : {};
383
+ const bowel = ab.bowelSounds;
384
+ const bowels = bowel === "normal" || bowel === "up" || bowel === "down" || bowel === "absent" ? bowel : "none";
385
+ const hb = v.hernia && typeof v.hernia === "object" ? v.hernia : {};
386
+ const br = v.breast && typeof v.breast === "object" ? v.breast : {};
387
+ const th = v.thyroid && typeof v.thyroid === "object" ? v.thyroid : {};
388
+ const ar = v.anorectal && typeof v.anorectal === "object" ? v.anorectal : {};
389
+ const lm = v.limb && typeof v.limb === "object" ? v.limb : {};
390
+ const bool = (x) => x === true;
391
+ return {
392
+ general: strArr(v.general),
393
+ regions: strArr(v.regions),
394
+ abdomen: {
395
+ inspection: strArr(ab.inspection),
396
+ palpation: strArr(ab.palpation),
397
+ percussion: strArr(ab.percussion),
398
+ massNotes: typeof ab.massNotes === "string" ? ab.massNotes : d.abdomen.massNotes,
399
+ bowelSounds: bowels
400
+ },
401
+ hernia: {
402
+ site: typeof hb.site === "string" ? hb.site : "",
403
+ reducible: bool(hb.reducible),
404
+ coughImpulse: bool(hb.coughImpulse),
405
+ tenderness: bool(hb.tenderness)
406
+ },
407
+ breast: {
408
+ lumpSizeCm: typeof br.lumpSizeCm === "string" ? br.lumpSizeCm : "",
409
+ mobile: bool(br.mobile),
410
+ skinInvolvement: bool(br.skinInvolvement),
411
+ axillaryNodes: bool(br.axillaryNodes)
412
+ },
413
+ thyroid: {
414
+ size: typeof th.size === "string" ? th.size : "",
415
+ mobileDeglutition: bool(th.mobileDeglutition),
416
+ nodules: bool(th.nodules),
417
+ cervicalNodes: bool(th.cervicalNodes)
418
+ },
419
+ anorectal: {
420
+ inspection: typeof ar.inspection === "string" ? ar.inspection : "",
421
+ dreDone: bool(ar.dreDone),
422
+ proctoscopyDone: bool(ar.proctoscopyDone),
423
+ notes: typeof ar.notes === "string" ? ar.notes : ""
424
+ },
425
+ limb: {
426
+ dilatedVeins: bool(lm.dilatedVeins),
427
+ ulcer: bool(lm.ulcer),
428
+ oedema: bool(lm.oedema)
429
+ }
430
+ };
431
+ }
432
+ function normalizeGeneralSurgeryGrading(raw) {
433
+ const d = defaultGeneralSurgeryGrading();
434
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return d;
435
+ const v = raw;
436
+ const out = { ...d };
437
+ for (const k of ALL_GS_CONDITIONS) {
438
+ const n = Number(v[k]);
439
+ if (Number.isFinite(n) && n >= 0 && n <= 5) out[k] = Math.round(n);
440
+ }
441
+ return out;
442
+ }
443
+ function gsGradingRowVisible(cond, chips, regions, grade) {
444
+ if (grade > 0) return true;
445
+ const t = GS_CONDITION_TRIGGERS[cond];
446
+ if (t.chips.some((c) => chips.includes(c))) return true;
447
+ if (t.regions.some((r) => regions.includes(r))) return true;
448
+ return false;
449
+ }
450
+
451
+ // src/core/painScaleFlags.ts
452
+ function normalizePainScaleFlags(raw, bounds) {
453
+ const min = bounds?.min ?? 0;
454
+ const max = bounds?.max ?? 10;
455
+ let pain = min;
456
+ let flags = [];
457
+ if (raw && typeof raw === "object" && !Array.isArray(raw)) {
458
+ const o = raw;
459
+ const p = Number(o.pain);
460
+ if (Number.isFinite(p)) pain = Math.min(max, Math.max(min, p));
461
+ if (Array.isArray(o.flags)) {
462
+ flags = o.flags.filter((x) => typeof x === "string");
463
+ }
464
+ }
465
+ return { pain, flags };
466
+ }
467
+
225
468
  // src/core/store.ts
226
469
  var FormStore = class {
227
470
  state;
@@ -267,9 +510,63 @@ var FormStore = class {
267
510
  values[field.id] = field.defaultValue;
268
511
  } else {
269
512
  if (field.type === "repeatable") values[field.id] = [];
270
- else if (field.type === "checkbox") values[field.id] = [];
513
+ else if (field.type === "checkbox" || field.type === "multiselect") values[field.id] = [];
271
514
  else if (field.type === "smart_textarea") values[field.id] = { text: "", extractedKeywords: [] };
272
- else values[field.id] = null;
515
+ else if (field.type === "suggestion_textarea" || field.type === "complaint_chips") values[field.id] = "";
516
+ else if (field.type === "lens_assessment")
517
+ values[field.id] = {
518
+ notes: "",
519
+ assessmentKey: void 0,
520
+ locs: {
521
+ OD: { NO: 0, NC: 0, C: 0, PSC: 0 },
522
+ OS: { NO: 0, NC: 0, C: 0, PSC: 0 }
523
+ }
524
+ };
525
+ else if (field.type === "functional_impairment_score")
526
+ values[field.id] = {
527
+ reading: 0,
528
+ nightDriving: 0,
529
+ glare: 0,
530
+ occupation: 0,
531
+ adl: 0
532
+ };
533
+ else if (field.type === "biometry_iol_workup")
534
+ values[field.id] = {
535
+ axialLengthOD: "",
536
+ axialLengthOS: "",
537
+ k1k2AxisOD: "",
538
+ k1k2AxisOS: "",
539
+ anteriorChamberDepthOD: "",
540
+ anteriorChamberDepthOS: "",
541
+ iolPowerOD: "",
542
+ iolPowerOS: "",
543
+ targetRefractionOD: "",
544
+ targetRefractionOS: "",
545
+ formula: "SRK/T",
546
+ method: "optical_biometry",
547
+ cornealTopoUploaded: false,
548
+ specularMicroscopyDone: false,
549
+ endothelialCount: ""
550
+ };
551
+ else if (field.type === "surgical_risk_flags")
552
+ values[field.id] = { OD: [], OS: [] };
553
+ else if (field.type === "toggle") values[field.id] = false;
554
+ else if (field.type === "slider") {
555
+ const s = field;
556
+ values[field.id] = s.defaultValue ?? s.min ?? 0;
557
+ } else if (field.type === "general_surgery_smart_history") {
558
+ values[field.id] = field.defaultValue ?? defaultGeneralSurgerySmartHistory();
559
+ } else if (field.type === "general_surgery_examination") {
560
+ values[field.id] = field.defaultValue ?? defaultGeneralSurgeryExamination();
561
+ } else if (field.type === "general_surgery_grading") {
562
+ values[field.id] = field.defaultValue ?? defaultGeneralSurgeryGrading();
563
+ } else if (field.type === "pain_scale_flags") {
564
+ const f = field;
565
+ values[field.id] = normalizePainScaleFlags(
566
+ f.defaultValue ?? { pain: f.min ?? 0, flags: [] },
567
+ { min: f.min, max: f.max }
568
+ );
569
+ } else values[field.id] = null;
273
570
  }
274
571
  });
275
572
  this.state.values = values;
@@ -989,7 +1286,8 @@ var TextWidget = ({ fieldId }) => {
989
1286
  fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
990
1287
  ] });
991
1288
  const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, children: labelContent });
992
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperClass, children: [
1289
+ const placeholder = typeof fieldDef.placeholder === "string" && fieldDef.placeholder.trim() ? fieldDef.placeholder : void 0;
1290
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(wrapperClass, isTextarea && "flex h-full min-h-0 flex-col"), children: [
993
1291
  hasVoice ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
994
1292
  labelEl,
995
1293
  /* @__PURE__ */ jsxRuntime.jsx(VoiceMicButton, { fieldId, onTranscriptReady: setValue })
@@ -1003,7 +1301,8 @@ var TextWidget = ({ fieldId }) => {
1003
1301
  onBlur: setTouched,
1004
1302
  disabled,
1005
1303
  type: fieldDef.type === "number" ? "number" : "text",
1006
- className: inputClass,
1304
+ className: cn(inputClass, isTextarea && height == null && "min-h-[80px] flex-1"),
1305
+ placeholder,
1007
1306
  ...isTextarea && { height }
1008
1307
  }
1009
1308
  ),
@@ -1479,6 +1778,8 @@ var SelectWidget = ({ fieldId }) => {
1479
1778
  }
1480
1779
  }, [fieldDef]);
1481
1780
  if (!fieldDef) return null;
1781
+ const schemaPlaceholder = typeof fieldDef.placeholder === "string" && fieldDef.placeholder.trim() ? fieldDef.placeholder : void 0;
1782
+ const selectPlaceholder = loading ? "Loading..." : schemaPlaceholder ?? "Select...";
1482
1783
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
1483
1784
  /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, children: [
1484
1785
  fieldDef.label,
@@ -1496,7 +1797,7 @@ var SelectWidget = ({ fieldId }) => {
1496
1797
  setTouched();
1497
1798
  },
1498
1799
  children: [
1499
- /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { id: fieldId, className: showError ? "border-red-500" : "", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: loading ? "Loading..." : "Select..." }) }),
1800
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { id: fieldId, className: showError ? "border-red-500" : "", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: selectPlaceholder }) }),
1500
1801
  /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: options.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: String(opt.value), children: opt.label }, String(opt.value))) })
1501
1802
  ]
1502
1803
  }
@@ -6100,6 +6401,12 @@ var tableCellClass = "border border-[#E0E0E0] px-1.5 py-1 text-center align-midd
6100
6401
  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";
6101
6402
  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";
6102
6403
  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";
6404
+ var refractionTableClass = "w-full table-fixed border-collapse text-xs";
6405
+ var refractionHeaderCellClass = "border border-[#E0E0E0] bg-[#F7F7F7] px-1 py-1 text-center font-semibold text-[11px]";
6406
+ var refractionDataCellClass = "border border-[#E0E0E0] p-0 text-center align-middle min-w-0";
6407
+ var refractionLabelCellClass = "border border-[#E0E0E0] px-2 py-1 text-left align-middle font-semibold whitespace-nowrap";
6408
+ 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";
6409
+ 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";
6103
6410
  var OphthalmologyWidget = ({ fieldId }) => {
6104
6411
  const { fieldDef, value, setValue, disabled } = useField(fieldId);
6105
6412
  const safe = React15.useMemo(() => ensureValue(value), [value]);
@@ -6331,34 +6638,45 @@ var OphthalmologyWidget = ({ fieldId }) => {
6331
6638
  ] }),
6332
6639
  /* @__PURE__ */ jsxRuntime.jsxs("section", { className: sectionWrapperClass, children: [
6333
6640
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionHeaderClass, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Current Glass Prescription" }) }),
6334
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: tableBaseClass, children: [
6641
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: refractionTableClass, children: [
6642
+ /* @__PURE__ */ jsxRuntime.jsxs("colgroup", { children: [
6643
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[10%]" }),
6644
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6645
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6646
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[6%]" }),
6647
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[25%]" }),
6648
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6649
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6650
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[6%]" }),
6651
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[25%]" })
6652
+ ] }),
6335
6653
  /* @__PURE__ */ jsxRuntime.jsxs("thead", { children: [
6336
6654
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6337
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass }),
6338
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, colSpan: 4, children: "Right Eye" }),
6339
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, colSpan: 4, children: "Left Eye" })
6655
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass }),
6656
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, colSpan: 4, children: "Right Eye" }),
6657
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, colSpan: 4, children: "Left Eye" })
6340
6658
  ] }),
6341
6659
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6342
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass }),
6343
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6344
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6345
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6346
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
6347
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6348
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6349
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6350
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "V/A" })
6660
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass }),
6661
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
6662
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
6663
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
6664
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "V/A" }),
6665
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
6666
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
6667
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
6668
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "V/A" })
6351
6669
  ] })
6352
6670
  ] }),
6353
6671
  /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6354
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Current Glass" }),
6355
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6672
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionLabelCellClass, children: "Current Glass" }),
6673
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6356
6674
  Input,
6357
6675
  {
6358
6676
  disabled,
6359
6677
  type: "number",
6360
6678
  step: "0.25",
6361
- className: numberInputClass,
6679
+ className: refractionInputClass,
6362
6680
  value: safe.current_glass_prescription.right_eye.sph ?? "",
6363
6681
  onChange: (e) => setRefractionField(
6364
6682
  "current_glass_prescription",
@@ -6369,13 +6687,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6369
6687
  )
6370
6688
  }
6371
6689
  ) }),
6372
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6690
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6373
6691
  Input,
6374
6692
  {
6375
6693
  disabled,
6376
6694
  type: "number",
6377
6695
  step: "0.25",
6378
- className: numberInputClass,
6696
+ className: refractionInputClass,
6379
6697
  value: safe.current_glass_prescription.right_eye.cyl ?? "",
6380
6698
  onChange: (e) => setRefractionField(
6381
6699
  "current_glass_prescription",
@@ -6386,12 +6704,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6386
6704
  )
6387
6705
  }
6388
6706
  ) }),
6389
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6707
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6390
6708
  Input,
6391
6709
  {
6392
6710
  disabled,
6393
6711
  type: "number",
6394
- className: numberInputClass,
6712
+ className: refractionInputClass,
6395
6713
  value: safe.current_glass_prescription.right_eye.axis ?? "",
6396
6714
  onChange: (e) => setRefractionField(
6397
6715
  "current_glass_prescription",
@@ -6402,11 +6720,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6402
6720
  )
6403
6721
  }
6404
6722
  ) }),
6405
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6723
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6406
6724
  "select",
6407
6725
  {
6408
6726
  disabled,
6409
- className: selectClass,
6727
+ className: refractionSelectClass,
6410
6728
  value: safe.current_glass_prescription.right_eye.va,
6411
6729
  onChange: (e) => setRefractionField(
6412
6730
  "current_glass_prescription",
@@ -6418,13 +6736,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6418
6736
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: opt, children: opt }, opt || "blank"))
6419
6737
  }
6420
6738
  ) }),
6421
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6739
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6422
6740
  Input,
6423
6741
  {
6424
6742
  disabled,
6425
6743
  type: "number",
6426
6744
  step: "0.25",
6427
- className: numberInputClass,
6745
+ className: refractionInputClass,
6428
6746
  value: safe.current_glass_prescription.left_eye.sph ?? "",
6429
6747
  onChange: (e) => setRefractionField(
6430
6748
  "current_glass_prescription",
@@ -6435,13 +6753,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6435
6753
  )
6436
6754
  }
6437
6755
  ) }),
6438
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6756
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6439
6757
  Input,
6440
6758
  {
6441
6759
  disabled,
6442
6760
  type: "number",
6443
6761
  step: "0.25",
6444
- className: numberInputClass,
6762
+ className: refractionInputClass,
6445
6763
  value: safe.current_glass_prescription.left_eye.cyl ?? "",
6446
6764
  onChange: (e) => setRefractionField(
6447
6765
  "current_glass_prescription",
@@ -6452,12 +6770,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6452
6770
  )
6453
6771
  }
6454
6772
  ) }),
6455
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6773
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6456
6774
  Input,
6457
6775
  {
6458
6776
  disabled,
6459
6777
  type: "number",
6460
- className: numberInputClass,
6778
+ className: refractionInputClass,
6461
6779
  value: safe.current_glass_prescription.left_eye.axis ?? "",
6462
6780
  onChange: (e) => setRefractionField(
6463
6781
  "current_glass_prescription",
@@ -6468,11 +6786,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6468
6786
  )
6469
6787
  }
6470
6788
  ) }),
6471
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6789
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6472
6790
  "select",
6473
6791
  {
6474
6792
  disabled,
6475
- className: selectClass,
6793
+ className: refractionSelectClass,
6476
6794
  value: safe.current_glass_prescription.left_eye.va,
6477
6795
  onChange: (e) => setRefractionField(
6478
6796
  "current_glass_prescription",
@@ -6581,37 +6899,50 @@ var OphthalmologyWidget = ({ fieldId }) => {
6581
6899
  ] }),
6582
6900
  /* @__PURE__ */ jsxRuntime.jsxs("section", { className: sectionWrapperClass, children: [
6583
6901
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionHeaderClass, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Refraction (Distance)" }) }),
6584
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: tableBaseClass, children: [
6902
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: refractionTableClass, children: [
6903
+ /* @__PURE__ */ jsxRuntime.jsxs("colgroup", { children: [
6904
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[10%]" }),
6905
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6906
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6907
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[6%]" }),
6908
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[13%]" }),
6909
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[12%]" }),
6910
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6911
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
6912
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[6%]" }),
6913
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[13%]" }),
6914
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[12%]" })
6915
+ ] }),
6585
6916
  /* @__PURE__ */ jsxRuntime.jsxs("thead", { children: [
6586
6917
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6587
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass }),
6588
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Right Eye" }),
6589
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Left Eye" })
6918
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass }),
6919
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, colSpan: 5, children: "Right Eye" }),
6920
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, colSpan: 5, children: "Left Eye" })
6590
6921
  ] }),
6591
6922
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6592
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass }),
6593
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6594
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6595
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6596
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
6597
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "P/D" }),
6598
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6599
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6600
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6601
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
6602
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "P/D" })
6923
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass }),
6924
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
6925
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
6926
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
6927
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "V/A" }),
6928
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "P/D" }),
6929
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
6930
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
6931
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
6932
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "V/A" }),
6933
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "P/D" })
6603
6934
  ] })
6604
6935
  ] }),
6605
6936
  /* @__PURE__ */ jsxRuntime.jsxs("tbody", { children: [
6606
6937
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6607
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Distance" }),
6608
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6938
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionLabelCellClass, children: "Distance" }),
6939
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6609
6940
  Input,
6610
6941
  {
6611
6942
  disabled,
6612
6943
  type: "number",
6613
6944
  step: "0.25",
6614
- className: numberInputClass,
6945
+ className: refractionInputClass,
6615
6946
  value: safe.refraction.right_eye.sph ?? "",
6616
6947
  onChange: (e) => setRefractionField(
6617
6948
  "refraction",
@@ -6622,13 +6953,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6622
6953
  )
6623
6954
  }
6624
6955
  ) }),
6625
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6956
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6626
6957
  Input,
6627
6958
  {
6628
6959
  disabled,
6629
6960
  type: "number",
6630
6961
  step: "0.25",
6631
- className: numberInputClass,
6962
+ className: refractionInputClass,
6632
6963
  value: safe.refraction.right_eye.cyl ?? "",
6633
6964
  onChange: (e) => setRefractionField(
6634
6965
  "refraction",
@@ -6639,12 +6970,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6639
6970
  )
6640
6971
  }
6641
6972
  ) }),
6642
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6973
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6643
6974
  Input,
6644
6975
  {
6645
6976
  disabled,
6646
6977
  type: "number",
6647
- className: numberInputClass,
6978
+ className: refractionInputClass,
6648
6979
  value: safe.refraction.right_eye.axis ?? "",
6649
6980
  onChange: (e) => setRefractionField(
6650
6981
  "refraction",
@@ -6655,11 +6986,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6655
6986
  )
6656
6987
  }
6657
6988
  ) }),
6658
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6989
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6659
6990
  "select",
6660
6991
  {
6661
6992
  disabled,
6662
- className: selectClass,
6993
+ className: refractionSelectClass,
6663
6994
  value: safe.refraction.right_eye.va,
6664
6995
  onChange: (e) => setRefractionField(
6665
6996
  "refraction",
@@ -6671,7 +7002,7 @@ var OphthalmologyWidget = ({ fieldId }) => {
6671
7002
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: opt, children: opt }, opt || "blank"))
6672
7003
  }
6673
7004
  ) }),
6674
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7005
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6675
7006
  Input,
6676
7007
  {
6677
7008
  disabled,
@@ -6679,18 +7010,18 @@ var OphthalmologyWidget = ({ fieldId }) => {
6679
7010
  min: 10,
6680
7011
  max: 45,
6681
7012
  step: "1",
6682
- className: numberInputClass,
7013
+ className: refractionInputClass,
6683
7014
  value: safe.refraction.right_eye.pd ?? "",
6684
7015
  onChange: (e) => setRefractionField("refraction", "right_eye", "pd", e.target.value, "int")
6685
7016
  }
6686
7017
  ) }),
6687
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7018
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6688
7019
  Input,
6689
7020
  {
6690
7021
  disabled,
6691
7022
  type: "number",
6692
7023
  step: "0.25",
6693
- className: numberInputClass,
7024
+ className: refractionInputClass,
6694
7025
  value: safe.refraction.left_eye.sph ?? "",
6695
7026
  onChange: (e) => setRefractionField(
6696
7027
  "refraction",
@@ -6701,13 +7032,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6701
7032
  )
6702
7033
  }
6703
7034
  ) }),
6704
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7035
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6705
7036
  Input,
6706
7037
  {
6707
7038
  disabled,
6708
7039
  type: "number",
6709
7040
  step: "0.25",
6710
- className: numberInputClass,
7041
+ className: refractionInputClass,
6711
7042
  value: safe.refraction.left_eye.cyl ?? "",
6712
7043
  onChange: (e) => setRefractionField(
6713
7044
  "refraction",
@@ -6718,12 +7049,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6718
7049
  )
6719
7050
  }
6720
7051
  ) }),
6721
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7052
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6722
7053
  Input,
6723
7054
  {
6724
7055
  disabled,
6725
7056
  type: "number",
6726
- className: numberInputClass,
7057
+ className: refractionInputClass,
6727
7058
  value: safe.refraction.left_eye.axis ?? "",
6728
7059
  onChange: (e) => setRefractionField(
6729
7060
  "refraction",
@@ -6734,11 +7065,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6734
7065
  )
6735
7066
  }
6736
7067
  ) }),
6737
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7068
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6738
7069
  "select",
6739
7070
  {
6740
7071
  disabled,
6741
- className: selectClass,
7072
+ className: refractionSelectClass,
6742
7073
  value: safe.refraction.left_eye.va,
6743
7074
  onChange: (e) => setRefractionField(
6744
7075
  "refraction",
@@ -6750,7 +7081,7 @@ var OphthalmologyWidget = ({ fieldId }) => {
6750
7081
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: opt, children: opt }, opt || "blank"))
6751
7082
  }
6752
7083
  ) }),
6753
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7084
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6754
7085
  Input,
6755
7086
  {
6756
7087
  disabled,
@@ -6758,32 +7089,32 @@ var OphthalmologyWidget = ({ fieldId }) => {
6758
7089
  min: 10,
6759
7090
  max: 45,
6760
7091
  step: "1",
6761
- className: numberInputClass,
7092
+ className: refractionInputClass,
6762
7093
  value: safe.refraction.left_eye.pd ?? "",
6763
7094
  onChange: (e) => setRefractionField("refraction", "left_eye", "pd", e.target.value, "int")
6764
7095
  }
6765
7096
  ) })
6766
7097
  ] }),
6767
7098
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6768
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Add" }),
6769
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
7099
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionLabelCellClass, children: "Add" }),
7100
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
6770
7101
  Input,
6771
7102
  {
6772
7103
  disabled,
6773
7104
  type: "number",
6774
7105
  step: "0.25",
6775
- className: numberInputClass,
7106
+ className: refractionInputClass,
6776
7107
  value: safe.refraction.add.right ?? "",
6777
7108
  onChange: (e) => setRefractionAdd("refraction", "right", e.target.value)
6778
7109
  }
6779
7110
  ) }),
6780
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
7111
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
6781
7112
  Input,
6782
7113
  {
6783
7114
  disabled,
6784
7115
  type: "number",
6785
7116
  step: "0.25",
6786
- className: numberInputClass,
7117
+ className: refractionInputClass,
6787
7118
  value: safe.refraction.add.left ?? "",
6788
7119
  onChange: (e) => setRefractionAdd("refraction", "left", e.target.value)
6789
7120
  }
@@ -6794,37 +7125,50 @@ var OphthalmologyWidget = ({ fieldId }) => {
6794
7125
  ] }),
6795
7126
  /* @__PURE__ */ jsxRuntime.jsxs("section", { className: sectionWrapperClass, children: [
6796
7127
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionHeaderClass, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Dilated Refraction" }) }),
6797
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: tableBaseClass, children: [
7128
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: refractionTableClass, children: [
7129
+ /* @__PURE__ */ jsxRuntime.jsxs("colgroup", { children: [
7130
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[10%]" }),
7131
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
7132
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
7133
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[6%]" }),
7134
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[8%]" }),
7135
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[17%]" }),
7136
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
7137
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
7138
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[6%]" }),
7139
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[8%]" }),
7140
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[17%]" })
7141
+ ] }),
6798
7142
  /* @__PURE__ */ jsxRuntime.jsxs("thead", { children: [
6799
7143
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6800
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass }),
6801
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Right Eye" }),
6802
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Left Eye" })
7144
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass }),
7145
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, colSpan: 5, children: "Right Eye" }),
7146
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, colSpan: 5, children: "Left Eye" })
6803
7147
  ] }),
6804
7148
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6805
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass }),
6806
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6807
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6808
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6809
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Prism" }),
6810
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
6811
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
6812
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
6813
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
6814
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Prism" }),
6815
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "V/A" })
7149
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass }),
7150
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
7151
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
7152
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
7153
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Prism" }),
7154
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "V/A" }),
7155
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
7156
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
7157
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
7158
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Prism" }),
7159
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "V/A" })
6816
7160
  ] })
6817
7161
  ] }),
6818
7162
  /* @__PURE__ */ jsxRuntime.jsxs("tbody", { children: [
6819
7163
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6820
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Dilated" }),
6821
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7164
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionLabelCellClass, children: "Dilated" }),
7165
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6822
7166
  Input,
6823
7167
  {
6824
7168
  disabled,
6825
7169
  type: "number",
6826
7170
  step: "0.25",
6827
- className: numberInputClass,
7171
+ className: refractionInputClass,
6828
7172
  value: safe.dilated_refraction.right_eye.sph ?? "",
6829
7173
  onChange: (e) => setRefractionField(
6830
7174
  "dilated_refraction",
@@ -6835,13 +7179,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6835
7179
  )
6836
7180
  }
6837
7181
  ) }),
6838
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7182
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6839
7183
  Input,
6840
7184
  {
6841
7185
  disabled,
6842
7186
  type: "number",
6843
7187
  step: "0.25",
6844
- className: numberInputClass,
7188
+ className: refractionInputClass,
6845
7189
  value: safe.dilated_refraction.right_eye.cyl ?? "",
6846
7190
  onChange: (e) => setRefractionField(
6847
7191
  "dilated_refraction",
@@ -6852,12 +7196,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6852
7196
  )
6853
7197
  }
6854
7198
  ) }),
6855
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7199
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6856
7200
  Input,
6857
7201
  {
6858
7202
  disabled,
6859
7203
  type: "number",
6860
- className: numberInputClass,
7204
+ className: refractionInputClass,
6861
7205
  value: safe.dilated_refraction.right_eye.axis ?? "",
6862
7206
  onChange: (e) => setRefractionField(
6863
7207
  "dilated_refraction",
@@ -6868,13 +7212,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6868
7212
  )
6869
7213
  }
6870
7214
  ) }),
6871
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7215
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6872
7216
  Input,
6873
7217
  {
6874
7218
  disabled,
6875
7219
  type: "number",
6876
7220
  step: "0.25",
6877
- className: numberInputClass,
7221
+ className: refractionInputClass,
6878
7222
  value: safe.dilated_refraction.right_eye.prism ?? "",
6879
7223
  onChange: (e) => setRefractionField(
6880
7224
  "dilated_refraction",
@@ -6885,11 +7229,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6885
7229
  )
6886
7230
  }
6887
7231
  ) }),
6888
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7232
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6889
7233
  "select",
6890
7234
  {
6891
7235
  disabled,
6892
- className: selectClass,
7236
+ className: refractionSelectClass,
6893
7237
  value: safe.dilated_refraction.right_eye.va,
6894
7238
  onChange: (e) => setRefractionField(
6895
7239
  "dilated_refraction",
@@ -6901,13 +7245,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6901
7245
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: opt, children: opt }, opt || "blank"))
6902
7246
  }
6903
7247
  ) }),
6904
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7248
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6905
7249
  Input,
6906
7250
  {
6907
7251
  disabled,
6908
7252
  type: "number",
6909
7253
  step: "0.25",
6910
- className: numberInputClass,
7254
+ className: refractionInputClass,
6911
7255
  value: safe.dilated_refraction.left_eye.sph ?? "",
6912
7256
  onChange: (e) => setRefractionField(
6913
7257
  "dilated_refraction",
@@ -6918,13 +7262,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6918
7262
  )
6919
7263
  }
6920
7264
  ) }),
6921
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7265
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6922
7266
  Input,
6923
7267
  {
6924
7268
  disabled,
6925
7269
  type: "number",
6926
7270
  step: "0.25",
6927
- className: numberInputClass,
7271
+ className: refractionInputClass,
6928
7272
  value: safe.dilated_refraction.left_eye.cyl ?? "",
6929
7273
  onChange: (e) => setRefractionField(
6930
7274
  "dilated_refraction",
@@ -6935,12 +7279,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
6935
7279
  )
6936
7280
  }
6937
7281
  ) }),
6938
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7282
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6939
7283
  Input,
6940
7284
  {
6941
7285
  disabled,
6942
7286
  type: "number",
6943
- className: numberInputClass,
7287
+ className: refractionInputClass,
6944
7288
  value: safe.dilated_refraction.left_eye.axis ?? "",
6945
7289
  onChange: (e) => setRefractionField(
6946
7290
  "dilated_refraction",
@@ -6951,13 +7295,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
6951
7295
  )
6952
7296
  }
6953
7297
  ) }),
6954
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7298
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6955
7299
  Input,
6956
7300
  {
6957
7301
  disabled,
6958
7302
  type: "number",
6959
7303
  step: "0.25",
6960
- className: numberInputClass,
7304
+ className: refractionInputClass,
6961
7305
  value: safe.dilated_refraction.left_eye.prism ?? "",
6962
7306
  onChange: (e) => setRefractionField(
6963
7307
  "dilated_refraction",
@@ -6968,11 +7312,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
6968
7312
  )
6969
7313
  }
6970
7314
  ) }),
6971
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7315
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
6972
7316
  "select",
6973
7317
  {
6974
7318
  disabled,
6975
- className: selectClass,
7319
+ className: refractionSelectClass,
6976
7320
  value: safe.dilated_refraction.left_eye.va,
6977
7321
  onChange: (e) => setRefractionField(
6978
7322
  "dilated_refraction",
@@ -6986,25 +7330,25 @@ var OphthalmologyWidget = ({ fieldId }) => {
6986
7330
  ) })
6987
7331
  ] }),
6988
7332
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
6989
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Add" }),
6990
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
7333
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionLabelCellClass, children: "Add" }),
7334
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
6991
7335
  Input,
6992
7336
  {
6993
7337
  disabled,
6994
7338
  type: "number",
6995
7339
  step: "0.25",
6996
- className: numberInputClass,
7340
+ className: refractionInputClass,
6997
7341
  value: safe.dilated_refraction.add.right ?? "",
6998
7342
  onChange: (e) => setRefractionAdd("dilated_refraction", "right", e.target.value)
6999
7343
  }
7000
7344
  ) }),
7001
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
7345
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
7002
7346
  Input,
7003
7347
  {
7004
7348
  disabled,
7005
7349
  type: "number",
7006
7350
  step: "0.25",
7007
- className: numberInputClass,
7351
+ className: refractionInputClass,
7008
7352
  value: safe.dilated_refraction.add.left ?? "",
7009
7353
  onChange: (e) => setRefractionAdd("dilated_refraction", "left", e.target.value)
7010
7354
  }
@@ -7015,37 +7359,50 @@ var OphthalmologyWidget = ({ fieldId }) => {
7015
7359
  ] }),
7016
7360
  /* @__PURE__ */ jsxRuntime.jsxs("section", { className: sectionWrapperClass, children: [
7017
7361
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionHeaderClass, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Glass Power Prescription" }) }),
7018
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: tableBaseClass, children: [
7362
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionBodyClass, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: refractionTableClass, children: [
7363
+ /* @__PURE__ */ jsxRuntime.jsxs("colgroup", { children: [
7364
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[10%]" }),
7365
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
7366
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
7367
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[6%]" }),
7368
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[8%]" }),
7369
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[17%]" }),
7370
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
7371
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[7%]" }),
7372
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[6%]" }),
7373
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[8%]" }),
7374
+ /* @__PURE__ */ jsxRuntime.jsx("col", { className: "w-[17%]" })
7375
+ ] }),
7019
7376
  /* @__PURE__ */ jsxRuntime.jsxs("thead", { children: [
7020
7377
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
7021
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass }),
7022
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Right Eye" }),
7023
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, colSpan: 5, children: "Left Eye" })
7378
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass }),
7379
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, colSpan: 5, children: "Right Eye" }),
7380
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, colSpan: 5, children: "Left Eye" })
7024
7381
  ] }),
7025
7382
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
7026
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass }),
7027
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
7028
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
7029
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
7030
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Prism" }),
7031
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "V/A" }),
7032
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Sph" }),
7033
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Cyl" }),
7034
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Axis" }),
7035
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "Prism" }),
7036
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: tableHeaderCellClass, children: "V/A" })
7383
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass }),
7384
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
7385
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
7386
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
7387
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Prism" }),
7388
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "V/A" }),
7389
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Sph" }),
7390
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Cyl" }),
7391
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Axis" }),
7392
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "Prism" }),
7393
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: refractionHeaderCellClass, children: "V/A" })
7037
7394
  ] })
7038
7395
  ] }),
7039
7396
  /* @__PURE__ */ jsxRuntime.jsxs("tbody", { children: [
7040
7397
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
7041
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Glass Power" }),
7042
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7398
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionLabelCellClass, children: "Glass Power" }),
7399
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7043
7400
  Input,
7044
7401
  {
7045
7402
  disabled,
7046
7403
  type: "number",
7047
7404
  step: "0.25",
7048
- className: numberInputClass,
7405
+ className: refractionInputClass,
7049
7406
  value: safe.glass_power_prescription.right_eye.sph ?? "",
7050
7407
  onChange: (e) => setRefractionField(
7051
7408
  "glass_power_prescription",
@@ -7056,13 +7413,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
7056
7413
  )
7057
7414
  }
7058
7415
  ) }),
7059
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7416
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7060
7417
  Input,
7061
7418
  {
7062
7419
  disabled,
7063
7420
  type: "number",
7064
7421
  step: "0.25",
7065
- className: numberInputClass,
7422
+ className: refractionInputClass,
7066
7423
  value: safe.glass_power_prescription.right_eye.cyl ?? "",
7067
7424
  onChange: (e) => setRefractionField(
7068
7425
  "glass_power_prescription",
@@ -7073,12 +7430,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
7073
7430
  )
7074
7431
  }
7075
7432
  ) }),
7076
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7433
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7077
7434
  Input,
7078
7435
  {
7079
7436
  disabled,
7080
7437
  type: "number",
7081
- className: numberInputClass,
7438
+ className: refractionInputClass,
7082
7439
  value: safe.glass_power_prescription.right_eye.axis ?? "",
7083
7440
  onChange: (e) => setRefractionField(
7084
7441
  "glass_power_prescription",
@@ -7089,13 +7446,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
7089
7446
  )
7090
7447
  }
7091
7448
  ) }),
7092
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7449
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7093
7450
  Input,
7094
7451
  {
7095
7452
  disabled,
7096
7453
  type: "number",
7097
7454
  step: "0.25",
7098
- className: numberInputClass,
7455
+ className: refractionInputClass,
7099
7456
  value: safe.glass_power_prescription.right_eye.prism ?? "",
7100
7457
  onChange: (e) => setRefractionField(
7101
7458
  "glass_power_prescription",
@@ -7106,11 +7463,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
7106
7463
  )
7107
7464
  }
7108
7465
  ) }),
7109
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7466
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7110
7467
  "select",
7111
7468
  {
7112
7469
  disabled,
7113
- className: selectClass,
7470
+ className: refractionSelectClass,
7114
7471
  value: safe.glass_power_prescription.right_eye.va,
7115
7472
  onChange: (e) => setRefractionField(
7116
7473
  "glass_power_prescription",
@@ -7122,13 +7479,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
7122
7479
  children: VA_OPTIONS.map((opt) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: opt, children: opt }, opt || "blank"))
7123
7480
  }
7124
7481
  ) }),
7125
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7482
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7126
7483
  Input,
7127
7484
  {
7128
7485
  disabled,
7129
7486
  type: "number",
7130
7487
  step: "0.25",
7131
- className: numberInputClass,
7488
+ className: refractionInputClass,
7132
7489
  value: safe.glass_power_prescription.left_eye.sph ?? "",
7133
7490
  onChange: (e) => setRefractionField(
7134
7491
  "glass_power_prescription",
@@ -7139,13 +7496,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
7139
7496
  )
7140
7497
  }
7141
7498
  ) }),
7142
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7499
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7143
7500
  Input,
7144
7501
  {
7145
7502
  disabled,
7146
7503
  type: "number",
7147
7504
  step: "0.25",
7148
- className: numberInputClass,
7505
+ className: refractionInputClass,
7149
7506
  value: safe.glass_power_prescription.left_eye.cyl ?? "",
7150
7507
  onChange: (e) => setRefractionField(
7151
7508
  "glass_power_prescription",
@@ -7156,12 +7513,12 @@ var OphthalmologyWidget = ({ fieldId }) => {
7156
7513
  )
7157
7514
  }
7158
7515
  ) }),
7159
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7516
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7160
7517
  Input,
7161
7518
  {
7162
7519
  disabled,
7163
7520
  type: "number",
7164
- className: numberInputClass,
7521
+ className: refractionInputClass,
7165
7522
  value: safe.glass_power_prescription.left_eye.axis ?? "",
7166
7523
  onChange: (e) => setRefractionField(
7167
7524
  "glass_power_prescription",
@@ -7172,13 +7529,13 @@ var OphthalmologyWidget = ({ fieldId }) => {
7172
7529
  )
7173
7530
  }
7174
7531
  ) }),
7175
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7532
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7176
7533
  Input,
7177
7534
  {
7178
7535
  disabled,
7179
7536
  type: "number",
7180
7537
  step: "0.25",
7181
- className: numberInputClass,
7538
+ className: refractionInputClass,
7182
7539
  value: safe.glass_power_prescription.left_eye.prism ?? "",
7183
7540
  onChange: (e) => setRefractionField(
7184
7541
  "glass_power_prescription",
@@ -7189,11 +7546,11 @@ var OphthalmologyWidget = ({ fieldId }) => {
7189
7546
  )
7190
7547
  }
7191
7548
  ) }),
7192
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7549
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, children: /* @__PURE__ */ jsxRuntime.jsx(
7193
7550
  "select",
7194
7551
  {
7195
7552
  disabled,
7196
- className: selectClass,
7553
+ className: refractionSelectClass,
7197
7554
  value: safe.glass_power_prescription.left_eye.va,
7198
7555
  onChange: (e) => setRefractionField(
7199
7556
  "glass_power_prescription",
@@ -7207,25 +7564,25 @@ var OphthalmologyWidget = ({ fieldId }) => {
7207
7564
  ) })
7208
7565
  ] }),
7209
7566
  /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
7210
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: cn(tableCellClass, "font-semibold text-left px-2"), children: "Add" }),
7211
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
7567
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionLabelCellClass, children: "Add" }),
7568
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
7212
7569
  Input,
7213
7570
  {
7214
7571
  disabled,
7215
7572
  type: "number",
7216
7573
  step: "0.25",
7217
- className: numberInputClass,
7574
+ className: refractionInputClass,
7218
7575
  value: safe.glass_power_prescription.add.right ?? "",
7219
7576
  onChange: (e) => setRefractionAdd("glass_power_prescription", "right", e.target.value)
7220
7577
  }
7221
7578
  ) }),
7222
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: tableCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
7579
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: refractionDataCellClass, colSpan: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
7223
7580
  Input,
7224
7581
  {
7225
7582
  disabled,
7226
7583
  type: "number",
7227
7584
  step: "0.25",
7228
- className: numberInputClass,
7585
+ className: refractionInputClass,
7229
7586
  value: safe.glass_power_prescription.add.left ?? "",
7230
7587
  onChange: (e) => setRefractionAdd("glass_power_prescription", "left", e.target.value)
7231
7588
  }
@@ -7912,123 +8269,2083 @@ var DischargeMedicationOrdersWidget = ({ fieldId }) => {
7912
8269
  showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
7913
8270
  ] });
7914
8271
  };
7915
- var FieldRenderer = ({ fieldId }) => {
7916
- const { fieldDef, visible } = useField(fieldId);
7917
- if (!visible || !fieldDef) {
7918
- return null;
8272
+ var DEFAULT_TOKEN_SEPARATOR = ", ";
8273
+ function getAppendSeparator(def) {
8274
+ const raw = def.meta && typeof def.meta.appendSeparator === "string" ? def.meta.appendSeparator : DEFAULT_TOKEN_SEPARATOR;
8275
+ return raw;
8276
+ }
8277
+ function getSuggestionTokensFromText(text) {
8278
+ return text.split(",").map((p) => p.trim()).filter(Boolean);
8279
+ }
8280
+ function toggleSuggestionTokenInText(current, token, separator = DEFAULT_TOKEN_SEPARATOR) {
8281
+ const t = String(token).trim();
8282
+ if (!t) return current;
8283
+ const parts = getSuggestionTokensFromText(current);
8284
+ const i = parts.findIndex((p) => p === t);
8285
+ if (i >= 0) {
8286
+ parts.splice(i, 1);
8287
+ } else {
8288
+ parts.push(t);
8289
+ }
8290
+ return parts.join(separator);
8291
+ }
8292
+ function isTokenSelected(text, optionValue) {
8293
+ const t = String(optionValue).trim();
8294
+ if (!t) return false;
8295
+ return getSuggestionTokensFromText(text).some((p) => p === t);
8296
+ }
8297
+ function deriveKnownSuggestionChipValues(text, options) {
8298
+ if (!options.length) return [];
8299
+ const allowed = new Map(options.map((o) => [String(o.value), o.value]));
8300
+ const tokens = getSuggestionTokensFromText(text);
8301
+ const out = [];
8302
+ const seen = /* @__PURE__ */ new Set();
8303
+ for (const t of tokens) {
8304
+ if (!allowed.has(t) || seen.has(t)) continue;
8305
+ seen.add(t);
8306
+ out.push(allowed.get(t));
8307
+ }
8308
+ return out;
8309
+ }
8310
+ function parallelChipArraysEqual(a, b) {
8311
+ if (!Array.isArray(a) || !Array.isArray(b)) return false;
8312
+ if (a.length !== b.length) return false;
8313
+ for (let i = 0; i < a.length; i++) {
8314
+ if (a[i] !== b[i]) return false;
7919
8315
  }
7920
- return renderWidget(fieldId, fieldDef);
7921
- };
7922
- function renderWidget(fieldId, fieldDef) {
8316
+ return true;
8317
+ }
8318
+ function isSuggestionField(type) {
8319
+ return type === "suggestion_textarea" || type === "complaint_chips";
8320
+ }
8321
+ function EmbeddedSchemaField({ fieldId }) {
8322
+ const store = useFormStore();
8323
+ const fieldDef = store.getFieldDef(fieldId);
8324
+ if (!fieldDef) return null;
7923
8325
  switch (fieldDef.type) {
7924
8326
  case "text":
7925
8327
  case "number":
7926
- return /* @__PURE__ */ jsxRuntime.jsx(TextWidget, { fieldId });
7927
8328
  case "textarea":
7928
- if (fieldMetaRequestsMarMedicationOrdersButton(fieldDef.meta)) {
7929
- return /* @__PURE__ */ jsxRuntime.jsx(MarMedicationOrdersWidget, { fieldId });
7930
- }
7931
8329
  return /* @__PURE__ */ jsxRuntime.jsx(TextWidget, { fieldId });
7932
- case "richtext":
7933
- return /* @__PURE__ */ jsxRuntime.jsx(RichTextWidget, { fieldId });
7934
- case "date":
7935
- return /* @__PURE__ */ jsxRuntime.jsx(DateWidget, { fieldId });
7936
- case "datetime":
7937
- return /* @__PURE__ */ jsxRuntime.jsx(DateTimeWidget, { fieldId });
7938
8330
  case "select":
7939
8331
  return /* @__PURE__ */ jsxRuntime.jsx(SelectWidget, { fieldId });
7940
- case "radio":
7941
- return /* @__PURE__ */ jsxRuntime.jsx(RadioWidget, { fieldId });
7942
- case "checkbox":
7943
- return /* @__PURE__ */ jsxRuntime.jsx(CheckboxWidget, { fieldId });
7944
- case "multiselect":
7945
- return /* @__PURE__ */ jsxRuntime.jsx(MultiSelectWidget, { fieldId });
7946
- case "repeatable":
7947
- return /* @__PURE__ */ jsxRuntime.jsx(RepeatableWidget, { fieldId });
7948
- case "image_upload":
7949
- return /* @__PURE__ */ jsxRuntime.jsx(ImageUploadWidget, { fieldId });
7950
- case "media_upload":
7951
- return /* @__PURE__ */ jsxRuntime.jsx(MediaUploadWidget, { fieldId });
7952
- case "signature":
7953
- return /* @__PURE__ */ jsxRuntime.jsx(SignatureUploadWidget, { fieldId });
7954
- case "editable_table":
7955
- return /* @__PURE__ */ jsxRuntime.jsx(EditableTableWidget, { fieldId });
7956
- case "medications":
7957
- return /* @__PURE__ */ jsxRuntime.jsx(AddMedicationWidget, { fieldId });
7958
- case "discharge_medication_orders":
7959
- return /* @__PURE__ */ jsxRuntime.jsx(DischargeMedicationOrdersWidget, { fieldId });
7960
- case "investigations":
7961
- return /* @__PURE__ */ jsxRuntime.jsx(AddInvestigationWidget, { fieldId });
7962
- case "procedures":
7963
- return /* @__PURE__ */ jsxRuntime.jsx(AddProcedureWidget, { fieldId });
7964
- case "differential_diagnosis":
7965
- return /* @__PURE__ */ jsxRuntime.jsx(DifferentialDiagnosisWidget, { fieldId });
7966
- case "vitals":
7967
- return /* @__PURE__ */ jsxRuntime.jsx(VitalsWidget, { fieldId });
7968
- case "hidden_vitals":
7969
- return /* @__PURE__ */ jsxRuntime.jsx(HiddenVitalsWidget, { fieldId });
7970
- case "referral":
7971
- return /* @__PURE__ */ jsxRuntime.jsx(ReferralWidget, { fieldId });
7972
- case "followup":
7973
- return /* @__PURE__ */ jsxRuntime.jsx(FollowupWidget, { fieldId });
7974
- case "smart_textarea":
7975
- return /* @__PURE__ */ jsxRuntime.jsx(SmartTextareaWidget, { fieldId });
7976
- case "diagnosis_textarea":
7977
- return /* @__PURE__ */ jsxRuntime.jsx(DiagnosisTextareaWidget, { fieldId });
7978
- case "obstetric_history":
7979
- return /* @__PURE__ */ jsxRuntime.jsx(ObstetricHistoryWidget, { fieldId });
7980
- case "eye_prescription":
7981
- return /* @__PURE__ */ jsxRuntime.jsx(OphthalmologyWidget, { fieldId });
7982
- case "ophthal_diagnosis":
7983
- return /* @__PURE__ */ jsxRuntime.jsx(OphthalDiagnosisWidget, { fieldId });
7984
- case "orthopedic_exam":
7985
- return /* @__PURE__ */ jsxRuntime.jsx(OrthopedicExamWidget, { fieldId });
7986
- case "toggle": {
7987
- const { value, setValue, setTouched, disabled } = useField(fieldId);
7988
- const store = useFormStore();
7989
- const excludes = fieldDef.excludes ?? [];
7990
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
7991
- /* @__PURE__ */ jsxRuntime.jsx(
7992
- Switch,
7993
- {
7994
- checked: value === true,
7995
- disabled,
7996
- onCheckedChange: (checked) => {
7997
- setValue(checked);
7998
- setTouched();
7999
- if (checked) excludes.forEach((id) => store.setValue(id, false));
8000
- }
8001
- }
8002
- ),
8003
- /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium leading-none cursor-pointer select-none", children: fieldDef.label })
8004
- ] });
8005
- }
8006
- case "static_text": {
8007
- const def = fieldDef;
8008
- const size = def.size ?? "regular";
8009
- const labelClass = size === "large" ? "text-base" : "text-sm";
8010
- const descClass = size === "large" ? "text-sm" : "text-xs";
8011
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${labelClass} text-muted-foreground`, children: [
8012
- def.label,
8013
- def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: `mt-1 ${descClass} opacity-90`, children: def.description })
8014
- ] });
8015
- }
8016
8332
  default:
8017
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-red-500", children: [
8018
- "Unknown field type: ",
8019
- fieldDef.type
8020
- ] });
8333
+ return null;
8021
8334
  }
8022
8335
  }
8023
- var Section = ({ title, children }) => {
8024
- const [expanded, setExpanded] = React15.useState(true);
8025
- const handleToggle = () => setExpanded((prev) => !prev);
8026
- const contentClassName = cn(
8027
- "overflow-hidden transition-[height] duration-200 ease-in-out",
8028
- !expanded && "hidden"
8029
- );
8030
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-6 border rounded-lg bg-white shadow-sm overflow-hidden", children: [
8031
- /* @__PURE__ */ jsxRuntime.jsxs(
8336
+ var SuggestionTextareaWidget = ({ fieldId }) => {
8337
+ const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
8338
+ const { state } = useForm();
8339
+ const store = useFormStore();
8340
+ const hasVoice = !!(fieldDef?.voice && store.getVoice());
8341
+ const [options, setOptions] = React15.useState([]);
8342
+ const [loading, setLoading] = React15.useState(false);
8343
+ const showError = !!error && (touched || state.submitAttempted);
8344
+ const def = fieldDef && isSuggestionField(fieldDef.type) ? fieldDef : void 0;
8345
+ const textValue = value == null || typeof value === "string" ? value || "" : String(value);
8346
+ const parallelChipFieldId = def?.meta && typeof def.meta.parallelChipFieldId === "string" ? def.meta.parallelChipFieldId.trim() : void 0;
8347
+ const embeddedFieldIds = React15.useMemo(() => {
8348
+ const raw = def?.meta && Array.isArray(def.meta.embeddedFieldIds) ? def.meta.embeddedFieldIds : [];
8349
+ return raw.filter((id) => typeof id === "string" && id.trim().length > 0).map((id) => id.trim()).filter((id) => store.getFieldDef(id));
8350
+ }, [def?.meta, store]);
8351
+ React15.useEffect(() => {
8352
+ if (!def) {
8353
+ setOptions([]);
8354
+ return;
8355
+ }
8356
+ if (def.options?.length) {
8357
+ setOptions(def.options);
8358
+ } else if (def.dataSource) {
8359
+ setLoading(true);
8360
+ fetchOptions(def.dataSource.source, def.dataSource.params).then((opts) => setOptions(opts)).finally(() => setLoading(false));
8361
+ } else {
8362
+ setOptions([]);
8363
+ }
8364
+ }, [def]);
8365
+ React15.useEffect(() => {
8366
+ if (!parallelChipFieldId || !def) return;
8367
+ const parallelDef = store.getFieldDef(parallelChipFieldId);
8368
+ if (!parallelDef || parallelDef.type !== "multiselect") return;
8369
+ const next = deriveKnownSuggestionChipValues(textValue, options);
8370
+ const prev = store.getFieldState(parallelChipFieldId).value;
8371
+ if (parallelChipArraysEqual(prev, next)) return;
8372
+ store.setValues({ [parallelChipFieldId]: next }, { touch: false });
8373
+ }, [def, parallelChipFieldId, textValue, options, store]);
8374
+ if (!def) {
8375
+ return null;
8376
+ }
8377
+ const appendSeparator = getAppendSeparator(def);
8378
+ const suggestionsAria = def.meta && typeof def.meta.suggestionsAriaLabel === "string" ? def.meta.suggestionsAriaLabel : "Quick suggestions";
8379
+ const theme = getThemeConfig("textarea", def.theme);
8380
+ const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
8381
+ const labelClass = theme?.labelClassName;
8382
+ const inputClass = cn(theme?.inputClassName, showError && "border-red-500");
8383
+ const height = def.height != null ? typeof def.height === "string" ? Number(def.height) || void 0 : def.height : void 0;
8384
+ const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
8385
+ def.label,
8386
+ " ",
8387
+ def.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
8388
+ ] });
8389
+ const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { children: labelContent });
8390
+ const onChipClick = (optValue) => {
8391
+ if (disabled) return;
8392
+ setValue(toggleSuggestionTokenInText(textValue, String(optValue), appendSeparator));
8393
+ };
8394
+ const hasSuggestions = options.length > 0;
8395
+ const hasEmbedded = embeddedFieldIds.length > 0;
8396
+ const hasShell = hasSuggestions || hasEmbedded;
8397
+ const isHighlightLabel = def.theme === "highlight-label";
8398
+ const suggestionShellClass = cn(
8399
+ "flex min-w-0 flex-col overflow-hidden",
8400
+ hasShell && (isHighlightLabel ? "-mt-1 rounded-b-md border-[#D0D0D0] bg-white" : "rounded-md border border-input bg-background")
8401
+ );
8402
+ const chipsRowClass = cn(
8403
+ "flex flex-wrap gap-2 px-3 pb-2 pt-3",
8404
+ hasSuggestions && (isHighlightLabel ? "" : "border-b border-input/70"),
8405
+ disabled && "pointer-events-none opacity-50"
8406
+ );
8407
+ const embeddedRowClass = cn(
8408
+ "grid gap-3 px-3 sm:grid-cols-3",
8409
+ hasEmbedded && (hasSuggestions ? cn("py-2", isHighlightLabel && "border-t border-input/70") : "border-b border-input/70 py-3"),
8410
+ disabled && "pointer-events-none opacity-50"
8411
+ );
8412
+ const textareaShellClass = cn(
8413
+ inputClass,
8414
+ hasShell && cn(
8415
+ "mt-0 rounded-t-none rounded-b-md border-0 shadow-none focus-visible:ring-offset-0",
8416
+ isHighlightLabel ? "border-t-0" : "min-h-[80px]"
8417
+ )
8418
+ );
8419
+ const suggestionButtons = loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: "Loading suggestions\u2026" }) : options.map((opt) => {
8420
+ const on = isTokenSelected(textValue, opt.value);
8421
+ return /* @__PURE__ */ jsxRuntime.jsx(
8422
+ "button",
8423
+ {
8424
+ type: "button",
8425
+ onClick: () => onChipClick(opt.value),
8426
+ className: cn(
8427
+ "inline-flex min-h-8 items-center rounded-full border px-3 py-1 text-xs font-medium leading-none transition-colors",
8428
+ on ? "border-primary bg-primary/10 text-primary" : "border-muted-foreground/30 bg-background hover:bg-muted/60"
8429
+ ),
8430
+ children: opt.label
8431
+ },
8432
+ String(opt.value)
8433
+ );
8434
+ });
8435
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperClass, children: [
8436
+ hasVoice ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
8437
+ labelEl,
8438
+ /* @__PURE__ */ jsxRuntime.jsx(VoiceMicButton, { fieldId, onTranscriptReady: setValue })
8439
+ ] }) : labelEl,
8440
+ def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: def.description }),
8441
+ hasShell ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: suggestionShellClass, children: [
8442
+ hasSuggestions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: chipsRowClass, role: "group", "aria-label": suggestionsAria, children: suggestionButtons }),
8443
+ hasEmbedded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: embeddedRowClass, children: embeddedFieldIds.map((id) => /* @__PURE__ */ jsxRuntime.jsx(EmbeddedSchemaField, { fieldId: id }, id)) }),
8444
+ /* @__PURE__ */ jsxRuntime.jsx(
8445
+ Textarea,
8446
+ {
8447
+ id: fieldId,
8448
+ value: textValue,
8449
+ onChange: (e) => setValue(e.target.value),
8450
+ onBlur: setTouched,
8451
+ disabled,
8452
+ className: textareaShellClass,
8453
+ placeholder: def.placeholder,
8454
+ style: height != null && Number.isFinite(height) ? { minHeight: height } : void 0
8455
+ }
8456
+ )
8457
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx(
8458
+ Textarea,
8459
+ {
8460
+ id: fieldId,
8461
+ value: textValue,
8462
+ onChange: (e) => setValue(e.target.value),
8463
+ onBlur: setTouched,
8464
+ disabled,
8465
+ className: inputClass,
8466
+ placeholder: def.placeholder,
8467
+ style: height != null && Number.isFinite(height) ? { minHeight: height } : void 0
8468
+ }
8469
+ ),
8470
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
8471
+ ] });
8472
+ };
8473
+ var EMPTY_GRADES = { NO: 0, NC: 0, C: 0, PSC: 0 };
8474
+ var LOCS_FIELDS = [
8475
+ { key: "NO", label: "Nuclear Opalescence", max: 4, hint: "0\u20134" },
8476
+ { key: "NC", label: "Nuclear Colour", max: 4, hint: "0\u20134" },
8477
+ { key: "C", label: "Cortical", max: 4, hint: "0\u20134" },
8478
+ { key: "PSC", label: "Posterior Subcapsular", max: 4, hint: "0\u20134" }
8479
+ ];
8480
+ var LOCS_GRID_STYLE = {
8481
+ display: "grid",
8482
+ gridTemplateColumns: "minmax(0, 1fr) minmax(5.5rem, auto) minmax(5.5rem, auto)",
8483
+ columnGap: "1rem",
8484
+ rowGap: "0.5rem",
8485
+ alignItems: "center",
8486
+ width: "100%",
8487
+ minWidth: 0
8488
+ };
8489
+ function parseGrades(raw) {
8490
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
8491
+ const r = raw;
8492
+ const n = (k) => {
8493
+ const v = Number(r[k]);
8494
+ return Number.isFinite(v) ? Math.trunc(v) : 0;
8495
+ };
8496
+ return { NO: n("NO"), NC: n("NC"), C: n("C"), PSC: n("PSC") };
8497
+ }
8498
+ function clampGrade(v) {
8499
+ return Math.max(0, Math.min(4, Math.trunc(v)));
8500
+ }
8501
+ function parseValue(raw) {
8502
+ const locs = {
8503
+ OD: { ...EMPTY_GRADES },
8504
+ OS: { ...EMPTY_GRADES }
8505
+ };
8506
+ if (raw && typeof raw === "object" && !Array.isArray(raw)) {
8507
+ const o = raw;
8508
+ const locsRaw = o.locs;
8509
+ if (locsRaw && typeof locsRaw === "object" && !Array.isArray(locsRaw)) {
8510
+ const L = locsRaw;
8511
+ const od = parseGrades(L.OD);
8512
+ const os = parseGrades(L.OS);
8513
+ if (od)
8514
+ locs.OD = {
8515
+ NO: clampGrade(od.NO),
8516
+ NC: clampGrade(od.NC),
8517
+ C: clampGrade(od.C),
8518
+ PSC: clampGrade(od.PSC)
8519
+ };
8520
+ if (os)
8521
+ locs.OS = {
8522
+ NO: clampGrade(os.NO),
8523
+ NC: clampGrade(os.NC),
8524
+ C: clampGrade(os.C),
8525
+ PSC: clampGrade(os.PSC)
8526
+ };
8527
+ }
8528
+ return {
8529
+ notes: typeof o.notes === "string" ? o.notes : "",
8530
+ assessmentKey: typeof o.assessmentKey === "string" ? o.assessmentKey : void 0,
8531
+ locs
8532
+ };
8533
+ }
8534
+ return { notes: "", assessmentKey: void 0, locs };
8535
+ }
8536
+ function cataractStage(eye, locs) {
8537
+ const g = locs[eye];
8538
+ const total = g.NO + g.NC + g.C + g.PSC;
8539
+ if (total === 0) return "\u2014";
8540
+ if (total <= 4) return "Early";
8541
+ if (total <= 8) return "Moderate";
8542
+ if (total <= 12) return "Advanced";
8543
+ return "Hypermature";
8544
+ }
8545
+ function Stepper({
8546
+ value,
8547
+ max,
8548
+ disabled,
8549
+ ariaLabel,
8550
+ onChange
8551
+ }) {
8552
+ return /* @__PURE__ */ jsxRuntime.jsxs(
8553
+ "div",
8554
+ {
8555
+ className: "flex items-center gap-1 justify-self-center",
8556
+ role: "group",
8557
+ "aria-label": ariaLabel,
8558
+ children: [
8559
+ /* @__PURE__ */ jsxRuntime.jsx(
8560
+ "button",
8561
+ {
8562
+ type: "button",
8563
+ disabled,
8564
+ onClick: () => onChange(Math.max(0, value - 1)),
8565
+ className: "h-6 w-6 shrink-0 rounded border border-input text-xs hover:bg-muted disabled:pointer-events-none disabled:opacity-50",
8566
+ children: "-"
8567
+ }
8568
+ ),
8569
+ /* @__PURE__ */ jsxRuntime.jsx(
8570
+ "input",
8571
+ {
8572
+ type: "number",
8573
+ min: 0,
8574
+ max,
8575
+ disabled,
8576
+ value,
8577
+ "aria-label": ariaLabel,
8578
+ onChange: (e) => onChange(Math.max(0, Math.min(max, Number(e.target.value) || 0))),
8579
+ className: "h-6 w-10 shrink-0 rounded border border-input bg-background px-1 py-0 text-center text-xs disabled:opacity-50"
8580
+ }
8581
+ ),
8582
+ /* @__PURE__ */ jsxRuntime.jsx(
8583
+ "button",
8584
+ {
8585
+ type: "button",
8586
+ disabled,
8587
+ onClick: () => onChange(Math.min(max, value + 1)),
8588
+ className: "h-6 w-6 shrink-0 rounded border border-input text-xs hover:bg-muted disabled:pointer-events-none disabled:opacity-50",
8589
+ children: "+"
8590
+ }
8591
+ )
8592
+ ]
8593
+ }
8594
+ );
8595
+ }
8596
+ function StageBadge({ stage }) {
8597
+ const cls = {
8598
+ Early: "border border-emerald-200 text-foreground",
8599
+ Moderate: "border border-amber-200 text-foreground",
8600
+ Advanced: "border border-orange-300 text-foreground",
8601
+ Hypermature: "border border-destructive text-foreground",
8602
+ "\u2014": "border border-border text-muted-foreground"
8603
+ };
8604
+ return /* @__PURE__ */ jsxRuntime.jsx(
8605
+ "span",
8606
+ {
8607
+ className: cn(
8608
+ "rounded-full bg-background px-2 py-0.5 text-[11px] font-medium",
8609
+ cls[stage] ?? "border border-border text-muted-foreground"
8610
+ ),
8611
+ children: stage
8612
+ }
8613
+ );
8614
+ }
8615
+ var DEFAULT_TITLE = "Lens Assessment \u2014 LOCS III";
8616
+ var LensAssessmentWidget = ({ fieldId }) => {
8617
+ const { fieldDef, value, setValue, error, disabled, touched } = useField(fieldId);
8618
+ const { state } = useForm();
8619
+ const showError = !!error && (touched || state.submitAttempted);
8620
+ if (!fieldDef || fieldDef.type !== "lens_assessment") {
8621
+ return null;
8622
+ }
8623
+ const def = fieldDef;
8624
+ const v = parseValue(value);
8625
+ const locs = v.locs ?? { OD: { ...EMPTY_GRADES }, OS: { ...EMPTY_GRADES } };
8626
+ const title = def.meta?.cardTitle || (def.label?.trim() ? def.label : DEFAULT_TITLE);
8627
+ const setPartial = (patch) => {
8628
+ setValue({ ...v, ...patch, locs: patch.locs ?? v.locs ?? locs });
8629
+ };
8630
+ const setLocs = (eye, key, n) => {
8631
+ const next = clampGrade(n);
8632
+ setPartial({
8633
+ locs: {
8634
+ ...locs,
8635
+ [eye]: { ...locs[eye], [key]: next }
8636
+ }
8637
+ });
8638
+ };
8639
+ return /* @__PURE__ */ jsxRuntime.jsxs(
8640
+ "div",
8641
+ {
8642
+ id: `lens-assessment-${fieldId}`,
8643
+ className: "w-full min-w-0 max-w-full rounded-lg border border-border bg-card p-4 text-card-foreground shadow-sm",
8644
+ children: [
8645
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "mb-3 text-sm font-semibold text-foreground", children: title }),
8646
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: LOCS_GRID_STYLE, children: [
8647
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-0", "aria-hidden": true }),
8648
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-24 justify-self-center text-center text-xs font-semibold", children: "Right Eye" }),
8649
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-24 justify-self-center text-center text-xs font-semibold", children: "Left Eye" }),
8650
+ LOCS_FIELDS.map((f) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "contents" }, children: [
8651
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 text-xs", children: [
8652
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-medium", children: f.label }),
8653
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground", children: f.hint })
8654
+ ] }),
8655
+ /* @__PURE__ */ jsxRuntime.jsx(
8656
+ Stepper,
8657
+ {
8658
+ value: locs.OD[f.key],
8659
+ max: f.max,
8660
+ disabled,
8661
+ ariaLabel: `${f.label} right eye`,
8662
+ onChange: (n) => setLocs("OD", f.key, n)
8663
+ }
8664
+ ),
8665
+ /* @__PURE__ */ jsxRuntime.jsx(
8666
+ Stepper,
8667
+ {
8668
+ value: locs.OS[f.key],
8669
+ max: f.max,
8670
+ disabled,
8671
+ ariaLabel: `${f.label} left eye`,
8672
+ onChange: (n) => setLocs("OS", f.key, n)
8673
+ }
8674
+ )
8675
+ ] }, f.key))
8676
+ ] }),
8677
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 border-t border-border pt-3 text-xs", children: [
8678
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Cataract Stage" }),
8679
+ " ",
8680
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-1 inline-flex items-center gap-1", children: [
8681
+ "OD ",
8682
+ /* @__PURE__ */ jsxRuntime.jsx(StageBadge, { stage: cataractStage("OD", locs) })
8683
+ ] }),
8684
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-2 inline-flex items-center gap-1", children: [
8685
+ "OS ",
8686
+ /* @__PURE__ */ jsxRuntime.jsx(StageBadge, { stage: cataractStage("OS", locs) })
8687
+ ] })
8688
+ ] }),
8689
+ def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: def.description }),
8690
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-red-500", children: error })
8691
+ ]
8692
+ }
8693
+ );
8694
+ };
8695
+
8696
+ // src/core/functionalImpairmentScore.ts
8697
+ function clampFunctionalScore03(n) {
8698
+ const v = typeof n === "number" ? n : Number(n);
8699
+ if (!Number.isFinite(v)) return 0;
8700
+ return Math.max(0, Math.min(3, Math.trunc(v)));
8701
+ }
8702
+ function parseFunctionalImpairmentScore(raw) {
8703
+ const base = {
8704
+ reading: 0,
8705
+ nightDriving: 0,
8706
+ glare: 0,
8707
+ occupation: 0,
8708
+ adl: 0
8709
+ };
8710
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return base;
8711
+ const o = raw;
8712
+ for (const k of Object.keys(base)) {
8713
+ base[k] = clampFunctionalScore03(o[k]);
8714
+ }
8715
+ return base;
8716
+ }
8717
+ function functionalImpairmentTotal(v) {
8718
+ return v.reading + v.nightDriving + v.glare + v.occupation + v.adl;
8719
+ }
8720
+ var ITEMS = [
8721
+ { key: "reading", label: "Difficulty reading" },
8722
+ { key: "nightDriving", label: "Night driving difficulty" },
8723
+ { key: "glare", label: "Glare sensitivity" },
8724
+ { key: "occupation", label: "Occupational impact" },
8725
+ { key: "adl", label: "ADL limitation" }
8726
+ ];
8727
+ var SCALE_LABELS = ["None", "Mild", "Moderate", "Severe"];
8728
+ var DEFAULT_TITLE2 = "Functional Impairment Score (Stage 5)";
8729
+ var ITEMS_GRID_STYLE = {
8730
+ display: "grid",
8731
+ gridTemplateColumns: "repeat(auto-fit, minmax(min(100%, 8rem), 1fr))",
8732
+ columnGap: "0.5rem",
8733
+ rowGap: "0.5rem",
8734
+ width: "100%",
8735
+ minWidth: 0
8736
+ };
8737
+ function clamp03(n) {
8738
+ const v = typeof n === "number" ? n : Number(n);
8739
+ if (!Number.isFinite(v)) return 0;
8740
+ return Math.max(0, Math.min(3, Math.trunc(v)));
8741
+ }
8742
+ var FunctionalImpairmentScoreWidget = ({
8743
+ fieldId
8744
+ }) => {
8745
+ const { fieldDef, value, setValue, error, disabled, touched } = useField(fieldId);
8746
+ const { state } = useForm();
8747
+ const showError = !!error && (touched || state.submitAttempted);
8748
+ if (!fieldDef || fieldDef.type !== "functional_impairment_score") {
8749
+ return null;
8750
+ }
8751
+ const def = fieldDef;
8752
+ const v = parseFunctionalImpairmentScore(value);
8753
+ const total = functionalImpairmentTotal(v);
8754
+ const title = def.meta?.cardTitle?.trim() || (def.label?.trim() ? def.label : DEFAULT_TITLE2);
8755
+ const setDim = (key, n) => {
8756
+ setValue({ ...v, [key]: clamp03(n) });
8757
+ };
8758
+ return /* @__PURE__ */ jsxRuntime.jsxs(
8759
+ "div",
8760
+ {
8761
+ id: `functional-impairment-${fieldId}`,
8762
+ className: "w-full min-w-0 max-w-full rounded-lg border border-border bg-card p-3 text-card-foreground shadow-sm",
8763
+ children: [
8764
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "mb-2 text-xs font-semibold leading-tight text-foreground sm:text-[13px]", children: title }),
8765
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: ITEMS_GRID_STYLE, children: ITEMS.map((it) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-col gap-1", children: [
8766
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[10px] font-medium leading-snug text-foreground sm:text-[11px]", children: it.label }),
8767
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-fit max-w-full shrink-0 gap-0.5", children: [0, 1, 2, 3].map((score) => /* @__PURE__ */ jsxRuntime.jsx(
8768
+ "button",
8769
+ {
8770
+ type: "button",
8771
+ title: SCALE_LABELS[score],
8772
+ disabled,
8773
+ onClick: () => setDim(it.key, score),
8774
+ className: cn(
8775
+ "h-6 w-7 shrink-0 rounded border text-[10px] transition-colors sm:text-[11px]",
8776
+ v[it.key] === score ? "border-primary bg-primary text-primary-foreground" : "border-input hover:bg-muted",
8777
+ disabled && "pointer-events-none opacity-50"
8778
+ ),
8779
+ children: score
8780
+ },
8781
+ score
8782
+ )) })
8783
+ ] }, it.key)) }),
8784
+ /* @__PURE__ */ jsxRuntime.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: [
8785
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[10px] leading-snug text-muted-foreground sm:text-[11px]", children: "Score scale: 0 = none, 3 = severe (each item)" }),
8786
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-1.5 sm:justify-end", children: [
8787
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-muted-foreground sm:text-[11px]", children: "Total" }),
8788
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm font-bold tabular-nums sm:text-[15px]", children: [
8789
+ total,
8790
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-normal text-muted-foreground", children: "/15" })
8791
+ ] })
8792
+ ] })
8793
+ ] }),
8794
+ def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: def.description }),
8795
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-red-500", children: error })
8796
+ ]
8797
+ }
8798
+ );
8799
+ };
8800
+ var FORMULA_OPTIONS = [
8801
+ "SRK/T",
8802
+ "Barrett Universal II",
8803
+ "Hoffer Q",
8804
+ "Haigis",
8805
+ "Holladay 1",
8806
+ "Holladay 2",
8807
+ "Kane"
8808
+ ];
8809
+ var METHODS = [
8810
+ { value: "optical_biometry", label: "Optical biometry (IOL Master)" },
8811
+ { value: "ascan_immersion", label: "A-scan (immersion)" },
8812
+ { value: "ascan_contact", label: "A-scan (contact)" }
8813
+ ];
8814
+ var EMPTY = {
8815
+ axialLengthOD: "",
8816
+ axialLengthOS: "",
8817
+ k1k2AxisOD: "",
8818
+ k1k2AxisOS: "",
8819
+ anteriorChamberDepthOD: "",
8820
+ anteriorChamberDepthOS: "",
8821
+ iolPowerOD: "",
8822
+ iolPowerOS: "",
8823
+ targetRefractionOD: "",
8824
+ targetRefractionOS: "",
8825
+ formula: "SRK/T",
8826
+ method: "optical_biometry",
8827
+ cornealTopoUploaded: false,
8828
+ specularMicroscopyDone: false,
8829
+ endothelialCount: ""
8830
+ };
8831
+ function str(x) {
8832
+ return typeof x === "string" ? x : "";
8833
+ }
8834
+ function parseValue2(raw) {
8835
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return { ...EMPTY };
8836
+ const o = raw;
8837
+ const m = o.method;
8838
+ const method = m === "ascan_immersion" || m === "ascan_contact" || m === "optical_biometry" ? m : "optical_biometry";
8839
+ const formula = str(o.formula);
8840
+ return {
8841
+ ...EMPTY,
8842
+ axialLengthOD: str(o.axialLengthOD),
8843
+ axialLengthOS: str(o.axialLengthOS),
8844
+ k1k2AxisOD: str(o.k1k2AxisOD),
8845
+ k1k2AxisOS: str(o.k1k2AxisOS),
8846
+ anteriorChamberDepthOD: str(o.anteriorChamberDepthOD),
8847
+ anteriorChamberDepthOS: str(o.anteriorChamberDepthOS),
8848
+ iolPowerOD: str(o.iolPowerOD),
8849
+ iolPowerOS: str(o.iolPowerOS),
8850
+ targetRefractionOD: str(o.targetRefractionOD),
8851
+ targetRefractionOS: str(o.targetRefractionOS),
8852
+ formula: formula || "SRK/T",
8853
+ method,
8854
+ cornealTopoUploaded: o.cornealTopoUploaded === true,
8855
+ specularMicroscopyDone: o.specularMicroscopyDone === true,
8856
+ endothelialCount: str(o.endothelialCount)
8857
+ };
8858
+ }
8859
+ var paramCell = "emr-biometry-param text-[11px] font-semibold leading-snug text-foreground sm:text-xs py-2";
8860
+ var eyeTh = "emr-biometry-eye text-center text-[11px] font-semibold sm:text-xs py-2";
8861
+ function Inp({
8862
+ value,
8863
+ onChange,
8864
+ disabled,
8865
+ placeholder
8866
+ }) {
8867
+ return /* @__PURE__ */ jsxRuntime.jsx(
8868
+ "input",
8869
+ {
8870
+ value,
8871
+ disabled,
8872
+ placeholder,
8873
+ onChange: (e) => onChange(e.target.value),
8874
+ className: "box-border w-full min-w-0 rounded border border-input bg-background px-2 py-1 text-[11px] sm:text-xs"
8875
+ }
8876
+ );
8877
+ }
8878
+ var DEFAULT_TITLE3 = "Biometry & IOL Workup (Stage 7)";
8879
+ var BiometryIolWorkupWidget = ({ fieldId }) => {
8880
+ const { fieldDef, value, setValue, error, disabled, touched } = useField(fieldId);
8881
+ const { state } = useForm();
8882
+ const showError = !!error && (touched || state.submitAttempted);
8883
+ if (!fieldDef || fieldDef.type !== "biometry_iol_workup") {
8884
+ return null;
8885
+ }
8886
+ const def = fieldDef;
8887
+ const v = parseValue2(value);
8888
+ const title = def.meta?.cardTitle?.trim() || (def.label?.trim() ? def.label : DEFAULT_TITLE3);
8889
+ const patch = (p) => setValue({ ...v, ...p });
8890
+ return /* @__PURE__ */ jsxRuntime.jsxs(
8891
+ "div",
8892
+ {
8893
+ id: `biometry-iol-${fieldId}`,
8894
+ 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",
8895
+ children: [
8896
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "mb-2.5 text-sm font-semibold leading-tight text-foreground", children: title }),
8897
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full min-w-0 overflow-x-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "emr-table emr-table--biometry min-w-full", children: [
8898
+ /* @__PURE__ */ jsxRuntime.jsxs("colgroup", { children: [
8899
+ /* @__PURE__ */ jsxRuntime.jsx("col", { style: { width: "32%" } }),
8900
+ /* @__PURE__ */ jsxRuntime.jsx("col", { style: { width: "34%" } }),
8901
+ /* @__PURE__ */ jsxRuntime.jsx("col", { style: { width: "34%" } })
8902
+ ] }),
8903
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
8904
+ /* @__PURE__ */ jsxRuntime.jsx("th", { scope: "col", className: paramCell, children: "Parameter" }),
8905
+ /* @__PURE__ */ jsxRuntime.jsx("th", { scope: "col", className: eyeTh, children: "Right Eye" }),
8906
+ /* @__PURE__ */ jsxRuntime.jsx("th", { scope: "col", className: eyeTh, children: "Left Eye" })
8907
+ ] }) }),
8908
+ /* @__PURE__ */ jsxRuntime.jsxs("tbody", { children: [
8909
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
8910
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: paramCell, children: "Axial Length (mm)" }),
8911
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
8912
+ Inp,
8913
+ {
8914
+ value: v.axialLengthOD,
8915
+ disabled,
8916
+ placeholder: "e.g. 23.45",
8917
+ onChange: (s) => patch({ axialLengthOD: s })
8918
+ }
8919
+ ) }),
8920
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
8921
+ Inp,
8922
+ {
8923
+ value: v.axialLengthOS,
8924
+ disabled,
8925
+ placeholder: "e.g. 23.45",
8926
+ onChange: (s) => patch({ axialLengthOS: s })
8927
+ }
8928
+ ) })
8929
+ ] }),
8930
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
8931
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: paramCell, children: "K1 / K2 / Axis" }),
8932
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
8933
+ Inp,
8934
+ {
8935
+ value: v.k1k2AxisOD,
8936
+ disabled,
8937
+ placeholder: "44.0 / 44.5 / 90",
8938
+ onChange: (s) => patch({ k1k2AxisOD: s })
8939
+ }
8940
+ ) }),
8941
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
8942
+ Inp,
8943
+ {
8944
+ value: v.k1k2AxisOS,
8945
+ disabled,
8946
+ placeholder: "44.0 / 44.5 / 90",
8947
+ onChange: (s) => patch({ k1k2AxisOS: s })
8948
+ }
8949
+ ) })
8950
+ ] }),
8951
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
8952
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: `${paramCell} whitespace-nowrap`, children: "Anterior Chamber Depth (mm)" }),
8953
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
8954
+ Inp,
8955
+ {
8956
+ value: v.anteriorChamberDepthOD,
8957
+ disabled,
8958
+ onChange: (s) => patch({ anteriorChamberDepthOD: s })
8959
+ }
8960
+ ) }),
8961
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
8962
+ Inp,
8963
+ {
8964
+ value: v.anteriorChamberDepthOS,
8965
+ disabled,
8966
+ onChange: (s) => patch({ anteriorChamberDepthOS: s })
8967
+ }
8968
+ ) })
8969
+ ] }),
8970
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
8971
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: paramCell, children: "IOL Power (D)" }),
8972
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(Inp, { value: v.iolPowerOD, disabled, onChange: (s) => patch({ iolPowerOD: s }) }) }),
8973
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(Inp, { value: v.iolPowerOS, disabled, onChange: (s) => patch({ iolPowerOS: s }) }) })
8974
+ ] }),
8975
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
8976
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: paramCell, children: "Target Refraction (D)" }),
8977
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
8978
+ Inp,
8979
+ {
8980
+ value: v.targetRefractionOD,
8981
+ disabled,
8982
+ placeholder: "e.g. -0.25",
8983
+ onChange: (s) => patch({ targetRefractionOD: s })
8984
+ }
8985
+ ) }),
8986
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "emr-biometry-eye min-w-0 px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
8987
+ Inp,
8988
+ {
8989
+ value: v.targetRefractionOS,
8990
+ disabled,
8991
+ placeholder: "e.g. -0.25",
8992
+ onChange: (s) => patch({ targetRefractionOS: s })
8993
+ }
8994
+ ) })
8995
+ ] }),
8996
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
8997
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: paramCell, children: "Formula" }),
8998
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 px-2 py-2 align-middle", colSpan: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
8999
+ "select",
9000
+ {
9001
+ value: v.formula,
9002
+ disabled,
9003
+ onChange: (e) => patch({ formula: e.target.value }),
9004
+ className: "box-border w-full min-w-0 rounded border border-input bg-background px-2 py-1 text-[11px] sm:text-xs",
9005
+ children: FORMULA_OPTIONS.map((opt) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: opt, children: opt }, opt))
9006
+ }
9007
+ ) })
9008
+ ] }),
9009
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
9010
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: `${paramCell} align-top`, children: "Method" }),
9011
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 px-2 py-2 align-middle", colSpan: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
9012
+ "div",
9013
+ {
9014
+ role: "radiogroup",
9015
+ "aria-label": "Biometry method",
9016
+ 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",
9017
+ children: METHODS.map(({ value: mv, label }) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex min-w-0 shrink-0 cursor-pointer items-center gap-1.5", children: [
9018
+ /* @__PURE__ */ jsxRuntime.jsx(
9019
+ "input",
9020
+ {
9021
+ type: "radio",
9022
+ name: `${fieldId}-biom-method`,
9023
+ value: mv,
9024
+ checked: v.method === mv,
9025
+ disabled,
9026
+ onChange: () => patch({ method: mv }),
9027
+ className: "shrink-0"
9028
+ }
9029
+ ),
9030
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 whitespace-nowrap leading-tight", children: label })
9031
+ ] }, mv))
9032
+ }
9033
+ ) })
9034
+ ] }),
9035
+ /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
9036
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: `${paramCell} align-top text-muted-foreground`, children: "Optional workup" }),
9037
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 px-2 py-2 align-middle", colSpan: 2, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
9038
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center justify-center gap-x-4 gap-y-2 sm:justify-between", children: [
9039
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex min-w-0 cursor-pointer items-center gap-1.5 text-[11px] leading-snug sm:text-xs", children: [
9040
+ /* @__PURE__ */ jsxRuntime.jsx(
9041
+ "input",
9042
+ {
9043
+ type: "checkbox",
9044
+ className: "shrink-0",
9045
+ checked: v.cornealTopoUploaded,
9046
+ disabled,
9047
+ onChange: (e) => patch({ cornealTopoUploaded: e.target.checked })
9048
+ }
9049
+ ),
9050
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Corneal topography uploaded" })
9051
+ ] }),
9052
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex min-w-0 cursor-pointer items-center gap-1.5 text-[11px] leading-snug sm:text-xs", children: [
9053
+ /* @__PURE__ */ jsxRuntime.jsx(
9054
+ "input",
9055
+ {
9056
+ type: "checkbox",
9057
+ className: "shrink-0",
9058
+ checked: v.specularMicroscopyDone,
9059
+ disabled,
9060
+ onChange: (e) => patch({ specularMicroscopyDone: e.target.checked })
9061
+ }
9062
+ ),
9063
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Specular microscopy done" })
9064
+ ] })
9065
+ ] }),
9066
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center justify-end gap-2 text-[11px] sm:text-xs", children: [
9067
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 text-muted-foreground", children: "Endothelial count:" }),
9068
+ /* @__PURE__ */ jsxRuntime.jsx(
9069
+ "input",
9070
+ {
9071
+ value: v.endothelialCount,
9072
+ disabled,
9073
+ placeholder: "cells/mm\xB2",
9074
+ onChange: (e) => patch({ endothelialCount: e.target.value }),
9075
+ 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"
9076
+ }
9077
+ )
9078
+ ] })
9079
+ ] }) })
9080
+ ] })
9081
+ ] })
9082
+ ] }) }),
9083
+ def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: def.description }),
9084
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-red-500", children: error })
9085
+ ]
9086
+ }
9087
+ );
9088
+ };
9089
+ var RISKS = [
9090
+ "Small pupil",
9091
+ "Pseudoexfoliation",
9092
+ "Diabetes",
9093
+ "Shallow AC",
9094
+ "Previous ocular surgery",
9095
+ "Zonular weakness",
9096
+ "Mature/white cataract"
9097
+ ];
9098
+ var DIABETES = "Diabetes";
9099
+ function parseValue3(raw) {
9100
+ const empty = { OD: [], OS: [] };
9101
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return empty;
9102
+ const o = raw;
9103
+ const arr = (x) => Array.isArray(x) ? x.filter((i) => typeof i === "string") : [];
9104
+ let OD = arr(o.OD);
9105
+ let OS = arr(o.OS);
9106
+ const odD = OD.includes(DIABETES);
9107
+ const osD = OS.includes(DIABETES);
9108
+ if (odD !== osD) {
9109
+ if (odD && !osD) OS = [...OS, DIABETES];
9110
+ else if (osD && !odD) OD = [...OD, DIABETES];
9111
+ }
9112
+ return { OD, OS };
9113
+ }
9114
+ function riskTierForCount(n) {
9115
+ if (n === 0) return "Low";
9116
+ if (n <= 2) return "Moderate";
9117
+ return "High";
9118
+ }
9119
+ function tierBadgeClass(tier) {
9120
+ if (tier === "High") return "bg-red-600 text-white";
9121
+ if (tier === "Moderate") return "bg-amber-500 text-white";
9122
+ return "bg-emerald-600 text-white";
9123
+ }
9124
+ var DEFAULT_TITLE4 = "Surgical Risk Flags (Stage 11)";
9125
+ function RiskCol({
9126
+ eye,
9127
+ value,
9128
+ disabled,
9129
+ onToggle
9130
+ }) {
9131
+ const selected = new Set(value[eye]);
9132
+ const tier = riskTierForCount(selected.size);
9133
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
9134
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-2 flex items-center justify-between gap-2", children: [
9135
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs font-semibold text-foreground", children: eye === "OD" ? "Right Eye (OD)" : "Left Eye (OS)" }),
9136
+ /* @__PURE__ */ jsxRuntime.jsxs(
9137
+ "span",
9138
+ {
9139
+ className: cn(
9140
+ "whitespace-nowrap rounded-full px-2 py-0.5 text-[11px] font-medium",
9141
+ tierBadgeClass(tier)
9142
+ ),
9143
+ children: [
9144
+ tier,
9145
+ " risk"
9146
+ ]
9147
+ }
9148
+ )
9149
+ ] }),
9150
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1.5", children: RISKS.map((r) => /* @__PURE__ */ jsxRuntime.jsxs(
9151
+ "label",
9152
+ {
9153
+ className: "flex cursor-pointer items-center gap-2 rounded px-2 py-1 text-xs hover:bg-muted/50",
9154
+ children: [
9155
+ /* @__PURE__ */ jsxRuntime.jsx(
9156
+ "input",
9157
+ {
9158
+ type: "checkbox",
9159
+ className: "shrink-0",
9160
+ checked: selected.has(r),
9161
+ disabled,
9162
+ onChange: () => onToggle(eye, r)
9163
+ }
9164
+ ),
9165
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: r })
9166
+ ]
9167
+ },
9168
+ r
9169
+ )) })
9170
+ ] });
9171
+ }
9172
+ var SurgicalRiskFlagsWidget = ({ fieldId }) => {
9173
+ const { fieldDef, value, setValue, error, disabled, touched } = useField(fieldId);
9174
+ const { state } = useForm();
9175
+ const showError = !!error && (touched || state.submitAttempted);
9176
+ if (!fieldDef || fieldDef.type !== "surgical_risk_flags") {
9177
+ return null;
9178
+ }
9179
+ const def = fieldDef;
9180
+ const v = parseValue3(value);
9181
+ const title = def.meta?.cardTitle?.trim() || (def.label?.trim() ? def.label : DEFAULT_TITLE4);
9182
+ const toggleRisk = (eye, risk) => {
9183
+ const next = {
9184
+ OD: [...v.OD],
9185
+ OS: [...v.OS]
9186
+ };
9187
+ if (risk === DIABETES) {
9188
+ const had = next.OD.includes(DIABETES) || next.OS.includes(DIABETES);
9189
+ if (had) {
9190
+ next.OD = next.OD.filter((x) => x !== DIABETES);
9191
+ next.OS = next.OS.filter((x) => x !== DIABETES);
9192
+ } else {
9193
+ if (!next.OD.includes(DIABETES)) next.OD.push(DIABETES);
9194
+ if (!next.OS.includes(DIABETES)) next.OS.push(DIABETES);
9195
+ }
9196
+ setValue(next);
9197
+ return;
9198
+ }
9199
+ const list = next[eye];
9200
+ const i = list.indexOf(risk);
9201
+ if (i === -1) list.push(risk);
9202
+ else list.splice(i, 1);
9203
+ setValue(next);
9204
+ };
9205
+ return /* @__PURE__ */ jsxRuntime.jsxs(
9206
+ "div",
9207
+ {
9208
+ id: `surgical-risk-flags-${fieldId}`,
9209
+ className: "w-full min-w-0 max-w-full rounded-lg border border-border bg-card p-3 text-card-foreground shadow-sm",
9210
+ children: [
9211
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "mb-3 text-sm font-semibold leading-tight text-foreground", children: title }),
9212
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-6", children: [
9213
+ /* @__PURE__ */ jsxRuntime.jsx(RiskCol, { eye: "OD", value: v, disabled, onToggle: toggleRisk }),
9214
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-px shrink-0 bg-border", "aria-hidden": true }),
9215
+ /* @__PURE__ */ jsxRuntime.jsx(RiskCol, { eye: "OS", value: v, disabled, onToggle: toggleRisk })
9216
+ ] }),
9217
+ def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: def.description }),
9218
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-red-500", children: error })
9219
+ ]
9220
+ }
9221
+ );
9222
+ };
9223
+ var SliderWidget = ({ fieldId }) => {
9224
+ const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
9225
+ const { state } = useForm();
9226
+ const showError = !!error && (touched || state.submitAttempted);
9227
+ if (!fieldDef || fieldDef.type !== "slider") return null;
9228
+ const def = fieldDef;
9229
+ const min = def.min ?? 0;
9230
+ const max = def.max ?? 10;
9231
+ const step = def.step ?? 1;
9232
+ const raw = value == null || value === "" ? min : Number(value);
9233
+ const num = Number.isFinite(raw) ? Math.min(max, Math.max(min, raw)) : min;
9234
+ const theme = getThemeConfig("textarea", def.theme);
9235
+ const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
9236
+ const labelClass = theme?.labelClassName;
9237
+ const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
9238
+ def.label,
9239
+ " ",
9240
+ def.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" }),
9241
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-2 text-muted-foreground font-normal tabular-nums", children: [
9242
+ num,
9243
+ "/",
9244
+ max
9245
+ ] })
9246
+ ] });
9247
+ const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { children: labelContent });
9248
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperClass, children: [
9249
+ labelEl,
9250
+ /* @__PURE__ */ jsxRuntime.jsx(
9251
+ Slider,
9252
+ {
9253
+ className: cn("py-1", showError && "opacity-90 ring-1 ring-red-500 rounded"),
9254
+ disabled,
9255
+ min,
9256
+ max,
9257
+ step,
9258
+ value: [num],
9259
+ onValueChange: (v) => {
9260
+ const n = v[0] ?? min;
9261
+ setValue(n);
9262
+ setTouched();
9263
+ }
9264
+ }
9265
+ ),
9266
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
9267
+ ] });
9268
+ };
9269
+ var CHIEF_CHIPS_FIELD = "chief_complaints_chips";
9270
+ var SWELLING_OPTS = [
9271
+ { value: "reducible_hernia", label: "Reducible (hernia)" },
9272
+ { value: "cough_impulse", label: "Cough impulse" },
9273
+ { value: "skin_changes", label: "Skin changes" }
9274
+ ];
9275
+ var GI_OPTS = [
9276
+ { value: "bleeding_pr", label: "Bleeding PR" },
9277
+ { value: "vomiting", label: "Vomiting" },
9278
+ { value: "haematemesis", label: "Haematemesis" }
9279
+ ];
9280
+ var BREAST_OPTS = [
9281
+ { value: "pain", label: "Pain" },
9282
+ { value: "fh_ca_breast", label: "Family history of Ca breast" }
9283
+ ];
9284
+ var ANO_OPTS = [
9285
+ { value: "pain_defecation", label: "Pain during defecation" },
9286
+ { value: "bleeding", label: "Bleeding" },
9287
+ { value: "constipation", label: "Constipation" },
9288
+ { value: "discharge", label: "Discharge" }
9289
+ ];
9290
+ var THYROID_OPTS = [
9291
+ { value: "dysphagia", label: "Dysphagia" },
9292
+ { value: "voice_change", label: "Voice change" },
9293
+ { value: "thyrotoxicosis", label: "Thyrotoxicosis symptoms" }
9294
+ ];
9295
+ var SOCRATES_KEYS = [
9296
+ "site",
9297
+ "onset",
9298
+ "character",
9299
+ "radiation",
9300
+ "associated",
9301
+ "timing",
9302
+ "exacerbating"
9303
+ ];
9304
+ function Panel({ title, children }) {
9305
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "overflow-hidden rounded-md border border-[#D0D0D0] bg-white", children: [
9306
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-b border-[#D0D0D0] bg-[#FEE8EC]/50 px-3 py-1.5 text-xs font-semibold text-slate-700", children: title }),
9307
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-3", children })
9308
+ ] });
9309
+ }
9310
+ function chipList(state) {
9311
+ const raw = state.values[CHIEF_CHIPS_FIELD];
9312
+ return Array.isArray(raw) ? raw.filter((x) => typeof x === "string") : [];
9313
+ }
9314
+ var GsSmartHistoryWidget = ({ fieldId }) => {
9315
+ const { fieldDef, value, setValue, setTouched, error, touched, disabled } = useField(fieldId);
9316
+ const { state } = useForm();
9317
+ const showError = !!error && (touched || state.submitAttempted);
9318
+ const safe = React15.useMemo(() => normalizeGeneralSurgerySmartHistory(value), [value]);
9319
+ const chips = React15.useMemo(() => chipList(state), [state]);
9320
+ const showPain = chips.includes("pain");
9321
+ const showSwelling = chips.includes("swelling_lump");
9322
+ const showGI = chips.includes("bleeding") || chips.includes("obstruction");
9323
+ const showBreast = chips.includes("breast");
9324
+ const showAno = chips.includes("anorectal");
9325
+ const showThyroid = chips.includes("thyroid");
9326
+ const update = (next) => {
9327
+ setValue(next);
9328
+ setTouched();
9329
+ };
9330
+ const setPain = (key, v) => {
9331
+ if (key === "severity") {
9332
+ const n = typeof v === "number" ? v : Number(v);
9333
+ const sev = Number.isFinite(n) ? Math.min(10, Math.max(0, Math.round(n))) : 0;
9334
+ update({ ...safe, pain: { ...safe.pain, severity: sev } });
9335
+ return;
9336
+ }
9337
+ update({ ...safe, pain: { ...safe.pain, [key]: String(v) } });
9338
+ };
9339
+ const toggleArr = (section, val) => {
9340
+ if (section === "swelling") {
9341
+ const a = safe.swelling.checks;
9342
+ const next = a.includes(val) ? a.filter((x) => x !== val) : [...a, val];
9343
+ update({ ...safe, swelling: { ...safe.swelling, checks: next } });
9344
+ } else if (section === "gi") {
9345
+ const a = safe.gi.checks;
9346
+ const next = a.includes(val) ? a.filter((x) => x !== val) : [...a, val];
9347
+ update({ ...safe, gi: { ...safe.gi, checks: next } });
9348
+ } else if (section === "breast") {
9349
+ const a = safe.breast.checks;
9350
+ const next = a.includes(val) ? a.filter((x) => x !== val) : [...a, val];
9351
+ update({ ...safe, breast: { ...safe.breast, checks: next } });
9352
+ } else if (section === "ano") {
9353
+ const a = safe.ano.checks;
9354
+ const next = a.includes(val) ? a.filter((x) => x !== val) : [...a, val];
9355
+ update({ ...safe, ano: { ...safe.ano, checks: next } });
9356
+ } else {
9357
+ const a = safe.thyroid.checks;
9358
+ const next = a.includes(val) ? a.filter((x) => x !== val) : [...a, val];
9359
+ update({ ...safe, thyroid: { ...safe.thyroid, checks: next } });
9360
+ }
9361
+ };
9362
+ if (!fieldDef) return null;
9363
+ const theme = getThemeConfig("textarea", fieldDef.theme);
9364
+ const wrapperClass = theme?.wrapperClassName ?? "rounded-md overflow-hidden flex flex-col border border-[#D0D0D0]";
9365
+ const labelClass = theme?.labelClassName;
9366
+ const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
9367
+ fieldDef.label,
9368
+ fieldDef.required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
9369
+ ] });
9370
+ const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: labelContent });
9371
+ const bodyClass = cn(
9372
+ "-mt-1 flex min-w-0 flex-col gap-3 border-t border-[#D0D0D0] bg-white px-3 py-3",
9373
+ disabled && "pointer-events-none opacity-60"
9374
+ );
9375
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("w-full min-w-0", wrapperClass), children: [
9376
+ labelEl,
9377
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: bodyClass, children: [
9378
+ showPain ? /* @__PURE__ */ jsxRuntime.jsx(Panel, { title: "SOCRATES \u2014 pain", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-2 md:grid-cols-4", children: [
9379
+ SOCRATES_KEYS.map((k) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
9380
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] font-medium uppercase tracking-wide text-muted-foreground", children: k }),
9381
+ /* @__PURE__ */ jsxRuntime.jsx(
9382
+ Input,
9383
+ {
9384
+ className: "h-8 text-xs",
9385
+ value: safe.pain[k],
9386
+ onChange: (e) => setPain(k, e.target.value),
9387
+ disabled
9388
+ }
9389
+ )
9390
+ ] }, k)),
9391
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
9392
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] font-medium uppercase tracking-wide text-muted-foreground", children: "Severity 0\u201310" }),
9393
+ /* @__PURE__ */ jsxRuntime.jsx(
9394
+ Input,
9395
+ {
9396
+ type: "number",
9397
+ min: 0,
9398
+ max: 10,
9399
+ className: "h-8 text-xs",
9400
+ value: safe.pain.severity,
9401
+ onChange: (e) => setPain("severity", e.target.value),
9402
+ disabled
9403
+ }
9404
+ )
9405
+ ] })
9406
+ ] }) }) : null,
9407
+ showSwelling ? /* @__PURE__ */ jsxRuntime.jsxs(Panel, { title: "Swelling history", children: [
9408
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-3 text-xs md:grid-cols-3", children: [
9409
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex flex-col gap-1", children: [
9410
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: "Duration" }),
9411
+ /* @__PURE__ */ jsxRuntime.jsx(
9412
+ Input,
9413
+ {
9414
+ className: "h-8 text-xs",
9415
+ value: safe.swelling.duration,
9416
+ onChange: (e) => update({ ...safe, swelling: { ...safe.swelling, duration: e.target.value } }),
9417
+ disabled
9418
+ }
9419
+ )
9420
+ ] }),
9421
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex flex-col gap-1", children: [
9422
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: "Size progression" }),
9423
+ /* @__PURE__ */ jsxRuntime.jsx(
9424
+ Input,
9425
+ {
9426
+ className: "h-8 text-xs",
9427
+ value: safe.swelling.sizeProgression,
9428
+ onChange: (e) => update({ ...safe, swelling: { ...safe.swelling, sizeProgression: e.target.value } }),
9429
+ disabled
9430
+ }
9431
+ )
9432
+ ] }),
9433
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex flex-col gap-1", children: [
9434
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: "Painful / painless" }),
9435
+ /* @__PURE__ */ jsxRuntime.jsx(
9436
+ Input,
9437
+ {
9438
+ className: "h-8 text-xs",
9439
+ value: safe.swelling.painfulPainless,
9440
+ onChange: (e) => update({ ...safe, swelling: { ...safe.swelling, painfulPainless: e.target.value } }),
9441
+ disabled
9442
+ }
9443
+ )
9444
+ ] })
9445
+ ] }),
9446
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 flex flex-wrap gap-x-4 gap-y-2", children: SWELLING_OPTS.map((o) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2 text-xs", children: [
9447
+ /* @__PURE__ */ jsxRuntime.jsx(
9448
+ Checkbox,
9449
+ {
9450
+ checked: safe.swelling.checks.includes(o.value),
9451
+ onCheckedChange: () => toggleArr("swelling", o.value),
9452
+ disabled
9453
+ }
9454
+ ),
9455
+ o.label
9456
+ ] }, o.value)) })
9457
+ ] }) : null,
9458
+ showGI ? /* @__PURE__ */ jsxRuntime.jsxs(Panel, { title: "GI history", children: [
9459
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-2 text-xs md:grid-cols-3", children: [
9460
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex flex-col gap-1", children: [
9461
+ "Appetite",
9462
+ /* @__PURE__ */ jsxRuntime.jsx(
9463
+ Input,
9464
+ {
9465
+ className: "h-8 text-xs",
9466
+ value: safe.gi.appetite,
9467
+ onChange: (e) => update({ ...safe, gi: { ...safe.gi, appetite: e.target.value } }),
9468
+ disabled
9469
+ }
9470
+ )
9471
+ ] }),
9472
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex flex-col gap-1", children: [
9473
+ "Weight loss",
9474
+ /* @__PURE__ */ jsxRuntime.jsx(
9475
+ Input,
9476
+ {
9477
+ className: "h-8 text-xs",
9478
+ value: safe.gi.weightLoss,
9479
+ onChange: (e) => update({ ...safe, gi: { ...safe.gi, weightLoss: e.target.value } }),
9480
+ disabled
9481
+ }
9482
+ )
9483
+ ] }),
9484
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex flex-col gap-1", children: [
9485
+ "Bowel habits",
9486
+ /* @__PURE__ */ jsxRuntime.jsx(
9487
+ Input,
9488
+ {
9489
+ className: "h-8 text-xs",
9490
+ value: safe.gi.bowelHabits,
9491
+ onChange: (e) => update({ ...safe, gi: { ...safe.gi, bowelHabits: e.target.value } }),
9492
+ disabled
9493
+ }
9494
+ )
9495
+ ] })
9496
+ ] }),
9497
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 flex flex-wrap gap-x-4 gap-y-2", children: GI_OPTS.map((o) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2 text-xs", children: [
9498
+ /* @__PURE__ */ jsxRuntime.jsx(
9499
+ Checkbox,
9500
+ {
9501
+ checked: safe.gi.checks.includes(o.value),
9502
+ onCheckedChange: () => toggleArr("gi", o.value),
9503
+ disabled
9504
+ }
9505
+ ),
9506
+ o.label
9507
+ ] }, o.value)) })
9508
+ ] }) : null,
9509
+ showBreast ? /* @__PURE__ */ jsxRuntime.jsxs(Panel, { title: "Breast history", children: [
9510
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-2 text-xs md:grid-cols-2", children: [
9511
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex flex-col gap-1", children: [
9512
+ "Lump duration",
9513
+ /* @__PURE__ */ jsxRuntime.jsx(
9514
+ Input,
9515
+ {
9516
+ className: "h-8 text-xs",
9517
+ value: safe.breast.lumpDuration,
9518
+ onChange: (e) => update({ ...safe, breast: { ...safe.breast, lumpDuration: e.target.value } }),
9519
+ disabled
9520
+ }
9521
+ )
9522
+ ] }),
9523
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex flex-col gap-1", children: [
9524
+ "Nipple discharge",
9525
+ /* @__PURE__ */ jsxRuntime.jsx(
9526
+ Input,
9527
+ {
9528
+ className: "h-8 text-xs",
9529
+ value: safe.breast.nippleDischarge,
9530
+ onChange: (e) => update({ ...safe, breast: { ...safe.breast, nippleDischarge: e.target.value } }),
9531
+ disabled
9532
+ }
9533
+ )
9534
+ ] })
9535
+ ] }),
9536
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 flex flex-wrap gap-x-4 gap-y-2", children: BREAST_OPTS.map((o) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2 text-xs", children: [
9537
+ /* @__PURE__ */ jsxRuntime.jsx(
9538
+ Checkbox,
9539
+ {
9540
+ checked: safe.breast.checks.includes(o.value),
9541
+ onCheckedChange: () => toggleArr("breast", o.value),
9542
+ disabled
9543
+ }
9544
+ ),
9545
+ o.label
9546
+ ] }, o.value)) })
9547
+ ] }) : null,
9548
+ showAno ? /* @__PURE__ */ jsxRuntime.jsx(Panel, { title: "Anorectal history", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-2 text-xs md:grid-cols-2", children: ANO_OPTS.map((o) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
9549
+ /* @__PURE__ */ jsxRuntime.jsx(
9550
+ Checkbox,
9551
+ {
9552
+ checked: safe.ano.checks.includes(o.value),
9553
+ onCheckedChange: () => toggleArr("ano", o.value),
9554
+ disabled
9555
+ }
9556
+ ),
9557
+ o.label
9558
+ ] }, o.value)) }) }) : null,
9559
+ showThyroid ? /* @__PURE__ */ jsxRuntime.jsxs(Panel, { title: "Thyroid history", children: [
9560
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-2 text-xs md:grid-cols-2", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex flex-col gap-1 md:col-span-2", children: [
9561
+ "Swelling duration",
9562
+ /* @__PURE__ */ jsxRuntime.jsx(
9563
+ Input,
9564
+ {
9565
+ className: "h-8 text-xs",
9566
+ value: safe.thyroid.swellingDuration,
9567
+ onChange: (e) => update({ ...safe, thyroid: { ...safe.thyroid, swellingDuration: e.target.value } }),
9568
+ disabled
9569
+ }
9570
+ )
9571
+ ] }) }),
9572
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 flex flex-wrap gap-x-4 gap-y-2", children: THYROID_OPTS.map((o) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2 text-xs", children: [
9573
+ /* @__PURE__ */ jsxRuntime.jsx(
9574
+ Checkbox,
9575
+ {
9576
+ checked: safe.thyroid.checks.includes(o.value),
9577
+ onCheckedChange: () => toggleArr("thyroid", o.value),
9578
+ disabled
9579
+ }
9580
+ ),
9581
+ o.label
9582
+ ] }, o.value)) })
9583
+ ] }) : null,
9584
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
9585
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-xs font-medium text-slate-700", children: "Systemic surgical screening" }),
9586
+ /* @__PURE__ */ jsxRuntime.jsx(
9587
+ Textarea,
9588
+ {
9589
+ className: "min-h-[72px] rounded-md border border-input bg-white text-sm",
9590
+ placeholder: "Fever, weight loss, appetite loss, fatigue, malignancy red flags\u2026",
9591
+ value: safe.systemic,
9592
+ onChange: (e) => update({ ...safe, systemic: e.target.value }),
9593
+ disabled
9594
+ }
9595
+ )
9596
+ ] })
9597
+ ] }),
9598
+ showError ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-3 pb-2 text-xs text-red-500", children: error }) : null
9599
+ ] });
9600
+ };
9601
+ var GS_CLINICAL_EXAMINATION_FIELD = "clinical_examination";
9602
+ var GENERAL = [
9603
+ { value: "pallor", label: "Pallor" },
9604
+ { value: "icterus", label: "Icterus" },
9605
+ { value: "cyanosis", label: "Cyanosis" },
9606
+ { value: "clubbing", label: "Clubbing" },
9607
+ { value: "lymphadenopathy", label: "Lymphadenopathy" },
9608
+ { value: "oedema", label: "Oedema" }
9609
+ ];
9610
+ var REGIONS = [
9611
+ { key: "abdomen", label: "Abdomen" },
9612
+ { key: "hernia", label: "Hernia" },
9613
+ { key: "breast", label: "Breast" },
9614
+ { key: "thyroid", label: "Thyroid" },
9615
+ { key: "anorectal", label: "Anorectal" },
9616
+ { key: "limb", label: "Limb / varicose" }
9617
+ ];
9618
+ var ABD_INSP = [
9619
+ { value: "distension", label: "Distension" },
9620
+ { value: "scars", label: "Scars" },
9621
+ { value: "visible_peristalsis", label: "Visible peristalsis" }
9622
+ ];
9623
+ var ABD_PALP = [
9624
+ { value: "tenderness", label: "Tenderness" },
9625
+ { value: "guarding", label: "Guarding" },
9626
+ { value: "rigidity", label: "Rigidity" },
9627
+ { value: "mass", label: "Palpable mass" }
9628
+ ];
9629
+ var ABD_PERC = [
9630
+ { value: "tympany", label: "Tympany" },
9631
+ { value: "shifting_dullness", label: "Shifting dullness" }
9632
+ ];
9633
+ function SubGroup({ title, children }) {
9634
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
9635
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: title }),
9636
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2", children })
9637
+ ] });
9638
+ }
9639
+ function RegionCard({ title, children }) {
9640
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "overflow-hidden rounded-md border border-[#D0D0D0] bg-white", children: [
9641
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-b border-[#D0D0D0] bg-[#FEE8EC]/50 px-3 py-1.5 text-xs font-semibold text-slate-700", children: title }),
9642
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-3", children })
9643
+ ] });
9644
+ }
9645
+ var GsExaminationWidget = ({ fieldId }) => {
9646
+ const { fieldDef, value, setValue, setTouched, error, touched, disabled } = useField(fieldId);
9647
+ const clinicalField = useField(GS_CLINICAL_EXAMINATION_FIELD);
9648
+ const { state } = useForm();
9649
+ const showError = !!error && (touched || state.submitAttempted);
9650
+ const safe = React15.useMemo(() => normalizeGeneralSurgeryExamination(value), [value]);
9651
+ const update = (next) => {
9652
+ setValue(next);
9653
+ setTouched();
9654
+ };
9655
+ const toggleIn = (arr, val) => arr.includes(val) ? arr.filter((x) => x !== val) : [...arr, val];
9656
+ const toggleGeneral = (val) => {
9657
+ update({ ...safe, general: toggleIn(safe.general, val) });
9658
+ };
9659
+ const toggleRegion = (key) => {
9660
+ update({ ...safe, regions: toggleIn(safe.regions, key) });
9661
+ };
9662
+ const toggleAbd = (key, val) => {
9663
+ update({
9664
+ ...safe,
9665
+ abdomen: { ...safe.abdomen, [key]: toggleIn(safe.abdomen[key], val) }
9666
+ });
9667
+ };
9668
+ if (!fieldDef) return null;
9669
+ const has = (r) => safe.regions.includes(r);
9670
+ const theme = getThemeConfig("textarea", fieldDef.theme);
9671
+ const wrapperClass = theme?.wrapperClassName ?? "rounded-md overflow-hidden flex flex-col border border-[#D0D0D0]";
9672
+ const labelClass = theme?.labelClassName;
9673
+ const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
9674
+ fieldDef.label,
9675
+ fieldDef.required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
9676
+ ] });
9677
+ const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: labelContent });
9678
+ const bodyClass = cn(
9679
+ "-mt-1 flex min-w-0 flex-col gap-3 border-t border-[#D0D0D0] bg-white px-3 py-3",
9680
+ disabled && "pointer-events-none opacity-60"
9681
+ );
9682
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("w-full min-w-0", wrapperClass), children: [
9683
+ labelEl,
9684
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: bodyClass, children: [
9685
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "overflow-hidden rounded-md border border-[#D0D0D0] bg-white", children: [
9686
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-b border-[#D0D0D0] bg-[#FEE8EC]/50 px-3 py-1.5 text-xs font-semibold text-slate-700", children: "General examination" }),
9687
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-3", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 gap-2 text-xs md:grid-cols-3 lg:grid-cols-6", children: GENERAL.map((g) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
9688
+ /* @__PURE__ */ jsxRuntime.jsx(
9689
+ Checkbox,
9690
+ {
9691
+ checked: safe.general.includes(g.value),
9692
+ onCheckedChange: () => toggleGeneral(g.value),
9693
+ disabled
9694
+ }
9695
+ ),
9696
+ g.label
9697
+ ] }, g.value)) }) })
9698
+ ] }),
9699
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
9700
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-2 text-xs font-semibold text-slate-700", children: "Regional examination \u2014 select region(s)" }),
9701
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2", children: REGIONS.map((r) => {
9702
+ const on = safe.regions.includes(r.key);
9703
+ return /* @__PURE__ */ jsxRuntime.jsx(
9704
+ Button,
9705
+ {
9706
+ type: "button",
9707
+ size: "sm",
9708
+ variant: on ? "default" : "outline",
9709
+ className: "h-7 rounded-full px-3 text-xs",
9710
+ onClick: () => toggleRegion(r.key),
9711
+ disabled,
9712
+ children: r.label
9713
+ },
9714
+ r.key
9715
+ );
9716
+ }) })
9717
+ ] }),
9718
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
9719
+ has("abdomen") ? /* @__PURE__ */ jsxRuntime.jsx(RegionCard, { title: "Abdomen \u2014 inspection \xB7 palpation \xB7 percussion \xB7 auscultation", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-4", children: [
9720
+ /* @__PURE__ */ jsxRuntime.jsx(SubGroup, { title: "Inspection", children: ABD_INSP.map((o) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2 text-xs", children: [
9721
+ /* @__PURE__ */ jsxRuntime.jsx(
9722
+ Checkbox,
9723
+ {
9724
+ checked: safe.abdomen.inspection.includes(o.value),
9725
+ onCheckedChange: () => toggleAbd("inspection", o.value),
9726
+ disabled
9727
+ }
9728
+ ),
9729
+ o.label
9730
+ ] }, o.value)) }),
9731
+ /* @__PURE__ */ jsxRuntime.jsxs(SubGroup, { title: "Palpation", children: [
9732
+ ABD_PALP.map((o) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2 text-xs", children: [
9733
+ /* @__PURE__ */ jsxRuntime.jsx(
9734
+ Checkbox,
9735
+ {
9736
+ checked: safe.abdomen.palpation.includes(o.value),
9737
+ onCheckedChange: () => toggleAbd("palpation", o.value),
9738
+ disabled
9739
+ }
9740
+ ),
9741
+ o.label
9742
+ ] }, o.value)),
9743
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "mt-2 block text-xs", children: [
9744
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mb-1 block font-medium", children: "Mass size / mobility" }),
9745
+ /* @__PURE__ */ jsxRuntime.jsx(
9746
+ Input,
9747
+ {
9748
+ className: "h-8 text-xs",
9749
+ value: safe.abdomen.massNotes,
9750
+ onChange: (e) => update({ ...safe, abdomen: { ...safe.abdomen, massNotes: e.target.value } }),
9751
+ disabled
9752
+ }
9753
+ )
9754
+ ] })
9755
+ ] }),
9756
+ /* @__PURE__ */ jsxRuntime.jsx(SubGroup, { title: "Percussion", children: ABD_PERC.map((o) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2 text-xs", children: [
9757
+ /* @__PURE__ */ jsxRuntime.jsx(
9758
+ Checkbox,
9759
+ {
9760
+ checked: safe.abdomen.percussion.includes(o.value),
9761
+ onCheckedChange: () => toggleAbd("percussion", o.value),
9762
+ disabled
9763
+ }
9764
+ ),
9765
+ o.label
9766
+ ] }, o.value)) }),
9767
+ /* @__PURE__ */ jsxRuntime.jsxs(SubGroup, { title: "Auscultation", children: [
9768
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mb-1 block text-xs font-medium", children: "Bowel sounds" }),
9769
+ /* @__PURE__ */ jsxRuntime.jsxs(
9770
+ Select,
9771
+ {
9772
+ value: safe.abdomen.bowelSounds,
9773
+ onValueChange: (val) => update({
9774
+ ...safe,
9775
+ abdomen: {
9776
+ ...safe.abdomen,
9777
+ bowelSounds: val
9778
+ }
9779
+ }),
9780
+ disabled,
9781
+ children: [
9782
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select\u2026" }) }),
9783
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
9784
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
9785
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "normal", children: "Normal" }),
9786
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "up", children: "\u2191" }),
9787
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "down", children: "\u2193" }),
9788
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "absent", children: "Absent" })
9789
+ ] })
9790
+ ]
9791
+ }
9792
+ )
9793
+ ] })
9794
+ ] }) }) : null,
9795
+ has("hernia") ? /* @__PURE__ */ jsxRuntime.jsx(RegionCard, { title: "Hernia exam", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-3 text-xs md:grid-cols-4", children: [
9796
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "block", children: [
9797
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mb-1 block font-medium", children: "Site" }),
9798
+ /* @__PURE__ */ jsxRuntime.jsx(
9799
+ Input,
9800
+ {
9801
+ className: "h-8 text-xs",
9802
+ value: safe.hernia.site,
9803
+ onChange: (e) => update({ ...safe, hernia: { ...safe.hernia, site: e.target.value } }),
9804
+ disabled
9805
+ }
9806
+ )
9807
+ ] }),
9808
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
9809
+ /* @__PURE__ */ jsxRuntime.jsx(
9810
+ Checkbox,
9811
+ {
9812
+ checked: safe.hernia.reducible,
9813
+ onCheckedChange: (c) => update({ ...safe, hernia: { ...safe.hernia, reducible: c === true } }),
9814
+ disabled
9815
+ }
9816
+ ),
9817
+ "Reducible"
9818
+ ] }),
9819
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
9820
+ /* @__PURE__ */ jsxRuntime.jsx(
9821
+ Checkbox,
9822
+ {
9823
+ checked: safe.hernia.coughImpulse,
9824
+ onCheckedChange: (c) => update({ ...safe, hernia: { ...safe.hernia, coughImpulse: c === true } }),
9825
+ disabled
9826
+ }
9827
+ ),
9828
+ "Cough impulse"
9829
+ ] }),
9830
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
9831
+ /* @__PURE__ */ jsxRuntime.jsx(
9832
+ Checkbox,
9833
+ {
9834
+ checked: safe.hernia.tenderness,
9835
+ onCheckedChange: (c) => update({ ...safe, hernia: { ...safe.hernia, tenderness: c === true } }),
9836
+ disabled
9837
+ }
9838
+ ),
9839
+ "Tenderness"
9840
+ ] })
9841
+ ] }) }) : null,
9842
+ has("breast") ? /* @__PURE__ */ jsxRuntime.jsx(RegionCard, { title: "Breast exam", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-3 text-xs md:grid-cols-4", children: [
9843
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "block", children: [
9844
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mb-1 block font-medium", children: "Lump size (cm)" }),
9845
+ /* @__PURE__ */ jsxRuntime.jsx(
9846
+ Input,
9847
+ {
9848
+ className: "h-8 text-xs",
9849
+ value: safe.breast.lumpSizeCm,
9850
+ onChange: (e) => update({ ...safe, breast: { ...safe.breast, lumpSizeCm: e.target.value } }),
9851
+ disabled
9852
+ }
9853
+ )
9854
+ ] }),
9855
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
9856
+ /* @__PURE__ */ jsxRuntime.jsx(
9857
+ Checkbox,
9858
+ {
9859
+ checked: safe.breast.mobile,
9860
+ onCheckedChange: (c) => update({ ...safe, breast: { ...safe.breast, mobile: c === true } }),
9861
+ disabled
9862
+ }
9863
+ ),
9864
+ "Mobile"
9865
+ ] }),
9866
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
9867
+ /* @__PURE__ */ jsxRuntime.jsx(
9868
+ Checkbox,
9869
+ {
9870
+ checked: safe.breast.skinInvolvement,
9871
+ onCheckedChange: (c) => update({ ...safe, breast: { ...safe.breast, skinInvolvement: c === true } }),
9872
+ disabled
9873
+ }
9874
+ ),
9875
+ "Skin involvement"
9876
+ ] }),
9877
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
9878
+ /* @__PURE__ */ jsxRuntime.jsx(
9879
+ Checkbox,
9880
+ {
9881
+ checked: safe.breast.axillaryNodes,
9882
+ onCheckedChange: (c) => update({ ...safe, breast: { ...safe.breast, axillaryNodes: c === true } }),
9883
+ disabled
9884
+ }
9885
+ ),
9886
+ "Axillary nodes"
9887
+ ] })
9888
+ ] }) }) : null,
9889
+ has("thyroid") ? /* @__PURE__ */ jsxRuntime.jsx(RegionCard, { title: "Thyroid exam", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-3 text-xs md:grid-cols-4", children: [
9890
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "block", children: [
9891
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mb-1 block font-medium", children: "Size" }),
9892
+ /* @__PURE__ */ jsxRuntime.jsx(
9893
+ Input,
9894
+ {
9895
+ className: "h-8 text-xs",
9896
+ value: safe.thyroid.size,
9897
+ onChange: (e) => update({ ...safe, thyroid: { ...safe.thyroid, size: e.target.value } }),
9898
+ disabled
9899
+ }
9900
+ )
9901
+ ] }),
9902
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
9903
+ /* @__PURE__ */ jsxRuntime.jsx(
9904
+ Checkbox,
9905
+ {
9906
+ checked: safe.thyroid.mobileDeglutition,
9907
+ onCheckedChange: (c) => update({ ...safe, thyroid: { ...safe.thyroid, mobileDeglutition: c === true } }),
9908
+ disabled
9909
+ }
9910
+ ),
9911
+ "Mobile with deglutition"
9912
+ ] }),
9913
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
9914
+ /* @__PURE__ */ jsxRuntime.jsx(
9915
+ Checkbox,
9916
+ {
9917
+ checked: safe.thyroid.nodules,
9918
+ onCheckedChange: (c) => update({ ...safe, thyroid: { ...safe.thyroid, nodules: c === true } }),
9919
+ disabled
9920
+ }
9921
+ ),
9922
+ "Nodules"
9923
+ ] }),
9924
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
9925
+ /* @__PURE__ */ jsxRuntime.jsx(
9926
+ Checkbox,
9927
+ {
9928
+ checked: safe.thyroid.cervicalNodes,
9929
+ onCheckedChange: (c) => update({ ...safe, thyroid: { ...safe.thyroid, cervicalNodes: c === true } }),
9930
+ disabled
9931
+ }
9932
+ ),
9933
+ "Cervical lymph nodes"
9934
+ ] })
9935
+ ] }) }) : null,
9936
+ has("anorectal") ? /* @__PURE__ */ jsxRuntime.jsx(RegionCard, { title: "Anorectal exam", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-3 text-xs md:grid-cols-3", children: [
9937
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "block md:col-span-3", children: [
9938
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mb-1 block font-medium", children: "Inspection findings" }),
9939
+ /* @__PURE__ */ jsxRuntime.jsx(
9940
+ Input,
9941
+ {
9942
+ className: "h-8 text-xs",
9943
+ value: safe.anorectal.inspection,
9944
+ onChange: (e) => update({ ...safe, anorectal: { ...safe.anorectal, inspection: e.target.value } }),
9945
+ disabled
9946
+ }
9947
+ )
9948
+ ] }),
9949
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
9950
+ /* @__PURE__ */ jsxRuntime.jsx(
9951
+ Checkbox,
9952
+ {
9953
+ checked: safe.anorectal.dreDone,
9954
+ onCheckedChange: (c) => update({ ...safe, anorectal: { ...safe.anorectal, dreDone: c === true } }),
9955
+ disabled
9956
+ }
9957
+ ),
9958
+ "DRE done"
9959
+ ] }),
9960
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
9961
+ /* @__PURE__ */ jsxRuntime.jsx(
9962
+ Checkbox,
9963
+ {
9964
+ checked: safe.anorectal.proctoscopyDone,
9965
+ onCheckedChange: (c) => update({ ...safe, anorectal: { ...safe.anorectal, proctoscopyDone: c === true } }),
9966
+ disabled
9967
+ }
9968
+ ),
9969
+ "Proctoscopy done"
9970
+ ] }),
9971
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "md:col-span-3", children: [
9972
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-xs font-semibold", children: "DRE / proctoscopy notes" }),
9973
+ /* @__PURE__ */ jsxRuntime.jsx(
9974
+ Textarea,
9975
+ {
9976
+ className: "mt-1 min-h-[64px] text-sm",
9977
+ placeholder: "Sphincter tone, masses, prostate, bleeding\u2026",
9978
+ value: safe.anorectal.notes,
9979
+ onChange: (e) => update({ ...safe, anorectal: { ...safe.anorectal, notes: e.target.value } }),
9980
+ disabled
9981
+ }
9982
+ )
9983
+ ] })
9984
+ ] }) }) : null,
9985
+ has("limb") ? /* @__PURE__ */ jsxRuntime.jsx(RegionCard, { title: "Limb / varicose veins", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-x-4 gap-y-2 text-xs", children: [
9986
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
9987
+ /* @__PURE__ */ jsxRuntime.jsx(
9988
+ Checkbox,
9989
+ {
9990
+ checked: safe.limb.dilatedVeins,
9991
+ onCheckedChange: (c) => update({ ...safe, limb: { ...safe.limb, dilatedVeins: c === true } }),
9992
+ disabled
9993
+ }
9994
+ ),
9995
+ "Dilated veins"
9996
+ ] }),
9997
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
9998
+ /* @__PURE__ */ jsxRuntime.jsx(
9999
+ Checkbox,
10000
+ {
10001
+ checked: safe.limb.ulcer,
10002
+ onCheckedChange: (c) => update({ ...safe, limb: { ...safe.limb, ulcer: c === true } }),
10003
+ disabled
10004
+ }
10005
+ ),
10006
+ "Ulcer"
10007
+ ] }),
10008
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
10009
+ /* @__PURE__ */ jsxRuntime.jsx(
10010
+ Checkbox,
10011
+ {
10012
+ checked: safe.limb.oedema,
10013
+ onCheckedChange: (c) => update({ ...safe, limb: { ...safe.limb, oedema: c === true } }),
10014
+ disabled
10015
+ }
10016
+ ),
10017
+ "Oedema"
10018
+ ] })
10019
+ ] }) }) : null
10020
+ ] }),
10021
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
10022
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-xs font-semibold text-slate-700", children: clinicalField.fieldDef?.label ?? "Clinical examination" }),
10023
+ /* @__PURE__ */ jsxRuntime.jsx(
10024
+ Textarea,
10025
+ {
10026
+ className: "min-h-[88px] rounded-md border border-input bg-white text-sm",
10027
+ value: typeof clinicalField.value === "string" ? clinicalField.value : clinicalField.value == null ? "" : String(clinicalField.value),
10028
+ onChange: (e) => {
10029
+ clinicalField.setValue(e.target.value);
10030
+ clinicalField.setTouched();
10031
+ },
10032
+ disabled: disabled || clinicalField.disabled
10033
+ }
10034
+ )
10035
+ ] })
10036
+ ] }),
10037
+ showError ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-3 pb-2 text-xs text-red-500", children: error }) : null
10038
+ ] });
10039
+ };
10040
+ var CHIEF_CHIPS_FIELD2 = "chief_complaints_chips";
10041
+ var GS_EXAMINATION_FIELD = "gs_examination";
10042
+ function chipList2(state) {
10043
+ const raw = state.values[CHIEF_CHIPS_FIELD2];
10044
+ return Array.isArray(raw) ? raw.filter((x) => typeof x === "string") : [];
10045
+ }
10046
+ function regionList(state) {
10047
+ const raw = state.values[GS_EXAMINATION_FIELD];
10048
+ const ex = normalizeGeneralSurgeryExamination(raw);
10049
+ return ex.regions;
10050
+ }
10051
+ var GsGradingWidget = ({ fieldId }) => {
10052
+ const { fieldDef, value, setValue, setTouched, error, touched, disabled } = useField(fieldId);
10053
+ const { state } = useForm();
10054
+ const showError = !!error && (touched || state.submitAttempted);
10055
+ const safe = React15.useMemo(() => normalizeGeneralSurgeryGrading(value), [value]);
10056
+ const chips = React15.useMemo(() => chipList2(state), [state]);
10057
+ const regions = React15.useMemo(() => regionList(state), [state]);
10058
+ const visibleRows = React15.useMemo(() => {
10059
+ return ALL_GS_CONDITIONS.filter(
10060
+ (c) => gsGradingRowVisible(c, chips, regions, safe[c] ?? 0)
10061
+ );
10062
+ }, [chips, regions, safe]);
10063
+ const update = (next) => {
10064
+ setValue(next);
10065
+ setTouched();
10066
+ };
10067
+ const setGrade = (cond, gradeStr) => {
10068
+ const n = Math.min(5, Math.max(0, Math.round(Number(gradeStr)) || 0));
10069
+ update({ ...safe, [cond]: n });
10070
+ };
10071
+ if (!fieldDef) return null;
10072
+ const theme = getThemeConfig("textarea", fieldDef.theme);
10073
+ const wrapperClass = theme?.wrapperClassName ?? "rounded-md overflow-hidden flex flex-col border border-[#D0D0D0]";
10074
+ const labelClass = theme?.labelClassName;
10075
+ const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10076
+ fieldDef.label,
10077
+ fieldDef.required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
10078
+ ] });
10079
+ const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: labelContent });
10080
+ const bodyClass = cn(
10081
+ "-mt-1 flex min-w-0 flex-col gap-3 border-t border-[#D0D0D0] bg-white px-3 py-3",
10082
+ disabled && "pointer-events-none opacity-60"
10083
+ );
10084
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("w-full min-w-0", wrapperClass), children: [
10085
+ labelEl,
10086
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: bodyClass, children: visibleRows.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-dashed border-[#D0D0D0] bg-white p-6 text-center text-xs text-muted-foreground", children: "No conditions to grade yet. Select a chief complaint category or pick an examination region." }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-x-auto rounded-md border border-[#D0D0D0]", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full min-w-[520px] border-collapse text-xs", children: [
10087
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "border-b border-[#D0D0D0] bg-[#FEE8EC]/50", children: [
10088
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-3 py-2 text-left font-semibold text-slate-700", children: "Condition" }),
10089
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-24 px-2 py-2 font-semibold text-slate-700", children: "Grade" }),
10090
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-3 py-2 text-left font-semibold text-slate-700", children: "Description" })
10091
+ ] }) }),
10092
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "bg-white", children: visibleRows.map((c) => {
10093
+ const g = safe[c] ?? 0;
10094
+ const desc = GS_GRADE_DESCRIPTIONS[c][g] ?? "\u2014";
10095
+ return /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "border-b border-[#D0D0D0]/80 last:border-0", children: [
10096
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-3 py-2 font-medium", children: GS_CONDITION_LABELS[c] }),
10097
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-2 py-1.5 align-middle", children: /* @__PURE__ */ jsxRuntime.jsxs(
10098
+ Select,
10099
+ {
10100
+ value: String(g),
10101
+ onValueChange: (v) => setGrade(c, v),
10102
+ disabled,
10103
+ children: [
10104
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, {}) }),
10105
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: [0, 1, 2, 3, 4, 5].map((n) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: String(n), children: n === 0 ? "\u2014" : String(n) }, n)) })
10106
+ ]
10107
+ }
10108
+ ) }),
10109
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-3 py-2 text-muted-foreground", children: desc })
10110
+ ] }, c);
10111
+ }) })
10112
+ ] }) }) }),
10113
+ showError ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-3 pb-2 text-xs text-red-500", children: error }) : null
10114
+ ] });
10115
+ };
10116
+ function isFlagSelected(selected, optValue) {
10117
+ return selected.some((v) => v === optValue || String(v) === String(optValue));
10118
+ }
10119
+ var PainScaleFlagsWidget = ({ fieldId }) => {
10120
+ const { fieldDef, value, setValue, setTouched, error, touched, disabled } = useField(fieldId);
10121
+ const { state } = useForm();
10122
+ const showError = !!error && (touched || state.submitAttempted);
10123
+ if (!fieldDef || fieldDef.type !== "pain_scale_flags") return null;
10124
+ const def = fieldDef;
10125
+ const min = def.min ?? 0;
10126
+ const max = def.max ?? 10;
10127
+ const step = def.step ?? 1;
10128
+ const flagOptions = def.options ?? [];
10129
+ const safe = React15.useMemo(
10130
+ () => normalizePainScaleFlags(value, { min, max }),
10131
+ [value, min, max]
10132
+ );
10133
+ const theme = getThemeConfig("textarea", def.theme);
10134
+ const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
10135
+ const labelClass = theme?.labelClassName;
10136
+ const update = (next) => {
10137
+ setValue(normalizePainScaleFlags(next, { min, max }));
10138
+ setTouched();
10139
+ };
10140
+ const toggleFlag = (optValue) => {
10141
+ const sel = safe.flags;
10142
+ const isSelected = isFlagSelected(sel, optValue);
10143
+ const nextFlags = isSelected ? sel.filter((v) => v !== optValue && String(v) !== String(optValue)) : [...sel, String(optValue)];
10144
+ update({ pain: safe.pain, flags: nextFlags });
10145
+ };
10146
+ const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10147
+ def.label,
10148
+ " ",
10149
+ def.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
10150
+ ] });
10151
+ const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { children: labelContent });
10152
+ const bodyClass = cn(
10153
+ "-mt-1 flex min-w-0 flex-col border-t border-[#D0D0D0] bg-white px-3 py-3",
10154
+ disabled && "pointer-events-none opacity-60"
10155
+ );
10156
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(wrapperClass, "h-full min-h-0 flex flex-col"), children: [
10157
+ labelEl,
10158
+ def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: def.description }),
10159
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(bodyClass, "min-h-0 flex-1"), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 space-y-3", children: [
10160
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
10161
+ /* @__PURE__ */ jsxRuntime.jsxs(Label, { className: "text-sm font-medium text-slate-700", children: [
10162
+ "Pain score (VAS)",
10163
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-2 font-normal tabular-nums text-muted-foreground", children: [
10164
+ safe.pain,
10165
+ "/",
10166
+ max
10167
+ ] })
10168
+ ] }),
10169
+ /* @__PURE__ */ jsxRuntime.jsx(
10170
+ Slider,
10171
+ {
10172
+ className: cn("py-1", showError && "rounded opacity-90 ring-1 ring-red-500"),
10173
+ disabled,
10174
+ min,
10175
+ max,
10176
+ step,
10177
+ value: [safe.pain],
10178
+ onValueChange: (v) => {
10179
+ const n = v[0] ?? min;
10180
+ update({ pain: n, flags: safe.flags });
10181
+ }
10182
+ }
10183
+ )
10184
+ ] }),
10185
+ flagOptions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 space-y-1.5", children: [
10186
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium text-slate-700", children: "Triage flags" }),
10187
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-x-4 gap-y-2", children: flagOptions.map((opt) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10188
+ /* @__PURE__ */ jsxRuntime.jsx(
10189
+ Checkbox,
10190
+ {
10191
+ id: `${fieldId}-flag-${String(opt.value)}`,
10192
+ checked: isFlagSelected(safe.flags, opt.value),
10193
+ onCheckedChange: () => toggleFlag(opt.value),
10194
+ disabled
10195
+ }
10196
+ ),
10197
+ /* @__PURE__ */ jsxRuntime.jsx(
10198
+ Label,
10199
+ {
10200
+ htmlFor: `${fieldId}-flag-${String(opt.value)}`,
10201
+ className: "cursor-pointer text-sm font-normal leading-none",
10202
+ children: opt.label
10203
+ }
10204
+ )
10205
+ ] }, String(opt.value))) })
10206
+ ] }) : null
10207
+ ] }) }),
10208
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
10209
+ ] });
10210
+ };
10211
+ var FieldRenderer = ({ fieldId }) => {
10212
+ const { fieldDef, visible } = useField(fieldId);
10213
+ if (!visible || !fieldDef) {
10214
+ return null;
10215
+ }
10216
+ return renderWidget(fieldId, fieldDef);
10217
+ };
10218
+ function renderWidget(fieldId, fieldDef) {
10219
+ switch (fieldDef.type) {
10220
+ case "text":
10221
+ case "number":
10222
+ return /* @__PURE__ */ jsxRuntime.jsx(TextWidget, { fieldId });
10223
+ case "slider":
10224
+ return /* @__PURE__ */ jsxRuntime.jsx(SliderWidget, { fieldId });
10225
+ case "textarea":
10226
+ if (fieldMetaRequestsMarMedicationOrdersButton(fieldDef.meta)) {
10227
+ return /* @__PURE__ */ jsxRuntime.jsx(MarMedicationOrdersWidget, { fieldId });
10228
+ }
10229
+ return /* @__PURE__ */ jsxRuntime.jsx(TextWidget, { fieldId });
10230
+ case "richtext":
10231
+ return /* @__PURE__ */ jsxRuntime.jsx(RichTextWidget, { fieldId });
10232
+ case "date":
10233
+ return /* @__PURE__ */ jsxRuntime.jsx(DateWidget, { fieldId });
10234
+ case "datetime":
10235
+ return /* @__PURE__ */ jsxRuntime.jsx(DateTimeWidget, { fieldId });
10236
+ case "select":
10237
+ return /* @__PURE__ */ jsxRuntime.jsx(SelectWidget, { fieldId });
10238
+ case "radio":
10239
+ return /* @__PURE__ */ jsxRuntime.jsx(RadioWidget, { fieldId });
10240
+ case "checkbox":
10241
+ return /* @__PURE__ */ jsxRuntime.jsx(CheckboxWidget, { fieldId });
10242
+ case "multiselect":
10243
+ return /* @__PURE__ */ jsxRuntime.jsx(MultiSelectWidget, { fieldId });
10244
+ case "repeatable":
10245
+ return /* @__PURE__ */ jsxRuntime.jsx(RepeatableWidget, { fieldId });
10246
+ case "image_upload":
10247
+ return /* @__PURE__ */ jsxRuntime.jsx(ImageUploadWidget, { fieldId });
10248
+ case "media_upload":
10249
+ return /* @__PURE__ */ jsxRuntime.jsx(MediaUploadWidget, { fieldId });
10250
+ case "signature":
10251
+ return /* @__PURE__ */ jsxRuntime.jsx(SignatureUploadWidget, { fieldId });
10252
+ case "editable_table":
10253
+ return /* @__PURE__ */ jsxRuntime.jsx(EditableTableWidget, { fieldId });
10254
+ case "medications":
10255
+ return /* @__PURE__ */ jsxRuntime.jsx(AddMedicationWidget, { fieldId });
10256
+ case "discharge_medication_orders":
10257
+ return /* @__PURE__ */ jsxRuntime.jsx(DischargeMedicationOrdersWidget, { fieldId });
10258
+ case "investigations":
10259
+ return /* @__PURE__ */ jsxRuntime.jsx(AddInvestigationWidget, { fieldId });
10260
+ case "procedures":
10261
+ return /* @__PURE__ */ jsxRuntime.jsx(AddProcedureWidget, { fieldId });
10262
+ case "differential_diagnosis":
10263
+ return /* @__PURE__ */ jsxRuntime.jsx(DifferentialDiagnosisWidget, { fieldId });
10264
+ case "vitals":
10265
+ return /* @__PURE__ */ jsxRuntime.jsx(VitalsWidget, { fieldId });
10266
+ case "hidden_vitals":
10267
+ return /* @__PURE__ */ jsxRuntime.jsx(HiddenVitalsWidget, { fieldId });
10268
+ case "referral":
10269
+ return /* @__PURE__ */ jsxRuntime.jsx(ReferralWidget, { fieldId });
10270
+ case "followup":
10271
+ return /* @__PURE__ */ jsxRuntime.jsx(FollowupWidget, { fieldId });
10272
+ case "smart_textarea":
10273
+ return /* @__PURE__ */ jsxRuntime.jsx(SmartTextareaWidget, { fieldId });
10274
+ case "diagnosis_textarea":
10275
+ return /* @__PURE__ */ jsxRuntime.jsx(DiagnosisTextareaWidget, { fieldId });
10276
+ case "obstetric_history":
10277
+ return /* @__PURE__ */ jsxRuntime.jsx(ObstetricHistoryWidget, { fieldId });
10278
+ case "eye_prescription":
10279
+ return /* @__PURE__ */ jsxRuntime.jsx(OphthalmologyWidget, { fieldId });
10280
+ case "ophthal_diagnosis":
10281
+ return /* @__PURE__ */ jsxRuntime.jsx(OphthalDiagnosisWidget, { fieldId });
10282
+ case "orthopedic_exam":
10283
+ return /* @__PURE__ */ jsxRuntime.jsx(OrthopedicExamWidget, { fieldId });
10284
+ case "general_surgery_smart_history":
10285
+ return /* @__PURE__ */ jsxRuntime.jsx(GsSmartHistoryWidget, { fieldId });
10286
+ case "general_surgery_examination":
10287
+ return /* @__PURE__ */ jsxRuntime.jsx(GsExaminationWidget, { fieldId });
10288
+ case "general_surgery_grading":
10289
+ return /* @__PURE__ */ jsxRuntime.jsx(GsGradingWidget, { fieldId });
10290
+ case "pain_scale_flags":
10291
+ return /* @__PURE__ */ jsxRuntime.jsx(PainScaleFlagsWidget, { fieldId });
10292
+ case "toggle": {
10293
+ const { value, setValue, setTouched, disabled } = useField(fieldId);
10294
+ const store = useFormStore();
10295
+ const excludes = fieldDef.excludes ?? [];
10296
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
10297
+ /* @__PURE__ */ jsxRuntime.jsx(
10298
+ Switch,
10299
+ {
10300
+ checked: value === true,
10301
+ disabled,
10302
+ onCheckedChange: (checked) => {
10303
+ setValue(checked);
10304
+ setTouched();
10305
+ if (checked) excludes.forEach((id) => store.setValue(id, false));
10306
+ }
10307
+ }
10308
+ ),
10309
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium leading-none cursor-pointer select-none", children: fieldDef.label })
10310
+ ] });
10311
+ }
10312
+ case "suggestion_textarea":
10313
+ case "complaint_chips":
10314
+ return /* @__PURE__ */ jsxRuntime.jsx(SuggestionTextareaWidget, { fieldId });
10315
+ case "lens_assessment":
10316
+ return /* @__PURE__ */ jsxRuntime.jsx(LensAssessmentWidget, { fieldId });
10317
+ case "functional_impairment_score":
10318
+ return /* @__PURE__ */ jsxRuntime.jsx(FunctionalImpairmentScoreWidget, { fieldId });
10319
+ case "biometry_iol_workup":
10320
+ return /* @__PURE__ */ jsxRuntime.jsx(BiometryIolWorkupWidget, { fieldId });
10321
+ case "surgical_risk_flags":
10322
+ return /* @__PURE__ */ jsxRuntime.jsx(SurgicalRiskFlagsWidget, { fieldId });
10323
+ case "static_text": {
10324
+ const def = fieldDef;
10325
+ const size = def.size ?? "regular";
10326
+ const labelClass = size === "large" ? "text-base" : "text-sm";
10327
+ const descClass = size === "large" ? "text-sm" : "text-xs";
10328
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${labelClass} text-muted-foreground`, children: [
10329
+ def.label,
10330
+ def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: `mt-1 ${descClass} opacity-90`, children: def.description })
10331
+ ] });
10332
+ }
10333
+ default:
10334
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-red-500", children: [
10335
+ "Unknown field type: ",
10336
+ fieldDef.type
10337
+ ] });
10338
+ }
10339
+ }
10340
+ var Section = ({ title, children }) => {
10341
+ const [expanded, setExpanded] = React15.useState(true);
10342
+ const handleToggle = () => setExpanded((prev) => !prev);
10343
+ const contentClassName = cn(
10344
+ "overflow-hidden transition-[height] duration-200 ease-in-out",
10345
+ !expanded && "hidden"
10346
+ );
10347
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-6 border rounded-lg bg-white shadow-sm overflow-hidden", children: [
10348
+ /* @__PURE__ */ jsxRuntime.jsxs(
8032
10349
  "button",
8033
10350
  {
8034
10351
  type: "button",
@@ -8207,14 +10524,24 @@ var SmartForm = ({
8207
10524
  if (position !== "left") return null;
8208
10525
  return /* @__PURE__ */ jsxRuntime.jsx(FieldRenderer, { fieldId }, fieldId);
8209
10526
  }) }),
8210
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-2 grid grid-cols-2 gap-x-2 space-y-2", children: fieldIds.map((fieldId) => {
10527
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-2 grid grid-cols-2 gap-2", children: fieldIds.map((fieldId) => {
8211
10528
  const fieldDef = store.getFieldDef(fieldId);
8212
10529
  if (!fieldDef) return null;
8213
10530
  const position = fieldDef.position ?? "center";
8214
10531
  if (position !== "center") return null;
8215
10532
  const colSpanRaw = fieldDef.colSpan ?? 1;
8216
10533
  const colSpan = colSpanRaw === 2 ? 2 : 1;
8217
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: colSpan === 2 ? "col-span-2" : "col-span-1", children: /* @__PURE__ */ jsxRuntime.jsx(FieldRenderer, { fieldId }) }, fieldId);
10534
+ return /* @__PURE__ */ jsxRuntime.jsx(
10535
+ "div",
10536
+ {
10537
+ className: cn(
10538
+ "min-h-0 flex flex-col",
10539
+ colSpan === 2 ? "col-span-2" : "col-span-1 h-full"
10540
+ ),
10541
+ children: /* @__PURE__ */ jsxRuntime.jsx(FieldRenderer, { fieldId })
10542
+ },
10543
+ fieldId
10544
+ );
8218
10545
  }) }),
8219
10546
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-1 flex flex-col gap-2", children: fieldIds.map((fieldId) => {
8220
10547
  const fieldDef = store.getFieldDef(fieldId);
@@ -8662,11 +10989,17 @@ var ReadOnlyDischargeMedicationOrders = ({ fieldDef, value }) => {
8662
10989
  }) })
8663
10990
  ] });
8664
10991
  };
8665
- var ReadOnlyFieldRenderer = ({ fieldDef, value }) => {
10992
+ var ReadOnlyFieldRenderer = ({
10993
+ fieldDef,
10994
+ value,
10995
+ allValues,
10996
+ resolveFieldDef
10997
+ }) => {
8666
10998
  if (!fieldDef) return null;
8667
10999
  switch (fieldDef.type) {
8668
11000
  case "text":
8669
11001
  case "number":
11002
+ case "slider":
8670
11003
  case "textarea":
8671
11004
  case "richtext":
8672
11005
  return /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef, value });
@@ -8703,6 +11036,144 @@ var ReadOnlyFieldRenderer = ({ fieldDef, value }) => {
8703
11036
  /* @__PURE__ */ jsxRuntime.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" })
8704
11037
  ] });
8705
11038
  }
11039
+ case "suggestion_textarea":
11040
+ case "complaint_chips": {
11041
+ const embeddedIds = fieldDef.meta && Array.isArray(fieldDef.meta.embeddedFieldIds) ? fieldDef.meta.embeddedFieldIds.filter((id) => typeof id === "string" && id.trim().length > 0).map((id) => id.trim()) : [];
11042
+ const showEmbedded = embeddedIds.length > 0 && resolveFieldDef && allValues && typeof allValues === "object";
11043
+ if (!showEmbedded) {
11044
+ return /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef, value });
11045
+ }
11046
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
11047
+ /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef, value }),
11048
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid gap-3 border-t border-muted-foreground/20 pt-3 sm:grid-cols-3", children: embeddedIds.map((id) => {
11049
+ const fd = resolveFieldDef(id);
11050
+ if (!fd) return null;
11051
+ return /* @__PURE__ */ jsxRuntime.jsx(
11052
+ ReadOnlyFieldRenderer,
11053
+ {
11054
+ fieldDef: fd,
11055
+ value: allValues[id],
11056
+ allValues,
11057
+ resolveFieldDef
11058
+ },
11059
+ id
11060
+ );
11061
+ }) })
11062
+ ] });
11063
+ }
11064
+ case "lens_assessment": {
11065
+ const v = value && typeof value === "object" && !Array.isArray(value) ? value : null;
11066
+ const notes = typeof v?.notes === "string" ? v.notes : "";
11067
+ const key = typeof v?.assessmentKey === "string" ? v.assessmentKey : null;
11068
+ const locs = v?.locs;
11069
+ const locsRecord = locs != null && typeof locs === "object" && !Array.isArray(locs) ? locs : null;
11070
+ const eyeLine = (label, g) => {
11071
+ if (!g || typeof g !== "object") return null;
11072
+ const num = (k) => typeof g[k] === "number" ? g[k] : "\u2014";
11073
+ return /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-foreground", children: [
11074
+ label,
11075
+ ": NO ",
11076
+ String(num("NO")),
11077
+ ", NC ",
11078
+ String(num("NC")),
11079
+ ", C ",
11080
+ String(num("C")),
11081
+ ", PSC",
11082
+ " ",
11083
+ String(num("PSC"))
11084
+ ] });
11085
+ };
11086
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 rounded-md border p-3 text-sm", children: [
11087
+ fieldDef.label && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium text-foreground", children: fieldDef.label }),
11088
+ locsRecord ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 border-l-2 border-muted pl-2", children: [
11089
+ eyeLine("Right (OD)", locsRecord.OD),
11090
+ eyeLine("Left (OS)", locsRecord.OS)
11091
+ ] }) : null,
11092
+ key && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
11093
+ "Assessment (legacy): ",
11094
+ key
11095
+ ] }),
11096
+ notes && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "whitespace-pre-wrap text-foreground", children: notes })
11097
+ ] });
11098
+ }
11099
+ case "functional_impairment_score": {
11100
+ const v = parseFunctionalImpairmentScore(value);
11101
+ const total = functionalImpairmentTotal(v);
11102
+ const lines = [
11103
+ `Reading: ${v.reading}`,
11104
+ `Night driving: ${v.nightDriving}`,
11105
+ `Glare: ${v.glare}`,
11106
+ `Occupation: ${v.occupation}`,
11107
+ `ADL: ${v.adl}`,
11108
+ `Total: ${total}/15`
11109
+ ].join("\n");
11110
+ return /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef, value: lines });
11111
+ }
11112
+ case "biometry_iol_workup": {
11113
+ const v = value && typeof value === "object" && !Array.isArray(value) ? value : {};
11114
+ const s = (k) => typeof v[k] === "string" ? v[k] : "";
11115
+ const b = (k) => v[k] === true;
11116
+ const method = v.method === "ascan_immersion" ? "A-scan (immersion)" : v.method === "ascan_contact" ? "A-scan (contact)" : "Optical biometry (IOL Master)";
11117
+ const lines = [
11118
+ `Axial length OD/OS (mm): ${s("axialLengthOD")} / ${s("axialLengthOS")}`,
11119
+ `K1/K2/Axis OD/OS: ${s("k1k2AxisOD")} / ${s("k1k2AxisOS")}`,
11120
+ `AC depth OD/OS (mm): ${s("anteriorChamberDepthOD")} / ${s("anteriorChamberDepthOS")}`,
11121
+ `IOL power (D) OD/OS: ${s("iolPowerOD")} / ${s("iolPowerOS")}`,
11122
+ `Target refraction (D) OD/OS: ${s("targetRefractionOD")} / ${s("targetRefractionOS")}`,
11123
+ `Formula: ${s("formula") || "\u2014"}`,
11124
+ `Method: ${method}`,
11125
+ `Corneal topography uploaded: ${b("cornealTopoUploaded") ? "Yes" : "No"}`,
11126
+ `Specular microscopy: ${b("specularMicroscopyDone") ? "Yes" : "No"}`,
11127
+ `Endothelial count: ${s("endothelialCount") || "\u2014"}`
11128
+ ].join("\n");
11129
+ return /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef, value: lines });
11130
+ }
11131
+ case "surgical_risk_flags": {
11132
+ const v = value && typeof value === "object" && !Array.isArray(value) ? value : null;
11133
+ const list = (x) => Array.isArray(x) ? x.filter((i) => typeof i === "string").join(", ") : "\u2014";
11134
+ const od = list(v?.OD);
11135
+ const os = list(v?.OS);
11136
+ const lines = [`Right eye (OD): ${od}`, `Left eye (OS): ${os}`].join("\n");
11137
+ return /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef, value: lines });
11138
+ }
11139
+ case "pain_scale_flags": {
11140
+ const def = fieldDef;
11141
+ const min = def.min ?? 0;
11142
+ const max = def.max ?? 10;
11143
+ const safe = normalizePainScaleFlags(value, { min, max });
11144
+ const opts = def.options ?? [];
11145
+ const flagLabels = safe.flags.map((fv) => {
11146
+ const o = opts.find((x) => x.value === fv || String(x.value) === String(fv));
11147
+ return o?.label ?? fv;
11148
+ });
11149
+ const lines = [
11150
+ `Pain score (VAS): ${safe.pain}/${max}`,
11151
+ flagLabels.length > 0 ? `Triage flags: ${flagLabels.join(", ")}` : "Triage flags: \u2014"
11152
+ ].join("\n");
11153
+ return /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef, value: lines });
11154
+ }
11155
+ case "general_surgery_smart_history":
11156
+ case "general_surgery_grading":
11157
+ return /* @__PURE__ */ jsxRuntime.jsx(
11158
+ ReadOnlyText,
11159
+ {
11160
+ fieldDef,
11161
+ value: value && typeof value === "object" ? JSON.stringify(value, null, 2) : value == null || value === "" ? "\u2014" : String(value)
11162
+ }
11163
+ );
11164
+ case "general_surgery_examination": {
11165
+ const structuredDisplay = value && typeof value === "object" ? JSON.stringify(value, null, 2) : value == null || value === "" ? "\u2014" : String(value);
11166
+ const clinicalDef = resolveFieldDef?.("clinical_examination");
11167
+ const clinicalRaw = allValues?.["clinical_examination"];
11168
+ const clinicalStr = typeof clinicalRaw === "string" ? clinicalRaw : clinicalRaw != null && clinicalRaw !== "" ? String(clinicalRaw) : "";
11169
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
11170
+ /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef, value: structuredDisplay }),
11171
+ clinicalDef ? /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef: clinicalDef, value: clinicalStr }) : clinicalStr ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
11172
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-gray-700", children: "Clinical examination" }),
11173
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-gray-900 border border-gray-200 rounded-md p-3 bg-gray-50 min-h-[2.5rem] whitespace-pre-wrap", children: clinicalStr })
11174
+ ] }) : null
11175
+ ] });
11176
+ }
8706
11177
  case "static_text": {
8707
11178
  const def = fieldDef;
8708
11179
  const size = def.size ?? "regular";
@@ -8749,7 +11220,9 @@ var ReadOnlyForm = ({ schema, submission }) => {
8749
11220
  ReadOnlyFieldRenderer,
8750
11221
  {
8751
11222
  fieldDef,
8752
- value: formData[child]
11223
+ value: formData[child],
11224
+ allValues: formData,
11225
+ resolveFieldDef: (id) => fieldMap.get(id)
8753
11226
  },
8754
11227
  child
8755
11228
  ) : null;
@@ -8768,7 +11241,9 @@ var ReadOnlyForm = ({ schema, submission }) => {
8768
11241
  ReadOnlyFieldRenderer,
8769
11242
  {
8770
11243
  fieldDef,
8771
- value: formData[fieldId]
11244
+ value: formData[fieldId],
11245
+ allValues: formData,
11246
+ resolveFieldDef: (id) => fieldMap.get(id)
8772
11247
  },
8773
11248
  fieldId
8774
11249
  ))
@@ -8799,7 +11274,9 @@ var ReadOnlyForm = ({ schema, submission }) => {
8799
11274
  ReadOnlyFieldRenderer,
8800
11275
  {
8801
11276
  fieldDef,
8802
- value: formData[fieldId]
11277
+ value: formData[fieldId],
11278
+ allValues: formData,
11279
+ resolveFieldDef: (id) => fieldMap.get(id)
8803
11280
  },
8804
11281
  fieldId
8805
11282
  ))