@mindbill/react 0.54.1 → 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,10 +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{container:mbsf-service-lines / inline-size;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{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
- @container mbsf-service-lines (max-width:906px){.mbsf-line-diagnoses{grid-template-columns:repeat(4,minmax(0,1fr))}.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}}
2667
- @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%}}
2668
2686
  `;
2669
2687
  function RequiredMark() {
2670
2688
  return /* @__PURE__ */ jsx6("span", { className: "mbsf-star", children: " *" });
@@ -2889,6 +2907,8 @@ function BillSubmissionForm({
2889
2907
  children
2890
2908
  }) {
2891
2909
  const [bill, setBill] = useState6(() => cloneInitialBill(initialBill, treatmentBilling));
2910
+ const [sharedDiagnoses, setSharedDiagnoses] = useState6(() => billSubmissionUsesSharedDiagnoses(cloneInitialBill(initialBill, treatmentBilling)));
2911
+ const individualDiagnoses = useRef3(null);
2892
2912
  const [providerEditing, setProviderEditing] = useState6(false);
2893
2913
  const [selectedIds, setSelectedIds] = useState6(() => attachments.map((item) => item.id));
2894
2914
  const [removedSourceIds, setRemovedSourceIds] = useState6([]);
@@ -2924,6 +2944,18 @@ function BillSubmissionForm({
2924
2944
  const [feeQuotes, setFeeQuotes] = useState6({});
2925
2945
  const [postalStatus, setPostalStatus] = useState6(null);
2926
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
+ }, []);
2927
2959
  const formRef = useRef3(null);
2928
2960
  const fileInput = useRef3(null);
2929
2961
  const diagnosisRequest = useRef3(0);
@@ -2954,6 +2986,8 @@ function BillSubmissionForm({
2954
2986
  previousInitializationKey.current = initializationKey;
2955
2987
  setFeeDetails({});
2956
2988
  setFeeQuotes({});
2989
+ setSharedDiagnoses(billSubmissionUsesSharedDiagnoses(cloneInitialBill(initialBill, treatmentBilling)));
2990
+ individualDiagnoses.current = null;
2957
2991
  setBill(cloneInitialBill(initialBill, treatmentBilling));
2958
2992
  setEvaluationType(initialEvaluationType(initialBill));
2959
2993
  setSelectedIds(attachments.map((item) => item.id));
@@ -3048,7 +3082,7 @@ function BillSubmissionForm({
3048
3082
  return next;
3049
3083
  }));
3050
3084
  const populated = serviceLines.filter((line) => line.code.trim());
3051
- 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" } : {} };
3052
3086
  });
3053
3087
  };
3054
3088
  const text = (value, onChange, options = {}) => /* @__PURE__ */ jsx6("input", { className: "mbsf-input", disabled: locked, value: value ?? "", onChange: (event) => onChange(event.target.value), ...options });
@@ -3171,24 +3205,18 @@ function BillSubmissionForm({
3171
3205
  }).catch(() => setPostalStatus("ZIP lookup unavailable"));
3172
3206
  };
3173
3207
  const changeEvaluation = (type) => {
3208
+ if (sharedDiagnoses) individualDiagnoses.current = null;
3174
3209
  setEvaluationType(type);
3175
3210
  setBill((current) => {
3176
- 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);
3177
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) };
3178
3214
  });
3179
3215
  };
3180
3216
  const supportedFeeJurisdiction = (bill.claim.injuryState ?? "CA").trim().toUpperCase() === "CA";
3181
- const feeConfirmationKey = (line) => JSON.stringify({ date: parseBillSubmissionDate(line.serviceDate ?? bill.service.date) ?? "", location: bill.serviceLocation, provider: bill.renderingProvider });
3182
3217
  const quoteInputs = bill.serviceLines.map((line, index) => {
3183
3218
  if (!treatmentBilling || !line.code.trim() || isMedicalLegalCode(line.code)) return null;
3184
- const details = feeDetails[index];
3185
- let context = {};
3186
- if (details?.confirmed && details.confirmationKey === feeConfirmationKey(line)) {
3187
- const placeOfService = bill.serviceLocation?.placeOfServiceCode ?? "";
3188
- 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 } };
3189
- 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 } };
3190
- }
3191
- return billSubmissionFeeRequest(bill, line, context);
3219
+ return billSubmissionFeeRequest(bill, line, billSubmissionEstimateContext(line.code, bill.serviceLocation?.placeOfServiceCode ?? "", feeDetails[index]));
3192
3220
  });
3193
3221
  const quoteKeys = quoteInputs.map((input) => input ? JSON.stringify(input) : null);
3194
3222
  const quoteBatch = JSON.stringify(quoteInputs);
@@ -3217,7 +3245,7 @@ function BillSubmissionForm({
3217
3245
  if (treatmentBilling && line.code && !isMedicalLegalCode(line.code)) {
3218
3246
  const key = quoteKeys[index];
3219
3247
  const quote = key ? feeQuotes[key] : void 0;
3220
- 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;
3221
3249
  }
3222
3250
  return calculateBillSubmissionAllowedAmount(line, procedures) ?? (Number.isFinite(line.charge) ? Number(line.charge) : void 0);
3223
3251
  };
@@ -3229,37 +3257,45 @@ function BillSubmissionForm({
3229
3257
  const update = (patch) => setFeeDetails((current) => ({ ...current, [index]: { ...current[index], ...patch } }));
3230
3258
  const office = /^992(?:0[2-5]|1[2-5])$/.test(line.code);
3231
3259
  const therapy = line.code === "97110";
3232
- return /* @__PURE__ */ jsxs6("details", { className: "mbsf-fee-details", children: [
3233
- /* @__PURE__ */ jsxs6("summary", { children: [
3234
- "Fee schedule details",
3235
- quote?.status === "priced" ? " \xB7 Verified" : ""
3236
- ] }),
3237
- office ? /* @__PURE__ */ jsxs6("label", { className: "mbsf-field", children: [
3238
- /* @__PURE__ */ jsx6("span", { children: "Service performed by" }),
3239
- /* @__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: [
3240
- /* @__PURE__ */ jsx6("option", { value: "", children: "Select provider type\u2026" }),
3241
- /* @__PURE__ */ jsx6("option", { value: "physician", children: "Physician" }),
3242
- /* @__PURE__ */ jsx6("option", { value: "physician_assistant", children: "Physician assistant" }),
3243
- /* @__PURE__ */ jsx6("option", { value: "nurse_practitioner", children: "Nurse practitioner" }),
3244
- /* @__PURE__ */ jsx6("option", { value: "clinical_nurse_specialist", children: "Clinical nurse specialist" }),
3245
- /* @__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" })
3246
3266
  ] })
3247
- ] }) : null,
3248
- therapy ? /* @__PURE__ */ jsxs6("div", { className: "mbsf-grid", children: [
3249
- /* @__PURE__ */ jsxs6("label", { className: "mbsf-field", children: [
3250
- /* @__PURE__ */ jsx6("span", { children: "Direct one-on-one minutes" }),
3251
- /* @__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" : ""
3252
3273
  ] }),
3253
- /* @__PURE__ */ jsxs6("label", { className: "mbsf-field", children: [
3254
- /* @__PURE__ */ jsx6("span", { children: "Total visit minutes" }),
3255
- /* @__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 }) })
3256
- ] })
3257
- ] }) : null,
3258
- office || therapy ? /* @__PURE__ */ jsxs6("label", { className: "mbsf-fee-confirm", children: [
3259
- /* @__PURE__ */ jsx6("input", { type: "checkbox", checked: Boolean(details.confirmed && details.confirmationKey === feeConfirmationKey(line)), onChange: (event) => update({ confirmed: event.target.checked, confirmationKey: feeConfirmationKey(line) }) }),
3260
- /* @__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." })
3261
- ] }) : null,
3262
- /* @__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" }),
3263
3299
  quote?.status === "error" ? /* @__PURE__ */ jsx6("button", { type: "button", className: "mbsf-secondary", onClick: () => setFeeRetry((value) => value + 1), children: "Retry fee check" }) : null
3264
3300
  ] });
3265
3301
  };
@@ -3432,7 +3468,7 @@ function BillSubmissionForm({
3432
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 } })) }) }),
3433
3469
  /* @__PURE__ */ jsxs6(Field2, { label: "Treatment authorization # (optional)", children: [
3434
3470
  text(bill.service.authorizationNumber, (authorizationNumber) => setBill((c) => ({ ...c, service: { ...c.service, authorizationNumber } })), { placeholder: "Utilization-review authorization number" }),
3435
- /* @__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." })
3436
3472
  ] }),
3437
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 } })) }) }),
3438
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 } }))) }),
@@ -3492,28 +3528,7 @@ function BillSubmissionForm({
3492
3528
  " administers multiple payers. Choose the payer named on the claim or report so MindBill can route the bill correctly."
3493
3529
  ] })
3494
3530
  ] }) : null,
3495
- /* @__PURE__ */ jsx6(Field2, { label: "Injury description (optional)", span: true, children: text(bill.claim.description, (description2) => setBill((c) => ({ ...c, claim: { ...c.claim, description: description2 } }))) }),
3496
- /* @__PURE__ */ jsxs6(Field2, { path: "diagnoses", label: "Diagnosis codes (ICD-10)", required: true, span: true, error: errors.diagnoses, children: [
3497
- /* @__PURE__ */ jsx6("div", { className: "mbsf-quick-picks", "aria-label": "Common diagnosis codes", children: BILL_SUBMISSION_DIAGNOSIS_QUICK_PICKS.map((option) => {
3498
- const selected = (bill.diagnoses ?? []).includes(option.code);
3499
- 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: [
3500
- selected ? "\u2713" : "+",
3501
- " ",
3502
- option.label
3503
- ] }, option.code);
3504
- }) }),
3505
- /* @__PURE__ */ jsx6("div", { className: "mbsf-chips", children: (bill.diagnoses ?? []).map((code) => {
3506
- const option = [...BILL_SUBMISSION_DIAGNOSIS_QUICK_PICKS, ...diagnosisChoices].find((item) => item.code === code);
3507
- return /* @__PURE__ */ jsxs6("span", { className: "mbsf-chip", children: [
3508
- /* @__PURE__ */ jsx6("strong", { children: code }),
3509
- option?.description ? ` ${option.description}` : "",
3510
- /* @__PURE__ */ jsx6("button", { type: "button", "aria-label": `Remove ${code}`, onClick: () => setBill((c) => remapBillSubmissionDiagnoses(c, (c.diagnoses ?? []).filter((item) => item !== code))), children: "\xD7" })
3511
- ] }, code);
3512
- }) }),
3513
- /* @__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: () => {
3514
- if (diagnosisQuery !== "") loadDiagnoses("");
3515
- }, onQuery: searchDiagnoses, onEndReached: () => loadDiagnoses(diagnosisQuery ?? "", true), onSelect: (option) => setBill((c) => remapBillSubmissionDiagnoses(c, [...c.diagnoses ?? [], option.id])) })
3516
- ] })
3531
+ /* @__PURE__ */ jsx6(Field2, { label: "Injury description (optional)", span: true, children: text(bill.claim.description, (description2) => setBill((c) => ({ ...c, claim: { ...c.claim, description: description2 } }))) })
3517
3532
  ] })
3518
3533
  ] });
3519
3534
  const compactProviders = profileDisplay === "compact";
@@ -3591,20 +3606,67 @@ function BillSubmissionForm({
3591
3606
  ] })
3592
3607
  ] })
3593
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
+ };
3594
3646
  const serviceLinesSection = /* @__PURE__ */ jsxs6("fieldset", { className: "mbsf-card", disabled: locked, children: [
3595
3647
  /* @__PURE__ */ jsx6("legend", { className: "mbsf-legend", children: "Evaluation & service lines" }),
3596
3648
  /* @__PURE__ */ jsx6("p", { className: "mbsf-help", children: "Sets the evaluator/specialty modifier on medical-legal evaluation lines." }),
3597
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)) }),
3598
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,
3599
3661
  procedureError ? /* @__PURE__ */ jsx6("p", { className: "mbsf-error", role: "alert", children: procedureError }) : null,
3600
- /* @__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: [
3601
3663
  /* @__PURE__ */ jsxs6("div", { className: "mbsf-line-head", children: [
3602
3664
  /* @__PURE__ */ jsxs6("span", { children: [
3603
3665
  "Procedure code",
3604
3666
  /* @__PURE__ */ jsx6(RequiredMark, {})
3605
3667
  ] }),
3606
3668
  /* @__PURE__ */ jsx6("span", { children: "Modifiers" }),
3607
- /* @__PURE__ */ jsx6("span", { children: "Dx" }),
3669
+ !sharedDiagnoses ? /* @__PURE__ */ jsx6("span", { children: "Diagnosis codes" }) : null,
3608
3670
  /* @__PURE__ */ jsxs6("span", { children: [
3609
3671
  "Units",
3610
3672
  /* @__PURE__ */ jsx6(RequiredMark, {})
@@ -3631,16 +3693,10 @@ function BillSubmissionForm({
3631
3693
  ] }, modifier)) }),
3632
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])] }) })
3633
3695
  ] }),
3634
- /* @__PURE__ */ jsxs6("div", { "data-label": "Dx", "data-field-path": `serviceLines.${index}.diagnosisPointers`, "data-invalid": Boolean(errors[`serviceLines.${index}.diagnosisPointers`]), children: [
3635
- /* @__PURE__ */ jsx6("div", { className: "mbsf-line-diagnoses", children: [0, 1, 2, 3].map((slot) => {
3636
- const pointer = line.diagnosisPointers?.[slot];
3637
- const selectedCode = pointer ? bill.diagnoses?.[pointer - 1] ?? "" : "";
3638
- const selectedCodes = (line.diagnosisPointers ?? []).map((item) => bill.diagnoses?.[item - 1]);
3639
- 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)));
3640
- 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);
3641
- }) }),
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),
3642
3698
  errors[`serviceLines.${index}.diagnosisPointers`] ? /* @__PURE__ */ jsx6("small", { className: "mbsf-error", role: "alert", children: errors[`serviceLines.${index}.diagnosisPointers`] }) : null
3643
- ] }),
3699
+ ] }) : null,
3644
3700
  /* @__PURE__ */ jsxs6("div", { "data-label": "Units", "data-field-path": `serviceLines.${index}.units`, "data-invalid": Boolean(errors[`serviceLines.${index}.units`]), children: [
3645
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) }) }),
3646
3702
  errors[`serviceLines.${index}.units`] ? /* @__PURE__ */ jsx6("small", { className: "mbsf-error", role: "alert", children: errors[`serviceLines.${index}.units`] }) : null
@@ -3648,6 +3704,7 @@ function BillSubmissionForm({
3648
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" }) }),
3649
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: () => {
3650
3706
  setFeeDetails({});
3707
+ if (individualDiagnoses.current) individualDiagnoses.current.splice(index, 1);
3651
3708
  setBill((c) => {
3652
3709
  const lines = c.serviceLines.filter((_, itemIndex) => itemIndex !== index);
3653
3710
  const populated = lines.filter((item) => item.code.trim());