feat: picking a policy holder copies their insurance, address and status
Selecting a policy holder from the patient search fills the dependent's insurance type, member ID, group number, status, address, city, state and zip from the holder's record. Dependents may now share the holder's insurance ID without the duplicate-ID check blocking the save. Also teach the AI CDT lookup that "PNAO" is a typo of "pano" (D0330). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -72,6 +72,7 @@ const ALIAS_MAP: Record<string, string> = {
|
||||
"fmx": "intraoral complete series",
|
||||
"pano": "panoramic",
|
||||
"panorex": "panoramic",
|
||||
"pnao": "panoramic", // common typo of "pano"
|
||||
"bitewing": "bitewing",
|
||||
"bw": "bitewing two",
|
||||
"2bw": "bitewing two",
|
||||
|
||||
@@ -223,6 +223,11 @@ router.post("/create-temp", async (req: Request, res: Response): Promise<any> =>
|
||||
}
|
||||
});
|
||||
|
||||
// Dependents (spouse, children) are covered under the subscriber's member ID, so a
|
||||
// shared insurance ID is expected when the patient has a policy holder.
|
||||
const hasPolicyHolder = (p: { policyHolder?: string | null; policyHolderPatientId?: number | null }) =>
|
||||
p.policyHolderPatientId != null || !!(p.policyHolder ?? "").trim();
|
||||
|
||||
// Create a new patient
|
||||
router.post("/", async (req: Request, res: Response): Promise<any> => {
|
||||
try {
|
||||
@@ -242,7 +247,7 @@ router.post("/", async (req: Request, res: Response): Promise<any> => {
|
||||
const patientData = insertPatientSchema.parse(body);
|
||||
|
||||
// Check for duplicate insuranceId if it's provided
|
||||
if (patientData.insuranceId) {
|
||||
if (patientData.insuranceId && !hasPolicyHolder(patientData as any)) {
|
||||
const existingPatient = await storage.getPatientByInsuranceId(
|
||||
patientData.insuranceId as string
|
||||
);
|
||||
@@ -307,7 +312,8 @@ router.put(
|
||||
// If updating insuranceId, check for uniqueness (excluding self)
|
||||
if (
|
||||
patientData.insuranceId &&
|
||||
patientData.insuranceId !== existingPatient.insuranceId
|
||||
patientData.insuranceId !== existingPatient.insuranceId &&
|
||||
!hasPolicyHolder({ ...existingPatient, ...(patientData as any) })
|
||||
) {
|
||||
const duplicatePatient = await storage.getPatientByInsuranceId(
|
||||
patientData.insuranceId as string
|
||||
|
||||
@@ -34,6 +34,11 @@ export interface IStorage {
|
||||
dateOfBirth: Date;
|
||||
insuranceId: string | null;
|
||||
insuranceProvider: string | null;
|
||||
groupNumber: string | null;
|
||||
address: string | null;
|
||||
city: string | null;
|
||||
state: string | null;
|
||||
zipCode: string | null;
|
||||
status: string;
|
||||
}[]
|
||||
>;
|
||||
@@ -184,6 +189,11 @@ export const patientsStorage: IStorage = {
|
||||
dateOfBirth: true,
|
||||
insuranceId: true,
|
||||
insuranceProvider: true,
|
||||
groupNumber: true,
|
||||
address: true,
|
||||
city: true,
|
||||
state: true,
|
||||
zipCode: true,
|
||||
status: true,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user