formanitor 0.0.44 → 0.0.46

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
@@ -3109,6 +3117,18 @@ var DateTimeWidget = ({ fieldId }) => {
3109
3117
  showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
3110
3118
  ] });
3111
3119
  };
3120
+ function extractImageDisplayUrl(value) {
3121
+ if (value == null) return null;
3122
+ if (typeof value === "string") {
3123
+ return /^https?:\/\//i.test(value) ? value : null;
3124
+ }
3125
+ if (typeof value === "object") {
3126
+ const o = value;
3127
+ const u = o.presigned_url || o.value;
3128
+ if (typeof u === "string" && /^https?:\/\//i.test(u)) return u;
3129
+ }
3130
+ return null;
3131
+ }
3112
3132
  var ImageUploadWidget = ({ fieldId }) => {
3113
3133
  const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
3114
3134
  const store = useFormStore();
@@ -3116,7 +3136,14 @@ var ImageUploadWidget = ({ fieldId }) => {
3116
3136
  const [isUploading, setIsUploading] = React15.useState(false);
3117
3137
  const [preview, setPreview] = React15.useState(null);
3118
3138
  const fileInputRef = React15.useRef(null);
3139
+ const blobUrlRef = React15.useRef(null);
3119
3140
  const showError = !!error && (touched || state.submitAttempted);
3141
+ const revokeTrackedBlob = () => {
3142
+ if (blobUrlRef.current) {
3143
+ URL.revokeObjectURL(blobUrlRef.current);
3144
+ blobUrlRef.current = null;
3145
+ }
3146
+ };
3120
3147
  if (!fieldDef) return null;
3121
3148
  const uploadHandler = store.getUploadHandler();
3122
3149
  if (!uploadHandler) {
@@ -3129,12 +3156,24 @@ var ImageUploadWidget = ({ fieldId }) => {
3129
3156
  ] });
3130
3157
  }
3131
3158
  React15__namespace.default.useEffect(() => {
3132
- if (value && typeof value === "string") {
3133
- setPreview(value);
3134
- } else {
3159
+ const displayUrl = extractImageDisplayUrl(value);
3160
+ if (displayUrl) {
3161
+ revokeTrackedBlob();
3162
+ setPreview(displayUrl);
3163
+ return;
3164
+ }
3165
+ if (value === null || value === void 0 || value === "") {
3166
+ revokeTrackedBlob();
3135
3167
  setPreview(null);
3168
+ return;
3136
3169
  }
3137
3170
  }, [value]);
3171
+ React15__namespace.default.useEffect(
3172
+ () => () => {
3173
+ revokeTrackedBlob();
3174
+ },
3175
+ []
3176
+ );
3138
3177
  const handleFileSelect = async (event) => {
3139
3178
  const file = event.target.files?.[0];
3140
3179
  if (!file) return;
@@ -3150,15 +3189,18 @@ var ImageUploadWidget = ({ fieldId }) => {
3150
3189
  setIsUploading(true);
3151
3190
  setTouched();
3152
3191
  store.incrementPendingUploads();
3192
+ revokeTrackedBlob();
3193
+ const previewUrl = URL.createObjectURL(file);
3194
+ blobUrlRef.current = previewUrl;
3195
+ setPreview(previewUrl);
3153
3196
  try {
3154
- const previewUrl = URL.createObjectURL(file);
3155
- setPreview(previewUrl);
3156
3197
  const s3Key = await uploadHandler(file, file.name);
3157
3198
  setValue(s3Key);
3158
3199
  } catch (error2) {
3159
3200
  console.error("Upload failed:", error2);
3160
3201
  const errorMessage = error2 instanceof Error ? error2.message : "Upload failed. Please try again.";
3161
3202
  alert(errorMessage);
3203
+ revokeTrackedBlob();
3162
3204
  setPreview(null);
3163
3205
  } finally {
3164
3206
  setIsUploading(false);
@@ -3166,6 +3208,7 @@ var ImageUploadWidget = ({ fieldId }) => {
3166
3208
  }
3167
3209
  };
3168
3210
  const handleRemove = () => {
3211
+ revokeTrackedBlob();
3169
3212
  setValue(null);
3170
3213
  setPreview(null);
3171
3214
  if (fileInputRef.current) {
@@ -3243,6 +3286,18 @@ function isAcceptedMediaFile(file) {
3243
3286
  if (file.name.toLowerCase().endsWith(".pdf")) return true;
3244
3287
  return false;
3245
3288
  }
3289
+ function extractMediaDisplayUrl(value) {
3290
+ if (value == null) return null;
3291
+ if (typeof value === "string") {
3292
+ return /^https?:\/\//i.test(value) ? value : null;
3293
+ }
3294
+ if (typeof value === "object") {
3295
+ const o = value;
3296
+ const u = o.presigned_url || o.value;
3297
+ if (typeof u === "string" && /^https?:\/\//i.test(u)) return u;
3298
+ }
3299
+ return null;
3300
+ }
3246
3301
  var MediaUploadWidget = ({ fieldId }) => {
3247
3302
  const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
3248
3303
  const store = useFormStore();
@@ -3252,7 +3307,14 @@ var MediaUploadWidget = ({ fieldId }) => {
3252
3307
  const [previewIsPdf, setPreviewIsPdf] = React15.useState(false);
3253
3308
  const fileInputRef = React15.useRef(null);
3254
3309
  const pendingPreviewKindRef = React15.useRef(null);
3310
+ const blobUrlRef = React15.useRef(null);
3255
3311
  const showError = !!error && (touched || state.submitAttempted);
3312
+ const revokeTrackedBlob = () => {
3313
+ if (blobUrlRef.current) {
3314
+ URL.revokeObjectURL(blobUrlRef.current);
3315
+ blobUrlRef.current = null;
3316
+ }
3317
+ };
3256
3318
  if (!fieldDef) return null;
3257
3319
  const uploadHandler = store.getUploadHandler();
3258
3320
  if (!uploadHandler) {
@@ -3265,19 +3327,32 @@ var MediaUploadWidget = ({ fieldId }) => {
3265
3327
  ] });
3266
3328
  }
3267
3329
  React15__namespace.default.useEffect(() => {
3268
- if (value && typeof value === "string") {
3269
- setPreview(value);
3330
+ const displayUrl = extractMediaDisplayUrl(value);
3331
+ if (displayUrl) {
3332
+ revokeTrackedBlob();
3333
+ setPreview(displayUrl);
3270
3334
  if (pendingPreviewKindRef.current) {
3271
3335
  setPreviewIsPdf(pendingPreviewKindRef.current === "pdf");
3272
3336
  pendingPreviewKindRef.current = null;
3273
3337
  } else {
3274
- setPreviewIsPdf(urlLooksLikePdf(value));
3338
+ setPreviewIsPdf(urlLooksLikePdf(displayUrl));
3275
3339
  }
3276
- } else {
3340
+ return;
3341
+ }
3342
+ if (value === null || value === void 0 || value === "") {
3343
+ revokeTrackedBlob();
3344
+ pendingPreviewKindRef.current = null;
3277
3345
  setPreview(null);
3278
3346
  setPreviewIsPdf(false);
3347
+ return;
3279
3348
  }
3280
3349
  }, [value]);
3350
+ React15__namespace.default.useEffect(
3351
+ () => () => {
3352
+ revokeTrackedBlob();
3353
+ },
3354
+ []
3355
+ );
3281
3356
  const handleFileSelect = async (event) => {
3282
3357
  const file = event.target.files?.[0];
3283
3358
  if (!file) return;
@@ -3294,10 +3369,12 @@ var MediaUploadWidget = ({ fieldId }) => {
3294
3369
  setIsUploading(true);
3295
3370
  setTouched();
3296
3371
  store.incrementPendingUploads();
3372
+ revokeTrackedBlob();
3373
+ const previewUrl = URL.createObjectURL(file);
3374
+ blobUrlRef.current = previewUrl;
3375
+ setPreview(previewUrl);
3376
+ setPreviewIsPdf(isPdf);
3297
3377
  try {
3298
- const previewUrl = URL.createObjectURL(file);
3299
- setPreview(previewUrl);
3300
- setPreviewIsPdf(isPdf);
3301
3378
  const s3Key = await uploadHandler(file, file.name);
3302
3379
  pendingPreviewKindRef.current = isPdf ? "pdf" : "image";
3303
3380
  setValue(s3Key);
@@ -3305,6 +3382,8 @@ var MediaUploadWidget = ({ fieldId }) => {
3305
3382
  console.error("Upload failed:", error2);
3306
3383
  const errorMessage = error2 instanceof Error ? error2.message : "Upload failed. Please try again.";
3307
3384
  alert(errorMessage);
3385
+ pendingPreviewKindRef.current = null;
3386
+ revokeTrackedBlob();
3308
3387
  setPreview(null);
3309
3388
  setPreviewIsPdf(false);
3310
3389
  } finally {
@@ -3314,6 +3393,7 @@ var MediaUploadWidget = ({ fieldId }) => {
3314
3393
  };
3315
3394
  const handleRemove = () => {
3316
3395
  pendingPreviewKindRef.current = null;
3396
+ revokeTrackedBlob();
3317
3397
  setValue(null);
3318
3398
  setPreview(null);
3319
3399
  setPreviewIsPdf(false);
@@ -4299,24 +4379,24 @@ function Spinner({
4299
4379
  value,
4300
4380
  onChange
4301
4381
  }) {
4302
- const num = parseInt(value, 10) || 0;
4382
+ const num2 = parseInt(value, 10) || 0;
4303
4383
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center", children: [
4304
4384
  /* @__PURE__ */ jsxRuntime.jsx(
4305
4385
  "button",
4306
4386
  {
4307
4387
  type: "button",
4308
4388
  className: "text-muted-foreground hover:text-foreground cursor-pointer",
4309
- onClick: () => onChange(String(num + 1)),
4389
+ onClick: () => onChange(String(num2 + 1)),
4310
4390
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, { className: "h-3 w-3" })
4311
4391
  }
4312
4392
  ),
4313
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm w-4 text-center leading-none", children: num }),
4393
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm w-4 text-center leading-none", children: num2 }),
4314
4394
  /* @__PURE__ */ jsxRuntime.jsx(
4315
4395
  "button",
4316
4396
  {
4317
4397
  type: "button",
4318
4398
  className: "text-muted-foreground hover:text-foreground cursor-pointer",
4319
- onClick: () => onChange(String(Math.max(0, num - 1))),
4399
+ onClick: () => onChange(String(Math.max(0, num2 - 1))),
4320
4400
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-3 w-3" })
4321
4401
  }
4322
4402
  )
@@ -5897,14 +5977,14 @@ var FollowupWidget = ({ fieldId }) => {
5897
5977
  const handleValueChange = React15.useCallback(
5898
5978
  (newValue) => {
5899
5979
  setTouched();
5900
- const num = parseInt(newValue, 10);
5980
+ const num2 = parseInt(newValue, 10);
5901
5981
  const min = displayUnit === "days" ? 0 : 1;
5902
- const valid = (Number.isNaN(num) ? min : num) >= min || newValue === "";
5982
+ const valid = (Number.isNaN(num2) ? min : num2) >= min || newValue === "";
5903
5983
  if (!valid && newValue !== "") {
5904
5984
  setValue({ followupType: "one time", value: String(displayUnit === "days" ? 0 : durationToDays(1, displayUnit)), unit: "days" });
5905
5985
  return;
5906
5986
  }
5907
- const days = durationToDays(Number.isNaN(num) ? displayUnit === "days" ? 0 : 1 : num, displayUnit);
5987
+ const days = durationToDays(Number.isNaN(num2) ? displayUnit === "days" ? 0 : 1 : num2, displayUnit);
5908
5988
  setValue({ followupType: "one time", value: String(days), unit: "days" });
5909
5989
  },
5910
5990
  [displayUnit, setValue, setTouched]
@@ -6441,14 +6521,22 @@ var Switch = React15__namespace.forwardRef(
6441
6521
  }
6442
6522
  );
6443
6523
  Switch.displayName = "Switch";
6524
+ var DEFAULT_MENSTRUAL = {
6525
+ menarche_age: 13,
6526
+ cycle_length: 28,
6527
+ flow_days: 4,
6528
+ cycle_regular: true,
6529
+ dysmenorrhea: 0
6530
+ };
6444
6531
  var DEFAULT_DRAFT = {
6445
6532
  gpal: { G: 0, P: 0, A: 0, L: 0 },
6446
6533
  lmp: "",
6447
- is_pregnant: false,
6534
+ pregnancy_status: "not_pregnant",
6448
6535
  eddUSG: "",
6449
6536
  primaryEDD: "lmp",
6450
6537
  complications: "",
6451
- outcome: null
6538
+ outcome: null,
6539
+ menstrual: { ...DEFAULT_MENSTRUAL }
6452
6540
  };
6453
6541
  function pad2(n) {
6454
6542
  return String(n).padStart(2, "0");
@@ -6481,6 +6569,33 @@ function clampInt(val, min, max) {
6481
6569
  if (!Number.isFinite(val)) return min;
6482
6570
  return Math.max(min, Math.min(max, Math.trunc(val)));
6483
6571
  }
6572
+ function clampDysmenorrhea(val) {
6573
+ const n = Math.round(Number(val));
6574
+ if (!Number.isFinite(n)) return 0;
6575
+ if (n <= 0) return 0;
6576
+ if (n >= 3) return 3;
6577
+ return n;
6578
+ }
6579
+ function isPregnancyStatus(x) {
6580
+ return x === "not_pregnant" || x === "pregnant" || x === "unknown";
6581
+ }
6582
+ function normalizeMenstrual(raw) {
6583
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
6584
+ return { ...DEFAULT_MENSTRUAL };
6585
+ }
6586
+ const o = raw;
6587
+ const num2 = (v, fb) => {
6588
+ const n = Number(v);
6589
+ return Number.isFinite(n) ? n : fb;
6590
+ };
6591
+ return {
6592
+ menarche_age: num2(o.menarche_age, DEFAULT_MENSTRUAL.menarche_age),
6593
+ cycle_length: num2(o.cycle_length, DEFAULT_MENSTRUAL.cycle_length),
6594
+ flow_days: num2(o.flow_days, DEFAULT_MENSTRUAL.flow_days),
6595
+ cycle_regular: typeof o.cycle_regular === "boolean" ? o.cycle_regular : DEFAULT_MENSTRUAL.cycle_regular,
6596
+ dysmenorrhea: clampDysmenorrhea(o.dysmenorrhea)
6597
+ };
6598
+ }
6484
6599
  function parseLegacyString(input) {
6485
6600
  const result = {};
6486
6601
  const gpalMatch = input.match(/G(\d+)\s*P(\d+)\s*A(\d+)\s*L(\d+)/i);
@@ -6510,6 +6625,11 @@ function normalizeToDraft(value) {
6510
6625
  const json = safeJsonParse(value);
6511
6626
  parsed = json ?? value;
6512
6627
  }
6628
+ const resolvePregnancyStatus = (o) => {
6629
+ if (isPregnancyStatus(o?.pregnancy_status)) return o.pregnancy_status;
6630
+ if (typeof o?.is_pregnant === "boolean") return o.is_pregnant ? "pregnant" : "not_pregnant";
6631
+ return "not_pregnant";
6632
+ };
6513
6633
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed) && "gpal" in parsed && parsed.gpal && typeof parsed.gpal === "object") {
6514
6634
  const gpal = parsed.gpal ?? {};
6515
6635
  const edd = parsed.edd ?? null;
@@ -6518,7 +6638,6 @@ function normalizeToDraft(value) {
6518
6638
  const lmp = parsed.lmp ?? "";
6519
6639
  const complications = parsed.complications ?? "";
6520
6640
  const outcome = parsed.outcome ?? null;
6521
- const is_pregnant = !!parsed.is_pregnant;
6522
6641
  return {
6523
6642
  isNewEntry: false,
6524
6643
  draft: {
@@ -6529,7 +6648,7 @@ function normalizeToDraft(value) {
6529
6648
  L: clampInt(Number(gpal.L ?? 0), 0, 20)
6530
6649
  },
6531
6650
  lmp: typeof lmp === "string" ? lmp : "",
6532
- is_pregnant,
6651
+ pregnancy_status: resolvePregnancyStatus(parsed),
6533
6652
  eddUSG: typeof eddUSG === "string" ? eddUSG : "",
6534
6653
  primaryEDD: primaryEDD === "usg" ? "usg" : "lmp",
6535
6654
  complications: typeof complications === "string" ? complications : "",
@@ -6538,7 +6657,8 @@ function normalizeToDraft(value) {
6538
6657
  date: typeof outcome.date === "string" ? outcome.date : "",
6539
6658
  notes: typeof outcome.notes === "string" ? outcome.notes : "",
6540
6659
  is_final: !!outcome.is_final
6541
- } : null
6660
+ } : null,
6661
+ menstrual: normalizeMenstrual(parsed.menstrual)
6542
6662
  }
6543
6663
  };
6544
6664
  }
@@ -6564,7 +6684,8 @@ function normalizeToDraft(value) {
6564
6684
  notes: typeof parsed.outcome.notes === "string" ? parsed.outcome.notes : "",
6565
6685
  is_final: !!parsed.outcome.is_final
6566
6686
  } : null,
6567
- is_pregnant: !!parsed.is_pregnant
6687
+ pregnancy_status: resolvePregnancyStatus(parsed),
6688
+ menstrual: normalizeMenstrual(parsed.menstrual)
6568
6689
  }
6569
6690
  };
6570
6691
  }
@@ -6615,16 +6736,18 @@ function computeTrimester(ga) {
6615
6736
  function buildStored(draft, today) {
6616
6737
  const lmpIso = isValidIsoDate(draft.lmp) ? draft.lmp : null;
6617
6738
  const eddUsgIso = isValidIsoDate(draft.eddUSG) ? draft.eddUSG : null;
6618
- if (!draft.is_pregnant) {
6739
+ if (draft.pregnancy_status !== "pregnant") {
6619
6740
  return {
6620
6741
  gpal: draft.gpal,
6621
6742
  lmp: lmpIso,
6622
6743
  is_pregnant: false,
6744
+ pregnancy_status: draft.pregnancy_status,
6623
6745
  edd: null,
6624
6746
  gestationalAge: null,
6625
6747
  trimester: null,
6626
6748
  complications: draft.complications.trim() ? draft.complications : null,
6627
- outcome: draft.outcome
6749
+ outcome: draft.outcome,
6750
+ menstrual: { ...draft.menstrual }
6628
6751
  };
6629
6752
  }
6630
6753
  const eddFromLmp = lmpIso ? computeEddFromLmp(lmpIso) : null;
@@ -6636,11 +6759,13 @@ function buildStored(draft, today) {
6636
6759
  gpal: draft.gpal,
6637
6760
  lmp: lmpIso,
6638
6761
  is_pregnant: true,
6762
+ pregnancy_status: "pregnant",
6639
6763
  edd: { lmp: eddFromLmp, usg: eddUsgIso, primary },
6640
6764
  gestationalAge: gaPrimary,
6641
6765
  trimester: computeTrimester(gaPrimary),
6642
6766
  complications: draft.complications.trim() ? draft.complications : null,
6643
- outcome: draft.outcome
6767
+ outcome: draft.outcome,
6768
+ menstrual: { ...draft.menstrual }
6644
6769
  };
6645
6770
  }
6646
6771
  function stripGpalSuffix(label) {
@@ -6685,7 +6810,8 @@ var ObstetricHistoryWidget = ({ fieldId }) => {
6685
6810
  };
6686
6811
  const commitDebounced = useDebouncedCommit(commitImmediate, 500);
6687
6812
  const storedComputed = React15.useMemo(() => buildStored(draft, today), [draft, today]);
6688
- const rightPanelEnabled = draft.is_pregnant && (!!storedComputed.lmp || !!storedComputed.edd?.usg);
6813
+ const isPregnant = draft.pregnancy_status === "pregnant";
6814
+ const rightPanelEnabled = isPregnant && (!!storedComputed.lmp || !!storedComputed.edd?.usg);
6689
6815
  const headerLabel = fieldDef?.label ? stripGpalSuffix(fieldDef.label) : "Obstetric History";
6690
6816
  const setDraft = (updater, persist) => {
6691
6817
  setDraftState((prev) => {
@@ -6723,10 +6849,13 @@ var ObstetricHistoryWidget = ({ fieldId }) => {
6723
6849
  setLmpError(null);
6724
6850
  setDraft((prev) => ({ ...prev, lmp: nextIso }), "debounce");
6725
6851
  };
6726
- const handlePregStatus = (isPregnant) => {
6852
+ const handlePregStatus = (status) => {
6727
6853
  setLmpError(null);
6728
6854
  setPrimaryEddError(null);
6729
- setDraft((prev) => ({ ...prev, is_pregnant: isPregnant }), "immediate");
6855
+ setDraft((prev) => ({ ...prev, pregnancy_status: status }), "immediate");
6856
+ };
6857
+ const setMenstrualPatch = (patch) => {
6858
+ setDraft((prev) => ({ ...prev, menstrual: { ...prev.menstrual, ...patch } }), "debounce");
6730
6859
  };
6731
6860
  const handleEddUsgChange = (nextIso) => {
6732
6861
  setPrimaryEddError(null);
@@ -6823,17 +6952,17 @@ var ObstetricHistoryWidget = ({ fieldId }) => {
6823
6952
  ),
6824
6953
  lmpError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-600", children: lmpError })
6825
6954
  ] }),
6826
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 rounded-lg border bg-white p-4", children: [
6955
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 rounded-lg border bg-white p-4 min-w-0", children: [
6827
6956
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-medium", children: "Pregnancy Status" }),
6828
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
6957
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-wrap gap-2", children: [
6829
6958
  /* @__PURE__ */ jsxRuntime.jsx(
6830
6959
  "button",
6831
6960
  {
6832
6961
  type: "button",
6833
- onClick: () => handlePregStatus(false),
6962
+ onClick: () => handlePregStatus("not_pregnant"),
6834
6963
  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"
6964
+ "shrink-0 rounded-full border px-3 py-1.5 text-[11px] font-medium transition-colors",
6965
+ 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
6966
  ),
6838
6967
  children: "Not Pregnant"
6839
6968
  }
@@ -6842,15 +6971,104 @@ var ObstetricHistoryWidget = ({ fieldId }) => {
6842
6971
  "button",
6843
6972
  {
6844
6973
  type: "button",
6845
- onClick: () => handlePregStatus(true),
6974
+ onClick: () => handlePregStatus("pregnant"),
6846
6975
  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"
6976
+ "shrink-0 rounded-full border px-3 py-1.5 text-[11px] font-medium transition-colors",
6977
+ 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
6978
  ),
6850
6979
  children: "Pregnant"
6851
6980
  }
6981
+ ),
6982
+ /* @__PURE__ */ jsxRuntime.jsx(
6983
+ "button",
6984
+ {
6985
+ type: "button",
6986
+ onClick: () => handlePregStatus("unknown"),
6987
+ className: cn(
6988
+ "shrink-0 rounded-full border px-3 py-1.5 text-[11px] font-medium transition-colors",
6989
+ draft.pregnancy_status === "unknown" ? "border-amber-500 bg-amber-500 text-white" : "border-slate-300 bg-white text-slate-700 hover:bg-slate-50"
6990
+ ),
6991
+ children: "Unknown"
6992
+ }
6993
+ )
6994
+ ] })
6995
+ ] })
6996
+ ] }),
6997
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border bg-white p-4", children: [
6998
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs font-medium text-muted-foreground mb-3", children: "Menstrual" }),
6999
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3 sm:grid-cols-4", children: [
7000
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
7001
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: `${fieldId}-menarche`, className: "text-[11px] text-muted-foreground", children: "Menarche (age)" }),
7002
+ /* @__PURE__ */ jsxRuntime.jsx(
7003
+ Input,
7004
+ {
7005
+ id: `${fieldId}-menarche`,
7006
+ type: "number",
7007
+ min: 5,
7008
+ max: 25,
7009
+ value: draft.menstrual.menarche_age,
7010
+ onChange: (e) => setMenstrualPatch({ menarche_age: Number(e.target.value) || 0 })
7011
+ }
7012
+ )
7013
+ ] }),
7014
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
7015
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: `${fieldId}-cycle-length`, className: "text-[11px] text-muted-foreground", children: "Cycle (days)" }),
7016
+ /* @__PURE__ */ jsxRuntime.jsx(
7017
+ Input,
7018
+ {
7019
+ id: `${fieldId}-cycle-length`,
7020
+ type: "number",
7021
+ min: 0,
7022
+ max: 120,
7023
+ value: draft.menstrual.cycle_length,
7024
+ onChange: (e) => setMenstrualPatch({ cycle_length: Number(e.target.value) || 0 })
7025
+ }
7026
+ )
7027
+ ] }),
7028
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
7029
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: `${fieldId}-flow-days`, className: "text-[11px] text-muted-foreground", children: "Flow (days)" }),
7030
+ /* @__PURE__ */ jsxRuntime.jsx(
7031
+ Input,
7032
+ {
7033
+ id: `${fieldId}-flow-days`,
7034
+ type: "number",
7035
+ min: 0,
7036
+ max: 30,
7037
+ value: draft.menstrual.flow_days,
7038
+ onChange: (e) => setMenstrualPatch({ flow_days: Number(e.target.value) || 0 })
7039
+ }
7040
+ )
7041
+ ] }),
7042
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
7043
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-[11px] text-muted-foreground", children: "Dysmenorrhea" }),
7044
+ /* @__PURE__ */ jsxRuntime.jsxs(
7045
+ "select",
7046
+ {
7047
+ className: "h-9 w-full rounded-md border border-input bg-background px-2 text-sm",
7048
+ value: String(draft.menstrual.dysmenorrhea),
7049
+ onChange: (e) => setMenstrualPatch({
7050
+ dysmenorrhea: clampDysmenorrhea(Number(e.target.value))
7051
+ }),
7052
+ children: [
7053
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "0", children: "0 \u2014 none" }),
7054
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "1", children: "1 \u2014 mild" }),
7055
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "2", children: "2 \u2014 moderate" }),
7056
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "3", children: "3 \u2014 severe" })
7057
+ ]
7058
+ }
6852
7059
  )
