eligibility check - checkpoint1
This commit is contained in:
@@ -11,18 +11,18 @@ import {
|
||||
AppointmentUncheckedCreateInputObjectSchema,
|
||||
ClaimUncheckedCreateInputObjectSchema,
|
||||
} from "@repo/db/usedSchemas";
|
||||
import { AlertCircle, CheckCircle, Clock, FileCheck } from "lucide-react";
|
||||
import { FileCheck } from "lucide-react";
|
||||
import { parse, format } from "date-fns";
|
||||
import { z } from "zod";
|
||||
import { apiRequest, queryClient } from "@/lib/queryClient";
|
||||
import { useLocation } from "wouter";
|
||||
import RecentClaims from "@/components/claims/recent-claims";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useDispatch } from "react-redux";
|
||||
|
||||
import { useAppDispatch, useAppSelector } from "@/redux/hooks";
|
||||
import {
|
||||
setTaskStatus,
|
||||
clearTaskStatus,
|
||||
} from "@/redux/slices/seleniumTaskSlice";
|
||||
} from "@/redux/slices/seleniumClaimSubmitTaskSlice";
|
||||
import { SeleniumTaskBanner } from "@/components/claims/selenium-task-banner";
|
||||
|
||||
//creating types out of schema auto generated.
|
||||
@@ -78,7 +78,11 @@ export default function ClaimsPage() {
|
||||
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
|
||||
const [isClaimFormOpen, setIsClaimFormOpen] = useState(false);
|
||||
const [selectedPatient, setSelectedPatient] = useState<number | null>(null);
|
||||
const dispatch = useDispatch();
|
||||
const dispatch = useAppDispatch();
|
||||
const { status, message, show } = useAppSelector(
|
||||
(state) => state.seleniumClaimSubmitTask
|
||||
);
|
||||
|
||||
const { toast } = useToast();
|
||||
const { user } = useAuth();
|
||||
const [claimFormData, setClaimFormData] = useState<any>({
|
||||
@@ -428,7 +432,6 @@ export default function ClaimsPage() {
|
||||
}
|
||||
}, [memberId, dob]);
|
||||
|
||||
|
||||
const getDisplayProvider = (provider: string) => {
|
||||
const insuranceMap: Record<string, string> = {
|
||||
delta: "Delta Dental",
|
||||
@@ -614,8 +617,12 @@ export default function ClaimsPage() {
|
||||
|
||||
<div className="flex-1 flex flex-col overflow-hidden">
|
||||
<TopAppBar toggleMobileMenu={toggleMobileMenu} />
|
||||
|
||||
<SeleniumTaskBanner />
|
||||
<SeleniumTaskBanner
|
||||
status={status}
|
||||
message={message}
|
||||
show={show}
|
||||
onClear={() => dispatch(clearTaskStatus())}
|
||||
/>
|
||||
|
||||
<main className="flex-1 overflow-y-auto p-4">
|
||||
{/* Header */}
|
||||
|
||||
@@ -27,6 +27,12 @@ import {
|
||||
} from "@/components/ui/popover";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { apiRequest, queryClient } from "@/lib/queryClient";
|
||||
import { useAppDispatch, useAppSelector } from "@/redux/hooks";
|
||||
import {
|
||||
setTaskStatus,
|
||||
clearTaskStatus,
|
||||
} from "@/redux/slices/seleniumEligibilityCheckTaskSlice";
|
||||
import { SeleniumTaskBanner } from "@/components/claims/selenium-task-banner";
|
||||
|
||||
const PatientSchema = (
|
||||
PatientUncheckedCreateInputObjectSchema as unknown as z.ZodObject<any>
|
||||
@@ -47,6 +53,11 @@ type InsertPatient = z.infer<typeof insertPatientSchema>;
|
||||
export default function InsuranceEligibilityPage() {
|
||||
const { user } = useAuth();
|
||||
const { toast } = useToast();
|
||||
const dispatch = useAppDispatch();
|
||||
const { status, message, show } = useAppSelector(
|
||||
(state) => state.seleniumEligibilityCheckTask
|
||||
);
|
||||
|
||||
|
||||
const [selectedPatient, setSelectedPatient] = useState<Patient | null>(null);
|
||||
|
||||
@@ -113,7 +124,7 @@ export default function InsuranceEligibilityPage() {
|
||||
},
|
||||
});
|
||||
|
||||
// Insurance eligibility check mutation
|
||||
// Insurance eligibility check mutation --- not using right now
|
||||
const checkInsuranceMutation = useMutation({
|
||||
mutationFn: async ({
|
||||
provider,
|
||||
@@ -155,6 +166,67 @@ export default function InsuranceEligibilityPage() {
|
||||
},
|
||||
});
|
||||
|
||||
// handle selenium
|
||||
const handleSelenium = async () => {
|
||||
const data = {memberId, dateOfBirth, insuranceSiteKey: "MH", };
|
||||
try {
|
||||
dispatch(
|
||||
setTaskStatus({
|
||||
status: "pending",
|
||||
message: "Sending Data to Selenium...",
|
||||
})
|
||||
);
|
||||
const response = await apiRequest(
|
||||
"POST",
|
||||
"/api/insuranceEligibility/check",
|
||||
{ data: JSON.stringify(data) }
|
||||
);
|
||||
const result1 = await response.json();
|
||||
if (result1.error) throw new Error(result1.error);
|
||||
|
||||
dispatch(
|
||||
setTaskStatus({
|
||||
status: "pending",
|
||||
message: "Submitted to Selenium. Awaiting PDF...",
|
||||
})
|
||||
);
|
||||
|
||||
toast({
|
||||
title: "Selenium service notified",
|
||||
description:
|
||||
"Your claim data was successfully sent to Selenium, Waitinig for its response.",
|
||||
variant: "default",
|
||||
});
|
||||
} catch (error: any) {
|
||||
dispatch(
|
||||
setTaskStatus({
|
||||
status: "error",
|
||||
message: error.message || "Selenium submission failed",
|
||||
})
|
||||
);
|
||||
toast({
|
||||
title: "Selenium service error",
|
||||
description: error.message || "An error occurred.",
|
||||
variant: "destructive",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const handleAddPatient = () => {
|
||||
const newPatient: InsertPatient = {
|
||||
firstName,
|
||||
lastName,
|
||||
dateOfBirth: dateOfBirth,
|
||||
gender: "",
|
||||
phone: "",
|
||||
userId: user?.id ?? 1,
|
||||
status: "active",
|
||||
insuranceId: memberId,
|
||||
};
|
||||
addPatientMutation.mutate(newPatient);
|
||||
}
|
||||
|
||||
// Handle insurance provider button clicks
|
||||
const handleMHButton = () => {
|
||||
// Form Fields check
|
||||
@@ -169,19 +241,9 @@ export default function InsuranceEligibilityPage() {
|
||||
}
|
||||
|
||||
// Adding patient if same patient exists then it will skip.
|
||||
const newPatient: InsertPatient = {
|
||||
firstName,
|
||||
lastName,
|
||||
dateOfBirth: dateOfBirth,
|
||||
gender: "",
|
||||
phone: "",
|
||||
userId: user?.id ?? 1,
|
||||
status: "active",
|
||||
insuranceId: memberId,
|
||||
};
|
||||
addPatientMutation.mutate(newPatient);
|
||||
handleAddPatient();
|
||||
|
||||
|
||||
handleSelenium();
|
||||
|
||||
|
||||
};
|
||||
@@ -196,6 +258,13 @@ export default function InsuranceEligibilityPage() {
|
||||
<div className="flex-1 flex flex-col overflow-hidden">
|
||||
<TopAppBar toggleMobileMenu={toggleMobileMenu} />
|
||||
|
||||
<SeleniumTaskBanner
|
||||
status={status}
|
||||
message={message}
|
||||
show={show}
|
||||
onClear={() => dispatch(clearTaskStatus())}
|
||||
/>
|
||||
|
||||
<main className="flex-1 overflow-auto p-6">
|
||||
<div className="max-w-7xl mx-auto">
|
||||
{/* Header */}
|
||||
|
||||
Reference in New Issue
Block a user