@eka-care/medical-records-ui 1.2.38 → 1.2.40

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.js CHANGED
@@ -2030,7 +2030,7 @@ function compositionSectionMap(resources) {
2030
2030
  }
2031
2031
 
2032
2032
  // src/prescription/classify.ts
2033
- var HEADER_TYPES = /* @__PURE__ */ new Set(["Composition", "Encounter", "Patient", "Practitioner", "Organization", "DocumentReference"]);
2033
+ var HEADER_TYPES = /* @__PURE__ */ new Set(["Composition", "Encounter", "Patient", "Practitioner", "PractitionerRole", "Organization", "DocumentReference"]);
2034
2034
  var HISTORY_TYPES = /* @__PURE__ */ new Set(["Procedure"]);
2035
2035
  var SYMPTOM_CODES = ["symptom", "418799008", "s-8068301606"];
2036
2036
  var SNOMED_MEDICAL_ADVICE = "386464006";
@@ -2438,10 +2438,29 @@ function performerName(sr) {
2438
2438
  const performer = _optionalChain([sr, 'access', _206 => _206.performer, 'optionalAccess', _207 => _207.find, 'call', _208 => _208((p) => _optionalChain([p, 'optionalAccess', _209 => _209.display, 'optionalAccess', _210 => _210.trim, 'call', _211 => _211()]) && (!p.reference || p.reference.startsWith("Practitioner/")))]);
2439
2439
  return _optionalChain([performer, 'optionalAccess', _212 => _212.display, 'optionalAccess', _213 => _213.trim, 'call', _214 => _214()]) || null;
2440
2440
  }
