@mindbill/react 0.54.0 → 0.55.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.js CHANGED
@@ -2336,6 +2336,18 @@ var BILL_SUBMISSION_REPORT_TYPES = [
2336
2336
  { code: "V5", label: "Death Notification" },
2337
2337
  { code: "XP", label: "Photographs" }
2338
2338
  ];
2339
+ function billSubmissionEstimateContext(code, placeOfService, details = {}) {
2340
+ if (details.basis === "adjustment") return {};
2341
+ if (/^992(?:0[2-5]|1[2-5])$/.test(code) && details.providerKind && details.providerKind !== "physical_therapist") return {
2342
+ hasFeeAgreement: false,
2343
+ physicianContext: { providerKind: details.providerKind, placeOfService, incidentToPhysicianService: false, standaloneService: true, globalPeriodApplies: false, hpsaBonusEligible: false }
2344
+ };
2345
+ if (code === "97110" && (details.providerKind === "physical_therapist" || details.providerKind === "other") && details.minutes && details.totalMinutes) return {
2346
+ hasFeeAgreement: false,
2347
+ therapyContext: { providerKind: details.providerKind, personallyPerformed: true, hospitalPatient: false, incidentToPhysicianService: false, assistantInvolved: false, placeOfService, directOneOnOneMinutes: details.minutes, totalVisitMinutes: details.totalMinutes, visitsOnDate: 1, completeSameDayServices: true, otherSameDayServices: false, globalPeriodApplies: false, hpsaBonusEligible: false }
2348
+ };
2349
+ return {};
2350
+ }
2339
2351
  var isMedicalLegalCode = (code) => /^ML/i.test(code.trim());
2340
2352
  function billSubmissionFeeRequest(bill, line, context = {}) {
2341
2353
  const dateOfService = parseBillSubmissionDate(line.serviceDate ?? bill.service.date) ?? "";
@@ -2533,27 +2545,33 @@ function remapBillSubmissionDiagnoses(bill, nextCodes) {
2533
2545
  }) } : {}
2534
2546
  })) };
2535
2547
  }
