claimId fixed
This commit is contained in:
@@ -8,7 +8,6 @@ import {
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import { format, parse } from "date-fns";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { X, Calendar as CalendarIcon, HelpCircle } from "lucide-react";
|
||||
@@ -22,6 +21,7 @@ import {
|
||||
import {
|
||||
PatientUncheckedCreateInputObjectSchema,
|
||||
AppointmentUncheckedCreateInputObjectSchema,
|
||||
ClaimUncheckedCreateInputObjectSchema,
|
||||
} from "@repo/db/usedSchemas";
|
||||
import { z } from "zod";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
@@ -35,7 +35,6 @@ import {
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import procedureCodes from "../../assets/data/procedureCodes.json";
|
||||
import exp from "constants";
|
||||
|
||||
const PatientSchema = (
|
||||
PatientUncheckedCreateInputObjectSchema as unknown as z.ZodObject<any>
|
||||
@@ -78,6 +77,9 @@ const updateAppointmentSchema = (
|
||||
.partial();
|
||||
type UpdateAppointment = z.infer<typeof updateAppointmentSchema>;
|
||||
|
||||
type Claim = z.infer<typeof ClaimUncheckedCreateInputObjectSchema>;
|
||||
|
||||
|
||||
interface ServiceLine {
|
||||
procedureCode: string;
|
||||
procedureDate: string; // YYYY-MM-DD
|
||||
@@ -101,12 +103,13 @@ interface ClaimFormData {
|
||||
insuranceSiteKey?: string;
|
||||
status: string; // default "pending"
|
||||
serviceLines: ServiceLine[];
|
||||
claimId?: number;
|
||||
}
|
||||
|
||||
interface ClaimFormProps {
|
||||
patientId: number;
|
||||
extractedData?: Partial<Patient>;
|
||||
onSubmit: (data: ClaimFormData) => void;
|
||||
onSubmit: (data: ClaimFormData) => Promise<Claim>;
|
||||
onHandleAppointmentSubmit: (
|
||||
appointmentData: InsertAppointment | UpdateAppointment
|
||||
) => void;
|
||||
@@ -413,7 +416,7 @@ export function ClaimForm({
|
||||
);
|
||||
|
||||
const { uploadedFiles, insuranceSiteKey, ...formToCreateClaim } = form;
|
||||
onSubmit({
|
||||
const createdClaim = await onSubmit({
|
||||
...formToCreateClaim,
|
||||
serviceLines: filteredServiceLines,
|
||||
staffId: Number(staff?.id),
|
||||
@@ -431,6 +434,7 @@ export function ClaimForm({
|
||||
insuranceProvider: "Mass Health",
|
||||
appointmentId: appointmentId!,
|
||||
insuranceSiteKey: "MH",
|
||||
claimId: createdClaim.id,
|
||||
});
|
||||
// 4. Close form
|
||||
onClose();
|
||||
|
||||
@@ -85,7 +85,6 @@ export default function ClaimsPage() {
|
||||
patientId: null,
|
||||
serviceDate: "",
|
||||
});
|
||||
const [claimRes, setClaimRes] = useState<Claim | null>(null);
|
||||
|
||||
// Fetch patients
|
||||
const { data: patients = [], isLoading: isLoadingPatients } = useQuery<
|
||||
@@ -305,11 +304,9 @@ export default function ClaimsPage() {
|
||||
const res = await apiRequest("POST", "/api/claims/", claimData);
|
||||
return res.json();
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
console.log(data)
|
||||
setClaimRes(data);
|
||||
onSuccess: () => {
|
||||
toast({
|
||||
title: "Claim submitted successfully",
|
||||
title: "Claim created successfully",
|
||||
variant: "default",
|
||||
});
|
||||
},
|
||||
@@ -322,6 +319,12 @@ export default function ClaimsPage() {
|
||||
},
|
||||
});
|
||||
|
||||
function handleClaimSubmit(claimData: any): Promise<Claim> {
|
||||
return createClaimMutation.mutateAsync(claimData).then((data) => {
|
||||
return data;
|
||||
});
|
||||
}
|
||||
|
||||
const [location] = useLocation(); // gets path, e.g. "/claims"
|
||||
|
||||
const { name, memberId, dob } = useMemo(() => {
|
||||
@@ -425,9 +428,6 @@ export default function ClaimsPage() {
|
||||
}
|
||||
}, [memberId, dob]);
|
||||
|
||||
function handleClaimSubmit(claimData: any) {
|
||||
createClaimMutation.mutate(claimData);
|
||||
}
|
||||
|
||||
const getDisplayProvider = (provider: string) => {
|
||||
const insuranceMap: Record<string, string> = {
|
||||
@@ -553,8 +553,8 @@ export default function ClaimsPage() {
|
||||
// selenium pdf download handler
|
||||
const handleSeleniumPdfDownload = async (data: any) => {
|
||||
try {
|
||||
if (!claimRes?.id) {
|
||||
throw new Error("Missing claimId2s");
|
||||
if (!data.claimId) {
|
||||
throw new Error("Missing claimId in handleSeleniumPdfDownload");
|
||||
}
|
||||
if (!selectedPatient) {
|
||||
throw new Error("Missing patientId");
|
||||
@@ -569,8 +569,8 @@ export default function ClaimsPage() {
|
||||
|
||||
const res = await apiRequest("POST", "/api/claims/selenium/fetchpdf", {
|
||||
patientId: selectedPatient,
|
||||
claimId: claimRes.id,
|
||||
pdf_url: data["pdf_url"],
|
||||
claimId: data.claimId,
|
||||
pdf_url: data.pdf_url,
|
||||
});
|
||||
const result = await res.json();
|
||||
if (result.error) throw new Error(result.error);
|
||||
|
||||
Reference in New Issue
Block a user