6853
7060
  ] })
7061
+ ] }),
7062
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "mt-3 flex items-center gap-2 text-sm", children: [
7063
+ /* @__PURE__ */ jsxRuntime.jsx(
7064
+ "input",
7065
+ {
7066
+ type: "checkbox",
7067
+ checked: draft.menstrual.cycle_regular,
7068
+ onChange: (e) => setMenstrualPatch({ cycle_regular: e.target.checked })
7069
+ }
7070
+ ),
7071
+ "Regular cycle"
6854
7072
  ] })
6855
7073
  ] }),
6856
7074
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 rounded-lg border bg-white p-4", children: [
@@ -6868,9 +7086,9 @@ var ObstetricHistoryWidget = ({ fieldId }) => {
6868
7086
  ] })
6869
7087
  ] }),
6870
7088
  /* @__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: [
7089
+ !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' }),
7090
+ 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." }),
7091
+ isPregnant && rightPanelEnabled && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
6874
7092
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border p-4", children: [
6875
7093
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
6876
7094
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-semibold text-blue-700", children: "Expected Delivery Date (EDD)" }),
@@ -9952,7 +10170,7 @@ var SliderWidget = ({ fieldId }) => {
9952
10170
  const max = def.max ?? 10;
9953
10171
  const step = def.step ?? 1;
9954
10172
  const raw = value == null || value === "" ? min : Number(value);
9955
- const num = Number.isFinite(raw) ? Math.min(max, Math.max(min, raw)) : min;
10173
+ const num2 = Number.isFinite(raw) ? Math.min(max, Math.max(min, raw)) : min;
9956
10174
  const theme = getThemeConfig("textarea", def.theme);
9957
10175
  const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
9958
10176
  const labelClass = theme?.labelClassName;
@@ -9961,7 +10179,7 @@ var SliderWidget = ({ fieldId }) => {
9961
10179
  " ",
9962
10180
  def.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" }),
9963
10181
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-2 text-muted-foreground font-normal tabular-nums", children: [
9964
- num,
10182
+ num2,
9965
10183
  "/",
9966
10184
  max
9967
10185
  ] })
@@ -9977,7 +10195,7 @@ var SliderWidget = ({ fieldId }) => {
9977
10195
  min,
9978
10196
  max,
9979
10197
  step,
9980
- value: [num],
10198
+ value: [num2],
9981
10199
  onValueChange: (v) => {
9982
10200
  const n = v[0] ?? min;
9983
10201
  setValue(n);
@@ -10979,8 +11197,10 @@ var PainScaleFlagsWidget = ({ fieldId }) => {
10979
11197
  const sel = safe.flags;
10980
11198
  const isSelected = isFlagSelected(sel, optValue);
10981
11199
  const nextFlags = isSelected ? sel.filter((v) => v !== optValue && String(v) !== String(optValue)) : [...sel, String(optValue)];
10982
- update({ pain: safe.pain, flags: nextFlags });
11200
+ update({ pain: safe.pain, flags: nextFlags, bp: safe.bp, upt: safe.upt });
10983
11201
  };
11202
+ const setBp = (bp) => update({ pain: safe.pain, flags: safe.flags, bp, upt: safe.upt });
11203
+ const setUpt = (upt) => update({ pain: safe.pain, flags: safe.flags, bp: safe.bp, upt });
10984
11204
  const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10985
11205
  def.label,
10986
11206
  " ",
@@ -11015,7 +11235,7 @@ var PainScaleFlagsWidget = ({ fieldId }) => {
11015
11235
  value: [safe.pain],
11016
11236
  onValueChange: (v) => {
11017
11237
  const n = v[0] ?? min;
11018
- update({ pain: n, flags: safe.flags });
11238
+ update({ pain: n, flags: safe.flags, bp: safe.bp, upt: safe.upt });
11019
11239
  }
11020
11240
  }
11021
11241
  )
@@ -11041,6 +11261,42 @@ var PainScaleFlagsWidget = ({ fieldId }) => {
11041
11261
  }
11042
11262
  )
11043
11263
  ] }, String(opt.value))) })
11264
+ ] }) : null,
11265
+ def.showBp || def.showUpt ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-3 pt-1 sm:grid-cols-2", children: [
11266
+ def.showBp ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
11267
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: `${fieldId}-bp`, className: "text-sm font-medium text-slate-700", children: "BP recorded" }),
11268
+ /* @__PURE__ */ jsxRuntime.jsx(
11269
+ Input,
11270
+ {
11271
+ id: `${fieldId}-bp`,
11272
+ value: safe.bp ?? "",
11273
+ onChange: (e) => setBp(e.target.value),
11274
+ placeholder: "e.g. 130/86",
11275
+ disabled,
11276
+ className: "h-8 text-xs"
11277
+ }
11278
+ )
11279
+ ] }) : null,
11280
+ def.showUpt ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
11281
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium text-slate-700", children: "UPT (if reproductive age)" }),
11282
+ /* @__PURE__ */ jsxRuntime.jsxs(
11283
+ Select,
11284
+ {
11285
+ value: safe.upt ? safe.upt : "none",
11286
+ onValueChange: (val) => setUpt(val === "none" ? "" : val),
11287
+ disabled,
11288
+ children: [
11289
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
11290
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
11291
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
11292
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Positive", children: "Positive" }),
11293
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Negative", children: "Negative" }),
11294
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Not done", children: "Not done" })
11295
+ ] })
11296
+ ]
11297
+ }
11298
+ )
11299
+ ] }) : null
11044
11300
  ] }) : null
