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