@mindbill/browser 0.47.0 → 0.49.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/dist/index.d.ts CHANGED
@@ -1,157 +1,3 @@
1
- /** One patient's complete services for one provider/group. Dates are service dates, not publication dates. */
2
- type CaClaimFeeQuoteInput = {
3
- lines: Array<Omit<BillFeeQuoteInput, "billingProviderId" | "payerId" | "physicianContext"> & {
4
- id: string;
5
- serviceCounty?: string;
6
- physicianContext?: Omit<NonNullable<BillFeeQuoteInput["physicianContext"]>, "providerKind"> & {
7
- providerKind: NonNullable<BillFeeQuoteInput["physicianContext"]>["providerKind"] | "clinical_social_worker";
8
- telehealthModality?: "audio_video" | "audio_only";
9
- cmsSpecialtyCode?: string;
10
- };
11
- }>;
12
- completeDateOfServiceContext: boolean;
13
- ordinaryMultipleSurgeryContext?: boolean;
14
- };
15
- type CaFeeCitation = {
16
- id: string;
17
- url: string;
18
- sha256?: string;
19
- effectiveFrom?: string;
20
- effectiveThrough?: string;
21
- };
22
- type CaFeeCalculation = {
23
- method: "rbrvs" | "therapy_mppr";
24
- locality: string;
25
- serviceZip?: string;
26
- serviceCounty?: string;
27
- setting: "facility" | "nonfacility";
28
- units: number;
29
- conversionFactor: string;
30
- providerPercent: number;
31
- baseMaximumCents?: number;
32
- cmsIndicators?: Record<string, string>;
33
- sourceFiles?: Array<{
34
- kind: string;
35
- filename: string;
36
- }>;
37
- components: Array<{
38
- name: string;
39
- rvu: string;
40
- gpci: string;
41
- payableUnits: number;
42
- }>;
43
- rounding: string;
44
- };
45
- type CaClaimEditFinding = {
46
- type: string;
47
- lineIds: string[];
48
- message: string;
49
- citationUrl: string;
50
- column1?: string;
51
- column2?: string;
52
- modifierIndicator?: number;
53
- code?: string;
54
- limit?: number;
55
- submittedUnits?: number;
56
- adjudicationIndicator?: number;
57
- scope?: "line" | "patient_provider_date";
58
- };
59
- type CaClaimFeeFinding = {
60
- code: string;
61
- lineIds: string[];
62
- message: string;
63
- citationUrl?: string;
64
- edit?: CaClaimEditFinding;
65
- };
66
- type CaClaimLineQuote = ({
67
- status: "priced";
68
- amountCents: number;
69
- scheduleMaximumCents: number;
70
- basis: BillFeeQuoteBasis | "ca_ambulance";
71
- notes: string[];
72
- feeBreakdown?: {
73
- method: string;
74
- inputs: Array<{
75
- label: string;
76
- value: string;
77
- }>;
78
- steps: Array<{
79
- label: string;
80
- value: string;
81
- }>;
82
- };
83
- } | {
84
- status: "requires_review" | "not_separately_payable";
85
- reason: string;
86
- }) & {
87
- provenance: CaFeeCitation[];
88
- calculation?: CaFeeCalculation;
89
- };
90
- type CaClaimFeeQuoteResult = {
91
- status: "priced" | "requires_review" | "not_separately_payable";
92
- lines: Array<{
93
- id: string;
94
- input: CaClaimFeeQuoteInput["lines"][number];
95
- quote: CaClaimLineQuote;
96
- assessment: CaClaimFeeQuoteResult["status"];
97
- findings: CaClaimFeeFinding[];
98
- paymentAdjustment?: {
99
- rule: "ca_multiple_surgery";
100
- rank: number;
101
- percent: 100 | 50;
102
- unadjustedScheduleMaximumCents: number;
103
- scheduleMaximumCents: number;
104
- amountCents: number;
105
- citationUrl: string;
106
- };
107
- }>;
108
- totals: {
109
- submittedChargeCents: number | null;
110
- pricedSubtotalCents: number;
111
- estimatedPayableCents: number | null;
112
- scheduleMaximumCents: number | null;
113
- reviewLineCount: number;
114
- };
115
- claimEdits: Array<{
116
- dateOfService: string;
117
- lineIds: string[];
118
- status: "evaluated" | "requires_review" | "source_unavailable" | "not_applicable";
119
- reason?: string;
120
- findings: CaClaimEditFinding[];
121
- provenance?: unknown;
122
- supportedDateRange?: {
123
- from: string;
124
- through: string;
125
- };
126
- supportedDateIntervals?: Array<{
127
- from: string;
128
- through: string;
129
- }>;
130
- }>;
131
- limitations: string[];
132
- };
133
-
134
- type RfaAuthorizationDestinationOption = {
135
- method: "fax" | "email";
136
- destination: string;
137
- label: string;
138
- phone?: string;
139
- };
140
- /** Accept fax numbers only, never telephone notes, email addresses, or extensions. */
141
- declare function normalizeRfaFax(value: string): string | null;
142
- /** Returns choices only. Selecting or transmitting a destination is a separate user action. */
143
- declare function rfaAuthorizationDestinations(directory: BillClaimsAdministratorDirectory | null): RfaAuthorizationDestinationOption[];
144
- declare function rfaAuthorizationGuidance(directory: BillClaimsAdministratorDirectory | null): string;
145
-
146
- type CorrectionDraft = {
147
- correctBilling: boolean;
148
- units: string;
149
- modifiers: string;
150
- charge: string;
151
- chargeReviewed: boolean;
152
- };
153
- declare function parseSecondReviewCorrection(draft: CorrectionDraft): SecondReviewLineInput["correction"];
154
-
155
1
  type RfaReceiptInput = {
156
2
  channel: "fax" | "email" | "edi" | "portal" | "mail" | "manual";
157
3
  receivedAt: string;
@@ -213,6 +59,18 @@ type RfaSchedulingInput = {
213
59
  disposition: "no_appointment" | "canceled";
214
60
  reason: string;
215
61
  });
