@eka-care/medical-records-ui 1.2.42 → 1.2.44

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.d.mts CHANGED
@@ -354,6 +354,7 @@ interface CopyAnchor$1 {
354
354
  type CopyPrescriptionSections = (sections: PrescriptionSection[], anchor?: CopyAnchor$1) => void | boolean | Promise<void | boolean>;
355
355
  interface PrescriptionPanelProps {
356
356
  conversion: PrescriptionConversion;
357
+ title: string;
357
358
  typeCode?: string;
358
359
  source?: string;
359
360
  onBack?: () => void;
@@ -361,7 +362,7 @@ interface PrescriptionPanelProps {
361
362
  onAttach?: (name: string) => void;
362
363
  onCopySections?: CopyPrescriptionSections;
363
364
  }
364
- declare function PrescriptionPanel({ conversion, typeCode, source, onBack, onViewOriginal, onAttach, onCopySections }: PrescriptionPanelProps): react.JSX.Element;
365
+ declare function PrescriptionPanel({ conversion, title, typeCode, source, onBack, onViewOriginal, onAttach, onCopySections }: PrescriptionPanelProps): react.JSX.Element;
365
366
 
366
367
  interface CopyAnchor {
367
368
  x: number;
package/dist/index.d.ts CHANGED
@@ -354,6 +354,7 @@ interface CopyAnchor$1 {
354
354
  type CopyPrescriptionSections = (sections: PrescriptionSection[], anchor?: CopyAnchor$1) => void | boolean | Promise<void | boolean>;
355
355
  interface PrescriptionPanelProps {
356
356
  conversion: PrescriptionConversion;
357
+ title: string;
357
358
  typeCode?: string;
358
359
  source?: string;
359
360
  onBack?: () => void;
@@ -361,7 +362,7 @@ interface PrescriptionPanelProps {
361
362
  onAttach?: (name: string) => void;
362
363
  onCopySections?: CopyPrescriptionSections;
363
364
  }
364
- declare function PrescriptionPanel({ conversion, typeCode, source, onBack, onViewOriginal, onAttach, onCopySections }: PrescriptionPanelProps): react.JSX.Element;
365
+ declare function PrescriptionPanel({ conversion, title, typeCode, source, onBack, onViewOriginal, onAttach, onCopySections }: PrescriptionPanelProps): react.JSX.Element;
365
366
 
366
367
  interface CopyAnchor {
367
368
  x: number;
package/dist/index.js CHANGED
@@ -1960,7 +1960,7 @@ function conceptDisplay(cc) {
1960
1960
  const pick = _nullishCoalesce(_nullishCoalesce(list.find((c) => EKA_SYSTEM.test(_nullishCoalesce(c.system, () => ( ""))) && c.display), () => ( list.find((c) => SNOMED_SYSTEM.test(_nullishCoalesce(c.system, () => ( ""))) && c.display))), () => ( list.find((c) => c.display)));
1961
1961
  return _optionalChain([pick, 'optionalAccess', _59 => _59.display, 'optionalAccess', _60 => _60.trim, 'call', _61 => _61()]) || _optionalChain([cc, 'optionalAccess', _62 => _62.text, 'optionalAccess', _63 => _63.trim, 'call', _64 => _64()]) || null;
1962
1962
  }
1963
- var MDB_SYSTEM = /eka\.care\/(mdb|medication|service)|mdb\.eka\.care/i;
1963
+ var MDB_SYSTEM = /eka\.care\/mdb|mdb\.eka\.care/i;
1964
1964
  function ekaCode(cc) {
1965
1965
  return _nullishCoalesce(_optionalChain([codings, 'call', _65 => _65(cc), 'access', _66 => _66.find, 'call', _67 => _67((c) => MDB_SYSTEM.test(_nullishCoalesce(c.system, () => ( ""))) && c.code), 'optionalAccess', _68 => _68.code]), () => ( null));
1966
1966
  }
@@ -2205,7 +2205,8 @@ function examinationRow(obs) {
2205
2205
  const details = componentDetails(obs);
2206
2206
  const detail = details.length ? symptomDetails(obs).join(" | ") : _nullishCoalesce(noteText(obs.note), () => ( ""));
2207
2207
  const since = effectiveDateText(obs);
2208
- return { finding, status, detail, ...since ? { since } : {}, ...entityCodes(obs.code) };
2208
+ const codes = entityCodes(obs.code);
2209
+ return { finding, status, detail, ...since ? { since } : {}, finding_id: codes.eka_code, ...codes };
2209
2210
  }
2210
2211
  function socialHistoryRow(obs) {
2211
2212
  const condition = conceptDisplay(obs.code);
@@ -2248,6 +2249,7 @@ function labResultRow(obs) {
2248
2249
  out_of_range: _nullishCoalesce(_nullishCoalesce(INTERPRETATION[code], () => ( conceptDisplay(interpretation))), () => ( "")),
2249
2250
  remark: _nullishCoalesce(noteText(obs.note), () => ( "")),
2250
2251
  ...date ? { date } : {},
2252
+ ekaId: _nullishCoalesce(ekaCode(obs.code), () => ( "")),
2251
2253
  ...entityCodes(obs.code)
2252
2254
  };
2253
2255
  }
@@ -2347,6 +2349,7 @@ function historyRowFromCondition(cond) {
2347
2349
  status: presenceToken(firstCode(cond.clinicalStatus), firstCode(cond.verificationStatus)),
2348
2350
  since: onsetText(cond),
2349
2351
  note: _nullishCoalesce(noteText(cond.note), () => ( "")),
2352
+ diagnosis_id: _nullishCoalesce(ekaCode(cond.code), () => ( "")),
2350
2353
  ...entityCodes(cond.code)
2351
2354
  };
2352
2355
  }
@@ -2363,6 +2366,7 @@ function familyHistoryRows(fmh) {
2363
2366
  status: _nullishCoalesce(conceptDisplay(c.outcome), () => ( "")),
2364
2367
  since: familyOnsetText(c),
2365
2368
  note: [noteText(c.note), notes].filter(Boolean).join(". "),
2369
+ diagnosis_id: _nullishCoalesce(ekaCode(c.code), () => ( "")),
2366
2370
  ...entityCodes(c.code)
2367
2371
  }));
2368
2372
  }
@@ -2382,6 +2386,7 @@ function pastProcedureRow(proc) {
2382
2386
  status: "",
2383
2387
  since: _nullishCoalesce((performed && isoToDisplayDate(performed)), () => ( "")),
2384
2388
  note: _nullishCoalesce(noteText(proc.note), () => ( "")),
2389
+ procedure_id: _nullishCoalesce(ekaCode(proc.code), () => ( "")),
2385
2390
  ...entityCodes(proc.code)
2386
2391
  };
2387
2392
  }
@@ -2399,6 +2404,7 @@ function allergyRow(allergy) {
2399
2404
  const condition = conceptDisplay(allergy.code);
2400
2405
  if (!condition) return null;
2401
2406
  const kinds = Array.isArray(allergy.category) ? allergy.category : [];
2407
+ const codeKey = kinds.includes("medication") ? "medication_id" : "allergy_id";
2402
2408
  return {
2403
2409
  condition,
2404
2410
  category: kinds.includes("medication") ? "drug_allergy" : "other_allergy",
@@ -2408,6 +2414,7 @@ function allergyRow(allergy) {
2408
2414
  allergen_type: kinds.map((k) => ALLERGEN_TYPE[k]).filter(Boolean).join(", "),
2409
2415
  since: allergy.onsetDateTime ? _nullishCoalesce(isoToDisplayDate(allergy.onsetDateTime), () => ( "")) : _nullishCoalesce(_optionalChain([allergy, 'access', _188 => _188.onsetString, 'optionalAccess', _189 => _189.trim, 'call', _190 => _190()]), () => ( "")),
2410
2416
  note: _nullishCoalesce(noteText(allergy.note), () => ( "")),
2417
+ [codeKey]: _nullishCoalesce(ekaCode(allergy.code), () => ( "")),
2411
2418
  ...entityCodes(allergy.code)
2412
2419
  };
2413
2420
  }
@@ -2439,7 +2446,8 @@ function procedureRow(sr) {
2439
2446
  const procedure_name = conceptDisplay(sr.code);
2440
2447
  if (!procedure_name) return null;
2441
2448
  const date = isoToDisplayDate(_nullishCoalesce(_nullishCoalesce(sr.occurrenceDateTime, () => ( _optionalChain([sr, 'access', _201 => _201.occurrenceTiming, 'optionalAccess', _202 => _202.event, 'optionalAccess', _203 => _203[0]]))), () => ( _optionalChain([sr, 'access', _204 => _204.occurrencePeriod, 'optionalAccess', _205 => _205.start]))));
2442
- return { procedure_name, timing: "", note: _nullishCoalesce(noteText(sr.note), () => ( "")), ...date ? { date } : {}, ...entityCodes(sr.code) };
2449
+ const codes = entityCodes(sr.code);
2450
+ return { procedure_name, timing: "", note: _nullishCoalesce(noteText(sr.note), () => ( "")), ...date ? { date } : {}, procedure_id: codes.eka_code, ...codes };
2443
2451
  }
2444
2452
  function performerName(sr) {
2445
2453
  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/")))]);
@@ -2511,10 +2519,10 @@ function medicationRow(mr) {
2511
2519
  const dosage = Array.isArray(mr.dosageInstruction) ? _nullishCoalesce(mr.dosageInstruction[0], () => ( {})) : {};
2512
2520
  return {
2513
2521
  drug_name,
2514
- medication_id: _nullishCoalesce(_nullishCoalesce(ekaCode(mr.medicationCodeableConcept), () => ( _optionalChain([codings, 'call', _233 => _233(mr.medicationCodeableConcept), 'access', _234 => _234[0], 'optionalAccess', _235 => _235.code]))), () => ( "")),
2522
+ medication_id: _nullishCoalesce(ekaCode(mr.medicationCodeableConcept), () => ( "")),
2515
2523
  ...entityCodes(mr.medicationCodeableConcept),
2516
2524
  ...dosageColumns(dosage),
2517
- quantity: _nullishCoalesce(quantityText(_optionalChain([mr, 'access', _236 => _236.dispenseRequest, 'optionalAccess', _237 => _237.quantity])), () => ( "")),
2525
+ quantity: _nullishCoalesce(quantityText(_optionalChain([mr, 'access', _233 => _233.dispenseRequest, 'optionalAccess', _234 => _234.quantity])), () => ( "")),
2518
2526
  notes: (_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(dosage.text, () => ( dosage.patientInstruction)), () => ( noteText(mr.note))), () => ( ""))).trim()
2519
2527
  };
2520
2528
  }
@@ -2526,7 +2534,7 @@ function currentMedicationRow(ms) {
2526
2534
  const since = effectiveDateText(ms);
2527
2535
  return {
2528
2536
  drug_name,
2529
- medication_id: _nullishCoalesce(_nullishCoalesce(ekaCode(ms.medicationCodeableConcept), () => ( _optionalChain([codings, 'call', _238 => _238(ms.medicationCodeableConcept), 'access', _239 => _239[0], 'optionalAccess', _240 => _240.code]))), () => ( "")),
2537
+ medication_id: _nullishCoalesce(ekaCode(ms.medicationCodeableConcept), () => ( "")),
2530
2538
  ...entityCodes(ms.medicationCodeableConcept),
2531
2539
  ...columns,
2532
2540
  frequency: columns.frequency || (_nullishCoalesce(dosage.text, () => ( ""))).trim(),
@@ -2539,7 +2547,7 @@ function currentMedicationRow(ms) {
2539
2547
  // src/prescription/mappers/follow-up.ts
2540
2548
  var DAY_MS = 864e5;
2541
2549
  function followUpPayload(appt, visitDate) {
2542
- const date = (_nullishCoalesce(_nullishCoalesce(appt.start, () => ( _optionalChain([appt, 'access', _241 => _241.requestedPeriod, 'optionalAccess', _242 => _242[0], 'optionalAccess', _243 => _243.start]))), () => ( ""))).trim();
2550
+ const date = (_nullishCoalesce(_nullishCoalesce(appt.start, () => ( _optionalChain([appt, 'access', _235 => _235.requestedPeriod, 'optionalAccess', _236 => _236[0], 'optionalAccess', _237 => _237.start]))), () => ( ""))).trim();
2543
2551
  if (!date) return null;
2544
2552
  const written = (_nullishCoalesce(appt.description, () => ( ""))).trim();
2545
2553
  let interval = written && written !== date ? written : "";
@@ -2635,7 +2643,7 @@ function foldTargetOf(title) {
2635
2643
  }
2636
2644
  function historyCategoryOf(title) {
2637
2645
  const normal = normalTitle(title);
2638
- return _nullishCoalesce(_optionalChain([HISTORY_FOLD_CATEGORIES, 'access', _244 => _244.find, 'call', _245 => _245(([pattern]) => pattern.test(normal)), 'optionalAccess', _246 => _246[1]]), () => ( "condition"));
2646
+ return _nullishCoalesce(_optionalChain([HISTORY_FOLD_CATEGORIES, 'access', _238 => _238.find, 'call', _239 => _239(([pattern]) => pattern.test(normal)), 'optionalAccess', _240 => _240[1]]), () => ( "condition"));
2639
2647
  }
2640
2648
  function foldedRow(target, key, value, title) {
2641
2649
  switch (target) {
@@ -2689,7 +2697,7 @@ function unmappedReason(r) {
2689
2697
  case "CarePlan":
2690
2698
  return `CarePlan has no recognised category or intent (${categoryTexts(r.category).join(", ") || "none"})`;
2691
2699
  case "Appointment": {
2692
- const type = _nullishCoalesce(_optionalChain([codings, 'call', _247 => _247(r.appointmentType), 'access', _248 => _248[0], 'optionalAccess', _249 => _249.code]), () => ( "none"));
2700
+ const type = _nullishCoalesce(_optionalChain([codings, 'call', _241 => _241(r.appointmentType), 'access', _242 => _242[0], 'optionalAccess', _243 => _243.code]), () => ( "none"));
2693
2701
  return `Appointment type "${type}" is not a follow-up`;
2694
2702
  }
2695
2703
  default:
@@ -2698,8 +2706,8 @@ function unmappedReason(r) {
2698
2706
  }
2699
2707
  function convertPrescriptionBundle(bundle, options = {}) {
2700
2708
  const showCustomSections = _nullishCoalesce(options.showCustomSections, () => ( SHOW_CUSTOM_SECTIONS));
2701
- const entries = Array.isArray(_optionalChain([bundle, 'optionalAccess', _250 => _250.entry])) ? bundle.entry : [];
2702
- const resources = entries.map((e) => _optionalChain([e, 'optionalAccess', _251 => _251.resource])).filter((r) => !!r && typeof r === "object" && typeof r.resourceType === "string").map(stripHtmlDeep);
2709
+ const entries = Array.isArray(_optionalChain([bundle, 'optionalAccess', _244 => _244.entry])) ? bundle.entry : [];
2710
+ const resources = entries.map((e) => _optionalChain([e, 'optionalAccess', _245 => _245.resource])).filter((r) => !!r && typeof r === "object" && typeof r.resourceType === "string").map(stripHtmlDeep);
2703
2711
  const header = buildHeader(resources);
2704
2712
  const sectionOf = compositionSectionMap(resources);
2705
2713
  const specialties = practitionerSpecialties(resources);
@@ -2915,7 +2923,7 @@ function cellText(kind, key, value) {
2915
2923
  return value;
2916
2924
  }
2917
2925
  function visibleColumns(headers, rows) {
2918
- 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()]))));
2926
+ return headers.filter((h, i) => !HIDDEN_COLUMNS.has(h.key) && (i === 0 || rows.some((r) => _optionalChain([r, 'access', _246 => _246[h.key], 'optionalAccess', _247 => _247.trim, 'call', _248 => _248()]))));
2919
2927
  }
2920
2928
  function rowsToLineItems(headers, rows, skip = []) {
2921
2929
  const [nameColumn, ...rest] = headers.filter((h) => !HIDDEN_COLUMNS.has(h.key) && !skip.includes(h.key));
@@ -3039,7 +3047,7 @@ function markdownToText(markdown) {
3039
3047
  function tableLines(section) {
3040
3048
  const payload = section.payload;
3041
3049
  const columns = visibleColumns(payload.headers, payload.rows);
3042
- const nameKey = _nullishCoalesce(_optionalChain([columns, 'access', _255 => _255[0], 'optionalAccess', _256 => _256.key]), () => ( ""));
3050
+ const nameKey = _nullishCoalesce(_optionalChain([columns, 'access', _249 => _249[0], 'optionalAccess', _250 => _250.key]), () => ( ""));
3043
3051
  return payload.rows.map((row) => {
3044
3052
  const name = cellText(section.kind, nameKey, _nullishCoalesce(row[nameKey], () => ( ""))).trim();
3045
3053
  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}`);
@@ -3147,7 +3155,7 @@ function SectionFieldRows({ fields }) {
3147
3155
  var MIN_COLUMN_PX = 60;
3148
3156
  function SectionTable({ kind, payload }) {
3149
3157
  const columns = visibleColumns(payload.headers, payload.rows);
3150
- const nameKey = _nullishCoalesce(_optionalChain([columns, 'access', _257 => _257[0], 'optionalAccess', _258 => _258.key]), () => ( ""));
3158
+ const nameKey = _nullishCoalesce(_optionalChain([columns, 'access', _251 => _251[0], 'optionalAccess', _252 => _252.key]), () => ( ""));
3151
3159
  if (columns.length <= 1) {
3152
3160
  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)) });
3153
3161
  }
@@ -3202,7 +3210,7 @@ function PrescriptionSectionBody({ section }) {
3202
3210
  case "LIST": {
3203
3211
  const payload = section.payload;
3204
3212
  if (payload.entries) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LineItemList, { entries: payload.entries });
3205
- 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)) });
3213
+ 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', _253 => _253.leads, 'optionalAccess', _254 => _254[i]]), since: _optionalChain([payload, 'access', _255 => _255.since, 'optionalAccess', _256 => _256[i]]) }) }, i)) });
3206
3214
  }
3207
3215
  case "KEY_VALUE":
3208
3216
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FieldRows, { fields: sectionFields(section) });
@@ -3230,14 +3238,14 @@ var PrescriptionSectionCard = _react.memo.call(void 0, function PrescriptionSect
3230
3238
  const copyResetRef = _react.useRef.call(void 0, void 0);
3231
3239
  _react.useEffect.call(void 0, () => () => clearTimeout(copyResetRef.current), []);
3232
3240
  const handleCardClick = _react.useCallback.call(void 0, () => {
3233
- if (_optionalChain([window, 'access', _263 => _263.getSelection, 'call', _264 => _264(), 'optionalAccess', _265 => _265.toString, 'call', _266 => _266()])) return;
3234
- _optionalChain([onToggle, 'optionalCall', _267 => _267(section.key)]);
3241
+ if (_optionalChain([window, 'access', _257 => _257.getSelection, 'call', _258 => _258(), 'optionalAccess', _259 => _259.toString, 'call', _260 => _260()])) return;
3242
+ _optionalChain([onToggle, 'optionalCall', _261 => _261(section.key)]);
3235
3243
  }, [onToggle, section.key]);
3236
3244
  const handleCheckKeyDown = _react.useCallback.call(void 0,
3237
3245
  (e) => {
3238
3246
  if (e.key !== " " && e.key !== "Enter") return;
3239
3247
  e.preventDefault();
3240
- _optionalChain([onToggle, 'optionalCall', _268 => _268(section.key)]);
3248
+ _optionalChain([onToggle, 'optionalCall', _262 => _262(section.key)]);
3241
3249
  },
3242
3250
  [onToggle, section.key]
3243
3251
  );
@@ -3328,7 +3336,7 @@ function SectionCopyFooter({ selectedCount, allSelected, onToggleAll, onCopy, on
3328
3336
 
3329
3337
  // src/prescription/components/PrescriptionPanel.tsx
3330
3338
 
3331
- function PrescriptionPanel({ conversion, typeCode, source, onBack, onViewOriginal, onAttach, onCopySections }) {
3339
+ function PrescriptionPanel({ conversion, title, typeCode, source, onBack, onViewOriginal, onAttach, onCopySections }) {
3332
3340
  const { header, sections } = conversion;
3333
3341
  const date = isoToDisplayDate(header.date);
3334
3342
  const isEmpty = sections.length === 0;
@@ -3357,8 +3365,8 @@ function PrescriptionPanel({ conversion, typeCode, source, onBack, onViewOrigina
3357
3365
  [onCopySections, selectedKeys, sections]
3358
3366
  );
3359
3367
  const handleAddToContext = _react.useCallback.call(void 0, () => {
3360
- _optionalChain([onAttach, 'optionalCall', _269 => _269(date ? `Prescription \xB7 ${date}` : "Prescription")]);
3361
- }, [onAttach, date]);
3368
+ _optionalChain([onAttach, 'optionalCall', _263 => _263(date ? `${title} \xB7 ${date}` : title)]);
3369
+ }, [onAttach, date, title]);
3362
3370
  const canCopy = !!onCopySections && !isEmpty;
3363
3371
  const canAttach = !!onAttach && !isEmpty;
3364
3372
  const sectionCount = isEmpty ? "No sections" : `${sections.length} section${sections.length !== 1 ? "s" : ""}`;
@@ -3371,7 +3379,7 @@ function PrescriptionPanel({ conversion, typeCode, source, onBack, onViewOrigina
3371
3379
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mr-cc-panel__header", children: [
3372
3380
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mr-cc-panel__header-left", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mr-cc-panel__info", children: [
3373
3381
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mr-cc-panel__name-row", children: [
3374
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2VELBQXAjs.Typography_default, { variant: "label", as: "span", className: "mr-cc-panel__name", children: "Prescription" }),
3382
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2VELBQXAjs.Typography_default, { variant: "label", as: "span", className: "mr-cc-panel__name", children: title }),
3375
3383
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SourceBadge, { typeCode, source })
3376
3384
  ] }),
3377
3385
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "mr-cc-panel__sub", children: meta })
@@ -3431,13 +3439,13 @@ function ScribeDocumentPanel({
3431
3439
  const handleCopyFooter = _react.useCallback.call(void 0,
3432
3440
  (e) => {
3433
3441
  const rect = e.currentTarget.getBoundingClientRect();
3434
- void _optionalChain([copyState, 'optionalAccess', _270 => _270.copy, 'call', _271 => _271({ x: rect.left + rect.width / 2, y: rect.bottom })]);
3442
+ void _optionalChain([copyState, 'optionalAccess', _264 => _264.copy, 'call', _265 => _265({ x: rect.left + rect.width / 2, y: rect.bottom })]);
3435
3443
  },
3436
3444
  [copyState]
3437
3445
  );
3438
3446
  const handleAddToContext = _react.useCallback.call(void 0, () => {
3439
- _optionalChain([onAttach, 'optionalCall', _272 => _272(date ? `Prescription \xB7 ${date}` : "Prescription")]);
3440
- }, [onAttach, date]);
3447
+ _optionalChain([onAttach, 'optionalCall', _266 => _266(date ? `${title} \xB7 ${date}` : title)]);
3448
+ }, [onAttach, date, title]);
3441
3449
  const canCopy = !!copyState && copyState.total > 0;
3442
3450
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mr-sv__panel", children: [
3443
3451
  onBack && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "mr-sv__back-row", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "button", { type: "button", className: "mr-sv__back-btn", onClick: onBack, children: [
@@ -3475,11 +3483,12 @@ function ScribeDocumentPanel({
3475
3483
 
3476
3484
  var SCRIBE_SOURCE2 = "scribe";
3477
3485
  function RecordPanel({ recordId, caseId, onBack }) {
3478
- const { store } = _chunk2VELBQXAjs.useSdk.call(void 0, );
3486
+ const { store, labelOf } = _chunk2VELBQXAjs.useSdk.call(void 0, );
3479
3487
  const record = _zustand.useStore.call(void 0, store, (s) => s.records.byId[recordId]);
3488
+ const title = labelOf(_nullishCoalesce(_optionalChain([record, 'optionalAccess', _267 => _267.typeCode]), () => ( "")));
3480
3489
  const { openOriginal, attachToContext, onCopyPrescriptionSections, renderScribeDocument } = _chunkV4FEDCZCjs.useSmartRecordsActions.call(void 0, );
3481
3490
  const preview = _chunkV4FEDCZCjs.useRecordPreview.call(void 0, recordId);
3482
- const source = _nullishCoalesce(_optionalChain([record, 'optionalAccess', _273 => _273.source]), () => ( preview.source));
3491
+ const source = _nullishCoalesce(_optionalChain([record, 'optionalAccess', _268 => _268.source]), () => ( preview.source));
3483
3492
  const [unavailableFor, setUnavailableFor] = _react.useState.call(void 0, null);
3484
3493
  _react.useEffect.call(void 0, () => setUnavailableFor(null), [recordId]);
3485
3494
  const handleScribeUnavailable = _react.useCallback.call(void 0, () => setUnavailableFor(recordId), [recordId]);
@@ -3493,7 +3502,7 @@ function RecordPanel({ recordId, caseId, onBack }) {
3493
3502
  [openOriginal, recordId, caseId]
3494
3503
  );
3495
3504
  const handleAttach = _react.useCallback.call(void 0,
3496
- (name) => void _optionalChain([attachToContext, 'optionalCall', _274 => _274(recordId, name, recordId)]),
3505
+ (name) => void _optionalChain([attachToContext, 'optionalCall', _269 => _269(recordId, name, recordId)]),
3497
3506
  [attachToContext, recordId]
3498
3507
  );
3499
3508
  if (preview.status === "loading") {
@@ -3512,9 +3521,9 @@ function RecordPanel({ recordId, caseId, onBack }) {
3512
3521
  {
3513
3522
  documentId,
3514
3523
  recordId,
3515
- title: _nullishCoalesce(_optionalChain([record, 'optionalAccess', _275 => _275.title]), () => ( "Prescription")),
3524
+ title,
3516
3525
  date: record ? _chunk2VELBQXAjs.epochToDisplay.call(void 0, record.createdAtEpoch) : "",
3517
- typeCode: _optionalChain([record, 'optionalAccess', _276 => _276.typeCode]),
3526
+ typeCode: _optionalChain([record, 'optionalAccess', _270 => _270.typeCode]),
3518
3527
  source: _nullishCoalesce(source, () => ( void 0)),
3519
3528
  renderDocument: renderScribeDocument,
3520
3529
  onUnavailable: handleScribeUnavailable,
@@ -3529,7 +3538,8 @@ function RecordPanel({ recordId, caseId, onBack }) {
3529
3538
  PrescriptionPanel,
3530
3539
  {
3531
3540
  conversion,
3532
- typeCode: _optionalChain([record, 'optionalAccess', _277 => _277.typeCode]),
3541
+ title,
3542
+ typeCode: _optionalChain([record, 'optionalAccess', _271 => _271.typeCode]),
3533
3543
  source: _nullishCoalesce(source, () => ( void 0)),
3534
3544
  onBack,
3535
3545
  onViewOriginal: preview.files.length > 0 ? handleViewOriginal : void 0,
@@ -3539,7 +3549,7 @@ function RecordPanel({ recordId, caseId, onBack }) {
3539
3549
  recordId
3540
3550
  );
3541
3551
  }
3542
- if (_optionalChain([record, 'optionalAccess', _278 => _278.isSmart])) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SmartRecordSmartPanel, { recordId, caseId, onBack });
3552
+ if (_optionalChain([record, 'optionalAccess', _272 => _272.isSmart])) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SmartRecordSmartPanel, { recordId, caseId, onBack });
3543
3553
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SmartRecordPreviewPanel, { recordId, preview, onBack });
3544
3554
  }
3545
3555
 
@@ -3558,7 +3568,7 @@ function useJumpToSelected(activeId, listKey) {
3558
3568
  }, []);
3559
3569
  const [state, setState] = _react.useState.call(void 0, HIDDEN);
3560
3570
  const evaluate = _react.useCallback.call(void 0, () => {
3561
- const active = _nullishCoalesce(_optionalChain([body, 'optionalAccess', _279 => _279.querySelector, 'call', _280 => _280(".mr-sv__record-item--active")]), () => ( null));
3571
+ const active = _nullishCoalesce(_optionalChain([body, 'optionalAccess', _273 => _273.querySelector, 'call', _274 => _274(".mr-sv__record-item--active")]), () => ( null));
3562
3572
  if (!body || !active) {
3563
3573
  setState((s) => s.visible ? HIDDEN : s);
3564
3574
  return;
@@ -3586,7 +3596,7 @@ function useJumpToSelected(activeId, listKey) {
3586
3596
  evaluate();
3587
3597
  }, [evaluate, listKey]);
3588
3598
  const jumpToSelected = _react.useCallback.call(void 0, () => {
3589
- _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" })]);
3599
+ _optionalChain([body, 'optionalAccess', _275 => _275.querySelector, 'call', _276 => _276(".mr-sv__record-item--active"), 'optionalAccess', _277 => _277.scrollIntoView, 'call', _278 => _278({ behavior: "smooth", block: "center" })]);
3590
3600
  }, [body]);
3591
3601
  return {
3592
3602
  scrollBodyRef,
@@ -3638,10 +3648,10 @@ function toCollectionFilter(filters) {
3638
3648
  // src/views/hooks/smart-records/searchCollection.ts
3639
3649
  var isRecord = (item) => "document_id" in item.data;
3640
3650
  function recordText(data, labelOf) {
3641
- 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]), () => ( []))];
3651
+ return [_nullishCoalesce(_optionalChain([data, 'access', _279 => _279.metadata, 'optionalAccess', _280 => _280.title]), () => ( "")), labelOf(_nullishCoalesce(data.document_type, () => ( ""))), ..._nullishCoalesce(_optionalChain([data, 'access', _281 => _281.metadata, 'optionalAccess', _282 => _282.tags]), () => ( []))];
3642
3652
  }
3643
3653
  function caseText(item) {
3644
- return [_nullishCoalesce(_nullishCoalesce(item.title, () => ( _optionalChain([item, 'access', _289 => _289.data, 'access', _290 => _290.item, 'optionalAccess', _291 => _291.display_name]))), () => ( ""))];
3654
+ return [_nullishCoalesce(_nullishCoalesce(item.title, () => ( _optionalChain([item, 'access', _283 => _283.data, 'access', _284 => _284.item, 'optionalAccess', _285 => _285.display_name]))), () => ( ""))];
3645
3655
  }
3646
3656
  function searchCollection(groups, query, labelOf) {
3647
3657
  const q = query.trim().toLowerCase();
@@ -3727,10 +3737,10 @@ function buildSidebarRows(groups, labelOf) {
3727
3737
  kind: ROW_KIND.Case,
3728
3738
  id: item.id,
3729
3739
  date: _nullishCoalesce(newest, () => ( item.date)),
3730
- title: item.title || _optionalChain([data, 'access', _292 => _292.item, 'optionalAccess', _293 => _293.display_name]) || "Untitled case",
3740
+ title: item.title || _optionalChain([data, 'access', _286 => _286.item, 'optionalAccess', _287 => _287.display_name]) || "Untitled case",
3731
3741
  typeCode: "",
3732
3742
  isSmart: false,
3733
- caseTypeCode: _nullishCoalesce(_optionalChain([data, 'access', _294 => _294.item, 'optionalAccess', _295 => _295.type]), () => ( "")),
3743
+ caseTypeCode: _nullishCoalesce(_optionalChain([data, 'access', _288 => _288.item, 'optionalAccess', _289 => _289.type]), () => ( "")),
3734
3744
  recordCount: linked.length,
3735
3745
  ...matched2 ? { matchCount: matched2.length } : {}
3736
3746
  };
@@ -3783,7 +3793,7 @@ function useSidebarCollection({ limit } = {}) {
3783
3793
  return {
3784
3794
  rows,
3785
3795
  months,
3786
- latestId: _nullishCoalesce(_optionalChain([rows, 'access', _296 => _296[0], 'optionalAccess', _297 => _297.id]), () => ( null)),
3796
+ latestId: _nullishCoalesce(_optionalChain([rows, 'access', _290 => _290[0], 'optionalAccess', _291 => _291.id]), () => ( null)),
3787
3797
  matchingRecordCount: _react.useMemo.call(void 0, () => countRecordItems(searched), [searched]),
3788
3798
  hasActiveFilter: hasSidebarFilter(filters),
3789
3799
  search: filters.search
@@ -3961,7 +3971,7 @@ function resolveContentType(file) {
3961
3971
  if (t === "image/jpeg" || t === "image/jpg" || t === "image/png" || t === "application/pdf") {
3962
3972
  return t;
3963
3973
  }
3964
- 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()]);
3974
+ const ext = _optionalChain([file, 'access', _292 => _292.name, 'access', _293 => _293.split, 'call', _294 => _294("."), 'access', _295 => _295.pop, 'call', _296 => _296(), 'optionalAccess', _297 => _297.toLowerCase, 'call', _298 => _298()]);
3965
3975
  if (ext === "pdf") return "application/pdf";
3966
3976
  if (ext === "png") return "image/png";
3967
3977
  if (ext === "jpg" || ext === "jpeg") return "image/jpeg";
@@ -4000,12 +4010,12 @@ function useUploadConnection() {
4000
4010
  patientId
4001
4011
  });
4002
4012
  const queue2 = store.getState().uploadQueue;
4003
- if (res.message === "queued_offline" || !_optionalChain([res, 'access', _305 => _305.batch_response, 'optionalAccess', _306 => _306.length])) {
4013
+ if (res.message === "queued_offline" || !_optionalChain([res, 'access', _299 => _299.batch_response, 'optionalAccess', _300 => _300.length])) {
4004
4014
  throw new Error("No internet connection. Your upload will retry automatically when you're back online.");
4005
4015
  }
4006
4016
  localIds.forEach((id, i) => {
4007
- const documentId = _nullishCoalesce(_optionalChain([res, 'access', _307 => _307.batch_response, 'optionalAccess', _308 => _308[i], 'optionalAccess', _309 => _309.document_id]), () => ( ""));
4008
- const errorDetails = _optionalChain([res, 'access', _310 => _310.batch_response, 'optionalAccess', _311 => _311[i], 'optionalAccess', _312 => _312.error_details]);
4017
+ const documentId = _nullishCoalesce(_optionalChain([res, 'access', _301 => _301.batch_response, 'optionalAccess', _302 => _302[i], 'optionalAccess', _303 => _303.document_id]), () => ( ""));
4018
+ const errorDetails = _optionalChain([res, 'access', _304 => _304.batch_response, 'optionalAccess', _305 => _305[i], 'optionalAccess', _306 => _306.error_details]);
4009
4019
  if (errorDetails) {
4010
4020
  queue2.markFailed(id);
4011
4021
  } else {
@@ -4149,7 +4159,7 @@ function useFilteredRecordIds2() {
4149
4159
 
4150
4160
 
4151
4161
  var HighlightedText = _react.memo.call(void 0, function HighlightedText2({ text, query }) {
4152
- const q = _nullishCoalesce(_optionalChain([query, 'optionalAccess', _313 => _313.trim, 'call', _314 => _314(), 'access', _315 => _315.toLowerCase, 'call', _316 => _316()]), () => ( ""));
4162
+ const q = _nullishCoalesce(_optionalChain([query, 'optionalAccess', _307 => _307.trim, 'call', _308 => _308(), 'access', _309 => _309.toLowerCase, 'call', _310 => _310()]), () => ( ""));
4153
4163
  const start = q ? text.toLowerCase().indexOf(q) : -1;
4154
4164
  if (start < 0) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: text });
4155
4165
  const end = start + q.length;
@@ -4324,7 +4334,7 @@ var SidebarSearchField = _react.memo.call(void 0, function SidebarSearchField2({
4324
4334
  function summarize(options, value) {
4325
4335
  if (value.length === 0) return "All";
4326
4336
  if (value.length > 2) return `${value.length} types`;
4327
- 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(", ");
4337
+ return value.map((id) => _nullishCoalesce(_optionalChain([options, 'access', _311 => _311.find, 'call', _312 => _312((o) => o.id === id), 'optionalAccess', _313 => _313.display_name]), () => ( id))).join(", ");
4328
4338
  }
4329
4339
  function SidebarTypeSelect({ options, value, onChange }) {
4330
4340
  const [open, setOpen] = _react.useState.call(void 0, false);
@@ -4333,7 +4343,7 @@ function SidebarTypeSelect({ options, value, onChange }) {
4333
4343
  _react.useEffect.call(void 0, () => {
4334
4344
  if (!open) return;
4335
4345
  const onMouseDown = (e) => {
4336
- if (!_optionalChain([rootRef, 'access', _320 => _320.current, 'optionalAccess', _321 => _321.contains, 'call', _322 => _322(e.target)])) setOpen(false);
4346
+ if (!_optionalChain([rootRef, 'access', _314 => _314.current, 'optionalAccess', _315 => _315.contains, 'call', _316 => _316(e.target)])) setOpen(false);
4337
4347
  };
4338
4348
  document.addEventListener("mousedown", onMouseDown);
4339
4349
  return () => document.removeEventListener("mousedown", onMouseDown);
@@ -4407,7 +4417,7 @@ function SidebarFilterPopover({ containerRef, onClose }) {
4407
4417
  }));
4408
4418
  _react.useEffect.call(void 0, () => {
4409
4419
  const handler = (e) => {
4410
- if (_optionalChain([containerRef, 'access', _323 => _323.current, 'optionalAccess', _324 => _324.contains, 'call', _325 => _325(e.target)])) return;
4420
+ if (_optionalChain([containerRef, 'access', _317 => _317.current, 'optionalAccess', _318 => _318.contains, 'call', _319 => _319(e.target)])) return;
4411
4421
  onClose();
4412
4422
  };
4413
4423
  document.addEventListener("mousedown", handler);
@@ -4813,32 +4823,32 @@ function SmartRecordsViewInner({
4813
4823
  onViewChangeRef.current = onViewChange;
4814
4824
  renderScribeDocumentRef.current = renderScribeDocument;
4815
4825
  _react.useEffect.call(void 0, () => {
4816
- _optionalChain([onViewChangeRef, 'access', _326 => _326.current, 'optionalCall', _327 => _327(mainView)]);
4826
+ _optionalChain([onViewChangeRef, 'access', _320 => _320.current, 'optionalCall', _321 => _321(mainView)]);
4817
4827
  }, [mainView]);
4818
4828
  const [selectedCaseId, setSelectedCaseId] = _react.useState.call(void 0, null);
4819
4829
  const [uploadOpen, setUploadOpen] = _react.useState.call(void 0, false);
4820
4830
  const stableCopyToNote = _react.useCallback.call(void 0,
4821
- (text, anchor, vitalsRows) => _optionalChain([onCopyToNoteRef, 'access', _328 => _328.current, 'optionalCall', _329 => _329(text, anchor, vitalsRows)]),
4831
+ (text, anchor, vitalsRows) => _optionalChain([onCopyToNoteRef, 'access', _322 => _322.current, 'optionalCall', _323 => _323(text, anchor, vitalsRows)]),
4822
4832
  []
4823
4833
  );
4824
4834
  const stableCopyPrescriptionSections = _react.useCallback.call(void 0,
4825
- (sections, anchor) => _optionalChain([onCopyPrescriptionSectionsRef, 'access', _330 => _330.current, 'optionalCall', _331 => _331(sections, anchor)]),
4835
+ (sections, anchor) => _optionalChain([onCopyPrescriptionSectionsRef, 'access', _324 => _324.current, 'optionalCall', _325 => _325(sections, anchor)]),
4826
4836
  []
4827
4837
  );
4828
4838
  const stableCopyVitalsToNote = _react.useCallback.call(void 0,
4829
- (text) => _optionalChain([onCopyVitalsToNoteRef, 'access', _332 => _332.current, 'optionalCall', _333 => _333(text)]),
4839
+ (text) => _optionalChain([onCopyVitalsToNoteRef, 'access', _326 => _326.current, 'optionalCall', _327 => _327(text)]),
4830
4840
  []
4831
4841
  );
4832
4842
  const stableToast = _react.useCallback.call(void 0,
4833
- (message, type) => _optionalChain([onToastRef, 'access', _334 => _334.current, 'optionalCall', _335 => _335(message, type)]),
4843
+ (message, type) => _optionalChain([onToastRef, 'access', _328 => _328.current, 'optionalCall', _329 => _329(message, type)]),
4834
4844
  []
4835
4845
  );
4836
4846
  const stableRenderScribeDocument = _react.useCallback.call(void 0,
4837
- (args) => _nullishCoalesce(_optionalChain([renderScribeDocumentRef, 'access', _336 => _336.current, 'optionalCall', _337 => _337(args)]), () => ( null)),
4847
+ (args) => _nullishCoalesce(_optionalChain([renderScribeDocumentRef, 'access', _330 => _330.current, 'optionalCall', _331 => _331(args)]), () => ( null)),
4838
4848
  []
4839
4849
  );
4840
4850
  const attachToContext = _react.useCallback.call(void 0, (documentId, name, visitId) => {
4841
- void _optionalChain([onAddToContextRef, 'access', _338 => _338.current, 'optionalCall', _339 => _339([visitId ? { documentId, name, visitId } : { documentId, name }])]);
4851
+ void _optionalChain([onAddToContextRef, 'access', _332 => _332.current, 'optionalCall', _333 => _333([visitId ? { documentId, name, visitId } : { documentId, name }])]);
4842
4852
  }, []);
4843
4853
  const handleSelectCase = _react.useCallback.call(void 0,
4844
4854
  (caseId) => {