formanitor 0.0.44 → 0.0.45

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
@@ -88,23 +88,23 @@ function validateField(value, field) {
88
88
  const rules = field.validation;
89
89
  if (!rules) return null;
90
90
  if (field.type === "number") {
91
- const num = Number(value);
92
- if (isNaN(num)) return "Must be a valid number";
93
- if (rules.min !== void 0 && num < rules.min) {
91
+ const num2 = Number(value);
92
+ if (isNaN(num2)) return "Must be a valid number";
93
+ if (rules.min !== void 0 && num2 < rules.min) {
94
94
  return `Must be at least ${rules.min}`;
95
95
  }
96
- if (rules.max !== void 0 && num > rules.max) {
96
+ if (rules.max !== void 0 && num2 > rules.max) {
97
97
  return `Must be at most ${rules.max}`;
98
98
  }
99
99
  }
100
100
  if (field.type === "slider") {
101
- const num = Number(value);
102
- if (isNaN(num)) return "Must be a valid number";
101
+ const num2 = Number(value);
102
+ if (isNaN(num2)) return "Must be a valid number";
103
103
  const s = field;
104
104
  const min = s.min ?? 0;
105
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}`;
106
+ if (num2 < min) return `Must be at least ${min}`;
107
+ if (num2 > max) return `Must be at most ${max}`;
108
108
  }
109
109
  if (typeof value === "string") {
110
110
  if (rules.minLength !== void 0 && value.length < rules.minLength) {
@@ -423,7 +423,7 @@ function normalizeGeneralSurgerySmartHistory(raw) {
423
423
  ...painIn,
424
424
  severity: Number.isFinite(sev) ? Math.min(10, Math.max(0, Math.round(sev))) : d.pain.severity
425
425
  };
426
- const str4 = (x) => typeof x === "string" ? x : "";
426
+ const str5 = (x) => typeof x === "string" ? x : "";
427
427
  const strArr = (x) => Array.isArray(x) ? x.filter((i) => typeof i === "string") : [];
428
428
  const swell = v.swelling && typeof v.swelling === "object" ? v.swelling : {};
429
429
  const gi = v.gi && typeof v.gi === "object" ? v.gi : {};
@@ -433,44 +433,44 @@ function normalizeGeneralSurgerySmartHistory(raw) {
433
433
  return {
434
434
  pain,
435
435
  swelling: {
436
- duration: str4(swell.duration),
437
- sizeProgression: str4(swell.sizeProgression),
438
- painfulPainless: str4(swell.painfulPainless),
436
+ duration: str5(swell.duration),
437
+ sizeProgression: str5(swell.sizeProgression),
438
+ painfulPainless: str5(swell.painfulPainless),
439
439
  checks: strArr(swell.checks)
440
440
  },
441
441
  gi: {
442
- appetite: str4(gi.appetite),
443
- weightLoss: str4(gi.weightLoss),
444
- bowelHabits: str4(gi.bowelHabits),
442
+ appetite: str5(gi.appetite),
443
+ weightLoss: str5(gi.weightLoss),
444
+ bowelHabits: str5(gi.bowelHabits),
445
445
  checks: strArr(gi.checks)
446
446
  },
447
447
  breast: {
448
- lumpDuration: str4(breast.lumpDuration),
449
- nippleDischarge: str4(breast.nippleDischarge),
448
+ lumpDuration: str5(breast.lumpDuration),
449
+ nippleDischarge: str5(breast.nippleDischarge),
450
450
  checks: strArr(breast.checks)
451
451
  },
452
452
  ano: { checks: strArr(ano.checks) },
453
453
  thyroid: {
454
- swellingDuration: str4(thy.swellingDuration),
454
+ swellingDuration: str5(thy.swellingDuration),
455
455
  checks: strArr(thy.checks)
456
456
  }
457
457
  };
458
458
  }
459
459
  function normalizeBreastExamSide(partial) {
460
460
  const e = defaultBreastExamSide();
461
- const str4 = (x) => typeof x === "string" ? x : "";
462
- const bool2 = (x) => x === true;
461
+ const str5 = (x) => typeof x === "string" ? x : "";
462
+ const bool3 = (x) => x === true;
463
463
  if (!partial || typeof partial !== "object") return e;
464
464
  const p = partial;
465
465
  return {
466
- size: str4(p.size),
467
- quadrant: str4(p.quadrant),
468
- tenderness: str4(p.tenderness),
469
- fixity: str4(p.fixity),
470
- skinInvolvement: str4(p.skinInvolvement),
471
- consistency: str4(p.consistency),
472
- axillaryNodes: bool2(p.axillaryNodes),
473
- nippleAreolarComplex: bool2(p.nippleAreolarComplex)
466
+ size: str5(p.size),
467
+ quadrant: str5(p.quadrant),
468
+ tenderness: str5(p.tenderness),
469
+ fixity: str5(p.fixity),
470
+ skinInvolvement: str5(p.skinInvolvement),
471
+ consistency: str5(p.consistency),
472
+ axillaryNodes: bool3(p.axillaryNodes),
473
+ nippleAreolarComplex: bool3(p.nippleAreolarComplex)
474
474
  };
475
475
  }
476
476
  function normalizeBreastExaminationBlock(raw) {
@@ -494,7 +494,7 @@ function normalizeGeneralSurgeryExamination(raw) {
494
494
  const th = v.thyroid && typeof v.thyroid === "object" ? v.thyroid : {};
495
495
  const ar = v.anorectal && typeof v.anorectal === "object" ? v.anorectal : {};
496
496
  const lm = v.limb && typeof v.limb === "object" ? v.limb : {};
497
- const bool2 = (x) => x === true;
497
+ const bool3 = (x) => x === true;
498
498
  return {
499
499
  general: strArr(v.general),
500
500
  regions: strArr(v.regions),
@@ -507,27 +507,27 @@ function normalizeGeneralSurgeryExamination(raw) {
507
507
  },
508
508
  hernia: {
509
509
  site: typeof hb.site === "string" ? hb.site : "",
510
- reducible: bool2(hb.reducible),
511
- coughImpulse: bool2(hb.coughImpulse),
512
- tenderness: bool2(hb.tenderness)
510
+ reducible: bool3(hb.reducible),
511
+ coughImpulse: bool3(hb.coughImpulse),
512
+ tenderness: bool3(hb.tenderness)
513
513
  },
514
514
  breast: normalizeBreastExaminationBlock(br),
515
515
  thyroid: {
516
516
  size: typeof th.size === "string" ? th.size : "",
517
- mobileDeglutition: bool2(th.mobileDeglutition),
518
- nodules: bool2(th.nodules),
519
- cervicalNodes: bool2(th.cervicalNodes)
517
+ mobileDeglutition: bool3(th.mobileDeglutition),
518
+ nodules: bool3(th.nodules),
519
+ cervicalNodes: bool3(th.cervicalNodes)
520
520
  },
521
521
  anorectal: {
522
522
  inspection: typeof ar.inspection === "string" ? ar.inspection : "",
523
- dreDone: bool2(ar.dreDone),
524
- proctoscopyDone: bool2(ar.proctoscopyDone),
523
+ dreDone: bool3(ar.dreDone),
524
+ proctoscopyDone: bool3(ar.proctoscopyDone),
525
525
  notes: typeof ar.notes === "string" ? ar.notes : ""
526
526
  },
527
527
  limb: {
528
- dilatedVeins: bool2(lm.dilatedVeins),
529
- ulcer: bool2(lm.ulcer),
530
- oedema: bool2(lm.oedema)
528
+ dilatedVeins: bool3(lm.dilatedVeins),
529
+ ulcer: bool3(lm.ulcer),
530
+ oedema: bool3(lm.oedema)
531
531
  }
532
532
  };
533
533
  }
@@ -1173,11 +1173,17 @@ function normalizeUrologyPathway(raw) {
1173
1173
  }
1174
1174
 
1175
1175
  // src/core/painScaleFlags.ts
1176
+ var UPT_VALUES = ["", "Positive", "Negative", "Not done"];
1177
+ function isUpt(x) {
1178
+ return typeof x === "string" && UPT_VALUES.includes(x);
1179
+ }
1176
1180
  function normalizePainScaleFlags(raw, bounds) {
1177
1181
  const min = bounds?.min ?? 0;
1178
1182
  const max = bounds?.max ?? 10;
1179
1183
  let pain = min;
1180
1184
  let flags = [];
1185
+ let bp = "";
1186
+ let upt = "";
1181
1187
  if (raw && typeof raw === "object" && !Array.isArray(raw)) {
1182
1188
  const o = raw;
1183
1189
  const p = Number(o.pain);
@@ -1185,8 +1191,10 @@ function normalizePainScaleFlags(raw, bounds) {
1185
1191
  if (Array.isArray(o.flags)) {
1186
1192
  flags = o.flags.filter((x) => typeof x === "string");
1187
1193
  }
1194
+ if (typeof o.bp === "string") bp = o.bp;
1195
+ if (isUpt(o.upt)) upt = o.upt;
1188
1196
  }
1189
- return { pain, flags };
1197
+ return { pain, flags, bp, upt };
1190
1198
  }
1191
1199
 
1192
1200
  // src/core/store.ts
@@ -4299,24 +4307,24 @@ function Spinner({
4299
4307
  value,
4300
4308
  onChange
4301
4309
  }) {
4302
- const num = parseInt(value, 10) || 0;
4310
+ const num2 = parseInt(value, 10) || 0;
4303
4311
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center", children: [
4304
4312
  /* @__PURE__ */ jsxRuntime.jsx(
4305
4313
  "button",
4306
4314
  {
4307
4315
  type: "button",
4308
4316
  className: "text-muted-foreground hover:text-foreground cursor-pointer",
4309
- onClick: () => onChange(String(num + 1)),
4317
+ onClick: () => onChange(String(num2 + 1)),
4310
4318
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, { className: "h-3 w-3" })
4311
4319
  }
4312
4320
  ),
4313
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm w-4 text-center leading-none", children: num }),
4321
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm w-4 text-center leading-none", children: num2 }),
4314
4322
  /* @__PURE__ */ jsxRuntime.jsx(
4315
4323
  "button",
4316
4324
  {
4317
4325
  type: "button",
4318
4326
  className: "text-muted-foreground hover:text-foreground cursor-pointer",
4319
- onClick: () => onChange(String(Math.max(0, num - 1))),
4327
+ onClick: () => onChange(String(Math.max(0, num2 - 1))),
4320
4328
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-3 w-3" })
4321
4329
  }
4322
4330
  )
@@ -5897,14 +5905,14 @@ var FollowupWidget = ({ fieldId }) => {
5897
5905
  const handleValueChange = React15.useCallback(
5898
5906
  (newValue) => {
5899
5907
  setTouched();
5900
- const num = parseInt(newValue, 10);
5908
+ const num2 = parseInt(newValue, 10);
5901
5909
  const min = displayUnit === "days" ? 0 : 1;
5902
- const valid = (Number.isNaN(num) ? min : num) >= min || newValue === "";
5910
+ const valid = (Number.isNaN(num2) ? min : num2) >= min || newValue === "";
5903
5911
  if (!valid && newValue !== "") {
5904
5912
  setValue({ followupType: "one time", value: String(displayUnit === "days" ? 0 : durationToDays(1, displayUnit)), unit: "days" });
5905
5913
  return;
5906
5914
  }
5907
- const days = durationToDays(Number.isNaN(num) ? displayUnit === "days" ? 0 : 1 : num, displayUnit);
5915
+ const days = durationToDays(Number.isNaN(num2) ? displayUnit === "days" ? 0 : 1 : num2, displayUnit);
5908
5916
  setValue({ followupType: "one time", value: String(days), unit: "days" });
5909
5917
  },
5910
5918
  [displayUnit, setValue, setTouched]
@@ -6441,14 +6449,22 @@ var Switch = React15__namespace.forwardRef(
6441
6449
  }
6442
6450
  );
6443
6451
  Switch.displayName = "Switch";
6452
+ var DEFAULT_MENSTRUAL = {
6453
+ menarche_age: 13,
6454
+ cycle_length: 28,
6455
+ flow_days: 4,
6456
+ cycle_regular: true,
6457
+ dysmenorrhea: 0
6458
+ };
6444
6459
  var DEFAULT_DRAFT = {
6445
6460
  gpal: { G: 0, P: 0, A: 0, L: 0 },
6446
6461
  lmp: "",
6447
- is_pregnant: false,
6462
+ pregnancy_status: "not_pregnant",
6448
6463
  eddUSG: "",
6449
6464
  primaryEDD: "lmp",
6450
6465
  complications: "",
6451
- outcome: null
6466
+ outcome: null,
6467
+ menstrual: { ...DEFAULT_MENSTRUAL }
6452
6468
  };
6453
6469
  function pad2(n) {
6454
6470
  return String(n).padStart(2, "0");
@@ -6481,6 +6497,33 @@ function clampInt(val, min, max) {
6481
6497
  if (!Number.isFinite(val)) return min;
6482
6498
  return Math.max(min, Math.min(max, Math.trunc(val)));
6483
6499
  }
6500
+ function clampDysmenorrhea(val) {
6501
+ const n = Math.round(Number(val));
6502
+ if (!Number.isFinite(n)) return 0;
6503
+ if (n <= 0) return 0;
6504
+ if (n >= 3) return 3;
6505
+ return n;
6506
+ }
6507
+ function isPregnancyStatus(x) {
6508
+ return x === "not_pregnant" || x === "pregnant" || x === "unknown";
6509
+ }
6510
+ function normalizeMenstrual(raw) {
6511
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
6512
+ return { ...DEFAULT_MENSTRUAL };
6513
+ }
6514
+ const o = raw;
6515
+ const num2 = (v, fb) => {
6516
+ const n = Number(v);
6517
+ return Number.isFinite(n) ? n : fb;
6518
+ };
6519
+ return {
6520
+ menarche_age: num2(o.menarche_age, DEFAULT_MENSTRUAL.menarche_age),
6521
+ cycle_length: num2(o.cycle_length, DEFAULT_MENSTRUAL.cycle_length),
6522
+ flow_days: num2(o.flow_days, DEFAULT_MENSTRUAL.flow_days),
6523
+ cycle_regular: typeof o.cycle_regular === "boolean" ? o.cycle_regular : DEFAULT_MENSTRUAL.cycle_regular,
6524
+ dysmenorrhea: clampDysmenorrhea(o.dysmenorrhea)
6525
+ };
6526
+ }
6484
6527
  function parseLegacyString(input) {
6485
6528
  const result = {};
6486
6529
  const gpalMatch = input.match(/G(\d+)\s*P(\d+)\s*A(\d+)\s*L(\d+)/i);
@@ -6510,6 +6553,11 @@ function normalizeToDraft(value) {
6510
6553
  const json = safeJsonParse(value);
6511
6554
  parsed = json ?? value;
6512
6555
  }
6556
+ const resolvePregnancyStatus = (o) => {
6557
+ if (isPregnancyStatus(o?.pregnancy_status)) return o.pregnancy_status;
6558
+ if (typeof o?.is_pregnant === "boolean") return o.is_pregnant ? "pregnant" : "not_pregnant";
6559
+ return "not_pregnant";
6560
+ };
6513
6561
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed) && "gpal" in parsed && parsed.gpal && typeof parsed.gpal === "object") {
6514
6562
  const gpal = parsed.gpal ?? {};
6515
6563
  const edd = parsed.edd ?? null;
@@ -6518,7 +6566,6 @@ function normalizeToDraft(value) {
6518
6566
  const lmp = parsed.lmp ?? "";
6519
6567
  const complications = parsed.complications ?? "";
6520
6568
  const outcome = parsed.outcome ?? null;
6521
- const is_pregnant = !!parsed.is_pregnant;
6522
6569
  return {
6523
6570
  isNewEntry: false,
6524
6571
  draft: {
@@ -6529,7 +6576,7 @@ function normalizeToDraft(value) {
6529
6576
  L: clampInt(Number(gpal.L ?? 0), 0, 20)
6530
6577
  },
6531
6578
  lmp: typeof lmp === "string" ? lmp : "",
6532
- is_pregnant,
6579
+ pregnancy_status: resolvePregnancyStatus(parsed),
6533
6580
  eddUSG: typeof eddUSG === "string" ? eddUSG : "",
6534
6581
  primaryEDD: primaryEDD === "usg" ? "usg" : "lmp",
6535
6582
  complications: typeof complications === "string" ? complications : "",
@@ -6538,7 +6585,8 @@ function normalizeToDraft(value) {
6538
6585
  date: typeof outcome.date === "string" ? outcome.date : "",
6539
6586
  notes: typeof outcome.notes === "string" ? outcome.notes : "",
6540
6587
  is_final: !!outcome.is_final
6541
- } : null
6588
+ } : null,
6589
+ menstrual: normalizeMenstrual(parsed.menstrual)
6542
6590
  }
6543
6591
  };
6544
6592
  }
@@ -6564,7 +6612,8 @@ function normalizeToDraft(value) {
6564
6612
  notes: typeof parsed.outcome.notes === "string" ? parsed.outcome.notes : "",
6565
6613
  is_final: !!parsed.outcome.is_final
6566
6614
  } : null,
6567
- is_pregnant: !!parsed.is_pregnant
6615
+ pregnancy_status: resolvePregnancyStatus(parsed),
6616
+ menstrual: normalizeMenstrual(parsed.menstrual)
6568
6617
  }
6569
6618
  };
6570
6619
  }
@@ -6615,16 +6664,18 @@ function computeTrimester(ga) {
6615
6664
  function buildStored(draft, today) {
6616
6665
  const lmpIso = isValidIsoDate(draft.lmp) ? draft.lmp : null;
6617
6666
  const eddUsgIso = isValidIsoDate(draft.eddUSG) ? draft.eddUSG : null;
6618
- if (!draft.is_pregnant) {
6667
+ if (draft.pregnancy_status !== "pregnant") {
6619
6668
  return {
6620
6669
  gpal: draft.gpal,
6621
6670
  lmp: lmpIso,
6622
6671
  is_pregnant: false,
6672
+ pregnancy_status: draft.pregnancy_status,
6623
6673
  edd: null,
6624
6674
  gestationalAge: null,
6625
6675
  trimester: null,
6626
6676
  complications: draft.complications.trim() ? draft.complications : null,
6627
- outcome: draft.outcome
6677
+ outcome: draft.outcome,
6678
+ menstrual: { ...draft.menstrual }
6628
6679
  };
6629
6680
  }
6630
6681
  const eddFromLmp = lmpIso ? computeEddFromLmp(lmpIso) : null;
@@ -6636,11 +6687,13 @@ function buildStored(draft, today) {
6636
6687
  gpal: draft.gpal,
6637
6688
  lmp: lmpIso,
6638
6689
  is_pregnant: true,
6690
+ pregnancy_status: "pregnant",
6639
6691
  edd: { lmp: eddFromLmp, usg: eddUsgIso, primary },
6640
6692
  gestationalAge: gaPrimary,
6641
6693
  trimester: computeTrimester(gaPrimary),
6642
6694
  complications: draft.complications.trim() ? draft.complications : null,
6643
- outcome: draft.outcome
6695
+ outcome: draft.outcome,
6696
+ menstrual: { ...draft.menstrual }
6644
6697
  };
6645
6698
  }
6646
6699
  function stripGpalSuffix(label) {
@@ -6685,7 +6738,8 @@ var ObstetricHistoryWidget = ({ fieldId }) => {
6685
6738
  };
6686
6739
  const commitDebounced = useDebouncedCommit(commitImmediate, 500);
6687
6740
  const storedComputed = React15.useMemo(() => buildStored(draft, today), [draft, today]);
6688
- const rightPanelEnabled = draft.is_pregnant && (!!storedComputed.lmp || !!storedComputed.edd?.usg);
6741
+ const isPregnant = draft.pregnancy_status === "pregnant";
6742
+ const rightPanelEnabled = isPregnant && (!!storedComputed.lmp || !!storedComputed.edd?.usg);
6689
6743
  const headerLabel = fieldDef?.label ? stripGpalSuffix(fieldDef.label) : "Obstetric History";
6690
6744
  const setDraft = (updater, persist) => {
6691
6745
  setDraftState((prev) => {
@@ -6723,10 +6777,13 @@ var ObstetricHistoryWidget = ({ fieldId }) => {
6723
6777
  setLmpError(null);
6724
6778
  setDraft((prev) => ({ ...prev, lmp: nextIso }), "debounce");
6725
6779
  };
6726
- const handlePregStatus = (isPregnant) => {
6780
+ const handlePregStatus = (status) => {
6727
6781
  setLmpError(null);
6728
6782
  setPrimaryEddError(null);
6729
- setDraft((prev) => ({ ...prev, is_pregnant: isPregnant }), "immediate");
6783
+ setDraft((prev) => ({ ...prev, pregnancy_status: status }), "immediate");
6784
+ };
6785
+ const setMenstrualPatch = (patch) => {
6786
+ setDraft((prev) => ({ ...prev, menstrual: { ...prev.menstrual, ...patch } }), "debounce");
6730
6787
  };
6731
6788
  const handleEddUsgChange = (nextIso) => {
6732
6789
  setPrimaryEddError(null);
@@ -6823,17 +6880,17 @@ var ObstetricHistoryWidget = ({ fieldId }) => {
6823
6880
  ),
6824
6881
  lmpError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-600", children: lmpError })
6825
6882
  ] }),
6826
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 rounded-lg border bg-white p-4", children: [
6883
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 rounded-lg border bg-white p-4 min-w-0", children: [
6827
6884
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-medium", children: "Pregnancy Status" }),
6828
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
6885
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-wrap gap-2", children: [
6829
6886
  /* @__PURE__ */ jsxRuntime.jsx(
6830
6887
  "button",
6831
6888
  {
6832
6889
  type: "button",
6833
- onClick: () => handlePregStatus(false),
6890
+ onClick: () => handlePregStatus("not_pregnant"),
6834
6891
  className: cn(
6835
- "flex-1 rounded-md border px-3 py-2 text-xs",
6836
- !draft.is_pregnant ? "bg-green-600 text-white border-green-600" : "bg-white"
6892
+ "shrink-0 rounded-full border px-3 py-1.5 text-[11px] font-medium transition-colors",
6893
+ draft.pregnancy_status === "not_pregnant" ? "border-green-600 bg-green-600 text-white" : "border-slate-300 bg-white text-slate-700 hover:bg-slate-50"
6837
6894
  ),
6838
6895
  children: "Not Pregnant"
6839
6896
  }
@@ -6842,15 +6899,104 @@ var ObstetricHistoryWidget = ({ fieldId }) => {
6842
6899
  "button",
6843
6900
  {
6844
6901
  type: "button",
6845
- onClick: () => handlePregStatus(true),
6902
+ onClick: () => handlePregStatus("pregnant"),
6846
6903
  className: cn(
6847
- "flex-1 rounded-md border px-3 py-2 text-xs",
6848
- draft.is_pregnant ? "bg-green-600 text-white border-green-600" : "bg-white"
6904
+ "shrink-0 rounded-full border px-3 py-1.5 text-[11px] font-medium transition-colors",
6905
+ draft.pregnancy_status === "pregnant" ? "border-green-600 bg-green-600 text-white" : "border-slate-300 bg-white text-slate-700 hover:bg-slate-50"
6849
6906
  ),
6850
6907
  children: "Pregnant"
6851
6908
  }
6909
+ ),
6910
+ /* @__PURE__ */ jsxRuntime.jsx(
6911
+ "button",
6912
+ {
6913
+ type: "button",
6914
+ onClick: () => handlePregStatus("unknown"),
6915
+ className: cn(
6916
+ "shrink-0 rounded-full border px-3 py-1.5 text-[11px] font-medium transition-colors",
6917
+ draft.pregnancy_status === "unknown" ? "border-amber-500 bg-amber-500 text-white" : "border-slate-300 bg-white text-slate-700 hover:bg-slate-50"
6918
+ ),
6919
+ children: "Unknown"
6920
+ }
6921
+ )
6922
+ ] })
6923
+ ] })
6924
+ ] }),
6925
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border bg-white p-4", children: [
6926
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs font-medium text-muted-foreground mb-3", children: "Menstrual" }),
6927
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3 sm:grid-cols-4", children: [
6928
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
6929
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: `${fieldId}-menarche`, className: "text-[11px] text-muted-foreground", children: "Menarche (age)" }),
6930
+ /* @__PURE__ */ jsxRuntime.jsx(
6931
+ Input,
6932
+ {
6933
+ id: `${fieldId}-menarche`,
6934
+ type: "number",
6935
+ min: 5,
6936
+ max: 25,
6937
+ value: draft.menstrual.menarche_age,
6938
+ onChange: (e) => setMenstrualPatch({ menarche_age: Number(e.target.value) || 0 })
6939
+ }
6940
+ )
6941
+ ] }),
6942
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
6943
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: `${fieldId}-cycle-length`, className: "text-[11px] text-muted-foreground", children: "Cycle (days)" }),
6944
+ /* @__PURE__ */ jsxRuntime.jsx(
6945
+ Input,
6946
+ {
6947
+ id: `${fieldId}-cycle-length`,
6948
+ type: "number",
6949
+ min: 0,
6950
+ max: 120,
6951
+ value: draft.menstrual.cycle_length,
6952
+ onChange: (e) => setMenstrualPatch({ cycle_length: Number(e.target.value) || 0 })
6953
+ }
6954
+ )
6955
+ ] }),
6956
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
6957
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: `${fieldId}-flow-days`, className: "text-[11px] text-muted-foreground", children: "Flow (days)" }),
6958
+ /* @__PURE__ */ jsxRuntime.jsx(
6959
+ Input,
6960
+ {
6961
+ id: `${fieldId}-flow-days`,
6962
+ type: "number",
6963
+ min: 0,
6964
+ max: 30,
6965
+ value: draft.menstrual.flow_days,
6966
+ onChange: (e) => setMenstrualPatch({ flow_days: Number(e.target.value) || 0 })
6967
+ }
6968
+ )
6969
+ ] }),
6970
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
6971
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-[11px] text-muted-foreground", children: "Dysmenorrhea" }),
6972
+ /* @__PURE__ */ jsxRuntime.jsxs(
6973
+ "select",
6974
+ {
6975
+ className: "h-9 w-full rounded-md border border-input bg-background px-2 text-sm",
6976
+ value: String(draft.menstrual.dysmenorrhea),
6977
+ onChange: (e) => setMenstrualPatch({
6978
+ dysmenorrhea: clampDysmenorrhea(Number(e.target.value))
6979
+ }),
6980
+ children: [
6981
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "0", children: "0 \u2014 none" }),
6982
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "1", children: "1 \u2014 mild" }),
6983
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "2", children: "2 \u2014 moderate" }),
6984
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "3", children: "3 \u2014 severe" })
6985
+ ]
6986
+ }
6852
6987
  )
6853
6988
  ] })
6989
+ ] }),
6990
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "mt-3 flex items-center gap-2 text-sm", children: [
6991
+ /* @__PURE__ */ jsxRuntime.jsx(
6992
+ "input",
6993
+ {
6994
+ type: "checkbox",
6995
+ checked: draft.menstrual.cycle_regular,
6996
+ onChange: (e) => setMenstrualPatch({ cycle_regular: e.target.checked })
6997
+ }
6998
+ ),
6999
+ "Regular cycle"
6854
7000
  ] })
6855
7001
  ] }),
6856
7002
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 rounded-lg border bg-white p-4", children: [
@@ -6868,9 +7014,9 @@ var ObstetricHistoryWidget = ({ fieldId }) => {
6868
7014
  ] })
6869
7015
  ] }),
6870
7016
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border bg-white p-4 min-h-[260px]", children: [
6871
- !draft.is_pregnant && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full flex items-center justify-center text-center text-sm text-muted-foreground px-6 py-10", children: 'Only for "Pregnant Women" and enter LMP to calculate gestational age and EDD' }),
6872
- draft.is_pregnant && !rightPanelEnabled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full flex items-center justify-center text-center text-sm text-muted-foreground px-6 py-10", children: "Enter LMP and/or EDD (USG) to enable gestational age and EDD calculations." }),
6873
- draft.is_pregnant && rightPanelEnabled && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
7017
+ !isPregnant && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full flex items-center justify-center text-center text-sm text-muted-foreground px-6 py-10", children: draft.pregnancy_status === "unknown" ? "Pregnancy status unknown \u2014 confirm with UPT/USG to enable gestational age and EDD." : 'Only for "Pregnant Women" and enter LMP to calculate gestational age and EDD' }),
7018
+ isPregnant && !rightPanelEnabled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full flex items-center justify-center text-center text-sm text-muted-foreground px-6 py-10", children: "Enter LMP and/or EDD (USG) to enable gestational age and EDD calculations." }),
7019
+ isPregnant && rightPanelEnabled && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
6874
7020
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border p-4", children: [
6875
7021
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
6876
7022
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-semibold text-blue-700", children: "Expected Delivery Date (EDD)" }),
@@ -9952,7 +10098,7 @@ var SliderWidget = ({ fieldId }) => {
9952
10098
  const max = def.max ?? 10;
9953
10099
  const step = def.step ?? 1;
9954
10100
  const raw = value == null || value === "" ? min : Number(value);
9955
- const num = Number.isFinite(raw) ? Math.min(max, Math.max(min, raw)) : min;
10101
+ const num2 = Number.isFinite(raw) ? Math.min(max, Math.max(min, raw)) : min;
9956
10102
  const theme = getThemeConfig("textarea", def.theme);
9957
10103
  const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
9958
10104
  const labelClass = theme?.labelClassName;
@@ -9961,7 +10107,7 @@ var SliderWidget = ({ fieldId }) => {
9961
10107
  " ",
9962
10108
  def.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" }),
9963
10109
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-2 text-muted-foreground font-normal tabular-nums", children: [
9964
- num,
10110
+ num2,
9965
10111
  "/",
9966
10112
  max
9967
10113
  ] })
@@ -9977,7 +10123,7 @@ var SliderWidget = ({ fieldId }) => {
9977
10123
  min,
9978
10124
  max,
9979
10125
  step,
9980
- value: [num],
10126
+ value: [num2],
9981
10127
  onValueChange: (v) => {
9982
10128
  const n = v[0] ?? min;
9983
10129
  setValue(n);
@@ -10979,8 +11125,10 @@ var PainScaleFlagsWidget = ({ fieldId }) => {
10979
11125
  const sel = safe.flags;
10980
11126
  const isSelected = isFlagSelected(sel, optValue);
10981
11127
  const nextFlags = isSelected ? sel.filter((v) => v !== optValue && String(v) !== String(optValue)) : [...sel, String(optValue)];
10982
- update({ pain: safe.pain, flags: nextFlags });
11128
+ update({ pain: safe.pain, flags: nextFlags, bp: safe.bp, upt: safe.upt });
10983
11129
  };
11130
+ const setBp = (bp) => update({ pain: safe.pain, flags: safe.flags, bp, upt: safe.upt });
11131
+ const setUpt = (upt) => update({ pain: safe.pain, flags: safe.flags, bp: safe.bp, upt });
10984
11132
  const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10985
11133
  def.label,
10986
11134
  " ",
@@ -11015,7 +11163,7 @@ var PainScaleFlagsWidget = ({ fieldId }) => {
11015
11163
  value: [safe.pain],
11016
11164
  onValueChange: (v) => {
11017
11165
  const n = v[0] ?? min;
11018
- update({ pain: n, flags: safe.flags });
11166
+ update({ pain: n, flags: safe.flags, bp: safe.bp, upt: safe.upt });
11019
11167
  }
11020
11168
  }
11021
11169
  )
@@ -11041,6 +11189,42 @@ var PainScaleFlagsWidget = ({ fieldId }) => {
11041
11189
  }
11042
11190
  )
11043
11191
  ] }, String(opt.value))) })
11192
+ ] }) : null,
11193
+ def.showBp || def.showUpt ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-3 pt-1 sm:grid-cols-2", children: [
11194
+ def.showBp ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
11195
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: `${fieldId}-bp`, className: "text-sm font-medium text-slate-700", children: "BP recorded" }),
11196
+ /* @__PURE__ */ jsxRuntime.jsx(
11197
+ Input,
11198
+ {
11199
+ id: `${fieldId}-bp`,
11200
+ value: safe.bp ?? "",
11201
+ onChange: (e) => setBp(e.target.value),
11202
+ placeholder: "e.g. 130/86",
11203
+ disabled,
11204
+ className: "h-8 text-xs"
11205
+ }
11206
+ )
11207
+ ] }) : null,
11208
+ def.showUpt ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
11209
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium text-slate-700", children: "UPT (if reproductive age)" }),
11210
+ /* @__PURE__ */ jsxRuntime.jsxs(
11211
+ Select,
11212
+ {
11213
+ value: safe.upt ? safe.upt : "none",
11214
+ onValueChange: (val) => setUpt(val === "none" ? "" : val),
11215
+ disabled,
11216
+ children: [
11217
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
11218
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
11219
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
11220
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Positive", children: "Positive" }),
11221
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Negative", children: "Negative" }),
11222
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Not done", children: "Not done" })
11223
+ ] })
11224
+ ]
11225
+ }
11226
+ )
11227
+ ] }) : null
11044
11228
  ] }) : null
11045
11229
  ] }) }),
11046
11230
  showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
@@ -11888,142 +12072,1775 @@ var UrologyPathwayWidget = ({ fieldId }) => {
11888
12072
  ] })
11889
12073
  ] });
11890
12074
  };
11891
- var FieldRenderer = ({ fieldId }) => {
11892
- const { fieldDef, visible } = useField(fieldId);
11893
- if (!visible || !fieldDef) {
11894
- return null;
11895
- }
11896
- return renderWidget(fieldId, fieldDef);
12075
+
12076
+ // src/core/obgPathway.ts
12077
+ var UTERUS_SIZES = ["", "Normal", "Bulky", "Enlarged"];
12078
+ function bool2(x) {
12079
+ return x === true;
12080
+ }
12081
+ function str4(x) {
12082
+ return typeof x === "string" ? x : "";
12083
+ }
12084
+ function defaultObgExamination() {
12085
+ return {
12086
+ general: {
12087
+ pallor: false,
12088
+ oedema: false,
12089
+ thyroid: false,
12090
+ hirsutism: false,
12091
+ acanthosis: false
12092
+ },
12093
+ abdomen: { surgicalScars: false, massTenderness: false },
12094
+ breast: { lump: false, nippleDischarge: false, skinChanges: false, axillaryNodes: false },
12095
+ pelvic: {
12096
+ speculumDone: false,
12097
+ discharge: false,
12098
+ cervicalErosion: false,
12099
+ cervicalGrowth: false,
12100
+ activeBleeding: false,
12101
+ bimanualDone: false,
12102
+ adnexalMass: false,
12103
+ cmt: false
12104
+ },
12105
+ uterusSize: "",
12106
+ examinationNotes: ""
12107
+ };
12108
+ }
12109
+ function normalizeObgExamination(raw) {
12110
+ const base = defaultObgExamination();
12111
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return base;
12112
+ const o = raw;
12113
+ const g = o.general && typeof o.general === "object" ? o.general : {};
12114
+ const a = o.abdomen && typeof o.abdomen === "object" ? o.abdomen : {};
12115
+ const b = o.breast && typeof o.breast === "object" ? o.breast : {};
12116
+ const p = o.pelvic && typeof o.pelvic === "object" ? o.pelvic : {};
12117
+ const us = str4(o.uterusSize);
12118
+ return {
12119
+ general: {
12120
+ pallor: bool2(g.pallor),
12121
+ oedema: bool2(g.oedema),
12122
+ thyroid: bool2(g.thyroid),
12123
+ hirsutism: bool2(g.hirsutism),
12124
+ acanthosis: bool2(g.acanthosis)
12125
+ },
12126
+ abdomen: {
12127
+ surgicalScars: bool2(a.surgicalScars),
12128
+ massTenderness: bool2(a.massTenderness)
12129
+ },
12130
+ breast: {
12131
+ lump: bool2(b.lump),
12132
+ nippleDischarge: bool2(b.nippleDischarge),
12133
+ skinChanges: bool2(b.skinChanges),
12134
+ axillaryNodes: bool2(b.axillaryNodes)
12135
+ },
12136
+ pelvic: {
12137
+ speculumDone: bool2(p.speculumDone),
12138
+ discharge: bool2(p.discharge),
12139
+ cervicalErosion: bool2(p.cervicalErosion),
12140
+ cervicalGrowth: bool2(p.cervicalGrowth),
12141
+ activeBleeding: bool2(p.activeBleeding),
12142
+ bimanualDone: bool2(p.bimanualDone),
12143
+ adnexalMass: bool2(p.adnexalMass),
12144
+ cmt: bool2(p.cmt)
12145
+ },
12146
+ uterusSize: UTERUS_SIZES.includes(us) ? us : "",
12147
+ examinationNotes: str4(o.examinationNotes)
12148
+ };
12149
+ }
12150
+ var GENERAL_LABELS = {
12151
+ pallor: "Pallor",
12152
+ oedema: "Oedema",
12153
+ thyroid: "Thyroid",
12154
+ hirsutism: "Hirsutism",
12155
+ acanthosis: "Acanthosis"
11897
12156
  };
11898
- function renderWidget(fieldId, fieldDef) {
11899
- switch (fieldDef.type) {
11900
- case "text":
11901
- case "number":
11902
- return /* @__PURE__ */ jsxRuntime.jsx(TextWidget, { fieldId });
11903
- case "slider":
11904
- return /* @__PURE__ */ jsxRuntime.jsx(SliderWidget, { fieldId });
11905
- case "textarea":
11906
- if (fieldMetaRequestsMarMedicationOrdersButton(fieldDef.meta)) {
11907
- return /* @__PURE__ */ jsxRuntime.jsx(MarMedicationOrdersWidget, { fieldId });
11908
- }
11909
- return /* @__PURE__ */ jsxRuntime.jsx(TextWidget, { fieldId });
11910
- case "richtext":
11911
- return /* @__PURE__ */ jsxRuntime.jsx(RichTextWidget, { fieldId });
11912
- case "date":
11913
- return /* @__PURE__ */ jsxRuntime.jsx(DateWidget, { fieldId });
11914
- case "datetime":
11915
- return /* @__PURE__ */ jsxRuntime.jsx(DateTimeWidget, { fieldId });
11916
- case "select":
11917
- return /* @__PURE__ */ jsxRuntime.jsx(SelectWidget, { fieldId });
11918
- case "radio":
11919
- return /* @__PURE__ */ jsxRuntime.jsx(RadioWidget, { fieldId });
11920
- case "checkbox":
11921
- return /* @__PURE__ */ jsxRuntime.jsx(CheckboxWidget, { fieldId });
11922
- case "multiselect":
11923
- return /* @__PURE__ */ jsxRuntime.jsx(MultiSelectWidget, { fieldId });
11924
- case "repeatable":
11925
- return /* @__PURE__ */ jsxRuntime.jsx(RepeatableWidget, { fieldId });
11926
- case "image_upload":
11927
- return /* @__PURE__ */ jsxRuntime.jsx(ImageUploadWidget, { fieldId });
11928
- case "media_upload":
11929
- return /* @__PURE__ */ jsxRuntime.jsx(MediaUploadWidget, { fieldId });
11930
- case "signature":
11931
- return /* @__PURE__ */ jsxRuntime.jsx(SignatureUploadWidget, { fieldId });
11932
- case "editable_table":
11933
- return /* @__PURE__ */ jsxRuntime.jsx(EditableTableWidget, { fieldId });
11934
- case "medications":
11935
- return /* @__PURE__ */ jsxRuntime.jsx(AddMedicationWidget, { fieldId });
11936
- case "discharge_medication_orders":
11937
- return /* @__PURE__ */ jsxRuntime.jsx(DischargeMedicationOrdersWidget, { fieldId });
11938
- case "investigations":
11939
- return /* @__PURE__ */ jsxRuntime.jsx(AddInvestigationWidget, { fieldId });
11940
- case "procedures":
11941
- return /* @__PURE__ */ jsxRuntime.jsx(AddProcedureWidget, { fieldId });
11942
- case "differential_diagnosis":
11943
- return /* @__PURE__ */ jsxRuntime.jsx(DifferentialDiagnosisWidget, { fieldId });
11944
- case "vitals":
11945
- return /* @__PURE__ */ jsxRuntime.jsx(VitalsWidget, { fieldId });
11946
- case "hidden_vitals":
11947
- return /* @__PURE__ */ jsxRuntime.jsx(HiddenVitalsWidget, { fieldId });
11948
- case "referral":
11949
- return /* @__PURE__ */ jsxRuntime.jsx(ReferralWidget, { fieldId });
11950
- case "followup":
11951
- return /* @__PURE__ */ jsxRuntime.jsx(FollowupWidget, { fieldId });
11952
- case "smart_textarea":
11953
- return /* @__PURE__ */ jsxRuntime.jsx(SmartTextareaWidget, { fieldId });
11954
- case "diagnosis_textarea":
11955
- return /* @__PURE__ */ jsxRuntime.jsx(DiagnosisTextareaWidget, { fieldId });
11956
- case "obstetric_history":
11957
- return /* @__PURE__ */ jsxRuntime.jsx(ObstetricHistoryWidget, { fieldId });
11958
- case "eye_prescription":
11959
- return /* @__PURE__ */ jsxRuntime.jsx(OphthalmologyWidget, { fieldId });
11960
- case "ophthal_diagnosis":
11961
- return /* @__PURE__ */ jsxRuntime.jsx(OphthalDiagnosisWidget, { fieldId });
11962
- case "orthopedic_exam":
11963
- return /* @__PURE__ */ jsxRuntime.jsx(OrthopedicExamWidget, { fieldId });
11964
- case "general_surgery_smart_history":
11965
- return /* @__PURE__ */ jsxRuntime.jsx(GsSmartHistoryWidget, { fieldId });
11966
- case "general_surgery_examination":
11967
- return /* @__PURE__ */ jsxRuntime.jsx(GsExaminationWidget, { fieldId });
11968
- case "general_surgery_grading":
11969
- return /* @__PURE__ */ jsxRuntime.jsx(GsGradingWidget, { fieldId });
11970
- case "pain_scale_flags":
11971
- return /* @__PURE__ */ jsxRuntime.jsx(PainScaleFlagsWidget, { fieldId });
11972
- case "urology_smart_history":
11973
- return /* @__PURE__ */ jsxRuntime.jsx(UrologySmartHistoryWidget, { fieldId });
11974
- case "urology_examination":
11975
- return /* @__PURE__ */ jsxRuntime.jsx(UrologyExaminationWidget, { fieldId });
11976
- case "urology_pathway":
11977
- return /* @__PURE__ */ jsxRuntime.jsx(UrologyPathwayWidget, { fieldId });
11978
- case "toggle": {
11979
- const { value, setValue, setTouched, disabled } = useField(fieldId);
11980
- const store = useFormStore();
11981
- const excludes = fieldDef.excludes ?? [];
11982
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
11983
- /* @__PURE__ */ jsxRuntime.jsx(
11984
- Switch,
11985
- {
11986
- checked: value === true,
11987
- disabled,
11988
- onCheckedChange: (checked) => {
11989
- setValue(checked);
11990
- setTouched();
11991
- if (checked) excludes.forEach((id) => store.setValue(id, false));
11992
- }
11993
- }
11994
- ),
11995
- /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium leading-none cursor-pointer select-none", children: fieldDef.label })
11996
- ] });
12157
+ var ABDOMEN_LABELS = {
12158
+ surgicalScars: "Surgical scars",
12159
+ massTenderness: "Mass / tenderness"
12160
+ };
12161
+ var BREAST_LABELS = {
12162
+ lump: "Lump",
12163
+ nippleDischarge: "Nipple discharge",
12164
+ skinChanges: "Skin changes",
12165
+ axillaryNodes: "Axillary nodes"
12166
+ };
12167
+ var PELVIC_LABELS = {
12168
+ speculumDone: "Speculum done",
12169
+ discharge: "Discharge",
12170
+ cervicalErosion: "Cervical erosion",
12171
+ cervicalGrowth: "Cervical growth",
12172
+ activeBleeding: "Active bleeding",
12173
+ bimanualDone: "Bimanual done",
12174
+ adnexalMass: "Adnexal mass",
12175
+ cmt: "Cervical motion tenderness"
12176
+ };
12177
+ function pickLabels(group, labels) {
12178
+ return Object.keys(labels).filter((k) => group[k]).map((k) => labels[k]);
12179
+ }
12180
+ function formatObgExaminationToClinicalExamination(v) {
12181
+ const lines = [];
12182
+ const general = pickLabels(v.general, GENERAL_LABELS);
12183
+ if (general.length) lines.push(`General: ${general.join(", ")}`);
12184
+ const abd = pickLabels(v.abdomen, ABDOMEN_LABELS);
12185
+ if (abd.length) lines.push(`Abdomen: ${abd.join(", ")}`);
12186
+ const breast = pickLabels(v.breast, BREAST_LABELS);
12187
+ if (breast.length) lines.push(`Breast: ${breast.join(", ")}`);
12188
+ const pelvic = pickLabels(v.pelvic, PELVIC_LABELS);
12189
+ let pelvicLine = pelvic.length ? `Pelvic: ${pelvic.join(", ")}` : "";
12190
+ if (v.pelvic.bimanualDone && v.uterusSize) {
12191
+ pelvicLine = pelvicLine ? `${pelvicLine} \u2014 uterus ${v.uterusSize.toLowerCase()}` : `Pelvic: uterus ${v.uterusSize.toLowerCase()}`;
12192
+ }
12193
+ if (pelvicLine) lines.push(pelvicLine);
12194
+ return lines.join("\n");
12195
+ }
12196
+ var OBG_ZONE_ORDER = [
12197
+ "menstrual_reproductive",
12198
+ "antenatal",
12199
+ "gynaecological",
12200
+ "obstetric",
12201
+ "infertility",
12202
+ "postoperative"
12203
+ ];
12204
+ var OBG_ZONE_SET = new Set(OBG_ZONE_ORDER);
12205
+ function coerceZones(raw) {
12206
+ const list = [];
12207
+ const push = (x) => {
12208
+ if (typeof x === "string" && OBG_ZONE_SET.has(x) && !list.includes(x)) {
12209
+ list.push(x);
11997
12210
  }
11998
- case "suggestion_textarea":
11999
- case "complaint_chips":
12000
- return /* @__PURE__ */ jsxRuntime.jsx(SuggestionTextareaWidget, { fieldId });
12001
- case "lens_assessment":
12002
- return /* @__PURE__ */ jsxRuntime.jsx(LensAssessmentWidget, { fieldId });
12003
- case "functional_impairment_score":
12004
- return /* @__PURE__ */ jsxRuntime.jsx(FunctionalImpairmentScoreWidget, { fieldId });
12005
- case "biometry_iol_workup":
12006
- return /* @__PURE__ */ jsxRuntime.jsx(BiometryIolWorkupWidget, { fieldId });
12007
- case "surgical_risk_flags":
12008
- return /* @__PURE__ */ jsxRuntime.jsx(SurgicalRiskFlagsWidget, { fieldId });
12009
- case "static_text": {
12010
- const def = fieldDef;
12011
- const size = def.size ?? "regular";
12012
- const labelClass = size === "large" ? "text-base" : "text-sm";
12013
- const descClass = size === "large" ? "text-sm" : "text-xs";
12014
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${labelClass} text-muted-foreground`, children: [
12015
- def.label,
12016
- def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: `mt-1 ${descClass} opacity-90`, children: def.description })
12017
- ] });
12211
+ };
12212
+ if (Array.isArray(raw)) raw.forEach(push);
12213
+ else push(raw);
12214
+ return list.sort((a, b) => OBG_ZONE_ORDER.indexOf(a) - OBG_ZONE_ORDER.indexOf(b));
12215
+ }
12216
+ function num(x, fallback = 0) {
12217
+ const n = Number(x);
12218
+ return Number.isFinite(n) ? n : fallback;
12219
+ }
12220
+ function clampDysmenorrhea2(x) {
12221
+ const n = Math.round(num(x, 0));
12222
+ if (n <= 0) return 0;
12223
+ if (n >= 3) return 3;
12224
+ return n;
12225
+ }
12226
+ function defaultObgPathway() {
12227
+ return {
12228
+ zones: [],
12229
+ menstrual: {
12230
+ menarcheAge: 13,
12231
+ cycleLength: 28,
12232
+ flowDays: 4,
12233
+ cycleRegular: true,
12234
+ dysmenorrhea: 0,
12235
+ amount: "",
12236
+ lmp: "",
12237
+ menopauseStatus: ""
12238
+ },
12239
+ antenatal: {
12240
+ gravida: 0,
12241
+ gaWeeksLmp: 0,
12242
+ gaDaysLmp: 0,
12243
+ gaWeeksUsg: 0,
12244
+ gaDaysUsg: 0,
12245
+ edd: "",
12246
+ riskCategory: "",
12247
+ symptoms: {
12248
+ nauseaVomiting: false,
12249
+ bleedingPV: false,
12250
+ painAbdomen: false,
12251
+ decreasedFetalMovements: false
12252
+ },
12253
+ exam: {
12254
+ weightKg: 0,
12255
+ heightCm: 0,
12256
+ bmi: 0,
12257
+ bp: "",
12258
+ pallor: false,
12259
+ oedema: false,
12260
+ fundalHeightCm: 0,
12261
+ fhrBpm: 0,
12262
+ presentation: "",
12263
+ lie: ""
12264
+ },
12265
+ investigations: {
12266
+ bloodGroup: "",
12267
+ cbc: "",
12268
+ tsh: "",
12269
+ rbsOgtt: "",
12270
+ serology: "",
12271
+ urine: "",
12272
+ usg: ""
12273
+ }
12274
+ },
12275
+ gynae: {
12276
+ symptoms: {
12277
+ aub: false,
12278
+ whiteDischarge: false,
12279
+ pelvicPain: false,
12280
+ dyspareunia: false,
12281
+ urinaryComplaints: false,
12282
+ prolapse: false
12283
+ }
12284
+ },
12285
+ obstetric: [],
12286
+ infertility: {
12287
+ type: "",
12288
+ durationMonths: 0,
12289
+ previousTreatments: "",
12290
+ female: { ovulation: "", pcosFeatures: false, endometriosisSuspicion: false },
12291
+ male: { age: 0, semenAnalysis: "" },
12292
+ investigations: { amh: "", fshLh: "", prolactin: "", tsh: "", tvs: "", hsg: "" }
12293
+ },
12294
+ postop: {
12295
+ surgeryDate: "",
12296
+ procedure: "",
12297
+ histopathology: "",
12298
+ woundStatus: "",
12299
+ painScore: 0,
12300
+ complications: ""
12018
12301
  }
12019
- default:
12020
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-red-500", children: [
12021
- "Unknown field type: ",
12022
- fieldDef.type
12023
- ] });
12024
- }
12302
+ };
12025
12303
  }
