'use client'; import React, { useState } from 'react'; import { Superbill, ClinicTenant } from '@/types/clinical'; import { generateSuperbillPdf } from '@/lib/pdf-generator'; import { Download, CreditCard, CheckCircle2, ShieldAlert, ArrowLeft, DollarSign, Printer, FileCheck, } from 'lucide-react'; interface SuperbillViewProps { superbill: Superbill; activeTenant: ClinicTenant; onBack: () => void; onMarkPaid: (superbillId: string, method: Superbill['paymentMethod']) => void; } export const SuperbillView: React.FC = ({ superbill, activeTenant, onBack, onMarkPaid, }) => { const [showPaymentModal, setShowPaymentModal] = useState(false); const [isProcessingStripe, setIsProcessingStripe] = useState(false); const [paymentSuccess, setPaymentSuccess] = useState(false); const handleDownloadPdf = () => { generateSuperbillPdf(superbill); }; const handleStripePay = (method: Superbill['paymentMethod']) => { setIsProcessingStripe(true); setTimeout(() => { setIsProcessingStripe(false); setPaymentSuccess(true); onMarkPaid(superbill.id, method); setTimeout(() => { setShowPaymentModal(false); setPaymentSuccess(false); }, 1500); }, 1200); }; return (
{/* Top Header Bar */}

Superbill Statement {superbill.invoiceNumber}

{superbill.balanceDue === 0 ? 'Paid in Full' : 'Balance Due'}

Standard CMS-1500 Reimbursement Statement for {superbill.patientName}

{superbill.balanceDue > 0 && ( )}
{/* Main Printed Superbill Card Simulation */}
{/* Clinic & Statement Header */}
OFFICIAL MEDICAL SUPERBILL & CLAIM

{superbill.clinicName}

{superbill.clinicAddress}

Tax ID / EIN: {superbill.clinicTaxId} • POS:{' '} {superbill.posCode}

Invoice Number
{superbill.invoiceNumber}
Date of Service
{superbill.dateOfService}
{/* Provider & Patient 2-Col Info */}
{/* Provider */}

Rendering Provider

{superbill.providerName}
National Provider Identifier (NPI):{' '} {superbill.providerNpi}
Specialty: Chiropractic Clinical Biomechanics
{/* Patient */}

Patient Demographics

{superbill.patientName}
DOB: {superbill.patientDob}
Address: {superbill.patientAddress}
{/* Diagnosis ICD-10 Section */}

Primary Diagnosis Codes (ICD-10-CM)

{superbill.icd10Codes.map((icd, index) => (
{index + 1} {icd.code} {icd.description}
))}
{/* Procedures Table */}

Rendered Procedures (CPT Codes)

{superbill.items.map((item) => ( ))}
CPT Code Service Description Units Fee Total
{item.cptCode} {item.description} {item.units} ${item.rate.toFixed(2)} ${item.total.toFixed(2)}
{/* Financial Summary */}

This Superbill fulfills the standard medical reimbursement criteria for direct patient submission to commercial insurers, Medicare supplements, and HSA/FSA plans.

Payment Record: {superbill.paymentMethod}

Total Charges: ${superbill.totalAmount.toFixed(2)}
Patient Paid: -${superbill.patientPaid.toFixed(2)}
Balance Due: ${superbill.balanceDue.toFixed(2)}
{/* Stripe Payment Modal */} {showPaymentModal && (

Hospital Payment Terminal

Connected to {activeTenant.name}

Balance Due: ${superbill.balanceDue.toFixed(2)}
{paymentSuccess ? (
Payment Processed Successfully!
Transaction ID: TX-90281-OK
) : ( <>
)}
{!paymentSuccess && (
)}
)}
); };