@mindbill/browser 0.4.0 → 0.6.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 CHANGED
@@ -8,19 +8,41 @@ the Partner API key never reaches the browser.
8
8
  import { createBillLifecycleClient } from "@mindbill/browser";
9
9
 
10
10
  const billing = createBillLifecycleClient({
11
+ billId: "bill_123",
11
12
  sessionEndpoint: "/api/mindbill/session",
12
13
  });
13
14
 
14
- const { billId, data } = await billing.createBill(knownBillValues);
15
+ const data = await billing.getLifecycle();
16
+ const packet = await billing.getPacket();
15
17
  ```
16
18
 
17
- Review mutations are normalized against the v2 write contract automatically.
18
- Read-only snapshot metadata returned for rendering is never sent back on save,
19
- so the same client is safe to use from React, Angular, or plain JavaScript.
19
+ The browser client operates only on an already-submitted bill. It loads the
20
+ immutable snapshot, server-owned activity history, current lifecycle actions,
21
+ EORs, and the complete submission packet. It can execute only actions authorized
22
+ by the server, including Second Bill Review, payment posting, close, and reopen.
23
+ Bill creation, document selection, review, and the atomic submission stay on the partner server.
24
+ The public lifecycle begins at `submitted`, then advances through `accepted`,
25
+ `processed`, and `closed`; it never exposes draft or queued states. The same
26
+ lifecycle client is safe to use from React, Angular, or plain JavaScript.
20
27
 
21
- Pass `billId` when opening an existing bill. The same organization/user session
22
- can create and work with any bill allowed by its permissions; an optional
23
- `resource: { billId }` restriction is available for unusually narrow access.
28
+ Pre-submission components can query canonical routing reference data without
29
+ inventing a draft bill:
30
+
31
+ ```ts
32
+ import { createBillReferenceClient } from "@mindbill/browser";
33
+
34
+ const references = createBillReferenceClient({
35
+ sessionEndpoint: "/api/mindbill/session",
36
+ });
37
+
38
+ const payers = await references.searchClaimsAdministrators("Zurich", "claim-123");
39
+ ```
40
+
41
+ This client exposes reference-data operations only. It never creates or mutates
42
+ a bill; the first persisted bill remains the submitted immutable snapshot.
43
+
44
+ Pass `billId` for the submitted bill. An optional `resource: { billId }`
45
+ restriction makes the session usable for only that bill.
24
46
 
25
47
  The session endpoint is the only required partner-server integration. See the
26
48
  [10-minute quickstart](https://docs.mindbill.org/quickstart).
package/dist/index.d.ts CHANGED
@@ -112,6 +112,13 @@ type BillReviewData = {
112
112
  middleName?: string;
113
113
  lastName?: string;
114
114
  dob?: string;
115
+ phone?: string;
116
+ address?: {
117
+ line1?: string;
118
+ city?: string;
119
+ state?: string;
120
+ postalCode?: string;
121
+ };
115
122
  };
116
123
  injury: {
117
124
  claimNumber?: string;
@@ -122,6 +129,8 @@ type BillReviewData = {
122
129
  adjNumber?: string;
123
130
  claimsAdminId?: string;
124
131
  claimsAdminName?: string;
132
+ injuryDescription?: string;
133
+ diagnosisCodes?: string[];
125
134
  claimPatternStatus?: BillReviewClaimPatternStatus;
126
135
  };
127
136
  };
@@ -203,7 +212,7 @@ type SubmitBillInput = {
203
212
  subject?: string;
204
213
  note?: string;
205
214
  };
206
- type BillLifecycleActionId = "edit_and_submit" | "correct_and_resubmit" | "second_review" | "independent_bill_review" | "view_eor" | "post_payment" | "close";
215
+ type BillLifecycleActionId = "second_review" | "independent_bill_review" | "view_eor" | "post_payment" | "close" | "reopen";
207
216
  type BillLifecycleAction = {
208
217
  id: BillLifecycleActionId;
209
218
  label: string;
@@ -222,6 +231,7 @@ type BillActivityRecord = {
222
231
  id: string;
223
232
  type: string;
224
233
  createdAt: string;
234
+ title?: string;
225
235
  description: string;
226
236
  actor: string | null;
227
237
  delivery: BillSubmissionRoute | null;
@@ -282,6 +292,9 @@ type BillLifecycleSessionProvider = (request: BillLifecycleSessionRequest) => Pr
282
292
  type CloseBillInput = {
283
293
  reason: string;
284
294
  };
295
+ type ReopenBillInput = {
296
+ reason: string;
297
+ };
285
298
  type PostBillPaymentInput = {
286
299
  amount: number;
287
300
  method: "check" | "eft";
@@ -312,7 +325,7 @@ type BrowserBillCreateInput = {
312
325
  firstName: string;
313
326
  middleName?: string;
314
327
  lastName: string;
315
- dateOfBirth?: string;
328
+ dateOfBirth: string;
316
329
  ssn?: string;
317
330
  gender?: "M" | "F" | "X";
318
331
  phone?: string;
@@ -371,38 +384,41 @@ type BrowserBillCreateInput = {
371
384
  }>;
372
385
  };
373
386
  type BillLifecycleClientOptions = {
374
- /** Open an existing bill. Omit this to create one with `createBill`. */
375
- billId?: string;
387
+ /** ID of an already-submitted bill. Bills are created only by the atomic server API. */
388
+ billId: string;
376
389
  sessionEndpoint?: string | undefined;
377
390
  getSession?: BillLifecycleSessionProvider | undefined;
378
391
  apiBaseUrl?: string | undefined;
379
392
  fetch?: typeof globalThis.fetch | undefined;
380
393
  };
394
+ /** Browser-session options for pre-submission reference-data lookups. */
395
+ type BillReferenceClientOptions = Omit<BillLifecycleClientOptions, "billId">;
396
+ type BillReferenceClient = {
397
+ searchClaimsAdministrators: (query: string, claimNumber?: string) => Promise<BillReviewPayer[]>;
398
+ clearSession: () => void;
399
+ };
381
400
  type BillLifecycleClient = {
382
- getBillId: () => string | null;
383
- createBill: (input: BrowserBillCreateInput) => Promise<{
384
- billId: string;
385
- data: BillLifecycleData;
386
- }>;
401
+ getBillId: () => string;
387
402
  getLifecycle: (signal?: AbortSignal) => Promise<BillLifecycleData>;
388
403
  searchClaimsAdministrators: (query: string, claimNumber?: string) => Promise<BillReviewPayer[]>;
389
404
  getDeliveryOptions: () => Promise<BillDeliveryOptions>;
390
- saveReview: (input: BillReviewSaveInput) => Promise<BillLifecycleData>;
391
- submitBill: (input: BillReviewSaveInput, submission: SubmitBillInput) => Promise<BillLifecycleData>;
392
- addAttachment: (file: File, documentType: BillReviewDocumentType, description?: string) => Promise<BillLifecycleData>;
393
- removeAttachment: (attachmentId: string) => Promise<BillLifecycleData>;
394
405
  getAttachment: (attachmentId: string) => Promise<Blob>;
395
406
  getEor: (documentId: string) => Promise<Blob>;
407
+ getPacket: () => Promise<Blob>;
396
408
  closeBill: (input: CloseBillInput) => Promise<BillLifecycleData>;
409
+ reopenBill: (input: ReopenBillInput) => Promise<BillLifecycleData>;
397
410
  postPayment: (input: PostBillPaymentInput) => Promise<BillLifecycleData>;
398
411
  submitSecondReview: (input: SubmitSecondReviewInput) => Promise<BillLifecycleData>;
399
- startCorrection: () => Promise<{
400
- replacementBillId: string;
401
- data: BillLifecycleData;
402
- }>;
403
412
  clearSession: () => void;
404
413
  };
405
- /** Browser-safe, framework-neutral client for the complete bill lifecycle. */
414
+ /** Browser-safe, framework-neutral client for an already-submitted bill. */
406
415
  declare function createBillLifecycleClient({ billId, sessionEndpoint, getSession, apiBaseUrl, fetch: fetchOverride, }: BillLifecycleClientOptions): BillLifecycleClient;
416
+ /**
417
+ * Browser-safe client for reference data needed before a bill exists.
418
+ *
419
+ * Partners can pass the same short-lived session provider used by the submitted-bill
420
+ * lifecycle without inventing a draft bill or exposing payer directory credentials.
421
+ */
422
+ declare function createBillReferenceClient(options?: BillReferenceClientOptions): BillReferenceClient;
407
423
 
408
- export { type BillActivityRecord, type BillDeliveryOption, type BillDeliveryOptions, type BillEorDocument, type BillLifecycleAction, type BillLifecycleActionId, type BillLifecycleClient, type BillLifecycleClientOptions, type BillLifecycleData, type BillLifecycleDelivery, type BillLifecycleSession, type BillLifecycleSessionProvider, type BillLifecycleSessionRequest, type BillPaymentRecord, type BillRemittanceSummary, type BillReviewAttachment, type BillReviewBillingProvider, type BillReviewClaimPatternStatus, type BillReviewClinician, type BillReviewData, type BillReviewDocumentType, type BillReviewFeatures, type BillReviewLineItem, type BillReviewLocation, type BillReviewPayer, type BillReviewSaveInput, type BillSubmissionRoute, type BrowserBillAddress, type BrowserBillCreateInput, type CloseBillInput, DEFAULT_API_BASE_URL, DEFAULT_SESSION_ENDPOINT, type PostBillPaymentInput, type SubmitBillInput, type SubmitSecondReviewInput, createBillLifecycleClient, sanitizeBillReviewSaveInput };
424
+ export { type BillActivityRecord, type BillDeliveryOption, type BillDeliveryOptions, type BillEorDocument, type BillLifecycleAction, type BillLifecycleActionId, type BillLifecycleClient, type BillLifecycleClientOptions, type BillLifecycleData, type BillLifecycleDelivery, type BillLifecycleSession, type BillLifecycleSessionProvider, type BillLifecycleSessionRequest, type BillPaymentRecord, type BillReferenceClient, type BillReferenceClientOptions, type BillRemittanceSummary, type BillReviewAttachment, type BillReviewBillingProvider, type BillReviewClaimPatternStatus, type BillReviewClinician, type BillReviewData, type BillReviewDocumentType, type BillReviewFeatures, type BillReviewLineItem, type BillReviewLocation, type BillReviewPayer, type BillReviewSaveInput, type BillSubmissionRoute, type BrowserBillAddress, type BrowserBillCreateInput, type CloseBillInput, DEFAULT_API_BASE_URL, DEFAULT_SESSION_ENDPOINT, type PostBillPaymentInput, type ReopenBillInput, type SubmitBillInput, type SubmitSecondReviewInput, createBillLifecycleClient, createBillReferenceClient, sanitizeBillReviewSaveInput };
package/dist/index.js CHANGED
@@ -149,8 +149,8 @@ function createBillLifecycleClient({
149
149
  if (typeof fetcher !== "function") throw new Error("A Fetch API implementation is required.");
150
150
  let session = null;
151
151
  let sessionRequest = null;
152
- let currentBillId = billId?.trim() || null;
153
- let createRequest = null;
152
+ const currentBillId = billId.trim();
153
+ if (!currentBillId) throw new Error("billId is required for the submitted-bill lifecycle client.");
154
154
  const mintSession = async (signal, force = false) => {
155
155
  if (!force && isSessionFresh(session)) return session;
156
156
  if (!force && sessionRequest) return sessionRequest;
@@ -192,13 +192,7 @@ function createBillLifecycleClient({
192
192
  }
193
193
  return response;
194
194
  };
195
- const requireBillId = () => {
196
- if (!currentBillId) {
197
- throw new Error("No bill is open. Pass billId or create a bill before using this operation.");
198
- }
199
- return currentBillId;
200
- };
201
- const billPath = (suffix = "") => `/partner/v2/browser/bills/${encodeURIComponent(requireBillId())}${suffix}`;
195
+ const billPath = (suffix = "") => `/partner/v2/browser/bills/${encodeURIComponent(currentBillId)}${suffix}`;
202
196
  const loadLifecycle = async (signal) => {
203
197
  const response = await request(billPath("/lifecycle"), {}, signal);
204
198
  if (!response.ok) throw await responseError(response, "Bill lifecycle could not be loaded.");
@@ -255,38 +249,10 @@ function createBillLifecycleClient({
255
249
  const body = await response.json();
256
250
  return normalizeLifecycle(body.data);
257
251
  };
258
- const saveReview = async (input) => {
259
- await mutation(billPath(), {
260
- method: "PATCH",
261
- headers: { "content-type": "application/json" },
262
- body: JSON.stringify(sanitizeBillReviewSaveInput(input))
263
- }, "Bill changes could not be saved.");
264
- return loadLifecycle();
265
- };
266
252
  return {
267
253
  getBillId() {
268
254
  return currentBillId;
269
255
  },
270
- async createBill(input) {
271
- if (currentBillId) throw new Error("A bill is already open in this lifecycle client.");
272
- if (createRequest) return createRequest;
273
- const pending = (async () => {
274
- const response = await mutation("/partner/v2/browser/bills", {
275
- method: "POST",
276
- headers: { "content-type": "application/json" },
277
- body: JSON.stringify(input)
278
- }, "Bill could not be created.");
279
- const body = await response.json();
280
- const nextBillId = typeof body.id === "string" ? body.id : typeof body.data?.id === "string" ? body.data.id : null;
281
- if (!nextBillId) throw new Error("The billing service did not return the new bill ID.");
282
- currentBillId = nextBillId;
283
- return { billId: nextBillId, data: await loadLifecycle() };
284
- })().finally(() => {
285
- if (createRequest === pending) createRequest = null;
286
- });
287
- createRequest = pending;
288
- return pending;
289
- },
290
256
  clearSession() {
291
257
  session = null;
292
258
  sessionRequest = null;
@@ -299,28 +265,6 @@ function createBillLifecycleClient({
299
265
  const body = await response.json();
300
266
  return normalizeDeliveryOptions(body.data ?? body);
301
267
  },
302
- saveReview,
303
- async submitBill(input, submission) {
304
- await saveReview(input);
305
- await mutation(billPath("/submissions"), {
306
- method: "POST",
307
- headers: { "content-type": "application/json" },
308
- body: JSON.stringify(submission)
309
- }, "Bill could not be submitted.");
310
- return loadLifecycle();
311
- },
312
- async addAttachment(file, documentType, description) {
313
- const body = new FormData();
314
- body.set("file", file);
315
- body.set("documentType", documentType);
316
- if (description) body.set("description", description);
317
- await mutation(billPath("/documents"), { method: "POST", body }, "Document could not be attached.");
318
- return loadLifecycle();
319
- },
320
- async removeAttachment(attachmentId) {
321
- await mutation(billPath(`/documents/${encodeURIComponent(attachmentId)}`), { method: "DELETE" }, "Document could not be removed.");
322
- return loadLifecycle();
323
- },
324
268
  async getAttachment(attachmentId) {
325
269
  const response = await request(billPath(`/documents/${encodeURIComponent(attachmentId)}`));
326
270
  if (!response.ok) throw await responseError(response, "Document could not be opened.");
@@ -331,32 +275,40 @@ function createBillLifecycleClient({
331
275
  if (!response.ok) throw await responseError(response, "EOR could not be opened.");
332
276
  return response.blob();
333
277
  },
278
+ async getPacket() {
279
+ const response = await request(billPath("/packet"));
280
+ if (!response.ok) throw await responseError(response, "Submission packet could not be downloaded.");
281
+ return response.blob();
282
+ },
334
283
  closeBill(input) {
335
284
  return action({ action: "close", ...input }, "Bill could not be closed.");
336
285
  },
286
+ reopenBill(input) {
287
+ return action({ action: "reopen", ...input }, "Bill could not be reopened.");
288
+ },
337
289
  postPayment(input) {
338
290
  return action({ action: "post_payment", ...input, checkNumber: input.checkNumber ?? "" }, "Payment could not be posted.");
339
291
  },
340
292
  submitSecondReview(input) {
341
293
  return action({ action: "second_review", ...input }, "Second Review could not be submitted.");
342
- },
343
- async startCorrection() {
344
- const response = await mutation(billPath("/actions"), {
345
- method: "POST",
346
- headers: { "content-type": "application/json" },
347
- body: JSON.stringify({ action: "start_correction" })
348
- }, "Correction draft could not be created.");
349
- const body = await response.json();
350
- if (typeof body.replacementBillId !== "string") throw new Error("The billing service did not return the correction bill ID.");
351
- currentBillId = body.replacementBillId;
352
- return { replacementBillId: body.replacementBillId, data: normalizeLifecycle(body.data) };
353
294
  }
354
295
  };
355
296
  }
297
+ function createBillReferenceClient(options = {}) {
298
+ const lifecycle = createBillLifecycleClient({
299
+ ...options,
300
+ billId: "pre-submission-reference-data"
301
+ });
302
+ return {
303
+ searchClaimsAdministrators: lifecycle.searchClaimsAdministrators,
304
+ clearSession: lifecycle.clearSession
305
+ };
306
+ }
356
307
  export {
357
308
  DEFAULT_API_BASE_URL,
358
309
  DEFAULT_SESSION_ENDPOINT,
359
310
  createBillLifecycleClient,
311
+ createBillReferenceClient,
360
312
  sanitizeBillReviewSaveInput
361
313
  };
362
314
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export const DEFAULT_API_BASE_URL = \"https://app.mindbill.org\";\nexport const DEFAULT_SESSION_ENDPOINT = \"/api/mindbill/session\";\n\nexport type BillReviewDocumentType =\n | \"final_report\"\n | \"letter_of_attestation\"\n | \"proof_of_service\"\n | \"form_122\"\n | \"return_to_work_voucher\"\n | \"w9\"\n | \"medical_records\"\n | \"appeal\"\n | \"other\";\n\nexport type BillReviewBillingProvider = {\n name: string;\n taxId: string;\n npi: string;\n billType: \"Professional\" | \"Institutional\";\n phone?: string;\n billingStreet?: string;\n billingCity?: string;\n billingState?: string;\n billingZip?: string;\n};\n\nexport type BillReviewClinician = {\n name: string;\n specialty: string;\n npi: string;\n taxonomy?: string;\n licenseNumber?: string;\n licenseState?: string;\n signaturePng?: string;\n signatureKey?: string;\n isQME?: boolean;\n isAME?: boolean;\n email?: string;\n active?: boolean;\n};\n\nexport type BillReviewLocation = {\n billingProviderId?: string;\n name: string;\n nickname?: string;\n street: string;\n city: string;\n state: string;\n zip: string;\n county?: string;\n posCode?: string;\n isPrimary?: boolean;\n active?: boolean;\n};\n\nexport type BillReviewLineItem = {\n id?: string;\n code: string;\n modifiers: string[];\n units: number;\n charge: number;\n feeSchedule?: number;\n serviceDate?: string | null;\n serviceDateEnd?: string | null;\n diagnosisPointers?: number[];\n};\n\nexport type BillReviewAttachment = {\n id: string;\n filename: string;\n description?: string | null;\n documentType: string;\n reportType?: string | null;\n source?: string;\n addedAt?: string;\n contentUrl?: string;\n};\n\nexport type BillReviewPayer = {\n id: string;\n name: string;\n hasElectronic?: boolean;\n states?: string[];\n confidence?: \"high\" | \"medium\" | \"directory\";\n recommended?: boolean;\n signals?: Array<{\n kind: \"name\" | \"claim_number\";\n state: \"match\" | \"warning\";\n label: string;\n }>;\n};\n\nexport type BillReviewFeatures = {\n authorizationNumber?: boolean;\n serviceDateRange?: boolean;\n wcabNumber?: boolean;\n codingPresets?: boolean;\n};\n\nexport type BillReviewClaimPatternStatus = {\n state: \"match\" | \"warning\" | \"unknown\";\n label: string;\n detail?: string;\n suggestion?: string;\n};\n\nexport type BillReviewData = {\n bill: {\n id: string;\n billNumber: string | number;\n status: string;\n transmissionState?: string;\n billingMode: \"med_legal\" | \"professional\";\n dos: string;\n dosEnd?: string | null;\n authorizationNumber?: string | null;\n billingSnapshot?: {\n billingProvider?: BillReviewBillingProvider;\n renderingProvider?: BillReviewClinician;\n placeOfService?: BillReviewLocation;\n } | null;\n lineItems: BillReviewLineItem[];\n attachments: BillReviewAttachment[];\n totalCharge: number;\n totalPaid: number;\n balanceDue: number;\n };\n patient: {\n name: string;\n firstName?: string;\n middleName?: string;\n lastName?: string;\n dob?: string;\n };\n injury: {\n claimNumber?: string;\n employer?: string;\n doi?: string;\n injuryEndDate?: string;\n cumulativeTrauma?: boolean;\n adjNumber?: string;\n claimsAdminId?: string;\n claimsAdminName?: string;\n claimPatternStatus?: BillReviewClaimPatternStatus;\n };\n};\n\nexport type BillReviewSaveInput = {\n claimsAdminId: string;\n patientOverrides?: {\n firstName: string;\n middleName?: string;\n lastName: string;\n dob?: string;\n };\n injuryOverrides?: {\n claimNumber?: string;\n employer?: string;\n doi?: string;\n injuryEndDate?: string;\n cumulativeTrauma?: boolean;\n adjNumber?: string;\n };\n dos: string;\n dosEnd?: string | null;\n authorizationNumber?: string | null;\n billingProvider?: BillReviewBillingProvider;\n renderingProvider?: BillReviewClinician;\n placeOfService?: BillReviewLocation;\n lineItems: Array<{\n id?: string;\n code: string;\n modifiers: string[];\n units: number;\n charge?: number;\n serviceDate?: string | null;\n serviceDateEnd?: string | null;\n diagnosisPointers?: number[];\n }>;\n};\n\nfunction pickDefined(\n source: object,\n keys: readonly string[],\n): Record<string, unknown> {\n const record = source as Record<string, unknown>;\n return Object.fromEntries(\n keys.flatMap((key) => record[key] === undefined ? [] : [[key, record[key]]]),\n );\n}\n\n/**\n * Removes read-only snapshot metadata before a review mutation is sent.\n * Lifecycle reads can include display-only fields such as entity IDs; the v2\n * write contract accepts only the values that should be frozen onto the bill.\n */\nexport function sanitizeBillReviewSaveInput(\n input: BillReviewSaveInput,\n): BillReviewSaveInput {\n return {\n claimsAdminId: input.claimsAdminId,\n ...(input.patientOverrides ? {\n patientOverrides: pickDefined(input.patientOverrides, [\n \"firstName\", \"middleName\", \"lastName\", \"dob\",\n ]) as NonNullable<BillReviewSaveInput[\"patientOverrides\"]>,\n } : {}),\n ...(input.injuryOverrides ? {\n injuryOverrides: pickDefined(input.injuryOverrides, [\n \"claimNumber\", \"employer\", \"doi\", \"injuryEndDate\",\n \"cumulativeTrauma\", \"adjNumber\",\n ]) as NonNullable<BillReviewSaveInput[\"injuryOverrides\"]>,\n } : {}),\n dos: input.dos,\n ...(input.dosEnd !== undefined ? { dosEnd: input.dosEnd } : {}),\n ...(input.authorizationNumber !== undefined\n ? { authorizationNumber: input.authorizationNumber }\n : {}),\n ...(input.billingProvider ? {\n billingProvider: pickDefined(input.billingProvider, [\n \"name\", \"taxId\", \"npi\", \"billType\", \"phone\", \"billingStreet\",\n \"billingCity\", \"billingState\", \"billingZip\",\n ]) as BillReviewBillingProvider,\n } : {}),\n ...(input.renderingProvider ? {\n renderingProvider: pickDefined(input.renderingProvider, [\n \"name\", \"specialty\", \"npi\", \"taxonomy\", \"licenseNumber\",\n \"licenseState\", \"signaturePng\", \"signatureKey\", \"isQME\", \"isAME\",\n \"email\", \"active\",\n ]) as BillReviewClinician,\n } : {}),\n ...(input.placeOfService ? {\n placeOfService: pickDefined(input.placeOfService, [\n \"billingProviderId\", \"name\", \"nickname\", \"street\", \"city\", \"state\",\n \"zip\", \"county\", \"posCode\", \"isPrimary\", \"active\",\n ]) as BillReviewLocation,\n } : {}),\n lineItems: input.lineItems.map((line) => pickDefined(line, [\n \"id\", \"code\", \"modifiers\", \"units\", \"charge\", \"serviceDate\",\n \"serviceDateEnd\", \"diagnosisPointers\",\n ]) as BillReviewSaveInput[\"lineItems\"][number]),\n };\n}\n\nexport type BillSubmissionRoute = \"ebill\" | \"fax\" | \"mail\" | \"email\";\nexport type BillDeliveryOption = {\n route: BillSubmissionRoute;\n label: string;\n detail: string;\n fallback: boolean;\n confidence: string;\n payerName: string;\n target?: string;\n chKey?: string;\n payerId?: string;\n printAndMail?: boolean;\n costUsd?: number;\n};\nexport type BillDeliveryOptions = {\n payerName: string;\n recommended: BillDeliveryOption;\n options: BillDeliveryOption[];\n contacts: {\n faxNumber?: string | null;\n claimsEmail?: string | null;\n portalUrl?: string | null;\n mailingAddress?: string | null;\n adjusterName?: string | null;\n adjusterPhone?: string | null;\n adjusterEmail?: string | null;\n };\n};\nexport type SubmitBillInput = {\n route: BillSubmissionRoute;\n destination?: {\n faxNumber?: string;\n email?: string;\n mailingAddress?: string;\n };\n attention?: string;\n subject?: string;\n note?: string;\n};\nexport type BillLifecycleActionId =\n | \"edit_and_submit\"\n | \"correct_and_resubmit\"\n | \"second_review\"\n | \"independent_bill_review\"\n | \"view_eor\"\n | \"post_payment\"\n | \"close\";\n\nexport type BillLifecycleAction = {\n id: BillLifecycleActionId;\n label: string;\n enabled: boolean;\n primary?: boolean;\n reason?: string;\n};\n\nexport type BillEorDocument = {\n id: string;\n filename: string;\n description: string | null;\n addedAt: string;\n contentUrl: string;\n};\n\nexport type BillActivityRecord = {\n id: string;\n type: string;\n createdAt: string;\n description: string;\n actor: string | null;\n delivery: BillSubmissionRoute | null;\n amount: number | null;\n accepted: boolean | null;\n stcCategory: string | null;\n};\n\nexport type BillPaymentRecord = {\n id: string;\n method: \"check\" | \"eft\";\n checkNumber: string;\n status: string | null;\n depositDate: string | null;\n checkReceived: boolean | null;\n receivedDate: string | null;\n amount: number;\n feeAmount: number | null;\n feeReason: string | null;\n source: \"paper\" | \"835\" | \"portal\";\n postedAt: string;\n updatedAt: string | null;\n note: string | null;\n};\n\nexport type BillRemittanceSummary = {\n payerReportedPaid: number | null;\n totalPaid: number;\n balanceDue: number;\n denialReason: string | null;\n};\n\nexport type BillLifecycleDelivery = {\n payerName: string;\n contacts: BillDeliveryOptions[\"contacts\"];\n};\n\nexport type BillLifecycleData = BillReviewData & {\n lifecycle: {\n state: string;\n nativeStatus: string;\n submittedAt?: string | null;\n agingDays?: number | null;\n updatedAt?: string | null;\n actions: BillLifecycleAction[];\n };\n eors: BillEorDocument[];\n activity: BillActivityRecord[];\n payments: BillPaymentRecord[];\n remittance: BillRemittanceSummary;\n delivery: BillLifecycleDelivery;\n};\n\nexport type BillLifecycleSession = {\n token: string;\n expiresAt?: string;\n apiBaseUrl?: string;\n};\n\nexport type BillLifecycleSessionRequest = {\n signal: AbortSignal;\n};\n\nexport type BillLifecycleSessionProvider = (\n request: BillLifecycleSessionRequest,\n) => Promise<BillLifecycleSession>;\n\nexport type CloseBillInput = { reason: string };\nexport type PostBillPaymentInput = {\n amount: number;\n method: \"check\" | \"eft\";\n checkNumber?: string;\n depositDate: string;\n note?: string;\n};\nexport type SubmitSecondReviewInput = {\n reason: string;\n payerClaimControlNumber: string;\n disputedAmount: number | undefined;\n attachmentIds: string[];\n route: BillSubmissionRoute;\n};\n\nexport type BrowserBillAddress = {\n line1: string;\n city: string;\n state: string;\n postalCode: string;\n};\n\n/** Complete bill snapshot accepted by the browser create endpoint. */\nexport type BrowserBillCreateInput = {\n externalId?: string;\n billingMode?: \"med_legal\" | \"professional\";\n patient: {\n id?: string;\n externalId?: string;\n firstName: string;\n middleName?: string;\n lastName: string;\n dateOfBirth?: string;\n ssn?: string;\n gender?: \"M\" | \"F\" | \"X\";\n phone?: string;\n address: BrowserBillAddress;\n };\n claim: {\n id?: string;\n externalId?: string;\n claimNumber: string;\n adjNumber?: string;\n employer?: string;\n dateOfInjury?: string;\n injuryState?: string;\n description?: string;\n claimsAdministrator?: { id?: string; name: string };\n };\n service: { date?: string; endDate?: string | null; authorizationNumber?: string | null };\n billingProvider?: { name?: string; taxId?: string; npi?: string; phone?: string; address?: BrowserBillAddress };\n renderingProvider?: {\n name?: string;\n specialty?: string;\n npi?: string;\n taxonomy?: string;\n licenseNumber?: string;\n licenseState?: string;\n isQme?: boolean;\n isAme?: boolean;\n };\n serviceLocation?: { name?: string; address?: BrowserBillAddress; placeOfServiceCode?: string };\n diagnoses?: string[];\n serviceLines?: Array<{\n code: string;\n modifiers?: string[];\n units?: number;\n charge?: number;\n serviceDate?: string;\n serviceDateEnd?: string;\n diagnosisPointers?: number[];\n }>;\n};\n\nexport type BillLifecycleClientOptions = {\n /** Open an existing bill. Omit this to create one with `createBill`. */\n billId?: string;\n sessionEndpoint?: string | undefined;\n getSession?: BillLifecycleSessionProvider | undefined;\n apiBaseUrl?: string | undefined;\n fetch?: typeof globalThis.fetch | undefined;\n};\n\nexport type BillLifecycleClient = {\n getBillId: () => string | null;\n createBill: (input: BrowserBillCreateInput) => Promise<{ billId: string; data: BillLifecycleData }>;\n getLifecycle: (signal?: AbortSignal) => Promise<BillLifecycleData>;\n searchClaimsAdministrators: (query: string, claimNumber?: string) => Promise<BillReviewPayer[]>;\n getDeliveryOptions: () => Promise<BillDeliveryOptions>;\n saveReview: (input: BillReviewSaveInput) => Promise<BillLifecycleData>;\n submitBill: (input: BillReviewSaveInput, submission: SubmitBillInput) => Promise<BillLifecycleData>;\n addAttachment: (file: File, documentType: BillReviewDocumentType, description?: string) => Promise<BillLifecycleData>;\n removeAttachment: (attachmentId: string) => Promise<BillLifecycleData>;\n getAttachment: (attachmentId: string) => Promise<Blob>;\n getEor: (documentId: string) => Promise<Blob>;\n closeBill: (input: CloseBillInput) => Promise<BillLifecycleData>;\n postPayment: (input: PostBillPaymentInput) => Promise<BillLifecycleData>;\n submitSecondReview: (input: SubmitSecondReviewInput) => Promise<BillLifecycleData>;\n startCorrection: () => Promise<{ replacementBillId: string; data: BillLifecycleData }>;\n clearSession: () => void;\n};\n\nasync function responseError(response: Response, fallback: string): Promise<Error> {\n const body: unknown = await response.json().catch(() => null);\n const detail = body && typeof body === \"object\"\n ? (body as { detail?: unknown; message?: unknown; error?: unknown }).detail\n ?? (body as { message?: unknown }).message\n ?? (body as { error?: unknown }).error\n : null;\n return new Error(typeof detail === \"string\" ? detail : fallback);\n}\n\nfunction isSessionFresh(session: BillLifecycleSession | null): boolean {\n if (!session) return false;\n if (!session.expiresAt) return true;\n const expiresAt = new Date(session.expiresAt).getTime();\n return Number.isFinite(expiresAt) && expiresAt > Date.now() + 30_000;\n}\n\nfunction normalizeSession(value: unknown): BillLifecycleSession {\n if (!value || typeof value !== \"object\") {\n throw new Error(\"The billing session endpoint returned an invalid response.\");\n }\n const candidate = value as { token?: unknown; expiresAt?: unknown; apiBaseUrl?: unknown; session?: unknown; data?: unknown };\n const nested = candidate.session ?? candidate.data;\n const session = nested && typeof nested === \"object\" ? nested as typeof candidate : candidate;\n if (typeof session.token !== \"string\" || session.token.length < 8) {\n throw new Error(\"The billing session endpoint did not return a browser session token.\");\n }\n return {\n token: session.token,\n ...(typeof session.expiresAt === \"string\" ? { expiresAt: session.expiresAt } : {}),\n ...(typeof session.apiBaseUrl === \"string\" ? { apiBaseUrl: session.apiBaseUrl } : {}),\n };\n}\n\nfunction normalizeLifecycle(value: unknown): BillLifecycleData {\n if (!value || typeof value !== \"object\") {\n throw new Error(\"The billing service returned an invalid bill lifecycle.\");\n }\n const data = value as Partial<BillLifecycleData>;\n if (\n !data.bill\n || !data.patient\n || !data.injury\n || !data.lifecycle\n || !Array.isArray(data.lifecycle.actions)\n || !Array.isArray(data.eors)\n || !Array.isArray(data.activity)\n || !Array.isArray(data.payments)\n || !data.remittance\n || typeof data.remittance !== \"object\"\n || !data.delivery\n || typeof data.delivery !== \"object\"\n || !data.delivery.contacts\n || typeof data.delivery.contacts !== \"object\"\n ) {\n throw new Error(\"The billing service returned an invalid bill lifecycle.\");\n }\n return data as BillLifecycleData;\n}\n\nfunction normalizeDeliveryOptions(value: unknown): BillDeliveryOptions {\n if (!value || typeof value !== \"object\") {\n throw new Error(\"The billing service returned invalid delivery options.\");\n }\n const data = value as Partial<BillDeliveryOptions>;\n if (\n typeof data.payerName !== \"string\"\n || !data.recommended\n || typeof data.recommended !== \"object\"\n || ![\"ebill\", \"fax\", \"mail\", \"email\"].includes(data.recommended.route ?? \"\")\n || !Array.isArray(data.options)\n || !data.contacts\n ) {\n throw new Error(\"The billing service returned invalid delivery options.\");\n }\n return data as BillDeliveryOptions;\n}\n\nfunction idempotencyKey(): string {\n if (typeof globalThis.crypto?.randomUUID === \"function\") return globalThis.crypto.randomUUID();\n return `mb-${Date.now()}-${Math.random().toString(36).slice(2)}`;\n}\n\n/** Browser-safe, framework-neutral client for the complete bill lifecycle. */\nexport function createBillLifecycleClient({\n billId,\n sessionEndpoint = DEFAULT_SESSION_ENDPOINT,\n getSession,\n apiBaseUrl = DEFAULT_API_BASE_URL,\n fetch: fetchOverride,\n}: BillLifecycleClientOptions): BillLifecycleClient {\n const fetcher = fetchOverride ?? globalThis.fetch;\n if (typeof fetcher !== \"function\") throw new Error(\"A Fetch API implementation is required.\");\n let session: BillLifecycleSession | null = null;\n let sessionRequest: Promise<BillLifecycleSession> | null = null;\n let currentBillId = billId?.trim() || null;\n let createRequest: Promise<{ billId: string; data: BillLifecycleData }> | null = null;\n\n const mintSession = async (signal: AbortSignal, force = false): Promise<BillLifecycleSession> => {\n if (!force && isSessionFresh(session)) return session as BillLifecycleSession;\n if (!force && sessionRequest) return sessionRequest;\n const pending = getSession\n ? getSession({ signal })\n : fetcher(sessionEndpoint, {\n method: \"POST\",\n credentials: \"same-origin\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({}),\n signal,\n }).then(async (response) => {\n if (!response.ok) throw await responseError(response, \"The billing session could not be created.\");\n return response.json();\n });\n const request = Promise.resolve(pending).then(normalizeSession).then((nextSession) => {\n session = nextSession;\n return nextSession;\n }).finally(() => {\n if (sessionRequest === request) sessionRequest = null;\n });\n sessionRequest = request;\n return request;\n };\n\n const request = async (path: string, init: RequestInit = {}, providedSignal?: AbortSignal): Promise<Response> => {\n const controller = providedSignal ? null : new AbortController();\n const signal = providedSignal ?? controller?.signal;\n if (!signal) throw new Error(\"An AbortSignal could not be created.\");\n let browserSession = await mintSession(signal);\n const perform = (current: BillLifecycleSession) => {\n const base = (current.apiBaseUrl ?? apiBaseUrl).replace(/\\/$/, \"\");\n const headers = new Headers(init.headers);\n headers.set(\"authorization\", `Bearer ${current.token}`);\n return fetcher(`${base}${path}`, { ...init, headers, signal });\n };\n let response = await perform(browserSession);\n if (response.status === 401) {\n session = null;\n browserSession = await mintSession(signal, true);\n response = await perform(browserSession);\n }\n return response;\n };\n\n const requireBillId = (): string => {\n if (!currentBillId) {\n throw new Error(\"No bill is open. Pass billId or create a bill before using this operation.\");\n }\n return currentBillId;\n };\n const billPath = (suffix = \"\"): string =>\n `/partner/v2/browser/bills/${encodeURIComponent(requireBillId())}${suffix}`;\n\n const loadLifecycle = async (signal?: AbortSignal) => {\n const response = await request(billPath(\"/lifecycle\"), {}, signal);\n if (!response.ok) throw await responseError(response, \"Bill lifecycle could not be loaded.\");\n const body = await response.json() as { data?: unknown };\n return normalizeLifecycle(body.data);\n };\n\n const searchClaimsAdministrators = async (query: string, claimNumber?: string): Promise<BillReviewPayer[]> => {\n const params = new URLSearchParams();\n if (query.trim()) params.set(\"q\", query.trim());\n if (claimNumber?.trim()) params.set(\"claimNumber\", claimNumber.trim());\n const response = await request(`/partner/v2/browser/claims-administrators?${params.toString()}`);\n if (!response.ok) throw await responseError(response, \"Claims administrator search is unavailable.\");\n const body = await response.json() as { results?: unknown };\n if (!Array.isArray(body.results)) throw new Error(\"Claims administrator search returned an invalid response.\");\n return body.results.flatMap((value): BillReviewPayer[] => {\n if (!value || typeof value !== \"object\") return [];\n const payer = value as Partial<BillReviewPayer>;\n if (typeof payer.id !== \"string\" || typeof payer.name !== \"string\") return [];\n return [{\n id: payer.id,\n name: payer.name,\n ...(typeof payer.hasElectronic === \"boolean\" ? { hasElectronic: payer.hasElectronic } : {}),\n ...(Array.isArray(payer.states)\n ? { states: payer.states.filter((state): state is string => typeof state === \"string\") }\n : {}),\n ...([\"high\", \"medium\", \"directory\"].includes(payer.confidence ?? \"\")\n ? { confidence: payer.confidence as NonNullable<BillReviewPayer[\"confidence\"]> }\n : {}),\n ...(typeof payer.recommended === \"boolean\" ? { recommended: payer.recommended } : {}),\n ...(Array.isArray(payer.signals)\n ? {\n signals: payer.signals.flatMap((signal) => {\n if (!signal || typeof signal !== \"object\") return [];\n const candidate = signal as { kind?: unknown; state?: unknown; label?: unknown };\n if (\n ![\"name\", \"claim_number\"].includes(String(candidate.kind))\n || ![\"match\", \"warning\"].includes(String(candidate.state))\n || typeof candidate.label !== \"string\"\n ) return [];\n return [{\n kind: candidate.kind as \"name\" | \"claim_number\",\n state: candidate.state as \"match\" | \"warning\",\n label: candidate.label,\n }];\n }),\n }\n : {}),\n }];\n });\n };\n\n const mutation = async (path: string, init: RequestInit, fallback: string) => {\n const headers = new Headers(init.headers);\n headers.set(\"idempotency-key\", idempotencyKey());\n const response = await request(path, { ...init, headers });\n if (!response.ok) throw await responseError(response, fallback);\n return response;\n };\n const action = async (input: Record<string, unknown>, fallback: string): Promise<BillLifecycleData> => {\n const response = await mutation(billPath(\"/actions\"), {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(input),\n }, fallback);\n const body = await response.json() as { data?: unknown };\n return normalizeLifecycle(body.data);\n };\n const saveReview = async (input: BillReviewSaveInput): Promise<BillLifecycleData> => {\n await mutation(billPath(), {\n method: \"PATCH\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(sanitizeBillReviewSaveInput(input)),\n }, \"Bill changes could not be saved.\");\n return loadLifecycle();\n };\n\n return {\n getBillId() { return currentBillId; },\n async createBill(input) {\n if (currentBillId) throw new Error(\"A bill is already open in this lifecycle client.\");\n if (createRequest) return createRequest;\n const pending = (async () => {\n const response = await mutation(\"/partner/v2/browser/bills\", {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(input),\n }, \"Bill could not be created.\");\n const body = await response.json() as { id?: unknown; data?: { id?: unknown } };\n const nextBillId = typeof body.id === \"string\"\n ? body.id\n : typeof body.data?.id === \"string\" ? body.data.id : null;\n if (!nextBillId) throw new Error(\"The billing service did not return the new bill ID.\");\n currentBillId = nextBillId;\n return { billId: nextBillId, data: await loadLifecycle() };\n })().finally(() => {\n if (createRequest === pending) createRequest = null;\n });\n createRequest = pending;\n return pending;\n },\n clearSession() { session = null; sessionRequest = null; },\n getLifecycle: loadLifecycle,\n searchClaimsAdministrators,\n async getDeliveryOptions() {\n const response = await request(billPath(\"/delivery-options\"));\n if (!response.ok) throw await responseError(response, \"Delivery options could not be loaded.\");\n const body = await response.json() as { data?: unknown };\n return normalizeDeliveryOptions(body.data ?? body);\n },\n saveReview,\n async submitBill(input, submission) {\n await saveReview(input);\n await mutation(billPath(\"/submissions\"), {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(submission),\n }, \"Bill could not be submitted.\");\n return loadLifecycle();\n },\n async addAttachment(file, documentType, description) {\n const body = new FormData();\n body.set(\"file\", file);\n body.set(\"documentType\", documentType);\n if (description) body.set(\"description\", description);\n await mutation(billPath(\"/documents\"), { method: \"POST\", body }, \"Document could not be attached.\");\n return loadLifecycle();\n },\n async removeAttachment(attachmentId) {\n await mutation(billPath(`/documents/${encodeURIComponent(attachmentId)}`), { method: \"DELETE\" }, \"Document could not be removed.\");\n return loadLifecycle();\n },\n async getAttachment(attachmentId) {\n const response = await request(billPath(`/documents/${encodeURIComponent(attachmentId)}`));\n if (!response.ok) throw await responseError(response, \"Document could not be opened.\");\n return response.blob();\n },\n async getEor(documentId) {\n const response = await request(billPath(`/eors/${encodeURIComponent(documentId)}`));\n if (!response.ok) throw await responseError(response, \"EOR could not be opened.\");\n return response.blob();\n },\n closeBill(input) { return action({ action: \"close\", ...input }, \"Bill could not be closed.\"); },\n postPayment(input) { return action({ action: \"post_payment\", ...input, checkNumber: input.checkNumber ?? \"\" }, \"Payment could not be posted.\"); },\n submitSecondReview(input) { return action({ action: \"second_review\", ...input }, \"Second Review could not be submitted.\"); },\n async startCorrection() {\n const response = await mutation(billPath(\"/actions\"), {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ action: \"start_correction\" }),\n }, \"Correction draft could not be created.\");\n const body = await response.json() as { replacementBillId?: unknown; data?: unknown };\n if (typeof body.replacementBillId !== \"string\") throw new Error(\"The billing service did not return the correction bill ID.\");\n currentBillId = body.replacementBillId;\n return { replacementBillId: body.replacementBillId, data: normalizeLifecycle(body.data) };\n },\n };\n}\n"],"mappings":";AAAO,IAAM,uBAAuB;AAC7B,IAAM,2BAA2B;AAoLxC,SAAS,YACP,QACA,MACyB;AACzB,QAAM,SAAS;AACf,SAAO,OAAO;AAAA,IACZ,KAAK,QAAQ,CAAC,QAAQ,OAAO,GAAG,MAAM,SAAY,CAAC,IAAI,CAAC,CAAC,KAAK,OAAO,GAAG,CAAC,CAAC,CAAC;AAAA,EAC7E;AACF;AAOO,SAAS,4BACd,OACqB;AACrB,SAAO;AAAA,IACL,eAAe,MAAM;AAAA,IACrB,GAAI,MAAM,mBAAmB;AAAA,MAC3B,kBAAkB,YAAY,MAAM,kBAAkB;AAAA,QACpD;AAAA,QAAa;AAAA,QAAc;AAAA,QAAY;AAAA,MACzC,CAAC;AAAA,IACH,IAAI,CAAC;AAAA,IACL,GAAI,MAAM,kBAAkB;AAAA,MAC1B,iBAAiB,YAAY,MAAM,iBAAiB;AAAA,QAClD;AAAA,QAAe;AAAA,QAAY;AAAA,QAAO;AAAA,QAClC;AAAA,QAAoB;AAAA,MACtB,CAAC;AAAA,IACH,IAAI,CAAC;AAAA,IACL,KAAK,MAAM;AAAA,IACX,GAAI,MAAM,WAAW,SAAY,EAAE,QAAQ,MAAM,OAAO,IAAI,CAAC;AAAA,IAC7D,GAAI,MAAM,wBAAwB,SAC9B,EAAE,qBAAqB,MAAM,oBAAoB,IACjD,CAAC;AAAA,IACL,GAAI,MA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AAAA,IACvB;AAAA,IACA,UAAU,OAAO;AAAE,aAAO,OAAO,EAAE,QAAQ,SAAS,GAAG,MAAM,GAAG,2BAA2B;AAAA,IAAG;AAAA,IAC9F,YAAY,OAAO;AAAE,aAAO,OAAO,EAAE,QAAQ,gBAAgB,GAAG,OAAO,aAAa,MAAM,eAAe,GAAG,GAAG,8BAA8B;AAAA,IAAG;AAAA,IAChJ,mBAAmB,OAAO;AAAE,aAAO,OAAO,EAAE,QAAQ,iBAAiB,GAAG,MAAM,GAAG,uCAAuC;AAAA,IAAG;AAAA,IAC3H,MAAM,kBAAkB;AACtB,YAAM,WAAW,MAAM,SAAS,SAAS,UAAU,GAAG;AAAA,QACpD,QAAQ;AAAA,QACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,QAC9C,MAAM,KAAK,UAAU,EAAE,QAAQ,mBAAmB,CAAC;AAAA,MACrD,GAAG,wCAAwC;AAC3C,YAAM,OAAO,MAAM,SAAS,KAAK;AACjC,UAAI,OAAO,KAAK,sBAAsB,SAAU,OAAM,IAAI,MAAM,4DAA4D;AAC5H,sBAAgB,KAAK;AACrB,aAAO,EAAE,mBAAmB,KAAK,mBAAmB,MAAM,mBAAmB,KAAK,IAAI,EAAE;AAAA,IAC1F;AAAA,EACF;AACF;","names":["request"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export const DEFAULT_API_BASE_URL = \"https://app.mindbill.org\";\nexport const DEFAULT_SESSION_ENDPOINT = \"/api/mindbill/session\";\n\nexport type BillReviewDocumentType =\n | \"final_report\"\n | \"letter_of_attestation\"\n | \"proof_of_service\"\n | \"form_122\"\n | \"return_to_work_voucher\"\n | \"w9\"\n | \"medical_records\"\n | \"appeal\"\n | \"other\";\n\nexport type BillReviewBillingProvider = {\n name: string;\n taxId: string;\n npi: string;\n billType: \"Professional\" | \"Institutional\";\n phone?: string;\n billingStreet?: string;\n billingCity?: string;\n billingState?: string;\n billingZip?: string;\n};\n\nexport type BillReviewClinician = {\n name: string;\n specialty: string;\n npi: string;\n taxonomy?: string;\n licenseNumber?: string;\n licenseState?: string;\n signaturePng?: string;\n signatureKey?: string;\n isQME?: boolean;\n isAME?: boolean;\n email?: string;\n active?: boolean;\n};\n\nexport type BillReviewLocation = {\n billingProviderId?: string;\n name: string;\n nickname?: string;\n street: string;\n city: string;\n state: string;\n zip: string;\n county?: string;\n posCode?: string;\n isPrimary?: boolean;\n active?: boolean;\n};\n\nexport type BillReviewLineItem = {\n id?: string;\n code: string;\n modifiers: string[];\n units: number;\n charge: number;\n feeSchedule?: number;\n serviceDate?: string | null;\n serviceDateEnd?: string | null;\n diagnosisPointers?: number[];\n};\n\nexport type BillReviewAttachment = {\n id: string;\n filename: string;\n description?: string | null;\n documentType: string;\n reportType?: string | null;\n source?: string;\n addedAt?: string;\n contentUrl?: string;\n};\n\nexport type BillReviewPayer = {\n id: string;\n name: string;\n hasElectronic?: boolean;\n states?: string[];\n confidence?: \"high\" | \"medium\" | \"directory\";\n recommended?: boolean;\n signals?: Array<{\n kind: \"name\" | \"claim_number\";\n state: \"match\" | \"warning\";\n label: string;\n }>;\n};\n\nexport type BillReviewFeatures = {\n authorizationNumber?: boolean;\n serviceDateRange?: boolean;\n wcabNumber?: boolean;\n codingPresets?: boolean;\n};\n\nexport type BillReviewClaimPatternStatus = {\n state: \"match\" | \"warning\" | \"unknown\";\n label: string;\n detail?: string;\n suggestion?: string;\n};\n\nexport type BillReviewData = {\n bill: {\n id: string;\n billNumber: string | number;\n status: string;\n transmissionState?: string;\n billingMode: \"med_legal\" | \"professional\";\n dos: string;\n dosEnd?: string | null;\n authorizationNumber?: string | null;\n billingSnapshot?: {\n billingProvider?: BillReviewBillingProvider;\n renderingProvider?: BillReviewClinician;\n placeOfService?: BillReviewLocation;\n } | null;\n lineItems: BillReviewLineItem[];\n attachments: BillReviewAttachment[];\n totalCharge: number;\n totalPaid: number;\n balanceDue: number;\n };\n patient: {\n name: string;\n firstName?: string;\n middleName?: string;\n lastName?: string;\n dob?: string;\n phone?: string;\n address?: {\n line1?: string;\n city?: string;\n state?: string;\n postalCode?: string;\n };\n };\n injury: {\n claimNumber?: string;\n employer?: string;\n doi?: string;\n injuryEndDate?: string;\n cumulativeTrauma?: boolean;\n adjNumber?: string;\n claimsAdminId?: string;\n claimsAdminName?: string;\n injuryDescription?: string;\n diagnosisCodes?: string[];\n claimPatternStatus?: BillReviewClaimPatternStatus;\n };\n};\n\nexport type BillReviewSaveInput = {\n claimsAdminId: string;\n patientOverrides?: {\n firstName: string;\n middleName?: string;\n lastName: string;\n dob?: string;\n };\n injuryOverrides?: {\n claimNumber?: string;\n employer?: string;\n doi?: string;\n injuryEndDate?: string;\n cumulativeTrauma?: boolean;\n adjNumber?: string;\n };\n dos: string;\n dosEnd?: string | null;\n authorizationNumber?: string | null;\n billingProvider?: BillReviewBillingProvider;\n renderingProvider?: BillReviewClinician;\n placeOfService?: BillReviewLocation;\n lineItems: Array<{\n id?: string;\n code: string;\n modifiers: string[];\n units: number;\n charge?: number;\n serviceDate?: string | null;\n serviceDateEnd?: string | null;\n diagnosisPointers?: number[];\n }>;\n};\n\nfunction pickDefined(\n source: object,\n keys: readonly string[],\n): Record<string, unknown> {\n const record = source as Record<string, unknown>;\n return Object.fromEntries(\n keys.flatMap((key) => record[key] === undefined ? [] : [[key, record[key]]]),\n );\n}\n\n/**\n * Removes read-only snapshot metadata before a review mutation is sent.\n * Lifecycle reads can include display-only fields such as entity IDs; the v2\n * write contract accepts only the values that should be frozen onto the bill.\n */\nexport function sanitizeBillReviewSaveInput(\n input: BillReviewSaveInput,\n): BillReviewSaveInput {\n return {\n claimsAdminId: input.claimsAdminId,\n ...(input.patientOverrides ? {\n patientOverrides: pickDefined(input.patientOverrides, [\n \"firstName\", \"middleName\", \"lastName\", \"dob\",\n ]) as NonNullable<BillReviewSaveInput[\"patientOverrides\"]>,\n } : {}),\n ...(input.injuryOverrides ? {\n injuryOverrides: pickDefined(input.injuryOverrides, [\n \"claimNumber\", \"employer\", \"doi\", \"injuryEndDate\",\n \"cumulativeTrauma\", \"adjNumber\",\n ]) as NonNullable<BillReviewSaveInput[\"injuryOverrides\"]>,\n } : {}),\n dos: input.dos,\n ...(input.dosEnd !== undefined ? { dosEnd: input.dosEnd } : {}),\n ...(input.authorizationNumber !== undefined\n ? { authorizationNumber: input.authorizationNumber }\n : {}),\n ...(input.billingProvider ? {\n billingProvider: pickDefined(input.billingProvider, [\n \"name\", \"taxId\", \"npi\", \"billType\", \"phone\", \"billingStreet\",\n \"billingCity\", \"billingState\", \"billingZip\",\n ]) as BillReviewBillingProvider,\n } : {}),\n ...(input.renderingProvider ? {\n renderingProvider: pickDefined(input.renderingProvider, [\n \"name\", \"specialty\", \"npi\", \"taxonomy\", \"licenseNumber\",\n \"licenseState\", \"signaturePng\", \"signatureKey\", \"isQME\", \"isAME\",\n \"email\", \"active\",\n ]) as BillReviewClinician,\n } : {}),\n ...(input.placeOfService ? {\n placeOfService: pickDefined(input.placeOfService, [\n \"billingProviderId\", \"name\", \"nickname\", \"street\", \"city\", \"state\",\n \"zip\", \"county\", \"posCode\", \"isPrimary\", \"active\",\n ]) as BillReviewLocation,\n } : {}),\n lineItems: input.lineItems.map((line) => pickDefined(line, [\n \"id\", \"code\", \"modifiers\", \"units\", \"charge\", \"serviceDate\",\n \"serviceDateEnd\", \"diagnosisPointers\",\n ]) as BillReviewSaveInput[\"lineItems\"][number]),\n };\n}\n\nexport type BillSubmissionRoute = \"ebill\" | \"fax\" | \"mail\" | \"email\";\nexport type BillDeliveryOption = {\n route: BillSubmissionRoute;\n label: string;\n detail: string;\n fallback: boolean;\n confidence: string;\n payerName: string;\n target?: string;\n chKey?: string;\n payerId?: string;\n printAndMail?: boolean;\n costUsd?: number;\n};\nexport type BillDeliveryOptions = {\n payerName: string;\n recommended: BillDeliveryOption;\n options: BillDeliveryOption[];\n contacts: {\n faxNumber?: string | null;\n claimsEmail?: string | null;\n portalUrl?: string | null;\n mailingAddress?: string | null;\n adjusterName?: string | null;\n adjusterPhone?: string | null;\n adjusterEmail?: string | null;\n };\n};\nexport type SubmitBillInput = {\n route: BillSubmissionRoute;\n destination?: {\n faxNumber?: string;\n email?: string;\n mailingAddress?: string;\n };\n attention?: string;\n subject?: string;\n note?: string;\n};\nexport type BillLifecycleActionId =\n | \"second_review\"\n | \"independent_bill_review\"\n | \"view_eor\"\n | \"post_payment\"\n | \"close\"\n | \"reopen\";\n\nexport type BillLifecycleAction = {\n id: BillLifecycleActionId;\n label: string;\n enabled: boolean;\n primary?: boolean;\n reason?: string;\n};\n\nexport type BillEorDocument = {\n id: string;\n filename: string;\n description: string | null;\n addedAt: string;\n contentUrl: string;\n};\n\nexport type BillActivityRecord = {\n id: string;\n type: string;\n createdAt: string;\n title?: string;\n description: string;\n actor: string | null;\n delivery: BillSubmissionRoute | null;\n amount: number | null;\n accepted: boolean | null;\n stcCategory: string | null;\n};\n\nexport type BillPaymentRecord = {\n id: string;\n method: \"check\" | \"eft\";\n checkNumber: string;\n status: string | null;\n depositDate: string | null;\n checkReceived: boolean | null;\n receivedDate: string | null;\n amount: number;\n feeAmount: number | null;\n feeReason: string | null;\n source: \"paper\" | \"835\" | \"portal\";\n postedAt: string;\n updatedAt: string | null;\n note: string | null;\n};\n\nexport type BillRemittanceSummary = {\n payerReportedPaid: number | null;\n totalPaid: number;\n balanceDue: number;\n denialReason: string | null;\n};\n\nexport type BillLifecycleDelivery = {\n payerName: string;\n contacts: BillDeliveryOptions[\"contacts\"];\n};\n\nexport type BillLifecycleData = BillReviewData & {\n lifecycle: {\n state: string;\n nativeStatus: string;\n submittedAt?: string | null;\n agingDays?: number | null;\n updatedAt?: string | null;\n actions: BillLifecycleAction[];\n };\n eors: BillEorDocument[];\n activity: BillActivityRecord[];\n payments: BillPaymentRecord[];\n remittance: BillRemittanceSummary;\n delivery: BillLifecycleDelivery;\n};\n\nexport type BillLifecycleSession = {\n token: string;\n expiresAt?: string;\n apiBaseUrl?: string;\n};\n\nexport type BillLifecycleSessionRequest = {\n signal: AbortSignal;\n};\n\nexport type BillLifecycleSessionProvider = (\n request: BillLifecycleSessionRequest,\n) => Promise<BillLifecycleSession>;\n\nexport type CloseBillInput = { reason: string };\nexport type ReopenBillInput = { reason: string };\nexport type PostBillPaymentInput = {\n amount: number;\n method: \"check\" | \"eft\";\n checkNumber?: string;\n depositDate: string;\n note?: string;\n};\nexport type SubmitSecondReviewInput = {\n reason: string;\n payerClaimControlNumber: string;\n disputedAmount: number | undefined;\n attachmentIds: string[];\n route: BillSubmissionRoute;\n};\n\nexport type BrowserBillAddress = {\n line1: string;\n city: string;\n state: string;\n postalCode: string;\n};\n\n/** Complete bill snapshot accepted by the browser create endpoint. */\nexport type BrowserBillCreateInput = {\n externalId?: string;\n billingMode?: \"med_legal\" | \"professional\";\n patient: {\n id?: string;\n externalId?: string;\n firstName: string;\n middleName?: string;\n lastName: string;\n dateOfBirth: string;\n ssn?: string;\n gender?: \"M\" | \"F\" | \"X\";\n phone?: string;\n address: BrowserBillAddress;\n };\n claim: {\n id?: string;\n externalId?: string;\n claimNumber: string;\n adjNumber?: string;\n employer?: string;\n dateOfInjury?: string;\n injuryState?: string;\n description?: string;\n claimsAdministrator?: { id?: string; name: string };\n };\n service: { date?: string; endDate?: string | null; authorizationNumber?: string | null };\n billingProvider?: { name?: string; taxId?: string; npi?: string; phone?: string; address?: BrowserBillAddress };\n renderingProvider?: {\n name?: string;\n specialty?: string;\n npi?: string;\n taxonomy?: string;\n licenseNumber?: string;\n licenseState?: string;\n isQme?: boolean;\n isAme?: boolean;\n };\n serviceLocation?: { name?: string; address?: BrowserBillAddress; placeOfServiceCode?: string };\n diagnoses?: string[];\n serviceLines?: Array<{\n code: string;\n modifiers?: string[];\n units?: number;\n charge?: number;\n serviceDate?: string;\n serviceDateEnd?: string;\n diagnosisPointers?: number[];\n }>;\n};\n\nexport type BillLifecycleClientOptions = {\n /** ID of an already-submitted bill. Bills are created only by the atomic server API. */\n billId: string;\n sessionEndpoint?: string | undefined;\n getSession?: BillLifecycleSessionProvider | undefined;\n apiBaseUrl?: string | undefined;\n fetch?: typeof globalThis.fetch | undefined;\n};\n\n/** Browser-session options for pre-submission reference-data lookups. */\nexport type BillReferenceClientOptions = Omit<BillLifecycleClientOptions, \"billId\">;\n\nexport type BillReferenceClient = {\n searchClaimsAdministrators: (query: string, claimNumber?: string) => Promise<BillReviewPayer[]>;\n clearSession: () => void;\n};\n\nexport type BillLifecycleClient = {\n getBillId: () => string;\n getLifecycle: (signal?: AbortSignal) => Promise<BillLifecycleData>;\n searchClaimsAdministrators: (query: string, claimNumber?: string) => Promise<BillReviewPayer[]>;\n getDeliveryOptions: () => Promise<BillDeliveryOptions>;\n getAttachment: (attachmentId: string) => Promise<Blob>;\n getEor: (documentId: string) => Promise<Blob>;\n getPacket: () => Promise<Blob>;\n closeBill: (input: CloseBillInput) => Promise<BillLifecycleData>;\n reopenBill: (input: ReopenBillInput) => Promise<BillLifecycleData>;\n postPayment: (input: PostBillPaymentInput) => Promise<BillLifecycleData>;\n submitSecondReview: (input: SubmitSecondReviewInput) => Promise<BillLifecycleData>;\n clearSession: () => void;\n};\n\nasync function responseError(response: Response, fallback: string): Promise<Error> {\n const body: unknown = await response.json().catch(() => null);\n const detail = body && typeof body === \"object\"\n ? (body as { detail?: unknown; message?: unknown; error?: unknown }).detail\n ?? (body as { message?: unknown }).message\n ?? (body as { error?: unknown }).error\n : null;\n return new Error(typeof detail === \"string\" ? detail : fallback);\n}\n\nfunction isSessionFresh(session: BillLifecycleSession | null): boolean {\n if (!session) return false;\n if (!session.expiresAt) return true;\n const expiresAt = new Date(session.expiresAt).getTime();\n return Number.isFinite(expiresAt) && expiresAt > Date.now() + 30_000;\n}\n\nfunction normalizeSession(value: unknown): BillLifecycleSession {\n if (!value || typeof value !== \"object\") {\n throw new Error(\"The billing session endpoint returned an invalid response.\");\n }\n const candidate = value as { token?: unknown; expiresAt?: unknown; apiBaseUrl?: unknown; session?: unknown; data?: unknown };\n const nested = candidate.session ?? candidate.data;\n const session = nested && typeof nested === \"object\" ? nested as typeof candidate : candidate;\n if (typeof session.token !== \"string\" || session.token.length < 8) {\n throw new Error(\"The billing session endpoint did not return a browser session token.\");\n }\n return {\n token: session.token,\n ...(typeof session.expiresAt === \"string\" ? { expiresAt: session.expiresAt } : {}),\n ...(typeof session.apiBaseUrl === \"string\" ? { apiBaseUrl: session.apiBaseUrl } : {}),\n };\n}\n\nfunction normalizeLifecycle(value: unknown): BillLifecycleData {\n if (!value || typeof value !== \"object\") {\n throw new Error(\"The billing service returned an invalid bill lifecycle.\");\n }\n const data = value as Partial<BillLifecycleData>;\n if (\n !data.bill\n || !data.patient\n || !data.injury\n || !data.lifecycle\n || !Array.isArray(data.lifecycle.actions)\n || !Array.isArray(data.eors)\n || !Array.isArray(data.activity)\n || !Array.isArray(data.payments)\n || !data.remittance\n || typeof data.remittance !== \"object\"\n || !data.delivery\n || typeof data.delivery !== \"object\"\n || !data.delivery.contacts\n || typeof data.delivery.contacts !== \"object\"\n ) {\n throw new Error(\"The billing service returned an invalid bill lifecycle.\");\n }\n return data as BillLifecycleData;\n}\n\nfunction normalizeDeliveryOptions(value: unknown): BillDeliveryOptions {\n if (!value || typeof value !== \"object\") {\n throw new Error(\"The billing service returned invalid delivery options.\");\n }\n const data = value as Partial<BillDeliveryOptions>;\n if (\n typeof data.payerName !== \"string\"\n || !data.recommended\n || typeof data.recommended !== \"object\"\n || ![\"ebill\", \"fax\", \"mail\", \"email\"].includes(data.recommended.route ?? \"\")\n || !Array.isArray(data.options)\n || !data.contacts\n ) {\n throw new Error(\"The billing service returned invalid delivery options.\");\n }\n return data as BillDeliveryOptions;\n}\n\nfunction idempotencyKey(): string {\n if (typeof globalThis.crypto?.randomUUID === \"function\") return globalThis.crypto.randomUUID();\n return `mb-${Date.now()}-${Math.random().toString(36).slice(2)}`;\n}\n\n/** Browser-safe, framework-neutral client for an already-submitted bill. */\nexport function createBillLifecycleClient({\n billId,\n sessionEndpoint = DEFAULT_SESSION_ENDPOINT,\n getSession,\n apiBaseUrl = DEFAULT_API_BASE_URL,\n fetch: fetchOverride,\n}: BillLifecycleClientOptions): BillLifecycleClient {\n const fetcher = fetchOverride ?? globalThis.fetch;\n if (typeof fetcher !== \"function\") throw new Error(\"A Fetch API implementation is required.\");\n let session: BillLifecycleSession | null = null;\n let sessionRequest: Promise<BillLifecycleSession> | null = null;\n const currentBillId = billId.trim();\n if (!currentBillId) throw new Error(\"billId is required for the submitted-bill lifecycle client.\");\n\n const mintSession = async (signal: AbortSignal, force = false): Promise<BillLifecycleSession> => {\n if (!force && isSessionFresh(session)) return session as BillLifecycleSession;\n if (!force && sessionRequest) return sessionRequest;\n const pending = getSession\n ? getSession({ signal })\n : fetcher(sessionEndpoint, {\n method: \"POST\",\n credentials: \"same-origin\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({}),\n signal,\n }).then(async (response) => {\n if (!response.ok) throw await responseError(response, \"The billing session could not be created.\");\n return response.json();\n });\n const request = Promise.resolve(pending).then(normalizeSession).then((nextSession) => {\n session = nextSession;\n return nextSession;\n }).finally(() => {\n if (sessionRequest === request) sessionRequest = null;\n });\n sessionRequest = request;\n return request;\n };\n\n const request = async (path: string, init: RequestInit = {}, providedSignal?: AbortSignal): Promise<Response> => {\n const controller = providedSignal ? null : new AbortController();\n const signal = providedSignal ?? controller?.signal;\n if (!signal) throw new Error(\"An AbortSignal could not be created.\");\n let browserSession = await mintSession(signal);\n const perform = (current: BillLifecycleSession) => {\n const base = (current.apiBaseUrl ?? apiBaseUrl).replace(/\\/$/, \"\");\n const headers = new Headers(init.headers);\n headers.set(\"authorization\", `Bearer ${current.token}`);\n return fetcher(`${base}${path}`, { ...init, headers, signal });\n };\n let response = await perform(browserSession);\n if (response.status === 401) {\n session = null;\n browserSession = await mintSession(signal, true);\n response = await perform(browserSession);\n }\n return response;\n };\n\n const billPath = (suffix = \"\"): string =>\n `/partner/v2/browser/bills/${encodeURIComponent(currentBillId)}${suffix}`;\n\n const loadLifecycle = async (signal?: AbortSignal) => {\n const response = await request(billPath(\"/lifecycle\"), {}, signal);\n if (!response.ok) throw await responseError(response, \"Bill lifecycle could not be loaded.\");\n const body = await response.json() as { data?: unknown };\n return normalizeLifecycle(body.data);\n };\n\n const searchClaimsAdministrators = async (query: string, claimNumber?: string): Promise<BillReviewPayer[]> => {\n const params = new URLSearchParams();\n if (query.trim()) params.set(\"q\", query.trim());\n if (claimNumber?.trim()) params.set(\"claimNumber\", claimNumber.trim());\n const response = await request(`/partner/v2/browser/claims-administrators?${params.toString()}`);\n if (!response.ok) throw await responseError(response, \"Claims administrator search is unavailable.\");\n const body = await response.json() as { results?: unknown };\n if (!Array.isArray(body.results)) throw new Error(\"Claims administrator search returned an invalid response.\");\n return body.results.flatMap((value): BillReviewPayer[] => {\n if (!value || typeof value !== \"object\") return [];\n const payer = value as Partial<BillReviewPayer>;\n if (typeof payer.id !== \"string\" || typeof payer.name !== \"string\") return [];\n return [{\n id: payer.id,\n name: payer.name,\n ...(typeof payer.hasElectronic === \"boolean\" ? { hasElectronic: payer.hasElectronic } : {}),\n ...(Array.isArray(payer.states)\n ? { states: payer.states.filter((state): state is string => typeof state === \"string\") }\n : {}),\n ...([\"high\", \"medium\", \"directory\"].includes(payer.confidence ?? \"\")\n ? { confidence: payer.confidence as NonNullable<BillReviewPayer[\"confidence\"]> }\n : {}),\n ...(typeof payer.recommended === \"boolean\" ? { recommended: payer.recommended } : {}),\n ...(Array.isArray(payer.signals)\n ? {\n signals: payer.signals.flatMap((signal) => {\n if (!signal || typeof signal !== \"object\") return [];\n const candidate = signal as { kind?: unknown; state?: unknown; label?: unknown };\n if (\n ![\"name\", \"claim_number\"].includes(String(candidate.kind))\n || ![\"match\", \"warning\"].includes(String(candidate.state))\n || typeof candidate.label !== \"string\"\n ) return [];\n return [{\n kind: candidate.kind as \"name\" | \"claim_number\",\n state: candidate.state as \"match\" | \"warning\",\n label: candidate.label,\n }];\n }),\n }\n : {}),\n }];\n });\n };\n\n const mutation = async (path: string, init: RequestInit, fallback: string) => {\n const headers = new Headers(init.headers);\n headers.set(\"idempotency-key\", idempotencyKey());\n const response = await request(path, { ...init, headers });\n if (!response.ok) throw await responseError(response, fallback);\n return response;\n };\n const action = async (input: Record<string, unknown>, fallback: string): Promise<BillLifecycleData> => {\n const response = await mutation(billPath(\"/actions\"), {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(input),\n }, fallback);\n const body = await response.json() as { data?: unknown };\n return normalizeLifecycle(body.data);\n };\n return {\n getBillId() { return currentBillId; },\n clearSession() { session = null; sessionRequest = null; },\n getLifecycle: loadLifecycle,\n searchClaimsAdministrators,\n async getDeliveryOptions() {\n const response = await request(billPath(\"/delivery-options\"));\n if (!response.ok) throw await responseError(response, \"Delivery options could not be loaded.\");\n const body = await response.json() as { data?: unknown };\n return normalizeDeliveryOptions(body.data ?? body);\n },\n async getAttachment(attachmentId) {\n const response = await request(billPath(`/documents/${encodeURIComponent(attachmentId)}`));\n if (!response.ok) throw await responseError(response, \"Document could not be opened.\");\n return response.blob();\n },\n async getEor(documentId) {\n const response = await request(billPath(`/eors/${encodeURIComponent(documentId)}`));\n if (!response.ok) throw await responseError(response, \"EOR could not be opened.\");\n return response.blob();\n },\n async getPacket() {\n const response = await request(billPath(\"/packet\"));\n if (!response.ok) throw await responseError(response, \"Submission packet could not be downloaded.\");\n return response.blob();\n },\n closeBill(input) { return action({ action: \"close\", ...input }, \"Bill could not be closed.\"); },\n reopenBill(input) { return action({ action: \"reopen\", ...input }, \"Bill could not be reopened.\"); },\n postPayment(input) { return action({ action: \"post_payment\", ...input, checkNumber: input.checkNumber ?? \"\" }, \"Payment could not be posted.\"); },\n submitSecondReview(input) { return action({ action: \"second_review\", ...input }, \"Second Review could not be submitted.\"); },\n };\n}\n\n/**\n * Browser-safe client for reference data needed before a bill exists.\n *\n * Partners can pass the same short-lived session provider used by the submitted-bill\n * lifecycle without inventing a draft bill or exposing payer directory credentials.\n */\nexport function createBillReferenceClient(\n options: BillReferenceClientOptions = {},\n): BillReferenceClient {\n const lifecycle = createBillLifecycleClient({\n ...options,\n billId: \"pre-submission-reference-data\",\n });\n return {\n searchClaimsAdministrators: lifecycle.searchClaimsAdministrators,\n clearSession: lifecycle.clearSession,\n };\n}\n"],"mappings":";AAAO,IAAM,uBAAuB;AAC7B,IAAM,2BAA2B;AA6LxC,SAAS,YACP,QACA,MACyB;AACzB,QAAM,SAAS;AACf,SAAO,OAAO;AAAA,IACZ,KAAK,QAAQ,CAAC,QAAQ,OAAO,GAAG,MAAM,SAAY,CAAC,IAAI,CAAC,CAAC,KAAK,OAAO,GAAG,CAAC,CAAC,CAAC;AAAA,EAC7E;AACF;AAOO,SAAS,4BACd,OACqB;AACrB,SAAO;AAAA,IACL,eAAe,MAAM;AAAA,IACrB,GAAI,MAAM,mBAAmB;AAAA,MAC3B,kBAAkB,YAAY,MAAM,kBAAkB;AAAA,QACpD;AAAA,QAAa;AAAA,QAAc;AAAA,QAAY;AAAA,MACzC,CAAC;AAAA,IACH,IAAI,CAAC;AAAA,IACL,GAAI,MAAM,kBAAkB;AAAA,MAC1B,iBAAiB,YAAY,MAAM,iBAAiB;AAAA,QAClD;AAAA,QAAe;AAAA,QAAY;AAAA,QAAO;AAAA,QAClC;AAAA,QAAoB;AAAA,MACtB,CAAC;AAAA,IACH,IAAI,CAAC;AAAA,IACL,KAAK,MAAM;AAAA,IACX,GAAI,MAAM,WAAW,SAAY,EAAE,QAAQ,MAAM,OAAO,IAAI,CAAC;AAAA,IAC7D,GAAI,MAAM,wBAAwB,SAC9B,EAAE,qBAAqB,MAAM,oBAAoB,IACjD,CAAC;AAAA,IACL,GAAI,MAAM,kBAAkB;AAAA,MAC1B,iBAAiB,YAAY,MAAM,iBAAiB;AAAA,QAClD;AAAA,QAAQ;AAAA,QAAS;AAAA,QAAO;AAAA,QAAY;AAAA,QAAS;AAAA,QAC7C;AAAA,QAAe;AAAA,QAAgB;AAAA,MACjC,CAAC;AAAA,IACH,IAAI,CAAC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AAM,YAAY,0BAA0B;AAAA,IAC1C,GAAG;AAAA,IACH,QAAQ;AAAA,EACV,CAAC;AACD,SAAO;AAAA,IACL,4BAA4B,UAAU;AAAA,IACtC,cAAc,UAAU;AAAA,EAC1B;AACF;","names":["request"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindbill/browser",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Framework-neutral browser client for the MindBill bill lifecycle",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",