@mindbill/react 0.23.2 → 0.24.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
@@ -152,10 +152,10 @@ The component includes the interaction model, not just the markup:
152
152
  - paste-friendly `MM/DD/YYYY` date fields and required-field asterisks;
153
153
  - ZIP-to-city/state completion through MindBill's authenticated postal directory;
154
154
  - complete, server-backed ICD-10 search with an alphabetized 100-code first page, automatic 100-code scroll paging, common-injury quick picks, and removable chips;
155
- - canonical claims-administrator search through the authenticated MindBill payer directory;
155
+ - canonical claims-administrator matching through the authenticated MindBill payer directory: exact aliases select automatically, while fuzzy matches show up to five explicit suggestions with claim-number pattern evidence;
156
156
  - QME, AME, and Psych QME evaluation modes with medical-legal modifier defaults; Psych QME also seeds `Z04.6` when no more specific diagnosis was supplied, and exposes it as a Psych quick pick;
157
157
  - searchable workers-comp procedure/modifier controls, medical-legal fee-schedule amounts, totals, valid manual CPT/HCPCS entry, and an automatically maintained empty line;
158
- - removable source documents with new-tab previews, a locked auto-attached practice W-9, and a full-width click, panel-drop, or whole-page PDF upload area. Every visible source document is included until removed; uploaded PDFs do not require document-type tagging.
158
+ - removable source documents with new-tab previews, a locked auto-attached practice W-9, and a full-width click, panel-drop, or whole-page PDF upload area. Med-legal mode assigns every document to `J4 - Med-Legal Report` without showing another control; professional mode shows the complete searchable PWK01 report-type directory. Override that presentation with `attachmentReportTypeMode`, `attachmentReportTypes`, and `defaultAttachmentReportType`.
159
159
 
160
160
  Partners supply tenant-specific bootstrap data, one short-lived browser session callback, and optionally an `onSubmitted` callback to persist the returned `billId`. Required fields, validation, ZIP lookup, ICD-10 and payer directories, service-line behavior, PDF encoding, wire-format serialization, atomic submission, attachments, and submission UX stay inside `@mindbill/react`, so every integration receives the same billing workflow. Optional `diagnosisOptions`, `procedureOptions`, `modifierOptions`, and lookup callbacks extend or replace defaults when a partner has licensed or organization-specific data.
161
161
 