12026
- var Section = ({ title, children }) => {
12304
+ function normalizeObgPathway(raw) {
12305
+ const base = defaultObgPathway();
12306
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return base;
12307
+ const o = raw;
12308
+ const zones = coerceZones(o.zones ?? o.zone);
12309
+ const m = o.menstrual && typeof o.menstrual === "object" ? o.menstrual : {};
12310
+ const a = o.antenatal && typeof o.antenatal === "object" ? o.antenatal : {};
12311
+ const aSym = a.symptoms && typeof a.symptoms === "object" ? a.symptoms : {};
12312
+ const aExam = a.exam && typeof a.exam === "object" ? a.exam : {};
12313
+ const aInv = a.investigations && typeof a.investigations === "object" ? a.investigations : {};
12314
+ const g = o.gynae && typeof o.gynae === "object" ? o.gynae : {};
12315
+ const gSym = g.symptoms && typeof g.symptoms === "object" ? g.symptoms : {};
12316
+ const inf = o.infertility && typeof o.infertility === "object" ? o.infertility : {};
12317
+ const infF = inf.female && typeof inf.female === "object" ? inf.female : {};
12318
+ const infM = inf.male && typeof inf.male === "object" ? inf.male : {};
12319
+ const infInv = inf.investigations && typeof inf.investigations === "object" ? inf.investigations : {};
12320
+ const po = o.postop && typeof o.postop === "object" ? o.postop : {};
12321
+ const obstetricRows = Array.isArray(o.obstetric) ? o.obstetric.map((row) => {
12322
+ const r = row && typeof row === "object" ? row : {};
12323
+ const mode = str4(r.mode);
12324
+ return {
12325
+ year: str4(r.year),
12326
+ ga: str4(r.ga),
12327
+ mode: ["", "NVD", "LSCS", "Instrumental", "Abortion", "Stillbirth"].includes(mode) ? mode : "",
12328
+ indicationLscs: str4(r.indicationLscs),
12329
+ babyOutcome: str4(r.babyOutcome),
12330
+ complications: str4(r.complications)
12331
+ };
12332
+ }) : [];
12333
+ return {
12334
+ zones,
12335
+ menstrual: {
12336
+ menarcheAge: num(m.menarcheAge, base.menstrual.menarcheAge),
12337
+ cycleLength: num(m.cycleLength, base.menstrual.cycleLength),
12338
+ flowDays: num(m.flowDays, base.menstrual.flowDays),
12339
+ cycleRegular: m.cycleRegular === void 0 ? base.menstrual.cycleRegular : bool2(m.cycleRegular),
12340
+ dysmenorrhea: clampDysmenorrhea2(m.dysmenorrhea),
12341
+ amount: ["", "Scanty", "Normal", "Heavy"].includes(str4(m.amount)) ? str4(m.amount) : "",
12342
+ lmp: str4(m.lmp),
12343
+ menopauseStatus: ["", "Pre", "Peri", "Post"].includes(str4(m.menopauseStatus)) ? str4(m.menopauseStatus) : ""
12344
+ },
12345
+ antenatal: {
12346
+ gravida: num(a.gravida),
12347
+ gaWeeksLmp: num(a.gaWeeksLmp),
12348
+ gaDaysLmp: num(a.gaDaysLmp),
12349
+ gaWeeksUsg: num(a.gaWeeksUsg),
12350
+ gaDaysUsg: num(a.gaDaysUsg),
12351
+ edd: str4(a.edd),
12352
+ riskCategory: ["", "Low", "High"].includes(str4(a.riskCategory)) ? str4(a.riskCategory) : "",
12353
+ symptoms: {
12354
+ nauseaVomiting: bool2(aSym.nauseaVomiting),
12355
+ bleedingPV: bool2(aSym.bleedingPV),
12356
+ painAbdomen: bool2(aSym.painAbdomen),
12357
+ decreasedFetalMovements: bool2(aSym.decreasedFetalMovements)
12358
+ },
12359
+ exam: {
12360
+ weightKg: num(aExam.weightKg),
12361
+ heightCm: num(aExam.heightCm),
12362
+ bmi: num(aExam.bmi),
12363
+ bp: str4(aExam.bp),
12364
+ pallor: bool2(aExam.pallor),
12365
+ oedema: bool2(aExam.oedema),
12366
+ fundalHeightCm: num(aExam.fundalHeightCm),
12367
+ fhrBpm: num(aExam.fhrBpm),
12368
+ presentation: ["", "Cephalic", "Breech", "Other"].includes(str4(aExam.presentation)) ? str4(aExam.presentation) : "",
12369
+ lie: ["", "Longitudinal", "Transverse", "Oblique"].includes(str4(aExam.lie)) ? str4(aExam.lie) : ""
12370
+ },
12371
+ investigations: {
12372
+ bloodGroup: str4(aInv.bloodGroup),
12373
+ cbc: ["", "Done", "Pending", "Abnormal"].includes(str4(aInv.cbc)) ? str4(aInv.cbc) : "",
12374
+ tsh: ["", "Done", "Pending", "Abnormal"].includes(str4(aInv.tsh)) ? str4(aInv.tsh) : "",
12375
+ rbsOgtt: ["", "Done", "Pending", "Abnormal"].includes(str4(aInv.rbsOgtt)) ? str4(aInv.rbsOgtt) : "",
12376
+ serology: ["", "Done", "Pending", "Abnormal"].includes(str4(aInv.serology)) ? str4(aInv.serology) : "",
12377
+ urine: ["", "Done", "Pending", "Abnormal"].includes(str4(aInv.urine)) ? str4(aInv.urine) : "",
12378
+ usg: ["", "Dating", "NT", "Anomaly", "Growth", "Pending"].includes(str4(aInv.usg)) ? str4(aInv.usg) : ""
12379
+ }
12380
+ },
12381
+ gynae: {
12382
+ symptoms: {
12383
+ aub: bool2(gSym.aub),
12384
+ whiteDischarge: bool2(gSym.whiteDischarge),
12385
+ pelvicPain: bool2(gSym.pelvicPain),
12386
+ dyspareunia: bool2(gSym.dyspareunia),
12387
+ urinaryComplaints: bool2(gSym.urinaryComplaints),
12388
+ prolapse: bool2(gSym.prolapse)
12389
+ }
12390
+ },
12391
+ obstetric: obstetricRows,
12392
+ infertility: {
12393
+ type: ["", "Primary", "Secondary"].includes(str4(inf.type)) ? str4(inf.type) : "",
12394
+ durationMonths: num(inf.durationMonths),
12395
+ previousTreatments: str4(inf.previousTreatments),
12396
+ female: {
12397
+ ovulation: ["", "Ovulatory", "Anovulatory", "Unknown"].includes(str4(infF.ovulation)) ? str4(infF.ovulation) : "",
12398
+ pcosFeatures: bool2(infF.pcosFeatures),
12399
+ endometriosisSuspicion: bool2(infF.endometriosisSuspicion)
12400
+ },
12401
+ male: {
12402
+ age: num(infM.age),
12403
+ semenAnalysis: ["", "Normal", "Abnormal", "Pending"].includes(str4(infM.semenAnalysis)) ? str4(infM.semenAnalysis) : ""
12404
+ },
12405
+ investigations: {
12406
+ amh: str4(infInv.amh),
12407
+ fshLh: str4(infInv.fshLh),
12408
+ prolactin: str4(infInv.prolactin),
12409
+ tsh: str4(infInv.tsh),
12410
+ tvs: str4(infInv.tvs),
12411
+ hsg: str4(infInv.hsg)
12412
+ }
12413
+ },
12414
+ postop: {
12415
+ surgeryDate: str4(po.surgeryDate),
12416
+ procedure: str4(po.procedure),
12417
+ histopathology: str4(po.histopathology),
12418
+ woundStatus: ["", "Healthy", "Erythema", "Discharge", "Dehisced"].includes(str4(po.woundStatus)) ? str4(po.woundStatus) : "",
12419
+ painScore: Math.max(0, Math.min(10, num(po.painScore))),
12420
+ complications: str4(po.complications)
12421
+ }
12422
+ };
12423
+ }
12424
+ var ZONE_LABELS = {
12425
+ menstrual_reproductive: "Menstrual & reproductive",
12426
+ antenatal: "Antenatal",
12427
+ gynaecological: "Gynaecological",
12428
+ obstetric: "Obstetric",
12429
+ infertility: "Infertility",
12430
+ postoperative: "Post-operative"
12431
+ };
12432
+ function obgZoneLabel(zone) {
12433
+ return ZONE_LABELS[zone];
12434
+ }
12435
+ function nonEmpty(parts) {
12436
+ return parts.map((s) => (s ?? "").trim()).filter(Boolean);
12437
+ }
12438
+ function formatMenstrualBlock(m) {
12439
+ const bits = nonEmpty([
12440
+ m.menarcheAge ? `menarche ${m.menarcheAge}y` : "",
12441
+ m.cycleLength ? `cycle ${m.cycleLength}d` : "",
12442
+ m.flowDays ? `flow ${m.flowDays}d` : "",
12443
+ m.cycleRegular ? "regular" : "irregular",
12444
+ m.amount ? `flow ${m.amount.toLowerCase()}` : "",
12445
+ m.dysmenorrhea ? `dysmenorrhea grade ${m.dysmenorrhea}` : "",
12446
+ m.lmp ? `LMP ${m.lmp}` : "",
12447
+ m.menopauseStatus ? `${m.menopauseStatus.toLowerCase()}menopausal` : ""
12448
+ ]);
12449
+ return bits.length ? `Menstrual: ${bits.join(", ")}` : "";
12450
+ }
12451
+ function formatAntenatalBlock(a) {
12452
+ const lines = [];
12453
+ const head = nonEmpty([
12454
+ a.gravida ? `G${a.gravida}` : "",
12455
+ a.gaWeeksLmp || a.gaDaysLmp ? `GA(LMP) ${a.gaWeeksLmp}w ${a.gaDaysLmp}d` : "",
12456
+ a.gaWeeksUsg || a.gaDaysUsg ? `GA(USG) ${a.gaWeeksUsg}w ${a.gaDaysUsg}d` : "",
12457
+ a.edd ? `EDD ${a.edd}` : "",
12458
+ a.riskCategory ? `${a.riskCategory} risk` : ""
12459
+ ]);
12460
+ if (head.length) lines.push(`Antenatal: ${head.join(", ")}`);
12461
+ const sym = nonEmpty([
12462
+ a.symptoms.nauseaVomiting ? "nausea/vomiting" : "",
12463
+ a.symptoms.bleedingPV ? "bleeding PV" : "",
12464
+ a.symptoms.painAbdomen ? "pain abdomen" : "",
12465
+ a.symptoms.decreasedFetalMovements ? "decreased fetal movements" : ""
12466
+ ]);
12467
+ if (sym.length) lines.push(`Antenatal symptoms: ${sym.join(", ")}`);
12468
+ return lines.join("\n");
12469
+ }
12470
+ function formatGynaeBlock(g) {
12471
+ const sym = nonEmpty([
12472
+ g.symptoms.aub ? "AUB" : "",
12473
+ g.symptoms.whiteDischarge ? "white discharge" : "",
12474
+ g.symptoms.pelvicPain ? "pelvic pain" : "",
12475
+ g.symptoms.dyspareunia ? "dyspareunia" : "",
12476
+ g.symptoms.urinaryComplaints ? "urinary complaints" : "",
12477
+ g.symptoms.prolapse ? "prolapse" : ""
12478
+ ]);
12479
+ return sym.length ? `Gynae symptoms: ${sym.join(", ")}` : "";
12480
+ }
12481
+ function formatObstetricBlock(rows) {
12482
+ if (!rows.length) return "";
12483
+ const summary = rows.map((r) => nonEmpty([r.year, r.ga, r.mode, r.babyOutcome]).join(" / ")).filter(Boolean).join("; ");
12484
+ return summary ? `Obstetric history (${rows.length}): ${summary}` : "";
12485
+ }
12486
+ function formatInfertilityBlock(i) {
12487
+ const bits = nonEmpty([
12488
+ i.type ? `${i.type} infertility` : "",
12489
+ i.durationMonths ? `${i.durationMonths} months` : "",
12490
+ i.female.pcosFeatures ? "PCOS features" : "",
12491
+ i.female.endometriosisSuspicion ? "endometriosis suspicion" : "",
12492
+ i.female.ovulation ? `ovulation: ${i.female.ovulation}` : "",
12493
+ i.male.semenAnalysis ? `semen: ${i.male.semenAnalysis}` : ""
12494
+ ]);
12495
+ return bits.length ? `Infertility: ${bits.join(", ")}` : "";
12496
+ }
12497
+ function formatPostOpBlock(p) {
12498
+ const bits = nonEmpty([
12499
+ p.surgeryDate ? `op ${p.surgeryDate}` : "",
12500
+ p.procedure || "",
12501
+ p.woundStatus ? `wound ${p.woundStatus.toLowerCase()}` : "",
12502
+ p.painScore ? `pain ${p.painScore}/10` : "",
12503
+ p.complications ? `complications: ${p.complications}` : ""
12504
+ ]);
12505
+ return bits.length ? `Post-op: ${bits.join(", ")}` : "";
12506
+ }
12507
+ var ZONE_FORMATTERS = {
12508
+ menstrual_reproductive: (v) => formatMenstrualBlock(v.menstrual),
12509
+ antenatal: (v) => formatAntenatalBlock(v.antenatal),
12510
+ gynaecological: (v) => formatGynaeBlock(v.gynae),
12511
+ obstetric: (v) => formatObstetricBlock(v.obstetric),
12512
+ infertility: (v) => formatInfertilityBlock(v.infertility),
12513
+ postoperative: (v) => formatPostOpBlock(v.postop)
12514
+ };
12515
+ function formatObgPathwayToSymptomsNarrative(v) {
12516
+ if (!v.zones.length) return "";
12517
+ const sections = [`Pathway: ${v.zones.map(obgZoneLabel).join(", ")}`];
12518
+ for (const z of v.zones) {
12519
+ const block = ZONE_FORMATTERS[z](v).trim();
12520
+ if (block) sections.push(block);
12521
+ }
12522
+ return sections.join("\n\n");
12523
+ }
12524
+ var CLINICAL_EXAMINATION_FIELD = "clinical_examination";
12525
+ var GENERAL_ROWS2 = [
12526
+ { key: "pallor", label: "Pallor" },
12527
+ { key: "oedema", label: "Oedema" },
12528
+ { key: "thyroid", label: "Thyroid" },
12529
+ { key: "hirsutism", label: "Hirsutism" },
12530
+ { key: "acanthosis", label: "Acanthosis" }
12531
+ ];
12532
+ var ABDOMEN_ROWS = [
12533
+ { key: "surgicalScars", label: "Surgical scars" },
12534
+ { key: "massTenderness", label: "Mass / tenderness" }
12535
+ ];
12536
+ var BREAST_ROWS = [
12537
+ { key: "lump", label: "Lump" },
12538
+ { key: "nippleDischarge", label: "Nipple discharge" },
12539
+ { key: "skinChanges", label: "Skin changes" },
12540
+ { key: "axillaryNodes", label: "Axillary nodes" }
12541
+ ];
12542
+ var PELVIC_ROWS = [
12543
+ { key: "speculumDone", label: "Speculum done" },
12544
+ { key: "discharge", label: "Discharge" },
12545
+ { key: "cervicalErosion", label: "Cervical erosion" },
12546
+ { key: "cervicalGrowth", label: "Cervical growth" },
12547
+ { key: "activeBleeding", label: "Active bleeding" },
12548
+ { key: "bimanualDone", label: "Bimanual done" },
12549
+ { key: "adnexalMass", label: "Adnexal mass" },
12550
+ { key: "cmt", label: "Cervical motion tenderness" }
12551
+ ];
12552
+ var UTERUS_OPTIONS = [
12553
+ { value: "", label: "\u2014" },
12554
+ { value: "Normal", label: "Normal" },
12555
+ { value: "Bulky", label: "Bulky" },
12556
+ { value: "Enlarged", label: "Enlarged" }
12557
+ ];
12558
+ var OBGExaminationWidget = ({ fieldId }) => {
12559
+ const { fieldDef, value, setValue, setTouched, error, touched, disabled } = useField(fieldId);
12560
+ const clinicalField = useField(CLINICAL_EXAMINATION_FIELD);
12561
+ const { state } = useForm();
12562
+ const showError = !!error && (touched || state.submitAttempted);
12563
+ const safe = React15.useMemo(() => normalizeObgExamination(value), [value]);
12564
+ React15.useEffect(() => {
12565
+ if (disabled) return;
12566
+ const norm = normalizeObgExamination(value);
12567
+ const next = formatObgExaminationToClinicalExamination(norm);
12568
+ clinicalField.setValue(next);
12569
+ if (norm.examinationNotes !== next) {
12570
+ setValue({ ...norm, examinationNotes: next });
12571
+ }
12572
+ }, [value, disabled]);
12573
+ const bump = (next) => {
12574
+ setValue(next);
12575
+ setTouched();
12576
+ };
12577
+ const toggleGeneral = (key) => bump({ ...safe, general: { ...safe.general, [key]: !safe.general[key] } });
12578
+ const toggleAbdomen = (key) => bump({ ...safe, abdomen: { ...safe.abdomen, [key]: !safe.abdomen[key] } });
12579
+ const toggleBreast = (key) => bump({ ...safe, breast: { ...safe.breast, [key]: !safe.breast[key] } });
12580
+ const togglePelvic = (key) => {
12581
+ const nextPelvic = { ...safe.pelvic, [key]: !safe.pelvic[key] };
12582
+ const nextUterus = !nextPelvic.bimanualDone ? "" : safe.uterusSize;
12583
+ bump({ ...safe, pelvic: nextPelvic, uterusSize: nextUterus });
12584
+ };
12585
+ const setUterusSize = (val) => bump({ ...safe, uterusSize: val });
12586
+ if (!fieldDef) return null;
12587
+ const theme = getThemeConfig("textarea", fieldDef.theme);
12588
+ const wrapperClass = theme?.wrapperClassName ?? "rounded-md overflow-hidden flex flex-col border border-[#D0D0D0]";
12589
+ const labelClass = theme?.labelClassName;
12590
+ const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12591
+ fieldDef.label,
12592
+ fieldDef.required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
12593
+ ] });
12594
+ const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: labelContent });
12595
+ const bodyClass = cn(
12596
+ "-mt-1 flex min-w-0 flex-col gap-3 border-t border-[#D0D0D0] bg-white px-3 py-3",
12597
+ disabled && "pointer-events-none opacity-60"
12598
+ );
12599
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("w-full min-w-0", wrapperClass), children: [
12600
+ labelEl,
12601
+ fieldDef.description ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-3 pt-2 text-[11px] text-muted-foreground", children: fieldDef.description }) : null,
12602
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: bodyClass, children: [
12603
+ showError ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-600", children: error }) : null,
12604
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-3 text-xs md:grid-cols-2 xl:grid-cols-4", children: [
12605
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
12606
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold text-slate-800", children: "General" }),
12607
+ GENERAL_ROWS2.map((r) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
12608
+ /* @__PURE__ */ jsxRuntime.jsx(
12609
+ Checkbox,
12610
+ {
12611
+ checked: safe.general[r.key],
12612
+ onCheckedChange: () => toggleGeneral(r.key),
12613
+ disabled
12614
+ }
12615
+ ),
12616
+ r.label
12617
+ ] }, r.key))
12618
+ ] }),
12619
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
12620
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold text-slate-800", children: "Abdomen" }),
12621
+ ABDOMEN_ROWS.map((r) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
12622
+ /* @__PURE__ */ jsxRuntime.jsx(
12623
+ Checkbox,
12624
+ {
12625
+ checked: safe.abdomen[r.key],
12626
+ onCheckedChange: () => toggleAbdomen(r.key),
12627
+ disabled
12628
+ }
12629
+ ),
12630
+ r.label
12631
+ ] }, r.key)),
12632
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[10px] text-muted-foreground", children: "Pregnancy \u2192 fundal ht / FHR / lie captured in Antenatal pathway." })
12633
+ ] }),
12634
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
12635
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold text-slate-800", children: "Breast" }),
12636
+ BREAST_ROWS.map((r) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
12637
+ /* @__PURE__ */ jsxRuntime.jsx(
12638
+ Checkbox,
12639
+ {
12640
+ checked: safe.breast[r.key],
12641
+ onCheckedChange: () => toggleBreast(r.key),
12642
+ disabled
12643
+ }
12644
+ ),
12645
+ r.label
12646
+ ] }, r.key))
12647
+ ] }),
12648
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
12649
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold text-slate-800", children: "Pelvic (consent applied)" }),
12650
+ PELVIC_ROWS.map((r) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
12651
+ /* @__PURE__ */ jsxRuntime.jsx(
12652
+ Checkbox,
12653
+ {
12654
+ checked: safe.pelvic[r.key],
12655
+ onCheckedChange: () => togglePelvic(r.key),
12656
+ disabled
12657
+ }
12658
+ ),
12659
+ r.label
12660
+ ] }, r.key)),
12661
+ safe.pelvic.bimanualDone ? /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "block pt-1", children: [
12662
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mb-1 block font-medium", children: "Uterus size (on bimanual)" }),
12663
+ /* @__PURE__ */ jsxRuntime.jsxs(
12664
+ Select,
12665
+ {
12666
+ value: safe.uterusSize === "" ? "none" : safe.uterusSize,
12667
+ onValueChange: (v) => setUterusSize(v === "none" ? "" : v),
12668
+ disabled,
12669
+ children: [
12670
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
12671
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: UTERUS_OPTIONS.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: opt.value === "" ? "none" : opt.value, children: opt.label }, opt.value || "none")) })
12672
+ ]
12673
+ }
12674
+ )
12675
+ ] }) : null
12676
+ ] })
12677
+ ] }),
12678
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 border-t border-[#D0D0D0] pt-3", children: [
12679
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: "Clinical examination" }),
12680
+ /* @__PURE__ */ jsxRuntime.jsx(
12681
+ Textarea,
12682
+ {
12683
+ value: formatObgExaminationToClinicalExamination(safe),
12684
+ readOnly: true,
12685
+ disabled,
12686
+ className: "min-h-[80px] text-xs",
12687
+ placeholder: "Derived from examination selections above."
12688
+ }
12689
+ )
12690
+ ] })
12691
+ ] })
12692
+ ] });
12693
+ };
12694
+ var SYMPTOMS_FIELD2 = "symptoms";
12695
+ function Panel3({
12696
+ title,
12697
+ right,
12698
+ children
12699
+ }) {
12700
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "overflow-hidden rounded-md border border-[#D0D0D0] bg-white", children: [
12701
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between border-b border-[#D0D0D0] bg-[#FEE8EC]/50 px-3 py-1.5", children: [
12702
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-semibold text-slate-700", children: title }),
12703
+ right
12704
+ ] }),
12705
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-3 text-xs", children })
12706
+ ] });
12707
+ }
12708
+ function ChipRow({
12709
+ options,
12710
+ selected,
12711
+ onToggle,
12712
+ disabled
12713
+ }) {
12714
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2", children: options.map((o) => {
12715
+ const on = !!selected[o.key];
12716
+ return /* @__PURE__ */ jsxRuntime.jsx(
12717
+ "button",
12718
+ {
12719
+ type: "button",
12720
+ onClick: () => onToggle(o.key),
12721
+ disabled,
12722
+ className: cn(
12723
+ "rounded-full border px-3 py-1 text-[11px] transition-colors",
12724
+ on ? "border-rose-500 bg-rose-50 text-rose-700" : "border-slate-300 bg-white text-slate-600 hover:bg-slate-50"
12725
+ ),
12726
+ children: o.label
12727
+ },
12728
+ o.key
12729
+ );
12730
+ }) });
12731
+ }
12732
+ var OBGPathwayWidget = ({ fieldId }) => {
12733
+ const { fieldDef, value, setValue, setTouched, error, touched, disabled } = useField(fieldId);
12734
+ const symptomsField = useField(SYMPTOMS_FIELD2);
12735
+ const { state } = useForm();
12736
+ const showError = !!error && (touched || state.submitAttempted);
12737
+ const safe = React15.useMemo(() => normalizeObgPathway(value), [value]);
12738
+ const prevZoneCountRef = React15.useRef(0);
12739
+ React15.useEffect(() => {
12740
+ if (disabled) return;
12741
+ const zoneCount = safe.zones.length;
12742
+ if (!zoneCount) {
12743
+ if (prevZoneCountRef.current > 0) {
12744
+ symptomsField.setValue("");
12745
+ }
12746
+ prevZoneCountRef.current = 0;
12747
+ return;
12748
+ }
12749
+ prevZoneCountRef.current = zoneCount;
12750
+ const next = formatObgPathwayToSymptomsNarrative(safe);
12751
+ if (typeof symptomsField.value !== "string" || symptomsField.value !== next) {
12752
+ symptomsField.setValue(next);
12753
+ }
12754
+ }, [safe, disabled]);
12755
+ const update = (next) => {
12756
+ setValue(next);
12757
+ setTouched();
12758
+ };
12759
+ if (!fieldDef) return null;
12760
+ const theme = getThemeConfig("textarea", fieldDef.theme);
12761
+ const wrapperClass = theme?.wrapperClassName ?? "rounded-md overflow-hidden flex flex-col border border-[#D0D0D0]";
12762
+ const labelClass = theme?.labelClassName;
12763
+ const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12764
+ fieldDef.label,
12765
+ fieldDef.required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
12766
+ ] });
12767
+ const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: labelContent });
12768
+ const bodyClass = cn(
12769
+ "-mt-1 flex min-w-0 flex-col gap-3 border-t border-[#D0D0D0] bg-white px-3 py-3",
12770
+ disabled && "pointer-events-none opacity-60"
12771
+ );
12772
+ const hasZone = (z) => safe.zones.includes(z);
12773
+ const toggleZone = (z) => update({
12774
+ ...safe,
12775
+ zones: hasZone(z) ? safe.zones.filter((x) => x !== z) : OBG_ZONE_ORDER.filter((x) => x === z || hasZone(x))
12776
+ });
12777
+ const m = safe.menstrual;
12778
+ const setMenstrual = (patch) => update({ ...safe, menstrual: { ...m, ...patch } });
12779
+ const a = safe.antenatal;
12780
+ const setAntenatal = (patch) => update({ ...safe, antenatal: { ...a, ...patch } });
12781
+ const setAntenatalSymptom = (key) => update({
12782
+ ...safe,
12783
+ antenatal: { ...a, symptoms: { ...a.symptoms, [key]: !a.symptoms[key] } }
12784
+ });
12785
+ const setAntenatalExam = (patch) => update({ ...safe, antenatal: { ...a, exam: { ...a.exam, ...patch } } });
12786
+ const setAntenatalInv = (patch) => update({
12787
+ ...safe,
12788
+ antenatal: { ...a, investigations: { ...a.investigations, ...patch } }
12789
+ });
12790
+ const gSym = safe.gynae.symptoms;
12791
+ const toggleGynae = (key) => update({ ...safe, gynae: { symptoms: { ...gSym, [key]: !gSym[key] } } });
12792
+ const setObstetric = (rows) => update({ ...safe, obstetric: rows });
12793
+ const addObstetricRow = () => setObstetric([
12794
+ ...safe.obstetric,
12795
+ { year: "", ga: "", mode: "", indicationLscs: "", babyOutcome: "", complications: "" }
12796
+ ]);
12797
+ const updateObstetricRow = (idx, patch) => setObstetric(safe.obstetric.map((row, i) => i === idx ? { ...row, ...patch } : row));
12798
+ const deleteObstetricRow = (idx) => setObstetric(safe.obstetric.filter((_, i) => i !== idx));
12799
+ const inf = safe.infertility;
12800
+ const setInfertility = (patch) => update({ ...safe, infertility: { ...inf, ...patch } });
12801
+ const po = safe.postop;
12802
+ const setPostop = (patch) => update({ ...safe, postop: { ...po, ...patch } });
12803
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("w-full min-w-0", wrapperClass), children: [
12804
+ labelEl,
12805
+ fieldDef.description ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-3 pt-2 text-[11px] text-muted-foreground", children: fieldDef.description }) : null,
12806
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: bodyClass, children: [
12807
+ showError ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-600", children: error }) : null,
12808
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
12809
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: "Primary concern (Consultant zone \u2014 multi-select)" }),
12810
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2", children: OBG_ZONE_ORDER.map((z) => {
12811
+ const on = hasZone(z);
12812
+ return /* @__PURE__ */ jsxRuntime.jsx(
12813
+ "button",
12814
+ {
12815
+ type: "button",
12816
+ onClick: () => toggleZone(z),
12817
+ disabled,
12818
+ "aria-pressed": on,
12819
+ className: cn(
12820
+ "rounded-full border px-3 py-1 text-[11px] transition-colors",
12821
+ on ? "border-rose-500 bg-rose-50 text-rose-700" : "border-slate-300 bg-white text-slate-600 hover:bg-slate-50"
12822
+ ),
12823
+ children: obgZoneLabel(z)
12824
+ },
12825
+ z
12826
+ );
12827
+ }) })
12828
+ ] }),
12829
+ hasZone("menstrual_reproductive") ? /* @__PURE__ */ jsxRuntime.jsx(Panel3, { title: "Menstrual & reproductive history", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3 md:grid-cols-4", children: [
12830
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
12831
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Menarche (age)" }),
12832
+ /* @__PURE__ */ jsxRuntime.jsx(
12833
+ Input,
12834
+ {
12835
+ type: "number",
12836
+ min: 5,
12837
+ max: 25,
12838
+ className: "h-8 text-xs",
12839
+ value: m.menarcheAge,
12840
+ onChange: (e) => setMenstrual({ menarcheAge: Number(e.target.value) || 0 }),
12841
+ disabled
12842
+ }
12843
+ )
12844
+ ] }),
12845
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
12846
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Cycle (days)" }),
12847
+ /* @__PURE__ */ jsxRuntime.jsx(
12848
+ Input,
12849
+ {
12850
+ type: "number",
12851
+ min: 0,
12852
+ max: 120,
12853
+ className: "h-8 text-xs",
12854
+ value: m.cycleLength,
12855
+ onChange: (e) => setMenstrual({ cycleLength: Number(e.target.value) || 0 }),
12856
+ disabled
12857
+ }
12858
+ )
12859
+ ] }),
12860
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
12861
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Flow (days)" }),
12862
+ /* @__PURE__ */ jsxRuntime.jsx(
12863
+ Input,
12864
+ {
12865
+ type: "number",
12866
+ min: 0,
12867
+ max: 30,
12868
+ className: "h-8 text-xs",
12869
+ value: m.flowDays,
12870
+ onChange: (e) => setMenstrual({ flowDays: Number(e.target.value) || 0 }),
12871
+ disabled
12872
+ }
12873
+ )
12874
+ ] }),
12875
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-end gap-2 pb-1", children: [
12876
+ /* @__PURE__ */ jsxRuntime.jsx(
12877
+ Checkbox,
12878
+ {
12879
+ checked: m.cycleRegular,
12880
+ onCheckedChange: (c) => setMenstrual({ cycleRegular: c === true }),
12881
+ disabled
12882
+ }
12883
+ ),
12884
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Regular cycle" })
12885
+ ] }),
12886
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
12887
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Amount of flow" }),
12888
+ /* @__PURE__ */ jsxRuntime.jsxs(
12889
+ Select,
12890
+ {
12891
+ value: m.amount === "" ? "none" : m.amount,
12892
+ onValueChange: (v) => setMenstrual({ amount: v === "none" ? "" : v }),
12893
+ disabled,
12894
+ children: [
12895
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
12896
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
12897
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
12898
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Scanty", children: "Scanty" }),
12899
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Normal", children: "Normal" }),
12900
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Heavy", children: "Heavy" })
12901
+ ] })
12902
+ ]
12903
+ }
12904
+ )
12905
+ ] }),
12906
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
12907
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Dysmenorrhea" }),
12908
+ /* @__PURE__ */ jsxRuntime.jsxs(
12909
+ Select,
12910
+ {
12911
+ value: String(m.dysmenorrhea),
12912
+ onValueChange: (v) => setMenstrual({ dysmenorrhea: Number(v) ?? 0 }),
12913
+ disabled,
12914
+ children: [
12915
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "0" }) }),
12916
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
12917
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "0", children: "0 \u2014 none" }),
12918
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "1", children: "1 \u2014 mild" }),
12919
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "2", children: "2 \u2014 moderate" }),
12920
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "3", children: "3 \u2014 severe" })
12921
+ ] })
12922
+ ]
12923
+ }
12924
+ )
12925
+ ] }),
12926
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
12927
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "LMP" }),
12928
+ /* @__PURE__ */ jsxRuntime.jsx(
12929
+ Input,
12930
+ {
12931
+ type: "date",
12932
+ className: "h-8 text-xs",
12933
+ value: m.lmp,
12934
+ onChange: (e) => setMenstrual({ lmp: e.target.value }),
12935
+ disabled
12936
+ }
12937
+ )
12938
+ ] }),
12939
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
12940
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Menopause status" }),
12941
+ /* @__PURE__ */ jsxRuntime.jsxs(
12942
+ Select,
12943
+ {
12944
+ value: m.menopauseStatus === "" ? "none" : m.menopauseStatus,
12945
+ onValueChange: (v) => setMenstrual({
12946
+ menopauseStatus: v === "none" ? "" : v
12947
+ }),
12948
+ disabled,
12949
+ children: [
12950
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
12951
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
12952
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
12953
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Pre", children: "Pre" }),
12954
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Peri", children: "Peri" }),
12955
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Post", children: "Post" })
12956
+ ] })
12957
+ ]
12958
+ }
12959
+ )
12960
+ ] })
12961
+ ] }) }) : null,
12962
+ hasZone("antenatal") ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
12963
+ /* @__PURE__ */ jsxRuntime.jsx(Panel3, { title: "Current pregnancy details", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3 md:grid-cols-4", children: [
12964
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
12965
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Gravida" }),
12966
+ /* @__PURE__ */ jsxRuntime.jsx(
12967
+ Input,
12968
+ {
12969
+ type: "number",
12970
+ min: 0,
12971
+ className: "h-8 text-xs",
12972
+ value: a.gravida,
12973
+ onChange: (e) => setAntenatal({ gravida: Number(e.target.value) || 0 }),
12974
+ disabled
12975
+ }
12976
+ )
12977
+ ] }),
12978
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
12979
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "GA (LMP) \u2014 w / d" }),
12980
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
12981
+ /* @__PURE__ */ jsxRuntime.jsx(
12982
+ Input,
12983
+ {
12984
+ type: "number",
12985
+ min: 0,
12986
+ max: 45,
12987
+ className: "h-8 text-xs",
12988
+ value: a.gaWeeksLmp,
12989
+ onChange: (e) => setAntenatal({ gaWeeksLmp: Number(e.target.value) || 0 }),
12990
+ disabled
12991
+ }
12992
+ ),
12993
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-muted-foreground", children: "w" }),
12994
+ /* @__PURE__ */ jsxRuntime.jsx(
12995
+ Input,
12996
+ {
12997
+ type: "number",
12998
+ min: 0,
12999
+ max: 6,
13000
+ className: "h-8 text-xs",
13001
+ value: a.gaDaysLmp,
13002
+ onChange: (e) => setAntenatal({ gaDaysLmp: Number(e.target.value) || 0 }),
13003
+ disabled
13004
+ }
13005
+ ),
13006
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-muted-foreground", children: "d" })
13007
+ ] })
13008
+ ] }),
13009
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
13010
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "GA (USG) \u2014 w / d" }),
13011
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
13012
+ /* @__PURE__ */ jsxRuntime.jsx(
13013
+ Input,
13014
+ {
13015
+ type: "number",
13016
+ min: 0,
13017
+ max: 45,
13018
+ className: "h-8 text-xs",
13019
+ value: a.gaWeeksUsg,
13020
+ onChange: (e) => setAntenatal({ gaWeeksUsg: Number(e.target.value) || 0 }),
13021
+ disabled
13022
+ }
13023
+ ),
13024
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-muted-foreground", children: "w" }),
13025
+ /* @__PURE__ */ jsxRuntime.jsx(
13026
+ Input,
13027
+ {
13028
+ type: "number",
13029
+ min: 0,
13030
+ max: 6,
13031
+ className: "h-8 text-xs",
13032
+ value: a.gaDaysUsg,
13033
+ onChange: (e) => setAntenatal({ gaDaysUsg: Number(e.target.value) || 0 }),
13034
+ disabled
13035
+ }
13036
+ ),
13037
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-muted-foreground", children: "d" })
13038
+ ] })
13039
+ ] }),
13040
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13041
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "EDD" }),
13042
+ /* @__PURE__ */ jsxRuntime.jsx(
13043
+ Input,
13044
+ {
13045
+ type: "date",
13046
+ className: "h-8 text-xs",
13047
+ value: a.edd,
13048
+ onChange: (e) => setAntenatal({ edd: e.target.value }),
13049
+ disabled
13050
+ }
13051
+ )
13052
+ ] }),
13053
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1 md:col-span-2", children: [
13054
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Risk category" }),
13055
+ /* @__PURE__ */ jsxRuntime.jsxs(
13056
+ Select,
13057
+ {
13058
+ value: a.riskCategory === "" ? "none" : a.riskCategory,
13059
+ onValueChange: (v) => setAntenatal({
13060
+ riskCategory: v === "none" ? "" : v
13061
+ }),
13062
+ disabled,
13063
+ children: [
13064
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13065
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13066
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13067
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Low", children: "Low" }),
13068
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "High", children: "High" })
13069
+ ] })
13070
+ ]
13071
+ }
13072
+ )
13073
+ ] })
13074
+ ] }) }),
13075
+ /* @__PURE__ */ jsxRuntime.jsx(Panel3, { title: "Antenatal symptoms", children: /* @__PURE__ */ jsxRuntime.jsx(
13076
+ ChipRow,
13077
+ {
13078
+ options: [
13079
+ { key: "nauseaVomiting", label: "Nausea / vomiting" },
13080
+ { key: "bleedingPV", label: "Bleeding PV" },
13081
+ { key: "painAbdomen", label: "Pain abdomen" },
13082
+ { key: "decreasedFetalMovements", label: "Decreased fetal movements" }
13083
+ ],
13084
+ selected: a.symptoms,
13085
+ onToggle: (k) => setAntenatalSymptom(k),
13086
+ disabled
13087
+ }
13088
+ ) }),
13089
+ /* @__PURE__ */ jsxRuntime.jsx(Panel3, { title: "Antenatal examination", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3 md:grid-cols-4", children: [
13090
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13091
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Weight (kg)" }),
13092
+ /* @__PURE__ */ jsxRuntime.jsx(
13093
+ Input,
13094
+ {
13095
+ type: "number",
13096
+ className: "h-8 text-xs",
13097
+ value: a.exam.weightKg,
13098
+ onChange: (e) => setAntenatalExam({ weightKg: Number(e.target.value) || 0 }),
13099
+ disabled
13100
+ }
13101
+ )
13102
+ ] }),
13103
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13104
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Height (cm)" }),
13105
+ /* @__PURE__ */ jsxRuntime.jsx(
13106
+ Input,
13107
+ {
13108
+ type: "number",
13109
+ className: "h-8 text-xs",
13110
+ value: a.exam.heightCm,
13111
+ onChange: (e) => setAntenatalExam({ heightCm: Number(e.target.value) || 0 }),
13112
+ disabled
13113
+ }
13114
+ )
13115
+ ] }),
13116
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13117
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "BMI" }),
13118
+ /* @__PURE__ */ jsxRuntime.jsx(
13119
+ Input,
13120
+ {
13121
+ type: "number",
13122
+ step: 0.1,
13123
+ className: "h-8 text-xs",
13124
+ value: a.exam.bmi,
13125
+ onChange: (e) => setAntenatalExam({ bmi: Number(e.target.value) || 0 }),
13126
+ disabled
13127
+ }
13128
+ )
13129
+ ] }),
13130
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13131
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "BP" }),
13132
+ /* @__PURE__ */ jsxRuntime.jsx(
13133
+ Input,
13134
+ {
13135
+ placeholder: "e.g. 120/80",
13136
+ className: "h-8 text-xs",
13137
+ value: a.exam.bp,
13138
+ onChange: (e) => setAntenatalExam({ bp: e.target.value }),
13139
+ disabled
13140
+ }
13141
+ )
13142
+ ] }),
13143
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-end gap-2 pb-1", children: [
13144
+ /* @__PURE__ */ jsxRuntime.jsx(
13145
+ Checkbox,
13146
+ {
13147
+ checked: a.exam.pallor,
13148
+ onCheckedChange: (c) => setAntenatalExam({ pallor: c === true }),
13149
+ disabled
13150
+ }
13151
+ ),
13152
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Pallor" })
13153
+ ] }),
13154
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-end gap-2 pb-1", children: [
13155
+ /* @__PURE__ */ jsxRuntime.jsx(
13156
+ Checkbox,
13157
+ {
13158
+ checked: a.exam.oedema,
13159
+ onCheckedChange: (c) => setAntenatalExam({ oedema: c === true }),
13160
+ disabled
13161
+ }
13162
+ ),
13163
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Oedema" })
13164
+ ] }),
13165
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13166
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Fundal height (cm)" }),
13167
+ /* @__PURE__ */ jsxRuntime.jsx(
13168
+ Input,
13169
+ {
13170
+ type: "number",
13171
+ className: "h-8 text-xs",
13172
+ value: a.exam.fundalHeightCm,
13173
+ onChange: (e) => setAntenatalExam({ fundalHeightCm: Number(e.target.value) || 0 }),
13174
+ disabled
13175
+ }
13176
+ )
13177
+ ] }),
13178
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13179
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "FHR (bpm)" }),
13180
+ /* @__PURE__ */ jsxRuntime.jsx(
13181
+ Input,
13182
+ {
13183
+ type: "number",
13184
+ className: "h-8 text-xs",
13185
+ value: a.exam.fhrBpm,
13186
+ onChange: (e) => setAntenatalExam({ fhrBpm: Number(e.target.value) || 0 }),
13187
+ disabled
13188
+ }
13189
+ )
13190
+ ] }),
13191
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13192
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Presentation" }),
13193
+ /* @__PURE__ */ jsxRuntime.jsxs(
13194
+ Select,
13195
+ {
13196
+ value: a.exam.presentation === "" ? "none" : a.exam.presentation,
13197
+ onValueChange: (v) => setAntenatalExam({
13198
+ presentation: v === "none" ? "" : v
13199
+ }),
13200
+ disabled,
13201
+ children: [
13202
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13203
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13204
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13205
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Cephalic", children: "Cephalic" }),
13206
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Breech", children: "Breech" }),
13207
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Other", children: "Other" })
13208
+ ] })
13209
+ ]
13210
+ }
13211
+ )
13212
+ ] }),
13213
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13214
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Lie" }),
13215
+ /* @__PURE__ */ jsxRuntime.jsxs(
13216
+ Select,
13217
+ {
13218
+ value: a.exam.lie === "" ? "none" : a.exam.lie,
13219
+ onValueChange: (v) => setAntenatalExam({ lie: v === "none" ? "" : v }),
13220
+ disabled,
13221
+ children: [
13222
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13223
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13224
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13225
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Longitudinal", children: "Longitudinal" }),
13226
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Transverse", children: "Transverse" }),
13227
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Oblique", children: "Oblique" })
13228
+ ] })
13229
+ ]
13230
+ }
13231
+ )
13232
+ ] })
13233
+ ] }) }),
13234
+ /* @__PURE__ */ jsxRuntime.jsx(Panel3, { title: "Investigations tracker", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3 md:grid-cols-3", children: [
13235
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13236
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Blood Group / Rh" }),
13237
+ /* @__PURE__ */ jsxRuntime.jsx(
13238
+ Input,
13239
+ {
13240
+ className: "h-8 text-xs",
13241
+ placeholder: "e.g. O+ve",
13242
+ value: a.investigations.bloodGroup,
13243
+ onChange: (e) => setAntenatalInv({ bloodGroup: e.target.value }),
13244
+ disabled
13245
+ }
13246
+ )
13247
+ ] }),
13248
+ [
13249
+ { key: "cbc", label: "CBC" },
13250
+ { key: "tsh", label: "TSH" },
13251
+ { key: "rbsOgtt", label: "RBS / OGTT" },
13252
+ { key: "serology", label: "HIV / HBsAg / VDRL" },
13253
+ { key: "urine", label: "Urine routine" }
13254
+ ].map((row) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13255
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: row.label }),
13256
+ /* @__PURE__ */ jsxRuntime.jsxs(
13257
+ Select,
13258
+ {
13259
+ value: a.investigations[row.key] === "" ? "none" : a.investigations[row.key],
13260
+ onValueChange: (v) => setAntenatalInv({
13261
+ [row.key]: v === "none" ? "" : v
13262
+ }),
13263
+ disabled,
13264
+ children: [
13265
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13266
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13267
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13268
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Done", children: "Done" }),
13269
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Pending", children: "Pending" }),
13270
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Abnormal", children: "Abnormal" })
13271
+ ] })
13272
+ ]
13273
+ }
13274
+ )
13275
+ ] }, row.key)),
13276
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13277
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "USG" }),
13278
+ /* @__PURE__ */ jsxRuntime.jsxs(
13279
+ Select,
13280
+ {
13281
+ value: a.investigations.usg === "" ? "none" : a.investigations.usg,
13282
+ onValueChange: (v) => setAntenatalInv({
13283
+ usg: v === "none" ? "" : v
13284
+ }),
13285
+ disabled,
13286
+ children: [
13287
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13288
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13289
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13290
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Dating", children: "Dating" }),
13291
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "NT", children: "NT" }),
13292
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Anomaly", children: "Anomaly" }),
13293
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Growth", children: "Growth" }),
13294
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Pending", children: "Pending" })
13295
+ ] })
13296
+ ]
13297
+ }
13298
+ )
13299
+ ] })
13300
+ ] }) })
13301
+ ] }) : null,
13302
+ hasZone("gynaecological") ? /* @__PURE__ */ jsxRuntime.jsx(Panel3, { title: "Gynaecological symptoms", children: /* @__PURE__ */ jsxRuntime.jsx(
13303
+ ChipRow,
13304
+ {
13305
+ options: [
13306
+ { key: "aub", label: "Abnormal uterine bleeding" },
13307
+ { key: "whiteDischarge", label: "White discharge" },
13308
+ { key: "pelvicPain", label: "Pelvic pain" },
13309
+ { key: "dyspareunia", label: "Dyspareunia" },
13310
+ { key: "urinaryComplaints", label: "Urinary complaints" },
13311
+ { key: "prolapse", label: "Prolapse" }
13312
+ ],
13313
+ selected: gSym,
13314
+ onToggle: (k) => toggleGynae(k),
13315
+ disabled
13316
+ }
13317
+ ) }) : null,
13318
+ hasZone("obstetric") ? /* @__PURE__ */ jsxRuntime.jsx(
13319
+ Panel3,
13320
+ {
13321
+ title: "Obstetric history (G-P-A-L)",
13322
+ right: /* @__PURE__ */ jsxRuntime.jsx(
13323
+ Button,
13324
+ {
13325
+ type: "button",
13326
+ size: "sm",
13327
+ variant: "outline",
13328
+ className: "h-7 text-xs",
13329
+ onClick: addObstetricRow,
13330
+ disabled,
13331
+ children: "+ Add row"
13332
+ }
13333
+ ),
13334
+ children: safe.obstetric.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[11px] text-muted-foreground", children: "No prior pregnancies recorded." }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full text-[11px]", children: [
13335
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "bg-slate-50 text-left text-slate-600", children: [
13336
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "p-1.5 font-medium", children: "Year" }),
13337
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "p-1.5 font-medium", children: "GA" }),
13338
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "p-1.5 font-medium", children: "Mode" }),
13339
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "p-1.5 font-medium", children: "LSCS indication" }),
13340
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "p-1.5 font-medium", children: "Baby outcome" }),
13341
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "p-1.5 font-medium", children: "Complications" }),
13342
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "p-1.5" })
13343
+ ] }) }),
13344
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: safe.obstetric.map((row, idx) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "border-t", children: [
13345
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "p-1", children: /* @__PURE__ */ jsxRuntime.jsx(
13346
+ Input,
13347
+ {
13348
+ className: "h-7 text-[11px]",
13349
+ value: row.year,
13350
+ onChange: (e) => updateObstetricRow(idx, { year: e.target.value }),
13351
+ disabled
13352
+ }
13353
+ ) }),
13354
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "p-1", children: /* @__PURE__ */ jsxRuntime.jsx(
13355
+ Input,
13356
+ {
13357
+ className: "h-7 text-[11px]",
13358
+ value: row.ga,
13359
+ onChange: (e) => updateObstetricRow(idx, { ga: e.target.value }),
13360
+ disabled
13361
+ }
13362
+ ) }),
13363
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "p-1", children: /* @__PURE__ */ jsxRuntime.jsxs(
13364
+ Select,
13365
+ {
13366
+ value: row.mode === "" ? "none" : row.mode,
13367
+ onValueChange: (v) => updateObstetricRow(idx, {
13368
+ mode: v === "none" ? "" : v
13369
+ }),
13370
+ disabled,
13371
+ children: [
13372
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-7 text-[11px]", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13373
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13374
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13375
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "NVD", children: "NVD" }),
13376
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "LSCS", children: "LSCS" }),
13377
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Instrumental", children: "Instrumental" }),
13378
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Abortion", children: "Abortion" }),
13379
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Stillbirth", children: "Stillbirth" })
13380
+ ] })
13381
+ ]
13382
+ }
13383
+ ) }),
13384
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "p-1", children: /* @__PURE__ */ jsxRuntime.jsx(
13385
+ Input,
13386
+ {
13387
+ className: "h-7 text-[11px]",
13388
+ value: row.indicationLscs,
13389
+ onChange: (e) => updateObstetricRow(idx, { indicationLscs: e.target.value }),
13390
+ disabled
13391
+ }
13392
+ ) }),
13393
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "p-1", children: /* @__PURE__ */ jsxRuntime.jsx(
13394
+ Input,
13395
+ {
13396
+ className: "h-7 text-[11px]",
13397
+ value: row.babyOutcome,
13398
+ onChange: (e) => updateObstetricRow(idx, { babyOutcome: e.target.value }),
13399
+ disabled
13400
+ }
13401
+ ) }),
13402
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "p-1", children: /* @__PURE__ */ jsxRuntime.jsx(
13403
+ Input,
13404
+ {
13405
+ className: "h-7 text-[11px]",
13406
+ placeholder: "PIH, GDM, PPH, NICU\u2026",
13407
+ value: row.complications,
13408
+ onChange: (e) => updateObstetricRow(idx, { complications: e.target.value }),
13409
+ disabled
13410
+ }
13411
+ ) }),
13412
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "p-1", children: /* @__PURE__ */ jsxRuntime.jsx(
13413
+ Button,
13414
+ {
13415
+ type: "button",
13416
+ size: "sm",
13417
+ variant: "ghost",
13418
+ className: "h-7 text-[11px] text-rose-600 hover:bg-rose-50",
13419
+ onClick: () => deleteObstetricRow(idx),
13420
+ disabled,
13421
+ children: "\xD7"
13422
+ }
13423
+ ) })
13424
+ ] }, idx)) })
13425
+ ] }) })
13426
+ }
13427
+ ) : null,
13428
+ hasZone("infertility") ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
13429
+ /* @__PURE__ */ jsxRuntime.jsx(Panel3, { title: "Infertility profile", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3 md:grid-cols-3", children: [
13430
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13431
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Type" }),
13432
+ /* @__PURE__ */ jsxRuntime.jsxs(
13433
+ Select,
13434
+ {
13435
+ value: inf.type === "" ? "none" : inf.type,
13436
+ onValueChange: (v) => setInfertility({ type: v === "none" ? "" : v }),
13437
+ disabled,
13438
+ children: [
13439
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13440
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13441
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13442
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Primary", children: "Primary" }),
13443
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Secondary", children: "Secondary" })
13444
+ ] })
13445
+ ]
13446
+ }
13447
+ )
13448
+ ] }),
13449
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13450
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Duration (months)" }),
13451
+ /* @__PURE__ */ jsxRuntime.jsx(
13452
+ Input,
13453
+ {
13454
+ type: "number",
13455
+ min: 0,
13456
+ className: "h-8 text-xs",
13457
+ value: inf.durationMonths,
13458
+ onChange: (e) => setInfertility({ durationMonths: Number(e.target.value) || 0 }),
13459
+ disabled
13460
+ }
13461
+ )
13462
+ ] }),
13463
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1 md:col-span-1", children: [
13464
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Previous treatments" }),
13465
+ /* @__PURE__ */ jsxRuntime.jsx(
13466
+ Input,
13467
+ {
13468
+ className: "h-8 text-xs",
13469
+ placeholder: "IUI \xD72, OI cycles\u2026",
13470
+ value: inf.previousTreatments,
13471
+ onChange: (e) => setInfertility({ previousTreatments: e.target.value }),
13472
+ disabled
13473
+ }
13474
+ )
13475
+ ] })
13476
+ ] }) }),
13477
+ /* @__PURE__ */ jsxRuntime.jsx(Panel3, { title: "Female partner evaluation", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3 md:grid-cols-3", children: [
13478
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13479
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Ovulation status" }),
13480
+ /* @__PURE__ */ jsxRuntime.jsxs(
13481
+ Select,
13482
+ {
13483
+ value: inf.female.ovulation === "" ? "none" : inf.female.ovulation,
13484
+ onValueChange: (v) => setInfertility({
13485
+ female: {
13486
+ ...inf.female,
13487
+ ovulation: v === "none" ? "" : v
13488
+ }
13489
+ }),
13490
+ disabled,
13491
+ children: [
13492
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13493
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13494
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13495
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Ovulatory", children: "Ovulatory" }),
13496
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Anovulatory", children: "Anovulatory" }),
13497
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Unknown", children: "Unknown" })
13498
+ ] })
13499
+ ]
13500
+ }
13501
+ )
13502
+ ] }),
13503
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-end gap-2 pb-1", children: [
13504
+ /* @__PURE__ */ jsxRuntime.jsx(
13505
+ Checkbox,
13506
+ {
13507
+ checked: inf.female.pcosFeatures,
13508
+ onCheckedChange: (c) => setInfertility({
13509
+ female: { ...inf.female, pcosFeatures: c === true }
13510
+ }),
13511
+ disabled
13512
+ }
13513
+ ),
13514
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "PCOS features" })
13515
+ ] }),
13516
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-end gap-2 pb-1", children: [
13517
+ /* @__PURE__ */ jsxRuntime.jsx(
13518
+ Checkbox,
13519
+ {
13520
+ checked: inf.female.endometriosisSuspicion,
13521
+ onCheckedChange: (c) => setInfertility({
13522
+ female: { ...inf.female, endometriosisSuspicion: c === true }
13523
+ }),
13524
+ disabled
13525
+ }
13526
+ ),
13527
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Endometriosis suspicion" })
13528
+ ] })
13529
+ ] }) }),
13530
+ /* @__PURE__ */ jsxRuntime.jsx(Panel3, { title: "Male partner details", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3 md:grid-cols-3", children: [
13531
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13532
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Age" }),
13533
+ /* @__PURE__ */ jsxRuntime.jsx(
13534
+ Input,
13535
+ {
13536
+ type: "number",
13537
+ min: 0,
13538
+ className: "h-8 text-xs",
13539
+ value: inf.male.age,
13540
+ onChange: (e) => setInfertility({ male: { ...inf.male, age: Number(e.target.value) || 0 } }),
13541
+ disabled
13542
+ }
13543
+ )
13544
+ ] }),
13545
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13546
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Semen analysis" }),
13547
+ /* @__PURE__ */ jsxRuntime.jsxs(
13548
+ Select,
13549
+ {
13550
+ value: inf.male.semenAnalysis === "" ? "none" : inf.male.semenAnalysis,
13551
+ onValueChange: (v) => setInfertility({
13552
+ male: {
13553
+ ...inf.male,
13554
+ semenAnalysis: v === "none" ? "" : v
13555
+ }
13556
+ }),
13557
+ disabled,
13558
+ children: [
13559
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13560
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13561
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13562
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Normal", children: "Normal" }),
13563
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Abnormal", children: "Abnormal" }),
13564
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Pending", children: "Pending" })
13565
+ ] })
13566
+ ]
13567
+ }
13568
+ )
13569
+ ] })
13570
+ ] }) }),
13571
+ /* @__PURE__ */ jsxRuntime.jsx(Panel3, { title: "Investigations", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 gap-3 md:grid-cols-3", children: [
13572
+ { key: "amh", label: "AMH" },
13573
+ { key: "fshLh", label: "FSH / LH" },
13574
+ { key: "prolactin", label: "Prolactin" },
13575
+ { key: "tsh", label: "TSH" },
13576
+ { key: "tvs", label: "TVS findings" },
13577
+ { key: "hsg", label: "HSG findings" }
13578
+ ].map((row) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13579
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: row.label }),
13580
+ /* @__PURE__ */ jsxRuntime.jsx(
13581
+ Input,
13582
+ {
13583
+ className: "h-8 text-xs",
13584
+ value: inf.investigations[row.key],
13585
+ onChange: (e) => setInfertility({
13586
+ investigations: { ...inf.investigations, [row.key]: e.target.value }
13587
+ }),
13588
+ disabled
13589
+ }
13590
+ )
13591
+ ] }, row.key)) }) })
13592
+ ] }) : null,
13593
+ hasZone("postoperative") ? /* @__PURE__ */ jsxRuntime.jsx(Panel3, { title: "Post-operative follow-up", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3 md:grid-cols-3", children: [
13594
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13595
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Date of surgery" }),
13596
+ /* @__PURE__ */ jsxRuntime.jsx(
13597
+ Input,
13598
+ {
13599
+ type: "date",
13600
+ className: "h-8 text-xs",
13601
+ value: po.surgeryDate,
13602
+ onChange: (e) => setPostop({ surgeryDate: e.target.value }),
13603
+ disabled
13604
+ }
13605
+ )
13606
+ ] }),
13607
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1 md:col-span-2", children: [
13608
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Procedure performed" }),
13609
+ /* @__PURE__ */ jsxRuntime.jsx(
13610
+ Input,
13611
+ {
13612
+ className: "h-8 text-xs",
13613
+ value: po.procedure,
13614
+ onChange: (e) => setPostop({ procedure: e.target.value }),
13615
+ disabled
13616
+ }
13617
+ )
13618
+ ] }),
13619
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1 md:col-span-2", children: [
13620
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Histopathology result" }),
13621
+ /* @__PURE__ */ jsxRuntime.jsx(
13622
+ Input,
13623
+ {
13624
+ className: "h-8 text-xs",
13625
+ value: po.histopathology,
13626
+ onChange: (e) => setPostop({ histopathology: e.target.value }),
13627
+ disabled
13628
+ }
13629
+ )
13630
+ ] }),
13631
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13632
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Wound status" }),
13633
+ /* @__PURE__ */ jsxRuntime.jsxs(
13634
+ Select,
13635
+ {
13636
+ value: po.woundStatus === "" ? "none" : po.woundStatus,
13637
+ onValueChange: (v) => setPostop({
13638
+ woundStatus: v === "none" ? "" : v
13639
+ }),
13640
+ disabled,
13641
+ children: [
13642
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13643
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13644
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13645
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Healthy", children: "Healthy" }),
13646
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Erythema", children: "Erythema" }),
13647
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Discharge", children: "Discharge" }),
13648
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Dehisced", children: "Dehisced" })
13649
+ ] })
13650
+ ]
13651
+ }
13652
+ )
13653
+ ] }),
13654
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13655
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Pain score (0-10)" }),
13656
+ /* @__PURE__ */ jsxRuntime.jsx(
13657
+ Input,
13658
+ {
13659
+ type: "number",
13660
+ min: 0,
13661
+ max: 10,
13662
+ className: "h-8 text-xs",
13663
+ value: po.painScore,
13664
+ onChange: (e) => setPostop({
13665
+ painScore: Math.max(0, Math.min(10, Number(e.target.value) || 0))
13666
+ }),
13667
+ disabled
13668
+ }
13669
+ )
13670
+ ] }),
13671
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1 md:col-span-3", children: [
13672
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Complications" }),
13673
+ /* @__PURE__ */ jsxRuntime.jsx(
13674
+ Textarea,
13675
+ {
13676
+ className: "min-h-[60px] text-xs",
13677
+ value: po.complications,
13678
+ onChange: (e) => setPostop({ complications: e.target.value }),
13679
+ disabled
13680
+ }
13681
+ )
13682
+ ] })
13683
+ ] }) }) : null,
13684
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 border-t border-[#D0D0D0] pt-3", children: [
13685
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: "History of Presenting Complaint" }),
13686
+ /* @__PURE__ */ jsxRuntime.jsx(
13687
+ Textarea,
13688
+ {
13689
+ value: safe.zones.length > 0 ? formatObgPathwayToSymptomsNarrative(safe) : typeof symptomsField.value === "string" ? symptomsField.value : "",
13690
+ onChange: (e) => {
13691
+ if (safe.zones.length > 0) return;
13692
+ symptomsField.setValue(e.target.value);
13693
+ },
13694
+ readOnly: safe.zones.length > 0,
13695
+ disabled,
13696
+ className: "min-h-[70px] text-xs",
13697
+ placeholder: safe.zones.length > 0 ? "Generated from pathway panels above." : "Free-text history, or select pathway zones above for a structured narrative."
13698
+ }
13699
+ )
13700
+ ] })
13701
+ ] })
13702
+ ] });
13703
+ };
13704
+ var FieldRenderer = ({ fieldId }) => {
13705
+ const { fieldDef, visible } = useField(fieldId);
13706
+ if (!visible || !fieldDef) {
13707
+ return null;
13708
+ }
13709
+ return renderWidget(fieldId, fieldDef);
13710
+ };
13711
+ function renderWidget(fieldId, fieldDef) {
13712
+ switch (fieldDef.type) {
13713
+ case "text":
13714
+ case "number":
13715
+ return /* @__PURE__ */ jsxRuntime.jsx(TextWidget, { fieldId });
13716
+ case "slider":
13717
+ return /* @__PURE__ */ jsxRuntime.jsx(SliderWidget, { fieldId });
13718
+ case "textarea":
13719
+ if (fieldMetaRequestsMarMedicationOrdersButton(fieldDef.meta)) {
13720
+ return /* @__PURE__ */ jsxRuntime.jsx(MarMedicationOrdersWidget, { fieldId });
13721
+ }
13722
+ return /* @__PURE__ */ jsxRuntime.jsx(TextWidget, { fieldId });
13723
+ case "richtext":
13724
+ return /* @__PURE__ */ jsxRuntime.jsx(RichTextWidget, { fieldId });
13725
+ case "date":
13726
+ return /* @__PURE__ */ jsxRuntime.jsx(DateWidget, { fieldId });
13727
+ case "datetime":
13728
+ return /* @__PURE__ */ jsxRuntime.jsx(DateTimeWidget, { fieldId });
13729
+ case "select":
13730
+ return /* @__PURE__ */ jsxRuntime.jsx(SelectWidget, { fieldId });
13731
+ case "radio":
13732
+ return /* @__PURE__ */ jsxRuntime.jsx(RadioWidget, { fieldId });
13733
+ case "checkbox":
13734
+ return /* @__PURE__ */ jsxRuntime.jsx(CheckboxWidget, { fieldId });
13735
+ case "multiselect":
13736
+ return /* @__PURE__ */ jsxRuntime.jsx(MultiSelectWidget, { fieldId });
13737
+ case "repeatable":
13738
+ return /* @__PURE__ */ jsxRuntime.jsx(RepeatableWidget, { fieldId });
13739
+ case "image_upload":
13740
+ return /* @__PURE__ */ jsxRuntime.jsx(ImageUploadWidget, { fieldId });
13741
+ case "media_upload":
13742
+ return /* @__PURE__ */ jsxRuntime.jsx(MediaUploadWidget, { fieldId });
13743
+ case "signature":
13744
+ return /* @__PURE__ */ jsxRuntime.jsx(SignatureUploadWidget, { fieldId });
13745
+ case "editable_table":
13746
+ return /* @__PURE__ */ jsxRuntime.jsx(EditableTableWidget, { fieldId });
13747
+ case "medications":
13748
+ return /* @__PURE__ */ jsxRuntime.jsx(AddMedicationWidget, { fieldId });
13749
+ case "discharge_medication_orders":
13750
+ return /* @__PURE__ */ jsxRuntime.jsx(DischargeMedicationOrdersWidget, { fieldId });
13751
+ case "investigations":
13752
+ return /* @__PURE__ */ jsxRuntime.jsx(AddInvestigationWidget, { fieldId });
13753
+ case "procedures":
13754
+ return /* @__PURE__ */ jsxRuntime.jsx(AddProcedureWidget, { fieldId });
13755
+ case "differential_diagnosis":
13756
+ return /* @__PURE__ */ jsxRuntime.jsx(DifferentialDiagnosisWidget, { fieldId });
13757
+ case "vitals":
13758
+ return /* @__PURE__ */ jsxRuntime.jsx(VitalsWidget, { fieldId });
13759
+ case "hidden_vitals":
13760
+ return /* @__PURE__ */ jsxRuntime.jsx(HiddenVitalsWidget, { fieldId });
13761
+ case "referral":
13762
+ return /* @__PURE__ */ jsxRuntime.jsx(ReferralWidget, { fieldId });
13763
+ case "followup":
13764
+ return /* @__PURE__ */ jsxRuntime.jsx(FollowupWidget, { fieldId });
13765
+ case "smart_textarea":
13766
+ return /* @__PURE__ */ jsxRuntime.jsx(SmartTextareaWidget, { fieldId });
13767
+ case "diagnosis_textarea":
13768
+ return /* @__PURE__ */ jsxRuntime.jsx(DiagnosisTextareaWidget, { fieldId });
13769
+ case "obstetric_history":
13770
+ return /* @__PURE__ */ jsxRuntime.jsx(ObstetricHistoryWidget, { fieldId });
13771
+ case "eye_prescription":
13772
+ return /* @__PURE__ */ jsxRuntime.jsx(OphthalmologyWidget, { fieldId });
13773
+ case "ophthal_diagnosis":
13774
+ return /* @__PURE__ */ jsxRuntime.jsx(OphthalDiagnosisWidget, { fieldId });
13775
+ case "orthopedic_exam":
13776
+ return /* @__PURE__ */ jsxRuntime.jsx(OrthopedicExamWidget, { fieldId });
13777
+ case "general_surgery_smart_history":
13778
+ return /* @__PURE__ */ jsxRuntime.jsx(GsSmartHistoryWidget, { fieldId });
13779
+ case "general_surgery_examination":
13780
+ return /* @__PURE__ */ jsxRuntime.jsx(GsExaminationWidget, { fieldId });
13781
+ case "general_surgery_grading":
13782
+ return /* @__PURE__ */ jsxRuntime.jsx(GsGradingWidget, { fieldId });
13783
+ case "pain_scale_flags":
13784
+ return /* @__PURE__ */ jsxRuntime.jsx(PainScaleFlagsWidget, { fieldId });
13785
+ case "urology_smart_history":
13786
+ return /* @__PURE__ */ jsxRuntime.jsx(UrologySmartHistoryWidget, { fieldId });
13787
+ case "urology_examination":
13788
+ return /* @__PURE__ */ jsxRuntime.jsx(UrologyExaminationWidget, { fieldId });
13789
+ case "urology_pathway":
13790
+ return /* @__PURE__ */ jsxRuntime.jsx(UrologyPathwayWidget, { fieldId });
13791
+ case "obg_examination":
13792
+ return /* @__PURE__ */ jsxRuntime.jsx(OBGExaminationWidget, { fieldId });
13793
+ case "obg_pathway":
13794
+ return /* @__PURE__ */ jsxRuntime.jsx(OBGPathwayWidget, { fieldId });
13795
+ case "toggle": {
13796
+ const { value, setValue, setTouched, disabled } = useField(fieldId);
13797
+ const store = useFormStore();
13798
+ const excludes = fieldDef.excludes ?? [];
13799
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
13800
+ /* @__PURE__ */ jsxRuntime.jsx(
13801
+ Switch,
13802
+ {
13803
+ checked: value === true,
13804
+ disabled,
13805
+ onCheckedChange: (checked) => {
13806
+ setValue(checked);
13807
+ setTouched();
13808
+ if (checked) excludes.forEach((id) => store.setValue(id, false));
13809
+ }
13810
+ }
13811
+ ),
13812
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium leading-none cursor-pointer select-none", children: fieldDef.label })
13813
+ ] });
13814
+ }
13815
+ case "suggestion_textarea":
13816
+ case "complaint_chips":
13817
+ return /* @__PURE__ */ jsxRuntime.jsx(SuggestionTextareaWidget, { fieldId });
13818
+ case "lens_assessment":
13819
+ return /* @__PURE__ */ jsxRuntime.jsx(LensAssessmentWidget, { fieldId });
13820
+ case "functional_impairment_score":
13821
+ return /* @__PURE__ */ jsxRuntime.jsx(FunctionalImpairmentScoreWidget, { fieldId });
13822
+ case "biometry_iol_workup":
13823
+ return /* @__PURE__ */ jsxRuntime.jsx(BiometryIolWorkupWidget, { fieldId });
13824
+ case "surgical_risk_flags":
13825
+ return /* @__PURE__ */ jsxRuntime.jsx(SurgicalRiskFlagsWidget, { fieldId });
13826
+ case "static_text": {
13827
+ const def = fieldDef;
13828
+ const size = def.size ?? "regular";
13829
+ const labelClass = size === "large" ? "text-base" : "text-sm";
13830
+ const descClass = size === "large" ? "text-sm" : "text-xs";
13831
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${labelClass} text-muted-foreground`, children: [
13832
+ def.label,
13833
+ def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: `mt-1 ${descClass} opacity-90`, children: def.description })
13834
+ ] });
13835
+ }
13836
+ default:
13837
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-red-500", children: [
13838
+ "Unknown field type: ",
13839
+ fieldDef.type
13840
+ ] });
13841
+ }
13842
+ }
13843
+ var Section = ({ title, children }) => {
12027
13844
  const [expanded, setExpanded] = React15.useState(true);
12028
13845
  const handleToggle = () => setExpanded((prev) => !prev);
12029
13846
  const contentClassName = cn(
@@ -12824,18 +14641,18 @@ var ReadOnlyFieldRenderer = ({
12824
14641
  const locsRecord = locs != null && typeof locs === "object" && !Array.isArray(locs) ? locs : null;
12825
14642
  const eyeLine = (label, g) => {
12826
14643
  if (!g || typeof g !== "object") return null;
12827
- const num = (k) => typeof g[k] === "number" ? g[k] : "\u2014";
14644
+ const num2 = (k) => typeof g[k] === "number" ? g[k] : "\u2014";
12828
14645
  return /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-foreground", children: [
12829
14646
  label,
12830
14647
  ": NO ",
12831
- String(num("NO")),
14648
+ String(num2("NO")),
12832
14649
  ", NC ",
12833
- String(num("NC")),
14650
+ String(num2("NC")),
12834
14651
  ", C ",
12835
- String(num("C")),
14652
+ String(num2("C")),
12836
14653
  ", PSC",
12837
14654
  " ",
12838
- String(num("PSC"))
14655
+ String(num2("PSC"))
12839
14656
  ] });
12840
14657
  };
12841
14658
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 rounded-md border p-3 text-sm", children: [
@@ -12975,6 +14792,32 @@ var ReadOnlyFieldRenderer = ({
12975
14792
  ] }) : null
12976
14793
  ] });
12977
14794
  }
14795
+ case "obg_pathway": {
14796
+ const structuredDisplay = value && typeof value === "object" ? JSON.stringify(normalizeObgPathway(value), null, 2) : value == null || value === "" ? "\u2014" : String(value);
14797
+ const hopcDef = resolveFieldDef?.("symptoms");
14798
+ const hopcRaw = allValues?.["symptoms"];
14799
+ const hopcStr = typeof hopcRaw === "string" ? hopcRaw : hopcRaw != null && hopcRaw !== "" ? String(hopcRaw) : "";
14800
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
14801
+ /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef, value: structuredDisplay }),
14802
+ hopcDef ? /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef: hopcDef, value: hopcStr }) : hopcStr ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
14803
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-gray-700", children: "History of presenting complaint" }),
14804
+ /* @__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: hopcStr })
14805
+ ] }) : null
14806
+ ] });
14807
+ }
14808
+ case "obg_examination": {
14809
+ const structuredDisplay = value && typeof value === "object" ? JSON.stringify(value, null, 2) : value == null || value === "" ? "\u2014" : String(value);
14810
+ const clinicalDef = resolveFieldDef?.("clinical_examination");
14811
+ const clinicalRaw = allValues?.["clinical_examination"];
14812
+ const clinicalStr = typeof clinicalRaw === "string" ? clinicalRaw : clinicalRaw != null && clinicalRaw !== "" ? String(clinicalRaw) : "";
14813
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
14814
+ /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef, value: structuredDisplay }),
14815
+ clinicalDef ? /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef: clinicalDef, value: clinicalStr }) : clinicalStr ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
14816
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-gray-700", children: "Clinical examination" }),
14817
+ /* @__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 })
14818
+ ] }) : null
14819
+ ] });
14820
+ }
12978
14821
  case "static_text": {
12979
14822
  const def = fieldDef;
12980
14823
  const size = def.size ?? "regular";