From 0b3279fc9812afde4a2d552b0d5db733b633e9e2 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Tue, 4 Feb 2025 23:45:38 +0530 Subject: [PATCH 1/3] Filter allergies by encounter if encounter is marked as completed --- src/components/Patient/allergy/list.tsx | 12 ++++++++++-- src/pages/Encounters/tabs/EncounterUpdatesTab.tsx | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/Patient/allergy/list.tsx b/src/components/Patient/allergy/list.tsx index a4a91bae6a1..61d4afbbfb2 100644 --- a/src/components/Patient/allergy/list.tsx +++ b/src/components/Patient/allergy/list.tsx @@ -22,24 +22,32 @@ import { Avatar } from "@/components/Common/Avatar"; import query from "@/Utils/request/query"; import { AllergyIntolerance } from "@/types/emr/allergyIntolerance/allergyIntolerance"; import allergyIntoleranceApi from "@/types/emr/allergyIntolerance/allergyIntoleranceApi"; +import { Encounter, completedEncounterStatus } from "@/types/emr/encounter"; interface AllergyListProps { facilityId?: string; patientId: string; encounterId?: string; + encounterStatus: Encounter["status"]; } export function AllergyList({ facilityId, patientId, encounterId, + encounterStatus, }: AllergyListProps) { const [showEnteredInError, setShowEnteredInError] = useState(false); const { data: allergies, isLoading } = useQuery({ - queryKey: ["allergies", patientId, encounterId], + queryKey: ["allergies", patientId, encounterId, encounterStatus], queryFn: query(allergyIntoleranceApi.getAllergy, { pathParams: { patientId }, + queryParams: { + encounter: completedEncounterStatus.includes(encounterStatus as string) + ? encounterId + : undefined, + }, }), }); @@ -233,7 +241,7 @@ const AllergyListLayout = ({ {t("allergies")} - {facilityId && encounterId && ( + {facilityId && ( From b816e20ad6c70565e6d49873db937e73460b4663 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Tue, 4 Feb 2025 23:52:30 +0530 Subject: [PATCH 2/3] fix type --- src/components/Patient/allergy/list.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Patient/allergy/list.tsx b/src/components/Patient/allergy/list.tsx index 61d4afbbfb2..3eed3b32e40 100644 --- a/src/components/Patient/allergy/list.tsx +++ b/src/components/Patient/allergy/list.tsx @@ -28,7 +28,7 @@ interface AllergyListProps { facilityId?: string; patientId: string; encounterId?: string; - encounterStatus: Encounter["status"]; + encounterStatus?: Encounter["status"]; } export function AllergyList({ From c242c96ff7896981b2a0272bf00ad1312f1576c7 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Wed, 5 Feb 2025 00:00:17 +0530 Subject: [PATCH 3/3] show edit button only if encounter id is present --- src/components/Patient/allergy/list.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Patient/allergy/list.tsx b/src/components/Patient/allergy/list.tsx index 3eed3b32e40..623aaf416d8 100644 --- a/src/components/Patient/allergy/list.tsx +++ b/src/components/Patient/allergy/list.tsx @@ -241,7 +241,7 @@ const AllergyListLayout = ({ {t("allergies")} - {facilityId && ( + {facilityId && encounterId && (