62
+ type RfaTreatmentClosureInput = {
63
+ closed: boolean;
64
+ reason: string;
65
+ expectedVersion: number;
66
+ };
67
+ type RfaTreatmentClosure = {
68
+ closed: boolean;
69
+ reason: string;
70
+ version: number;
71
+ updatedAt: string;
72
+ updatedBy: string;
73
+ };
216
74
  type RfaDecisionCorrectionInput = {
217
75
  itemId: string;
218
76
  expectedDecisionEventId: string;
@@ -293,6 +151,7 @@ type RfaLifecycleClient = {
293
151
  matchInboundFax(faxId: string, rfaId: string, idempotencyKey: string): Promise<RfaInboundFaxMatch>;
294
152
  listScheduling(id: string): Promise<RfaScheduling[]>;
295
153
  updateScheduling(id: string, itemId: string, input: RfaSchedulingInput, idempotencyKey: string): Promise<RfaScheduling[]>;
154
+ updateTreatmentClosure(id: string, itemId: string, input: RfaTreatmentClosureInput, idempotencyKey: string): Promise<RfaRecord>;
296
155
  correctDecision(id: string, input: RfaDecisionCorrectionInput, idempotencyKey: string): Promise<RfaRecord>;
297
156
  listHistory(id: string): Promise<RfaHistoryEvent[]>;
298
157
  addNote(id: string, text: string, idempotencyKey: string): Promise<RfaHistoryEvent>;
@@ -314,6 +173,168 @@ type RfaLifecycleClient = {
314
173
  /** Records clinical workflow evidence. These methods never send faxes or reconcile notification queues. */
315
174
  declare function createRfaLifecycleClient({ sessionEndpoint, getSession, apiBaseUrl, fetch: fetchOverride }?: OrganizationClientOptions): RfaLifecycleClient;
316
175
 
176
+ type RfaLifecycleStatus = "incomplete" | "sent" | "failed" | "received" | "closed" | "canceled";
177
+ declare const RFA_LIFECYCLE_LABELS: Readonly<Record<RfaLifecycleStatus, string>>;
178
+ type LifecycleRecord = Pick<RfaRecord, "status"> & Partial<Pick<RfaRecord, "lifecycleStatus" | "submittedAt" | "receivedAt" | "transmissions">>;
179
+ /** Prefer the API lifecycle. Older responses are derived from the current submission's evidence. */
180
+ declare function getRfaLifecycleStatus(rfa: LifecycleRecord): RfaLifecycleStatus;
181
+
182
+ /** One patient's complete services for one provider/group. Dates are service dates, not publication dates. */
183
+ type CaClaimFeeQuoteInput = {
184
+ lines: Array<Omit<BillFeeQuoteInput, "billingProviderId" | "payerId" | "physicianContext"> & {
185
+ id: string;
186
+ serviceCounty?: string;
187
+ physicianContext?: Omit<NonNullable<BillFeeQuoteInput["physicianContext"]>, "providerKind"> & {
188
+ providerKind: NonNullable<BillFeeQuoteInput["physicianContext"]>["providerKind"] | "clinical_social_worker";
189
+ telehealthModality?: "audio_video" | "audio_only";
190
+ cmsSpecialtyCode?: string;
191
+ };
192
+ }>;
193
+ completeDateOfServiceContext: boolean;
194
+ ordinaryMultipleSurgeryContext?: boolean;
195
+ };
196
+ type CaFeeCitation = {
197
+ id: string;
198
+ url: string;
199
+ sha256?: string;
200
+ effectiveFrom?: string;
201
+ effectiveThrough?: string;
202
+ };
203
+ type CaFeeCalculation = {
204
+ method: "rbrvs" | "therapy_mppr";
205
+ locality: string;
206
+ serviceZip?: string;
207
+ serviceCounty?: string;
208
+ setting: "facility" | "nonfacility";
209
+ units: number;
210
+ conversionFactor: string;
211
+ providerPercent: number;
212
+ baseMaximumCents?: number;
213
+ cmsIndicators?: Record<string, string>;
214
+ sourceFiles?: Array<{
215
+ kind: string;
216
+ filename: string;
217
+ }>;
218
+ components: Array<{
219
+ name: string;
220
+ rvu: string;
221
+ gpci: string;
222
+ payableUnits: number;
223
+ }>;
224
+ rounding: string;
225
+ };
226
+ type CaClaimEditFinding = {
227
+ type: string;
228
+ lineIds: string[];
229
+ message: string;
230
+ citationUrl: string;
231
+ column1?: string;
232
+ column2?: string;
233
+ modifierIndicator?: number;
234
+ code?: string;
235
+ limit?: number;
236
+ submittedUnits?: number;
237
+ adjudicationIndicator?: number;
238
+ scope?: "line" | "patient_provider_date";
239
+ };
240
+ type CaClaimFeeFinding = {
241
+ code: string;
242
+ lineIds: string[];
243
+ message: string;
244
+ citationUrl?: string;
245
+ edit?: CaClaimEditFinding;
246
+ };
247
+ type CaClaimLineQuote = ({
248
+ status: "priced";
249
+ amountCents: number;
250
+ scheduleMaximumCents: number;
251
+ basis: BillFeeQuoteBasis | "ca_ambulance";
252
+ notes: string[];
253
+ feeBreakdown?: {
254
+ method: string;
255
+ inputs: Array<{
256
+ label: string;
257
+ value: string;
258
+ }>;
259
+ steps: Array<{
260
+ label: string;
261
+ value: string;
262
+ }>;
263
+ };
264
+ } | {
265
+ status: "requires_review" | "not_separately_payable";
266
+ reason: string;
267
+ }) & {
268
+ provenance: CaFeeCitation[];
269
+ calculation?: CaFeeCalculation;
270
+ };
271
+ type CaClaimFeeQuoteResult = {
272
+ status: "priced" | "requires_review" | "not_separately_payable";
273
+ lines: Array<{
274
+ id: string;
275
+ input: CaClaimFeeQuoteInput["lines"][number];
276
+ quote: CaClaimLineQuote;
277
+ assessment: CaClaimFeeQuoteResult["status"];
278
+ findings: CaClaimFeeFinding[];
279
+ paymentAdjustment?: {
280
+ rule: "ca_multiple_surgery";
281
+ rank: number;
282
+ percent: 100 | 50;
283
+ unadjustedScheduleMaximumCents: number;
284
+ scheduleMaximumCents: number;
285
+ amountCents: number;
286
+ citationUrl: string;
287
+ };
288
+ }>;
289
+ totals: {
290
+ submittedChargeCents: number | null;
291
+ pricedSubtotalCents: number;
292
+ estimatedPayableCents: number | null;
293
+ scheduleMaximumCents: number | null;
294
+ reviewLineCount: number;
295
+ };
296
+ claimEdits: Array<{
297
+ dateOfService: string;
298
+ lineIds: string[];
299
+ status: "evaluated" | "requires_review" | "source_unavailable" | "not_applicable";
300
+ reason?: string;
301
+ findings: CaClaimEditFinding[];
302
+ provenance?: unknown;
303
+ supportedDateRange?: {
304
+ from: string;
305
+ through: string;
306
+ };
307
+ supportedDateIntervals?: Array<{
308
+ from: string;
309
+ through: string;
310
+ }>;
311
+ }>;
312
+ limitations: string[];
313
+ };
314
+
315
+ type RfaAuthorizationDestinationOption = {
316
+ method: "fax" | "email";
317
+ destination: string;
318
+ label: string;
319
+ phone?: string;
320
+ /** Recipient attention line, retained on the reviewed delivery cover. */
321
+ recipientName?: string;
322
+ };
323
+ /** Accept fax numbers only, never telephone notes, email addresses, or extensions. */
324
+ declare function normalizeRfaFax(value: string): string | null;
325
+ /** Returns choices only. Selecting or transmitting a destination is a separate user action. */
326
+ declare function rfaAuthorizationDestinations(directory: BillClaimsAdministratorDirectory | null): RfaAuthorizationDestinationOption[];
327
+ declare function rfaAuthorizationGuidance(directory: BillClaimsAdministratorDirectory | null): string;
328
+
329
+ type CorrectionDraft = {
330
+ correctBilling: boolean;
331
+ units: string;
332
+ modifiers: string;
333
+ charge: string;
334
+ chargeReviewed: boolean;
335
+ };
336
+ declare function parseSecondReviewCorrection(draft: CorrectionDraft): SecondReviewLineInput["correction"];
337
+
317
338
  type ReportAutofillField = {
318
339
  key: string;
319
340
  value: string;
@@ -1931,6 +1952,7 @@ type RfaDeliveryPreviewInput = {
1931
1952
  documentIds: string[];
1932
1953
  channel: "fax" | "email" | "download";
1933
1954
  to?: string;
1955
+ recipientName?: string;
1934
1956
  message?: string;
1935
1957
  };
1936
1958
  type RfaDeliveryPreview = {
@@ -1941,6 +1963,7 @@ type RfaDeliveryPreview = {
1941
1963
  type RfaSubmitInput = Omit<RfaDeliveryPreview, "contentRevision"> & {
1942
1964
  channel: "fax" | "email";
1943
1965
  to: string;
1966
+ recipientName?: string;
1944
1967
  message?: string;
1945
1968
  nonBusinessDates?: string[];
1946
1969
  };
@@ -2001,6 +2024,8 @@ type RfaRecord = {
2001
2024
  providerName: string;
2002
2025
  claimNumber: string | null;
2003
2026
  status: string;
2027
+ /** Delivery/review lifecycle, separate from the clinical status and item outcomes. */
2028
+ lifecycleStatus?: RfaLifecycleStatus;
2004
2029
  requestType?: RfaCreateDraftInput["requestType"];
2005
2030
  writtenConfirmation?: boolean;
2006
2031
  requestingPractice?: RfaContact | null;
@@ -2045,6 +2070,7 @@ type RfaRecord = {
2045
2070
  units: number | null;
2046
2071
  authorizationNumber: string | null;
2047
2072
  decisionReason: string | null;
2073
+ decisionClosure?: RfaTreatmentClosure | null;
2048
2074
  currentDecisionEventId?: string | null;
2049
2075
  currentResponseDocumentId?: string | null;
2050
2076
  currentImrDocumentId?: string | null;
@@ -2091,14 +2117,21 @@ type RfaRecord = {
2091
2117
  text?: string;
2092
2118
  }>;
2093
2119
  };
2120
+ type RfaAgingBucket = "0_5" | "6_14" | "15_30" | "31_plus";
2121
+ type RfaAgingSummary = {
2122
+ byBucket: Record<RfaAgingBucket, number>;
2123
+ byLifecycleStatus: Record<RfaLifecycleStatus, Record<RfaAgingBucket, number>>;
2124
+ };
2094
2125
  type RfaListQuery = {
2126
+ agingBucket?: RfaAgingBucket;
2095
2127
  patientId?: string;
2096
2128
  search?: string;
2097
- sortBy?: "createdAt" | "employeeName" | "providerName" | "submittedAt" | "status";
2129
+ sortBy?: "createdAt" | "employeeName" | "providerName" | "submittedAt" | "status" | "lifecycleStatus";
2098
2130
  sortDirection?: "asc" | "desc";
2099
2131
  claimId?: string;
2100
2132
  renderingProviderId?: string;
2101
2133
  status?: string;
2134
+ lifecycleStatus?: RfaLifecycleStatus;
2102
2135
  createdFrom?: string;
2103
2136
  createdTo?: string;
2104
2137
  limit?: number;
@@ -2110,6 +2143,8 @@ type RfaListResult = {
2110
2143
  summary: {
2111
2144
  total: number;
2112
2145
  byStatus: Record<string, number>;
2146
+ aging?: RfaAgingSummary;
2147
+ byLifecycleStatus?: Partial<Record<RfaLifecycleStatus, number>>;
2113
2148
  };
2114
2149
  };
2115
2150
  type RfaSigningPreviewInput = {
@@ -2222,4 +2257,4 @@ type RfaClient = {
2222
2257
  /** Uses short-lived browser credentials. Never pass a partner API key. */
2223
2258
  declare function createRfaClient({ sessionEndpoint, getSession, apiBaseUrl, fetch: fetchOverride }?: OrganizationClientOptions): RfaClient;
2224
2259
 
2225
- export { type AddBillNoteInput, BILL_FEE_QUOTE_BASES, BILL_TASKS_AGING_BUCKETS, type BillActivityRecord, type BillActorInput, type BillAttemptSummary, type BillClaimsAdministratorAuthorizationStatus, type BillClaimsAdministratorContact, type BillClaimsAdministratorDirectory, type BillClaimsAdministratorMailingAddress, type BillClaimsAdministratorPattern, type BillClaimsAdministratorPayer, type BillClaimsAdministratorSource, type BillCourtesyCopyInput, type BillCourtesyCopyPreview, type BillCourtesyCopyResult, type BillDeliveryOption, type BillDeliveryOptions, type BillDeliveryPreviewInput, type BillDiagnosisCode, type BillEorDocument, type BillFeeContext, type BillFeeQuote, type BillFeeQuoteBasis, type BillFeeQuoteInput, type BillFeeSource, type BillFormData, type BillFormValue, type BillHistoryEntry, type BillLifecycleAction, type BillLifecycleActionId, type BillLifecycleClient, type BillLifecycleClientOptions, type BillLifecycleData, type BillLifecycleDelivery, type BillLifecycleSession, type BillLifecycleSessionProvider, type BillLifecycleSessionRequest, type BillLineFeeBreakdown, type BillLineFormData, type BillPaymentRecord, type BillPostalPlace, type BillProcedureCodePage, type BillProcedureCodeSearchInput, type BillReferenceClient, type BillReferenceClientOptions, type BillRejection, type BillRejectionIssue, type BillRemittanceSummary, type BillReviewAttachment, type BillReviewBillingProvider, type BillReviewClaimPatternStatus, type BillReviewClinician, type BillReviewData, type BillReviewDocumentType, type BillReviewFeatures, type BillReviewLineItem, type BillReviewLocation, type BillReviewPayer, type BillReviewPayerListInput, type BillReviewPayerOption, type BillReviewPayerPage, type BillReviewPayerSuggestion, type BillReviewSaveInput, type BillSubmissionClient, type BillSubmissionClientOptions, type BillSubmissionDetail, type BillSubmissionRoute, type BillTasksAgingBucket, type BillTasksDashboardData, type BillTasksDashboardItem, type BillTasksDashboardRow, type BillTasksDashboardSection, type BillTasksDashboardSectionInput, type BillTasksDashboardTone, type BillTeamNote, type BilledDrug, type BrowserBillAddress, type BrowserBillCreateInput, type BrowserBillSubmissionDocument, type BrowserBillSubmissionInput, type BrowserBillSubmissionResult, type BrowserSubmittedBill, type CaAnesthesiaContext, type CaAnesthesiaEvent, type CaAnesthesiaInterval, type CaAnesthesiaOptionalParticipation, type CaAnesthesiaParticipation, type CaClaimEditFinding, type CaClaimFeeFinding, type CaClaimFeeQuoteInput, type CaClaimFeeQuoteResult, type CaClaimLineQuote, type CaFeeCalculation, type CaFeeCitation, type CaMedicalDirection, type CaMedicalDirectionCase, type CaMonitoredAnesthesiaCare, type CaPadbContext, type CaProfessionalComponentContext, type CaTechnicalComponentContext, type CaTherapyContext, type ClaimForm, type CloseBillInput, type CorrectionDraft, DEFAULT_API_BASE_URL, DEFAULT_SESSION_ENDPOINT, type HistoricalBillReviewData, type OrganizationBillingProviderInput, type OrganizationChecklistItem, type OrganizationClaimsAdministrator, type OrganizationClaimsAdministratorInput, type OrganizationClient, type OrganizationClientOptions, type OrganizationLocationInput, type OrganizationPracticeIdentity, type OrganizationProfileData, type OrganizationRenderingProviderInput, type OrganizationTeam, type OrganizationTeamMember, type OrganizationTeamRole, type PostBillPaymentInput, REPORT_BILL_STATUS_OPTIONS, type ReopenBillInput, type ReportAutofillClient, type ReportAutofillField, type ReportAutofillMatch, type ReportAutofillResult, type ReportBillStatusActionInput, type ReportBillStatusContacts, type ReportBillStatusId, type ReportBillStatusInput, type ReportBillStatusOption, type ResubmitBillInput, type RfaAuthorizationDestinationOption, type RfaClient, type RfaContact, type RfaCreateDraftInput, type RfaCreationClaim, type RfaCreationContext, type RfaCreationContextQuery, type RfaCreationProvider, type RfaDecisionCorrectionInput, type RfaDecisionsInput, type RfaDeliveryPreview, type RfaDeliveryPreviewInput, type RfaDraftActionsClient, type RfaFaxInput, type RfaFollowUp, type RfaFollowUpList, type RfaFollowUpUpdate, type RfaForwardInput, type RfaForwardResult, type RfaHistoryEvent, type RfaInboundFax, type RfaInboundFaxMatch, type RfaInformationRequestInput, type RfaInformationResponseInput, type RfaLifecycleClient, type RfaListQuery, type RfaListResult, type RfaPacketHistory, type RfaPacketTransmission, type RfaPacketsClient, type RfaProvisionClaimInput, type RfaProvisionClaimResult, type RfaReceiptInput, type RfaRecord, type RfaSavedPacket, type RfaScheduling, type RfaSchedulingInput, type RfaSignInput, type RfaSigningPreview, type RfaSigningPreviewInput, type RfaSubmitInput, type RfaTreatmentDecisionInput, type RfaUpdateDraftInput, type RfaUploadDocumentInput, SECOND_REVIEW_REASON_TEMPLATE, SECOND_REVIEW_WINDOW_DAYS, type SandboxSimulationScenario, type SecondReviewDeadline, type SecondReviewLineInput, type SendDuplicateBillInput, type SimulateSandboxBillInput, type SubmitBillInput, type SubmitNewBillInput, type SubmitSecondReviewInput, billTasksAgingBucketIndex, buildBillTasksDashboard, createBillLifecycleClient, createBillReferenceClient, createBillSubmissionClient, createOrganizationClient, createReportAutofillClient, createRfaClient, createRfaDraftActionsClient, createRfaLifecycleClient, createRfaPacketsClient, defaultBillReviewPayerOption, normalizeRfaFax, organizationTaxIdWrite, parseSecondReviewCorrection, reportBillStatusContacts, rfaAuthorizationDestinations, rfaAuthorizationGuidance, sanitizeBillReviewSaveInput, secondReviewDeadline };
2260
+ export { type AddBillNoteInput, BILL_FEE_QUOTE_BASES, BILL_TASKS_AGING_BUCKETS, type BillActivityRecord, type BillActorInput, type BillAttemptSummary, type BillClaimsAdministratorAuthorizationStatus, type BillClaimsAdministratorContact, type BillClaimsAdministratorDirectory, type BillClaimsAdministratorMailingAddress, type BillClaimsAdministratorPattern, type BillClaimsAdministratorPayer, type BillClaimsAdministratorSource, type BillCourtesyCopyInput, type BillCourtesyCopyPreview, type BillCourtesyCopyResult, type BillDeliveryOption, type BillDeliveryOptions, type BillDeliveryPreviewInput, type BillDiagnosisCode, type BillEorDocument, type BillFeeContext, type BillFeeQuote, type BillFeeQuoteBasis, type BillFeeQuoteInput, type BillFeeSource, type BillFormData, type BillFormValue, type BillHistoryEntry, type BillLifecycleAction, type BillLifecycleActionId, type BillLifecycleClient, type BillLifecycleClientOptions, type BillLifecycleData, type BillLifecycleDelivery, type BillLifecycleSession, type BillLifecycleSessionProvider, type BillLifecycleSessionRequest, type BillLineFeeBreakdown, type BillLineFormData, type BillPaymentRecord, type BillPostalPlace, type BillProcedureCodePage, type BillProcedureCodeSearchInput, type BillReferenceClient, type BillReferenceClientOptions, type BillRejection, type BillRejectionIssue, type BillRemittanceSummary, type BillReviewAttachment, type BillReviewBillingProvider, type BillReviewClaimPatternStatus, type BillReviewClinician, type BillReviewData, type BillReviewDocumentType, type BillReviewFeatures, type BillReviewLineItem, type BillReviewLocation, type BillReviewPayer, type BillReviewPayerListInput, type BillReviewPayerOption, type BillReviewPayerPage, type BillReviewPayerSuggestion, type BillReviewSaveInput, type BillSubmissionClient, type BillSubmissionClientOptions, type BillSubmissionDetail, type BillSubmissionRoute, type BillTasksAgingBucket, type BillTasksDashboardData, type BillTasksDashboardItem, type BillTasksDashboardRow, type BillTasksDashboardSection, type BillTasksDashboardSectionInput, type BillTasksDashboardTone, type BillTeamNote, type BilledDrug, type BrowserBillAddress, type BrowserBillCreateInput, type BrowserBillSubmissionDocument, type BrowserBillSubmissionInput, type BrowserBillSubmissionResult, type BrowserSubmittedBill, type CaAnesthesiaContext, type CaAnesthesiaEvent, type CaAnesthesiaInterval, type CaAnesthesiaOptionalParticipation, type CaAnesthesiaParticipation, type CaClaimEditFinding, type CaClaimFeeFinding, type CaClaimFeeQuoteInput, type CaClaimFeeQuoteResult, type CaClaimLineQuote, type CaFeeCalculation, type CaFeeCitation, type CaMedicalDirection, type CaMedicalDirectionCase, type CaMonitoredAnesthesiaCare, type CaPadbContext, type CaProfessionalComponentContext, type CaTechnicalComponentContext, type CaTherapyContext, type ClaimForm, type CloseBillInput, type CorrectionDraft, DEFAULT_API_BASE_URL, DEFAULT_SESSION_ENDPOINT, type HistoricalBillReviewData, type OrganizationBillingProviderInput, type OrganizationChecklistItem, type OrganizationClaimsAdministrator, type OrganizationClaimsAdministratorInput, type OrganizationClient, type OrganizationClientOptions, type OrganizationLocationInput, type OrganizationPracticeIdentity, type OrganizationProfileData, type OrganizationRenderingProviderInput, type OrganizationTeam, type OrganizationTeamMember, type OrganizationTeamRole, type PostBillPaymentInput, REPORT_BILL_STATUS_OPTIONS, RFA_LIFECYCLE_LABELS, type ReopenBillInput, type ReportAutofillClient, type ReportAutofillField, type ReportAutofillMatch, type ReportAutofillResult, type ReportBillStatusActionInput, type ReportBillStatusContacts, type ReportBillStatusId, type ReportBillStatusInput, type ReportBillStatusOption, type ResubmitBillInput, type RfaAgingBucket, type RfaAgingSummary, type RfaAuthorizationDestinationOption, type RfaClient, type RfaContact, type RfaCreateDraftInput, type RfaCreationClaim, type RfaCreationContext, type RfaCreationContextQuery, type RfaCreationProvider, type RfaDecisionCorrectionInput, type RfaDecisionsInput, type RfaDeliveryPreview, type RfaDeliveryPreviewInput, type RfaDraftActionsClient, type RfaFaxInput, type RfaFollowUp, type RfaFollowUpList, type RfaFollowUpUpdate, type RfaForwardInput, type RfaForwardResult, type RfaHistoryEvent, type RfaInboundFax, type RfaInboundFaxMatch, type RfaInformationRequestInput, type RfaInformationResponseInput, type RfaLifecycleClient, type RfaLifecycleStatus, type RfaListQuery, type RfaListResult, type RfaPacketHistory, type RfaPacketTransmission, type RfaPacketsClient, type RfaProvisionClaimInput, type RfaProvisionClaimResult, type RfaReceiptInput, type RfaRecord, type RfaSavedPacket, type RfaScheduling, type RfaSchedulingInput, type RfaSignInput, type RfaSigningPreview, type RfaSigningPreviewInput, type RfaSubmitInput, type RfaTreatmentClosure, type RfaTreatmentClosureInput, type RfaTreatmentDecisionInput, type RfaUpdateDraftInput, type RfaUploadDocumentInput, SECOND_REVIEW_REASON_TEMPLATE, SECOND_REVIEW_WINDOW_DAYS, type SandboxSimulationScenario, type SecondReviewDeadline, type SecondReviewLineInput, type SendDuplicateBillInput, type SimulateSandboxBillInput, type SubmitBillInput, type SubmitNewBillInput, type SubmitSecondReviewInput, billTasksAgingBucketIndex, buildBillTasksDashboard, createBillLifecycleClient, createBillReferenceClient, createBillSubmissionClient, createOrganizationClient, createReportAutofillClient, createRfaClient, createRfaDraftActionsClient, createRfaLifecycleClient, createRfaPacketsClient, defaultBillReviewPayerOption, getRfaLifecycleStatus, normalizeRfaFax, organizationTaxIdWrite, parseSecondReviewCorrection, reportBillStatusContacts, rfaAuthorizationDestinations, rfaAuthorizationGuidance, sanitizeBillReviewSaveInput, secondReviewDeadline };
package/dist/index.js CHANGED
@@ -49,7 +49,7 @@ function normalizeRfaFax(value) {
49
49
  function rfaAuthorizationDestinations(directory) {
50
50
  if (!directory || ["adjuster_specific_required", "daisybill_unverified", "profile_not_published"].includes(directory.authorizationStatus ?? "")) return [];
51
51
  return (directory.authorization ?? []).flatMap((contact) => {
52
- const common = { label: contact.location || contact.name || "Authorization department", ...contact.phone ? { phone: contact.phone } : {} };
52
+ const common = { label: contact.location || contact.name || "Authorization department", ...contact.name ? { recipientName: contact.name } : {}, ...contact.phone ? { phone: contact.phone } : {} };
53
53
  const options = [];
54
54
  const fax = contact.fax ? normalizeRfaFax(contact.fax) : null;
55
55
  if (fax && contact.method !== "email") options.push({ ...common, method: "fax", destination: fax });
@@ -170,6 +170,12 @@ function createRfaLifecycleClient({ sessionEndpoint = "/api/mindbill/session", g
170
170
  if (!key.trim()) return Promise.reject(new Error("An idempotency key is required."));
171
171
  return readArray(path(id, `items/${encodeURIComponent(itemId)}/scheduling`), { method: "PATCH", headers: { "idempotency-key": key }, body: JSON.stringify(input) });
172
172
  },
173
+ updateTreatmentClosure: (id, itemId, input, key) => {
174
+ const reason = input.reason.trim();
175
+ if (!reason || reason.length > 2e3) return Promise.reject(new Error("Enter a reason of 1\u20132000 characters."));
176
+ if (!Number.isInteger(input.expectedVersion) || input.expectedVersion < 0) return Promise.reject(new Error("Refresh to load the current treatment version."));
177
+ return mutate(path(id, `items/${encodeURIComponent(itemId)}/closure`), { ...input, reason }, key, "PATCH");
178
+ },
173
179
  correctDecision: (id, input, key) => mutate(path(id, "decision-corrections"), input, key),
174
180
  listHistory: (id) => readArray(path(id, "events")),
175
181
  addNote: (id, text, key) => {
@@ -369,6 +375,32 @@ function createRfaPacketsClient({ sessionEndpoint = "/api/mindbill/session", get
369
375
  };
370
376
  }
371
377
 
378
+ // src/rfa-status.ts
379
+ var RFA_LIFECYCLE_LABELS = {
380
+ incomplete: "Incomplete",
381
+ sent: "Sent",
382
+ failed: "Failed",
383
+ received: "Received",
384
+ closed: "Closed",
385
+ canceled: "Canceled"
386
+ };
387
+ var timestamp = (value) => value ? Date.parse(value) || 0 : 0;
388
+ function getRfaLifecycleStatus(rfa) {
389
+ if (rfa.lifecycleStatus && Object.hasOwn(RFA_LIFECYCLE_LABELS, rfa.lifecycleStatus)) return rfa.lifecycleStatus;
390
+ if (rfa.status === "canceled") return "canceled";
391
+ if (["closed", "approved", "modified", "denied", "mixed"].includes(rfa.status)) return "closed";
392
+ const submissions = (rfa.transmissions ?? []).filter((value) => !value.purpose || value.purpose === "submission");
393
+ const latest = submissions.filter((value) => value.direction === "outbound").sort((a, b) => timestamp(b.occurredAt) - timestamp(a.occurredAt) || b.id.localeCompare(a.id))[0];
394
+ if (latest) {
395
+ const received = latest.receivedAt || submissions.some((value) => value.direction === "inbound" && value.status === "received" && timestamp(value.receivedAt ?? value.occurredAt) >= timestamp(latest.occurredAt));
396
+ if (received) return "received";
397
+ return latest.status === "failed" ? "failed" : "sent";
398
+ }
399
+ if (rfa.receivedAt || ["received", "under_review", "information_requested"].includes(rfa.status)) return "received";
400
+ if (rfa.submittedAt || rfa.status === "submitted") return "sent";
401
+ return "incomplete";
402
+ }
403
+
372
404
  // src/index.ts
373
405
  var DEFAULT_API_BASE_URL = "https://app.mindbill.org";
374
406
  var DEFAULT_SESSION_ENDPOINT = "/api/mindbill/session";
@@ -1326,6 +1358,7 @@ export {
1326
1358
  DEFAULT_API_BASE_URL,
1327
1359
  DEFAULT_SESSION_ENDPOINT,
1328
1360
  REPORT_BILL_STATUS_OPTIONS,
1361
+ RFA_LIFECYCLE_LABELS,
1329
1362
  SECOND_REVIEW_REASON_TEMPLATE,
1330
1363
  SECOND_REVIEW_WINDOW_DAYS,
1331
1364
  billTasksAgingBucketIndex,
@@ -1340,6 +1373,7 @@ export {
1340
1373
  createRfaLifecycleClient,
1341
1374
  createRfaPacketsClient,
1342
1375
  defaultBillReviewPayerOption,
1376
+ getRfaLifecycleStatus,
1343
1377
  normalizeRfaFax,
1344
1378
  organizationTaxIdWrite,
1345
1379
  parseSecondReviewCorrection,