@mindbill/react 0.14.2 → 0.16.0
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/README.md +45 -12
- package/dist/index.d.ts +43 -8
- package/dist/index.js +278 -135
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -16,10 +16,10 @@ Procedure entry is keyboard-first: the form always keeps one empty row after the
|
|
|
16
16
|
import { ConnectedBillLifecycle } from "@mindbill/react";
|
|
17
17
|
|
|
18
18
|
<ConnectedBillLifecycle
|
|
19
|
-
|
|
20
|
-
sessionEndpoint="/api/mindbill/
|
|
19
|
+
create={knownBillValues}
|
|
20
|
+
sessionEndpoint="/api/mindbill/session"
|
|
21
21
|
appearance={{ preset: "qme-companion" }}
|
|
22
|
-
|
|
22
|
+
onBillCreated={(billId) => navigate(`/bills/${billId}`)}
|
|
23
23
|
/>
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -41,21 +41,19 @@ Choose a complete preset, then override only the tokens your design system owns.
|
|
|
41
41
|
|
|
42
42
|
Available presets are `mindbill`, `qme-companion`, `orange-bright`, and `clinical-blue`. Preset names describe visual styles rather than customer or partner brands. Supported overrides include accent, accent text, background, surface, input background, text, muted text, border, font, panel radius, control radius, shadow, danger, success, and warning colors.
|
|
43
43
|
|
|
44
|
-
Add one authenticated route to your app. It
|
|
44
|
+
Add one authenticated route to your app. It maps the signed-in user's role to billing permissions, then mints an exact-origin token for that user in your MindBill organization. The Partner API key stays on the server.
|
|
45
45
|
|
|
46
46
|
```ts
|
|
47
|
-
//
|
|
47
|
+
// Any server framework: POST /api/mindbill/session
|
|
48
48
|
import { mindbill } from "@/lib/mindbill";
|
|
49
49
|
|
|
50
50
|
export async function POST(request: Request) {
|
|
51
51
|
const user = await requireUser(request); // your existing auth
|
|
52
|
-
const { billId } = await request.json();
|
|
53
|
-
await requireBillAccess(user, billId); // your existing authorization
|
|
54
52
|
|
|
55
53
|
const session = await mindbill.createBrowserSession({
|
|
56
|
-
|
|
57
|
-
billId,
|
|
54
|
+
subject: user.id,
|
|
58
55
|
allowedOrigin: new URL(request.url).origin,
|
|
56
|
+
permissions: billingPermissionsFor(user.role),
|
|
59
57
|
expiresIn: 900,
|
|
60
58
|
});
|
|
61
59
|
|
|
@@ -68,24 +66,59 @@ export async function POST(request: Request) {
|
|
|
68
66
|
|
|
69
67
|
The component searches MindBill's claims-administrator directory with both payer text and the current claim number. It explains name and claim-pattern evidence, shows delivery availability, and only preselects a high-confidence exact name or alias match.
|
|
70
68
|
|
|
71
|
-
|
|
69
|
+
The API key binds every session to one organization. `subject` identifies the user and `permissions` express the role. MindBill enforces the organization boundary on every bill request. A permanent Partner API key must never enter frontend code.
|
|
72
70
|
|
|
73
71
|
## Compact status
|
|
74
72
|
|
|
75
|
-
Use `ConnectedBillStatus` when the partner page only needs a small status and aging surface.
|
|
73
|
+
Use `ConnectedBillStatus` when the partner page only needs a small status and aging surface. It reuses the same session route.
|
|
76
74
|
|
|
77
75
|
```tsx
|
|
78
76
|
import { ConnectedBillStatus } from "@mindbill/react";
|
|
79
77
|
|
|
80
78
|
<ConnectedBillStatus
|
|
81
79
|
billId={billId}
|
|
82
|
-
sessionEndpoint="/api/mindbill/
|
|
80
|
+
sessionEndpoint="/api/mindbill/session"
|
|
83
81
|
appearance={{ preset: "qme-companion" }}
|
|
84
82
|
/>
|
|
85
83
|
```
|
|
86
84
|
|
|
87
85
|
Use `useBillStatus({ billId })` when you want to render custom status UI. It returns `data`, `error`, `isLoading`, `isRefreshing`, and `refresh`. Use `createBillStatusClient` outside React.
|
|
88
86
|
|
|
87
|
+
## Lifecycle actions
|
|
88
|
+
|
|
89
|
+
MindBill returns the actions that are valid for the bill's current state. Render that server-authoritative list instead of duplicating rejection, EOR, denial, review, payment, and closure rules in your application.
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
import { BillLifecycleActions } from "@mindbill/react";
|
|
93
|
+
|
|
94
|
+
<BillLifecycleActions
|
|
95
|
+
actions={bill.data.lifecycle.actions}
|
|
96
|
+
onAction={(action) => {
|
|
97
|
+
switch (action.id) {
|
|
98
|
+
case "view_eor": return bill.openEor();
|
|
99
|
+
case "post_payment": return setPaymentOpen(true);
|
|
100
|
+
case "second_review": return setSecondReviewOpen(true);
|
|
101
|
+
case "correct_and_resubmit": return bill.startCorrection();
|
|
102
|
+
case "close": return bill.closeBill({ reason: "Resolved" });
|
|
103
|
+
}
|
|
104
|
+
}}
|
|
105
|
+
/>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Disabled actions are hidden by default. Set `showUnavailable` to show them with the reason returned by the API.
|
|
109
|
+
|
|
110
|
+
## Activity timeline
|
|
111
|
+
|
|
112
|
+
`BillActivityTimeline` renders ordered lifecycle events. Feed it events stored from MindBill's signed webhooks so a reload does not depend on browser callback history.
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
import { BillActivityTimeline } from "@mindbill/react";
|
|
116
|
+
|
|
117
|
+
<BillActivityTimeline events={billEvents} />
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Browser callbacks such as `onBillCreated`, `onBillIdChange`, and `onChanged` are for immediate UI, navigation, optimistic state, and analytics. Signed webhooks are the authoritative integration for durable server state.
|
|
121
|
+
|
|
89
122
|
## Controlled escape hatch
|
|
90
123
|
|
|
91
124
|
Use `BillReviewForm` only when your application intentionally owns the API calls and local review state. Known bill values and payer documents remain explicit and editable.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MindBillAppearance, MindBillEventDetail, MindBillErrorDetail } from '@mindbill/embed';
|
|
2
2
|
export { MindBillAppearance, MindBillErrorDetail, MindBillEventDetail } from '@mindbill/embed';
|
|
3
3
|
import { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
4
|
-
import { BillLifecycleClientOptions, BillLifecycleData, BillLifecycleClient, BillEorDocument } from '@mindbill/browser';
|
|
5
|
-
export { BillEorDocument, BillLifecycleAction, BillLifecycleActionId, BillLifecycleClient, BillLifecycleClientOptions, BillLifecycleData, BillLifecycleSession, BillLifecycleSessionProvider, BillLifecycleSessionRequest, CloseBillInput, PostBillPaymentInput, SubmitSecondReviewInput, createBillLifecycleClient } from '@mindbill/browser';
|
|
4
|
+
import { BillLifecycleAction, BillLifecycleClientOptions, BrowserBillCreateInput, BillLifecycleData, BillLifecycleClient, BillEorDocument } from '@mindbill/browser';
|
|
5
|
+
export { BillEorDocument, BillLifecycleAction, BillLifecycleActionId, BillLifecycleClient, BillLifecycleClientOptions, BillLifecycleData, BillLifecycleSession, BillLifecycleSessionProvider, BillLifecycleSessionRequest, BrowserBillAddress, BrowserBillCreateInput, CloseBillInput, PostBillPaymentInput, SubmitSecondReviewInput, createBillLifecycleClient } from '@mindbill/browser';
|
|
6
6
|
|
|
7
7
|
type MindBillThemePreset = "mindbill" | "qme-companion" | "orange-bright" | "clinical-blue";
|
|
8
8
|
type MindBillReactAppearance = MindBillAppearance & {
|
|
@@ -361,13 +361,12 @@ type BillStatusSession = {
|
|
|
361
361
|
apiBaseUrl?: string;
|
|
362
362
|
};
|
|
363
363
|
type BillStatusSessionRequest = {
|
|
364
|
-
billId: string;
|
|
365
364
|
signal: AbortSignal;
|
|
366
365
|
};
|
|
367
366
|
type BillStatusSessionProvider = (request: BillStatusSessionRequest) => Promise<BillStatusSession>;
|
|
368
367
|
type BillStatusClientOptions = {
|
|
369
368
|
billId: string;
|
|
370
|
-
/** Same-origin route that mints a short-lived
|
|
369
|
+
/** Same-origin route that mints a short-lived organization/user browser session. */
|
|
371
370
|
sessionEndpoint?: string;
|
|
372
371
|
/** Advanced escape hatch for non-HTTP session exchange. */
|
|
373
372
|
getSession?: BillStatusSessionProvider;
|
|
@@ -407,14 +406,50 @@ type ConnectedBillStatusProps = UseBillStatusOptions & {
|
|
|
407
406
|
};
|
|
408
407
|
declare function ConnectedBillStatus({ actions, appearance, className, style, loadingFallback, errorFallback, ...options }: ConnectedBillStatusProps): ReactElement | null;
|
|
409
408
|
|
|
409
|
+
type BillLifecycleActionsProps = {
|
|
410
|
+
actions: readonly BillLifecycleAction[];
|
|
411
|
+
onAction: (action: BillLifecycleAction) => void;
|
|
412
|
+
/** Show disabled actions and the server-provided reason. Defaults to false. */
|
|
413
|
+
showUnavailable?: boolean;
|
|
414
|
+
disabled?: boolean;
|
|
415
|
+
appearance?: MindBillReactAppearance;
|
|
416
|
+
className?: string;
|
|
417
|
+
style?: CSSProperties;
|
|
418
|
+
};
|
|
419
|
+
/** Returns the server-authoritative actions that should be rendered. */
|
|
420
|
+
declare function visibleBillLifecycleActions(actions: readonly BillLifecycleAction[], showUnavailable?: boolean): BillLifecycleAction[];
|
|
421
|
+
declare function BillLifecycleActions({ actions, onAction, showUnavailable, disabled, appearance, className, style, }: BillLifecycleActionsProps): ReactElement | null;
|
|
422
|
+
type BillActivityEvent = {
|
|
423
|
+
id: string;
|
|
424
|
+
type: string;
|
|
425
|
+
createdAt: string;
|
|
426
|
+
title?: string;
|
|
427
|
+
description?: string;
|
|
428
|
+
actor?: string;
|
|
429
|
+
};
|
|
430
|
+
type BillActivityTimelineProps = {
|
|
431
|
+
events: readonly BillActivityEvent[];
|
|
432
|
+
emptyLabel?: string;
|
|
433
|
+
appearance?: MindBillReactAppearance;
|
|
434
|
+
className?: string;
|
|
435
|
+
style?: CSSProperties;
|
|
436
|
+
formatDate?: (createdAt: string) => string;
|
|
437
|
+
};
|
|
438
|
+
/** Human-readable fallback for a signed partner event type. */
|
|
439
|
+
declare function billActivityEventLabel(type: string): string;
|
|
440
|
+
declare function BillActivityTimeline({ events, emptyLabel, appearance, className, style, formatDate, }: BillActivityTimelineProps): ReactElement;
|
|
441
|
+
|
|
410
442
|
type UseBillLifecycleOptions = BillLifecycleClientOptions & {
|
|
443
|
+
/** Initial bill snapshot used when no existing `billId` is supplied. */
|
|
444
|
+
create?: BrowserBillCreateInput;
|
|
411
445
|
refreshInterval?: number;
|
|
412
446
|
enabled?: boolean;
|
|
413
447
|
initialData?: BillLifecycleData | null;
|
|
414
|
-
|
|
448
|
+
onBillCreated?: (billId: string, data: BillLifecycleData) => void | Promise<void>;
|
|
449
|
+
onBillIdChange?: (billId: string, previousBillId: string | null) => void | Promise<void>;
|
|
415
450
|
};
|
|
416
451
|
type UseBillLifecycleResult = {
|
|
417
|
-
billId: string;
|
|
452
|
+
billId: string | null;
|
|
418
453
|
data: BillLifecycleData | null;
|
|
419
454
|
error: Error | null;
|
|
420
455
|
isLoading: boolean;
|
|
@@ -434,7 +469,7 @@ type UseBillLifecycleResult = {
|
|
|
434
469
|
submitSecondReview: BillLifecycleClient["submitSecondReview"];
|
|
435
470
|
startCorrection: () => Promise<BillLifecycleData>;
|
|
436
471
|
};
|
|
437
|
-
declare function useBillLifecycle({ billId: providedBillId, sessionEndpoint, getSession, apiBaseUrl, refreshInterval, enabled, initialData, onBillIdChange, fetch: fetchOverride, }: UseBillLifecycleOptions): UseBillLifecycleResult;
|
|
472
|
+
declare function useBillLifecycle({ billId: providedBillId, create, sessionEndpoint, getSession, apiBaseUrl, refreshInterval, enabled, initialData, onBillCreated, onBillIdChange, fetch: fetchOverride, }: UseBillLifecycleOptions): UseBillLifecycleResult;
|
|
438
473
|
type ConnectedBillLifecycleProps = UseBillLifecycleOptions & {
|
|
439
474
|
appearance?: MindBillReactAppearance;
|
|
440
475
|
features?: BillReviewFeatures;
|
|
@@ -458,4 +493,4 @@ type MindBillWidgetProps = {
|
|
|
458
493
|
declare function MindBillBillTimeline(props: MindBillWidgetProps): ReactElement;
|
|
459
494
|
declare function MindBillBillReview(props: MindBillWidgetProps): ReactElement;
|
|
460
495
|
|
|
461
|
-
export { type BillReviewAttachment, type BillReviewBillingProvider, type BillReviewClinician, type BillReviewData, type BillReviewDocumentType, type BillReviewDraft, type BillReviewFeatures, BillReviewForm, type BillReviewFormProps, type BillReviewLineItem, type BillReviewLocation, type BillReviewPayer, type BillReviewSaveInput, type BillStatusAction, type BillStatusClient, type BillStatusClientOptions, type BillStatusData, type BillStatusSession, type BillStatusSessionProvider, type BillStatusSessionRequest, BillStatusSummary, type BillStatusSummaryProps, type BillSubmissionRoute, ConnectedBillLifecycle, type ConnectedBillLifecycleProps, ConnectedBillStatus, type ConnectedBillStatusProps, MindBillBillReview, MindBillBillTimeline, type MindBillReactAppearance, type MindBillThemePreset, type MindBillWidgetProps, type UseBillLifecycleOptions, type UseBillLifecycleResult, type UseBillStatusOptions, type UseBillStatusResult, buildBillReviewSaveInput, createBillStatusClient, ensureTrailingProcedureLine, mindBillAppearanceStyle, mindBillThemePresets, resolveMindBillAppearance, useBillLifecycle, useBillStatus };
|
|
496
|
+
export { type BillActivityEvent, BillActivityTimeline, type BillActivityTimelineProps, BillLifecycleActions, type BillLifecycleActionsProps, type BillReviewAttachment, type BillReviewBillingProvider, type BillReviewClinician, type BillReviewData, type BillReviewDocumentType, type BillReviewDraft, type BillReviewFeatures, BillReviewForm, type BillReviewFormProps, type BillReviewLineItem, type BillReviewLocation, type BillReviewPayer, type BillReviewSaveInput, type BillStatusAction, type BillStatusClient, type BillStatusClientOptions, type BillStatusData, type BillStatusSession, type BillStatusSessionProvider, type BillStatusSessionRequest, BillStatusSummary, type BillStatusSummaryProps, type BillSubmissionRoute, ConnectedBillLifecycle, type ConnectedBillLifecycleProps, ConnectedBillStatus, type ConnectedBillStatusProps, MindBillBillReview, MindBillBillTimeline, type MindBillReactAppearance, type MindBillThemePreset, type MindBillWidgetProps, type UseBillLifecycleOptions, type UseBillLifecycleResult, type UseBillStatusOptions, type UseBillStatusResult, billActivityEventLabel, buildBillReviewSaveInput, createBillStatusClient, ensureTrailingProcedureLine, mindBillAppearanceStyle, mindBillThemePresets, resolveMindBillAppearance, useBillLifecycle, useBillStatus, visibleBillLifecycleActions };
|