@mindbill/react 0.77.53 → 0.77.55

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.ts CHANGED
@@ -1179,6 +1179,15 @@ type RfaDashboardProps = OrganizationClientOptions & TreatmentDraftAppearance &
1179
1179
  /** Host-owned saved provider selection and provider creation. Newly selected providers are resolved through creation context. */
1180
1180
  renderProviderSelector?: (props: RfaProviderSelectorProps) => ReactNode;
1181
1181
  canManageProviderSignatures?: boolean;
1182
+ /** Host-owned physician signature setup inside the send dialog (for example draw or upload buttons). `missing` holds the send until
1183
+ * the host reports a saved signature; leave it undefined when the host cannot tell. Replaces the built-in PNG upload there. */
1184
+ renderSendSignatureSetup?: (props: {
1185
+ renderingProviderId: string;
1186
+ providerName: string;
1187
+ }) => {
1188
+ missing?: boolean;
1189
+ setup: ReactNode;
1190
+ };
1182
1191
  /** Optional separate admin session for saving physician signatures. */
1183
1192
  signatureSession?: OrganizationClientOptions;
1184
1193
  patientId?: string;
@@ -2242,9 +2251,13 @@ type RfaAuthorizationDestinationProps = {
2242
2251
  autoSelectSingle?: boolean;
2243
2252
  /** Compact mode: offer one "enter manually" choice that hands entry to the host's own fields. */
2244
2253
  onManualEntry?: () => void;
2254
+ /** Offer only destinations of this kind (and only that kind of manual entry). */
2255
+ method?: "fax" | "email";
2256
+ /** Start on the destination already saved on the request, so the user reviews it instead of choosing again. */
2257
+ preselectSaved?: boolean;
2245
2258
  };
2246
2259
  /** Choose a destination without sending an RFA or treating email as fax. */
2247
- declare function RfaAuthorizationDestination({ contextKey, directory, savedContact, loading, error, disabled, onChange, onSelectionStart, compact, onManualEntry, autoSelectSingle }: RfaAuthorizationDestinationProps): ReactElement;
2260
+ declare function RfaAuthorizationDestination({ contextKey, directory, savedContact, loading, error, disabled, onChange, onSelectionStart, compact, onManualEntry, autoSelectSingle, method, preselectSaved }: RfaAuthorizationDestinationProps): ReactElement;
2248
2261
 
