@mindbill/react 0.77.42 → 0.77.43

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
@@ -1010,6 +1010,8 @@ type RfaDraftFormProps = TreatmentDraftAppearance & RfaContactDirectoryProps & {
1010
1010
  selectors?: RfaFormSelectors;
1011
1011
  /** Open the host's in-place editor for the selected practice or location (null adds a location). The form reloads saved values when focus returns. */
1012
1012
  onEditPractice?: (practiceId: string) => void;
1013
+ /** Opens the host's editor for a new practice; adds an "Add new practice" choice to the practice list. */
1014
+ onAddPractice?: () => void;
1013
1015
  onEditLocation?: (locationId: string | null, practiceId: string) => void;
1014
1016
  /** Saved sets of requested treatments offered in the Requested Treatment section (official form). */
1015
1017
  treatmentTemplates?: RfaTreatmentTemplate[] | undefined;
@@ -1057,7 +1059,7 @@ type RfaDraftFormProps = TreatmentDraftAppearance & RfaContactDirectoryProps & {
1057
1059
  /** Remove blank optional item fields, retaining an explicitly cleared return fax. */
1058
1060
  declare function normalizeRfaDraft(draft: RfaDraftInput): RfaDraftInput;
1059
1061
  declare function validateRfaDraft(draft: RfaDraftInput): string | null;
1060
- declare function RfaDraftForm({ initialDraft, identity, officialForm, formDetails, selectors, onEditPractice, onEditLocation, treatmentTemplates, onSaveTreatmentTemplate, onManageTreatmentTemplates, managePracticeHref, manageLocationsHref, onRefreshProfile, profilePending, onReview, onPreview, searchClaimsAdministrators, getClaimsAdministratorDirectory, embedded, onSave, onBack, mode, searchDiagnosisCodes, organizationProfile, savedDiagnosisCodes, supportingDocuments, disabled, ...appearance }: RfaDraftFormProps): ReactElement;
1062
+ declare function RfaDraftForm({ initialDraft, identity, officialForm, formDetails, selectors, onEditPractice, onAddPractice, onEditLocation, treatmentTemplates, onSaveTreatmentTemplate, onManageTreatmentTemplates, managePracticeHref, manageLocationsHref, onRefreshProfile, profilePending, onReview, onPreview, searchClaimsAdministrators, getClaimsAdministratorDirectory, embedded, onSave, onBack, mode, searchDiagnosisCodes, organizationProfile, savedDiagnosisCodes, supportingDocuments, disabled, ...appearance }: RfaDraftFormProps): ReactElement;
1061
1063
 
1062
1064
  /** A saved set of requested treatments. Diagnoses stay with the claim, so templates do not carry them. */
1063
1065
  type RfaTreatmentTemplate = {
@@ -1134,6 +1136,8 @@ type RfaDashboardProps = OrganizationClientOptions & TreatmentDraftAppearance &
1134
1136
  officialForm?: boolean;
1135
1137
  /** Host in-place editors for the selected practice or location (official form). */
1136
1138
  onEditPractice?: (practiceId: string) => void;
1139
+ /** Opens the host's editor for a new practice; adds an "Add new practice" choice to the practice list. */
1140
+ onAddPractice?: () => void;
1137
1141
  onEditLocation?: (locationId: string | null, practiceId: string) => void;
1138
1142
  /** Saved sets of requested treatments for the official form, with host-owned saving and management. */
1139
1143
  treatmentTemplates?: RfaTreatmentTemplate[];
package/dist/index.js CHANGED
@@ -12681,7 +12681,7 @@ function RfaClaimSetup({ client, disabled, onCreated, onCancel }) {
12681
12681
  // src/rfa-practice-picker.tsx
12682
12682
  import { useEffect as useEffect20, useRef as useRef18, useState as useState23 } from "react";
12683
12683
  import { Fragment as Fragment21, jsx as jsx38, jsxs as jsxs36 } from "react/jsx-runtime";
12684
- function RfaPracticePicker({ profile, value, onChange, managePracticeHref, manageLocationsHref, onEditPractice, onEditLocation, onChosen }) {
12684
+ function RfaPracticePicker({ profile, value, onChange, managePracticeHref, manageLocationsHref, onEditPractice, onAddPractice, onEditLocation, onChosen }) {
12685
12685
  const practices = profile?.billingProviders ?? [];
12686
12686
  const [practice, setPractice] = useState23(() => practices.find((item) => item.name === value?.name)?.id ?? "");
12687
12687
  const [location, setLocation] = useState23(() => practice ? (profile?.locations ?? []).find((item) => item.active !== false && item.street === value?.address && (!item.billingProviderId || item.billingProviderId === practice))?.id ?? "" : "");
@@ -12714,26 +12714,46 @@ function RfaPracticePicker({ profile, value, onChange, managePracticeHref, manag
12714
12714
  if (onlyPractice) choosePractice(onlyPractice);
12715
12715
  }, [onlyPractice]);
12716
12716
  const locations = (profile?.locations ?? []).filter((item) => item.active !== false && (item.billingProviderId ? item.billingProviderId === practice : practices.length <= 1));
12717
+ const adding = useRef18(null);
12718
+ const practiceIds = practices.map((item) => item.id).join("|"), locationIds = locations.map((item) => item.id).join("|");
12719
+ useEffect20(() => {
12720
+ const pending = adding.current;
12721
+ if (!pending) return;
12722
+ const added = (pending.kind === "practice" ? practices : locations).find((item) => !pending.known.includes(item.id));
12723
+ if (!added) return;
12724
+ adding.current = null;
12725
+ if (pending.kind === "practice") choosePractice(added.id);
12726
+ else chooseLocation(added.id);
12727
+ }, [practiceIds, locationIds]);
12728
+ const chooseLocation = (id) => {
12729
+ const chosen = locations.find((item) => item.id === id);
12730
+ if (!chosen) return;
12731
+ setLocation(id);
12732
+ setLocationQuery("");
12733
+ onChosen?.();
12734
+ onChange({ ...value, ...located(chosen, practices.find((item) => item.id === practice)?.phone) });
12735
+ };
12736
+ const ADD = "__add__";
12717
12737
  return /* @__PURE__ */ jsxs36(Fragment21, { children: [
12718
12738
  /* @__PURE__ */ jsxs36(RfaPicker, { label: "Practice", children: [
12719
- /* @__PURE__ */ jsx38(RfaIdentitySelect, { label: "Saved practice", placeholder: "Choose a practice", searchPlaceholder: "Search practices", query: practiceQuery, onSearch: setPracticeQuery, searchable: true, value: practice, options: practices.filter((item) => item.id === practice || item.name.toLowerCase().includes(practiceQuery.toLowerCase())).map((item) => ({ id: item.id, label: item.name })), onSelect: choosePractice }),
12739
+ /* @__PURE__ */ jsx38(RfaIdentitySelect, { label: "Saved practice", placeholder: "Choose a practice", searchPlaceholder: "Search practices", query: practiceQuery, onSearch: setPracticeQuery, searchable: true, value: practice, options: [...practices.filter((item) => item.id === practice || item.name.toLowerCase().includes(practiceQuery.toLowerCase())).map((item) => ({ id: item.id, label: item.name })), ...onAddPractice ? [{ id: ADD, label: "Add new practice", action: true }] : []], onSelect: (id) => {
12740
+ if (id !== ADD) return choosePractice(id);
12741
+ adding.current = { kind: "practice", known: practices.map((item) => item.id) };
12742
+ onAddPractice?.();
12743
+ } }),
12720
12744
  /* @__PURE__ */ jsxs36("span", { className: "mbrfa-picker-links", children: [
12721
12745
  onEditPractice && practice ? /* @__PURE__ */ jsx38("button", { type: "button", className: "mbrfa-link", onClick: () => onEditPractice(practice), children: "Edit practice" }) : null,
12722
12746
  managePracticeHref ? /* @__PURE__ */ jsx38("a", { className: "mbrfa-link-out", href: managePracticeHref, target: "_blank", rel: "noopener noreferrer", children: onEditPractice ? "Manage practices \u2197" : "Add / manage practices" }) : null
12723
12747
  ] })
12724
12748
  ] }),
12725
12749
  /* @__PURE__ */ jsxs36(RfaPicker, { label: "Practice location", children: [
12726
- /* @__PURE__ */ jsx38(RfaIdentitySelect, { label: "Practice location", placeholder: practice ? "Choose a location" : "Choose a practice first", searchPlaceholder: "Search locations", query: locationQuery, onSearch: setLocationQuery, searchable: true, disabled: !practice, value: location, options: locations.filter((item) => item.id === location || item.name.toLowerCase().includes(locationQuery.toLowerCase())).map((item) => ({ id: item.id, label: item.name, detail: `${item.street}, ${item.city}` })), onSelect: (id) => {
12727
- const chosen = locations.find((item) => item.id === id);
12728
- if (!chosen) return;
12729
- setLocation(id);
12730
- setLocationQuery("");
12731
- onChosen?.();
12732
- onChange({ ...value, ...located(chosen, practices.find((item) => item.id === practice)?.phone) });
12750
+ /* @__PURE__ */ jsx38(RfaIdentitySelect, { label: "Practice location", placeholder: practice ? "Choose a location" : "Choose a practice first", searchPlaceholder: "Search locations", query: locationQuery, onSearch: setLocationQuery, searchable: true, disabled: !practice, value: location, options: [...locations.filter((item) => item.id === location || item.name.toLowerCase().includes(locationQuery.toLowerCase())).map((item) => ({ id: item.id, label: item.name, detail: `${item.street}, ${item.city}` })), ...onEditLocation && practice ? [{ id: ADD, label: "Add new location", action: true }] : []], onSelect: (id) => {
12751
+ if (id !== ADD) return chooseLocation(id);
12752
+ adding.current = { kind: "location", known: locations.map((item) => item.id) };
12753
+ onEditLocation?.(null, practice);
12733
12754
  } }),
12734
12755
  /* @__PURE__ */ jsxs36("span", { className: "mbrfa-picker-links", children: [
12735
12756
  onEditLocation && practice && location ? /* @__PURE__ */ jsx38("button", { type: "button", className: "mbrfa-link", onClick: () => onEditLocation(location, practice), children: "Edit location" }) : null,
12736
- onEditLocation && practice ? /* @__PURE__ */ jsx38("button", { type: "button", className: "mbrfa-link", onClick: () => onEditLocation(null, practice), children: "Add location" }) : null,
12737
12757
  manageLocationsHref ? /* @__PURE__ */ jsx38("a", { className: "mbrfa-link-out", href: manageLocationsHref, target: "_blank", rel: "noopener noreferrer", children: onEditLocation ? "Manage locations \u2197" : "Add / manage locations" }) : null
12738
12758
  ] })
12739
12759
  ] })
@@ -13242,7 +13262,7 @@ function validateRfaDraft(draft2) {
13242
13262
  }
13243
13263
  return null;
13244
13264
  }
13245
- function RfaDraftForm({ initialDraft, identity, officialForm = false, formDetails, selectors, onEditPractice, onEditLocation, treatmentTemplates, onSaveTreatmentTemplate, onManageTreatmentTemplates, managePracticeHref, manageLocationsHref, onRefreshProfile, profilePending = false, onReview, onPreview, searchClaimsAdministrators, getClaimsAdministratorDirectory, embedded = false, onSave, onBack, mode = "create", searchDiagnosisCodes, organizationProfile, savedDiagnosisCodes = [], supportingDocuments, disabled = false, ...appearance }) {
13265
+ function RfaDraftForm({ initialDraft, identity, officialForm = false, formDetails, selectors, onEditPractice, onAddPractice, onEditLocation, treatmentTemplates, onSaveTreatmentTemplate, onManageTreatmentTemplates, managePracticeHref, manageLocationsHref, onRefreshProfile, profilePending = false, onReview, onPreview, searchClaimsAdministrators, getClaimsAdministratorDirectory, embedded = false, onSave, onBack, mode = "create", searchDiagnosisCodes, organizationProfile, savedDiagnosisCodes = [], supportingDocuments, disabled = false, ...appearance }) {
13246
13266
  const [savedDraft, setDraft] = useState28(() => normalizeRfaDraft(initialDraft));
13247
13267
  useEffect23(() => {
13248
13268
  if (identity) setDraft((current) => {
@@ -13433,7 +13453,7 @@ function RfaDraftForm({ initialDraft, identity, officialForm = false, formDetail
13433
13453
  /* @__PURE__ */ jsx43("legend", { children: "Requesting Physician Information" }),
13434
13454
  /* @__PURE__ */ jsxs41("div", { className: "mbrfa-pickers", "data-columns": selectors?.physician ? 3 : 2, children: [
13435
13455
  selectors?.physician ? /* @__PURE__ */ jsx43(RfaPicker, { required: true, label: "Requesting physician", children: selectors.physician }) : null,
13436
- /* @__PURE__ */ jsx43(RfaPracticePicker, { profile: organizationProfile, value: draft2.requestingPractice, onChange: (requestingPractice) => update({ requestingPractice }), ...managePracticeHref ? { managePracticeHref } : {}, ...manageLocationsHref ? { manageLocationsHref } : {}, onEditPractice, onEditLocation, onChosen: () => setPracticeManual(false) })
13456
+ /* @__PURE__ */ jsx43(RfaPracticePicker, { profile: organizationProfile, value: draft2.requestingPractice, onChange: (requestingPractice) => update({ requestingPractice }), ...managePracticeHref ? { managePracticeHref } : {}, ...manageLocationsHref ? { manageLocationsHref } : {}, onEditPractice, onAddPractice, onEditLocation, onChosen: () => setPracticeManual(false) })
13437
13457
  ] }),
13438
13458
  /* @__PURE__ */ jsx43("fieldset", { className: "mbrfa-plain", disabled: locked, children: /* @__PURE__ */ jsx43(
13439
13459
  RfaOfficialContactFields,
@@ -14577,7 +14597,7 @@ function RfaDashboard({ sessionEndpoint, getSession, apiBaseUrl, fetch: fetchOve
14577
14597
  const identity = useMemo12(() => ({ client, signatureClient, key: key() }), [client, signatureClient]);
14578
14598
  return /* @__PURE__ */ jsx47(RfaDashboardContent, { ...props, ...patientId ? { patientId } : {}, ...claimId ? { claimId } : {}, ...renderingProviderId ? { renderingProviderId } : {}, client, signatureClient, options }, `${identity.key}:${patientId ?? ""}:${claimId ?? ""}:${renderingProviderId ?? ""}`);
14579
14599
  }
14580
- function RfaDashboardContent({ client, signatureClient, options, patientId, claimId, renderingProviderId, initialDraft, initialView = "overview", initialOverviewView, initialStatus = "", initialAgingBucket = "", taskPresentation, taskQuery: taskQuery2, renderTaskIdentity, navigation, permissions = [], canCreateClaim = false, renderClaimSelector, renderProviderSelector, officialForm = false, managePracticeHref, onEditPractice, onEditLocation, treatmentTemplates, onSaveTreatmentTemplate, onManageTreatmentTemplates, savedProfileChanges, manageLocationsHref, onPreviewRequest, canManageProviderSignatures = false, environment = "sandbox", actorReference, onCreated, onContinue, selectedRfaId, selectedTreatmentId, selectedResponseDocumentId: controlledResponseDocumentId, onSelectRfa, getRfaHref, getPatientHref, getClaimHref, getProviderHref, formPreviewUrl, hideBackButton = false, hideHeading = false, layout = "classic", ...appearance }) {
14600
+ function RfaDashboardContent({ client, signatureClient, options, patientId, claimId, renderingProviderId, initialDraft, initialView = "overview", 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, canManageProviderSignatures = false, environment = "sandbox", actorReference, onCreated, onContinue, selectedRfaId, selectedTreatmentId, selectedResponseDocumentId: controlledResponseDocumentId, onSelectRfa, getRfaHref, getPatientHref, getClaimHref, getProviderHref, formPreviewUrl, hideBackButton = false, hideHeading = false, layout = "classic", ...appearance }) {
14581
14601
  const active = useRef23(true);
14582
14602
  useEffect26(() => {
14583
14603
  active.current = true;
@@ -14593,7 +14613,7 @@ function RfaDashboardContent({ client, signatureClient, options, patientId, clai
14593
14613
  const merge = (current, saved) => saved?.length ? [...current.map((item) => saved.find((next) => next.id === item.id) ?? item), ...saved.filter((next) => !current.some((item) => item.id === next.id))] : current;
14594
14614
  setProfile((current) => current ? { ...current, billingProviders: merge(current.billingProviders, savedProfileChanges.billingProviders), locations: merge(current.locations, savedProfileChanges.locations) } : current);
14595
14615
  }, [savedProfileChanges]);
14596
- const draftFormProps = { officialForm, profilePending: !profile && !profileSettled, ...officialForm && (treatmentTemplates || onSaveTreatmentTemplate) ? { treatmentTemplates: treatmentTemplates ?? [], onSaveTreatmentTemplate, onManageTreatmentTemplates } : {}, ...onEditPractice ? { onEditPractice } : {}, ...onEditLocation ? { onEditLocation } : {}, ...managePracticeHref ? { managePracticeHref } : {}, ...manageLocationsHref ? { manageLocationsHref } : {}, onRefreshProfile: async () => {
14616
+ const draftFormProps = { officialForm, profilePending: !profile && !profileSettled, ...officialForm && (treatmentTemplates || onSaveTreatmentTemplate) ? { treatmentTemplates: treatmentTemplates ?? [], onSaveTreatmentTemplate, onManageTreatmentTemplates } : {}, ...onEditPractice ? { onEditPractice } : {}, ...onAddPractice ? { onAddPractice } : {}, ...onEditLocation ? { onEditLocation } : {}, ...managePracticeHref ? { managePracticeHref } : {}, ...manageLocationsHref ? { manageLocationsHref } : {}, onRefreshProfile: async () => {
14597
14617
  const next = await createOrganizationClient4(options).getBillingProfile();
14598
14618
  if (active.current) setProfile(next);
14599
14619
  }, ...client.searchClaimsAdministrators ? { searchClaimsAdministrators: client.searchClaimsAdministrators } : {}, ...client.getClaimsAdministratorDirectory ? { getClaimsAdministratorDirectory: client.getClaimsAdministratorDirectory } : {}, searchDiagnosisCodes: references.searchDiagnosisCodes, ...profile ? { organizationProfile: profile } : {} };