From e3ce0564aa47bb6a85187f26b008f96b86f9ae97 Mon Sep 17 00:00:00 2001 From: Vishnu Date: Sat, 7 Jun 2025 18:12:22 +0530 Subject: [PATCH] claim form now will show 10 rows of service lines --- .gitignore | 5 ++- .../src/components/claims/claim-form.tsx | 42 +++++++++---------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index b93444e..156615b 100644 --- a/.gitignore +++ b/.gitignore @@ -36,4 +36,7 @@ yarn-error.log* dist/ # env -*.env \ No newline at end of file +*.env + +#temp +1.html \ No newline at end of file diff --git a/apps/Frontend/src/components/claims/claim-form.tsx b/apps/Frontend/src/components/claims/claim-form.tsx index 558651d..d9b525c 100644 --- a/apps/Frontend/src/components/claims/claim-form.tsx +++ b/apps/Frontend/src/components/claims/claim-form.tsx @@ -90,7 +90,7 @@ interface ClaimFormData { remarks: string; serviceDate: string; // YYYY-MM-DD insuranceProvider: string; - insuranceSiteKey?:string; + insuranceSiteKey?: string; status: string; // default "pending" serviceLines: ServiceLine[]; } @@ -211,7 +211,7 @@ export function ClaimForm({ // MAIN FORM INITIAL STATE const [form, setForm] = useState({ patientId: patientId || 0, - appointmentId: 0, + appointmentId: 0, userId: Number(user?.id), staffId: Number(staff?.id), patientName: `${patient?.firstName} ${patient?.lastName}`.trim(), @@ -220,19 +220,16 @@ export function ClaimForm({ remarks: "", serviceDate: serviceDate, insuranceProvider: "", - insuranceSiteKey:"", + insuranceSiteKey: "", status: "pending", - serviceLines: [ - { - procedureCode: "", - procedureDate: serviceDate, - oralCavityArea: "", - toothNumber: "", - toothSurface: "", - billedAmount: 0, - }, - ], - + serviceLines: Array.from({ length: 10 }, () => ({ + procedureCode: "", + procedureDate: serviceDate, + oralCavityArea: "", + toothNumber: "", + toothSurface: "", + billedAmount: 0, + })), uploadedFiles: [], }); @@ -279,7 +276,7 @@ export function ClaimForm({ if (updatedLines[index]) { if (field === "billedAmount") { - const num = typeof value === "string" ? parseFloat(value) : value; + const num = typeof value === "string" ? parseFloat(value) : value; const rounded = Math.round((isNaN(num) ? 0 : num) * 100) / 100; updatedLines[index][field] = rounded; } else { @@ -362,13 +359,15 @@ export function ClaimForm({ } // 3. Create Claim(if not) - const { - uploadedFiles, - insuranceSiteKey, - ...formToCreateClaim - } = form; + // Filter out empty service lines (empty procedureCode) + const filteredServiceLines = form.serviceLines.filter( + (line) => line.procedureCode.trim() !== "" + ); + + const { uploadedFiles, insuranceSiteKey, ...formToCreateClaim } = form; onSubmit({ ...formToCreateClaim, + serviceLines: filteredServiceLines, staffId: Number(staff?.id), patientId: patientId, insuranceProvider: "MassHealth", @@ -378,11 +377,12 @@ export function ClaimForm({ // 4. sending form data to selenium service onHandleForSelenium({ ...form, + serviceLines: filteredServiceLines, staffId: Number(staff?.id), patientId: patientId, insuranceProvider: "Mass Health", appointmentId: appointmentId!, - insuranceSiteKey:"MH", + insuranceSiteKey: "MH", }); // 4. Close form onClose();