2249
2262
  type RfaLifecycleControlsProps = OrganizationClientOptions & TreatmentDraftAppearance & {
2250
2263
  rfa: RfaRecord;
package/dist/index.js CHANGED
@@ -10234,12 +10234,14 @@ function useRfaFormDetails(client, claimId, renderingProviderId, enabled) {
10234
10234
  // src/rfa-authorization-destination.tsx
10235
10235
  import { normalizeRfaFax, rfaAuthorizationDestinations, rfaAuthorizationGuidance as rfaAuthorizationGuidance2 } from "@mindbill/browser";
10236
10236
  import { Fragment as Fragment13, jsx as jsx24, jsxs as jsxs22 } from "react/jsx-runtime";
10237
- function RfaAuthorizationDestination({ contextKey, directory, savedContact, loading = false, error, disabled = false, onChange, onSelectionStart, compact = false, onManualEntry, autoSelectSingle = false }) {
10238
- const options = loading || error ? [] : rfaAuthorizationDestinations(directory);
10237
+ function RfaAuthorizationDestination({ contextKey, directory, savedContact, loading = false, error, disabled = false, onChange, onSelectionStart, compact = false, onManualEntry, autoSelectSingle = false, method, preselectSaved = false }) {
10238
+ let options = loading || error ? [] : rfaAuthorizationDestinations(directory);
10239
10239
  const fax = savedContact?.fax ? normalizeRfaFax(savedContact.fax) : null;
10240
10240
  const savedLabel = savedContact?.contactName || savedContact?.name || "Saved request contact";
10241
10241
  if (fax && !options.some((option) => option.method === "fax" && option.destination === fax)) options.unshift({ method: "fax", destination: fax, label: savedLabel, ...savedContact?.contactName ? { recipientName: savedContact.contactName } : {} });
10242
10242
  if (savedContact?.email?.trim() && !options.some((option) => option.method === "email" && option.destination === savedContact.email?.trim())) options.unshift({ method: "email", destination: savedContact.email.trim(), label: savedLabel, ...savedContact?.contactName ? { recipientName: savedContact.contactName } : {} });
10243
+ if (method) options = options.filter((option) => option.method === method);
10244
+ const savedIndex = preselectSaved ? options.findIndex((option) => option.method === "fax" ? option.destination === fax : option.destination === savedContact?.email?.trim()) : -1;
10243
10245
  const signature = JSON.stringify([contextKey, directory?.authorizationStatus, options, loading, error]);
10244
10246
  const [selection, setSelection] = useState15("");
10245
10247
  const [manual, setManual] = useState15("");
@@ -10250,12 +10252,23 @@ function RfaAuthorizationDestination({ contextKey, directory, savedContact, load
10250
10252
  callback.current = onChange;
10251
10253
  const auto = useRef10(autoSelectSingle);
10252
10254
  auto.current = autoSelectSingle;
10255
+ const startAt = useRef10(savedIndex);
10256
+ startAt.current = savedIndex;
10253
10257
  useEffect13(() => {
10254
10258
  setManual("");
10255
- const only = auto.current && !needsAdjuster && options.length === 1 ? options[0] : void 0;
10256
- setSelection(only ? "0" : "");
10257
- setContactName(only?.recipientName ?? "");
10258
- callback.current(only ?? null);
10259
+ if (loading) {
10260
+ setSelection("");
10261
+ setContactName("");
10262
+ callback.current(null);
10263
+ return;
10264
+ }
10265
+ const index = startAt.current >= 0 ? startAt.current : auto.current && !needsAdjuster && options.length === 1 ? 0 : -1;
10266
+ const only = index >= 0 ? options[index] : void 0;
10267
+ const name = only?.recipientName ?? (needsAdjuster ? savedContact?.contactName ?? "" : "");
10268
+ const next = only ? String(index) : method && !options.length && !onManualEntry ? method === "email" ? "manual-email" : "manual" : "";
10269
+ setSelection(next);
10270
+ setContactName(name);
10271
+ callback.current(only && !(needsAdjuster && !name.trim()) ? { ...only, ...name.trim() ? { recipientName: name.trim() } : {} } : null);
10259
10272
  }, [signature]);
10260
10273
  const chosen = selection !== "" ? options[Number(selection)] : void 0;
10261
10274
  const emit = (nextSelection, value, name) => {
@@ -10298,7 +10311,7 @@ function RfaAuthorizationDestination({ contextKey, directory, savedContact, load
10298
10311
  searchable: true,
10299
10312
  disabled: disabled || loading,
10300
10313
  value: selection,
10301
- options: [...options.map((option, index) => ({ id: String(index), .../[a-z]/i.test(option.label) ? { label: option.label, detail: option.method === "fax" ? `Fax ${formatRfaPhone(option.destination)}` : option.destination } : { label: option.method === "fax" ? "Authorization fax" : "Authorization e-mail", detail: option.method === "fax" ? formatRfaPhone(option.destination) : option.destination } })), ...onManualEntry ? [{ id: "manual-entry", action: true, label: needsAdjuster ? "Enter the handling adjuster\u2019s contact manually" : "Enter a different contact manually" }] : [{ id: "manual", label: needsAdjuster ? "Enter the handling adjuster\u2019s fax" : "Enter another confirmed authorization fax" }, { id: "manual-email", label: "Enter a confirmed authorization e-mail" }]].filter((option) => option.id === selection || `${option.label} ${"detail" in option ? option.detail : ""}`.toLowerCase().includes(query.trim().toLowerCase())),
10314
+ options: [...options.map((option, index) => ({ id: String(index), .../[a-z]/i.test(option.label) ? { label: option.label, detail: option.method === "fax" ? `Fax ${formatRfaPhone(option.destination)}` : option.destination } : { label: option.method === "fax" ? "Authorization fax" : "Authorization e-mail", detail: option.method === "fax" ? formatRfaPhone(option.destination) : option.destination } })), ...onManualEntry ? [{ id: "manual-entry", action: true, label: needsAdjuster ? "Enter the handling adjuster\u2019s contact manually" : "Enter a different contact manually" }] : [...method === "email" ? [] : [{ id: "manual", action: true, label: needsAdjuster ? "Enter the handling adjuster\u2019s fax" : options.length ? "Enter a different fax number" : "Enter a fax number" }], ...method === "fax" ? [] : [{ id: "manual-email", action: true, label: options.length ? "Enter a different e-mail address" : "Enter an e-mail address" }]]].filter((option) => option.id === selection || `${option.label} ${"detail" in option ? option.detail : ""}`.toLowerCase().includes(query.trim().toLowerCase())),
10302
10315
  onSelect: (value) => {
10303
10316
  setQuery("");
10304
10317
  if (value === "manual-entry") {
@@ -10330,22 +10343,23 @@ function RfaAuthorizationDestination({ contextKey, directory, savedContact, load
10330
10343
  emit(selection, manual, event.target.value);
10331
10344
  } })
10332
10345
  ] }) : null,
10333
- selection === "manual-email" ? /* @__PURE__ */ jsxs22("label", { children: [
10334
- "Authorization email address",
10335
- /* @__PURE__ */ jsx24("input", { type: "email", value: manual, onChange: (event) => {
10346
+ selection === "manual-email" ? /* @__PURE__ */ jsxs22("label", { style: { display: "grid", gap: 6, minWidth: 0 }, children: [
10347
+ "Authorization e-mail address",
10348
+ /* @__PURE__ */ jsx24("input", { type: "email", placeholder: "name@example.com", value: manual, onChange: (event) => {
10336
10349
  const value = event.target.value;
10337
10350
  setManual(value);
10338
10351
  emit(selection, value, contactName);
10339
10352
  } })
10340
10353
  ] }) : selection === "manual" ? /* @__PURE__ */ jsxs22("label", { style: { display: "grid", gap: 6, minWidth: 0 }, children: [
10341
10354
  "Authorization fax number",
10342
- /* @__PURE__ */ jsx24("input", { type: "tel", value: manual, onChange: (event) => {
10343
- const value = event.target.value;
10355
+ /* @__PURE__ */ jsx24("input", { type: "tel", placeholder: "(555) 555-0100", value: manual, onChange: (event) => {
10356
+ const digits = event.target.value.replace(/\D/g, "").replace(/^1(?=\d{10})/, "").slice(0, 10);
10357
+ const value = digits.length > 6 ? `(${digits.slice(0, 3)}) ${digits.slice(3, 6)}-${digits.slice(6)}` : digits.length > 3 ? `(${digits.slice(0, 3)}) ${digits.slice(3)}` : digits;
10344
10358
  setManual(value);
10345
10359
  emit(selection, value, contactName);
10346
10360
  }, style: { padding: 10, width: "100%", minWidth: 0, boxSizing: "border-box", font: "inherit" } })
10347
10361
  ] }) : selection !== "" && chosen ? /* @__PURE__ */ jsxs22(Fragment13, { children: [
10348
- chosen.method === "email" ? /* @__PURE__ */ jsxs22("p", { style: { margin: 0, overflowWrap: "anywhere" }, children: [
10362
+ chosen.method === "email" && !compact ? /* @__PURE__ */ jsxs22("p", { style: { margin: 0, overflowWrap: "anywhere" }, children: [
10349
10363
  "Email: ",
10350
10364
  chosen.destination,
10351
10365
  ". Review this recipient before preparing and sending the packet."
@@ -14130,19 +14144,23 @@ var rfaSendDialogCss = `.mbrfa-send-backdrop{position:fixed;z-index:1000;inset:0
14130
14144
  .mbrfa-send>header{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:16px 20px;border-bottom:1px solid var(--mb-border)}.mbrfa-send>header h3{margin:0;font-size:16px}
14131
14145
  .mbrfa-send>header button{width:36px;height:36px;min-height:36px;padding:0;border:0;background:none;font-size:22px;line-height:1;cursor:pointer;color:var(--mb-muted)}
14132
14146
  .mbrfa-send-body{display:grid;gap:14px;padding:18px 20px;overflow:auto}.mbrfa-send-body p{margin:0}.mbrfa-send-body label{display:grid;gap:5px;font-size:13px}
14133
- .mbrfa-send-methods{display:flex;flex-wrap:wrap;gap:6px 18px}.mbrfa-send-methods label{display:flex;align-items:center;gap:8px;min-height:36px;cursor:pointer}.mbrfa-send-methods input{width:16px;height:16px;min-height:16px;margin:0;padding:0;accent-color:var(--mb-accent)}
14147
+ .mbrfa-send-methods{display:flex;flex-wrap:wrap;align-items:center;gap:6px 18px}.mbrfa-send-methods>span{font-size:13px;font-weight:600}.mbrfa-send .mb-rfa-destination{margin:0;padding:0;border:0}.mbrfa-send-to{display:grid;gap:5px;min-width:0}.mbrfa-send-to>span{font-size:13px;font-weight:600}.mbrfa-send-to[data-method=email] .mbrfa-guidance{display:none}.mbrfa-send .mb-rfa-destination label{display:grid;gap:5px}.mbrfa-send-methods label{display:flex;align-items:center;gap:8px;min-height:36px;cursor:pointer}.mbrfa-send-methods input{width:16px;height:16px;min-height:16px;margin:0;padding:0;accent-color:var(--mb-accent)}
14134
14148
  .mbrfa-send-summary{display:grid;gap:4px;padding:12px 14px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius);background:color-mix(in srgb,var(--mb-accent) 4%,var(--mb-surface));font-size:13px}.mbrfa-send-summary span{color:var(--mb-muted)}
14149
+ .mbrfa-send-contents{display:grid;gap:10px}.mbrfa-send-contents h4{margin:0 0 4px;font-size:13px;font-weight:600}.mbrfa-send-contents ul{display:grid;gap:4px;margin:0;padding:0;list-style:none;font-size:13px}.mbrfa-send-contents li{min-width:0;overflow-wrap:anywhere}.mbrfa-send-contents li span,.mbrfa-send-contents p{color:var(--mb-muted);font-size:13px}
14150
+ .mbrfa-send-signature{display:grid;gap:8px;padding:12px 14px;border:1px solid color-mix(in srgb,var(--mb-danger,#b42318) 35%,var(--mb-border));border-radius:var(--mb-control-radius);background:color-mix(in srgb,var(--mb-danger,#b42318) 5%,var(--mb-surface));font-size:13px}
14135
14151
  .mbrfa-send-confirm{display:flex!important;align-items:flex-start;gap:10px;padding-top:4px;cursor:pointer}.mbrfa-send-confirm input{width:16px;height:16px;min-height:16px;margin:3px 0 0;padding:0;flex:none;accent-color:var(--mb-accent)}
14136
14152
  .mbrfa-send>footer{display:flex;flex-direction:row-reverse;gap:10px;padding:14px 20px;border-top:1px solid var(--mb-border)}.mbrfa-send>footer>a{margin-right:auto;align-self:center;font-size:13px}
14137
14153
  .mbrfa-send [role=alert]{color:var(--mb-danger,#b42318);font-size:13px}
14138
14154
  @media(max-width:640px){.mbrfa-send-backdrop{place-items:end stretch;padding:0}.mbrfa-send{width:100%;max-height:92vh;border-radius:var(--mb-radius) var(--mb-radius) 0 0}.mbrfa-send>footer{flex-direction:column}.mbrfa-send>footer>a{margin:0;align-self:center}}`;
14139
- function RfaSendDialog({ rfa, client, documentIds, diagnosisDescriptions, directory, directoryLoading, directoryError, environment, canSend, canSign, actorReference, previewUrl, signatureSetup, onUpdated, onSent, onClose }) {
14140
- const [mode, setMode] = useState30("send");
14155
+ var treatmentDetail = (item) => [item.procedureCode ? `CPT/HCPCS ${item.procedureCode}` : "", item.quantity ? `Qty ${item.quantity}` : "", item.frequency ?? "", item.duration ?? "", `Dx ${item.diagnosisCode}`].filter(Boolean).join(" \xB7 ");
14156
+ function RfaSendDialog({ rfa, client, documentIds, diagnosisDescriptions, directory, directoryLoading, directoryError, environment, canSend, canSign, actorReference, previewUrl, signatureSetup, signatureMissing, onUpdated, onSent, onClose }) {
14157
+ const [method, setMethod] = useState30(() => !rfa.authorizationContact?.fax?.trim() && rfa.authorizationContact?.email?.trim() ? "email" : "fax");
14141
14158
  const [destination, setDestination] = useState30(null);
14142
14159
  const [message, setMessage] = useState30("");
14143
14160
  const [confirmed, setConfirmed] = useState30(false);
14144
14161
  const [busy, setBusy] = useState30("");
14145
14162
  const [error, setError] = useState30("");
14163
+ const [signatureRefused, setSignatureRefused] = useState30(false);
14146
14164
  const keys = useRef22(/* @__PURE__ */ new Map());
14147
14165
  const alive = useRef22(true);
14148
14166
  const latest = useRef22(rfa);
@@ -14155,7 +14173,7 @@ function RfaSendDialog({ rfa, client, documentIds, diagnosisDescriptions, direct
14155
14173
  }, []);
14156
14174
  useEffect25(() => {
14157
14175
  const close = (event) => {
14158
- if (event.key === "Escape" && !busy) onClose();
14176
+ if (event.key === "Escape" && !busy && !event.defaultPrevented) onClose();
14159
14177
  };
14160
14178
  window.addEventListener("keydown", close);
14161
14179
  return () => window.removeEventListener("keydown", close);
@@ -14172,9 +14190,13 @@ function RfaSendDialog({ rfa, client, documentIds, diagnosisDescriptions, direct
14172
14190
  const supporting = rfa.documents.filter((document2) => ["clinical_report", "supporting_record"].includes(document2.documentType) && documentIds.includes(document2.id));
14173
14191
  const missingDiagnosis = rfa.items.find((item) => !(diagnosisDescriptions[item.id] ?? item.diagnosisDescription ?? "").trim());
14174
14192
  const live = environment === "live";
14175
- const blocked = !supporting.length ? "Add the report that supports this request (PR-2, Doctor's First Report or narrative) before sending." : missingDiagnosis ? `Add the diagnosis for ${missingDiagnosis.diagnosisCode} (Edit request) before sending.` : !rfa.signedAt && !canSign ? "Sending applies the physician's saved signature, and your account is not set up to do that." : mode === "send" && !live ? "This is a sandbox: nothing is faxed or e-mailed. You can still download the packet." : mode === "send" && !canSend ? "Sending requires permission from your organization." : "";
14193
+ const needsSignature = !rfa.signedAt && (signatureMissing ?? signatureRefused);
14194
+ useEffect25(() => {
14195
+ if (signatureMissing === false) setSignatureRefused(false);
14196
+ }, [signatureMissing]);
14197
+ const blocked = !supporting.length ? "Add the report that supports this request (PR-2, Doctor's First Report or narrative) before sending." : missingDiagnosis ? `Add the diagnosis for ${missingDiagnosis.diagnosisCode} (Edit request) before sending.` : !rfa.signedAt && !canSign ? "Sending applies the physician's saved signature, and your account is not set up to do that." : !live ? "This is a sandbox: nothing is faxed or e-mailed." : !canSend ? "Sending requires permission from your organization." : "";
14176
14198
  const go = async () => {
14177
- if (busy || blocked || !confirmed || mode === "send" && !destination) return;
14199
+ if (busy || blocked || needsSignature || !confirmed || !destination) return;
14178
14200
  setError("");
14179
14201
  try {
14180
14202
  let current = latest.current, ids = documentIds;
@@ -14188,25 +14210,22 @@ function RfaSendDialog({ rfa, client, documentIds, diagnosisDescriptions, direct
14188
14210
  const form = current.documents.filter((document2) => document2.documentType === "rfa_form" && document2.contentRevision === current.contentRevision).sort((a, b) => (b.createdAt ?? "").localeCompare(a.createdAt ?? ""))[0];
14189
14211
  ids = current.documents.filter((document2) => document2.id === form?.id || supporting.some((kept) => kept.id === document2.id)).map((document2) => document2.id);
14190
14212
  }
14191
- setBusy(mode === "download" ? "Preparing packet\u2026" : "Sending\u2026");
14213
+ setBusy("Sending\u2026");
14192
14214
  const text3 = message.trim();
14193
- const packet = await client.prepareDelivery(current.id, { documentIds: ids, channel: mode === "download" ? "download" : destination.method, ...mode === "send" ? { to: destination.destination, ...destination.recipientName ? { recipientName: destination.recipientName } : {} } : {}, ...text3 ? { message: text3 } : {} });
14194
- if (mode === "download") {
14195
- const url = URL.createObjectURL(await client.getPacket(current.id, packet.packetId));
14196
- window.open(url, "_blank", "noopener");
14197
- setTimeout(() => URL.revokeObjectURL(url), 6e4);
14198
- if (alive.current) onClose();
14199
- return;
14200
- }
14215
+ const packet = await client.prepareDelivery(current.id, { documentIds: ids, channel: destination.method, to: destination.destination, ...destination.recipientName ? { recipientName: destination.recipientName } : {}, ...text3 ? { message: text3 } : {} });
14201
14216
  const body = { packetId: packet.packetId, sha256: packet.sha256, channel: destination.method, to: destination.destination, ...destination.recipientName ? { recipientName: destination.recipientName } : {}, ...text3 ? { message: text3 } : {} };
14202
14217
  onSent(await client.submit(current.id, body, stable("submit", body)));
14203
14218
  } catch (caught) {
14204
- if (alive.current) setError(caught instanceof Error ? caught.message : "The request could not be sent. Nothing was sent; try again.");
14219
+ const reason = caught instanceof Error ? caught.message : "";
14220
+ if (!alive.current) return;
14221
+ if (/saved.signature/i.test(reason)) setSignatureRefused(true);
14222
+ else setError(reason || "The request could not be sent. Nothing was sent; try again.");
14205
14223
  } finally {
14206
14224
  if (alive.current) setBusy("");
14207
14225
  }
14208
14226
  };
14209
- const where = mode === "download" ? "" : destination ? `${destination.recipientName ? `${destination.recipientName} \xB7 ` : ""}${destination.destination}` : "";
14227
+ const attention = destination?.recipientName && /[a-z]/i.test(destination.recipientName) ? destination.recipientName : "";
14228
+ const where = destination ? `${destination.method === "fax" ? `fax ${formatRfaPhone(destination.destination)}` : destination.destination}${attention ? ` (attention ${attention})` : ""}` : "";
14210
14229
  return /* @__PURE__ */ jsxs43("div", { className: "mbrfa-send-backdrop", onMouseDown: (event) => {
14211
14230
  if (event.target === event.currentTarget && !busy) onClose();
14212
14231
  }, children: [
@@ -14222,46 +14241,70 @@ function RfaSendDialog({ rfa, client, documentIds, diagnosisDescriptions, direct
14222
14241
  rfa.employeeName,
14223
14242
  rfa.claimNumber ? ` \xB7 Claim ${rfa.claimNumber}` : ""
14224
14243
  ] }),
14225
- /* @__PURE__ */ jsxs43("span", { children: [
14226
- rfa.providerName,
14227
- " \xB7 ",
14228
- rfa.items.length,
14229
- " requested treatment",
14230
- rfa.items.length === 1 ? "" : "s",
14231
- " \xB7 ",
14232
- supporting.length,
14233
- " supporting document",
14234
- supporting.length === 1 ? "" : "s"
14244
+ /* @__PURE__ */ jsx45("span", { children: rfa.providerName })
14245
+ ] }),
14246
+ /* @__PURE__ */ jsxs43("div", { className: "mbrfa-send-contents", children: [
14247
+ /* @__PURE__ */ jsxs43("div", { children: [
14248
+ /* @__PURE__ */ jsxs43("h4", { children: [
14249
+ "Requested treatment",
14250
+ rfa.items.length === 1 ? "" : "s"
14251
+ ] }),
14252
+ /* @__PURE__ */ jsx45("ul", { children: rfa.items.map((item) => {
14253
+ const detail = treatmentDetail(item);
14254
+ return /* @__PURE__ */ jsxs43("li", { children: [
14255
+ item.serviceDescription,
14256
+ detail ? /* @__PURE__ */ jsxs43("span", { children: [
14257
+ " \xB7 ",
14258
+ detail
14259
+ ] }) : null
14260
+ ] }, item.id);
14261
+ }) })
14262
+ ] }),
14263
+ /* @__PURE__ */ jsxs43("div", { children: [
14264
+ /* @__PURE__ */ jsx45("h4", { children: "Supporting documents" }),
14265
+ supporting.length ? /* @__PURE__ */ jsx45("ul", { children: supporting.map((document2) => /* @__PURE__ */ jsx45("li", { children: document2.filename }, document2.id)) }) : /* @__PURE__ */ jsx45("p", { children: "None attached yet." })
14235
14266
  ] })
14236
14267
  ] }),
14237
- /* @__PURE__ */ jsxs43("div", { className: "mbrfa-send-methods", role: "radiogroup", "aria-label": "How to send", children: [
14268
+ /* @__PURE__ */ jsxs43("div", { className: "mbrfa-send-methods", role: "radiogroup", "aria-label": "Send by", children: [
14269
+ /* @__PURE__ */ jsx45("span", { children: "Send by" }),
14238
14270
  /* @__PURE__ */ jsxs43("label", { children: [
14239
- /* @__PURE__ */ jsx45("input", { type: "radio", name: "rfa-send-mode", checked: mode === "send", disabled: !!busy, onChange: () => {
14240
- setMode("send");
14271
+ /* @__PURE__ */ jsx45("input", { type: "radio", name: "rfa-send-method", checked: method === "fax", disabled: !!busy, onChange: () => {
14272
+ setMethod("fax");
14241
14273
  setConfirmed(false);
14242
14274
  } }),
14243
- "Send to the claims administrator"
14275
+ "Fax"
14244
14276
  ] }),
14245
14277
  /* @__PURE__ */ jsxs43("label", { children: [
14246
- /* @__PURE__ */ jsx45("input", { type: "radio", name: "rfa-send-mode", checked: mode === "download", disabled: !!busy, onChange: () => {
14247
- setMode("download");
14278
+ /* @__PURE__ */ jsx45("input", { type: "radio", name: "rfa-send-method", checked: method === "email", disabled: !!busy, onChange: () => {
14279
+ setMethod("email");
14248
14280
  setConfirmed(false);
14249
14281
  } }),
14250
- "Download to send myself"
14282
+ "E-mail"
14251
14283
  ] })
14252
14284
  ] }),
14253
- mode === "send" ? /* @__PURE__ */ jsx45(RfaAuthorizationDestination, { autoSelectSingle: true, contextKey: `${rfa.id}:${rfa.claimsAdminId ?? "manual"}`, directory, savedContact: rfa.authorizationContact, loading: directoryLoading, error: directoryError, disabled: !!busy, onChange: (value) => {
14254
- setDestination(value);
14255
- setConfirmed(false);
14256
- } }) : /* @__PURE__ */ jsx45("p", { children: "Downloading does not mark the request as sent. Keep proof of how you submit it." }),
14285
+ /* @__PURE__ */ jsxs43("div", { className: "mbrfa-send-to", "data-method": method, children: [
14286
+ /* @__PURE__ */ jsx45("span", { children: "Send to" }),
14287
+ /* @__PURE__ */ jsx45(RfaAuthorizationDestination, { compact: true, preselectSaved: true, autoSelectSingle: true, method, contextKey: `${rfa.id}:${rfa.claimsAdminId ?? "manual"}:${method}`, directory, savedContact: rfa.authorizationContact, loading: directoryLoading, error: directoryError, disabled: !!busy, onChange: (value) => {
14288
+ setDestination(value);
14289
+ setConfirmed(false);
14290
+ } })
14291
+ ] }),
14257
14292
  /* @__PURE__ */ jsxs43("label", { children: [
14258
- mode === "send" && destination?.method === "email" ? "E-mail message" : "Cover sheet message",
14293
+ method === "email" ? "E-mail message" : "Cover sheet message",
14259
14294
  " (optional)",
14260
14295
  /* @__PURE__ */ jsx45("textarea", { disabled: !!busy, maxLength: 1e3, rows: 2, value: message, onChange: (event) => setMessage(event.target.value) })
14261
14296
  ] }),
14262
- signatureSetup,
14297
+ needsSignature ? /* @__PURE__ */ jsxs43("div", { className: "mbrfa-send-signature", children: [
14298
+ /* @__PURE__ */ jsxs43("p", { role: "alert", children: [
14299
+ rfa.providerName,
14300
+ " has no saved signature yet. Sending puts the physician\u2019s signature on the form, so add it first.",
14301
+ signatureSetup ? "" : " Add it on the physician\u2019s page, then send again.",
14302
+ signatureRefused ? " Nothing was sent." : ""
14303
+ ] }),
14304
+ signatureSetup
14305
+ ] }) : signatureSetup,
14263
14306
  blocked ? /* @__PURE__ */ jsx45("p", { role: "alert", children: blocked }) : /* @__PURE__ */ jsxs43("label", { className: "mbrfa-send-confirm", children: [
14264
- /* @__PURE__ */ jsx45("input", { type: "checkbox", checked: confirmed, disabled: !!busy || mode === "send" && !destination, onChange: (event) => setConfirmed(event.target.checked) }),
14307
+ /* @__PURE__ */ jsx45("input", { type: "checkbox", checked: confirmed, disabled: !!busy || !destination, onChange: (event) => setConfirmed(event.target.checked) }),
14265
14308
  /* @__PURE__ */ jsxs43("span", { children: [
14266
14309
  rfa.signedAt ? "I reviewed this request" : /* @__PURE__ */ jsxs43(Fragment25, { children: [
14267
14310
  "I reviewed this request and am authorized by ",
@@ -14278,7 +14321,7 @@ function RfaSendDialog({ rfa, client, documentIds, diagnosisDescriptions, direct
14278
14321
  error ? /* @__PURE__ */ jsx45("p", { role: "alert", children: error }) : null
14279
14322
  ] }),
14280
14323
  /* @__PURE__ */ jsxs43("footer", { children: [
14281
- /* @__PURE__ */ jsx45("button", { type: "button", className: "mbtd-primary", disabled: !!busy || !!blocked || !confirmed || mode === "send" && !destination, onClick: () => void go(), children: busy || (mode === "download" ? "Download packet" : destination?.method === "email" ? "Send e-mail" : "Send fax") }),
14324
+ /* @__PURE__ */ jsx45("button", { type: "button", className: "mbtd-primary", disabled: !!busy || !!blocked || needsSignature || !confirmed || !destination, onClick: () => void go(), children: busy || (method === "email" ? "Send e-mail" : "Send fax") }),
14282
14325
  /* @__PURE__ */ jsx45("button", { type: "button", disabled: !!busy, onClick: onClose, children: "Cancel" }),
14283
14326
  previewUrl ? /* @__PURE__ */ jsx45("a", { href: previewUrl, target: "_blank", rel: "noopener noreferrer", children: "Preview packet" }) : null
14284
14327
  ] })
@@ -14918,7 +14961,7 @@ function RfaDashboard({ sessionEndpoint, getSession, apiBaseUrl, fetch: fetchOve
14918
14961
  const identity = useMemo12(() => ({ client, signatureClient, key: key() }), [client, signatureClient]);
14919
14962
  return /* @__PURE__ */ jsx48(RfaDashboardContent, { ...props, ...patientId ? { patientId } : {}, ...claimId ? { claimId } : {}, ...renderingProviderId ? { renderingProviderId } : {}, client, signatureClient, options }, `${identity.key}:${patientId ?? ""}:${claimId ?? ""}:${renderingProviderId ?? ""}`);
14920
14963
  }
14921
- function RfaDashboardContent({ client, signatureClient, options, patientId, claimId, renderingProviderId, initialDraft, initialView = "overview", initialDetailAction, initialOverviewView, initialStatus = "", initialAgingBucket = "", taskPresentation, taskQuery: taskQuery2, renderTaskIdentity, navigation, permissions = [], canCreateClaim = false, renderClaimSelector, renderProviderSelector, officialForm = false, managePracticeHref, onEditPractice, onAddPractice, onEditLocation, treatmentTemplates, onSaveTreatmentTemplate, onManageTreatmentTemplates, savedProfileChanges, manageLocationsHref, onPreviewRequest, onPreviewDraft, canManageProviderSignatures = false, environment = "sandbox", actorReference, onCreated, onContinue, selectedRfaId, selectedTreatmentId, selectedResponseDocumentId: controlledResponseDocumentId, onSelectRfa, getRfaHref, getPatientHref, getClaimHref, getProviderHref, formPreviewUrl, hideBackButton = false, hideHeading = false, layout = "classic", ...appearance }) {
14964
+ function RfaDashboardContent({ client, signatureClient, options, patientId, claimId, renderingProviderId, initialDraft, initialView = "overview", initialDetailAction, initialOverviewView, initialStatus = "", initialAgingBucket = "", taskPresentation, taskQuery: taskQuery2, renderTaskIdentity, navigation, permissions = [], canCreateClaim = false, renderClaimSelector, renderProviderSelector, officialForm = false, managePracticeHref, onEditPractice, onAddPractice, onEditLocation, treatmentTemplates, onSaveTreatmentTemplate, onManageTreatmentTemplates, savedProfileChanges, manageLocationsHref, onPreviewRequest, onPreviewDraft, canManageProviderSignatures = false, renderSendSignatureSetup, environment = "sandbox", actorReference, onCreated, onContinue, selectedRfaId, selectedTreatmentId, selectedResponseDocumentId: controlledResponseDocumentId, onSelectRfa, getRfaHref, getPatientHref, getClaimHref, getProviderHref, formPreviewUrl, hideBackButton = false, hideHeading = false, layout = "classic", ...appearance }) {
14922
14965
  const active = useRef25(true);
14923
14966
  useEffect27(() => {
14924
14967
  active.current = true;
@@ -15104,7 +15147,7 @@ function RfaDashboardContent({ client, signatureClient, options, patientId, clai
15104
15147
  } }) : selected ? /* @__PURE__ */ jsx48(RfaDetail, { layout, ...initialDetailAction ? { initialAction: initialDetailAction } : {}, ...relatedLinks, ...formPreviewUrl ? { formPreviewUrl } : {}, id: selected, selectedItem, ...selectedResponseDocumentId ? { selectedResponseDocumentId } : {}, client, signatureClient, options, onCopied: (draft2) => {
15105
15148
  selectRfa(draft2.id);
15106
15149
  onCreated?.(draft2);
15107
- }, draftFormProps, canManageProviderSignatures, permissions, environment, ...actorReference ? { actorReference } : {}, ...onContinue ? { onContinue } : {}, ...appearance.disabled !== void 0 ? { disabled: appearance.disabled } : {} }, selected) : /* @__PURE__ */ jsxs46(Fragment27, { children: [
15150
+ }, draftFormProps, canManageProviderSignatures, ...renderSendSignatureSetup ? { renderSendSignatureSetup } : {}, permissions, environment, ...actorReference ? { actorReference } : {}, ...onContinue ? { onContinue } : {}, ...appearance.disabled !== void 0 ? { disabled: appearance.disabled } : {} }, selected) : /* @__PURE__ */ jsxs46(Fragment27, { children: [
15108
15151
  view === "overview" ? /* @__PURE__ */ jsx48(RfaTaskBoard, { ...taskPresentation ? { presentation: taskPresentation } : {}, ...taskQuery2 ? { query: taskQuery2 } : {}, ...renderTaskIdentity ? { renderTaskIdentity } : {}, ...navigation?.getTaskHref ? { getTaskHref: navigation.getTaskHref } : {}, ...navigation?.onNavigate ? { onNavigate: navigation.onNavigate } : {}, embedded: true, ...appearance, ...options, ...patientId ? { patientId } : {}, ...claimId ? { claimId } : {}, ...renderingProviderId ? { renderingProviderId } : {}, permissions: permissions.filter((value) => value === "act"), onSelect: (id, documentId) => selectRfa(id, documentId ? { responseDocumentId: documentId } : void 0) }) : /* @__PURE__ */ jsxs46("div", { className: "mbrfa-filters", children: [
15109
15152
  /* @__PURE__ */ jsxs46("label", { className: "mbrfa-search", children: [
15110
15153
  "Search requests",
@@ -15186,7 +15229,7 @@ function RfaDashboardContent({ client, signatureClient, options, patientId, clai
15186
15229
  ] })
15187
15230
  ] });
15188
15231
  }
15189
- function RfaDetail({ layout, id, selectedItem, selectedResponseDocumentId, client, signatureClient, options, permissions, environment, actorReference, onContinue, disabled, draftFormProps, canManageProviderSignatures, onCopied, getPatientHref, getClaimHref, getProviderHref, formPreviewUrl, initialAction }) {
15232
+ function RfaDetail({ layout, id, selectedItem, selectedResponseDocumentId, client, signatureClient, options, permissions, environment, actorReference, onContinue, disabled, draftFormProps, canManageProviderSignatures, renderSendSignatureSetup, onCopied, getPatientHref, getClaimHref, getProviderHref, formPreviewUrl, initialAction }) {
15190
15233
  const [rfa, setRfa] = useState33(null);
15191
15234
  const [error, setError] = useState33("");
15192
15235
  const [busy, setBusy] = useState33(false);
@@ -15695,30 +15738,34 @@ function RfaDetail({ layout, id, selectedItem, selectedResponseDocumentId, clien
15695
15738
  simple && unsent ? /* @__PURE__ */ jsx48("button", { type: "button", className: "mbtd-primary", disabled: locked, onClick: () => setSending(true), children: "Send" }) : simple && reviewable && detailTab === "details" ? /* @__PURE__ */ jsx48("button", { type: "button", disabled: locked, onClick: () => reveal("review"), children: "Record response" }) : null
15696
15739
  ] })
15697
15740
  ] }) : null,
15698
- simple && sending && unsent ? /* @__PURE__ */ jsx48(
15699
- RfaSendDialog,
15700
- {
15701
- rfa,
15702
- client,
15703
- documentIds,
15704
- diagnosisDescriptions: descriptions2,
15705
- directory,
15706
- directoryLoading,
15707
- directoryError,
15708
- environment,
15709
- canSend: permissions.includes("send"),
15710
- canSign,
15711
- actorReference,
15712
- previewUrl: formPreviewUrl,
15713
- signatureSetup: canManageProviderSignatures && canSign ? settingSignature ? /* @__PURE__ */ jsx48(RfaProviderSignatureSetup, { client: signatureClient, renderingProviderId: rfa.renderingProviderId, providerName: rfa.providerName, disabled: !!locked, onSaved: () => setSettingSignature(false), onCancel: () => setSettingSignature(false) }) : /* @__PURE__ */ jsx48("p", { children: /* @__PURE__ */ jsx48("button", { type: "button", className: "mbrfa-text-link", onClick: () => setSettingSignature(true), children: "Set up or replace the physician's saved signature" }) }) : null,
15714
- onUpdated: adopt,
15715
- onSent: (value) => {
15716
- adopt(value);
15717
- setSending(false);
15718
- },
15719
- onClose: () => setSending(false)
15720
- }
15721
- ) : null
15741
+ simple && sending && unsent ? (() => {
15742
+ const hostSignature = renderSendSignatureSetup?.({ renderingProviderId: rfa.renderingProviderId, providerName: rfa.providerName });
15743
+ return /* @__PURE__ */ jsx48(
15744
+ RfaSendDialog,
15745
+ {
15746
+ rfa,
15747
+ client,
15748
+ documentIds,
15749
+ diagnosisDescriptions: descriptions2,
15750
+ directory,
15751
+ directoryLoading,
15752
+ directoryError,
15753
+ environment,
15754
+ canSend: permissions.includes("send"),
15755
+ canSign,
15756
+ actorReference,
15757
+ previewUrl: formPreviewUrl,
15758
+ signatureMissing: hostSignature?.missing,
15759
+ signatureSetup: hostSignature ? hostSignature.setup : canManageProviderSignatures && canSign ? settingSignature ? /* @__PURE__ */ jsx48(RfaProviderSignatureSetup, { client: signatureClient, renderingProviderId: rfa.renderingProviderId, providerName: rfa.providerName, disabled: !!locked, onSaved: () => setSettingSignature(false), onCancel: () => setSettingSignature(false) }) : /* @__PURE__ */ jsx48("p", { children: /* @__PURE__ */ jsx48("button", { type: "button", className: "mbrfa-text-link", onClick: () => setSettingSignature(true), children: "Set up or replace the physician's saved signature" }) }) : null,
15760
+ onUpdated: adopt,
15761
+ onSent: (value) => {
15762
+ adopt(value);
15763
+ setSending(false);
15764
+ },
15765
+ onClose: () => setSending(false)
15766
+ }
15767
+ );
15768
+ })() : null
15722
15769
  ] })
15723
15770
  ] });
15724
15771
  }