package/dist/index.d.ts CHANGED
@@ -357,6 +357,13 @@ declare function BillReadOnlyForm({ data, appearance, className, style, onOpenAt
357
357
 
358
358
  declare const BILL_SUBMISSION_DOCUMENT_TYPES: readonly ["final_report", "proof_of_service", "letter_of_attestation", "form_122", "return_to_work_voucher", "w9", "medical_records", "appeal", "other"];
359
359
  type BillSubmissionDocumentType = (typeof BILL_SUBMISSION_DOCUMENT_TYPES)[number];
360
+ type BillSubmissionAttachmentReportTypeMode = "auto" | "hidden" | "visible";
361
+ type BillSubmissionReportTypeOption = {
362
+ code: string;
363
+ label: string;
364
+ };
365
+ declare const MED_LEGAL_REPORT_TYPE_CODE = "OZ:J4";
366
+ declare const BILL_SUBMISSION_REPORT_TYPES: readonly BillSubmissionReportTypeOption[];
360
367
  type BillSubmissionEvaluationType = "qme" | "ame" | "psych_qme";
361
368
  type BillSubmissionAddress = {
362
369
  line1: string;
@@ -459,15 +466,18 @@ type BillSubmissionSourceAttachment = {
459
466
  autoAttached?: boolean;
460
467
  removable?: boolean;
461
468
  previewUrl?: string;
469
+ reportTypeCode?: string;
462
470
  };
463
471
  type BillSubmissionUpload = {
464
472
  file: File;
465
473
  documentType: BillSubmissionDocumentType;
466
474
  description?: string;
475
+ reportTypeCode?: string;
467
476
  };
468
477
  type BillSubmissionFormValue = {
469
478
  bill: BillSubmissionInput;
470
479
  sourceAttachmentIds: string[];
480
+ sourceAttachmentReportTypes: Record<string, string>;
471
481
  uploads: BillSubmissionUpload[];
472
482
  };
473
483
  type BillSubmissionFormProps = {
@@ -491,6 +501,10 @@ type BillSubmissionFormProps = {
491
501
  onLookupPostalCode?: (postalCode: string) => Promise<BillSubmissionPostalPlace | null>;
492
502
  procedureOptions?: BillSubmissionProcedureOption[];
493
503
  modifierOptions?: BillSubmissionModifierOption[];
504
+ /** Auto hides and forces J4 for med-legal bills; treatment bills show the full report-type directory. */
505
+ attachmentReportTypeMode?: BillSubmissionAttachmentReportTypeMode;
506
+ attachmentReportTypes?: readonly BillSubmissionReportTypeOption[];
507
+ defaultAttachmentReportType?: string;
494
508
  appearance?: MindBillReactAppearance;
495
509
  className?: string;
496
510
  style?: CSSProperties;
@@ -509,10 +523,12 @@ type BillSubmissionValidation = {
509
523
  valid: boolean;
510
524
  fieldErrors: Record<string, string>;
511
525
  };
512
- declare function prepareBillSubmissionDocuments({ attachments, selectedIds, uploads, fetch: fetchOverride, }: {
526
+ declare function prepareBillSubmissionDocuments({ attachments, selectedIds, uploads, reportTypeCodeByAttachmentId, defaultReportTypeCode, fetch: fetchOverride, }: {
513
527
  attachments: BillSubmissionSourceAttachment[];
514
528
  selectedIds: string[];
515
529
  uploads: BillSubmissionUpload[];
530
+ reportTypeCodeByAttachmentId?: Record<string, string>;
531
+ defaultReportTypeCode?: string;
516
532
  fetch?: typeof globalThis.fetch;
517
533
  }): Promise<BrowserBillSubmissionDocument[]>;
518
534
  declare function ensureTrailingBillSubmissionLine(lines: BillSubmissionInput["serviceLines"]): BillSubmissionInput["serviceLines"];
@@ -523,6 +539,9 @@ declare const PSYCH_QME_DEFAULT_DIAGNOSIS = "Z04.6";
523
539
  /** Seed Psych QME's general examination code only when no diagnosis was supplied. */
524
540
  declare function applyBillSubmissionEvaluationDiagnoses(diagnoses: string[] | undefined, type: BillSubmissionEvaluationType): string[];
525
541
  declare function validateBillSubmission(bill: BillSubmissionInput): BillSubmissionValidation;
542
+ declare function normalizeClaimsAdministratorName(value: string): string;
543
+ declare function exactClaimsAdministratorMatch(results: BillReviewPayer$1[], suppliedName: string): BillReviewPayer$1 | undefined;
544
+ declare function claimsAdministratorRecommendations(results: BillReviewPayer$1[], limit?: number): BillReviewPayer$1[];
526
545
  type BillSubmissionSectionId = "header" | "patient" | "claim" | "providers" | "serviceLines" | "attachments" | "actions";
527
546
  declare function BillSubmissionHeader(): ReactElement;
528
547
  declare function BillSubmissionPatientSection(): ReactElement;
@@ -531,7 +550,7 @@ declare function BillSubmissionProvidersSection(): ReactElement;
531
550
  declare function BillSubmissionServiceLinesSection(): ReactElement;
532
551
  declare function BillSubmissionAttachmentsSection(): ReactElement;
533
552
  declare function BillSubmissionActions(): ReactElement;
534
- declare function BillSubmissionForm({ initialBill, attachments, onSubmit, onSubmitted, getSession, sessionEndpoint, apiBaseUrl, fetch: fetchOverride, onSearchClaimsAdministrators, diagnosisOptions, onSearchDiagnoses, onLookupPostalCode, procedureOptions, modifierOptions, appearance, className, style, disabled, submitLabel, heading, description, children, }: BillSubmissionFormProps): ReactElement;
553
+ declare function BillSubmissionForm({ initialBill, attachments, onSubmit, onSubmitted, getSession, sessionEndpoint, apiBaseUrl, fetch: fetchOverride, onSearchClaimsAdministrators, diagnosisOptions, onSearchDiagnoses, onLookupPostalCode, procedureOptions, modifierOptions, attachmentReportTypeMode, attachmentReportTypes, defaultAttachmentReportType, appearance, className, style, disabled, submitLabel, heading, description, children, }: BillSubmissionFormProps): ReactElement;
535
554
 
536
555
  /** Public-domain and MindBill-owned metadata. CPT descriptions are intentionally limited to the curated catalog. */
537
556
  declare const DEFAULT_BILL_SUBMISSION_PROCEDURES: BillSubmissionProcedureOption[];
@@ -793,4 +812,4 @@ type MindBillWidgetProps = {
793
812
  declare function MindBillBillTimeline(props: MindBillWidgetProps): ReactElement;
794
813
  declare function MindBillBillReview(props: MindBillWidgetProps): ReactElement;
795
814
 
796
- export { BILL_SUBMISSION_DIAGNOSIS_QUICK_PICKS, BILL_SUBMISSION_DOCUMENT_TYPES, BILL_SUBMISSION_REQUIRED_FIELDS, type BillActivityEvent, BillActivityTimeline, type BillActivityTimelineProps, type BillAgingBucket, type BillAgingBucketId, BillAgingSummary, type BillAgingSummaryProps, BillLifecycleActions, type BillLifecycleActionsProps, BillLifecycleProgress, type BillLifecycleProgressProps, type BillLifecycleStage, BillList, type BillListProps, BillPayerContactCard, type BillPayerContactCardProps, BillPaymentLedger, type BillPaymentLedgerProps, BillReadOnlyForm, type BillReadOnlyFormProps, BillRemittanceCard, type BillRemittanceCardProps, type BillReviewAttachment, type BillReviewBillingProvider, type BillReviewClinician, type BillReviewData, type BillReviewDocumentType, type BillReviewDraft, type BillReviewFeatures, BillReviewForm, type BillReviewFormProps, type BillReviewLineItem, type BillReviewLocation, type BillReviewPayer, type BillReviewSaveInput, BillSnapshotSummary, type BillSnapshotSummaryProps, type BillStatusAction, type BillStatusClient, type BillStatusClientOptions, type BillStatusData, type BillStatusSession, type BillStatusSessionProvider, type BillStatusSessionRequest, BillStatusSummary, type BillStatusSummaryProps, BillSubmissionActions, type BillSubmissionAddress, BillSubmissionAttachmentsSection, BillSubmissionClaimSection, type BillSubmissionDiagnosisOption, type BillSubmissionDocumentType, type BillSubmissionEvaluationType, BillSubmissionForm, type BillSubmissionFormProps, type BillSubmissionFormValue, BillSubmissionHeader, type BillSubmissionInput, type BillSubmissionModifierOption, BillSubmissionPatientSection, type BillSubmissionPostalPlace, type BillSubmissionProcedureOption, BillSubmissionProvidersSection, type BillSubmissionRoute, type BillSubmissionSectionId, BillSubmissionServiceLinesSection, type BillSubmissionSourceAttachment, type BillSubmissionUpload, type BillSubmissionValidation, type BillingComponentProps, BillingDashboard, type BillingDashboardBill, type BillingDashboardProps, type BillingDashboardSummary, BillingReport, type BillingReportDimension, type BillingReportProps, type BillingReportRow, ConnectedBillLifecycle, type ConnectedBillLifecycleProps, ConnectedBillStatus, type ConnectedBillStatusProps, DEFAULT_BILL_SUBMISSION_MODIFIERS, DEFAULT_BILL_SUBMISSION_PROCEDURES, MindBillBillReview, MindBillBillTimeline, type MindBillReactAppearance, type MindBillThemePreset, type MindBillWidgetProps, PSYCH_QME_DEFAULT_DIAGNOSIS, type UseBillLifecycleOptions, type UseBillLifecycleResult, type UseBillStatusOptions, type UseBillStatusResult, applyBillSubmissionEvaluationDiagnoses, applyBillSubmissionEvaluationModifiers, billActivityEventLabel, billAgingBucket, billAgingDays, billLifecycleDisplayLabel, billLifecycleStage, buildBillReviewSaveInput, buildBillingReportCsv, buildBillingReportRows, calculateBillSubmissionAllowedAmount, createBillStatusClient, ensureTrailingBillSubmissionLine, ensureTrailingProcedureLine, formatBillSubmissionDate, mindBillAppearanceStyle, mindBillThemePresets, parseBillSubmissionDate, prepareBillSubmissionDocuments, resolveMindBillAppearance, summarizeBillingDashboard, useBillLifecycle, useBillStatus, validateBillSubmission, visibleBillLifecycleActions };
815
+ export { BILL_SUBMISSION_DIAGNOSIS_QUICK_PICKS, BILL_SUBMISSION_DOCUMENT_TYPES, BILL_SUBMISSION_REPORT_TYPES, BILL_SUBMISSION_REQUIRED_FIELDS, type BillActivityEvent, BillActivityTimeline, type BillActivityTimelineProps, type BillAgingBucket, type BillAgingBucketId, BillAgingSummary, type BillAgingSummaryProps, BillLifecycleActions, type BillLifecycleActionsProps, BillLifecycleProgress, type BillLifecycleProgressProps, type BillLifecycleStage, BillList, type BillListProps, BillPayerContactCard, type BillPayerContactCardProps, BillPaymentLedger, type BillPaymentLedgerProps, BillReadOnlyForm, type BillReadOnlyFormProps, BillRemittanceCard, type BillRemittanceCardProps, type BillReviewAttachment, type BillReviewBillingProvider, type BillReviewClinician, type BillReviewData, type BillReviewDocumentType, type BillReviewDraft, type BillReviewFeatures, BillReviewForm, type BillReviewFormProps, type BillReviewLineItem, type BillReviewLocation, type BillReviewPayer, type BillReviewSaveInput, BillSnapshotSummary, type BillSnapshotSummaryProps, type BillStatusAction, type BillStatusClient, type BillStatusClientOptions, type BillStatusData, type BillStatusSession, type BillStatusSessionProvider, type BillStatusSessionRequest, BillStatusSummary, type BillStatusSummaryProps, BillSubmissionActions, type BillSubmissionAddress, type BillSubmissionAttachmentReportTypeMode, BillSubmissionAttachmentsSection, BillSubmissionClaimSection, type BillSubmissionDiagnosisOption, type BillSubmissionDocumentType, type BillSubmissionEvaluationType, BillSubmissionForm, type BillSubmissionFormProps, type BillSubmissionFormValue, BillSubmissionHeader, type BillSubmissionInput, type BillSubmissionModifierOption, BillSubmissionPatientSection, type BillSubmissionPostalPlace, type BillSubmissionProcedureOption, BillSubmissionProvidersSection, type BillSubmissionReportTypeOption, type BillSubmissionRoute, type BillSubmissionSectionId, BillSubmissionServiceLinesSection, type BillSubmissionSourceAttachment, type BillSubmissionUpload, type BillSubmissionValidation, type BillingComponentProps, BillingDashboard, type BillingDashboardBill, type BillingDashboardProps, type BillingDashboardSummary, BillingReport, type BillingReportDimension, type BillingReportProps, type BillingReportRow, ConnectedBillLifecycle, type ConnectedBillLifecycleProps, ConnectedBillStatus, type ConnectedBillStatusProps, DEFAULT_BILL_SUBMISSION_MODIFIERS, DEFAULT_BILL_SUBMISSION_PROCEDURES, MED_LEGAL_REPORT_TYPE_CODE, MindBillBillReview, MindBillBillTimeline, type MindBillReactAppearance, type MindBillThemePreset, type MindBillWidgetProps, PSYCH_QME_DEFAULT_DIAGNOSIS, type UseBillLifecycleOptions, type UseBillLifecycleResult, type UseBillStatusOptions, type UseBillStatusResult, applyBillSubmissionEvaluationDiagnoses, applyBillSubmissionEvaluationModifiers, billActivityEventLabel, billAgingBucket, billAgingDays, billLifecycleDisplayLabel, billLifecycleStage, buildBillReviewSaveInput, buildBillingReportCsv, buildBillingReportRows, calculateBillSubmissionAllowedAmount, claimsAdministratorRecommendations, createBillStatusClient, ensureTrailingBillSubmissionLine, ensureTrailingProcedureLine, exactClaimsAdministratorMatch, formatBillSubmissionDate, mindBillAppearanceStyle, mindBillThemePresets, normalizeClaimsAdministratorName, parseBillSubmissionDate, prepareBillSubmissionDocuments, resolveMindBillAppearance, summarizeBillingDashboard, useBillLifecycle, useBillStatus, validateBillSubmission, visibleBillLifecycleActions };
package/dist/index.js CHANGED
@@ -1294,6 +1294,79 @@ var BILL_SUBMISSION_DOCUMENT_TYPES = [
1294
1294
  "appeal",
1295
1295
  "other"
1296
1296
  ];
1297
+ var MED_LEGAL_REPORT_TYPE_CODE = "OZ:J4";
1298
+ var BILL_SUBMISSION_REPORT_TYPES = [
1299
+ { code: "OZ:J1", label: "Doctor's First Report (DLSR 5021)" },
1300
+ { code: "OZ:J2", label: "Supplemental Medical Report (BRs)" },
1301
+ { code: "OZ:J3", label: "Medical Permanent Impairment Report" },
1302
+ { code: MED_LEGAL_REPORT_TYPE_CODE, label: "Med-Legal Report" },
1303
+ { code: "OZ:J5", label: "Vocational Report" },
1304
+ { code: "OZ:J6", label: "Work Status Report" },
1305
+ { code: "OZ:J7", label: "Consultation Report" },
1306
+ { code: "OZ:J8", label: "Permanent Disability Report" },
1307
+ { code: "OZ:J9", label: "Itemized Statement" },
1308
+ { code: "03", label: "Justifying Treatment Beyond Utilization Guidelines" },
1309
+ { code: "04", label: "Drugs Administered" },
1310
+ { code: "05", label: "Treatment Diagnosis" },
1311
+ { code: "06", label: "Initial Assessment" },
1312
+ { code: "07", label: "Plan of Treatment" },
1313
+ { code: "08", label: "Plan of Treatment" },
1314
+ { code: "09", label: "PR2 (Progress Report)" },
1315
+ { code: "10", label: "Continued Treatment" },
1316
+ { code: "11", label: "Chemical Analysis" },
1317
+ { code: "13", label: "Certified Test Report" },
1318
+ { code: "15", label: "Justification for Admission" },
1319
+ { code: "21", label: "Recovery Plan" },
1320
+ { code: "A3", label: "Allergies/Sensitivities Document" },
1321
+ { code: "A4", label: "Autopsy Report" },
1322
+ { code: "AM", label: "Ambulance Certification" },
1323
+ { code: "AS", label: "Admission Summary" },
1324
+ { code: "B2", label: "Prescription" },
1325
+ { code: "B3", label: "Physician Order" },
1326
+ { code: "B4", label: "Referral Form" },
1327
+ { code: "BR", label: "Benchmark Testing Results" },
1328
+ { code: "BS", label: "Baseline" },
1329
+ { code: "BT", label: "Blanket Test Results" },
1330
+ { code: "CB", label: "Chiropractic Justification" },
1331
+ { code: "CK", label: "Canceled Check" },
1332
+ { code: "CT", label: "Certification" },
1333
+ { code: "D2", label: "Drug Profile Document" },
1334
+ { code: "DA", label: "Dental Models" },
1335
+ { code: "DB", label: "Durable Medical Equipment RX" },
1336
+ { code: "DG", label: "Diagnostic Report" },
1337
+ { code: "DJ", label: "Discharge Monitoring Report" },
1338
+ { code: "DS", label: "Discharge Summary" },
1339
+ { code: "EB", label: "Explanation of Benefits" },
1340
+ { code: "HC", label: "Health Clinic Records (HC)" },
1341
+ { code: "HR", label: "Health Clinic Records (HR)" },
1342
+ { code: "I5", label: "Immunization Record" },
1343
+ { code: "IR", label: "State School Immunization Records" },
1344
+ { code: "LA", label: "Laboratory Results" },
1345
+ { code: "M1", label: "Medical Record Attachment" },
1346
+ { code: "MT", label: "Nursing Notes" },
1347
+ { code: "NN", label: "Minor Deviation Request" },
1348
+ { code: "OB", label: "Operative Note" },
1349
+ { code: "OC", label: "Oxygen Content Averaging Report" },
1350
+ { code: "OD", label: "Orders and Treatments Document" },
1351
+ { code: "OE", label: "Objective Physical Examination Doc" },
1352
+ { code: "OX", label: "Oxygen Therapy Certification" },
1353
+ { code: "OZ", label: "Support Data for Bill" },
1354
+ { code: "P4", label: "Pathology Report" },
1355
+ { code: "P5", label: "Patient Medical History Document" },
1356
+ { code: "PE", label: "Periodontal Charts" },
1357
+ { code: "PN", label: "Physical Therapy Notes" },
1358
+ { code: "PO", label: "Prosthetics or Orthotic Certification" },
1359
+ { code: "PQ", label: "Paramedical Results" },
1360
+ { code: "PY", label: "Physician's Report" },
1361
+ { code: "PZ", label: "Physical Therapy Certification" },
1362
+ { code: "RB", label: "Radiology Films" },
1363
+ { code: "RR", label: "Radiology Reports" },
1364
+ { code: "RT", label: "Report of tests and Analysis Report" },
1365
+ { code: "RX", label: "Renewable Oxygen Content Averaging Report" },
1366
+ { code: "SG", label: "Symptoms Document" },
1367
+ { code: "V5", label: "Death Notification" },
1368
+ { code: "XP", label: "Photographs" }
1369
+ ];
1297
1370
  var BILL_SUBMISSION_REQUIRED_FIELDS = [
1298
1371
  "patient.firstName",
1299
1372
  "patient.lastName",
@@ -1344,6 +1417,8 @@ async function prepareBillSubmissionDocuments({
1344
1417
  attachments,
1345
1418
  selectedIds,
1346
1419
  uploads,
1420
+ reportTypeCodeByAttachmentId = {},
1421
+ defaultReportTypeCode,
1347
1422
  fetch: fetchOverride
1348
1423
  }) {
1349
1424
  const fetcher = fetchOverride ?? globalThis.fetch;
@@ -1357,12 +1432,14 @@ async function prepareBillSubmissionDocuments({
1357
1432
  externalId: attachment.id,
1358
1433
  filename: attachment.fileName,
1359
1434
  documentType: attachment.documentType,
1435
+ ...reportTypeCodeByAttachmentId[attachment.id] || attachment.reportTypeCode || defaultReportTypeCode ? { reportTypeCode: reportTypeCodeByAttachmentId[attachment.id] || attachment.reportTypeCode || defaultReportTypeCode } : {},
1360
1436
  ...attachment.description ? { description: attachment.description } : {}
1361
1437
  });
1362
1438
  }));
1363
- const uploadedDocuments = await Promise.all(uploads.map(({ file, documentType, description }) => pdfDocument(file, {
1439
+ const uploadedDocuments = await Promise.all(uploads.map(({ file, documentType, description, reportTypeCode }) => pdfDocument(file, {
1364
1440
  filename: file.name,
1365
1441
  documentType,
1442
+ ...reportTypeCode || defaultReportTypeCode ? { reportTypeCode: reportTypeCode || defaultReportTypeCode } : {},
1366
1443
  ...description ? { description } : {}
1367
1444
  })));
1368
1445
  return [...sourceDocuments, ...uploadedDocuments];
@@ -1482,13 +1559,14 @@ function validateBillSubmission(bill) {
1482
1559
  var css = `
1483
1560
  .mbsf{display:grid;gap:20px;color:var(--mb-text);font-family:var(--mb-font);font-size:15px}.mbsf *{box-sizing:border-box}
1484
1561
  .mbsf-head,.mbsf-section-head,.mbsf-attach-row,.mbsf-actions{display:flex;align-items:center;justify-content:space-between;gap:16px}.mbsf-title{margin:0;font-size:24px}.mbsf-copy,.mbsf-help{color:var(--mb-muted);margin:5px 0 0}.mbsf-required{font-size:13px;color:var(--mb-muted);white-space:nowrap}.mbsf-star,.mbsf-error{color:var(--mb-danger)}
1485
- .mbsf-card{min-width:0;margin:0;padding:24px;border:1px solid var(--mb-border);border-radius:var(--mb-radius);background:var(--mb-surface);box-shadow:var(--mb-shadow)}.mbsf-legend{padding:0 10px;font-size:18px;font-weight:760}.mbsf-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px 24px}.mbsf-span{grid-column:1/-1}.mbsf-field{display:grid;align-content:start;gap:7px;min-width:0}.mbsf-label{font-weight:680}.mbsf-input,.mbsf-select{width:100%;min-height:46px;padding:10px 12px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius);background:var(--mb-input);color:var(--mb-text);font:inherit}.mbsf-input:focus,.mbsf-select:focus{outline:3px solid color-mix(in srgb,var(--mb-accent) 22%,transparent);border-color:var(--mb-accent)}.mbsf-field[data-invalid=true] .mbsf-input,.mbsf-field[data-invalid=true] .mbsf-select,.mbsf-invalid-control .mbsf-input{border-color:var(--mb-danger);background:color-mix(in srgb,var(--mb-danger) 4%,var(--mb-input))}.mbsf-field[data-invalid=true] .mbsf-input:focus,.mbsf-field[data-invalid=true] .mbsf-select:focus{outline-color:color-mix(in srgb,var(--mb-danger) 24%,transparent)}
1562
+ .mbsf-card{min-width:0;margin:0;padding:24px;border:1px solid var(--mb-border);border-radius:var(--mb-radius);background:var(--mb-surface);box-shadow:var(--mb-shadow)}.mbsf-card[data-invalid=true]{border-color:var(--mb-danger)}.mbsf-legend{padding:0 10px;font-size:18px;font-weight:760}.mbsf-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px 24px}.mbsf-span{grid-column:1/-1}.mbsf-field{display:grid;align-content:start;gap:7px;min-width:0}.mbsf-label{font-weight:680}.mbsf-input,.mbsf-select{width:100%;min-height:46px;padding:10px 12px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius);background:var(--mb-input);color:var(--mb-text);font:inherit}.mbsf-input:focus,.mbsf-select:focus{outline:3px solid color-mix(in srgb,var(--mb-accent) 22%,transparent);border-color:var(--mb-accent)}.mbsf-field[data-invalid=true] .mbsf-input,.mbsf-field[data-invalid=true] .mbsf-select,.mbsf-invalid-control .mbsf-input{border-color:var(--mb-danger);background:color-mix(in srgb,var(--mb-danger) 4%,var(--mb-input))}.mbsf-field[data-invalid=true] .mbsf-input:focus,.mbsf-field[data-invalid=true] .mbsf-select:focus{outline-color:color-mix(in srgb,var(--mb-danger) 24%,transparent)}
1486
1563
  .mbsf-combo{position:relative}.mbsf-menu{position:absolute;z-index:20;top:calc(100% + 5px);left:0;right:0;max-height:min(360px,46vh);overflow:auto;overscroll-behavior:contain;padding:7px;border:1px solid var(--mb-border);border-radius:12px;background:var(--mb-surface);box-shadow:0 14px 35px rgba(17,38,49,.16)}.mbsf-option{display:grid;width:100%;gap:2px;padding:10px;border:0;border-radius:8px;background:transparent;color:var(--mb-text);font:inherit;text-align:left;cursor:pointer}.mbsf-option:hover,.mbsf-option:focus{background:color-mix(in srgb,var(--mb-accent) 9%,var(--mb-surface))}.mbsf-option small{color:var(--mb-muted)}.mbsf-menu-status{padding:12px;text-align:center;color:var(--mb-muted);font-size:13px}
1564
+ .mbsf-payer-status{display:flex;align-items:center;gap:7px;color:#087f5b;font-size:13px;font-weight:650}.mbsf-payer-intro{margin:4px 0 0;color:var(--mb-muted)}.mbsf-payer-list{display:grid;gap:8px}.mbsf-payer-option{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:11px 12px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius);background:color-mix(in srgb,var(--mb-accent) 3%,var(--mb-surface))}.mbsf-payer-option-main{display:grid;gap:5px;min-width:0}.mbsf-payer-option-main strong{overflow-wrap:anywhere}.mbsf-payer-signals{display:flex;flex-wrap:wrap;gap:6px}.mbsf-payer-signal{padding:2px 7px;border:1px solid var(--mb-border);border-radius:999px;color:var(--mb-muted);font-size:12px}.mbsf-payer-signal[data-state=match]{border-color:color-mix(in srgb,#159447 45%,var(--mb-border));color:#087f5b}.mbsf-payer-signal[data-state=warning]{border-color:color-mix(in srgb,#c56a00 55%,var(--mb-border));color:#9a5200}
1487
1565
  .mbsf-chips,.mbsf-quick-picks{display:flex;flex-wrap:wrap;gap:7px;margin-bottom:8px}.mbsf-chip,.mbsf-quick-pick{display:inline-flex;align-items:center;gap:7px;padding:5px 9px;border:1px solid var(--mb-border);border-radius:999px;background:var(--mb-input)}.mbsf-chip button{border:0;background:transparent;color:var(--mb-muted);cursor:pointer;font:inherit}.mbsf-quick-pick{color:var(--mb-text);font:inherit;cursor:pointer}.mbsf-quick-pick[data-selected=true]{border-color:var(--mb-accent);color:var(--mb-accent)}
1488
1566
  .mbsf-segments{display:grid;grid-template-columns:repeat(3,1fr);border:1px solid var(--mb-border);border-radius:var(--mb-control-radius);overflow:hidden}.mbsf-segment{min-height:44px;border:0;border-right:1px solid var(--mb-border);background:var(--mb-input);color:var(--mb-text);font:inherit;font-weight:700;cursor:pointer}.mbsf-segment:last-child{border-right:0}.mbsf-segment[aria-pressed=true]{background:var(--mb-accent);color:var(--mb-accent-contrast)}
1489
1567
  .mbsf-lines{margin-top:18px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius);overflow:visible}.mbsf-lines[data-invalid=true]{border-color:var(--mb-danger)}.mbsf-line-head,.mbsf-line{display:grid;grid-template-columns:minmax(190px,1.05fr) minmax(220px,1.5fr) 100px 120px 42px;gap:12px;align-items:start;padding:12px}.mbsf-line-head{color:var(--mb-muted);font-size:13px;font-weight:700;border-bottom:1px solid var(--mb-border)}.mbsf-line{border-bottom:1px solid var(--mb-border)}.mbsf-line:last-child{border-bottom:0}.mbsf-line [data-invalid=true] .mbsf-input{border-color:var(--mb-danger);background:color-mix(in srgb,var(--mb-danger) 4%,var(--mb-input))}.mbsf-money{padding-top:12px;text-align:right;font-variant-numeric:tabular-nums}.mbsf-total{display:flex;justify-content:flex-end;gap:45px;padding:16px 56px 16px 16px;font-size:17px;font-weight:760}
1490
- .mbsf-icon-btn{width:40px;height:42px;border:0;background:transparent;color:var(--mb-text);font-size:22px;cursor:pointer}.mbsf-secondary{min-height:40px;padding:8px 14px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius);background:var(--mb-surface);color:var(--mb-text);font:inherit;font-weight:680;cursor:pointer}.mbsf-attach-list{display:grid;gap:10px;margin-bottom:18px}.mbsf-attach-row{padding:14px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius)}.mbsf-attach-row[data-auto=true]{border-color:color-mix(in srgb,#159447 45%,var(--mb-border));background:color-mix(in srgb,#159447 5%,var(--mb-surface))}.mbsf-attach-main{display:flex;align-items:center;gap:12px;min-width:0;flex:1}.mbsf-attach-actions{display:flex;align-items:center;gap:6px;flex:0 0 auto}.mbsf-file{min-width:0}.mbsf-file strong{overflow-wrap:anywhere}.mbsf-badge{display:inline-block;margin-left:8px;padding:2px 7px;border:1px solid var(--mb-border);border-radius:7px;color:var(--mb-muted);font-size:12px;font-weight:600}.mbsf-drop{display:grid;width:100%;place-items:center;min-height:210px;padding:30px;border:2px dashed color-mix(in srgb,var(--mb-muted) 55%,transparent);border-radius:var(--mb-control-radius);background:color-mix(in srgb,var(--mb-accent) 3%,var(--mb-surface));color:var(--mb-text);font:inherit;text-align:center;cursor:pointer}.mbsf-drop[data-active=true]{border-color:var(--mb-accent);background:color-mix(in srgb,var(--mb-accent) 10%,var(--mb-surface))}.mbsf-alert{padding:12px 14px;border-radius:var(--mb-control-radius);background:color-mix(in srgb,var(--mb-danger) 10%,transparent);color:var(--mb-danger)}.mbsf-actions{justify-content:flex-end}.mbsf-submit{min-width:180px;min-height:48px;padding:11px 24px;border:0;border-radius:var(--mb-control-radius);background:var(--mb-accent);color:var(--mb-accent-contrast);font:inherit;font-weight:780;cursor:pointer}
1491
- @media(max-width:820px){.mbsf{gap:16px}.mbsf-grid{grid-template-columns:1fr}.mbsf-span{grid-column:auto}.mbsf-card{padding:18px 16px}.mbsf-line-head{display:none}.mbsf-line{position:relative;display:grid;grid-template-columns:minmax(0,1fr) 86px;gap:14px;padding:18px 16px}.mbsf-line>div:before{display:block;margin-bottom:6px;color:var(--mb-muted);font-size:12px;font-weight:700;content:attr(data-label)}.mbsf-line>div:nth-child(1),.mbsf-line>div:nth-child(2){grid-column:1/-1}.mbsf-money{align-self:end;padding:0 0 12px;text-align:right}.mbsf-line .mbsf-icon-btn{position:absolute;right:8px;bottom:3px}.mbsf-total{padding:16px 18px;gap:24px}.mbsf-head{align-items:flex-start}.mbsf-segments{grid-template-columns:repeat(3,minmax(0,1fr))}.mbsf-segment{min-width:0;padding:8px 4px;border-right:1px solid var(--mb-border);border-bottom:0;font-size:13px}.mbsf-segment:last-child{border-right:0}.mbsf-attach-row{align-items:flex-start;flex-wrap:wrap}.mbsf-attach-main{align-items:flex-start}.mbsf-attach-actions{margin-left:auto}.mbsf-drop{min-height:190px;padding:24px 18px}.mbsf-actions{position:sticky;bottom:86px;z-index:10}.mbsf-submit{width:100%}}
1568
+ .mbsf-icon-btn{width:40px;height:42px;border:0;background:transparent;color:var(--mb-text);font-size:22px;cursor:pointer}.mbsf-secondary{min-height:40px;padding:8px 14px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius);background:var(--mb-surface);color:var(--mb-text);font:inherit;font-weight:680;cursor:pointer}.mbsf-attach-list{display:grid;gap:10px;margin-bottom:18px}.mbsf-attach-row{padding:14px;border:1px solid var(--mb-border);border-radius:var(--mb-control-radius)}.mbsf-attach-row[data-auto=true]{border-color:color-mix(in srgb,#159447 45%,var(--mb-border));background:color-mix(in srgb,#159447 5%,var(--mb-surface))}.mbsf-attach-main{display:flex;align-items:center;gap:12px;min-width:0;flex:1}.mbsf-attach-type{width:min(360px,32vw);flex:0 1 360px}.mbsf-attach-type .mbsf-label{display:block;margin-bottom:6px;font-size:12px}.mbsf-attach-actions{display:flex;align-items:center;gap:6px;flex:0 0 auto}.mbsf-file{min-width:0}.mbsf-file strong{overflow-wrap:anywhere}.mbsf-badge{display:inline-block;margin-left:8px;padding:2px 7px;border:1px solid var(--mb-border);border-radius:7px;color:var(--mb-muted);font-size:12px;font-weight:600}.mbsf-drop{display:grid;width:100%;place-items:center;min-height:210px;padding:30px;border:2px dashed color-mix(in srgb,var(--mb-muted) 55%,transparent);border-radius:var(--mb-control-radius);background:color-mix(in srgb,var(--mb-accent) 3%,var(--mb-surface));color:var(--mb-text);font:inherit;text-align:center;cursor:pointer}.mbsf-drop[data-active=true]{border-color:var(--mb-accent);background:color-mix(in srgb,var(--mb-accent) 10%,var(--mb-surface))}.mbsf-alert{padding:12px 14px;border-radius:var(--mb-control-radius);background:color-mix(in srgb,var(--mb-danger) 10%,transparent);color:var(--mb-danger)}.mbsf-actions{justify-content:flex-end}.mbsf-submit{min-width:180px;min-height:48px;padding:11px 24px;border:0;border-radius:var(--mb-control-radius);background:var(--mb-accent);color:var(--mb-accent-contrast);font:inherit;font-weight:780;cursor:pointer}
1569
+ @media(max-width:820px){.mbsf{gap:16px}.mbsf-grid{grid-template-columns:1fr}.mbsf-span{grid-column:auto}.mbsf-card{padding:18px 16px}.mbsf-line-head{display:none}.mbsf-line{position:relative;display:grid;grid-template-columns:minmax(0,1fr) 86px;gap:14px;padding:18px 16px}.mbsf-line>div:before{display:block;margin-bottom:6px;color:var(--mb-muted);font-size:12px;font-weight:700;content:attr(data-label)}.mbsf-line>div:nth-child(1),.mbsf-line>div:nth-child(2){grid-column:1/-1}.mbsf-money{align-self:end;padding:0 0 12px;text-align:right}.mbsf-line .mbsf-icon-btn{position:absolute;right:8px;bottom:3px}.mbsf-total{padding:16px 18px;gap:24px}.mbsf-head{align-items:flex-start}.mbsf-segments{grid-template-columns:repeat(3,minmax(0,1fr))}.mbsf-segment{min-width:0;padding:8px 4px;border-right:1px solid var(--mb-border);border-bottom:0;font-size:13px}.mbsf-segment:last-child{border-right:0}.mbsf-payer-option{align-items:flex-start}.mbsf-attach-row{align-items:flex-start;flex-wrap:wrap}.mbsf-attach-main{align-items:flex-start;flex-basis:calc(100% - 150px)}.mbsf-attach-type{width:100%;flex-basis:100%;order:3}.mbsf-attach-actions{margin-left:auto}.mbsf-drop{min-height:190px;padding:24px 18px}.mbsf-actions{position:sticky;bottom:86px;z-index:10}.mbsf-submit{width:100%}}
1492
1570
  `;
1493
1571
  function RequiredMark() {
1494
1572
  return /* @__PURE__ */ jsx3("span", { className: "mbsf-star", children: " *" });
@@ -1522,7 +1600,7 @@ function TextDateInput({ value, onChange, disabled, required, ariaLabel }) {
1522
1600
  invalid ? /* @__PURE__ */ jsx3("small", { className: "mbsf-error", children: "Use MM/DD/YYYY" }) : null
1523
1601
  ] });
1524
1602
  }
1525
- function ComboBox({ value, placeholder, options, disabled, loading, loadingMore, invalid, onOpen, onQuery, onEndReached, onSelect, createOption, ariaLabel }) {
1603
+ function ComboBox({ value, placeholder, options, disabled, loading, loadingMore, invalid, preserveValueOnOpen = false, onOpen, onQuery, onEndReached, onSelect, createOption, ariaLabel }) {
1526
1604
  const [open, setOpen] = useState2(false);
1527
1605
  const [query, setQuery] = useState2("");
1528
1606
  const visible = useMemo2(() => {
@@ -1534,9 +1612,11 @@ function ComboBox({ value, placeholder, options, disabled, loading, loadingMore,
1534
1612
  const showMenu = open && (loading || visible.length > 0 || query.trim().length >= 2);
1535
1613
  return /* @__PURE__ */ jsxs3("div", { className: "mbsf-combo", children: [
1536
1614
  /* @__PURE__ */ jsx3("input", { className: "mbsf-input", role: "combobox", "aria-label": ariaLabel, "aria-invalid": invalid, "aria-expanded": showMenu, autoComplete: "off", disabled, placeholder, value: open ? query : value, onFocus: () => {
1615
+ const next = preserveValueOnOpen ? value : "";
1537
1616
  setOpen(true);
1538
- setQuery("");
1617
+ setQuery(next);
1539
1618
  onOpen?.();
1619
+ if (next) onQuery?.(next);
1540
1620
  }, onChange: (event) => {
1541
1621
  setOpen(true);
1542
1622
  setQuery(event.target.value);
@@ -1546,7 +1626,7 @@ function ComboBox({ value, placeholder, options, disabled, loading, loadingMore,
1546
1626
  const menu = event.currentTarget;
1547
1627
  if (menu.scrollHeight - menu.scrollTop - menu.clientHeight < 120) onEndReached?.();
1548
1628
  }, children: [
1549
- loading && !visible.length ? /* @__PURE__ */ jsx3("div", { className: "mbsf-menu-status", children: "Loading codes\u2026" }) : visible.length ? visible.map((option) => /* @__PURE__ */ jsxs3("button", { className: "mbsf-option", type: "button", role: "option", onMouseDown: (event) => event.preventDefault(), onClick: () => {
1629
+ loading && !visible.length ? /* @__PURE__ */ jsx3("div", { className: "mbsf-menu-status", children: "Loading\u2026" }) : visible.length ? visible.map((option) => /* @__PURE__ */ jsxs3("button", { className: "mbsf-option", type: "button", role: "option", onMouseDown: (event) => event.preventDefault(), onClick: () => {
1550
1630
  onSelect(option);
1551
1631
  setOpen(false);
1552
1632
  setQuery("");
@@ -1590,6 +1670,16 @@ function mergeOptions(defaults, supplied) {
1590
1670
  function mergeDiagnosisOptions(options) {
1591
1671
  return [...new Map(options.map((item) => [item.code.toUpperCase(), item])).values()].sort((left, right) => left.code.localeCompare(right.code, void 0, { numeric: true }));
1592
1672
  }
1673
+ function normalizeClaimsAdministratorName(value) {
1674
+ return value.toUpperCase().replace(/\[[^\]]*]/g, " ").replace(/\b(?:INCORPORATED|INC|COMPANY|CO|CORPORATION|CORP|GROUP|INSURANCE|SERVICES)\b/g, " ").replace(/[^A-Z0-9]+/g, " ").trim().replace(/\s+/g, " ");
1675
+ }
1676
+ function exactClaimsAdministratorMatch(results, suppliedName) {
1677
+ const normalized = normalizeClaimsAdministratorName(suppliedName);
1678
+ return results.find((payer) => normalizeClaimsAdministratorName(payer.name) === normalized) ?? results.find((payer) => payer.confidence === "high" && payer.recommended);
1679
+ }
1680
+ function claimsAdministratorRecommendations(results, limit = 5) {
1681
+ return [...results].sort((left, right) => Number(Boolean(right.recommended)) - Number(Boolean(left.recommended))).slice(0, Math.max(0, limit));
1682
+ }
1593
1683
  var BillSubmissionSectionsContext = createContext(null);
1594
1684
  function BillSubmissionSection({ id }) {
1595
1685
  const sections = useContext(BillSubmissionSectionsContext);
@@ -1632,6 +1722,9 @@ function BillSubmissionForm({
1632
1722
  onLookupPostalCode,
1633
1723
  procedureOptions,
1634
1724
  modifierOptions,
1725
+ attachmentReportTypeMode = "auto",
1726
+ attachmentReportTypes = BILL_SUBMISSION_REPORT_TYPES,
1727
+ defaultAttachmentReportType,
1635
1728
  appearance,
1636
1729
  className = "bill-submission-form",
1637
1730
  style,
@@ -1646,6 +1739,7 @@ function BillSubmissionForm({
1646
1739
  const [removedSourceIds, setRemovedSourceIds] = useState2([]);
1647
1740
  const [uploads, setUploads] = useState2([]);
1648
1741
  const [errors, setErrors] = useState2({});
1742
+ const [sourceAttachmentReportTypes, setSourceAttachmentReportTypes] = useState2(() => Object.fromEntries(attachments.flatMap((item) => item.reportTypeCode ? [[item.id, item.reportTypeCode]] : [])));
1649
1743
  const [validationActive, setValidationActive] = useState2(false);
1650
1744
  const [formError, setFormError] = useState2(null);
1651
1745
  const [submitting, setSubmitting] = useState2(false);
@@ -1662,6 +1756,7 @@ function BillSubmissionForm({
1662
1756
  const fileInput = useRef2(null);
1663
1757
  const diagnosisRequest = useRef2(0);
1664
1758
  const diagnosisAppendPending = useRef2(false);
1759
+ const payerRequest = useRef2(0);
1665
1760
  const procedures = useMemo2(() => mergeOptions(DEFAULT_BILL_SUBMISSION_PROCEDURES, procedureOptions), [procedureOptions]);
1666
1761
  const modifiers = useMemo2(() => mergeOptions(DEFAULT_BILL_SUBMISSION_MODIFIERS, modifierOptions), [modifierOptions]);
1667
1762
  const [evaluationType, setEvaluationType] = useState2(() => initialEvaluationType(initialBill));
@@ -1669,12 +1764,17 @@ function BillSubmissionForm({
1669
1764
  const referenceClient = useMemo2(() => getSession || sessionEndpoint || connected ? createBillReferenceClient({ getSession, sessionEndpoint, apiBaseUrl, fetch: fetchOverride }) : null, [getSession, sessionEndpoint, apiBaseUrl, fetchOverride, connected]);
1670
1765
  const submissionClient = useMemo2(() => connected ? createBillSubmissionClient({ getSession, sessionEndpoint, apiBaseUrl, fetch: fetchOverride }) : null, [getSession, sessionEndpoint, apiBaseUrl, fetchOverride, connected]);
1671
1766
  const locked = disabled || submitting;
1767
+ const showAttachmentReportTypes = attachmentReportTypeMode === "visible" || attachmentReportTypeMode === "auto" && bill.billingMode !== "med_legal";
1768
+ const forcedAttachmentReportType = showAttachmentReportTypes ? void 0 : defaultAttachmentReportType ?? MED_LEGAL_REPORT_TYPE_CODE;
1769
+ const reportTypeOptions = useMemo2(() => attachmentReportTypes.map((item) => ({ id: item.code, label: item.code.replace(/^OZ:/, ""), detail: item.label })), [attachmentReportTypes]);
1770
+ const missingAttachmentReportType = showAttachmentReportTypes && (selectedIds.some((id) => !(sourceAttachmentReportTypes[id] || attachments.find((item) => item.id === id)?.reportTypeCode || defaultAttachmentReportType)) || uploads.some((upload) => !(upload.reportTypeCode || defaultAttachmentReportType)));
1672
1771
  useEffect2(() => {
1673
1772
  setBill(cloneInitialBill(initialBill));
1674
1773
  setEvaluationType(initialEvaluationType(initialBill));
1675
1774
  setSelectedIds(attachments.map((item) => item.id));
1676
1775
  setRemovedSourceIds([]);
1677
1776
  setUploads([]);
1777
+ setSourceAttachmentReportTypes(Object.fromEntries(attachments.flatMap((item) => item.reportTypeCode ? [[item.id, item.reportTypeCode]] : [])));
1678
1778
  setErrors({});
1679
1779
  setValidationActive(false);
1680
1780
  setFormError(null);
@@ -1685,8 +1785,10 @@ function BillSubmissionForm({
1685
1785
  diagnosisAppendPending.current = false;
1686
1786
  }, [initialBill, attachments]);
1687
1787
  useEffect2(() => {
1688
- if (validationActive) setErrors(validateBillSubmission(bill).fieldErrors);
1689
- }, [bill, validationActive]);
1788
+ if (!validationActive) return;
1789
+ const next = validateBillSubmission(bill).fieldErrors;
1790
+ setErrors(missingAttachmentReportType ? { ...next, attachments: "Select a report type for every attachment." } : next);
1791
+ }, [bill, missingAttachmentReportType, validationActive]);
1690
1792
  const addFiles = useCallback((fileList) => {
1691
1793
  const files = Array.from(fileList);
1692
1794
  if (!files.length) return;
@@ -1698,8 +1800,8 @@ function BillSubmissionForm({
1698
1800
  const nextBytes = [...uploads.map((item) => item.file), ...files].reduce((sum, file) => sum + file.size, 0);
1699
1801
  if (nextBytes > MAX_UPLOAD_BYTES) return setFormError("Attachments exceed the 100 MB upload limit.");
1700
1802
  if (selectedIds.length + uploads.length + files.length > MAX_DOCUMENTS) return setFormError(`A bill can include at most ${MAX_DOCUMENTS} attachments.`);
1701
- setUploads((current) => [...current, ...files.map((file) => ({ file, documentType: "other" }))]);
1702
- }, [selectedIds.length, uploads]);
1803
+ setUploads((current) => [...current, ...files.map((file) => ({ file, documentType: "other", ...defaultAttachmentReportType ? { reportTypeCode: defaultAttachmentReportType } : {} }))]);
1804
+ }, [defaultAttachmentReportType, selectedIds.length, uploads]);
1703
1805
  useEffect2(() => {
1704
1806
  const over = (event) => {
1705
1807
  if (event.dataTransfer?.types.includes("Files")) {
@@ -1740,16 +1842,41 @@ function BillSubmissionForm({
1740
1842
  return next;
1741
1843
  })) }));
1742
1844
  const text = (value, onChange, options = {}) => /* @__PURE__ */ jsx3("input", { className: "mbsf-input", disabled: locked, value: value ?? "", onChange: (event) => onChange(event.target.value), ...options });
1743
- const searchPayers = (query) => {
1744
- if (query.trim().length < 2) return;
1745
- setPayerLoading(true);
1746
- const search = onSearchClaimsAdministrators ?? referenceClient?.searchClaimsAdministrators;
1747
- if (!search) {
1748
- setPayerLoading(false);
1845
+ const runPayerSearch = useCallback(async (query, autoSelect) => {
1846
+ const trimmed = query.trim();
1847
+ if (trimmed.length < 2) {
1848
+ setPayerResults([]);
1749
1849
  return;
1750
1850
  }
1751
- void search(query, bill.claim.claimNumber).then(setPayerResults).catch((caught) => setFormError(caught instanceof Error ? caught.message : "Claims administrator search is unavailable.")).finally(() => setPayerLoading(false));
1851
+ const search = onSearchClaimsAdministrators ?? referenceClient?.searchClaimsAdministrators;
1852
+ if (!search) return;
1853
+ const request = ++payerRequest.current;
1854
+ setPayerLoading(true);
1855
+ try {
1856
+ const results = await search(trimmed, bill.claim.claimNumber);
1857
+ if (request !== payerRequest.current) return;
1858
+ setPayerResults(results);
1859
+ const exact = autoSelect ? exactClaimsAdministratorMatch(results, trimmed) : void 0;
1860
+ if (exact) setBill((current) => ({ ...current, claim: { ...current.claim, claimsAdministrator: { id: exact.id, name: exact.name } } }));
1861
+ } catch (caught) {
1862
+ if (request === payerRequest.current) setFormError(caught instanceof Error ? caught.message : "Claims administrator search is unavailable.");
1863
+ } finally {
1864
+ if (request === payerRequest.current) setPayerLoading(false);
1865
+ }
1866
+ }, [bill.claim.claimNumber, onSearchClaimsAdministrators, referenceClient]);
1867
+ const searchPayers = (query) => {
1868
+ setBill((current) => {
1869
+ const selected = current.claim.claimsAdministrator;
1870
+ if (selected?.id && selected.name === query) return current;
1871
+ return { ...current, claim: { ...current.claim, claimsAdministrator: { name: query } } };
1872
+ });
1873
+ void runPayerSearch(query, true);
1752
1874
  };
1875
+ useEffect2(() => {
1876
+ const payer = bill.claim.claimsAdministrator;
1877
+ if (!payer?.name || payer.name.trim().length < 2) return;
1878
+ void runPayerSearch(payer.name, !payer.id);
1879
+ }, [bill.claim.claimsAdministrator?.id, bill.claim.claimsAdministrator?.name, bill.claim.claimNumber, runPayerSearch]);
1753
1880
  const loadDiagnoses = (query, append = false) => {
1754
1881
  const trimmed = query.trim();
1755
1882
  const search = onSearchDiagnoses ?? referenceClient?.searchDiagnosisCodes;
@@ -1811,12 +1938,13 @@ function BillSubmissionForm({
1811
1938
  return charge == null ? line : { ...line, charge };
1812
1939
  }) };
1813
1940
  const validation = validateBillSubmission(clean);
1941
+ const fieldErrors = missingAttachmentReportType ? { ...validation.fieldErrors, attachments: "Select a report type for every attachment." } : validation.fieldErrors;
1814
1942
  setValidationActive(true);
1815
- setErrors(validation.fieldErrors);
1943
+ setErrors(fieldErrors);
1816
1944
  setFormError(null);
1817
- if (!validation.valid) {
1818
- const count = Object.keys(validation.fieldErrors).length;
1819
- const first = Object.values(validation.fieldErrors)[0];
1945
+ if (Object.keys(fieldErrors).length) {
1946
+ const count = Object.keys(fieldErrors).length;
1947
+ const first = Object.values(fieldErrors)[0];
1820
1948
  setFormError(`Fix ${count} highlighted field${count === 1 ? "" : "s"} before submitting. ${first}`);
1821
1949
  window.requestAnimationFrame(() => {
1822
1950
  if (formRef.current) focusFirstInvalid(formRef.current);
@@ -1827,13 +1955,15 @@ function BillSubmissionForm({
1827
1955
  setSubmitting(true);
1828
1956
  try {
1829
1957
  if (onSubmit) {
1830
- await onSubmit({ bill: clean, sourceAttachmentIds: selectedIds, uploads });
1958
+ await onSubmit({ bill: clean, sourceAttachmentIds: selectedIds, sourceAttachmentReportTypes, uploads });
1831
1959
  } else {
1832
1960
  if (!submissionClient) throw new Error("The connected billing client is unavailable.");
1833
1961
  const documents = await prepareBillSubmissionDocuments({
1834
1962
  attachments,
1835
1963
  selectedIds,
1836
1964
  uploads,
1965
+ reportTypeCodeByAttachmentId: sourceAttachmentReportTypes,
1966
+ ...forcedAttachmentReportType ? { defaultReportTypeCode: forcedAttachmentReportType } : {},
1837
1967
  ...fetchOverride ? { fetch: fetchOverride } : {}
1838
1968
  });
1839
1969
  const result = await submissionClient.submitBill({ bill: clean, documents });
@@ -1845,7 +1975,10 @@ function BillSubmissionForm({
1845
1975
  setSubmitting(false);
1846
1976
  }
1847
1977
  }
1848
- const claimsAdministratorError = errors["claim.claimsAdministrator"] ?? (!bill.claim.claimsAdministrator?.id ? "Required for routing \u2014 search and select a claims administrator." : void 0);
1978
+ const claimsAdministratorError = errors["claim.claimsAdministrator"];
1979
+ const selectedPayer = payerResults.find((payer) => payer.id === bill.claim.claimsAdministrator?.id);
1980
+ const payerRecommendations = bill.claim.claimsAdministrator?.id ? [] : claimsAdministratorRecommendations(payerResults);
1981
+ const choosePayer = (payer) => setBill((current) => ({ ...current, claim: { ...current.claim, claimsAdministrator: { id: payer.id, name: payer.name } } }));
1849
1982
  const headerSection = /* @__PURE__ */ jsxs3("div", { className: "mbsf-head", children: [
1850
1983
  /* @__PURE__ */ jsxs3("div", { children: [
1851
1984
  /* @__PURE__ */ jsx3("h3", { className: "mbsf-title", children: heading }),
@@ -1881,7 +2014,38 @@ function BillSubmissionForm({
1881
2014
  /* @__PURE__ */ jsx3(Field2, { label: "Employer (optional)", children: text(bill.claim.employer, (employer) => setBill((c) => ({ ...c, claim: { ...c.claim, employer } }))) }),
1882
2015
  /* @__PURE__ */ jsx3(Field2, { path: "claim.claimNumber", label: "Claim number", required: true, error: errors["claim.claimNumber"], children: text(bill.claim.claimNumber, (claimNumber) => setBill((c) => ({ ...c, claim: { ...c.claim, claimNumber } }))) }),
1883
2016
  /* @__PURE__ */ jsx3(Field2, { label: "WCAB / ADJ number (optional)", children: text(bill.claim.adjNumber, (adjNumber) => setBill((c) => ({ ...c, claim: { ...c.claim, adjNumber } }))) }),
1884
- /* @__PURE__ */ jsx3(Field2, { path: "claim.claimsAdministrator", label: "Claims administrator", required: true, span: true, error: claimsAdministratorError, children: /* @__PURE__ */ jsx3(ComboBox, { ariaLabel: "Claims administrator", invalid: Boolean(claimsAdministratorError), disabled: locked, loading: payerLoading, value: bill.claim.claimsAdministrator?.name ?? "", placeholder: "Search the payer directory\u2026", options: payerResults.map((payer) => ({ id: payer.id, label: payer.name, detail: [payer.hasElectronic ? "Electronic" : "Work comp", ...payer.states ?? []].join(" \xB7 ") })), onQuery: searchPayers, onSelect: (option) => setBill((c) => ({ ...c, claim: { ...c.claim, claimsAdministrator: { id: option.id, name: option.label } } })) }) }),
2017
+ /* @__PURE__ */ jsxs3(Field2, { path: "claim.claimsAdministrator", label: "Claims administrator", required: true, span: true, error: claimsAdministratorError, children: [
2018
+ /* @__PURE__ */ jsx3(ComboBox, { ariaLabel: "Claims administrator", invalid: Boolean(claimsAdministratorError), disabled: locked, loading: payerLoading, preserveValueOnOpen: true, value: bill.claim.claimsAdministrator?.name ?? "", placeholder: "Search the payer directory\u2026", options: payerResults.map((payer) => ({ id: payer.id, label: payer.name, detail: [payer.hasElectronic ? "Electronic" : "Work comp", ...payer.states ?? []].join(" \xB7 ") })), onQuery: searchPayers, onSelect: (option) => choosePayer({ id: option.id, name: option.label }) }),
2019
+ selectedPayer ? /* @__PURE__ */ jsxs3("div", { className: "mbsf-payer-status", role: "status", children: [
2020
+ /* @__PURE__ */ jsx3("strong", { children: "\u2713 Routing match set:" }),
2021
+ " ",
2022
+ selectedPayer.name
2023
+ ] }) : null,
2024
+ selectedPayer?.signals?.length ? /* @__PURE__ */ jsx3("div", { className: "mbsf-payer-signals", children: selectedPayer.signals.map((signal, index) => /* @__PURE__ */ jsxs3("span", { "data-state": signal.state, children: [
2025
+ signal.state === "match" ? "\u2713" : "!",
2026
+ " ",
2027
+ signal.label
2028
+ ] }, `${signal.kind}-${index}`)) }) : null,
2029
+ !selectedPayer && payerRecommendations.length ? /* @__PURE__ */ jsxs3(Fragment2, { children: [
2030
+ /* @__PURE__ */ jsxs3("p", { className: "mbsf-payer-intro", children: [
2031
+ "Confirm the best routing match for ",
2032
+ /* @__PURE__ */ jsx3("strong", { children: bill.claim.claimsAdministrator?.name }),
2033
+ ":"
2034
+ ] }),
2035
+ /* @__PURE__ */ jsx3("div", { className: "mbsf-payer-list", children: payerRecommendations.map((payer) => /* @__PURE__ */ jsxs3("div", { className: "mbsf-payer-option", children: [
2036
+ /* @__PURE__ */ jsxs3("div", { className: "mbsf-payer-option-main", children: [
2037
+ /* @__PURE__ */ jsx3("strong", { children: payer.name }),
2038
+ payer.signals?.length ? /* @__PURE__ */ jsx3("div", { className: "mbsf-payer-signals", children: payer.signals.map((signal, index) => /* @__PURE__ */ jsxs3("span", { "data-state": signal.state, children: [
2039
+ signal.state === "match" ? "\u2713" : "!",
2040
+ " ",
2041
+ signal.label
2042
+ ] }, `${signal.kind}-${index}`)) }) : /* @__PURE__ */ jsx3("small", { className: "mbsf-help", children: "Directory match" })
2043
+ ] }),
2044
+ /* @__PURE__ */ jsx3("button", { className: "mbsf-secondary", type: "button", onClick: () => choosePayer(payer), children: "Use" })
2045
+ ] }, payer.id)) })
2046
+ ] }) : null,
2047
+ !selectedPayer && !payerLoading && !payerRecommendations.length && (bill.claim.claimsAdministrator?.name.trim().length ?? 0) >= 2 ? /* @__PURE__ */ jsx3("small", { className: "mbsf-help", children: "No confident route selected yet. Search the directory and choose a claims administrator." }) : null
2048
+ ] }),
1885
2049
  /* @__PURE__ */ jsx3(Field2, { label: "Injury description (optional)", span: true, children: text(bill.claim.description, (description2) => setBill((c) => ({ ...c, claim: { ...c.claim, description: description2 } }))) }),
1886
2050
  /* @__PURE__ */ jsxs3(Field2, { path: "diagnoses", label: "Diagnosis codes (ICD-10)", required: true, span: true, error: errors.diagnoses, children: [
1887
2051
  /* @__PURE__ */ jsx3("div", { className: "mbsf-quick-picks", "aria-label": "Common diagnosis codes", children: BILL_SUBMISSION_DIAGNOSIS_QUICK_PICKS.map((option) => {
@@ -1967,12 +2131,13 @@ function BillSubmissionForm({
1967
2131
  ] }),
1968
2132
  errors.serviceLines ? /* @__PURE__ */ jsx3("p", { className: "mbsf-error", role: "alert", children: errors.serviceLines }) : null
1969
2133
  ] });
1970
- const attachmentsSection = /* @__PURE__ */ jsxs3("fieldset", { className: "mbsf-card", disabled: locked, children: [
2134
+ const attachmentsSection = /* @__PURE__ */ jsxs3("fieldset", { className: "mbsf-card", "data-field-path": "attachments", "data-invalid": Boolean(errors.attachments), disabled: locked, children: [
1971
2135
  /* @__PURE__ */ jsx3("legend", { className: "mbsf-legend", children: "Attachments" }),
1972
2136
  /* @__PURE__ */ jsxs3("div", { className: "mbsf-attach-list", children: [
1973
2137
  attachments.filter((attachment) => !removedSourceIds.includes(attachment.id)).map((attachment) => {
1974
2138
  const auto = attachment.autoAttached || attachment.documentType === "w9";
1975
2139
  const removable = !auto && attachment.removable !== false;
2140
+ const reportTypeCode = sourceAttachmentReportTypes[attachment.id] || attachment.reportTypeCode || defaultAttachmentReportType || "";
1976
2141
  return /* @__PURE__ */ jsxs3("div", { className: "mbsf-attach-row", "data-auto": auto, children: [
1977
2142
  /* @__PURE__ */ jsxs3("div", { className: "mbsf-attach-main", children: [
1978
2143
  auto ? /* @__PURE__ */ jsx3("span", { "aria-label": "Always attached", role: "img", children: "\u2713" }) : null,
@@ -1982,6 +2147,7 @@ function BillSubmissionForm({
1982
2147
  /* @__PURE__ */ jsx3("span", { className: "mbsf-help", style: { display: "block" }, children: attachment.description || (auto ? "Included automatically with every bill." : documentLabels[attachment.documentType]) })
1983
2148
  ] })
1984
2149
  ] }),
2150
+ showAttachmentReportTypes ? /* @__PURE__ */ jsx3("div", { className: "mbsf-attach-type", children: /* @__PURE__ */ jsx3(ComboBox, { ariaLabel: `Report type for ${attachment.fileName}`, invalid: !reportTypeCode, disabled: locked, preserveValueOnOpen: true, value: reportTypeCode, placeholder: "Select report type\u2026", options: reportTypeOptions, onSelect: (option) => setSourceAttachmentReportTypes((current) => ({ ...current, [attachment.id]: option.id })) }) }) : null,
1985
2151
  /* @__PURE__ */ jsxs3("div", { className: "mbsf-attach-actions", children: [
1986
2152
  attachment.previewUrl ? /* @__PURE__ */ jsx3("a", { className: "mbsf-secondary", href: attachment.previewUrl, target: "_blank", rel: "noopener noreferrer", children: "Preview" }) : null,
1987
2153
  removable ? /* @__PURE__ */ jsx3("button", { className: "mbsf-icon-btn", type: "button", "aria-label": `Remove ${attachment.fileName}`, disabled: locked, onClick: () => {
@@ -1991,20 +2157,25 @@ function BillSubmissionForm({
1991
2157
  ] })
1992
2158
  ] }, attachment.id);
1993
2159
  }),
1994
- uploads.map((upload, index) => /* @__PURE__ */ jsxs3("div", { className: "mbsf-attach-row", children: [
1995
- /* @__PURE__ */ jsx3("div", { className: "mbsf-attach-main", children: /* @__PURE__ */ jsxs3("span", { className: "mbsf-file", children: [
1996
- /* @__PURE__ */ jsx3("strong", { children: upload.file.name }),
1997
- /* @__PURE__ */ jsxs3("span", { className: "mbsf-help", style: { display: "block" }, children: [
1998
- (upload.file.size / 1024 / 1024).toFixed(1),
1999
- " MB"
2160
+ uploads.map((upload, index) => {
2161
+ const reportTypeCode = upload.reportTypeCode || defaultAttachmentReportType || "";
2162
+ return /* @__PURE__ */ jsxs3("div", { className: "mbsf-attach-row", children: [
2163
+ /* @__PURE__ */ jsx3("div", { className: "mbsf-attach-main", children: /* @__PURE__ */ jsxs3("span", { className: "mbsf-file", children: [
2164
+ /* @__PURE__ */ jsx3("strong", { children: upload.file.name }),
2165
+ /* @__PURE__ */ jsxs3("span", { className: "mbsf-help", style: { display: "block" }, children: [
2166
+ (upload.file.size / 1024 / 1024).toFixed(1),
2167
+ " MB"
2168
+ ] })
2169
+ ] }) }),
2170
+ showAttachmentReportTypes ? /* @__PURE__ */ jsx3("div", { className: "mbsf-attach-type", children: /* @__PURE__ */ jsx3(ComboBox, { ariaLabel: `Report type for ${upload.file.name}`, invalid: !reportTypeCode, disabled: locked, preserveValueOnOpen: true, value: reportTypeCode, placeholder: "Select report type\u2026", options: reportTypeOptions, onSelect: (option) => setUploads((current) => current.map((item, itemIndex) => itemIndex === index ? { ...item, reportTypeCode: option.id } : item)) }) }) : null,
2171
+ /* @__PURE__ */ jsxs3("div", { className: "mbsf-attach-actions", children: [
2172
+ /* @__PURE__ */ jsx3("button", { className: "mbsf-secondary", type: "button", onClick: () => previewUploadedPdf(upload.file), children: "Preview" }),
2173
+ /* @__PURE__ */ jsx3("button", { className: "mbsf-icon-btn", type: "button", "aria-label": `Remove ${upload.file.name}`, onClick: () => setUploads((current) => current.filter((_, itemIndex) => itemIndex !== index)), children: "\xD7" })
2000
2174
  ] })
2001
- ] }) }),
2002
- /* @__PURE__ */ jsxs3("div", { className: "mbsf-attach-actions", children: [
2003
- /* @__PURE__ */ jsx3("button", { className: "mbsf-secondary", type: "button", onClick: () => previewUploadedPdf(upload.file), children: "Preview" }),
2004
- /* @__PURE__ */ jsx3("button", { className: "mbsf-icon-btn", type: "button", "aria-label": `Remove ${upload.file.name}`, onClick: () => setUploads((current) => current.filter((_, itemIndex) => itemIndex !== index)), children: "\xD7" })
2005
- ] })
2006
- ] }, `${upload.file.name}-${index}`))
2175
+ ] }, `${upload.file.name}-${index}`);
2176
+ })
2007
2177
  ] }),
2178
+ errors.attachments ? /* @__PURE__ */ jsx3("p", { className: "mbsf-error", role: "alert", children: errors.attachments }) : null,
2008
2179
  /* @__PURE__ */ jsx3("input", { ref: fileInput, hidden: true, type: "file", accept: "application/pdf,.pdf", multiple: true, onChange: (event) => {
2009
2180
  if (event.target.files) addFiles(event.target.files);
2010
2181
  event.target.value = "";
@@ -3256,6 +3427,7 @@ function MindBillBillReview(props) {
3256
3427
  export {
3257
3428
  BILL_SUBMISSION_DIAGNOSIS_QUICK_PICKS,
3258
3429
  BILL_SUBMISSION_DOCUMENT_TYPES,
3430
+ BILL_SUBMISSION_REPORT_TYPES,
3259
3431
  BILL_SUBMISSION_REQUIRED_FIELDS,
3260
3432
  BillActivityTimeline,
3261
3433
  BillAgingSummary,
@@ -3283,6 +3455,7 @@ export {
3283
3455
  ConnectedBillStatus,
3284
3456
  DEFAULT_BILL_SUBMISSION_MODIFIERS,
3285
3457
  DEFAULT_BILL_SUBMISSION_PROCEDURES,
3458
+ MED_LEGAL_REPORT_TYPE_CODE,
3286
3459
  MindBillBillReview,
3287
3460
  MindBillBillTimeline,
3288
3461
  PSYCH_QME_DEFAULT_DIAGNOSIS,
@@ -3297,13 +3470,16 @@ export {
3297
3470
  buildBillingReportCsv,
3298
3471
  buildBillingReportRows,
3299
3472
  calculateBillSubmissionAllowedAmount,
3473
+ claimsAdministratorRecommendations,
3300
3474
  createBillLifecycleClient2 as createBillLifecycleClient,
3301
3475
  createBillStatusClient,
3302
3476
  ensureTrailingBillSubmissionLine,
3303
3477
  ensureTrailingProcedureLine,
3478
+ exactClaimsAdministratorMatch,
3304
3479
  formatBillSubmissionDate,
3305
3480
  mindBillAppearanceStyle,
3306
3481
  mindBillThemePresets,
3482
+ normalizeClaimsAdministratorName,
3307
3483
  parseBillSubmissionDate,
3308
3484
  prepareBillSubmissionDocuments,
3309
3485
  resolveMindBillAppearance,