feat(direct combo buttons added)

This commit is contained in:
2025-09-24 20:50:33 +05:30
parent eb3055c069
commit 2b9d135105
2 changed files with 155 additions and 90 deletions

View File

@@ -299,12 +299,17 @@ export function ClaimForm({
}, []); }, []);
// 1st Button workflow - Mass Health Button Handler // 1st Button workflow - Mass Health Button Handler
const handleMHSubmit = async () => { const handleMHSubmit = async (
formToUse?: ClaimFormData & { uploadedFiles?: File[] }
) => {
// Use the passed form, or fallback to current state
const f = formToUse ?? form;
// 0. Validate required fields // 0. Validate required fields
const missingFields: string[] = []; const missingFields: string[] = [];
if (!form.memberId?.trim()) missingFields.push("Member ID"); if (!f.memberId?.trim()) missingFields.push("Member ID");
if (!form.dateOfBirth?.trim()) missingFields.push("Date of Birth"); if (!f.dateOfBirth?.trim()) missingFields.push("Date of Birth");
if (!patient?.firstName?.trim()) missingFields.push("First Name"); if (!patient?.firstName?.trim()) missingFields.push("First Name");
if (missingFields.length > 0) { if (missingFields.length > 0) {
@@ -319,7 +324,7 @@ export function ClaimForm({
// 1. Create or update appointment // 1. Create or update appointment
const appointmentData = { const appointmentData = {
patientId: patientId, patientId: patientId,
date: serviceDate, date: f.serviceDate,
staffId: staff?.id, staffId: staff?.id,
}; };
const appointmentId = await onHandleAppointmentSubmit(appointmentData); const appointmentId = await onHandleAppointmentSubmit(appointmentData);
@@ -343,10 +348,10 @@ export function ClaimForm({
// 3. Create Claim(if not) // 3. Create Claim(if not)
// Filter out empty service lines (empty procedureCode) // Filter out empty service lines (empty procedureCode)
const filteredServiceLines = form.serviceLines.filter( const filteredServiceLines = f.serviceLines.filter(
(line) => line.procedureCode.trim() !== "" (line) => line.procedureCode.trim() !== ""
); );
const { uploadedFiles, insuranceSiteKey, ...formToCreateClaim } = form; const { uploadedFiles, insuranceSiteKey, ...formToCreateClaim } = f;
// build claimFiles metadata from uploadedFiles (only filename + mimeType) // build claimFiles metadata from uploadedFiles (only filename + mimeType)
const claimFilesMeta: ClaimFileMeta[] = (uploadedFiles || []).map((f) => ({ const claimFilesMeta: ClaimFileMeta[] = (uploadedFiles || []).map((f) => ({
@@ -366,7 +371,7 @@ export function ClaimForm({
// 4. sending form data to selenium service // 4. sending form data to selenium service
onHandleForMHSelenium({ onHandleForMHSelenium({
...form, ...f,
serviceLines: filteredServiceLines, serviceLines: filteredServiceLines,
staffId: Number(staff?.id), staffId: Number(staff?.id),
patientId: patientId, patientId: patientId,
@@ -450,6 +455,22 @@ export function ClaimForm({
onClose(); onClose();
}; };
const applyComboAndThenMH = async (
comboId: keyof typeof PROCEDURE_COMBOS
) => {
const nextForm = applyComboToForm(
form,
comboId,
patient?.dateOfBirth ?? "",
{ replaceAll: true, lineDate: form.serviceDate }
);
setForm(nextForm);
setTimeout(() => scrollToLine(0), 0);
await handleMHSubmit(nextForm);
};
return ( return (
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4 overflow-y-auto"> <div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4 overflow-y-auto">
<Card className="w-full max-w-5xl max-h-[90vh] overflow-y-auto bg-white"> <Card className="w-full max-w-5xl max-h-[90vh] overflow-y-auto bg-white">
@@ -544,7 +565,8 @@ export function ClaimForm({
Service Lines Service Lines
</h3> </h3>
<div className="flex justify-end items-center mb-2"> <div className="flex flex-col gap-2">
<div className="flex justify-end items-center mb-4">
{/* Service Date */} {/* Service Date */}
<div className="flex gap-2"> <div className="flex gap-2">
<Label className="flex items-center">Service Date</Label> <Label className="flex items-center">Service Date</Label>
@@ -624,6 +646,28 @@ export function ClaimForm({
</div> </div>
</div> </div>
<div className="flex justify-start gap-2">
<Button
variant="warning"
onClick={() => applyComboAndThenMH("childRecallDirect")}
>
Child Recall Direct
</Button>
<Button
variant="warning"
onClick={() => applyComboAndThenMH("adultRecallDirect")}
>
Adult Recall Direct
</Button>
<Button
variant="warning"
onClick={() => applyComboAndThenMH("adultRecallDirect4bw")}
>
Adult Recall Direct 4BW
</Button>
</div>
</div>
{/* Header */} {/* Header */}
<div className="grid grid-cols-[1.5fr,0.5fr,1fr,1fr,1fr,1fr,1fr] gap-1 mb-2 mt-10 font-medium text-sm text-gray-700 items-center"> <div className="grid grid-cols-[1.5fr,0.5fr,1fr,1fr,1fr,1fr,1fr] gap-1 mb-2 mt-10 font-medium text-sm text-gray-700 items-center">
<div className="grid grid-cols-[auto,1fr] items-center gap-2"> <div className="grid grid-cols-[auto,1fr] items-center gap-2">
@@ -875,7 +919,7 @@ export function ClaimForm({
<Button <Button
className="w-32" className="w-32"
variant="warning" variant="warning"
onClick={handleMHSubmit} onClick={() => handleMHSubmit()}
> >
MH MH
</Button> </Button>

View File

@@ -1,16 +1,21 @@
export const PROCEDURE_COMBOS: Record< export const PROCEDURE_COMBOS: Record<
string, string,
{ id: string; label: string; codes: string[]; toothNumbers?: (string | null)[] } {
id: string;
label: string;
codes: string[];
toothNumbers?: (string | null)[];
}
> = { > = {
childRecall: { childRecall: {
id: "childRecall", id: "childRecall",
label: "Child Recall", label: "Child Recall",
codes: [ codes: ["D0120", "D1120", "D0272", "D1208"],
"D0120", },
"D1120", childRecallDirect: {
"D0272", id: "childRecallDirect",
"D1208", label: "Child Recall Direct(no x-ray)",
], codes: ["D0120", "D1120", "D1208"],
}, },
adultRecall: { adultRecall: {
id: "adultRecall", id: "adultRecall",
@@ -18,6 +23,16 @@ export const PROCEDURE_COMBOS: Record<
codes: ["D0120", "D0220", "D0230", "D0274", "D1110"], codes: ["D0120", "D0220", "D0230", "D0274", "D1110"],
toothNumbers: [null, "9", "24", null, null], // only these two need values toothNumbers: [null, "9", "24", null, null], // only these two need values
}, },
adultRecallDirect: {
id: "adultRecallDirect",
label: "Adult Recall Direct(no x-ray)",
codes: ["D0120", "D1110"],
},
adultRecallDirect4bw: {
id: "adultRecallDirect4bw",
label: "Adult Recall Direct - 4bw (no x-ray)",
codes: ["D0120", "D1110", "D0274"],
},
newChildPatient: { newChildPatient: {
id: "newChildPatient", id: "newChildPatient",
label: "New Child Patient", label: "New Child Patient",
@@ -159,9 +174,11 @@ export const PROCEDURE_COMBOS: Record<
// add more… // add more…
}; };
// Which combos appear under which heading // Which combos appear under which heading
export const COMBO_CATEGORIES: Record<string, (keyof typeof PROCEDURE_COMBOS)[]> = { export const COMBO_CATEGORIES: Record<
string,
(keyof typeof PROCEDURE_COMBOS)[]
> = {
"Recalls & New Patients": [ "Recalls & New Patients": [
"childRecall", "childRecall",
"adultRecall", "adultRecall",
@@ -192,5 +209,9 @@ export const COMBO_CATEGORIES: Record<string, (keyof typeof PROCEDURE_COMBOS)[]>
Endodontics: ["rctAnterior", "rctPremolar", "rctMolar", "postCore"], Endodontics: ["rctAnterior", "rctPremolar", "rctMolar", "postCore"],
Prosthodontics: ["crown"], Prosthodontics: ["crown"],
Periodontics: ["deepCleaning"], Periodontics: ["deepCleaning"],
Extractions: ["simpleExtraction", "surgicalExtraction", "babyTeethExtraction"], Extractions: [
"simpleExtraction",
"surgicalExtraction",
"babyTeethExtraction",
],
}; };