11045
11301
  ] }) }),
11046
11302
  showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
@@ -11888,125 +12144,1758 @@ var UrologyPathwayWidget = ({ fieldId }) => {
11888
12144
  ] })
11889
12145
  ] });
11890
12146
  };
11891
- var FieldRenderer = ({ fieldId }) => {
11892
- const { fieldDef, visible } = useField(fieldId);
11893
- if (!visible || !fieldDef) {
11894
- return null;
11895
- }
11896
- return renderWidget(fieldId, fieldDef);
12147
+
12148
+ // src/core/obgPathway.ts
12149
+ var UTERUS_SIZES = ["", "Normal", "Bulky", "Enlarged"];
12150
+ function bool2(x) {
12151
+ return x === true;
12152
+ }
12153
+ function str4(x) {
12154
+ return typeof x === "string" ? x : "";
12155
+ }
12156
+ function defaultObgExamination() {
12157
+ return {
12158
+ general: {
12159
+ pallor: false,
12160
+ oedema: false,
12161
+ thyroid: false,
12162
+ hirsutism: false,
12163
+ acanthosis: false
12164
+ },
12165
+ abdomen: { surgicalScars: false, massTenderness: false },
12166
+ breast: { lump: false, nippleDischarge: false, skinChanges: false, axillaryNodes: false },
12167
+ pelvic: {
12168
+ speculumDone: false,
12169
+ discharge: false,
12170
+ cervicalErosion: false,
12171
+ cervicalGrowth: false,
12172
+ activeBleeding: false,
12173
+ bimanualDone: false,
12174
+ adnexalMass: false,
12175
+ cmt: false
12176
+ },
12177
+ uterusSize: "",
12178
+ examinationNotes: ""
12179
+ };
12180
+ }
12181
+ function normalizeObgExamination(raw) {
12182
+ const base = defaultObgExamination();
12183
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return base;
12184
+ const o = raw;
12185
+ const g = o.general && typeof o.general === "object" ? o.general : {};
12186
+ const a = o.abdomen && typeof o.abdomen === "object" ? o.abdomen : {};
12187
+ const b = o.breast && typeof o.breast === "object" ? o.breast : {};
12188
+ const p = o.pelvic && typeof o.pelvic === "object" ? o.pelvic : {};
12189
+ const us = str4(o.uterusSize);
12190
+ return {
12191
+ general: {
12192
+ pallor: bool2(g.pallor),
12193
+ oedema: bool2(g.oedema),
12194
+ thyroid: bool2(g.thyroid),
12195
+ hirsutism: bool2(g.hirsutism),
12196
+ acanthosis: bool2(g.acanthosis)
12197
+ },
12198
+ abdomen: {
12199
+ surgicalScars: bool2(a.surgicalScars),
12200
+ massTenderness: bool2(a.massTenderness)
12201
+ },
12202
+ breast: {
12203
+ lump: bool2(b.lump),
12204
+ nippleDischarge: bool2(b.nippleDischarge),
12205
+ skinChanges: bool2(b.skinChanges),
12206
+ axillaryNodes: bool2(b.axillaryNodes)
12207
+ },
12208
+ pelvic: {
12209
+ speculumDone: bool2(p.speculumDone),
12210
+ discharge: bool2(p.discharge),
12211
+ cervicalErosion: bool2(p.cervicalErosion),
12212
+ cervicalGrowth: bool2(p.cervicalGrowth),
12213
+ activeBleeding: bool2(p.activeBleeding),
12214
+ bimanualDone: bool2(p.bimanualDone),
12215
+ adnexalMass: bool2(p.adnexalMass),
12216
+ cmt: bool2(p.cmt)
12217
+ },
12218
+ uterusSize: UTERUS_SIZES.includes(us) ? us : "",
12219
+ examinationNotes: str4(o.examinationNotes)
12220
+ };
12221
+ }
12222
+ var GENERAL_LABELS = {
12223
+ pallor: "Pallor",
12224
+ oedema: "Oedema",
12225
+ thyroid: "Thyroid",
12226
+ hirsutism: "Hirsutism",
12227
+ acanthosis: "Acanthosis"
11897
12228
  };
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
- ] });
12229
+ var ABDOMEN_LABELS = {
12230
+ surgicalScars: "Surgical scars",
12231
+ massTenderness: "Mass / tenderness"
12232
+ };
12233
+ var BREAST_LABELS = {
12234
+ lump: "Lump",
12235
+ nippleDischarge: "Nipple discharge",
12236
+ skinChanges: "Skin changes",
12237
+ axillaryNodes: "Axillary nodes"
12238
+ };
12239
+ var PELVIC_LABELS = {
12240
+ speculumDone: "Speculum done",
12241
+ discharge: "Discharge",
12242
+ cervicalErosion: "Cervical erosion",
12243
+ cervicalGrowth: "Cervical growth",
12244
+ activeBleeding: "Active bleeding",
12245
+ bimanualDone: "Bimanual done",
12246
+ adnexalMass: "Adnexal mass",
12247
+ cmt: "Cervical motion tenderness"
12248
+ };
12249
+ function pickLabels(group, labels) {
12250
+ return Object.keys(labels).filter((k) => group[k]).map((k) => labels[k]);
12251
+ }
12252
+ function formatObgExaminationToClinicalExamination(v) {
12253
+ const lines = [];
12254
+ const general = pickLabels(v.general, GENERAL_LABELS);
12255
+ if (general.length) lines.push(`General: ${general.join(", ")}`);
12256
+ const abd = pickLabels(v.abdomen, ABDOMEN_LABELS);
12257
+ if (abd.length) lines.push(`Abdomen: ${abd.join(", ")}`);
12258
+ const breast = pickLabels(v.breast, BREAST_LABELS);
12259
+ if (breast.length) lines.push(`Breast: ${breast.join(", ")}`);
12260
+ const pelvic = pickLabels(v.pelvic, PELVIC_LABELS);
12261
+ let pelvicLine = pelvic.length ? `Pelvic: ${pelvic.join(", ")}` : "";
12262
+ if (v.pelvic.bimanualDone && v.uterusSize) {
12263
+ pelvicLine = pelvicLine ? `${pelvicLine} \u2014 uterus ${v.uterusSize.toLowerCase()}` : `Pelvic: uterus ${v.uterusSize.toLowerCase()}`;
12264
+ }
12265
+ if (pelvicLine) lines.push(pelvicLine);
12266
+ return lines.join("\n");
12267
+ }
12268
+ var OBG_ZONE_ORDER = [
12269
+ "menstrual_reproductive",
12270
+ "antenatal",
12271
+ "gynaecological",
12272
+ "obstetric",
12273
+ "infertility",
12274
+ "postoperative"
12275
+ ];
12276
+ var OBG_ZONE_SET = new Set(OBG_ZONE_ORDER);
12277
+ function coerceZones(raw) {
12278
+ const list = [];
12279
+ const push = (x) => {
12280
+ if (typeof x === "string" && OBG_ZONE_SET.has(x) && !list.includes(x)) {
12281
+ list.push(x);
11997
12282
  }
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": {
12283
+ };
12284
+ if (Array.isArray(raw)) raw.forEach(push);
12285
+ else push(raw);
12286
+ return list.sort((a, b) => OBG_ZONE_ORDER.indexOf(a) - OBG_ZONE_ORDER.indexOf(b));
12287
+ }
12288
+ function num(x, fallback = 0) {
12289
+ const n = Number(x);
12290
+ return Number.isFinite(n) ? n : fallback;
12291
+ }
12292
+ function clampDysmenorrhea2(x) {
12293
+ const n = Math.round(num(x, 0));
12294
+ if (n <= 0) return 0;
12295
+ if (n >= 3) return 3;
12296
+ return n;
12297
+ }
12298
+ function defaultObgPathway() {
12299
+ return {
12300
+ zones: [],
12301
+ menstrual: {
12302
+ menarcheAge: 13,
12303
+ cycleLength: 28,
12304
+ flowDays: 4,
12305
+ cycleRegular: true,
12306
+ dysmenorrhea: 0,
12307
+ amount: "",
12308
+ lmp: "",
12309
+ menopauseStatus: ""
12310
+ },
12311
+ antenatal: {
12312
+ gravida: 0,
12313
+ gaWeeksLmp: 0,
12314
+ gaDaysLmp: 0,
12315
+ gaWeeksUsg: 0,
12316
+ gaDaysUsg: 0,
12317
+ edd: "",
12318
+ riskCategory: "",
12319
+ symptoms: {
12320
+ nauseaVomiting: false,
12321
+ bleedingPV: false,
12322
+ painAbdomen: false,
12323
+ decreasedFetalMovements: false
12324
+ },
12325
+ exam: {
12326
+ weightKg: 0,
12327
+ heightCm: 0,
12328
+ bmi: 0,
12329
+ bp: "",
12330
+ pallor: false,
12331
+ oedema: false,
12332
+ fundalHeightCm: 0,
12333
+ fhrBpm: 0,
12334
+ presentation: "",
12335
+ lie: ""
12336
+ },
12337
+ investigations: {
12338
+ bloodGroup: "",
12339
+ cbc: "",
12340
+ tsh: "",
12341
+ rbsOgtt: "",
12342
+ serology: "",
12343
+ urine: "",
12344
+ usg: ""
12345
+ }
12346
+ },
12347
+ gynae: {
12348
+ symptoms: {
12349
+ aub: false,
12350
+ whiteDischarge: false,
12351
+ pelvicPain: false,
12352
+ dyspareunia: false,
12353
+ urinaryComplaints: false,
12354
+ prolapse: false
12355
+ }
12356
+ },
12357
+ obstetric: [],
12358
+ infertility: {
12359
+ type: "",
12360
+ durationMonths: 0,
12361
+ previousTreatments: "",
12362
+ female: { ovulation: "", pcosFeatures: false, endometriosisSuspicion: false },
12363
+ male: { age: 0, semenAnalysis: "" },
12364
+ investigations: { amh: "", fshLh: "", prolactin: "", tsh: "", tvs: "", hsg: "" }
12365
+ },
12366
+ postop: {
12367
+ surgeryDate: "",
12368
+ procedure: "",
12369
+ histopathology: "",
12370
+ woundStatus: "",
12371
+ painScore: 0,
12372
+ complications: ""
12373
+ }
12374
+ };
12375
+ }
12376
+ function normalizeObgPathway(raw) {
12377
+ const base = defaultObgPathway();
12378
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return base;
12379
+ const o = raw;
12380
+ const zones = coerceZones(o.zones ?? o.zone);
12381
+ const m = o.menstrual && typeof o.menstrual === "object" ? o.menstrual : {};
12382
+ const a = o.antenatal && typeof o.antenatal === "object" ? o.antenatal : {};
12383
+ const aSym = a.symptoms && typeof a.symptoms === "object" ? a.symptoms : {};
12384
+ const aExam = a.exam && typeof a.exam === "object" ? a.exam : {};
12385
+ const aInv = a.investigations && typeof a.investigations === "object" ? a.investigations : {};
12386
+ const g = o.gynae && typeof o.gynae === "object" ? o.gynae : {};
12387
+ const gSym = g.symptoms && typeof g.symptoms === "object" ? g.symptoms : {};
12388
+ const inf = o.infertility && typeof o.infertility === "object" ? o.infertility : {};
12389
+ const infF = inf.female && typeof inf.female === "object" ? inf.female : {};
12390
+ const infM = inf.male && typeof inf.male === "object" ? inf.male : {};
12391
+ const infInv = inf.investigations && typeof inf.investigations === "object" ? inf.investigations : {};
12392
+ const po = o.postop && typeof o.postop === "object" ? o.postop : {};
12393
+ const obstetricRows = Array.isArray(o.obstetric) ? o.obstetric.map((row) => {
12394
+ const r = row && typeof row === "object" ? row : {};
12395
+ const mode = str4(r.mode);
12396
+ return {
12397
+ year: str4(r.year),
12398
+ ga: str4(r.ga),
12399
+ mode: ["", "NVD", "LSCS", "Instrumental", "Abortion", "Stillbirth"].includes(mode) ? mode : "",
12400
+ indicationLscs: str4(r.indicationLscs),
12401
+ babyOutcome: str4(r.babyOutcome),
12402
+ complications: str4(r.complications)
12403
+ };
12404
+ }) : [];
12405
+ return {
12406
+ zones,
12407
+ menstrual: {
12408
+ menarcheAge: num(m.menarcheAge, base.menstrual.menarcheAge),
12409
+ cycleLength: num(m.cycleLength, base.menstrual.cycleLength),
12410
+ flowDays: num(m.flowDays, base.menstrual.flowDays),
12411
+ cycleRegular: m.cycleRegular === void 0 ? base.menstrual.cycleRegular : bool2(m.cycleRegular),
12412
+ dysmenorrhea: clampDysmenorrhea2(m.dysmenorrhea),
12413
+ amount: ["", "Scanty", "Normal", "Heavy"].includes(str4(m.amount)) ? str4(m.amount) : "",
12414
+ lmp: str4(m.lmp),
12415
+ menopauseStatus: ["", "Pre", "Peri", "Post"].includes(str4(m.menopauseStatus)) ? str4(m.menopauseStatus) : ""
12416
+ },
12417
+ antenatal: {
12418
+ gravida: num(a.gravida),
12419
+ gaWeeksLmp: num(a.gaWeeksLmp),
12420
+ gaDaysLmp: num(a.gaDaysLmp),
12421
+ gaWeeksUsg: num(a.gaWeeksUsg),
12422
+ gaDaysUsg: num(a.gaDaysUsg),
12423
+ edd: str4(a.edd),
12424
+ riskCategory: ["", "Low", "High"].includes(str4(a.riskCategory)) ? str4(a.riskCategory) : "",
12425
+ symptoms: {
12426
+ nauseaVomiting: bool2(aSym.nauseaVomiting),
12427
+ bleedingPV: bool2(aSym.bleedingPV),
12428
+ painAbdomen: bool2(aSym.painAbdomen),
12429
+ decreasedFetalMovements: bool2(aSym.decreasedFetalMovements)
12430
+ },
12431
+ exam: {
12432
+ weightKg: num(aExam.weightKg),
12433
+ heightCm: num(aExam.heightCm),
12434
+ bmi: num(aExam.bmi),
12435
+ bp: str4(aExam.bp),
12436
+ pallor: bool2(aExam.pallor),
12437
+ oedema: bool2(aExam.oedema),
12438
+ fundalHeightCm: num(aExam.fundalHeightCm),
12439
+ fhrBpm: num(aExam.fhrBpm),
12440
+ presentation: ["", "Cephalic", "Breech", "Other"].includes(str4(aExam.presentation)) ? str4(aExam.presentation) : "",
12441
+ lie: ["", "Longitudinal", "Transverse", "Oblique"].includes(str4(aExam.lie)) ? str4(aExam.lie) : ""
12442
+ },
12443
+ investigations: {
12444
+ bloodGroup: str4(aInv.bloodGroup),
12445
+ cbc: ["", "Done", "Pending", "Abnormal"].includes(str4(aInv.cbc)) ? str4(aInv.cbc) : "",
12446
+ tsh: ["", "Done", "Pending", "Abnormal"].includes(str4(aInv.tsh)) ? str4(aInv.tsh) : "",
12447
+ rbsOgtt: ["", "Done", "Pending", "Abnormal"].includes(str4(aInv.rbsOgtt)) ? str4(aInv.rbsOgtt) : "",
12448
+ serology: ["", "Done", "Pending", "Abnormal"].includes(str4(aInv.serology)) ? str4(aInv.serology) : "",
12449
+ urine: ["", "Done", "Pending", "Abnormal"].includes(str4(aInv.urine)) ? str4(aInv.urine) : "",
12450
+ usg: ["", "Dating", "NT", "Anomaly", "Growth", "Pending"].includes(str4(aInv.usg)) ? str4(aInv.usg) : ""
12451
+ }
12452
+ },
12453
+ gynae: {
12454
+ symptoms: {
12455
+ aub: bool2(gSym.aub),
12456
+ whiteDischarge: bool2(gSym.whiteDischarge),
12457
+ pelvicPain: bool2(gSym.pelvicPain),
12458
+ dyspareunia: bool2(gSym.dyspareunia),
12459
+ urinaryComplaints: bool2(gSym.urinaryComplaints),
12460
+ prolapse: bool2(gSym.prolapse)
12461
+ }
12462
+ },
12463
+ obstetric: obstetricRows,
12464
+ infertility: {
12465
+ type: ["", "Primary", "Secondary"].includes(str4(inf.type)) ? str4(inf.type) : "",
12466
+ durationMonths: num(inf.durationMonths),
12467
+ previousTreatments: str4(inf.previousTreatments),
12468
+ female: {
12469
+ ovulation: ["", "Ovulatory", "Anovulatory", "Unknown"].includes(str4(infF.ovulation)) ? str4(infF.ovulation) : "",
12470
+ pcosFeatures: bool2(infF.pcosFeatures),
12471
+ endometriosisSuspicion: bool2(infF.endometriosisSuspicion)
12472
+ },
12473
+ male: {
12474
+ age: num(infM.age),
12475
+ semenAnalysis: ["", "Normal", "Abnormal", "Pending"].includes(str4(infM.semenAnalysis)) ? str4(infM.semenAnalysis) : ""
12476
+ },
12477
+ investigations: {
12478
+ amh: str4(infInv.amh),
12479
+ fshLh: str4(infInv.fshLh),
12480
+ prolactin: str4(infInv.prolactin),
12481
+ tsh: str4(infInv.tsh),
12482
+ tvs: str4(infInv.tvs),
12483
+ hsg: str4(infInv.hsg)
12484
+ }
12485
+ },
12486
+ postop: {
12487
+ surgeryDate: str4(po.surgeryDate),
12488
+ procedure: str4(po.procedure),
12489
+ histopathology: str4(po.histopathology),
12490
+ woundStatus: ["", "Healthy", "Erythema", "Discharge", "Dehisced"].includes(str4(po.woundStatus)) ? str4(po.woundStatus) : "",
12491
+ painScore: Math.max(0, Math.min(10, num(po.painScore))),
12492
+ complications: str4(po.complications)
12493
+ }
12494
+ };
12495
+ }
12496
+ var ZONE_LABELS = {
12497
+ menstrual_reproductive: "Menstrual & reproductive",
12498
+ antenatal: "Antenatal",
12499
+ gynaecological: "Gynaecological",
12500
+ obstetric: "Obstetric",
12501
+ infertility: "Infertility",
12502
+ postoperative: "Post-operative"
12503
+ };
12504
+ function obgZoneLabel(zone) {
12505
+ return ZONE_LABELS[zone];
12506
+ }
12507
+ function nonEmpty(parts) {
12508
+ return parts.map((s) => (s ?? "").trim()).filter(Boolean);
12509
+ }
12510
+ function formatMenstrualBlock(m) {
12511
+ const bits = nonEmpty([
12512
+ m.menarcheAge ? `menarche ${m.menarcheAge}y` : "",
12513
+ m.cycleLength ? `cycle ${m.cycleLength}d` : "",
12514
+ m.flowDays ? `flow ${m.flowDays}d` : "",
12515
+ m.cycleRegular ? "regular" : "irregular",
12516
+ m.amount ? `flow ${m.amount.toLowerCase()}` : "",
12517
+ m.dysmenorrhea ? `dysmenorrhea grade ${m.dysmenorrhea}` : "",
12518
+ m.lmp ? `LMP ${m.lmp}` : "",
12519
+ m.menopauseStatus ? `${m.menopauseStatus.toLowerCase()}menopausal` : ""
12520
+ ]);
12521
+ return bits.length ? `Menstrual: ${bits.join(", ")}` : "";
12522
+ }
12523
+ function formatAntenatalBlock(a) {
12524
+ const lines = [];
12525
+ const head = nonEmpty([
12526
+ a.gravida ? `G${a.gravida}` : "",
12527
+ a.gaWeeksLmp || a.gaDaysLmp ? `GA(LMP) ${a.gaWeeksLmp}w ${a.gaDaysLmp}d` : "",
12528
+ a.gaWeeksUsg || a.gaDaysUsg ? `GA(USG) ${a.gaWeeksUsg}w ${a.gaDaysUsg}d` : "",
12529
+ a.edd ? `EDD ${a.edd}` : "",
12530
+ a.riskCategory ? `${a.riskCategory} risk` : ""
12531
+ ]);
12532
+ if (head.length) lines.push(`Antenatal: ${head.join(", ")}`);
12533
+ const sym = nonEmpty([
12534
+ a.symptoms.nauseaVomiting ? "nausea/vomiting" : "",
12535
+ a.symptoms.bleedingPV ? "bleeding PV" : "",
12536
+ a.symptoms.painAbdomen ? "pain abdomen" : "",
12537
+ a.symptoms.decreasedFetalMovements ? "decreased fetal movements" : ""
12538
+ ]);
12539
+ if (sym.length) lines.push(`Antenatal symptoms: ${sym.join(", ")}`);
12540
+ return lines.join("\n");
12541
+ }
12542
+ function formatGynaeBlock(g) {
12543
+ const sym = nonEmpty([
12544
+ g.symptoms.aub ? "AUB" : "",
12545
+ g.symptoms.whiteDischarge ? "white discharge" : "",
12546
+ g.symptoms.pelvicPain ? "pelvic pain" : "",
12547
+ g.symptoms.dyspareunia ? "dyspareunia" : "",
12548
+ g.symptoms.urinaryComplaints ? "urinary complaints" : "",
12549
+ g.symptoms.prolapse ? "prolapse" : ""
12550
+ ]);
12551
+ return sym.length ? `Gynae symptoms: ${sym.join(", ")}` : "";
12552
+ }
12553
+ function formatObstetricBlock(rows) {
12554
+ if (!rows.length) return "";
12555
+ const summary = rows.map((r) => nonEmpty([r.year, r.ga, r.mode, r.babyOutcome]).join(" / ")).filter(Boolean).join("; ");
12556
+ return summary ? `Obstetric history (${rows.length}): ${summary}` : "";
12557
+ }
12558
+ function formatInfertilityBlock(i) {
12559
+ const bits = nonEmpty([
12560
+ i.type ? `${i.type} infertility` : "",
12561
+ i.durationMonths ? `${i.durationMonths} months` : "",
12562
+ i.female.pcosFeatures ? "PCOS features" : "",
12563
+ i.female.endometriosisSuspicion ? "endometriosis suspicion" : "",
12564
+ i.female.ovulation ? `ovulation: ${i.female.ovulation}` : "",
12565
+ i.male.semenAnalysis ? `semen: ${i.male.semenAnalysis}` : ""
12566
+ ]);
12567
+ return bits.length ? `Infertility: ${bits.join(", ")}` : "";
12568
+ }
12569
+ function formatPostOpBlock(p) {
12570
+ const bits = nonEmpty([
12571
+ p.surgeryDate ? `op ${p.surgeryDate}` : "",
12572
+ p.procedure || "",
12573
+ p.woundStatus ? `wound ${p.woundStatus.toLowerCase()}` : "",
12574
+ p.painScore ? `pain ${p.painScore}/10` : "",
12575
+ p.complications ? `complications: ${p.complications}` : ""
12576
+ ]);
12577
+ return bits.length ? `Post-op: ${bits.join(", ")}` : "";
12578
+ }
12579
+ var ZONE_FORMATTERS = {
12580
+ menstrual_reproductive: (v) => formatMenstrualBlock(v.menstrual),
12581
+ antenatal: (v) => formatAntenatalBlock(v.antenatal),
12582
+ gynaecological: (v) => formatGynaeBlock(v.gynae),
12583
+ obstetric: (v) => formatObstetricBlock(v.obstetric),
12584
+ infertility: (v) => formatInfertilityBlock(v.infertility),
12585
+ postoperative: (v) => formatPostOpBlock(v.postop)
12586
+ };
12587
+ function formatObgPathwayToSymptomsNarrative(v) {
12588
+ if (!v.zones.length) return "";
12589
+ const sections = [`Pathway: ${v.zones.map(obgZoneLabel).join(", ")}`];
12590
+ for (const z of v.zones) {
12591
+ const block = ZONE_FORMATTERS[z](v).trim();
12592
+ if (block) sections.push(block);
12593
+ }
12594
+ return sections.join("\n\n");
12595
+ }
12596
+ var CLINICAL_EXAMINATION_FIELD = "clinical_examination";
12597
+ var GENERAL_ROWS2 = [
12598
+ { key: "pallor", label: "Pallor" },
12599
+ { key: "oedema", label: "Oedema" },
12600
+ { key: "thyroid", label: "Thyroid" },
12601
+ { key: "hirsutism", label: "Hirsutism" },
12602
+ { key: "acanthosis", label: "Acanthosis" }
12603
+ ];
12604
+ var ABDOMEN_ROWS = [
12605
+ { key: "surgicalScars", label: "Surgical scars" },
12606
+ { key: "massTenderness", label: "Mass / tenderness" }
12607
+ ];
12608
+ var BREAST_ROWS = [
12609
+ { key: "lump", label: "Lump" },
12610
+ { key: "nippleDischarge", label: "Nipple discharge" },
12611
+ { key: "skinChanges", label: "Skin changes" },
12612
+ { key: "axillaryNodes", label: "Axillary nodes" }
12613
+ ];
12614
+ var PELVIC_ROWS = [
12615
+ { key: "speculumDone", label: "Speculum done" },
12616
+ { key: "discharge", label: "Discharge" },
12617
+ { key: "cervicalErosion", label: "Cervical erosion" },
12618
+ { key: "cervicalGrowth", label: "Cervical growth" },
12619
+ { key: "activeBleeding", label: "Active bleeding" },
12620
+ { key: "bimanualDone", label: "Bimanual done" },
12621
+ { key: "adnexalMass", label: "Adnexal mass" },
12622
+ { key: "cmt", label: "Cervical motion tenderness" }
12623
+ ];
12624
+ var UTERUS_OPTIONS = [
12625
+ { value: "", label: "\u2014" },
12626
+ { value: "Normal", label: "Normal" },
12627
+ { value: "Bulky", label: "Bulky" },
12628
+ { value: "Enlarged", label: "Enlarged" }
12629
+ ];
12630
+ var OBGExaminationWidget = ({ fieldId }) => {
12631
+ const { fieldDef, value, setValue, setTouched, error, touched, disabled } = useField(fieldId);
12632
+ const clinicalField = useField(CLINICAL_EXAMINATION_FIELD);
12633
+ const { state } = useForm();
12634
+ const showError = !!error && (touched || state.submitAttempted);
12635
+ const safe = React15.useMemo(() => normalizeObgExamination(value), [value]);
12636
+ React15.useEffect(() => {
12637
+ if (disabled) return;
12638
+ const norm = normalizeObgExamination(value);
12639
+ const next = formatObgExaminationToClinicalExamination(norm);
12640
+ clinicalField.setValue(next);
12641
+ if (norm.examinationNotes !== next) {
12642
+ setValue({ ...norm, examinationNotes: next });
12643
+ }
12644
+ }, [value, disabled]);
12645
+ const bump = (next) => {
12646
+ setValue(next);
12647
+ setTouched();
12648
+ };
12649
+ const toggleGeneral = (key) => bump({ ...safe, general: { ...safe.general, [key]: !safe.general[key] } });
12650
+ const toggleAbdomen = (key) => bump({ ...safe, abdomen: { ...safe.abdomen, [key]: !safe.abdomen[key] } });
12651
+ const toggleBreast = (key) => bump({ ...safe, breast: { ...safe.breast, [key]: !safe.breast[key] } });
12652
+ const togglePelvic = (key) => {
12653
+ const nextPelvic = { ...safe.pelvic, [key]: !safe.pelvic[key] };
12654
+ const nextUterus = !nextPelvic.bimanualDone ? "" : safe.uterusSize;
12655
+ bump({ ...safe, pelvic: nextPelvic, uterusSize: nextUterus });
12656
+ };
12657
+ const setUterusSize = (val) => bump({ ...safe, uterusSize: val });
12658
+ if (!fieldDef) return null;
12659
+ const theme = getThemeConfig("textarea", fieldDef.theme);
12660
+ const wrapperClass = theme?.wrapperClassName ?? "rounded-md overflow-hidden flex flex-col border border-[#D0D0D0]";
12661
+ const labelClass = theme?.labelClassName;
12662
+ const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12663
+ fieldDef.label,
12664
+ fieldDef.required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
12665
+ ] });
12666
+ const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: labelContent });
12667
+ const bodyClass = cn(
12668
+ "-mt-1 flex min-w-0 flex-col gap-3 border-t border-[#D0D0D0] bg-white px-3 py-3",
12669
+ disabled && "pointer-events-none opacity-60"
12670
+ );
12671
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("w-full min-w-0", wrapperClass), children: [
12672
+ labelEl,
12673
+ fieldDef.description ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-3 pt-2 text-[11px] text-muted-foreground", children: fieldDef.description }) : null,
12674
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: bodyClass, children: [
12675
+ showError ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-600", children: error }) : null,
12676
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-3 text-xs md:grid-cols-2 xl:grid-cols-4", children: [
12677
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
12678
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold text-slate-800", children: "General" }),
12679
+ GENERAL_ROWS2.map((r) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
12680
+ /* @__PURE__ */ jsxRuntime.jsx(
12681
+ Checkbox,
12682
+ {
12683
+ checked: safe.general[r.key],
12684
+ onCheckedChange: () => toggleGeneral(r.key),
12685
+ disabled
12686
+ }
12687
+ ),
12688
+ r.label
12689
+ ] }, r.key))
12690
+ ] }),
12691
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
12692
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold text-slate-800", children: "Abdomen" }),
12693
+ ABDOMEN_ROWS.map((r) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
12694
+ /* @__PURE__ */ jsxRuntime.jsx(
12695
+ Checkbox,
12696
+ {
12697
+ checked: safe.abdomen[r.key],
12698
+ onCheckedChange: () => toggleAbdomen(r.key),
12699
+ disabled
12700
+ }
12701
+ ),
12702
+ r.label
12703
+ ] }, r.key)),
12704
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[10px] text-muted-foreground", children: "Pregnancy \u2192 fundal ht / FHR / lie captured in Antenatal pathway." })
12705
+ ] }),
12706
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
12707
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold text-slate-800", children: "Breast" }),
12708
+ BREAST_ROWS.map((r) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
12709
+ /* @__PURE__ */ jsxRuntime.jsx(
12710
+ Checkbox,
12711
+ {
12712
+ checked: safe.breast[r.key],
12713
+ onCheckedChange: () => toggleBreast(r.key),
12714
+ disabled
12715
+ }
12716
+ ),
12717
+ r.label
12718
+ ] }, r.key))
12719
+ ] }),
12720
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
12721
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold text-slate-800", children: "Pelvic (consent applied)" }),
12722
+ PELVIC_ROWS.map((r) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2", children: [
12723
+ /* @__PURE__ */ jsxRuntime.jsx(
12724
+ Checkbox,
12725
+ {
12726
+ checked: safe.pelvic[r.key],
12727
+ onCheckedChange: () => togglePelvic(r.key),
12728
+ disabled
12729
+ }
12730
+ ),
12731
+ r.label
12732
+ ] }, r.key)),
12733
+ safe.pelvic.bimanualDone ? /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "block pt-1", children: [
12734
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mb-1 block font-medium", children: "Uterus size (on bimanual)" }),
12735
+ /* @__PURE__ */ jsxRuntime.jsxs(
12736
+ Select,
12737
+ {
12738
+ value: safe.uterusSize === "" ? "none" : safe.uterusSize,
12739
+ onValueChange: (v) => setUterusSize(v === "none" ? "" : v),
12740
+ disabled,
12741
+ children: [
12742
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
12743
+ /* @__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")) })
12744
+ ]
12745
+ }
12746
+ )
12747
+ ] }) : null
12748
+ ] })
12749
+ ] }),
12750
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 border-t border-[#D0D0D0] pt-3", children: [
12751
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: "Clinical examination" }),
12752
+ /* @__PURE__ */ jsxRuntime.jsx(
12753
+ Textarea,
12754
+ {
12755
+ value: formatObgExaminationToClinicalExamination(safe),
12756
+ readOnly: true,
12757
+ disabled,
12758
+ className: "min-h-[80px] text-xs",
12759
+ placeholder: "Derived from examination selections above."
12760
+ }
12761
+ )
12762
+ ] })
12763
+ ] })
12764
+ ] });
12765
+ };
12766
+ var SYMPTOMS_FIELD2 = "symptoms";
12767
+ function Panel3({
12768
+ title,
12769
+ right,
12770
+ children
12771
+ }) {
12772
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "overflow-hidden rounded-md border border-[#D0D0D0] bg-white", children: [
12773
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between border-b border-[#D0D0D0] bg-[#FEE8EC]/50 px-3 py-1.5", children: [
12774
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-semibold text-slate-700", children: title }),
12775
+ right
12776
+ ] }),
12777
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-3 text-xs", children })
12778
+ ] });
12779
+ }
12780
+ function ChipRow({
12781
+ options,
12782
+ selected,
12783
+ onToggle,
12784
+ disabled
12785
+ }) {
12786
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2", children: options.map((o) => {
12787
+ const on = !!selected[o.key];
12788
+ return /* @__PURE__ */ jsxRuntime.jsx(
12789
+ "button",
12790
+ {
12791
+ type: "button",
12792
+ onClick: () => onToggle(o.key),
12793
+ disabled,
12794
+ className: cn(
12795
+ "rounded-full border px-3 py-1 text-[11px] transition-colors",
12796
+ on ? "border-rose-500 bg-rose-50 text-rose-700" : "border-slate-300 bg-white text-slate-600 hover:bg-slate-50"
12797
+ ),
12798
+ children: o.label
12799
+ },
12800
+ o.key
12801
+ );
12802
+ }) });
12803
+ }
12804
+ var OBGPathwayWidget = ({ fieldId }) => {
12805
+ const { fieldDef, value, setValue, setTouched, error, touched, disabled } = useField(fieldId);
12806
+ const symptomsField = useField(SYMPTOMS_FIELD2);
12807
+ const { state } = useForm();
12808
+ const showError = !!error && (touched || state.submitAttempted);
12809
+ const safe = React15.useMemo(() => normalizeObgPathway(value), [value]);
12810
+ const prevZoneCountRef = React15.useRef(0);
12811
+ React15.useEffect(() => {
12812
+ if (disabled) return;
12813
+ const zoneCount = safe.zones.length;
12814
+ if (!zoneCount) {
12815
+ if (prevZoneCountRef.current > 0) {
12816
+ symptomsField.setValue("");
12817
+ }
12818
+ prevZoneCountRef.current = 0;
12819
+ return;
12820
+ }
12821
+ prevZoneCountRef.current = zoneCount;
12822
+ const next = formatObgPathwayToSymptomsNarrative(safe);
12823
+ if (typeof symptomsField.value !== "string" || symptomsField.value !== next) {
12824
+ symptomsField.setValue(next);
12825
+ }
12826
+ }, [safe, disabled]);
12827
+ const update = (next) => {
12828
+ setValue(next);
12829
+ setTouched();
12830
+ };
12831
+ if (!fieldDef) return null;
12832
+ const theme = getThemeConfig("textarea", fieldDef.theme);
12833
+ const wrapperClass = theme?.wrapperClassName ?? "rounded-md overflow-hidden flex flex-col border border-[#D0D0D0]";
12834
+ const labelClass = theme?.labelClassName;
12835
+ const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12836
+ fieldDef.label,
12837
+ fieldDef.required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
12838
+ ] });
12839
+ const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: labelContent });
12840
+ const bodyClass = cn(
12841
+ "-mt-1 flex min-w-0 flex-col gap-3 border-t border-[#D0D0D0] bg-white px-3 py-3",
12842
+ disabled && "pointer-events-none opacity-60"
12843
+ );
12844
+ const hasZone = (z) => safe.zones.includes(z);
12845
+ const toggleZone = (z) => update({
12846
+ ...safe,
12847
+ zones: hasZone(z) ? safe.zones.filter((x) => x !== z) : OBG_ZONE_ORDER.filter((x) => x === z || hasZone(x))
12848
+ });
12849
+ const m = safe.menstrual;
12850
+ const setMenstrual = (patch) => update({ ...safe, menstrual: { ...m, ...patch } });
12851
+ const a = safe.antenatal;
12852
+ const setAntenatal = (patch) => update({ ...safe, antenatal: { ...a, ...patch } });
12853
+ const setAntenatalSymptom = (key) => update({
12854
+ ...safe,
12855
+ antenatal: { ...a, symptoms: { ...a.symptoms, [key]: !a.symptoms[key] } }
12856
+ });
12857
+ const setAntenatalExam = (patch) => update({ ...safe, antenatal: { ...a, exam: { ...a.exam, ...patch } } });
12858
+ const setAntenatalInv = (patch) => update({
12859
+ ...safe,
12860
+ antenatal: { ...a, investigations: { ...a.investigations, ...patch } }
12861
+ });
12862
+ const gSym = safe.gynae.symptoms;
12863
+ const toggleGynae = (key) => update({ ...safe, gynae: { symptoms: { ...gSym, [key]: !gSym[key] } } });
12864
+ const setObstetric = (rows) => update({ ...safe, obstetric: rows });
12865
+ const addObstetricRow = () => setObstetric([
12866
+ ...safe.obstetric,
12867
+ { year: "", ga: "", mode: "", indicationLscs: "", babyOutcome: "", complications: "" }
12868
+ ]);
12869
+ const updateObstetricRow = (idx, patch) => setObstetric(safe.obstetric.map((row, i) => i === idx ? { ...row, ...patch } : row));
12870
+ const deleteObstetricRow = (idx) => setObstetric(safe.obstetric.filter((_, i) => i !== idx));
12871
+ const inf = safe.infertility;
12872
+ const setInfertility = (patch) => update({ ...safe, infertility: { ...inf, ...patch } });
12873
+ const po = safe.postop;
12874
+ const setPostop = (patch) => update({ ...safe, postop: { ...po, ...patch } });
12875
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("w-full min-w-0", wrapperClass), children: [
12876
+ labelEl,
12877
+ fieldDef.description ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-3 pt-2 text-[11px] text-muted-foreground", children: fieldDef.description }) : null,
12878
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: bodyClass, children: [
12879
+ showError ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-600", children: error }) : null,
12880
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
12881
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: "Primary concern (Consultant zone \u2014 multi-select)" }),
12882
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2", children: OBG_ZONE_ORDER.map((z) => {
12883
+ const on = hasZone(z);
12884
+ return /* @__PURE__ */ jsxRuntime.jsx(
12885
+ "button",
12886
+ {
12887
+ type: "button",
12888
+ onClick: () => toggleZone(z),
12889
+ disabled,
12890
+ "aria-pressed": on,
12891
+ className: cn(
12892
+ "rounded-full border px-3 py-1 text-[11px] transition-colors",
12893
+ on ? "border-rose-500 bg-rose-50 text-rose-700" : "border-slate-300 bg-white text-slate-600 hover:bg-slate-50"
12894
+ ),
12895
+ children: obgZoneLabel(z)
12896
+ },
12897
+ z
12898
+ );
12899
+ }) })
12900
+ ] }),
12901
+ 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: [
12902
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
12903
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Menarche (age)" }),
12904
+ /* @__PURE__ */ jsxRuntime.jsx(
12905
+ Input,
12906
+ {
12907
+ type: "number",
12908
+ min: 5,
12909
+ max: 25,
12910
+ className: "h-8 text-xs",
12911
+ value: m.menarcheAge,
12912
+ onChange: (e) => setMenstrual({ menarcheAge: Number(e.target.value) || 0 }),
12913
+ disabled
12914
+ }
12915
+ )
12916
+ ] }),
12917
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
12918
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Cycle (days)" }),
12919
+ /* @__PURE__ */ jsxRuntime.jsx(
12920
+ Input,
12921
+ {
12922
+ type: "number",
12923
+ min: 0,
12924
+ max: 120,
12925
+ className: "h-8 text-xs",
12926
+ value: m.cycleLength,
12927
+ onChange: (e) => setMenstrual({ cycleLength: Number(e.target.value) || 0 }),
12928
+ disabled
12929
+ }
12930
+ )
12931
+ ] }),
12932
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
12933
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Flow (days)" }),
12934
+ /* @__PURE__ */ jsxRuntime.jsx(
12935
+ Input,
12936
+ {
12937
+ type: "number",
12938
+ min: 0,
12939
+ max: 30,
12940
+ className: "h-8 text-xs",
12941
+ value: m.flowDays,
12942
+ onChange: (e) => setMenstrual({ flowDays: Number(e.target.value) || 0 }),
12943
+ disabled
12944
+ }
12945
+ )
12946
+ ] }),
12947
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-end gap-2 pb-1", children: [
12948
+ /* @__PURE__ */ jsxRuntime.jsx(
12949
+ Checkbox,
12950
+ {
12951
+ checked: m.cycleRegular,
12952
+ onCheckedChange: (c) => setMenstrual({ cycleRegular: c === true }),
12953
+ disabled
12954
+ }
12955
+ ),
12956
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Regular cycle" })
12957
+ ] }),
12958
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
12959
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Amount of flow" }),
12960
+ /* @__PURE__ */ jsxRuntime.jsxs(
12961
+ Select,
12962
+ {
12963
+ value: m.amount === "" ? "none" : m.amount,
12964
+ onValueChange: (v) => setMenstrual({ amount: v === "none" ? "" : v }),
12965
+ disabled,
12966
+ children: [
12967
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
12968
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
12969
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
12970
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Scanty", children: "Scanty" }),
12971
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Normal", children: "Normal" }),
12972
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Heavy", children: "Heavy" })
12973
+ ] })
12974
+ ]
12975
+ }
12976
+ )
12977
+ ] }),
12978
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
12979
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Dysmenorrhea" }),
12980
+ /* @__PURE__ */ jsxRuntime.jsxs(
12981
+ Select,
12982
+ {
12983
+ value: String(m.dysmenorrhea),
12984
+ onValueChange: (v) => setMenstrual({ dysmenorrhea: Number(v) ?? 0 }),
12985
+ disabled,
12986
+ children: [
12987
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "0" }) }),
12988
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
12989
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "0", children: "0 \u2014 none" }),
12990
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "1", children: "1 \u2014 mild" }),
12991
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "2", children: "2 \u2014 moderate" }),
12992
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "3", children: "3 \u2014 severe" })
12993
+ ] })
12994
+ ]
12995
+ }
12996
+ )
12997
+ ] }),
12998
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
12999
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "LMP" }),
13000
+ /* @__PURE__ */ jsxRuntime.jsx(
13001
+ Input,
13002
+ {
13003
+ type: "date",
13004
+ className: "h-8 text-xs",
13005
+ value: m.lmp,
13006
+ onChange: (e) => setMenstrual({ lmp: e.target.value }),
13007
+ disabled
13008
+ }
13009
+ )
13010
+ ] }),
13011
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13012
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Menopause status" }),
13013
+ /* @__PURE__ */ jsxRuntime.jsxs(
13014
+ Select,
13015
+ {
13016
+ value: m.menopauseStatus === "" ? "none" : m.menopauseStatus,
13017
+ onValueChange: (v) => setMenstrual({
13018
+ menopauseStatus: v === "none" ? "" : v
13019
+ }),
13020
+ disabled,
13021
+ children: [
13022
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13023
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13024
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13025
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Pre", children: "Pre" }),
13026
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Peri", children: "Peri" }),
13027
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Post", children: "Post" })
13028
+ ] })
13029
+ ]
13030
+ }
13031
+ )
13032
+ ] })
13033
+ ] }) }) : null,
13034
+ hasZone("antenatal") ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
13035
+ /* @__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: [
13036
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13037
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Gravida" }),
13038
+ /* @__PURE__ */ jsxRuntime.jsx(
13039
+ Input,
13040
+ {
13041
+ type: "number",
13042
+ min: 0,
13043
+ className: "h-8 text-xs",
13044
+ value: a.gravida,
13045
+ onChange: (e) => setAntenatal({ gravida: Number(e.target.value) || 0 }),
13046
+ disabled
13047
+ }
13048
+ )
13049
+ ] }),
13050
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
13051
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "GA (LMP) \u2014 w / d" }),
13052
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
13053
+ /* @__PURE__ */ jsxRuntime.jsx(
13054
+ Input,
13055
+ {
13056
+ type: "number",
13057
+ min: 0,
13058
+ max: 45,
13059
+ className: "h-8 text-xs",
13060
+ value: a.gaWeeksLmp,
13061
+ onChange: (e) => setAntenatal({ gaWeeksLmp: Number(e.target.value) || 0 }),
13062
+ disabled
13063
+ }
13064
+ ),
13065
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-muted-foreground", children: "w" }),
13066
+ /* @__PURE__ */ jsxRuntime.jsx(
13067
+ Input,
13068
+ {
13069
+ type: "number",
13070
+ min: 0,
13071
+ max: 6,
13072
+ className: "h-8 text-xs",
13073
+ value: a.gaDaysLmp,
13074
+ onChange: (e) => setAntenatal({ gaDaysLmp: Number(e.target.value) || 0 }),
13075
+ disabled
13076
+ }
13077
+ ),
13078
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-muted-foreground", children: "d" })
13079
+ ] })
13080
+ ] }),
13081
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
13082
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "GA (USG) \u2014 w / d" }),
13083
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
13084
+ /* @__PURE__ */ jsxRuntime.jsx(
13085
+ Input,
13086
+ {
13087
+ type: "number",
13088
+ min: 0,
13089
+ max: 45,
13090
+ className: "h-8 text-xs",
13091
+ value: a.gaWeeksUsg,
13092
+ onChange: (e) => setAntenatal({ gaWeeksUsg: Number(e.target.value) || 0 }),
13093
+ disabled
13094
+ }
13095
+ ),
13096
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-muted-foreground", children: "w" }),
13097
+ /* @__PURE__ */ jsxRuntime.jsx(
13098
+ Input,
13099
+ {
13100
+ type: "number",
13101
+ min: 0,
13102
+ max: 6,
13103
+ className: "h-8 text-xs",
13104
+ value: a.gaDaysUsg,
13105
+ onChange: (e) => setAntenatal({ gaDaysUsg: Number(e.target.value) || 0 }),
13106
+ disabled
13107
+ }
13108
+ ),
13109
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-muted-foreground", children: "d" })
13110
+ ] })
13111
+ ] }),
13112
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13113
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "EDD" }),
13114
+ /* @__PURE__ */ jsxRuntime.jsx(
13115
+ Input,
13116
+ {
13117
+ type: "date",
13118
+ className: "h-8 text-xs",
13119
+ value: a.edd,
13120
+ onChange: (e) => setAntenatal({ edd: e.target.value }),
13121
+ disabled
13122
+ }
13123
+ )
13124
+ ] }),
13125
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1 md:col-span-2", children: [
13126
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Risk category" }),
13127
+ /* @__PURE__ */ jsxRuntime.jsxs(
13128
+ Select,
13129
+ {
13130
+ value: a.riskCategory === "" ? "none" : a.riskCategory,
13131
+ onValueChange: (v) => setAntenatal({
13132
+ riskCategory: v === "none" ? "" : v
13133
+ }),
13134
+ disabled,
13135
+ children: [
13136
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13137
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13138
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13139
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Low", children: "Low" }),
13140
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "High", children: "High" })
13141
+ ] })
13142
+ ]
13143
+ }
13144
+ )
13145
+ ] })
13146
+ ] }) }),
13147
+ /* @__PURE__ */ jsxRuntime.jsx(Panel3, { title: "Antenatal symptoms", children: /* @__PURE__ */ jsxRuntime.jsx(
13148
+ ChipRow,
13149
+ {
13150
+ options: [
13151
+ { key: "nauseaVomiting", label: "Nausea / vomiting" },
13152
+ { key: "bleedingPV", label: "Bleeding PV" },
13153
+ { key: "painAbdomen", label: "Pain abdomen" },
13154
+ { key: "decreasedFetalMovements", label: "Decreased fetal movements" }
13155
+ ],
13156
+ selected: a.symptoms,
13157
+ onToggle: (k) => setAntenatalSymptom(k),
13158
+ disabled
13159
+ }
13160
+ ) }),
13161
+ /* @__PURE__ */ jsxRuntime.jsx(Panel3, { title: "Antenatal examination", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3 md:grid-cols-4", children: [
13162
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13163
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Weight (kg)" }),
13164
+ /* @__PURE__ */ jsxRuntime.jsx(
13165
+ Input,
13166
+ {
13167
+ type: "number",
13168
+ className: "h-8 text-xs",
13169
+ value: a.exam.weightKg,
13170
+ onChange: (e) => setAntenatalExam({ weightKg: Number(e.target.value) || 0 }),
13171
+ disabled
13172
+ }
13173
+ )
13174
+ ] }),
13175
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13176
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Height (cm)" }),
13177
+ /* @__PURE__ */ jsxRuntime.jsx(
13178
+ Input,
13179
+ {
13180
+ type: "number",
13181
+ className: "h-8 text-xs",
13182
+ value: a.exam.heightCm,
13183
+ onChange: (e) => setAntenatalExam({ heightCm: Number(e.target.value) || 0 }),
13184
+ disabled
13185
+ }
13186
+ )
13187
+ ] }),
13188
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13189
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "BMI" }),
13190
+ /* @__PURE__ */ jsxRuntime.jsx(
13191
+ Input,
13192
+ {
13193
+ type: "number",
13194
+ step: 0.1,
13195
+ className: "h-8 text-xs",
13196
+ value: a.exam.bmi,
13197
+ onChange: (e) => setAntenatalExam({ bmi: Number(e.target.value) || 0 }),
13198
+ disabled
13199
+ }
13200
+ )
13201
+ ] }),
13202
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13203
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "BP" }),
13204
+ /* @__PURE__ */ jsxRuntime.jsx(
13205
+ Input,
13206
+ {
13207
+ placeholder: "e.g. 120/80",
13208
+ className: "h-8 text-xs",
13209
+ value: a.exam.bp,
13210
+ onChange: (e) => setAntenatalExam({ bp: e.target.value }),
13211
+ disabled
13212
+ }
13213
+ )
13214
+ ] }),
13215
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-end gap-2 pb-1", children: [
13216
+ /* @__PURE__ */ jsxRuntime.jsx(
13217
+ Checkbox,
13218
+ {
13219
+ checked: a.exam.pallor,
13220
+ onCheckedChange: (c) => setAntenatalExam({ pallor: c === true }),
13221
+ disabled
13222
+ }
13223
+ ),
13224
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Pallor" })
13225
+ ] }),
13226
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-end gap-2 pb-1", children: [
13227
+ /* @__PURE__ */ jsxRuntime.jsx(
13228
+ Checkbox,
13229
+ {
13230
+ checked: a.exam.oedema,
13231
+ onCheckedChange: (c) => setAntenatalExam({ oedema: c === true }),
13232
+ disabled
13233
+ }
13234
+ ),
13235
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Oedema" })
13236
+ ] }),
13237
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13238
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Fundal height (cm)" }),
13239
+ /* @__PURE__ */ jsxRuntime.jsx(
13240
+ Input,
13241
+ {
13242
+ type: "number",
13243
+ className: "h-8 text-xs",
13244
+ value: a.exam.fundalHeightCm,
13245
+ onChange: (e) => setAntenatalExam({ fundalHeightCm: Number(e.target.value) || 0 }),
13246
+ disabled
13247
+ }
13248
+ )
13249
+ ] }),
13250
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13251
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "FHR (bpm)" }),
13252
+ /* @__PURE__ */ jsxRuntime.jsx(
13253
+ Input,
13254
+ {
13255
+ type: "number",
13256
+ className: "h-8 text-xs",
13257
+ value: a.exam.fhrBpm,
13258
+ onChange: (e) => setAntenatalExam({ fhrBpm: Number(e.target.value) || 0 }),
13259
+ disabled
13260
+ }
13261
+ )
13262
+ ] }),
13263
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13264
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Presentation" }),
13265
+ /* @__PURE__ */ jsxRuntime.jsxs(
13266
+ Select,
13267
+ {
13268
+ value: a.exam.presentation === "" ? "none" : a.exam.presentation,
13269
+ onValueChange: (v) => setAntenatalExam({
13270
+ presentation: v === "none" ? "" : v
13271
+ }),
13272
+ disabled,
13273
+ children: [
13274
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13275
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13276
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13277
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Cephalic", children: "Cephalic" }),
13278
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Breech", children: "Breech" }),
13279
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Other", children: "Other" })
13280
+ ] })
13281
+ ]
13282
+ }
13283
+ )
13284
+ ] }),
13285
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13286
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Lie" }),
13287
+ /* @__PURE__ */ jsxRuntime.jsxs(
13288
+ Select,
13289
+ {
13290
+ value: a.exam.lie === "" ? "none" : a.exam.lie,
13291
+ onValueChange: (v) => setAntenatalExam({ lie: v === "none" ? "" : v }),
13292
+ disabled,
13293
+ children: [
13294
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13295
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13296
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13297
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Longitudinal", children: "Longitudinal" }),
13298
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Transverse", children: "Transverse" }),
13299
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Oblique", children: "Oblique" })
13300
+ ] })
13301
+ ]
13302
+ }
13303
+ )
13304
+ ] })
13305
+ ] }) }),
13306
+ /* @__PURE__ */ jsxRuntime.jsx(Panel3, { title: "Investigations tracker", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3 md:grid-cols-3", children: [
13307
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13308
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Blood Group / Rh" }),
13309
+ /* @__PURE__ */ jsxRuntime.jsx(
13310
+ Input,
13311
+ {
13312
+ className: "h-8 text-xs",
13313
+ placeholder: "e.g. O+ve",
13314
+ value: a.investigations.bloodGroup,
13315
+ onChange: (e) => setAntenatalInv({ bloodGroup: e.target.value }),
13316
+ disabled
13317
+ }
13318
+ )
13319
+ ] }),
13320
+ [
13321
+ { key: "cbc", label: "CBC" },
13322
+ { key: "tsh", label: "TSH" },
13323
+ { key: "rbsOgtt", label: "RBS / OGTT" },
13324
+ { key: "serology", label: "HIV / HBsAg / VDRL" },
13325
+ { key: "urine", label: "Urine routine" }
13326
+ ].map((row) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13327
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: row.label }),
13328
+ /* @__PURE__ */ jsxRuntime.jsxs(
13329
+ Select,
13330
+ {
13331
+ value: a.investigations[row.key] === "" ? "none" : a.investigations[row.key],
13332
+ onValueChange: (v) => setAntenatalInv({
13333
+ [row.key]: v === "none" ? "" : v
13334
+ }),
13335
+ disabled,
13336
+ children: [
13337
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13338
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13339
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13340
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Done", children: "Done" }),
13341
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Pending", children: "Pending" }),
13342
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Abnormal", children: "Abnormal" })
13343
+ ] })
13344
+ ]
13345
+ }
13346
+ )
13347
+ ] }, row.key)),
13348
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13349
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "USG" }),
13350
+ /* @__PURE__ */ jsxRuntime.jsxs(
13351
+ Select,
13352
+ {
13353
+ value: a.investigations.usg === "" ? "none" : a.investigations.usg,
13354
+ onValueChange: (v) => setAntenatalInv({
13355
+ usg: v === "none" ? "" : v
13356
+ }),
13357
+ disabled,
13358
+ children: [
13359
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13360
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13361
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13362
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Dating", children: "Dating" }),
13363
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "NT", children: "NT" }),
13364
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Anomaly", children: "Anomaly" }),
13365
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Growth", children: "Growth" }),
13366
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Pending", children: "Pending" })
13367
+ ] })
13368
+ ]
13369
+ }
13370
+ )
13371
+ ] })
13372
+ ] }) })
13373
+ ] }) : null,
13374
+ hasZone("gynaecological") ? /* @__PURE__ */ jsxRuntime.jsx(Panel3, { title: "Gynaecological symptoms", children: /* @__PURE__ */ jsxRuntime.jsx(
13375
+ ChipRow,
13376
+ {
13377
+ options: [
13378
+ { key: "aub", label: "Abnormal uterine bleeding" },
13379
+ { key: "whiteDischarge", label: "White discharge" },
13380
+ { key: "pelvicPain", label: "Pelvic pain" },
13381
+ { key: "dyspareunia", label: "Dyspareunia" },
13382
+ { key: "urinaryComplaints", label: "Urinary complaints" },
13383
+ { key: "prolapse", label: "Prolapse" }
13384
+ ],
13385
+ selected: gSym,
13386
+ onToggle: (k) => toggleGynae(k),
13387
+ disabled
13388
+ }
13389
+ ) }) : null,
13390
+ hasZone("obstetric") ? /* @__PURE__ */ jsxRuntime.jsx(
13391
+ Panel3,
13392
+ {
13393
+ title: "Obstetric history (G-P-A-L)",
13394
+ right: /* @__PURE__ */ jsxRuntime.jsx(
13395
+ Button,
13396
+ {
13397
+ type: "button",
13398
+ size: "sm",
13399
+ variant: "outline",
13400
+ className: "h-7 text-xs",
13401
+ onClick: addObstetricRow,
13402
+ disabled,
13403
+ children: "+ Add row"
13404
+ }
13405
+ ),
13406
+ 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: [
13407
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "bg-slate-50 text-left text-slate-600", children: [
13408
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "p-1.5 font-medium", children: "Year" }),
13409
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "p-1.5 font-medium", children: "GA" }),
13410
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "p-1.5 font-medium", children: "Mode" }),
13411
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "p-1.5 font-medium", children: "LSCS indication" }),
13412
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "p-1.5 font-medium", children: "Baby outcome" }),
13413
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "p-1.5 font-medium", children: "Complications" }),
13414
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "p-1.5" })
13415
+ ] }) }),
13416
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: safe.obstetric.map((row, idx) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "border-t", children: [
13417
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "p-1", children: /* @__PURE__ */ jsxRuntime.jsx(
13418
+ Input,
13419
+ {
13420
+ className: "h-7 text-[11px]",
13421
+ value: row.year,
13422
+ onChange: (e) => updateObstetricRow(idx, { year: e.target.value }),
13423
+ disabled
13424
+ }
13425
+ ) }),
13426
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "p-1", children: /* @__PURE__ */ jsxRuntime.jsx(
13427
+ Input,
13428
+ {
13429
+ className: "h-7 text-[11px]",
13430
+ value: row.ga,
13431
+ onChange: (e) => updateObstetricRow(idx, { ga: e.target.value }),
13432
+ disabled
13433
+ }
13434
+ ) }),
13435
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "p-1", children: /* @__PURE__ */ jsxRuntime.jsxs(
13436
+ Select,
13437
+ {
13438
+ value: row.mode === "" ? "none" : row.mode,
13439
+ onValueChange: (v) => updateObstetricRow(idx, {
13440
+ mode: v === "none" ? "" : v
13441
+ }),
13442
+ disabled,
13443
+ children: [
13444
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-7 text-[11px]", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13445
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13446
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13447
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "NVD", children: "NVD" }),
13448
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "LSCS", children: "LSCS" }),
13449
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Instrumental", children: "Instrumental" }),
13450
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Abortion", children: "Abortion" }),
13451
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Stillbirth", children: "Stillbirth" })
13452
+ ] })
13453
+ ]
13454
+ }
13455
+ ) }),
13456
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "p-1", children: /* @__PURE__ */ jsxRuntime.jsx(
13457
+ Input,
13458
+ {
13459
+ className: "h-7 text-[11px]",
13460
+ value: row.indicationLscs,
13461
+ onChange: (e) => updateObstetricRow(idx, { indicationLscs: e.target.value }),
13462
+ disabled
13463
+ }
13464
+ ) }),
13465
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "p-1", children: /* @__PURE__ */ jsxRuntime.jsx(
13466
+ Input,
13467
+ {
13468
+ className: "h-7 text-[11px]",
13469
+ value: row.babyOutcome,
13470
+ onChange: (e) => updateObstetricRow(idx, { babyOutcome: e.target.value }),
13471
+ disabled
13472
+ }
13473
+ ) }),
13474
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "p-1", children: /* @__PURE__ */ jsxRuntime.jsx(
13475
+ Input,
13476
+ {
13477
+ className: "h-7 text-[11px]",
13478
+ placeholder: "PIH, GDM, PPH, NICU\u2026",
13479
+ value: row.complications,
13480
+ onChange: (e) => updateObstetricRow(idx, { complications: e.target.value }),
13481
+ disabled
13482
+ }
13483
+ ) }),
13484
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "p-1", children: /* @__PURE__ */ jsxRuntime.jsx(
13485
+ Button,
13486
+ {
13487
+ type: "button",
13488
+ size: "sm",
13489
+ variant: "ghost",
13490
+ className: "h-7 text-[11px] text-rose-600 hover:bg-rose-50",
13491
+ onClick: () => deleteObstetricRow(idx),
13492
+ disabled,
13493
+ children: "\xD7"
13494
+ }
13495
+ ) })
13496
+ ] }, idx)) })
13497
+ ] }) })
13498
+ }
13499
+ ) : null,
13500
+ hasZone("infertility") ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
13501
+ /* @__PURE__ */ jsxRuntime.jsx(Panel3, { title: "Infertility profile", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-3 md:grid-cols-3", children: [
13502
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13503
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Type" }),
13504
+ /* @__PURE__ */ jsxRuntime.jsxs(
13505
+ Select,
13506
+ {
13507
+ value: inf.type === "" ? "none" : inf.type,
13508
+ onValueChange: (v) => setInfertility({ type: v === "none" ? "" : v }),
13509
+ disabled,
13510
+ children: [
13511
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13512
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13513
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13514
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Primary", children: "Primary" }),
13515
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Secondary", children: "Secondary" })
13516
+ ] })
13517
+ ]
13518
+ }
13519
+ )
13520
+ ] }),
13521
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13522
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Duration (months)" }),
13523
+ /* @__PURE__ */ jsxRuntime.jsx(
13524
+ Input,
13525
+ {
13526
+ type: "number",
13527
+ min: 0,
13528
+ className: "h-8 text-xs",
13529
+ value: inf.durationMonths,
13530
+ onChange: (e) => setInfertility({ durationMonths: Number(e.target.value) || 0 }),
13531
+ disabled
13532
+ }
13533
+ )
13534
+ ] }),
13535
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1 md:col-span-1", children: [
13536
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Previous treatments" }),
13537
+ /* @__PURE__ */ jsxRuntime.jsx(
13538
+ Input,
13539
+ {
13540
+ className: "h-8 text-xs",
13541
+ placeholder: "IUI \xD72, OI cycles\u2026",
13542
+ value: inf.previousTreatments,
13543
+ onChange: (e) => setInfertility({ previousTreatments: e.target.value }),
13544
+ disabled
13545
+ }
13546
+ )
13547
+ ] })
13548
+ ] }) }),
13549
+ /* @__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: [
13550
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13551
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Ovulation status" }),
13552
+ /* @__PURE__ */ jsxRuntime.jsxs(
13553
+ Select,
13554
+ {
13555
+ value: inf.female.ovulation === "" ? "none" : inf.female.ovulation,
13556
+ onValueChange: (v) => setInfertility({
13557
+ female: {
13558
+ ...inf.female,
13559
+ ovulation: v === "none" ? "" : v
13560
+ }
13561
+ }),
13562
+ disabled,
13563
+ children: [
13564
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13565
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13566
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13567
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Ovulatory", children: "Ovulatory" }),
13568
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Anovulatory", children: "Anovulatory" }),
13569
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Unknown", children: "Unknown" })
13570
+ ] })
13571
+ ]
13572
+ }
13573
+ )
13574
+ ] }),
13575
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-end gap-2 pb-1", children: [
13576
+ /* @__PURE__ */ jsxRuntime.jsx(
13577
+ Checkbox,
13578
+ {
13579
+ checked: inf.female.pcosFeatures,
13580
+ onCheckedChange: (c) => setInfertility({
13581
+ female: { ...inf.female, pcosFeatures: c === true }
13582
+ }),
13583
+ disabled
13584
+ }
13585
+ ),
13586
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "PCOS features" })
13587
+ ] }),
13588
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-end gap-2 pb-1", children: [
13589
+ /* @__PURE__ */ jsxRuntime.jsx(
13590
+ Checkbox,
13591
+ {
13592
+ checked: inf.female.endometriosisSuspicion,
13593
+ onCheckedChange: (c) => setInfertility({
13594
+ female: { ...inf.female, endometriosisSuspicion: c === true }
13595
+ }),
13596
+ disabled
13597
+ }
13598
+ ),
13599
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Endometriosis suspicion" })
13600
+ ] })
13601
+ ] }) }),
13602
+ /* @__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: [
13603
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13604
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Age" }),
13605
+ /* @__PURE__ */ jsxRuntime.jsx(
13606
+ Input,
13607
+ {
13608
+ type: "number",
13609
+ min: 0,
13610
+ className: "h-8 text-xs",
13611
+ value: inf.male.age,
13612
+ onChange: (e) => setInfertility({ male: { ...inf.male, age: Number(e.target.value) || 0 } }),
13613
+ disabled
13614
+ }
13615
+ )
13616
+ ] }),
13617
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13618
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Semen analysis" }),
13619
+ /* @__PURE__ */ jsxRuntime.jsxs(
13620
+ Select,
13621
+ {
13622
+ value: inf.male.semenAnalysis === "" ? "none" : inf.male.semenAnalysis,
13623
+ onValueChange: (v) => setInfertility({
13624
+ male: {
13625
+ ...inf.male,
13626
+ semenAnalysis: v === "none" ? "" : v
13627
+ }
13628
+ }),
13629
+ disabled,
13630
+ children: [
13631
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13632
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13633
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13634
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Normal", children: "Normal" }),
13635
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Abnormal", children: "Abnormal" }),
13636
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Pending", children: "Pending" })
13637
+ ] })
13638
+ ]
13639
+ }
13640
+ )
13641
+ ] })
13642
+ ] }) }),
13643
+ /* @__PURE__ */ jsxRuntime.jsx(Panel3, { title: "Investigations", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 gap-3 md:grid-cols-3", children: [
13644
+ { key: "amh", label: "AMH" },
13645
+ { key: "fshLh", label: "FSH / LH" },
13646
+ { key: "prolactin", label: "Prolactin" },
13647
+ { key: "tsh", label: "TSH" },
13648
+ { key: "tvs", label: "TVS findings" },
13649
+ { key: "hsg", label: "HSG findings" }
13650
+ ].map((row) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13651
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: row.label }),
13652
+ /* @__PURE__ */ jsxRuntime.jsx(
13653
+ Input,
13654
+ {
13655
+ className: "h-8 text-xs",
13656
+ value: inf.investigations[row.key],
13657
+ onChange: (e) => setInfertility({
13658
+ investigations: { ...inf.investigations, [row.key]: e.target.value }
13659
+ }),
13660
+ disabled
13661
+ }
13662
+ )
13663
+ ] }, row.key)) }) })
13664
+ ] }) : null,
13665
+ 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: [
13666
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13667
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Date of surgery" }),
13668
+ /* @__PURE__ */ jsxRuntime.jsx(
13669
+ Input,
13670
+ {
13671
+ type: "date",
13672
+ className: "h-8 text-xs",
13673
+ value: po.surgeryDate,
13674
+ onChange: (e) => setPostop({ surgeryDate: e.target.value }),
13675
+ disabled
13676
+ }
13677
+ )
13678
+ ] }),
13679
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1 md:col-span-2", children: [
13680
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Procedure performed" }),
13681
+ /* @__PURE__ */ jsxRuntime.jsx(
13682
+ Input,
13683
+ {
13684
+ className: "h-8 text-xs",
13685
+ value: po.procedure,
13686
+ onChange: (e) => setPostop({ procedure: e.target.value }),
13687
+ disabled
13688
+ }
13689
+ )
13690
+ ] }),
13691
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1 md:col-span-2", children: [
13692
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Histopathology result" }),
13693
+ /* @__PURE__ */ jsxRuntime.jsx(
13694
+ Input,
13695
+ {
13696
+ className: "h-8 text-xs",
13697
+ value: po.histopathology,
13698
+ onChange: (e) => setPostop({ histopathology: e.target.value }),
13699
+ disabled
13700
+ }
13701
+ )
13702
+ ] }),
13703
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13704
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Wound status" }),
13705
+ /* @__PURE__ */ jsxRuntime.jsxs(
13706
+ Select,
13707
+ {
13708
+ value: po.woundStatus === "" ? "none" : po.woundStatus,
13709
+ onValueChange: (v) => setPostop({
13710
+ woundStatus: v === "none" ? "" : v
13711
+ }),
13712
+ disabled,
13713
+ children: [
13714
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "\u2014" }) }),
13715
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
13716
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "none", children: "\u2014" }),
13717
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Healthy", children: "Healthy" }),
13718
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Erythema", children: "Erythema" }),
13719
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Discharge", children: "Discharge" }),
13720
+ /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: "Dehisced", children: "Dehisced" })
13721
+ ] })
13722
+ ]
13723
+ }
13724
+ )
13725
+ ] }),
13726
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1", children: [
13727
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Pain score (0-10)" }),
13728
+ /* @__PURE__ */ jsxRuntime.jsx(
13729
+ Input,
13730
+ {
13731
+ type: "number",
13732
+ min: 0,
13733
+ max: 10,
13734
+ className: "h-8 text-xs",
13735
+ value: po.painScore,
13736
+ onChange: (e) => setPostop({
13737
+ painScore: Math.max(0, Math.min(10, Number(e.target.value) || 0))
13738
+ }),
13739
+ disabled
13740
+ }
13741
+ )
13742
+ ] }),
13743
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "space-y-1 md:col-span-3", children: [
13744
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block font-medium", children: "Complications" }),
13745
+ /* @__PURE__ */ jsxRuntime.jsx(
13746
+ Textarea,
13747
+ {
13748
+ className: "min-h-[60px] text-xs",
13749
+ value: po.complications,
13750
+ onChange: (e) => setPostop({ complications: e.target.value }),
13751
+ disabled
13752
+ }
13753
+ )
13754
+ ] })
13755
+ ] }) }) : null,
13756
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 border-t border-[#D0D0D0] pt-3", children: [
13757
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: "History of Presenting Complaint" }),
13758
+ /* @__PURE__ */ jsxRuntime.jsx(
13759
+ Textarea,
13760
+ {
13761
+ value: safe.zones.length > 0 ? formatObgPathwayToSymptomsNarrative(safe) : typeof symptomsField.value === "string" ? symptomsField.value : "",
13762
+ onChange: (e) => {
13763
+ if (safe.zones.length > 0) return;
13764
+ symptomsField.setValue(e.target.value);
13765
+ },
13766
+ readOnly: safe.zones.length > 0,
13767
+ disabled,
13768
+ className: "min-h-[70px] text-xs",
13769
+ placeholder: safe.zones.length > 0 ? "Generated from pathway panels above." : "Free-text history, or select pathway zones above for a structured narrative."
13770
+ }
13771
+ )
13772
+ ] })
13773
+ ] })
13774
+ ] });
13775
+ };
13776
+ var FieldRenderer = ({ fieldId }) => {
13777
+ const { fieldDef, visible } = useField(fieldId);
13778
+ if (!visible || !fieldDef) {
13779
+ return null;
13780
+ }
13781
+ return renderWidget(fieldId, fieldDef);
13782
+ };
13783
+ function renderWidget(fieldId, fieldDef) {
13784
+ switch (fieldDef.type) {
13785
+ case "text":
13786
+ case "number":
13787
+ return /* @__PURE__ */ jsxRuntime.jsx(TextWidget, { fieldId });
13788
+ case "slider":
13789
+ return /* @__PURE__ */ jsxRuntime.jsx(SliderWidget, { fieldId });
13790
+ case "textarea":
13791
+ if (fieldMetaRequestsMarMedicationOrdersButton(fieldDef.meta)) {
13792
+ return /* @__PURE__ */ jsxRuntime.jsx(MarMedicationOrdersWidget, { fieldId });
13793
+ }
13794
+ return /* @__PURE__ */ jsxRuntime.jsx(TextWidget, { fieldId });
13795
+ case "richtext":
13796
+ return /* @__PURE__ */ jsxRuntime.jsx(RichTextWidget, { fieldId });
13797
+ case "date":
13798
+ return /* @__PURE__ */ jsxRuntime.jsx(DateWidget, { fieldId });
13799
+ case "datetime":
13800
+ return /* @__PURE__ */ jsxRuntime.jsx(DateTimeWidget, { fieldId });
13801
+ case "select":
13802
+ return /* @__PURE__ */ jsxRuntime.jsx(SelectWidget, { fieldId });
13803
+ case "radio":
13804
+ return /* @__PURE__ */ jsxRuntime.jsx(RadioWidget, { fieldId });
13805
+ case "checkbox":
13806
+ return /* @__PURE__ */ jsxRuntime.jsx(CheckboxWidget, { fieldId });
13807
+ case "multiselect":
13808
+ return /* @__PURE__ */ jsxRuntime.jsx(MultiSelectWidget, { fieldId });
13809
+ case "repeatable":
13810
+ return /* @__PURE__ */ jsxRuntime.jsx(RepeatableWidget, { fieldId });
13811
+ case "image_upload":
13812
+ return /* @__PURE__ */ jsxRuntime.jsx(ImageUploadWidget, { fieldId });
13813
+ case "media_upload":
13814
+ return /* @__PURE__ */ jsxRuntime.jsx(MediaUploadWidget, { fieldId });
13815
+ case "signature":
13816
+ return /* @__PURE__ */ jsxRuntime.jsx(SignatureUploadWidget, { fieldId });
13817
+ case "editable_table":
13818
+ return /* @__PURE__ */ jsxRuntime.jsx(EditableTableWidget, { fieldId });
13819
+ case "medications":
13820
+ return /* @__PURE__ */ jsxRuntime.jsx(AddMedicationWidget, { fieldId });
13821
+ case "discharge_medication_orders":
13822
+ return /* @__PURE__ */ jsxRuntime.jsx(DischargeMedicationOrdersWidget, { fieldId });
13823
+ case "investigations":
13824
+ return /* @__PURE__ */ jsxRuntime.jsx(AddInvestigationWidget, { fieldId });
13825
+ case "procedures":
13826
+ return /* @__PURE__ */ jsxRuntime.jsx(AddProcedureWidget, { fieldId });
13827
+ case "differential_diagnosis":
13828
+ return /* @__PURE__ */ jsxRuntime.jsx(DifferentialDiagnosisWidget, { fieldId });
13829
+ case "vitals":
13830
+ return /* @__PURE__ */ jsxRuntime.jsx(VitalsWidget, { fieldId });
13831
+ case "hidden_vitals":
13832
+ return /* @__PURE__ */ jsxRuntime.jsx(HiddenVitalsWidget, { fieldId });
13833
+ case "referral":
13834
+ return /* @__PURE__ */ jsxRuntime.jsx(ReferralWidget, { fieldId });
13835
+ case "followup":
13836
+ return /* @__PURE__ */ jsxRuntime.jsx(FollowupWidget, { fieldId });
13837
+ case "smart_textarea":
13838
+ return /* @__PURE__ */ jsxRuntime.jsx(SmartTextareaWidget, { fieldId });
13839
+ case "diagnosis_textarea":
13840
+ return /* @__PURE__ */ jsxRuntime.jsx(DiagnosisTextareaWidget, { fieldId });
13841
+ case "obstetric_history":
13842
+ return /* @__PURE__ */ jsxRuntime.jsx(ObstetricHistoryWidget, { fieldId });
13843
+ case "eye_prescription":
13844
+ return /* @__PURE__ */ jsxRuntime.jsx(OphthalmologyWidget, { fieldId });
13845
+ case "ophthal_diagnosis":
13846
+ return /* @__PURE__ */ jsxRuntime.jsx(OphthalDiagnosisWidget, { fieldId });
13847
+ case "orthopedic_exam":
13848
+ return /* @__PURE__ */ jsxRuntime.jsx(OrthopedicExamWidget, { fieldId });
13849
+ case "general_surgery_smart_history":
13850
+ return /* @__PURE__ */ jsxRuntime.jsx(GsSmartHistoryWidget, { fieldId });
13851
+ case "general_surgery_examination":
13852
+ return /* @__PURE__ */ jsxRuntime.jsx(GsExaminationWidget, { fieldId });
13853
+ case "general_surgery_grading":
13854
+ return /* @__PURE__ */ jsxRuntime.jsx(GsGradingWidget, { fieldId });
13855
+ case "pain_scale_flags":
13856
+ return /* @__PURE__ */ jsxRuntime.jsx(PainScaleFlagsWidget, { fieldId });
13857
+ case "urology_smart_history":
13858
+ return /* @__PURE__ */ jsxRuntime.jsx(UrologySmartHistoryWidget, { fieldId });
13859
+ case "urology_examination":
13860
+ return /* @__PURE__ */ jsxRuntime.jsx(UrologyExaminationWidget, { fieldId });
13861
+ case "urology_pathway":
13862
+ return /* @__PURE__ */ jsxRuntime.jsx(UrologyPathwayWidget, { fieldId });
13863
+ case "obg_examination":
13864
+ return /* @__PURE__ */ jsxRuntime.jsx(OBGExaminationWidget, { fieldId });
13865
+ case "obg_pathway":
13866
+ return /* @__PURE__ */ jsxRuntime.jsx(OBGPathwayWidget, { fieldId });
13867
+ case "toggle": {
13868
+ const { value, setValue, setTouched, disabled } = useField(fieldId);
13869
+ const store = useFormStore();
13870
+ const excludes = fieldDef.excludes ?? [];
13871
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
13872
+ /* @__PURE__ */ jsxRuntime.jsx(
13873
+ Switch,
13874
+ {
13875
+ checked: value === true,
13876
+ disabled,
13877
+ onCheckedChange: (checked) => {
13878
+ setValue(checked);
13879
+ setTouched();
13880
+ if (checked) excludes.forEach((id) => store.setValue(id, false));
13881
+ }
13882
+ }
13883
+ ),
13884
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium leading-none cursor-pointer select-none", children: fieldDef.label })
13885
+ ] });
13886
+ }
13887
+ case "suggestion_textarea":
13888
+ case "complaint_chips":
13889
+ return /* @__PURE__ */ jsxRuntime.jsx(SuggestionTextareaWidget, { fieldId });
13890
+ case "lens_assessment":
13891
+ return /* @__PURE__ */ jsxRuntime.jsx(LensAssessmentWidget, { fieldId });
13892
+ case "functional_impairment_score":
13893
+ return /* @__PURE__ */ jsxRuntime.jsx(FunctionalImpairmentScoreWidget, { fieldId });
13894
+ case "biometry_iol_workup":
13895
+ return /* @__PURE__ */ jsxRuntime.jsx(BiometryIolWorkupWidget, { fieldId });
13896
+ case "surgical_risk_flags":
13897
+ return /* @__PURE__ */ jsxRuntime.jsx(SurgicalRiskFlagsWidget, { fieldId });
13898
+ case "static_text": {
12010
13899
  const def = fieldDef;
12011
13900
  const size = def.size ?? "regular";
12012
13901
  const labelClass = size === "large" ? "text-base" : "text-sm";
@@ -12824,18 +14713,18 @@ var ReadOnlyFieldRenderer = ({
12824
14713
  const locsRecord = locs != null && typeof locs === "object" && !Array.isArray(locs) ? locs : null;
12825
14714
  const eyeLine = (label, g) => {
12826
14715
  if (!g || typeof g !== "object") return null;
12827
- const num = (k) => typeof g[k] === "number" ? g[k] : "\u2014";
14716
+ const num2 = (k) => typeof g[k] === "number" ? g[k] : "\u2014";
12828
14717
  return /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-foreground", children: [
12829
14718
  label,
12830
14719
  ": NO ",
12831
- String(num("NO")),
14720
+ String(num2("NO")),
12832
14721
  ", NC ",
12833
- String(num("NC")),
14722
+ String(num2("NC")),
12834
14723
  ", C ",
12835
- String(num("C")),
14724
+ String(num2("C")),
12836
14725
  ", PSC",
12837
14726
  " ",
12838
- String(num("PSC"))
14727
+ String(num2("PSC"))
12839
14728
  ] });
12840
14729
  };
