From 4ac357fba7882ef551517e1357a9a31245d6ffd4 Mon Sep 17 00:00:00 2001 From: Potenz Date: Thu, 24 Jul 2025 00:32:10 +0530 Subject: [PATCH] actions half done --- .../components/claims/claim-view-modal.tsx | 189 ++++++++++++++++++ .../components/claims/claims-recent-table.tsx | 23 ++- 2 files changed, 206 insertions(+), 6 deletions(-) create mode 100644 apps/Frontend/src/components/claims/claim-view-modal.tsx diff --git a/apps/Frontend/src/components/claims/claim-view-modal.tsx b/apps/Frontend/src/components/claims/claim-view-modal.tsx new file mode 100644 index 0000000..e8a42c6 --- /dev/null +++ b/apps/Frontend/src/components/claims/claim-view-modal.tsx @@ -0,0 +1,189 @@ +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle, + DialogDescription, +} from "@/components/ui/dialog"; +import { Button } from "@/components/ui/button"; +import { ClaimUncheckedCreateInputObjectSchema } from "@repo/db/usedSchemas"; +import React from "react"; +import { z } from "zod"; + +//creating types out of schema auto generated. +type Claim = z.infer; + +type ClaimWithServiceLines = Claim & { + serviceLines: { + id: number; + claimId: number; + procedureCode: string; + procedureDate: Date; + oralCavityArea: string | null; + toothNumber: string | null; + toothSurface: string | null; + billedAmount: number; + }[]; +}; + +type ClaimViewModalProps = { + isOpen: boolean; + onOpenChange: (open: boolean) => void; + onClose: () => void; + claim: ClaimWithServiceLines | null; + onEditClaim: (claim: ClaimWithServiceLines) => void; +}; + +export default function ClaimViewModal({ + isOpen, + onOpenChange, + onClose, + claim, + onEditClaim, +}: ClaimViewModalProps) { + return ( + + + + + Claim Details + + Detailed view of the selected claim. + + + + {claim && ( +
+
+
+ {claim.patientName.charAt(0)} +
+
+

{claim.patientName}

+

+ Claim ID: {claim.id?.toString().padStart(4, "0")} +

+
+
+ +
+
+

Basic Information

+
+

+ Member ID:{" "} + {claim.memberId} +

+

+ Date of Birth:{" "} + {new Date(claim.dateOfBirth).toLocaleDateString()} +

+

+ Service Date:{" "} + {new Date(claim.serviceDate).toLocaleDateString()} +

+

+ Status:{" "} + + {claim?.status + ? claim.status.charAt(0).toUpperCase() + + claim.status.slice(1).toLowerCase() + : "Unknown"} + +

+
+
+ +
+

Insurance

+
+

+ Provider:{" "} + {claim.insuranceProvider || "N/A"} +

+

+ Remarks:{" "} + {claim.remarks || "N/A"} +

+
+
+
+ +
+

Service Lines

+
+ {claim.serviceLines.length > 0 ? ( + claim.serviceLines.map((line, index) => ( +
+

+ Procedure Code:{" "} + {line.procedureCode} +

+

+ Procedure Date:{" "} + {new Date(line.procedureDate).toLocaleDateString()} +

+ {line.oralCavityArea && ( +

+ + Oral Cavity Area: + {" "} + {line.oralCavityArea} +

+ )} + {line.toothNumber && ( +

+ Tooth Number:{" "} + {line.toothNumber} +

+ )} + {line.toothSurface && ( +

+ Tooth Surface:{" "} + {line.toothSurface} +

+ )} +

+ Billed Amount: $ + {line.billedAmount.toFixed(2)} +

+
+ )) + ) : ( +

No service lines available.

+ )} +
+
+ +
+ + +
+
+ )} +
+
+ ); +} diff --git a/apps/Frontend/src/components/claims/claims-recent-table.tsx b/apps/Frontend/src/components/claims/claims-recent-table.tsx index 4903887..70b5ffa 100644 --- a/apps/Frontend/src/components/claims/claims-recent-table.tsx +++ b/apps/Frontend/src/components/claims/claims-recent-table.tsx @@ -41,6 +41,7 @@ import { Avatar, AvatarFallback } from "@/components/ui/avatar"; import { cn } from "@/lib/utils"; import { formatDateToHumanReadable } from "@/utils/dateUtils"; import { Card, CardHeader, CardTitle } from "@/components/ui/card"; +import ClaimViewModal from "./claim-view-modal"; //creating types out of schema auto generated. type Claim = z.infer; @@ -99,9 +100,9 @@ export default function ClaimsRecentTable({ const claimsPerPage = 5; const offset = (currentPage - 1) * claimsPerPage; - const [currentClaim, setCurrentClaim] = useState( - undefined - ); + const [currentClaim, setCurrentClaim] = useState< + ClaimWithServiceLines | undefined + >(undefined); const [selectedClaimId, setSelectedClaimId] = useState(null); const handleSelectClaim = (claim: Claim) => { @@ -170,17 +171,17 @@ export default function ClaimsRecentTable({ }, }); - const handleEditClaim = (claim: Claim) => { + const handleEditClaim = (claim: ClaimWithServiceLines) => { setCurrentClaim(claim); setIsEditClaimOpen(true); }; - const handleViewClaim = (claim: Claim) => { + const handleViewClaim = (claim: ClaimWithServiceLines) => { setCurrentClaim(claim); setIsViewClaimOpen(true); }; - const handleDeleteClaim = (claim: Claim) => { + const handleDeleteClaim = (claim: ClaimWithServiceLines) => { setCurrentClaim(claim); setIsDeleteClaimOpen(true); }; @@ -464,6 +465,16 @@ export default function ClaimsRecentTable({ entityName={currentClaim?.patientName} /> + {isViewClaimOpen && currentClaim && ( + setIsViewClaimOpen(false)} + onOpenChange={(open) => setIsViewClaimOpen(open)} + onEditClaim={(claim) => handleEditClaim(claim)} + claim={currentClaim} + /> + )} + {/* Pagination */} {totalPages > 1 && (