From 43f988444a3a49fa3dcb37b91db4e9083df42b5a Mon Sep 17 00:00:00 2001 From: Khavin Shankar Date: Thu, 26 Feb 2026 00:05:26 +0530 Subject: [PATCH] remove year validation for scan and share patient search --- src/apis/index.ts | 4 +-- src/components/TokenSearchDialog.tsx | 53 ++++++++++------------------ src/types/patient.ts | 5 +++ 3 files changed, 25 insertions(+), 37 deletions(-) diff --git a/src/apis/index.ts b/src/apis/index.ts index 132dfca..a7f4ff3 100644 --- a/src/apis/index.ts +++ b/src/apis/index.ts @@ -12,7 +12,7 @@ import { GovtOrganization } from "@/types/govtOrganization"; import { HealthFacility } from "@/types/healthFacility"; import { HealthInformation } from "@/types/healthInformation"; import { PaginatedResponse } from "./types"; -import { PartialPatient } from "@/types/patient"; +import { Patient } from "@/types/patient"; import { User } from "@/types/user"; // FIXME: Move all the api specific types to a ./types.ts file @@ -421,7 +421,7 @@ export const apis = { token: number; facility_id: string; }) => { - return await request( + return await request( `/api/abdm/v3/hip/patient/fetch-by-token/` + queryString(query) ); }, diff --git a/src/components/TokenSearchDialog.tsx b/src/components/TokenSearchDialog.tsx index 714da72..7c40b54 100644 --- a/src/components/TokenSearchDialog.tsx +++ b/src/components/TokenSearchDialog.tsx @@ -11,7 +11,7 @@ import { FC, useMemo, useState } from "react"; import { ArrowRightIcon } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; -import { PartialPatient } from "@/types/patient"; +import { Patient } from "@/types/patient"; import { Skeleton } from "@/components/ui/skeleton"; import { apis } from "@/apis"; import { navigate } from "raviger"; @@ -107,7 +107,7 @@ const TokenSearchDialog: FC = ({ )} {!isFetching && isEnabled && patient && ( - + )} @@ -116,11 +116,24 @@ const TokenSearchDialog: FC = ({ ); }; -const PartialPatientCard: FC<{ patient: PartialPatient }> = ({ patient }) => { - const [yearOfBirth, setYearOfBirth] = useState(""); +const PatientCard: FC<{ patient: Patient }> = ({ patient }) => { + const yearOfBirth = useMemo(() => { + return patient.year_of_birth ?? patient.date_of_birth?.split("-")[0]; + }, [patient]); return ( -
+
{ + navigate("patients/verify", { + query: { + phone_number: patient.phone_number, + year_of_birth: yearOfBirth, + partial_id: patient.partial_id || patient.id.slice(0, 5), + }, + }); + }} + className="border rounded-md p-4 cursor-pointer" + >
{patient.name}
@@ -132,36 +145,6 @@ const PartialPatientCard: FC<{ patient: PartialPatient }> = ({ patient }) => { #{patient.id.slice(0, 8)}
- -
- setYearOfBirth(e.target.value)} - minLength={4} - maxLength={4} - className="flex-1" - /> - -
); }; diff --git a/src/types/patient.ts b/src/types/patient.ts index e6d46ad..d0cfa98 100644 --- a/src/types/patient.ts +++ b/src/types/patient.ts @@ -1,5 +1,10 @@ export type Patient = { id: string; + name: string; + gender: "male" | "female" | "transgender"; + phone_number: string; + date_of_birth?: string | null; + year_of_birth?: string | null; [key: string]: unknown; };