2536
- function setBillSubmissionLineDiagnosis(bill, lineIndex, slot, code) {
2537
- if (!bill.serviceLines[lineIndex] || slot < 0 || slot > 3) return bill;
2538
- const diagnoses = [...bill.diagnoses ?? []];
2539
- const normalized = code.trim().toUpperCase();
2540
- if (normalized && !diagnoses.includes(normalized)) {
2541
- if (diagnoses.length >= 12) return bill;
2542
- diagnoses.push(normalized);
2543
- }
2544
- return { ...bill, diagnoses, serviceLines: bill.serviceLines.map((line, index) => {
2545
- if (index !== lineIndex) return line;
2546
- const pointers = [...line.diagnosisPointers ?? []];
2547
- if (normalized) pointers[slot] = diagnoses.indexOf(normalized) + 1;
2548
- else pointers.splice(slot, 1);
2549
- return { ...line, diagnosisPointers: [...new Set(pointers.filter((pointer) => Number.isInteger(pointer) && pointer > 0))].slice(0, 4) };
2550
- }) };
2548
+ function billSubmissionLineDiagnosisCodes(bill, index) {
2549
+ return (bill.serviceLines[index]?.diagnosisPointers ?? []).flatMap((pointer) => bill.diagnoses?.[pointer - 1] ? [bill.diagnoses[pointer - 1].trim().toUpperCase()] : []);
2550
+ }
2551
+ function billSubmissionUsesSharedDiagnoses(bill) {
2552
+ const codes = (bill.diagnoses ?? []).map((code) => code.trim().toUpperCase());
2553
+ if (codes.length > 4) return false;
2554
+ return bill.serviceLines.filter((line) => line.code.trim() && line.diagnosisPointers !== void 0).every((line) => JSON.stringify(line.diagnosisPointers?.map((pointer) => codes[pointer - 1])) === JSON.stringify(codes));
2555
+ }
2556
+ function setBillSubmissionDiagnosisAssignments(bill, assignments) {
2557
+ const normalized = bill.serviceLines.map((_, index) => [...new Set((assignments[index] ?? []).map((code) => code.trim().toUpperCase()).filter(Boolean))]);
2558
+ const selected = [...new Set(normalized.flat())];
2559
+ if (selected.length > 12 || normalized.some((codes) => codes.length > 4)) return bill;
2560
+ const diagnoses = [.../* @__PURE__ */ new Set([...(bill.diagnoses ?? []).map((code) => code.trim().toUpperCase()).filter((code) => selected.includes(code)), ...selected])];
2561
+ return { ...bill, diagnoses, serviceLines: bill.serviceLines.map((line, index) => ({ ...line, diagnosisPointers: normalized[index].map((code) => diagnoses.indexOf(code) + 1) })) };
2562
+ }
2563
+ function setBillSubmissionSharedDiagnoses(bill, codes) {
2564
+ return setBillSubmissionDiagnosisAssignments(bill, bill.serviceLines.map(() => codes));
2565
+ }
2566
+ function setBillSubmissionLineDiagnoses(bill, index, codes) {
2567
+ if (!bill.serviceLines[index]) return bill;
2568
+ return setBillSubmissionDiagnosisAssignments(bill, bill.serviceLines.map((_, lineIndex) => lineIndex === index ? codes : billSubmissionLineDiagnosisCodes(bill, lineIndex)));
2551
2569
  }
2552
2570
  function cloneInitialBill(bill, treatmentBilling = false) {
2553
2571
  const cloned = cloneBill(bill);
2554
2572
  if (treatmentBilling && cloned.serviceLines.some((line) => line.code.trim() && !isMedicalLegalCode(line.code))) cloned.billingMode = "professional";
2555
2573
  if (cloned.billingMode !== "professional") cloned.diagnoses = applyBillSubmissionEvaluationDiagnoses(cloned.diagnoses, initialEvaluationType(bill));
2556
- return cloned;
2574
+ return billSubmissionUsesSharedDiagnoses(cloned) ? setBillSubmissionSharedDiagnoses(cloned, cloned.diagnoses ?? []) : cloned;
2557
2575
  }
2558
2576
  function stableInitializationValue(value) {
2559
2577
  if (Array.isArray(value)) return value.map(stableInitializationValue);
@@ -2661,9 +2679,10 @@ var css3 = `
2661
2679
  .mbsf-source-evidence{display:grid;gap:4px;color:var(--mb-muted);font-size:13px}.mbsf-source-evidence a{color:var(--mb-accent);font-weight:700}.mbsf-source-evidence q{color:var(--mb-text)}.mbsf-suggestions{display:flex;align-items:center;flex-wrap:wrap;gap:7px;color:var(--mb-muted);font-size:13px}.mbsf-suggestion{padding:5px 10px;border:1px solid color-mix(in srgb,var(--mb-accent) 55%,var(--mb-border));border-radius:999px;background:color-mix(in srgb,var(--mb-accent) 7%,var(--mb-surface));color:var(--mb-accent);font:inherit;font-weight:700;cursor:pointer}.mbsf-suggestion:hover,.mbsf-suggestion:focus{outline:2px solid color-mix(in srgb,var(--mb-accent) 25%,transparent)}.mbsf-claim-patterns{display:grid;gap:4px;margin-top:2px;font-size:13px}.mbsf-claim-patterns[data-state=match]{color:#087f5b}.mbsf-claim-patterns[data-state=warning]{color:#9a5200}.mbsf-claim-pattern-list{color:var(--mb-muted)}
2662
2680
  .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)}
2663
2681
  .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)}
2664
- .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(190px,1.3fr) minmax(180px,1fr) 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-line-diagnoses{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;position:relative}.mbsf-line-diagnoses .mbsf-combo{position:static;min-width:0}.mbsf-line-diagnoses .mbsf-menu{left:0;right:0;min-width:100%}.mbsf-line-diagnoses .mbsf-input{padding:10px 6px;font-size:16px}.mbsf-fee-details{grid-column:1/-1;font-size:14px;color:var(--mb-muted);padding:8px 0}.mbsf-fee-details summary{cursor:pointer;font-weight:600}.mbsf-fee-details[open]{display:grid;gap:12px}.mbsf-fee-confirm{display:flex;gap:10px;align-items:flex-start;line-height:1.5}.mbsf-fee-confirm input{margin-top:4px}.mbsf-dx{display:flex;flex-wrap:wrap;gap:5px;padding-top:6px}.mbsf-dx-chip{width:30px;height:30px;border:1px solid var(--mb-border);border-radius:8px;background:var(--mb-surface);color:var(--mb-muted);font:inherit;font-size:13px;font-weight:750;cursor:pointer}.mbsf-dx-chip[data-active=true]{border-color:var(--mb-accent);background:color-mix(in srgb,var(--mb-accent) 10%,var(--mb-surface));color:var(--mb-accent)}.mbsf-total{display:flex;justify-content:flex-end;gap:45px;padding:16px 56px 16px 16px;font-size:17px;font-weight:760}
2682
+ .mbsf-lines{min-width:0;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(190px,1.3fr) minmax(180px,1fr) 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-line-diagnoses{min-width:0;position:relative}.mbsf-diagnosis-select{min-width:0}.mbsf-diagnosis-select .mbsf-chip{max-width:100%;align-items:flex-start}.mbsf-diagnosis-select .mbsf-chip>span{min-width:0;overflow-wrap:anywhere}.mbsf-diagnosis-toggle{display:flex;align-items:flex-start;gap:10px;margin:18px 0;line-height:1.5}.mbsf-diagnosis-toggle input{margin-top:4px}.mbsf-lines[data-shared-diagnoses=true]>.mbsf-line,.mbsf-lines[data-shared-diagnoses=true]>.mbsf-line-head{grid-template-columns:minmax(190px,1.05fr) minmax(190px,1.3fr) 100px 120px 42px}.mbsf-line-diagnoses .mbsf-combo{position:static;min-width:0}.mbsf-line-diagnoses .mbsf-menu{left:0;right:0;min-width:100%}.mbsf-line-diagnoses .mbsf-input{padding:10px 6px;font-size:16px}.mbsf-fee-details{min-width:0;grid-column:1/-1;font-size:14px;color:var(--mb-muted);padding:8px 0}.mbsf-fee-details summary{cursor:pointer;font-weight:600}.mbsf-fee-details details[open]{display:grid;gap:12px}.mbsf-fee-details>.mbsf-field{max-width:320px}.mbsf-fee-confirm{display:flex;gap:10px;align-items:flex-start;line-height:1.5}.mbsf-fee-confirm input{margin-top:4px}.mbsf-dx{display:flex;flex-wrap:wrap;gap:5px;padding-top:6px}.mbsf-dx-chip{width:30px;height:30px;border:1px solid var(--mb-border);border-radius:8px;background:var(--mb-surface);color:var(--mb-muted);font:inherit;font-size:13px;font-weight:750;cursor:pointer}.mbsf-dx-chip[data-active=true]{border-color:var(--mb-accent);background:color-mix(in srgb,var(--mb-accent) 10%,var(--mb-surface));color:var(--mb-accent)}.mbsf-total{display:flex;justify-content:flex-end;gap:45px;padding:16px 56px 16px 16px;font-size:17px;font-weight:760}
2665
2683
  .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}
2666
- @media(max-width:820px){.mbsf-line-diagnoses{grid-template-columns:repeat(4,minmax(0,1fr))}.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),.mbsf-line>div:nth-child(3){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.mbsf-lifecycle-correction .mbsf-actions{position:static;bottom:auto}.mbsf-submit{width:100%}}
2684
+ .mbsf-lines[data-stacked=true] .mbsf-line-head,.mbsf-lines[data-stacked=true][data-shared-diagnoses=true]>.mbsf-line-head{display:none}.mbsf-lines[data-stacked=true] .mbsf-line,.mbsf-lines[data-stacked=true][data-shared-diagnoses=true]>.mbsf-line{position:relative;display:grid;grid-template-columns:minmax(0,1fr) 86px;gap:14px;padding:18px 16px}.mbsf-lines[data-stacked=true] .mbsf-line>div:before{display:block;margin-bottom:6px;color:var(--mb-muted);font-size:12px;font-weight:700;content:attr(data-label)}.mbsf-lines[data-stacked=true] .mbsf-line>div:nth-child(1),.mbsf-lines[data-stacked=true] .mbsf-line>div:nth-child(2),.mbsf-lines[data-stacked=true] .mbsf-line>.mbsf-line-diagnoses{grid-column:1/-1}.mbsf-lines[data-stacked=true] .mbsf-money{align-self:end;padding:0 0 12px;text-align:right}.mbsf-lines[data-stacked=true] .mbsf-line .mbsf-icon-btn{position:absolute;right:8px;bottom:3px}.mbsf-lines[data-stacked=true] .mbsf-total{padding:16px 18px;gap:24px}
2685
+ @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,.mbsf-lines[data-shared-diagnoses=true]>.mbsf-line-head{display:none}.mbsf-line,.mbsf-lines[data-shared-diagnoses=true]>.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),.mbsf-line>.mbsf-line-diagnoses{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.mbsf-lifecycle-correction .mbsf-actions{position:static;bottom:auto}.mbsf-submit{width:100%}}
2667
2686
  `;
2668
2687
  function RequiredMark() {
2669
2688
  return /* @__PURE__ */ jsx6("span", { className: "mbsf-star", children: " *" });
@@ -2888,6 +2907,8 @@ function BillSubmissionForm({
2888
2907
  children
2889
2908
  }) {
2890
2909
  const [bill, setBill] = useState6(() => cloneInitialBill(initialBill, treatmentBilling));
2910
+ const [sharedDiagnoses, setSharedDiagnoses] = useState6(() => billSubmissionUsesSharedDiagnoses(cloneInitialBill(initialBill, treatmentBilling)));
2911
+ const individualDiagnoses = useRef3(null);
2891
2912
  const [providerEditing, setProviderEditing] = useState6(false);
2892
2913
  const [selectedIds, setSelectedIds] = useState6(() => attachments.map((item) => item.id));
2893
2914
  const [removedSourceIds, setRemovedSourceIds] = useState6([]);
@@ -2923,6 +2944,18 @@ function BillSubmissionForm({
2923
2944
  const [feeQuotes, setFeeQuotes] = useState6({});
2924
2945
  const [postalStatus, setPostalStatus] = useState6(null);
2925
2946
  const [dragActive, setDragActive] = useState6(false);
2947
+ const serviceLinesRef = useRef3(null);
2948
+ const [stackedServiceLines, setStackedServiceLines] = useState6(true);
2949
+ useEffect6(() => {
2950
+ const element = serviceLinesRef.current;
2951
+ if (!element) return;
2952
+ const update = () => setStackedServiceLines(element.clientWidth <= 906);
2953
+ update();
2954
+ if (typeof ResizeObserver === "undefined") return;
2955
+ const observer = new ResizeObserver(update);
2956
+ observer.observe(element);
2957
+ return () => observer.disconnect();
2958
+ }, []);
2926
2959
  const formRef = useRef3(null);
2927
2960
  const fileInput = useRef3(null);
2928
2961
  const diagnosisRequest = useRef3(0);
@@ -2953,6 +2986,8 @@ function BillSubmissionForm({
2953
2986
  previousInitializationKey.current = initializationKey;
2954
2987
  setFeeDetails({});
2955
2988
  setFeeQuotes({});
2989
+ setSharedDiagnoses(billSubmissionUsesSharedDiagnoses(cloneInitialBill(initialBill, treatmentBilling)));
2990
+ individualDiagnoses.current = null;
2956
2991
  setBill(cloneInitialBill(initialBill, treatmentBilling));
2957
2992
  setEvaluationType(initialEvaluationType(initialBill));
2958
2993
  setSelectedIds(attachments.map((item) => item.id));
@@ -3047,7 +3082,7 @@ function BillSubmissionForm({
3047
3082
  return next;
3048
3083
  }));
3049
3084
  const populated = serviceLines.filter((line) => line.code.trim());
3050
- return { ...replaceBillSubmissionServiceLines(current, serviceLines), ...treatmentBilling && populated.length ? { billingMode: populated.every((line) => isMedicalLegalCode(line.code)) ? "med_legal" : "professional" } : {} };
3085
+ return { ...sharedDiagnoses ? setBillSubmissionSharedDiagnoses(replaceBillSubmissionServiceLines(current, serviceLines), current.diagnoses ?? []) : replaceBillSubmissionServiceLines(current, serviceLines), ...treatmentBilling && populated.length ? { billingMode: populated.every((line) => isMedicalLegalCode(line.code)) ? "med_legal" : "professional" } : {} };
3051
3086
  });
3052
3087
  };
3053
3088
  const text = (value, onChange, options = {}) => /* @__PURE__ */ jsx6("input", { className: "mbsf-input", disabled: locked, value: value ?? "", onChange: (event) => onChange(event.target.value), ...options });
@@ -3170,24 +3205,18 @@ function BillSubmissionForm({
3170
3205
  }).catch(() => setPostalStatus("ZIP lookup unavailable"));
3171
3206
  };
3172
3207
  const changeEvaluation = (type) => {
3208
+ if (sharedDiagnoses) individualDiagnoses.current = null;
3173
3209
  setEvaluationType(type);
3174
3210
  setBill((current) => {
3175
- const remapped = remapBillSubmissionDiagnoses(current, current.billingMode === "professional" ? current.diagnoses ?? [] : applyBillSubmissionEvaluationDiagnoses(current.diagnoses, type));
3211
+ const nextDiagnoses = current.billingMode === "professional" ? current.diagnoses ?? [] : applyBillSubmissionEvaluationDiagnoses(current.diagnoses, type);
3212
+ const remapped = sharedDiagnoses ? setBillSubmissionSharedDiagnoses(current, nextDiagnoses) : remapBillSubmissionDiagnoses(current, nextDiagnoses);
3176
3213
  return { ...remapped, renderingProvider: { ...current.renderingProvider, isAme: type === "ame" || type === "psych_ame", isQme: type === "qme" || type === "psych_qme", ...(type === "psych_qme" || type === "psych_ame") && !current.renderingProvider?.specialty ? { specialty: "Psychiatry" } : {} }, serviceLines: applyBillSubmissionEvaluationModifiers(remapped.serviceLines, type) };
3177
3214
  });
3178
3215
  };
3179
3216
  const supportedFeeJurisdiction = (bill.claim.injuryState ?? "CA").trim().toUpperCase() === "CA";
3180
- const feeConfirmationKey = (line) => JSON.stringify({ date: parseBillSubmissionDate(line.serviceDate ?? bill.service.date) ?? "", location: bill.serviceLocation, provider: bill.renderingProvider });
3181
3217
  const quoteInputs = bill.serviceLines.map((line, index) => {
3182
3218
  if (!treatmentBilling || !line.code.trim() || isMedicalLegalCode(line.code)) return null;
3183
- const details = feeDetails[index];
3184
- let context = {};
3185
- if (details?.confirmed && details.confirmationKey === feeConfirmationKey(line)) {
3186
- const placeOfService = bill.serviceLocation?.placeOfServiceCode ?? "";
3187
- if (/^992(?:0[2-5]|1[2-5])$/.test(line.code) && details.providerKind) context = { ...context, hasFeeAgreement: false, physicianContext: { providerKind: details.providerKind, placeOfService, incidentToPhysicianService: false, standaloneService: true, globalPeriodApplies: false, hpsaBonusEligible: false } };
3188
- if (line.code === "97110" && details.minutes && details.totalMinutes) context = { ...context, hasFeeAgreement: false, therapyContext: { providerKind: "physical_therapist", personallyPerformed: true, hospitalPatient: false, incidentToPhysicianService: false, assistantInvolved: false, placeOfService, directOneOnOneMinutes: details.minutes, totalVisitMinutes: details.totalMinutes, visitsOnDate: 1, completeSameDayServices: true, otherSameDayServices: false, globalPeriodApplies: false, hpsaBonusEligible: false } };
3189
- }
3190
- return billSubmissionFeeRequest(bill, line, context);
3219
+ return billSubmissionFeeRequest(bill, line, billSubmissionEstimateContext(line.code, bill.serviceLocation?.placeOfServiceCode ?? "", feeDetails[index]));
3191
3220
  });
3192
3221
  const quoteKeys = quoteInputs.map((input) => input ? JSON.stringify(input) : null);
3193
3222
  const quoteBatch = JSON.stringify(quoteInputs);
@@ -3216,7 +3245,7 @@ function BillSubmissionForm({
3216
3245
  if (treatmentBilling && line.code && !isMedicalLegalCode(line.code)) {
3217
3246
  const key = quoteKeys[index];
3218
3247
  const quote = key ? feeQuotes[key] : void 0;
3219
- return supportedFeeJurisdiction && quote?.status === "priced" ? quote.amountCents / 100 : void 0;
3248
+ return supportedFeeJurisdiction && feeDetails[index]?.basis !== "adjustment" && quote?.status === "priced" ? quote.amountCents / 100 : void 0;
3220
3249
  }
3221
3250
  return calculateBillSubmissionAllowedAmount(line, procedures) ?? (Number.isFinite(line.charge) ? Number(line.charge) : void 0);
3222
3251
  };
@@ -3228,37 +3257,45 @@ function BillSubmissionForm({
3228
3257
  const update = (patch) => setFeeDetails((current) => ({ ...current, [index]: { ...current[index], ...patch } }));
3229
3258
  const office = /^992(?:0[2-5]|1[2-5])$/.test(line.code);
3230
3259
  const therapy = line.code === "97110";
3231
- return /* @__PURE__ */ jsxs6("details", { className: "mbsf-fee-details", children: [
3232
- /* @__PURE__ */ jsxs6("summary", { children: [
3233
- "Fee schedule details",
3234
- quote?.status === "priced" ? " \xB7 Verified" : ""
3235
- ] }),
3236
- office ? /* @__PURE__ */ jsxs6("label", { className: "mbsf-field", children: [
3237
- /* @__PURE__ */ jsx6("span", { children: "Service performed by" }),
3238
- /* @__PURE__ */ jsxs6("select", { className: "mbsf-input", "aria-label": `Service performed by for line ${index + 1}`, value: details.providerKind ?? "", onChange: (event) => update({ providerKind: event.target.value, confirmed: false }), children: [
3239
- /* @__PURE__ */ jsx6("option", { value: "", children: "Select provider type\u2026" }),
3240
- /* @__PURE__ */ jsx6("option", { value: "physician", children: "Physician" }),
3241
- /* @__PURE__ */ jsx6("option", { value: "physician_assistant", children: "Physician assistant" }),
3242
- /* @__PURE__ */ jsx6("option", { value: "nurse_practitioner", children: "Nurse practitioner" }),
3243
- /* @__PURE__ */ jsx6("option", { value: "clinical_nurse_specialist", children: "Clinical nurse specialist" }),
3244
- /* @__PURE__ */ jsx6("option", { value: "other", children: "Other" })
3260
+ return /* @__PURE__ */ jsxs6("div", { className: "mbsf-fee-details", children: [
3261
+ /* @__PURE__ */ jsxs6("label", { className: "mbsf-field", children: [
3262
+ /* @__PURE__ */ jsx6("span", { children: "Fee basis" }),
3263
+ /* @__PURE__ */ jsxs6("select", { className: "mbsf-input", "aria-label": `Fee basis for line ${index + 1}`, value: details.basis ?? "standard", onChange: (event) => update({ basis: event.target.value }), children: [
3264
+ /* @__PURE__ */ jsx6("option", { value: "standard", children: "Standard visit estimate" }),
3265
+ /* @__PURE__ */ jsx6("option", { value: "adjustment", children: "Requires adjustment" })
3245
3266
  ] })
3246
- ] }) : null,
3247
- therapy ? /* @__PURE__ */ jsxs6("div", { className: "mbsf-grid", children: [
3248
- /* @__PURE__ */ jsxs6("label", { className: "mbsf-field", children: [
3249
- /* @__PURE__ */ jsx6("span", { children: "Direct one-on-one minutes" }),
3250
- /* @__PURE__ */ jsx6("input", { className: "mbsf-input", "aria-label": `Direct one-on-one minutes for line ${index + 1}`, type: "number", min: "1", value: details.minutes ?? "", onChange: (event) => update({ minutes: Number(event.target.value), confirmed: false }) })
3267
+ ] }),
3268
+ /* @__PURE__ */ jsx6("p", { className: "mbsf-help", children: details.basis === "adjustment" ? "This service needs fee review before submission." : office ? "Estimate assumes a standalone office visit with no incident-to service, global-period adjustment, HPSA bonus, or fee agreement. Choose Requires adjustment if any assumption does not apply." : therapy ? "Estimate assumes personally performed physical therapy, one visit and no other same-day services, assistant, hospital care, incident-to service, global-period adjustment, HPSA bonus, or fee agreement. Choose Requires adjustment if any assumption does not apply." : "Standard fee estimate for the service date. Choose Requires adjustment for a nonstandard service or fee agreement." }),
3269
+ /* @__PURE__ */ jsxs6("details", { children: [
3270
+ /* @__PURE__ */ jsxs6("summary", { children: [
3271
+ "Fee schedule details",
3272
+ quote?.status === "priced" && details.basis !== "adjustment" ? " \xB7 Estimate" : ""
3251
3273
  ] }),
3252
- /* @__PURE__ */ jsxs6("label", { className: "mbsf-field", children: [
3253
- /* @__PURE__ */ jsx6("span", { children: "Total visit minutes" }),
3254
- /* @__PURE__ */ jsx6("input", { className: "mbsf-input", "aria-label": `Total visit minutes for line ${index + 1}`, type: "number", min: "1", value: details.totalMinutes ?? "", onChange: (event) => update({ totalMinutes: Number(event.target.value), confirmed: false }) })
3255
- ] })
3256
- ] }) : null,
3257
- office || therapy ? /* @__PURE__ */ jsxs6("label", { className: "mbsf-fee-confirm", children: [
3258
- /* @__PURE__ */ jsx6("input", { type: "checkbox", checked: Boolean(details.confirmed && details.confirmationKey === feeConfirmationKey(line)), onChange: (event) => update({ confirmed: event.target.checked, confirmationKey: feeConfirmationKey(line) }) }),
3259
- /* @__PURE__ */ jsx6("span", { children: office ? "I confirm this is a standalone visit, not incident to a physician service, with no global-period adjustment, HPSA bonus, or fee agreement." : "I confirm a physical therapist personally performed this service in one visit. All services for this date have been reviewed; there were no other services, assistant, hospital care, incident-to services, global-period adjustment, HPSA bonus, or fee agreement." })
3260
- ] }) : null,
3261
- /* @__PURE__ */ jsx6("p", { className: "mbsf-help", role: "status", children: !supportedFeeJurisdiction ? "This jurisdiction requires fee review before submission." : !quoteFee ? "Connect fee lookup to check this service." : !quoteInputs[index]?.dateOfService ? "Enter a valid service date to check the fee." : quote?.status === "priced" ? "Allowed amount verified for this service date and the details above." : quote?.reason ?? "Checking the fee schedule\u2026" }),
3274
+ office || therapy ? /* @__PURE__ */ jsxs6("label", { className: "mbsf-field", children: [
3275
+ /* @__PURE__ */ jsx6("span", { children: "Service performed by" }),
3276
+ /* @__PURE__ */ jsxs6("select", { className: "mbsf-input", "aria-label": `Service performed by for line ${index + 1}`, value: details.providerKind ?? "", onChange: (event) => update({ providerKind: event.target.value }), children: [
3277
+ /* @__PURE__ */ jsx6("option", { value: "", children: "Select provider type\u2026" }),
3278
+ office ? /* @__PURE__ */ jsxs6(Fragment4, { children: [
3279
+ /* @__PURE__ */ jsx6("option", { value: "physician", children: "Physician" }),
3280
+ /* @__PURE__ */ jsx6("option", { value: "physician_assistant", children: "Physician assistant" }),
3281
+ /* @__PURE__ */ jsx6("option", { value: "nurse_practitioner", children: "Nurse practitioner" }),
3282
+ /* @__PURE__ */ jsx6("option", { value: "clinical_nurse_specialist", children: "Clinical nurse specialist" })
3283
+ ] }) : /* @__PURE__ */ jsx6("option", { value: "physical_therapist", children: "Physical therapist" }),
3284
+ /* @__PURE__ */ jsx6("option", { value: "other", children: "Other" })
3285
+ ] })
3286
+ ] }) : null,
3287
+ therapy ? /* @__PURE__ */ jsxs6("div", { className: "mbsf-grid", children: [
3288
+ /* @__PURE__ */ jsxs6("label", { className: "mbsf-field", children: [
3289
+ /* @__PURE__ */ jsx6("span", { children: "Direct one-on-one minutes" }),
3290
+ /* @__PURE__ */ jsx6("input", { className: "mbsf-input", "aria-label": `Direct one-on-one minutes for line ${index + 1}`, type: "number", min: "1", value: details.minutes ?? "", onChange: (event) => update({ minutes: Number(event.target.value) }) })
3291
+ ] }),
3292
+ /* @__PURE__ */ jsxs6("label", { className: "mbsf-field", children: [
3293
+ /* @__PURE__ */ jsx6("span", { children: "Total visit minutes" }),
3294
+ /* @__PURE__ */ jsx6("input", { className: "mbsf-input", "aria-label": `Total visit minutes for line ${index + 1}`, type: "number", min: "1", value: details.totalMinutes ?? "", onChange: (event) => update({ totalMinutes: Number(event.target.value) }) })
3295
+ ] })
3296
+ ] }) : null
3297
+ ] }),
3298
+ /* @__PURE__ */ jsx6("p", { className: "mbsf-help", role: "status", children: details.basis === "adjustment" || !supportedFeeJurisdiction ? "This service requires fee review before submission." : !quoteFee ? "Connect fee lookup to estimate this service." : !quoteInputs[index]?.dateOfService ? "Enter a valid service date to estimate the fee." : quote?.status === "priced" ? "Standard fee estimate for this service date and the assumptions above." : quote?.reason ?? "Checking the fee schedule\u2026" }),
3262
3299
  quote?.status === "error" ? /* @__PURE__ */ jsx6("button", { type: "button", className: "mbsf-secondary", onClick: () => setFeeRetry((value) => value + 1), children: "Retry fee check" }) : null
3263
3300
  ] });
3264
3301
  };
@@ -3431,7 +3468,7 @@ function BillSubmissionForm({
3431
3468
  /* @__PURE__ */ jsx6(Field2, { path: "service.date", label: "Date of service", required: true, error: errors["service.date"], children: /* @__PURE__ */ jsx6(TextDateInput, { ariaLabel: "Date of service", value: bill.service.date, disabled: locked, required: true, onChange: (date2) => setBill((c) => ({ ...c, service: { ...c.service, date: date2 } })) }) }),
3432
3469
  /* @__PURE__ */ jsxs6(Field2, { label: "Treatment authorization # (optional)", children: [
3433
3470
  text(bill.service.authorizationNumber, (authorizationNumber) => setBill((c) => ({ ...c, service: { ...c.service, authorizationNumber } })), { placeholder: "Utilization-review authorization number" }),
3434
- /* @__PURE__ */ jsx6("small", { className: "mbsf-help", children: "Rides on the bill as CMS-1500 Box 23 / 837 REF*G1." })
3471
+ /* @__PURE__ */ jsx6("small", { className: "mbsf-help", children: "If the approval has no authorization number, leave this blank and attach the approval." })
3435
3472
  ] }),
3436
3473
  /* @__PURE__ */ jsx6(Field2, { path: "claim.dateOfInjury", label: "Date of injury", required: true, error: errors["claim.dateOfInjury"], children: /* @__PURE__ */ jsx6(TextDateInput, { ariaLabel: "Date of injury", value: bill.claim.dateOfInjury, disabled: locked, required: true, onChange: (dateOfInjury) => setBill((c) => ({ ...c, claim: { ...c.claim, dateOfInjury } })) }) }),
3437
3474
  /* @__PURE__ */ jsx6(Field2, { path: "claim.employer", label: "Employer name", required: true, error: errors["claim.employer"], children: text(bill.claim.employer, (employer) => setBill((c) => ({ ...c, claim: { ...c.claim, employer } }))) }),
@@ -3491,28 +3528,7 @@ function BillSubmissionForm({
3491
3528
  " administers multiple payers. Choose the payer named on the claim or report so MindBill can route the bill correctly."
3492
3529
  ] })
3493
3530
  ] }) : null,
3494
- /* @__PURE__ */ jsx6(Field2, { label: "Injury description (optional)", span: true, children: text(bill.claim.description, (description2) => setBill((c) => ({ ...c, claim: { ...c.claim, description: description2 } }))) }),
3495
- /* @__PURE__ */ jsxs6(Field2, { path: "diagnoses", label: "Diagnosis codes (ICD-10)", required: true, span: true, error: errors.diagnoses, children: [
3496
- /* @__PURE__ */ jsx6("div", { className: "mbsf-quick-picks", "aria-label": "Common diagnosis codes", children: BILL_SUBMISSION_DIAGNOSIS_QUICK_PICKS.map((option) => {
3497
- const selected = (bill.diagnoses ?? []).includes(option.code);
3498
- return /* @__PURE__ */ jsxs6("button", { className: "mbsf-quick-pick", "data-selected": selected, type: "button", "aria-pressed": selected, title: `${option.code} \u2014 ${option.description}`, onClick: () => setBill((current) => remapBillSubmissionDiagnoses(current, selected ? (current.diagnoses ?? []).filter((code) => code !== option.code) : [...current.diagnoses ?? [], option.code])), children: [
3499
- selected ? "\u2713" : "+",
3500
- " ",
3501
- option.label
3502
- ] }, option.code);
3503
- }) }),
3504
- /* @__PURE__ */ jsx6("div", { className: "mbsf-chips", children: (bill.diagnoses ?? []).map((code) => {
3505
- const option = [...BILL_SUBMISSION_DIAGNOSIS_QUICK_PICKS, ...diagnosisChoices].find((item) => item.code === code);
3506
- return /* @__PURE__ */ jsxs6("span", { className: "mbsf-chip", children: [
3507
- /* @__PURE__ */ jsx6("strong", { children: code }),
3508
- option?.description ? ` ${option.description}` : "",
3509
- /* @__PURE__ */ jsx6("button", { type: "button", "aria-label": `Remove ${code}`, onClick: () => setBill((c) => remapBillSubmissionDiagnoses(c, (c.diagnoses ?? []).filter((item) => item !== code))), children: "\xD7" })
3510
- ] }, code);
3511
- }) }),
3512
- /* @__PURE__ */ jsx6(ComboBox, { ariaLabel: "Add diagnosis code", invalid: Boolean(errors.diagnoses), disabled: locked, loading: diagnosisLoading, loadingMore: diagnosisLoadingMore, value: "", placeholder: bill.diagnoses?.length ?? 0 ? `${bill.diagnoses.length} selected \u2014 add more\u2026` : "Search ICD-10 codes\u2026", options: diagnosisChoices.filter((item) => !(bill.diagnoses ?? []).includes(item.code)).map((item) => ({ id: item.code, label: item.code, detail: item.description })), onOpen: () => {
3513
- if (diagnosisQuery !== "") loadDiagnoses("");
3514
- }, onQuery: searchDiagnoses, onEndReached: () => loadDiagnoses(diagnosisQuery ?? "", true), onSelect: (option) => setBill((c) => remapBillSubmissionDiagnoses(c, [...c.diagnoses ?? [], option.id])) })
3515
- ] })
3531
+ /* @__PURE__ */ jsx6(Field2, { label: "Injury description (optional)", span: true, children: text(bill.claim.description, (description2) => setBill((c) => ({ ...c, claim: { ...c.claim, description: description2 } }))) })
3516
3532
  ] })
3517
3533
  ] });
3518
3534
  const compactProviders = profileDisplay === "compact";
@@ -3590,20 +3606,67 @@ function BillSubmissionForm({
3590
3606
  ] })
3591
3607
  ] })
3592
3608
  ] });
