claim form now will show 10 rows of service lines

This commit is contained in:
2025-06-07 18:12:22 +05:30
parent a5ac927a36
commit e3ce0564aa
2 changed files with 25 additions and 22 deletions

5
.gitignore vendored
View File

@@ -36,4 +36,7 @@ yarn-error.log*
dist/ dist/
# env # env
*.env *.env
#temp
1.html

View File

@@ -90,7 +90,7 @@ interface ClaimFormData {
remarks: string; remarks: string;
serviceDate: string; // YYYY-MM-DD serviceDate: string; // YYYY-MM-DD
insuranceProvider: string; insuranceProvider: string;
insuranceSiteKey?:string; insuranceSiteKey?: string;
status: string; // default "pending" status: string; // default "pending"
serviceLines: ServiceLine[]; serviceLines: ServiceLine[];
} }
@@ -211,7 +211,7 @@ export function ClaimForm({
// MAIN FORM INITIAL STATE // MAIN FORM INITIAL STATE
const [form, setForm] = useState<ClaimFormData & { uploadedFiles: File[] }>({ const [form, setForm] = useState<ClaimFormData & { uploadedFiles: File[] }>({
patientId: patientId || 0, patientId: patientId || 0,
appointmentId: 0, appointmentId: 0,
userId: Number(user?.id), userId: Number(user?.id),
staffId: Number(staff?.id), staffId: Number(staff?.id),
patientName: `${patient?.firstName} ${patient?.lastName}`.trim(), patientName: `${patient?.firstName} ${patient?.lastName}`.trim(),
@@ -220,19 +220,16 @@ export function ClaimForm({
remarks: "", remarks: "",
serviceDate: serviceDate, serviceDate: serviceDate,
insuranceProvider: "", insuranceProvider: "",
insuranceSiteKey:"", insuranceSiteKey: "",
status: "pending", status: "pending",
serviceLines: [ serviceLines: Array.from({ length: 10 }, () => ({
{ procedureCode: "",
procedureCode: "", procedureDate: serviceDate,
procedureDate: serviceDate, oralCavityArea: "",
oralCavityArea: "", toothNumber: "",
toothNumber: "", toothSurface: "",
toothSurface: "", billedAmount: 0,
billedAmount: 0, })),
},
],
uploadedFiles: [], uploadedFiles: [],
}); });
@@ -279,7 +276,7 @@ export function ClaimForm({
if (updatedLines[index]) { if (updatedLines[index]) {
if (field === "billedAmount") { 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; const rounded = Math.round((isNaN(num) ? 0 : num) * 100) / 100;
updatedLines[index][field] = rounded; updatedLines[index][field] = rounded;
} else { } else {
@@ -362,13 +359,15 @@ export function ClaimForm({
} }
// 3. Create Claim(if not) // 3. Create Claim(if not)
const { // Filter out empty service lines (empty procedureCode)
uploadedFiles, const filteredServiceLines = form.serviceLines.filter(
insuranceSiteKey, (line) => line.procedureCode.trim() !== ""
...formToCreateClaim );
} = form;
const { uploadedFiles, insuranceSiteKey, ...formToCreateClaim } = form;
onSubmit({ onSubmit({
...formToCreateClaim, ...formToCreateClaim,
serviceLines: filteredServiceLines,
staffId: Number(staff?.id), staffId: Number(staff?.id),
patientId: patientId, patientId: patientId,
insuranceProvider: "MassHealth", insuranceProvider: "MassHealth",
@@ -378,11 +377,12 @@ export function ClaimForm({
// 4. sending form data to selenium service // 4. sending form data to selenium service
onHandleForSelenium({ onHandleForSelenium({
...form, ...form,
serviceLines: filteredServiceLines,
staffId: Number(staff?.id), staffId: Number(staff?.id),
patientId: patientId, patientId: patientId,
insuranceProvider: "Mass Health", insuranceProvider: "Mass Health",
appointmentId: appointmentId!, appointmentId: appointmentId!,
insuranceSiteKey:"MH", insuranceSiteKey: "MH",
}); });
// 4. Close form // 4. Close form
onClose(); onClose();