12841
14730
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 rounded-md border p-3 text-sm", children: [
@@ -12975,6 +14864,32 @@ var ReadOnlyFieldRenderer = ({
12975
14864
  ] }) : null
12976
14865
  ] });
12977
14866
  }
14867
+ case "obg_pathway": {
14868
+ const structuredDisplay = value && typeof value === "object" ? JSON.stringify(normalizeObgPathway(value), null, 2) : value == null || value === "" ? "\u2014" : String(value);
14869
+ const hopcDef = resolveFieldDef?.("symptoms");
14870
+ const hopcRaw = allValues?.["symptoms"];
14871
+ const hopcStr = typeof hopcRaw === "string" ? hopcRaw : hopcRaw != null && hopcRaw !== "" ? String(hopcRaw) : "";
14872
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
14873
+ /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef, value: structuredDisplay }),
14874
+ hopcDef ? /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef: hopcDef, value: hopcStr }) : hopcStr ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
14875
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-gray-700", children: "History of presenting complaint" }),
14876
+ /* @__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 })
14877
+ ] }) : null
14878
+ ] });
14879
+ }
14880
+ case "obg_examination": {
14881
+ const structuredDisplay = value && typeof value === "object" ? JSON.stringify(value, null, 2) : value == null || value === "" ? "\u2014" : String(value);
14882
+ const clinicalDef = resolveFieldDef?.("clinical_examination");
14883
+ const clinicalRaw = allValues?.["clinical_examination"];
14884
+ const clinicalStr = typeof clinicalRaw === "string" ? clinicalRaw : clinicalRaw != null && clinicalRaw !== "" ? String(clinicalRaw) : "";
14885
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
14886
+ /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef, value: structuredDisplay }),
14887
+ clinicalDef ? /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyText, { fieldDef: clinicalDef, value: clinicalStr }) : clinicalStr ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
14888
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-gray-700", children: "Clinical examination" }),
14889
+ /* @__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 })
14890
+ ] }) : null
14891
+ ] });
14892
+ }
12978
14893
  case "static_text": {
12979
14894
  const def = fieldDef;
12980
14895
  const size = def.size ?? "regular";