@mindbill/react 0.77.58 → 0.77.59

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
@@ -11407,6 +11407,21 @@ function rfaOutcome(item) {
11407
11407
  if (item.outcome === "denied") return { label: "Denied", tone: "bad" };
11408
11408
  return { label: sentence(item.outcome || "pending"), tone: "muted" };
11409
11409
  }
11410
+ function rfaDecisionSummary(rfa) {
11411
+ const items = rfa.items.filter((item) => !item.decisionClosure?.closed);
11412
+ const decided = items.filter((item) => item.outcome !== "pending");
11413
+ if (!decided.length) return null;
11414
+ if (decided.length < items.length) return { label: "Partially decided", tone: "warn" };
11415
+ if (decided.every((item) => item.outcome === "approved")) return { label: "Approved", tone: "ok" };
11416
+ if (decided.every((item) => item.outcome === "denied")) return { label: "Denied", tone: "bad" };
11417
+ if (decided.every((item) => item.outcome === "modified")) return { label: "Modified", tone: "warn" };
11418
+ return { label: "Partially approved", tone: "warn" };
11419
+ }
11420
+ var FAX_FAILURES = { busy: "The line was busy", no_answer: "No answer", not_a_fax_machine: "The number did not answer as a fax machine", invalid_number: "The number is not in service", rejected: "The call was rejected", carrier_error: "The fax carrier could not complete the call" };
11421
+ function rfaFailureReason(transmission) {
11422
+ const reason = transmission.metadata?.failureReason;
11423
+ return transmission.status === "failed" && typeof reason === "string" ? FAX_FAILURES[reason] ?? "" : "";
11424
+ }
11410
11425
  function RfaPill({ tone = "muted", children }) {
11411
11426
  return /* @__PURE__ */ jsx30("span", { className: "mbrfa-pill", "data-tone": tone, children });
11412
11427
  }