3609
+ const diagnosisSelector = (codes, onChange, lineIndex) => {
3610
+ const invalid = Boolean(lineIndex === void 0 ? errors.diagnoses : errors[`serviceLines.${lineIndex}.diagnosisPointers`]);
3611
+ const available = mergeDiagnosisOptions([...(bill.diagnoses ?? []).map((code) => ({ code, description: diagnosisChoices.find((item) => item.code === code)?.description ?? "" })), ...diagnosisChoices]);
3612
+ const canAdd = (code) => codes.length < 4 && (sharedDiagnoses || (bill.diagnoses?.length ?? 0) < 12 || Boolean(bill.diagnoses?.includes(code)));
3613
+ return /* @__PURE__ */ jsxs6("div", { className: "mbsf-diagnosis-select", children: [
3614
+ lineIndex === void 0 ? /* @__PURE__ */ jsx6("div", { className: "mbsf-quick-picks", "aria-label": "Common diagnosis codes", children: BILL_SUBMISSION_DIAGNOSIS_QUICK_PICKS.map((option) => {
3615
+ const selected = codes.includes(option.code);
3616
+ return /* @__PURE__ */ jsxs6("button", { className: "mbsf-quick-pick", disabled: locked || !selected && !canAdd(option.code), "data-selected": selected, type: "button", "aria-pressed": selected, title: `${option.code} \u2014 ${option.description}`, onClick: () => onChange(selected ? codes.filter((code) => code !== option.code) : [...codes, option.code]), children: [
3617
+ selected ? "\u2713" : "+",
3618
+ " ",
3619
+ option.label
3620
+ ] }, option.code);
3621
+ }) }) : null,
3622
+ /* @__PURE__ */ jsx6("div", { className: "mbsf-chips", children: codes.map((code) => {
3623
+ const option = [...BILL_SUBMISSION_DIAGNOSIS_QUICK_PICKS, ...available].find((item) => item.code === code);
3624
+ return /* @__PURE__ */ jsxs6("span", { className: "mbsf-chip", children: [
3625
+ /* @__PURE__ */ jsxs6("span", { children: [
3626
+ /* @__PURE__ */ jsx6("strong", { children: code }),
3627
+ option?.description ? ` ${option.description}` : ""
3628
+ ] }),
3629
+ /* @__PURE__ */ jsx6("button", { type: "button", disabled: locked, "aria-label": `Remove ${code}${lineIndex === void 0 ? "" : ` from service line ${lineIndex + 1}`}`, onClick: () => onChange(codes.filter((item) => item !== code)), children: "\xD7" })
3630
+ ] }, code);
3631
+ }) }),
3632
+ /* @__PURE__ */ jsx6(ComboBox, { ariaLabel: lineIndex === void 0 ? "Add diagnosis code" : `Diagnosis codes for service line ${lineIndex + 1}`, invalid, disabled: locked || codes.length >= 4, loading: diagnosisLoading, loadingMore: diagnosisLoadingMore, value: "", placeholder: codes.length >= 4 ? "4 selected (maximum)" : codes.length ? `${codes.length} selected \u2014 add more\u2026` : "Search ICD-10 codes\u2026", options: available.filter((item) => !codes.includes(item.code) && canAdd(item.code)).map((item) => ({ id: item.code, label: item.code, detail: item.description })), onOpen: () => loadDiagnoses(""), onQuery: searchDiagnoses, onEndReached: () => loadDiagnoses(diagnosisQuery ?? "", true), onSelect: (option) => onChange([...codes, option.id]) })
3633
+ ] });
3634
+ };
3635
+ const toggleSharedDiagnoses = (checked) => {
3636
+ if (checked) {
3637
+ individualDiagnoses.current = bill.serviceLines.map((_, index) => billSubmissionLineDiagnosisCodes(bill, index));
3638
+ const codes = individualDiagnoses.current.find((selection) => selection.length) ?? (bill.diagnoses ?? []).slice(0, 4);
3639
+ setBill(setBillSubmissionSharedDiagnoses(bill, codes));
3640
+ } else if (individualDiagnoses.current) {
3641
+ setBill(setBillSubmissionDiagnosisAssignments(bill, bill.serviceLines.map((_, index) => individualDiagnoses.current?.[index] ?? billSubmissionLineDiagnosisCodes(bill, index))));
3642
+ individualDiagnoses.current = null;
3643
+ }
3644
+ setSharedDiagnoses(checked);
3645
+ };
3593
3646
  const serviceLinesSection = /* @__PURE__ */ jsxs6("fieldset", { className: "mbsf-card", disabled: locked, children: [
3594
3647
  /* @__PURE__ */ jsx6("legend", { className: "mbsf-legend", children: "Evaluation & service lines" }),
3595
3648
  /* @__PURE__ */ jsx6("p", { className: "mbsf-help", children: "Sets the evaluator/specialty modifier on medical-legal evaluation lines." }),
3596
3649
  /* @__PURE__ */ jsx6("div", { className: "mbsf-segments", role: "group", "aria-label": "Evaluation type", children: [["qme", "QME (default)"], ["ame", "AME"], ["psych_qme", "Psych QME"], ["psych_ame", "Psych AME"]].map(([type, label]) => /* @__PURE__ */ jsx6("button", { className: "mbsf-segment", type: "button", "aria-pressed": evaluationType === type, onClick: () => changeEvaluation(type), children: label }, type)) }),
3597
3650
  /* @__PURE__ */ jsx6("p", { className: "mbsf-help", children: evaluationType === "psych_ame" ? "Psychiatric or psychological AME \u2014 eligible ML evaluation codes default to modifiers -94 and -96." : evaluationType === "ame" ? "Agreed Medical Evaluator \u2014 eligible ML evaluation codes default to modifier -94." : evaluationType === "psych_qme" ? "Psychiatric or psychological QME \u2014 eligible ML evaluation codes default to modifiers -95 and -96 (-95 only for ML200 and MLPRR)." : "Qualified Medical Evaluator \u2014 eligible ML evaluation codes default to modifier -95." }),
3651
+ /* @__PURE__ */ jsxs6("label", { className: "mbsf-diagnosis-toggle", children: [
3652
+ /* @__PURE__ */ jsx6("input", { type: "checkbox", checked: sharedDiagnoses, onChange: (event) => toggleSharedDiagnoses(event.target.checked) }),
3653
+ /* @__PURE__ */ jsx6("span", { children: "Apply the same diagnosis codes to all service lines" })
3654
+ ] }),
3655
+ sharedDiagnoses ? /* @__PURE__ */ jsx6(Field2, { path: "diagnoses", label: "Diagnosis codes (ICD-10)", required: true, error: errors.diagnoses, children: diagnosisSelector(bill.diagnoses ?? [], (codes) => {
3656
+ individualDiagnoses.current = null;
3657
+ setBill((current) => setBillSubmissionSharedDiagnoses(current, codes));
3658
+ }) }) : null,
3659
+ /* @__PURE__ */ jsx6("p", { className: "mbsf-help", children: "Choose up to 4 diagnosis codes per service line and 12 across the bill." }),
3660
+ !sharedDiagnoses && errors.diagnoses ? /* @__PURE__ */ jsx6("p", { className: "mbsf-error", role: "alert", children: errors.diagnoses }) : null,
3598
3661
  procedureError ? /* @__PURE__ */ jsx6("p", { className: "mbsf-error", role: "alert", children: procedureError }) : null,
3599
- /* @__PURE__ */ jsxs6("div", { className: "mbsf-lines", "data-field-path": "serviceLines", "data-invalid": Boolean(errors.serviceLines), children: [
3662
+ /* @__PURE__ */ jsxs6("div", { className: "mbsf-lines", ref: serviceLinesRef, "data-stacked": stackedServiceLines, "data-shared-diagnoses": sharedDiagnoses, "data-field-path": "serviceLines", "data-invalid": Boolean(errors.serviceLines), children: [
3600
3663
  /* @__PURE__ */ jsxs6("div", { className: "mbsf-line-head", children: [
3601
3664
  /* @__PURE__ */ jsxs6("span", { children: [
3602
3665
  "Procedure code",
3603
3666
  /* @__PURE__ */ jsx6(RequiredMark, {})
3604
3667
  ] }),
3605
3668
  /* @__PURE__ */ jsx6("span", { children: "Modifiers" }),
3606
- /* @__PURE__ */ jsx6("span", { children: "Dx" }),
3669
+ !sharedDiagnoses ? /* @__PURE__ */ jsx6("span", { children: "Diagnosis codes" }) : null,
3607
3670
  /* @__PURE__ */ jsxs6("span", { children: [
3608
3671
  "Units",
3609
3672
  /* @__PURE__ */ jsx6(RequiredMark, {})
@@ -3630,16 +3693,10 @@ function BillSubmissionForm({
3630
3693
  ] }, modifier)) }),
3631
3694
  /* @__PURE__ */ jsx6(ComboBox, { ariaLabel: `Modifiers ${index + 1}`, disabled: locked, value: "", placeholder: line.modifiers?.length ?? 0 ? `${line.modifiers.length} modifier${line.modifiers.length === 1 ? "" : "s"}` : "Add modifiers\u2026", options: modifiers.filter((item) => !(line.modifiers ?? []).includes(item.code)).map((item) => ({ id: item.code, label: `\u2212${item.code}`, detail: item.description })), onSelect: (option) => setLine(index, { modifiers: [.../* @__PURE__ */ new Set([...line.modifiers ?? [], option.id])] }) })
3632
3695
  ] }),
3633
- /* @__PURE__ */ jsxs6("div", { "data-label": "Dx", "data-field-path": `serviceLines.${index}.diagnosisPointers`, "data-invalid": Boolean(errors[`serviceLines.${index}.diagnosisPointers`]), children: [
3634
- /* @__PURE__ */ jsx6("div", { className: "mbsf-line-diagnoses", children: [0, 1, 2, 3].map((slot) => {
3635
- const pointer = line.diagnosisPointers?.[slot];
3636
- const selectedCode = pointer ? bill.diagnoses?.[pointer - 1] ?? "" : "";
3637
- const selectedCodes = (line.diagnosisPointers ?? []).map((item) => bill.diagnoses?.[item - 1]);
3638
- const options = mergeDiagnosisOptions([...(bill.diagnoses ?? []).map((code) => ({ code, description: diagnosisChoices.find((item) => item.code === code)?.description ?? "" })), ...diagnosisChoices]).filter((item) => (!selectedCodes.includes(item.code) || item.code === selectedCode) && ((bill.diagnoses?.length ?? 0) < 12 || bill.diagnoses?.includes(item.code)));
3639
- return /* @__PURE__ */ jsx6(ComboBox, { ariaLabel: `Diagnosis ${slot + 1} for service line ${index + 1}`, disabled: locked, invalid: Boolean(errors[`serviceLines.${index}.diagnosisPointers`]), value: selectedCode, placeholder: `Dx ${slot + 1}`, loading: diagnosisLoading, loadingMore: diagnosisLoadingMore, options: [...selectedCode ? [{ id: "", label: "Clear diagnosis" }] : [], ...options.map((item) => ({ id: item.code, label: item.code, detail: item.description }))], onOpen: () => loadDiagnoses(""), onQuery: searchDiagnoses, onEndReached: () => loadDiagnoses(diagnosisQuery ?? "", true), onSelect: (option) => setBill((current) => setBillSubmissionLineDiagnosis(current, index, slot, option.id)) }, slot);
3640
- }) }),
3696
+ !sharedDiagnoses ? /* @__PURE__ */ jsxs6("div", { className: "mbsf-line-diagnoses", "data-label": "Diagnosis codes (ICD-10)", "data-field-path": `serviceLines.${index}.diagnosisPointers`, "data-invalid": Boolean(errors[`serviceLines.${index}.diagnosisPointers`]), children: [
3697
+ diagnosisSelector(billSubmissionLineDiagnosisCodes(bill, index), (codes) => setBill((current) => setBillSubmissionLineDiagnoses(current, index, codes)), index),
3641
3698
  errors[`serviceLines.${index}.diagnosisPointers`] ? /* @__PURE__ */ jsx6("small", { className: "mbsf-error", role: "alert", children: errors[`serviceLines.${index}.diagnosisPointers`] }) : null
3642
- ] }),
3699
+ ] }) : null,
3643
3700
  /* @__PURE__ */ jsxs6("div", { "data-label": "Units", "data-field-path": `serviceLines.${index}.units`, "data-invalid": Boolean(errors[`serviceLines.${index}.units`]), children: [
3644
3701
  /* @__PURE__ */ jsx6("input", { className: "mbsf-input", "aria-label": `Units ${index + 1}`, "aria-invalid": Boolean(errors[`serviceLines.${index}.units`]), type: "number", min: 1, value: line.units ?? 1, onChange: (event) => setLine(index, { units: Number(event.target.value) }) }),
3645
3702
  errors[`serviceLines.${index}.units`] ? /* @__PURE__ */ jsx6("small", { className: "mbsf-error", role: "alert", children: errors[`serviceLines.${index}.units`] }) : null
@@ -3647,6 +3704,7 @@ function BillSubmissionForm({
3647
3704
  /* @__PURE__ */ jsx6("div", { className: "mbsf-money", "data-label": "Allowed", "data-field-path": `serviceLines.${index}.charge`, "data-invalid": Boolean(errors[`serviceLines.${index}.charge`]), children: lineCharge(line, index) == null ? quoteKeys[index] ? !supportedFeeJurisdiction || !quoteFee || !quoteInputs[index]?.dateOfService || feeQuotes[quoteKeys[index]] ? "Needs review" : "Checking\u2026" : "\u2014" : lineCharge(line, index).toLocaleString(void 0, { style: "currency", currency: "USD" }) }),
3648
3705
  /* @__PURE__ */ jsx6("button", { className: "mbsf-icon-btn", type: "button", "aria-label": `Remove service line ${index + 1}`, disabled: locked || !lineHasContent(line) && index === bill.serviceLines.length - 1, onClick: () => {
3649
3706
  setFeeDetails({});
3707
+ if (individualDiagnoses.current) individualDiagnoses.current.splice(index, 1);
3650
3708
  setBill((c) => {
3651
3709
  const lines = c.serviceLines.filter((_, itemIndex) => itemIndex !== index);
3652
3710
  const populated = lines.filter((item) => item.code.trim());