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;
} 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
// the form submits an update instead of creating a new claim.
const [existingClaimId, setExistingClaimId] = useState<number | null>(null);
@@ -531,10 +539,9 @@ export function ClaimForm({
if (!raw) return;
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 }[];
serviceDate?: string;
renderingProvider?: string | null;
};
sessionStorage.removeItem("chatbot_claim_prefill");
if (!codes?.length) return;
@@ -748,7 +755,7 @@ export function ClaimForm({
staffId: appointmentStaffId ?? Number(staff?.id),
patientName: `${patient?.firstName} ${patient?.lastName}`.trim(),
memberId: patient?.insuranceId ?? "",
dateOfBirth: normalizeToIsoDateString(patient?.dateOfBirth),
dateOfBirth: normalizeToIsoDateString(patient?.dateOfBirth) || normalizeToIsoDateString(chatbotDob ?? undefined),
remarks: "",
missingTeethStatus: "No_missing",
missingTeeth: {} as MissingMapStrict,
@@ -802,7 +809,7 @@ export function ClaimForm({
...prev,
patientId: Number(patient.id),
patientName: fullName,
dateOfBirth: normalizeToIsoDateString(patient.dateOfBirth),
dateOfBirth: normalizeToIsoDateString(patient.dateOfBirth) || normalizeToIsoDateString(chatbotDob ?? undefined),
memberId: patient.insuranceId || "",
...(siteKey ? { insuranceSiteKey: siteKey } : {}),
}));

View File

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

View File

@@ -710,7 +710,7 @@ export default function InsuranceStatusPage() {
try {
const raw = sessionStorage.getItem("chatbot_claim_codes");
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");
let pid: number | null = resolvedPatientId ?? patientId ?? null;
@@ -730,7 +730,7 @@ export default function InsuranceStatusPage() {
sessionStorage.setItem(
"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}`);
return true;