fixes - dob state fixed, combo added

This commit is contained in:
2025-10-17 06:14:35 +05:30
parent ff7c5713d9
commit a5d5e96d9a
4 changed files with 200 additions and 64 deletions

View File

@@ -39,9 +39,9 @@ export const PROCEDURE_COMBOS: Record<
codes: ["D0120", "D1120", "D1208", "D0220", "D0230", "D0274"],
toothNumbers: [null, null, null, "9", "24", null], // only these two need values
},
childRecallDirectPANO2PA2BW: {
id: "childRecallDirectPANO2PA2BW",
label: "Child Recall Direct PANO 2PA 2BW",
childRecallDirectPANO: {
id: "childRecallDirectPANO",
label: "Child Recall Direct PANO",
codes: ["D0120", "D1120", "D1208", "D0330"],
},
adultRecall: {
@@ -55,25 +55,31 @@ export const PROCEDURE_COMBOS: Record<
label: "Adult Recall Direct(no x-ray)",
codes: ["D0120", "D1110"],
},
adultRecallDirect2bw: {
id: "adultRecallDirect2bw",
adultRecallDirect2BW: {
id: "adultRecallDirect2BW",
label: "Adult Recall Direct - 2bw (no x-ray)",
codes: ["D0120", "D1110", "D0272"],
},
adultRecallDirect4bw: {
id: "adultRecallDirect4bw",
adultRecallDirect4BW: {
id: "adultRecallDirect4BW",
label: "Adult Recall Direct - 4bw (no x-ray)",
codes: ["D0120", "D1110", "D0274"],
},
adultRecallDirect4bw2pa: {
id: "adultRecallDirect4bw",
label: "Adult Recall Direct - 4bw (no x-ray)",
adultRecallDirect2PA2BW: {
id: "adultRecallDirect2PA2BW",
label: "Adult Recall Direct - 2PA 2BW",
codes: ["D0120", "D0220", "D0230", "D0272", "D1110"],
toothNumbers: [null, "9", "24", null, null], // only these two need values
},
adultRecallDirect2PA4BW: {
id: "adultRecallDirect2PA4BW",
label: "Adult Recall Direct - 2PA 4BW",
codes: ["D0120", "D0220", "D0230", "D0274", "D1110"],
toothNumbers: [null, "9", "24", null, null], // only these two need values
},
adultRecallDirectPano: {
id: "adultRecallDirectPano",
label: "Adult Recall Direct - Pano",
label: "Adult Recall Direct - PANO",
codes: ["D0120", "D1110", "D0330"],
},
newChildPatient: {
@@ -83,7 +89,7 @@ export const PROCEDURE_COMBOS: Record<
},
newAdultPatientPano: {
id: "newAdultPatientPano",
label: "New Adult Patient (Pano)",
label: "New Adult Patient - PANO",
codes: ["D0150", "D0330", "D1110"],
},
newAdultPatientFMX: {

View File

@@ -107,17 +107,56 @@ const ageOnDate = (dob: DateInput, on: DateInput): number => {
};
/**
* Price chooser that respects your age rules and IC/NC semantics.
* - If <=21 → PriceLTEQ21 (if present and not IC/NC/blank) else Price.
* - If >21 → PriceGT21 (if present and not IC/NC/blank) else Price.
* - If chosen field is IC/NC/blank → 0 (leave empty).
* we can implement per-code age buckets without changing the JSON.
*
* Behavior:
* - Default: same as before: age <= 21 -> PriceLTEQ21, else PriceGT21
* - Fallback to Price if tiered field is blank/IC/NC
* - Special-cases D1110 and D1120 according to MH rules
*/
export function pickPriceForRowByAge(row: CodeRow, age: number): Decimal {
export function pickPriceForRowByAge(
row: CodeRow,
age: number,
normalizedCode?: string
): Decimal {
// Special-case rules (add more codes here if needed)
if (normalizedCode) {
// D1110: only valid for age >=14 (14..21 => PriceLTEQ21, >21 => PriceGT21)
if (normalizedCode === "D1110") {
if (age < 14) {
// D1110 not applicable to children <14 (those belong to D1120)
return new Decimal(0);
}
if (age >= 14 && age <= 21) {
// use PriceLTEQ21 only if present
if (!isBlankPrice(row.PriceLTEQ21))
return toDecimalOrZero(row.PriceLTEQ21);
return new Decimal(0);
}
// age > 21
if (!isBlankPrice(row.PriceGT21)) return toDecimalOrZero(row.PriceGT21);
return new Decimal(0);
}
// D1120: child 0-13 => PriceLTEQ21, otherwise no price (NC)
if (normalizedCode === "D1120") {
if (age < 14) {
if (!isBlankPrice(row.PriceLTEQ21))
return toDecimalOrZero(row.PriceLTEQ21);
return new Decimal(0);
}
// age >= 14 => NC / no price
return new Decimal(0);
}
}
// Generic/default behavior (unchanged)
if (age <= 21) {
if (!isBlankPrice(row.PriceLTEQ21)) return toDecimalOrZero(row.PriceLTEQ21);
} else {
if (!isBlankPrice(row.PriceGT21)) return toDecimalOrZero(row.PriceGT21);
}
// Fallback to Price if tiered not available/blank
if (!isBlankPrice(row.Price)) return toDecimalOrZero(row.Price);
return new Decimal(0);
@@ -131,8 +170,9 @@ function getPriceForCodeWithAgeFromMap(
code: string,
age: number
): Decimal {
const row = map.get(normalizeCode(code));
return row ? pickPriceForRowByAge(row, age) : new Decimal(0);
const norm = normalizeCode(code);
const row = map.get(norm);
return row ? pickPriceForRowByAge(row, age, norm) : new Decimal(0);
}
// helper keeping lines empty,
@@ -251,10 +291,7 @@ export function applyComboToForm<T extends ClaimFormLike>(
procedureCode: code,
procedureDate: lineDate,
oralCavityArea: original?.oralCavityArea ?? "",
toothNumber:
preset.toothNumbers?.[j] ??
original?.toothNumber ??
"",
toothNumber: preset.toothNumbers?.[j] ?? original?.toothNumber ?? "",
toothSurface: original?.toothSurface ?? "",
totalBilled: price,
totalAdjusted: new Decimal(0),