2441
- function referralRow(sr) {
2442
- const referred_to = _optionalChain([sr, 'access', _215 => _215.code, 'optionalAccess', _216 => _216.text, 'optionalAccess', _217 => _217.trim, 'call', _218 => _218()]) || conceptDisplay(sr.code) || performerName(sr);
2441
+ function practitionerSpecialties(resources) {
2442
+ const map = /* @__PURE__ */ new Map();
2443
+ for (const r of resources) {
2444
+ if (_optionalChain([r, 'optionalAccess', _215 => _215.resourceType]) !== "PractitionerRole") continue;
2445
+ const role = r;
2446
+ const specialty = (_nullishCoalesce(role.specialty, () => ( []))).map(conceptDisplay).filter(Boolean).join(", ");
2447
+ if (!specialty) continue;
2448
+ if (_optionalChain([role, 'access', _216 => _216.practitioner, 'optionalAccess', _217 => _217.reference])) map.set(role.practitioner.reference, specialty);
2449
+ if (role.id) map.set(`PractitionerRole/${role.id}`, specialty);
2450
+ }
2451
+ return map;
2452
+ }
2453
+ function performerSpecialty(sr, specialties) {
2454
+ for (const performer of _nullishCoalesce(sr.performer, () => ( []))) {
2455
+ const specialty = _optionalChain([performer, 'optionalAccess', _218 => _218.reference]) ? specialties.get(performer.reference) : void 0;
2456
+ if (specialty) return specialty;
2457
+ }
2458
+ return "";
2459
+ }
2460
+ function referralRow(sr, specialties = /* @__PURE__ */ new Map()) {
2461
+ const referred_to = _optionalChain([sr, 'access', _219 => _219.code, 'optionalAccess', _220 => _220.text, 'optionalAccess', _221 => _221.trim, 'call', _222 => _222()]) || conceptDisplay(sr.code) || performerName(sr);
2443
2462
  if (!referred_to) return null;
2444
- return { referred_to, specialty: "", phone: "", hospital: "", notes: _nullishCoalesce(noteText(sr.note), () => ( "")), ...entityCodes(sr.code) };
2463
+ return { referred_to, specialty: performerSpecialty(sr, specialties), phone: "", hospital: "", notes: _nullishCoalesce(noteText(sr.note), () => ( "")), ...entityCodes(sr.code) };
2445
2464
  }
2446
2465
  function admissionNotes(sr) {
2447
2466
  return _nullishCoalesce(noteText(sr.note), () => ( ""));
@@ -2466,16 +2485,16 @@ function durationText(repeat) {
2466
2485
  function frequencyText(dosage) {
2467
2486
  const written = Array.isArray(dosage.additionalInstruction) ? conceptDisplay(dosage.additionalInstruction[0]) : null;
2468
2487
  if (written) return written;
2469
- const f = _optionalChain([dosage, 'access', _219 => _219.timing, 'optionalAccess', _220 => _220.repeat, 'optionalAccess', _221 => _221.frequency]);
2488
+ const f = _optionalChain([dosage, 'access', _223 => _223.timing, 'optionalAccess', _224 => _224.repeat, 'optionalAccess', _225 => _225.frequency]);
2470
2489
  return typeof f === "number" ? `${f} time${f === 1 ? "" : "s"} a day` : "";
2471
2490
  }
2472
2491
  function dosageColumns(dosage) {
2473
- const doseQuantity = Array.isArray(dosage.doseAndRate) ? _optionalChain([dosage, 'access', _222 => _222.doseAndRate, 'access', _223 => _223[0], 'optionalAccess', _224 => _224.doseQuantity]) : void 0;
2492
+ const doseQuantity = Array.isArray(dosage.doseAndRate) ? _optionalChain([dosage, 'access', _226 => _226.doseAndRate, 'access', _227 => _227[0], 'optionalAccess', _228 => _228.doseQuantity]) : void 0;
2474
2493
  return {
2475
2494
  dosage: _nullishCoalesce(quantityText(doseQuantity), () => ( "")),
2476
2495
  frequency: frequencyText(dosage),
2477
- timing: _nullishCoalesce(conceptDisplay(_optionalChain([dosage, 'access', _225 => _225.timing, 'optionalAccess', _226 => _226.code])), () => ( "")),
2478
- duration: durationText(_optionalChain([dosage, 'access', _227 => _227.timing, 'optionalAccess', _228 => _228.repeat])),
2496
+ timing: _nullishCoalesce(conceptDisplay(_optionalChain([dosage, 'access', _229 => _229.timing, 'optionalAccess', _230 => _230.code])), () => ( "")),
2497
+ duration: durationText(_optionalChain([dosage, 'access', _231 => _231.timing, 'optionalAccess', _232 => _232.repeat])),
2479
2498
  route: _nullishCoalesce(conceptDisplay(dosage.route), () => ( ""))
2480
2499
  };
2481
2500
  }
@@ -2485,10 +2504,10 @@ function medicationRow(mr) {
2485
2504
  const dosage = Array.isArray(mr.dosageInstruction) ? _nullishCoalesce(mr.dosageInstruction[0], () => ( {})) : {};
2486
2505
  return {
2487
2506
  drug_name,
2488
- medication_id: _nullishCoalesce(_nullishCoalesce(ekaCode(mr.medicationCodeableConcept), () => ( _optionalChain([codings, 'call', _229 => _229(mr.medicationCodeableConcept), 'access', _230 => _230[0], 'optionalAccess', _231 => _231.code]))), () => ( "")),
2507
+ medication_id: _nullishCoalesce(_nullishCoalesce(ekaCode(mr.medicationCodeableConcept), () => ( _optionalChain([codings, 'call', _233 => _233(mr.medicationCodeableConcept), 'access', _234 => _234[0], 'optionalAccess', _235 => _235.code]))), () => ( "")),
2489
2508
  ...entityCodes(mr.medicationCodeableConcept),
2490
2509
  ...dosageColumns(dosage),
2491
- quantity: _nullishCoalesce(quantityText(_optionalChain([mr, 'access', _232 => _232.dispenseRequest, 'optionalAccess', _233 => _233.quantity])), () => ( "")),
2510
+ quantity: _nullishCoalesce(quantityText(_optionalChain([mr, 'access', _236 => _236.dispenseRequest, 'optionalAccess', _237 => _237.quantity])), () => ( "")),
2492
2511
  notes: (_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(dosage.text, () => ( dosage.patientInstruction)), () => ( noteText(mr.note))), () => ( ""))).trim()
2493
2512
  };
2494
2513
  }
@@ -2499,7 +2518,7 @@ function currentMedicationRow(ms) {
2499
2518
  const columns = dosageColumns(dosage);
2500
2519
  return {
2501
2520
  drug_name,
2502
- medication_id: _nullishCoalesce(_nullishCoalesce(ekaCode(ms.medicationCodeableConcept), () => ( _optionalChain([codings, 'call', _234 => _234(ms.medicationCodeableConcept), 'access', _235 => _235[0], 'optionalAccess', _236 => _236.code]))), () => ( "")),
2521
+ medication_id: _nullishCoalesce(_nullishCoalesce(ekaCode(ms.medicationCodeableConcept), () => ( _optionalChain([codings, 'call', _238 => _238(ms.medicationCodeableConcept), 'access', _239 => _239[0], 'optionalAccess', _240 => _240.code]))), () => ( "")),
2503
2522
  ...entityCodes(ms.medicationCodeableConcept),
2504
2523
  ...columns,
2505
2524
  frequency: columns.frequency || (_nullishCoalesce(dosage.text, () => ( ""))).trim(),
@@ -2511,7 +2530,7 @@ function currentMedicationRow(ms) {
2511
2530
  // src/prescription/mappers/follow-up.ts
2512
2531
  var DAY_MS = 864e5;
2513
2532
  function followUpPayload(appt, visitDate) {
2514
- const date = (_nullishCoalesce(_nullishCoalesce(appt.start, () => ( _optionalChain([appt, 'access', _237 => _237.requestedPeriod, 'optionalAccess', _238 => _238[0], 'optionalAccess', _239 => _239.start]))), () => ( ""))).trim();
2533
+ const date = (_nullishCoalesce(_nullishCoalesce(appt.start, () => ( _optionalChain([appt, 'access', _241 => _241.requestedPeriod, 'optionalAccess', _242 => _242[0], 'optionalAccess', _243 => _243.start]))), () => ( ""))).trim();
2515
2534
  if (!date) return null;
2516
2535
  const written = (_nullishCoalesce(appt.description, () => ( ""))).trim();
2517
2536
  let interval = written && written !== date ? written : "";
@@ -2607,7 +2626,7 @@ function foldTargetOf(title) {
2607
2626
  }
2608
2627
  function historyCategoryOf(title) {
2609
2628
  const normal = normalTitle(title);
2610
- return _nullishCoalesce(_optionalChain([HISTORY_FOLD_CATEGORIES, 'access', _240 => _240.find, 'call', _241 => _241(([pattern]) => pattern.test(normal)), 'optionalAccess', _242 => _242[1]]), () => ( "condition"));
2629
+ return _nullishCoalesce(_optionalChain([HISTORY_FOLD_CATEGORIES, 'access', _244 => _244.find, 'call', _245 => _245(([pattern]) => pattern.test(normal)), 'optionalAccess', _246 => _246[1]]), () => ( "condition"));
2611
2630
  }
2612
2631
  function foldedRow(target, key, value, title) {
2613
2632
  switch (target) {
@@ -2658,7 +2677,7 @@ function unmappedReason(r) {
2658
2677
  case "CarePlan":
2659
2678
  return `CarePlan has no recognised category or intent (${categoryTexts(r.category).join(", ") || "none"})`;
2660
2679
  case "Appointment": {
2661
- const type = _nullishCoalesce(_optionalChain([codings, 'call', _243 => _243(r.appointmentType), 'access', _244 => _244[0], 'optionalAccess', _245 => _245.code]), () => ( "none"));
2680
+ const type = _nullishCoalesce(_optionalChain([codings, 'call', _247 => _247(r.appointmentType), 'access', _248 => _248[0], 'optionalAccess', _249 => _249.code]), () => ( "none"));
2662
2681
  return `Appointment type "${type}" is not a follow-up`;
2663
2682
  }
2664
2683
  default:
@@ -2667,10 +2686,11 @@ function unmappedReason(r) {
2667
2686
  }
2668
2687
  function convertPrescriptionBundle(bundle, options = {}) {
2669
2688
  const showCustomSections = _nullishCoalesce(options.showCustomSections, () => ( SHOW_CUSTOM_SECTIONS));
2670
- const entries = Array.isArray(_optionalChain([bundle, 'optionalAccess', _246 => _246.entry])) ? bundle.entry : [];
2671
- const resources = entries.map((e) => _optionalChain([e, 'optionalAccess', _247 => _247.resource])).filter((r) => !!r && typeof r === "object" && typeof r.resourceType === "string").map(stripHtmlDeep);
2689
+ const entries = Array.isArray(_optionalChain([bundle, 'optionalAccess', _250 => _250.entry])) ? bundle.entry : [];
2690
+ const resources = entries.map((e) => _optionalChain([e, 'optionalAccess', _251 => _251.resource])).filter((r) => !!r && typeof r === "object" && typeof r.resourceType === "string").map(stripHtmlDeep);
2672
2691
  const header = buildHeader(resources);
2673
2692
  const sectionOf = compositionSectionMap(resources);
2693
+ const specialties = practitionerSpecialties(resources);
2674
2694
  const diagnostics = [];
2675
2695
  const report = (r, reason) => diagnostics.push({ resourceType: r.resourceType, id: _nullishCoalesce(r.id, () => ( null)), reason });
2676
2696
  const symptoms = [];
@@ -2773,7 +2793,7 @@ function convertPrescriptionBundle(bundle, options = {}) {
2773
2793
  break;
2774
2794
  }
2775
2795
  case "referral":
2776
- pushRow(referrals, referralRow(r), r);
2796
+ pushRow(referrals, referralRow(r, specialties), r);
2777
2797
  break;
2778
2798
  case "ipAdmission":
2779
2799
  admissionNoteLines.push(admissionNotes(r));
@@ -2883,7 +2903,7 @@ function cellText(kind, key, value) {
2883
2903
  return value;
2884
2904
  }
2885
2905
  function visibleColumns(headers, rows) {
2886
- return headers.filter((h, i) => !HIDDEN_COLUMNS.has(h.key) && (i === 0 || rows.some((r) => _optionalChain([r, 'access', _248 => _248[h.key], 'optionalAccess', _249 => _249.trim, 'call', _250 => _250()]))));
2906
+ return headers.filter((h, i) => !HIDDEN_COLUMNS.has(h.key) && (i === 0 || rows.some((r) => _optionalChain([r, 'access', _252 => _252[h.key], 'optionalAccess', _253 => _253.trim, 'call', _254 => _254()]))));
2887
2907
  }
2888
2908
  function rowsToLineItems(headers, rows, skip = []) {
2889
2909
  const [nameColumn, ...rest] = headers.filter((h) => !HIDDEN_COLUMNS.has(h.key) && !skip.includes(h.key));
@@ -3007,7 +3027,7 @@ function markdownToText(markdown) {
3007
3027
  function tableLines(section) {
3008
3028
  const payload = section.payload;
3009
3029
  const columns = visibleColumns(payload.headers, payload.rows);
3010
- const nameKey = _nullishCoalesce(_optionalChain([columns, 'access', _251 => _251[0], 'optionalAccess', _252 => _252.key]), () => ( ""));
3030
+ const nameKey = _nullishCoalesce(_optionalChain([columns, 'access', _255 => _255[0], 'optionalAccess', _256 => _256.key]), () => ( ""));
3011
3031
  return payload.rows.map((row) => {
3012
3032
  const name = cellText(section.kind, nameKey, _nullishCoalesce(row[nameKey], () => ( ""))).trim();
3013
3033
  const details = columns.slice(1).map((c) => ({ label: c.label, value: cellText(section.kind, c.key, _nullishCoalesce(row[c.key], () => ( ""))).trim() })).filter((d) => d.value).map((d) => `${d.label}: ${d.value}`);
@@ -3115,7 +3135,7 @@ function SectionFieldRows({ fields }) {
3115
3135
  var MIN_COLUMN_PX = 60;
3116
3136
  function SectionTable({ kind, payload }) {
3117
3137
  const columns = visibleColumns(payload.headers, payload.rows);
3118
- const nameKey = _nullishCoalesce(_optionalChain([columns, 'access', _253 => _253[0], 'optionalAccess', _254 => _254.key]), () => ( ""));
3138
+ const nameKey = _nullishCoalesce(_optionalChain([columns, 'access', _257 => _257[0], 'optionalAccess', _258 => _258.key]), () => ( ""));
3119
3139
  if (columns.length <= 1) {
3120
3140
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ol", { className: "mr-rx-list", children: payload.rows.map((r, i) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { children: _nullishCoalesce(r[nameKey], () => ( "")) }, i)) });
3121
3141
  }
@@ -3170,7 +3190,7 @@ function PrescriptionSectionBody({ section }) {
3170
3190
  case "LIST": {
3171
3191
  const payload = section.payload;
3172
3192
  if (payload.entries) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LineItemList, { entries: payload.entries });
3173
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ol", { className: "mr-rx-list", children: payload.items.map((item, i) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ListItemText, { item, lead: _optionalChain([payload, 'access', _255 => _255.leads, 'optionalAccess', _256 => _256[i]]), since: _optionalChain([payload, 'access', _257 => _257.since, 'optionalAccess', _258 => _258[i]]) }) }, i)) });
3193
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ol", { className: "mr-rx-list", children: payload.items.map((item, i) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ListItemText, { item, lead: _optionalChain([payload, 'access', _259 => _259.leads, 'optionalAccess', _260 => _260[i]]), since: _optionalChain([payload, 'access', _261 => _261.since, 'optionalAccess', _262 => _262[i]]) }) }, i)) });
3174
3194
  }
3175
3195
  case "KEY_VALUE":
3176
3196
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FieldRows, { fields: sectionFields(section) });
@@ -3198,14 +3218,14 @@ var PrescriptionSectionCard = _react.memo.call(void 0, function PrescriptionSect
3198
3218
  const copyResetRef = _react.useRef.call(void 0, void 0);
3199
3219
  _react.useEffect.call(void 0, () => () => clearTimeout(copyResetRef.current), []);
3200
3220
  const handleCardClick = _react.useCallback.call(void 0, () => {
3201
- if (_optionalChain([window, 'access', _259 => _259.getSelection, 'call', _260 => _260(), 'optionalAccess', _261 => _261.toString, 'call', _262 => _262()])) return;
3202
- _optionalChain([onToggle, 'optionalCall', _263 => _263(section.key)]);
3221
+ if (_optionalChain([window, 'access', _263 => _263.getSelection, 'call', _264 => _264(), 'optionalAccess', _265 => _265.toString, 'call', _266 => _266()])) return;
3222
+ _optionalChain([onToggle, 'optionalCall', _267 => _267(section.key)]);
3203
3223
  }, [onToggle, section.key]);
3204
3224
  const handleCheckKeyDown = _react.useCallback.call(void 0,
3205
3225
  (e) => {
3206
3226
  if (e.key !== " " && e.key !== "Enter") return;
3207
3227
  e.preventDefault();
3208
- _optionalChain([onToggle, 'optionalCall', _264 => _264(section.key)]);
3228
+ _optionalChain([onToggle, 'optionalCall', _268 => _268(section.key)]);
3209
3229
  },
3210
3230
  [onToggle, section.key]
3211
3231
  );
@@ -3325,7 +3345,7 @@ function PrescriptionPanel({ conversion, typeCode, source, onBack, onViewOrigina
3325
3345
  [onCopySections, selectedKeys, sections]
3326
3346
  );
3327
3347
  const handleAddToContext = _react.useCallback.call(void 0, () => {
3328
- _optionalChain([onAttach, 'optionalCall', _265 => _265(date ? `Prescription \xB7 ${date}` : "Prescription")]);
3348
+ _optionalChain([onAttach, 'optionalCall', _269 => _269(date ? `Prescription \xB7 ${date}` : "Prescription")]);
3329
3349
  }, [onAttach, date]);
3330
3350
  const canCopy = !!onCopySections && !isEmpty;
3331
3351
  const canAttach = !!onAttach && !isEmpty;
@@ -3399,12 +3419,12 @@ function ScribeDocumentPanel({
3399
3419
  const handleCopyFooter = _react.useCallback.call(void 0,
3400
3420
  (e) => {
3401
3421
  const rect = e.currentTarget.getBoundingClientRect();
3402
- void _optionalChain([copyState, 'optionalAccess', _266 => _266.copy, 'call', _267 => _267({ x: rect.left + rect.width / 2, y: rect.bottom })]);
3422
+ void _optionalChain([copyState, 'optionalAccess', _270 => _270.copy, 'call', _271 => _271({ x: rect.left + rect.width / 2, y: rect.bottom })]);
3403
3423
  },
3404
3424
  [copyState]
3405
3425
  );
3406
3426
  const handleAddToContext = _react.useCallback.call(void 0, () => {
3407
- _optionalChain([onAttach, 'optionalCall', _268 => _268(date ? `Prescription \xB7 ${date}` : "Prescription")]);
3427
+ _optionalChain([onAttach, 'optionalCall', _272 => _272(date ? `Prescription \xB7 ${date}` : "Prescription")]);
3408
3428
  }, [onAttach, date]);
3409
3429
  const canCopy = !!copyState && copyState.total > 0;
3410
3430
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mr-sv__panel", children: [
@@ -3447,7 +3467,7 @@ function RecordPanel({ recordId, caseId, onBack }) {
3447
3467
  const record = _zustand.useStore.call(void 0, store, (s) => s.records.byId[recordId]);
3448
3468
  const { openOriginal, attachToContext, onCopyPrescriptionSections, renderScribeDocument } = _chunkX5ATIBJ3js.useSmartRecordsActions.call(void 0, );
3449
3469
  const preview = _chunkX5ATIBJ3js.useRecordPreview.call(void 0, recordId);
3450
- const source = _nullishCoalesce(_optionalChain([record, 'optionalAccess', _269 => _269.source]), () => ( preview.source));
3470
+ const source = _nullishCoalesce(_optionalChain([record, 'optionalAccess', _273 => _273.source]), () => ( preview.source));
3451
3471
  const [unavailableFor, setUnavailableFor] = _react.useState.call(void 0, null);
3452
3472
  _react.useEffect.call(void 0, () => setUnavailableFor(null), [recordId]);
3453
3473
  const handleScribeUnavailable = _react.useCallback.call(void 0, () => setUnavailableFor(recordId), [recordId]);
@@ -3461,7 +3481,7 @@ function RecordPanel({ recordId, caseId, onBack }) {
3461
3481
  [openOriginal, recordId, caseId]
3462
3482
  );
3463
3483
  const handleAttach = _react.useCallback.call(void 0,
3464
- (name) => void _optionalChain([attachToContext, 'optionalCall', _270 => _270(recordId, name, recordId)]),
3484
+ (name) => void _optionalChain([attachToContext, 'optionalCall', _274 => _274(recordId, name, recordId)]),
3465
3485
  [attachToContext, recordId]
3466
3486
  );
3467
3487
  if (preview.status === "loading") {
@@ -3480,9 +3500,9 @@ function RecordPanel({ recordId, caseId, onBack }) {
3480
3500
  {
3481
3501
  documentId,
3482
3502
  recordId,
3483
- title: _nullishCoalesce(_optionalChain([record, 'optionalAccess', _271 => _271.title]), () => ( "Prescription")),
3503
+ title: _nullishCoalesce(_optionalChain([record, 'optionalAccess', _275 => _275.title]), () => ( "Prescription")),
3484
3504
  date: record ? _chunkV3EM6XIMjs.epochToDisplay.call(void 0, record.createdAtEpoch) : "",
3485
- typeCode: _optionalChain([record, 'optionalAccess', _272 => _272.typeCode]),
3505
+ typeCode: _optionalChain([record, 'optionalAccess', _276 => _276.typeCode]),
3486
3506
  source: _nullishCoalesce(source, () => ( void 0)),
3487
3507
  renderDocument: renderScribeDocument,
3488
3508
  onUnavailable: handleScribeUnavailable,
@@ -3497,7 +3517,7 @@ function RecordPanel({ recordId, caseId, onBack }) {
3497
3517
  PrescriptionPanel,
3498
3518
  {
3499
3519
  conversion,
3500
- typeCode: _optionalChain([record, 'optionalAccess', _273 => _273.typeCode]),
3520
+ typeCode: _optionalChain([record, 'optionalAccess', _277 => _277.typeCode]),
3501
3521
  source: _nullishCoalesce(source, () => ( void 0)),
3502
3522
  onBack,
3503
3523
  onViewOriginal: preview.files.length > 0 ? handleViewOriginal : void 0,
@@ -3507,7 +3527,7 @@ function RecordPanel({ recordId, caseId, onBack }) {
3507
3527
  recordId
3508
3528
  );
3509
3529
  }
3510
- if (_optionalChain([record, 'optionalAccess', _274 => _274.isSmart])) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SmartRecordSmartPanel, { recordId, caseId, onBack });
3530
+ if (_optionalChain([record, 'optionalAccess', _278 => _278.isSmart])) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SmartRecordSmartPanel, { recordId, caseId, onBack });
3511
3531
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SmartRecordPreviewPanel, { recordId, preview, onBack });
3512
3532
  }
3513
3533
 
@@ -3526,7 +3546,7 @@ function useJumpToSelected(activeId, listKey) {
3526
3546
  }, []);
3527
3547
  const [state, setState] = _react.useState.call(void 0, HIDDEN);
3528
3548
  const evaluate = _react.useCallback.call(void 0, () => {
3529
- const active = _nullishCoalesce(_optionalChain([body, 'optionalAccess', _275 => _275.querySelector, 'call', _276 => _276(".mr-sv__record-item--active")]), () => ( null));
3549
+ const active = _nullishCoalesce(_optionalChain([body, 'optionalAccess', _279 => _279.querySelector, 'call', _280 => _280(".mr-sv__record-item--active")]), () => ( null));
3530
3550
  if (!body || !active) {
3531
3551
  setState((s) => s.visible ? HIDDEN : s);
3532
3552
  return;
@@ -3554,7 +3574,7 @@ function useJumpToSelected(activeId, listKey) {
3554
3574
  evaluate();
3555
3575
  }, [evaluate, listKey]);
3556
3576
  const jumpToSelected = _react.useCallback.call(void 0, () => {
3557
- _optionalChain([body, 'optionalAccess', _277 => _277.querySelector, 'call', _278 => _278(".mr-sv__record-item--active"), 'optionalAccess', _279 => _279.scrollIntoView, 'call', _280 => _280({ behavior: "smooth", block: "center" })]);
3577
+ _optionalChain([body, 'optionalAccess', _281 => _281.querySelector, 'call', _282 => _282(".mr-sv__record-item--active"), 'optionalAccess', _283 => _283.scrollIntoView, 'call', _284 => _284({ behavior: "smooth", block: "center" })]);
3558
3578
  }, [body]);
3559
3579
  return {
3560
3580
  scrollBodyRef,
@@ -3606,10 +3626,10 @@ function toCollectionFilter(filters) {
3606
3626
  // src/views/hooks/smart-records/searchCollection.ts
3607
3627
  var isRecord = (item) => "document_id" in item.data;
3608
3628
  function recordText(data, labelOf) {
3609
- return [_nullishCoalesce(_optionalChain([data, 'access', _281 => _281.metadata, 'optionalAccess', _282 => _282.title]), () => ( "")), labelOf(_nullishCoalesce(data.document_type, () => ( ""))), ..._nullishCoalesce(_optionalChain([data, 'access', _283 => _283.metadata, 'optionalAccess', _284 => _284.tags]), () => ( []))];
3629
+ return [_nullishCoalesce(_optionalChain([data, 'access', _285 => _285.metadata, 'optionalAccess', _286 => _286.title]), () => ( "")), labelOf(_nullishCoalesce(data.document_type, () => ( ""))), ..._nullishCoalesce(_optionalChain([data, 'access', _287 => _287.metadata, 'optionalAccess', _288 => _288.tags]), () => ( []))];
3610
3630
  }
3611
3631
  function caseText(item) {
3612
- return [_nullishCoalesce(_nullishCoalesce(item.title, () => ( _optionalChain([item, 'access', _285 => _285.data, 'access', _286 => _286.item, 'optionalAccess', _287 => _287.display_name]))), () => ( ""))];
3632
+ return [_nullishCoalesce(_nullishCoalesce(item.title, () => ( _optionalChain([item, 'access', _289 => _289.data, 'access', _290 => _290.item, 'optionalAccess', _291 => _291.display_name]))), () => ( ""))];
3613
3633
  }
3614
3634
  function searchCollection(groups, query, labelOf) {
3615
3635
  const q = query.trim().toLowerCase();
@@ -3695,10 +3715,10 @@ function buildSidebarRows(groups, labelOf) {
3695
3715
  kind: ROW_KIND.Case,
3696
3716
  id: item.id,
3697
3717
  date: _nullishCoalesce(newest, () => ( item.date)),
3698
- title: item.title || _optionalChain([data, 'access', _288 => _288.item, 'optionalAccess', _289 => _289.display_name]) || "Untitled case",
3718
+ title: item.title || _optionalChain([data, 'access', _292 => _292.item, 'optionalAccess', _293 => _293.display_name]) || "Untitled case",
3699
3719
  typeCode: "",
3700
3720
  isSmart: false,
3701
- caseTypeCode: _nullishCoalesce(_optionalChain([data, 'access', _290 => _290.item, 'optionalAccess', _291 => _291.type]), () => ( "")),
3721
+ caseTypeCode: _nullishCoalesce(_optionalChain([data, 'access', _294 => _294.item, 'optionalAccess', _295 => _295.type]), () => ( "")),
3702
3722
  recordCount: linked.length,
3703
3723
  ...matched2 ? { matchCount: matched2.length } : {}
3704
3724
  };
@@ -3751,7 +3771,7 @@ function useSidebarCollection({ limit } = {}) {
3751
3771
  return {
3752
3772
  rows,
3753
3773
  months,
3754
- latestId: _nullishCoalesce(_optionalChain([rows, 'access', _292 => _292[0], 'optionalAccess', _293 => _293.id]), () => ( null)),
3774
+ latestId: _nullishCoalesce(_optionalChain([rows, 'access', _296 => _296[0], 'optionalAccess', _297 => _297.id]), () => ( null)),
3755
3775
  matchingRecordCount: _react.useMemo.call(void 0, () => countRecordItems(searched), [searched]),
3756
3776
  hasActiveFilter: hasSidebarFilter(filters),
3757
3777
  search: filters.search
@@ -3929,7 +3949,7 @@ function resolveContentType(file) {
3929
3949
  if (t === "image/jpeg" || t === "image/jpg" || t === "image/png" || t === "application/pdf") {
3930
3950
  return t;
3931
3951
  }
3932
- const ext = _optionalChain([file, 'access', _294 => _294.name, 'access', _295 => _295.split, 'call', _296 => _296("."), 'access', _297 => _297.pop, 'call', _298 => _298(), 'optionalAccess', _299 => _299.toLowerCase, 'call', _300 => _300()]);
3952
+ const ext = _optionalChain([file, 'access', _298 => _298.name, 'access', _299 => _299.split, 'call', _300 => _300("."), 'access', _301 => _301.pop, 'call', _302 => _302(), 'optionalAccess', _303 => _303.toLowerCase, 'call', _304 => _304()]);
3933
3953
  if (ext === "pdf") return "application/pdf";
3934
3954
  if (ext === "png") return "image/png";
3935
3955
  if (ext === "jpg" || ext === "jpeg") return "image/jpeg";
@@ -3968,12 +3988,12 @@ function useUploadConnection() {
3968
3988
  patientId
3969
3989
  });
3970
3990
  const queue2 = store.getState().uploadQueue;
3971
- if (res.message === "queued_offline" || !_optionalChain([res, 'access', _301 => _301.batch_response, 'optionalAccess', _302 => _302.length])) {
3991
+ if (res.message === "queued_offline" || !_optionalChain([res, 'access', _305 => _305.batch_response, 'optionalAccess', _306 => _306.length])) {
3972
3992
  throw new Error("No internet connection. Your upload will retry automatically when you're back online.");
3973
3993
  }
3974
3994
  localIds.forEach((id, i) => {
3975
- const documentId = _nullishCoalesce(_optionalChain([res, 'access', _303 => _303.batch_response, 'optionalAccess', _304 => _304[i], 'optionalAccess', _305 => _305.document_id]), () => ( ""));
3976
- const errorDetails = _optionalChain([res, 'access', _306 => _306.batch_response, 'optionalAccess', _307 => _307[i], 'optionalAccess', _308 => _308.error_details]);
3995
+ const documentId = _nullishCoalesce(_optionalChain([res, 'access', _307 => _307.batch_response, 'optionalAccess', _308 => _308[i], 'optionalAccess', _309 => _309.document_id]), () => ( ""));
3996
+ const errorDetails = _optionalChain([res, 'access', _310 => _310.batch_response, 'optionalAccess', _311 => _311[i], 'optionalAccess', _312 => _312.error_details]);
3977
3997
  if (errorDetails) {
3978
3998
  queue2.markFailed(id);
3979
3999
  } else {
@@ -4117,7 +4137,7 @@ function useFilteredRecordIds2() {
4117
4137
 
4118
4138
 
4119
4139
  var HighlightedText = _react.memo.call(void 0, function HighlightedText2({ text, query }) {
4120
- const q = _nullishCoalesce(_optionalChain([query, 'optionalAccess', _309 => _309.trim, 'call', _310 => _310(), 'access', _311 => _311.toLowerCase, 'call', _312 => _312()]), () => ( ""));
4140
+ const q = _nullishCoalesce(_optionalChain([query, 'optionalAccess', _313 => _313.trim, 'call', _314 => _314(), 'access', _315 => _315.toLowerCase, 'call', _316 => _316()]), () => ( ""));
4121
4141
  const start = q ? text.toLowerCase().indexOf(q) : -1;
4122
4142
  if (start < 0) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: text });
4123
4143
  const end = start + q.length;
@@ -4292,7 +4312,7 @@ var SidebarSearchField = _react.memo.call(void 0, function SidebarSearchField2({
4292
4312
  function summarize(options, value) {
4293
4313
  if (value.length === 0) return "All";
4294
4314
  if (value.length > 2) return `${value.length} types`;
4295
- return value.map((id) => _nullishCoalesce(_optionalChain([options, 'access', _313 => _313.find, 'call', _314 => _314((o) => o.id === id), 'optionalAccess', _315 => _315.display_name]), () => ( id))).join(", ");
4315
+ return value.map((id) => _nullishCoalesce(_optionalChain([options, 'access', _317 => _317.find, 'call', _318 => _318((o) => o.id === id), 'optionalAccess', _319 => _319.display_name]), () => ( id))).join(", ");
4296
4316
  }
4297
4317
  function SidebarTypeSelect({ options, value, onChange }) {
4298
4318
  const [open, setOpen] = _react.useState.call(void 0, false);
@@ -4301,7 +4321,7 @@ function SidebarTypeSelect({ options, value, onChange }) {
4301
4321
  _react.useEffect.call(void 0, () => {
4302
4322
  if (!open) return;
4303
4323
  const onMouseDown = (e) => {
4304
- if (!_optionalChain([rootRef, 'access', _316 => _316.current, 'optionalAccess', _317 => _317.contains, 'call', _318 => _318(e.target)])) setOpen(false);
4324
+ if (!_optionalChain([rootRef, 'access', _320 => _320.current, 'optionalAccess', _321 => _321.contains, 'call', _322 => _322(e.target)])) setOpen(false);
4305
4325
  };
4306
4326
  document.addEventListener("mousedown", onMouseDown);
4307
4327
  return () => document.removeEventListener("mousedown", onMouseDown);
@@ -4375,7 +4395,7 @@ function SidebarFilterPopover({ containerRef, onClose }) {
4375
4395
  }));
4376
4396
  _react.useEffect.call(void 0, () => {
4377
4397
  const handler = (e) => {
4378
- if (_optionalChain([containerRef, 'access', _319 => _319.current, 'optionalAccess', _320 => _320.contains, 'call', _321 => _321(e.target)])) return;
4398
+ if (_optionalChain([containerRef, 'access', _323 => _323.current, 'optionalAccess', _324 => _324.contains, 'call', _325 => _325(e.target)])) return;
4379
4399
  onClose();
4380
4400
  };
4381
4401
  document.addEventListener("mousedown", handler);
@@ -4781,32 +4801,32 @@ function SmartRecordsViewInner({
4781
4801
  onViewChangeRef.current = onViewChange;
4782
4802
  renderScribeDocumentRef.current = renderScribeDocument;
4783
4803
  _react.useEffect.call(void 0, () => {
4784
- _optionalChain([onViewChangeRef, 'access', _322 => _322.current, 'optionalCall', _323 => _323(mainView)]);
4804
+ _optionalChain([onViewChangeRef, 'access', _326 => _326.current, 'optionalCall', _327 => _327(mainView)]);
4785
4805
  }, [mainView]);
4786
4806
  const [selectedCaseId, setSelectedCaseId] = _react.useState.call(void 0, null);
4787
4807
  const [uploadOpen, setUploadOpen] = _react.useState.call(void 0, false);
4788
4808
  const stableCopyToNote = _react.useCallback.call(void 0,
4789
- (text, anchor, vitalsRows) => _optionalChain([onCopyToNoteRef, 'access', _324 => _324.current, 'optionalCall', _325 => _325(text, anchor, vitalsRows)]),
4809
+ (text, anchor, vitalsRows) => _optionalChain([onCopyToNoteRef, 'access', _328 => _328.current, 'optionalCall', _329 => _329(text, anchor, vitalsRows)]),
4790
4810
  []
4791
4811
  );
4792
4812
  const stableCopyPrescriptionSections = _react.useCallback.call(void 0,
4793
- (sections, anchor) => _optionalChain([onCopyPrescriptionSectionsRef, 'access', _326 => _326.current, 'optionalCall', _327 => _327(sections, anchor)]),
4813
+ (sections, anchor) => _optionalChain([onCopyPrescriptionSectionsRef, 'access', _330 => _330.current, 'optionalCall', _331 => _331(sections, anchor)]),
4794
4814
  []
4795
4815
  );
4796
4816
  const stableCopyVitalsToNote = _react.useCallback.call(void 0,
4797
- (text) => _optionalChain([onCopyVitalsToNoteRef, 'access', _328 => _328.current, 'optionalCall', _329 => _329(text)]),
4817
+ (text) => _optionalChain([onCopyVitalsToNoteRef, 'access', _332 => _332.current, 'optionalCall', _333 => _333(text)]),
4798
4818
  []
4799
4819
  );
4800
4820
  const stableToast = _react.useCallback.call(void 0,
4801
- (message, type) => _optionalChain([onToastRef, 'access', _330 => _330.current, 'optionalCall', _331 => _331(message, type)]),
4821
+ (message, type) => _optionalChain([onToastRef, 'access', _334 => _334.current, 'optionalCall', _335 => _335(message, type)]),
4802
4822
  []
4803
4823
  );
4804
4824
  const stableRenderScribeDocument = _react.useCallback.call(void 0,
4805
- (args) => _nullishCoalesce(_optionalChain([renderScribeDocumentRef, 'access', _332 => _332.current, 'optionalCall', _333 => _333(args)]), () => ( null)),
4825
+ (args) => _nullishCoalesce(_optionalChain([renderScribeDocumentRef, 'access', _336 => _336.current, 'optionalCall', _337 => _337(args)]), () => ( null)),
4806
4826
  []
4807
4827
  );
4808
4828
  const attachToContext = _react.useCallback.call(void 0, (documentId, name, visitId) => {
4809
- void _optionalChain([onAddToContextRef, 'access', _334 => _334.current, 'optionalCall', _335 => _335([visitId ? { documentId, name, visitId } : { documentId, name }])]);
4829
+ void _optionalChain([onAddToContextRef, 'access', _338 => _338.current, 'optionalCall', _339 => _339([visitId ? { documentId, name, visitId } : { documentId, name }])]);
4810
4830
  }, []);
4811
4831
  const handleSelectCase = _react.useCallback.call(void 0,
4812
4832
  (caseId) => {