fix: pass DOB from chatbot through to claim form for DDMA claims

The chatbot-extracted DOB was stored in chatbot_claim_codes but never
forwarded to chatbot_claim_prefill, leaving the claim form DOB empty
when the patient DB record lacked it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ff
2026-06-18 13:58:12 -04:00
parent 3e919ec1c5
commit 6958d13282
3 changed files with 16 additions and 8 deletions

View File

@@ -139,6 +139,14 @@ export function ClaimForm({
return (parsed?.renderingProvider as string | null | undefined) ?? null; return (parsed?.renderingProvider as string | null | undefined) ?? null;
} catch { return null; } } catch { return null; }
}); });
const [chatbotDob] = useState<string | null>(() => {
try {
const raw = sessionStorage.getItem("chatbot_claim_prefill");
if (!raw) return null;
const parsed = JSON.parse(raw);
return (parsed?.dob as string | null | undefined) ?? null;
} catch { return null; }
});
// When an existing claim is loaded for the appointment, store its ID so // When an existing claim is loaded for the appointment, store its ID so
// the form submits an update instead of creating a new claim. // the form submits an update instead of creating a new claim.
const [existingClaimId, setExistingClaimId] = useState<number | null>(null); const [existingClaimId, setExistingClaimId] = useState<number | null>(null);
@@ -531,10 +539,9 @@ export function ClaimForm({
if (!raw) return; if (!raw) return;
try { try {
const { codes, serviceDate, renderingProvider } = JSON.parse(raw) as { const { codes, serviceDate } = JSON.parse(raw) as {
codes: { code: string; description: string; toothNumber?: string; toothSurface?: string; quad?: string }[]; codes: { code: string; description: string; toothNumber?: string; toothSurface?: string; quad?: string }[];
serviceDate?: string; serviceDate?: string;
renderingProvider?: string | null;
}; };
sessionStorage.removeItem("chatbot_claim_prefill"); sessionStorage.removeItem("chatbot_claim_prefill");
if (!codes?.length) return; if (!codes?.length) return;
@@ -748,7 +755,7 @@ export function ClaimForm({
staffId: appointmentStaffId ?? Number(staff?.id), staffId: appointmentStaffId ?? Number(staff?.id),
patientName: `${patient?.firstName} ${patient?.lastName}`.trim(), patientName: `${patient?.firstName} ${patient?.lastName}`.trim(),
memberId: patient?.insuranceId ?? "", memberId: patient?.insuranceId ?? "",
dateOfBirth: normalizeToIsoDateString(patient?.dateOfBirth), dateOfBirth: normalizeToIsoDateString(patient?.dateOfBirth) || normalizeToIsoDateString(chatbotDob ?? undefined),
remarks: "", remarks: "",
missingTeethStatus: "No_missing", missingTeethStatus: "No_missing",
missingTeeth: {} as MissingMapStrict, missingTeeth: {} as MissingMapStrict,
@@ -802,7 +809,7 @@ export function ClaimForm({
...prev, ...prev,
patientId: Number(patient.id), patientId: Number(patient.id),
patientName: fullName, patientName: fullName,
dateOfBirth: normalizeToIsoDateString(patient.dateOfBirth), dateOfBirth: normalizeToIsoDateString(patient.dateOfBirth) || normalizeToIsoDateString(chatbotDob ?? undefined),
memberId: patient.insuranceId || "", memberId: patient.insuranceId || "",
...(siteKey ? { insuranceSiteKey: siteKey } : {}), ...(siteKey ? { insuranceSiteKey: siteKey } : {}),
})); }));

View File

@@ -865,6 +865,7 @@ export function ChatbotButton() {
siteKey: apptSelectionData.siteKey, siteKey: apptSelectionData.siteKey,
serviceDate: opt.serviceDate, serviceDate: opt.serviceDate,
autoSubmit: true, autoSubmit: true,
dob: apptSelectionData.patient?.dateOfBirth ?? null,
}) })
); );
setChatbotPendingFiles(pendingFiles); setChatbotPendingFiles(pendingFiles);
@@ -919,7 +920,7 @@ export function ChatbotButton() {
if (patient?.id && matchedCodes.length > 0) { if (patient?.id && matchedCodes.length > 0) {
sessionStorage.setItem( sessionStorage.setItem(
"chatbot_claim_prefill", "chatbot_claim_prefill",
JSON.stringify({ codes: matchedCodes, siteKey, serviceDate, autoSubmit: true, renderingProvider: renderingProvider ?? null }) JSON.stringify({ codes: matchedCodes, siteKey, serviceDate, autoSubmit: true, renderingProvider: renderingProvider ?? null, dob: patient?.dateOfBirth ?? null })
); );
} }
setChatbotPendingFiles(pendingFiles); setChatbotPendingFiles(pendingFiles);
@@ -1036,7 +1037,7 @@ export function ChatbotButton() {
if (data.action === "claim_only_ready" && data.actionData) { if (data.action === "claim_only_ready" && data.actionData) {
const { patient, matchedCodes, siteKey, serviceDate, appointmentId, renderingProvider } = data.actionData; const { patient, matchedCodes, siteKey, serviceDate, appointmentId, renderingProvider } = data.actionData;
if (patient?.id && matchedCodes?.length > 0) { if (patient?.id && matchedCodes?.length > 0) {
sessionStorage.setItem("chatbot_claim_prefill", JSON.stringify({ codes: matchedCodes, siteKey, serviceDate, autoSubmit: true, renderingProvider: renderingProvider ?? null })); sessionStorage.setItem("chatbot_claim_prefill", JSON.stringify({ codes: matchedCodes, siteKey, serviceDate, autoSubmit: true, renderingProvider: renderingProvider ?? null, dob: patient?.dateOfBirth ?? null }));
} }
setChatbotPendingFiles(pendingFiles); setChatbotPendingFiles(pendingFiles);
const url = appointmentId ? `/claims?appointmentId=${appointmentId}` : `/claims?newPatient=${patient?.id}`; const url = appointmentId ? `/claims?appointmentId=${appointmentId}` : `/claims?newPatient=${patient?.id}`;

View File

@@ -710,7 +710,7 @@ export default function InsuranceStatusPage() {
try { try {
const raw = sessionStorage.getItem("chatbot_claim_codes"); const raw = sessionStorage.getItem("chatbot_claim_codes");
if (!raw) return false; if (!raw) return false;
const { codes, siteKey, patientId, memberId: storedMemberId, serviceDate, renderingProvider } = JSON.parse(raw); const { codes, siteKey, patientId, memberId: storedMemberId, dob, serviceDate, renderingProvider } = JSON.parse(raw);
sessionStorage.removeItem("chatbot_claim_codes"); sessionStorage.removeItem("chatbot_claim_codes");
let pid: number | null = resolvedPatientId ?? patientId ?? null; let pid: number | null = resolvedPatientId ?? patientId ?? null;
@@ -730,7 +730,7 @@ export default function InsuranceStatusPage() {
sessionStorage.setItem( sessionStorage.setItem(
"chatbot_claim_prefill", "chatbot_claim_prefill",
JSON.stringify({ codes, siteKey, serviceDate: serviceDate ?? null, autoSubmit: true, renderingProvider: renderingProvider ?? null }) JSON.stringify({ codes, siteKey, serviceDate: serviceDate ?? null, autoSubmit: true, renderingProvider: renderingProvider ?? null, dob: dob ?? null })
); );
setLocation(`/claims?newPatient=${pid}`); setLocation(`/claims?newPatient=${pid}`);
return true; return true;