@@ -11424,11 +11439,12 @@ function RfaStatusCard({ rfa }) {
11424
11439
  const stages = ["Draft", "Sent", "Received", "Decided"];
11425
11440
  const current = rfa.submittedAt && decided ? 3 : rfa.receivedAt ? 2 : rfa.submittedAt ? 1 : 0;
11426
11441
  const stopped = status === "canceled" || status === "failed";
11427
- const detail = status === "canceled" ? "This request was canceled" : status === "failed" ? "Delivery needs attention" : rfa.submittedAt ? `Sent ${rfaShortDate(rfa.submittedAt)}` : "Not sent yet";
11442
+ const failure = status === "failed" ? rfa.transmissions.map(rfaFailureReason).filter(Boolean).at(-1) : "";
11443
+ const detail = status === "canceled" ? "This request was canceled" : status === "failed" ? `Delivery needs attention${failure ? `: ${failure.charAt(0).toLowerCase()}${failure.slice(1)}` : ""}` : rfa.submittedAt ? `Sent ${rfaShortDate(rfa.submittedAt)}` : "Not sent yet";
11428
11444
  return /* @__PURE__ */ jsxs28("section", { className: "mbrfa-status", "aria-label": "Request status", "data-stopped": stopped || void 0, children: [
11429
11445
  /* @__PURE__ */ jsxs28("div", { className: "mbrfa-status-heading", children: [
11430
11446
  /* @__PURE__ */ jsxs28("div", { children: [
11431
- /* @__PURE__ */ jsx30("h3", { children: !rfa.submittedAt && !stopped ? "Draft" : RFA_LIFECYCLE_LABELS2[status] }),
11447
+ /* @__PURE__ */ jsx30("h3", { children: !rfa.submittedAt && !stopped ? "Draft" : !stopped && rfaDecisionSummary(rfa) ? rfaDecisionSummary(rfa).label : RFA_LIFECYCLE_LABELS2[status] }),
11432
11448
  /* @__PURE__ */ jsx30("p", { children: detail })
11433
11449
  ] }),
11434
11450
  rfa.submittedAt && !stopped ? /* @__PURE__ */ jsxs28("div", { className: "mbrfa-status-due", children: [
@@ -11739,7 +11755,8 @@ function RfaTrackingContent({ rfa: provided, options, permissions = [], onUpdate
11739
11755
  ] }) }),
11740
11756
  /* @__PURE__ */ jsx31("tbody", { children: rfa.items.map((item, index) => {
11741
11757
  const appointment = scheduling.find((value) => value.itemId === item.id);
11742
- const outcome = rfaOutcome(item);
11758
+ const awaiting = item.outcome === "pending" && !item.decisionClosure?.closed && rfa.items.some((other) => other.outcome !== "pending");
11759
+ const outcome = awaiting ? { label: "Awaiting decision", tone: "warn" } : rfaOutcome(item);
11743
11760
  const showAppointment = !!appointment && (appointment.eligible || appointment.version > 0);
11744
11761
  const closable = canClose && item.outcome === "pending" && !item.decidedAt;
11745
11762
  const correctable = canCorrect && !!item.currentDecisionEventId && item.outcome !== "pending";
@@ -11851,7 +11868,8 @@ function RfaTrackingContent({ rfa: provided, options, permissions = [], onUpdate
11851
11868
  transmission.providerMessageId ? /* @__PURE__ */ jsxs29("small", { children: [
11852
11869
  "Reference ",
11853
11870
  transmission.providerMessageId
11854
- ] }) : null
11871
+ ] }) : null,
11872
+ rfaFailureReason(transmission) ? /* @__PURE__ */ jsx31("small", { children: rfaFailureReason(transmission) }) : null
11855
11873
  ] }),
11856
11874
  /* @__PURE__ */ jsx31("td", { children: rfaShortDate(transmission.receivedAt) }),
11857
11875
  /* @__PURE__ */ jsx31("td", { className: "mbrfa-row-actions", children: evidence(transmission.proofDocumentId, "Receipt") })
@@ -14198,6 +14216,7 @@ function RfaSendDialog({ rfa, client, documentIds, diagnosisDescriptions, direct
14198
14216
  const supporting = rfa.documents.filter((document2) => ["clinical_report", "supporting_record"].includes(document2.documentType) && documentIds.includes(document2.id));
14199
14217
  const missingDiagnosis = rfa.items.find((item) => !(diagnosisDescriptions[item.id] ?? item.diagnosisDescription ?? "").trim());
14200
14218
  const live = environment === "live";
14219
+ const lastFailure = rfa.transmissions.map(rfaFailureReason).filter(Boolean).at(-1) ?? "";
14201
14220
  const needsSignature = !rfa.signedAt && (signatureMissing ?? signatureRefused);
14202
14221
  useEffect25(() => {
14203
14222
  if (signatureMissing === false) setSignatureRefused(false);
@@ -14273,7 +14292,11 @@ function RfaSendDialog({ rfa, client, documentIds, diagnosisDescriptions, direct
14273
14292
  supporting.length ? /* @__PURE__ */ jsx45("ul", { children: supporting.map((document2) => /* @__PURE__ */ jsx45("li", { children: document2.filename }, document2.id)) }) : /* @__PURE__ */ jsx45("p", { children: "None attached yet." })
14274
14293
  ] })
14275
14294
  ] }),
14276
- resend ? /* @__PURE__ */ jsx45("p", { className: "mbrfa-send-signature", role: "status", children: "The last attempt did not go through. Check the destination with the claims administrator, or choose another way to send, then send again." }) : null,
14295
+ resend ? /* @__PURE__ */ jsxs43("p", { className: "mbrfa-send-signature", role: "status", children: [
14296
+ "The last attempt did not go through",
14297
+ lastFailure ? `: ${lastFailure.charAt(0).toLowerCase()}${lastFailure.slice(1)}` : "",
14298
+ ". Check the destination with the claims administrator, or choose another way to send, then send again."
14299
+ ] }) : null,
14277
14300
  /* @__PURE__ */ jsxs43("div", { className: "mbrfa-send-methods", role: "radiogroup", "aria-label": "Send by", children: [
14278
14301
  /* @__PURE__ */ jsx45("span", { children: "Send by" }),
14279
14302
  /* @__PURE__ */ jsxs43("label", { children: [
@@ -15635,6 +15658,8 @@ function RfaDetail({ layout, id, selectedItem, selectedResponseDocumentId, clien
15635
15658
  const canSign = permissions.includes("sign") && !!actorReference?.trim();
15636
15659
  const unsent = rfa && !rfa.submittedAt && ["draft", "ready", "incomplete", "deferred"].includes(rfa.status);
15637
15660
  const resendable = !!rfa && rfaCanResend(rfa);
15661
+ const decision = rfa && !unsent && !["failed", "canceled"].includes(getRfaLifecycleStatus4(rfa)) ? rfaDecisionSummary(rfa) : null;
15662
+ const statusPill = rfa ? /* @__PURE__ */ jsx49(RfaPill, { tone: decision ? decision.tone : rfaLifecycleTone(rfa), children: unsent ? "Draft" : decision ? decision.label : RFA_LIFECYCLE_LABELS5[getRfaLifecycleStatus4(rfa)] }) : null;
15638
15663
  const reviewable = !!rfa && (!!rfa.submittedAt || ["submitted", "received", "under_review", "information_requested", "approved", "modified", "denied", "mixed", "incomplete", "deferred"].includes(rfa.status));
15639
15664
  const openDocument = (documentId, title) => run(async () => {
15640
15665
  const blob = await client.getDocument(id, documentId);
@@ -15652,7 +15677,7 @@ function RfaDetail({ layout, id, selectedItem, selectedResponseDocumentId, clien
15652
15677
  /* @__PURE__ */ jsxs47("div", { className: "mbrfa-detail-toolbar", children: [
15653
15678
  /* @__PURE__ */ jsx49("div", { children: simple ? /* @__PURE__ */ jsxs47(Fragment28, { children: [
15654
15679
  /* @__PURE__ */ jsx49("h2", { children: rfa.displayReference || "Request for Authorization" }),
15655
- /* @__PURE__ */ jsx49(RfaPill, { tone: rfaLifecycleTone(rfa), children: unsent ? "Draft" : RFA_LIFECYCLE_LABELS5[getRfaLifecycleStatus4(rfa)] }),
15680
+ statusPill,
15656
15681
  /* @__PURE__ */ jsx49(RfaPill, { children: rfa.expedited ? "Expedited" : sentence2(rfa.reviewType) }),
15657
15682
  rfa.claimNumber ? /* @__PURE__ */ jsxs47(RfaPill, { tone: "mono", children: [
15658
15683
  "Claim ",
@@ -15948,7 +15973,7 @@ function RfaDetail({ layout, id, selectedItem, selectedResponseDocumentId, clien
15948
15973
  ] })
15949
15974
  ] }),
15950
15975
  !editing || !simple ? /* @__PURE__ */ jsxs47("div", { className: "mbrfa-bottom-actions", children: [
15951
- simple ? /* @__PURE__ */ jsx49(RfaPill, { tone: rfaLifecycleTone(rfa), children: unsent ? "Draft" : RFA_LIFECYCLE_LABELS5[getRfaLifecycleStatus4(rfa)] }) : /* @__PURE__ */ jsx49("span", { className: "mbrfa-badge", children: RFA_LIFECYCLE_LABELS5[getRfaLifecycleStatus4(rfa)] }),
15976
+ simple ? statusPill : /* @__PURE__ */ jsx49("span", { className: "mbrfa-badge", children: RFA_LIFECYCLE_LABELS5[getRfaLifecycleStatus4(rfa)] }),
15952
15977
  /* @__PURE__ */ jsxs47("div", { className: "mbtd-actions", children: [
15953
15978
  !simple && permissions.includes("edit") && canEditRfaDraft(rfa) && !editing ? /* @__PURE__ */ jsx49("button", { type: "button", className: "mbtd-primary", disabled: locked, onClick: () => {
15954
15979
  setDetailTab("details");