From 2f2943952d289077bdb7e3fc8989cfa53c02a0c7 Mon Sep 17 00:00:00 2001 From: Khavin Shankar Date: Thu, 24 Oct 2024 08:10:16 +0530 Subject: [PATCH] Disable abha number linking when health facility id is not present (#8908) --- src/Locale/en.json | 2 + src/components/Patient/PatientInfoCard.tsx | 66 +++++++++++++++------- src/components/Patient/PatientRegister.tsx | 44 +++++++++++---- 3 files changed, 81 insertions(+), 31 deletions(-) diff --git a/src/Locale/en.json b/src/Locale/en.json index 833af3c4cda..3210a3e13f0 100644 --- a/src/Locale/en.json +++ b/src/Locale/en.json @@ -235,6 +235,7 @@ "abha_address_validation_length_error": "Should be atleast 4 character long", "abha_address_validation_start_error": "Shouldn't start with a number or dot (.)", "abha_details": "ABHA Details", + "abha_disabled_due_to_no_health_facility": "ABHA Number generation and linking is disabled for this facility, Please link a health facility to enable this feature.", "abha_link_options__create_with_aadhaar__description": "Create New ABHA Number Using Aadhaar Number", "abha_link_options__create_with_aadhaar__title": "Create with Aadhaar", "abha_link_options__create_with_driving_license__description": "Create New ABHA Number Using Driving License", @@ -669,6 +670,7 @@ "full_name": "Full Name", "full_screen": "Full Screen", "gender": "Gender", + "generate_link_abha": "Generate/Link ABHA Number", "generate_report": "Generate Report", "generated_summary_caution": "This is a computer generated summary using the information captured in the CARE system.", "generating": "Generating", diff --git a/src/components/Patient/PatientInfoCard.tsx b/src/components/Patient/PatientInfoCard.tsx index 4566cfbfb4f..bdc8b0e672d 100644 --- a/src/components/Patient/PatientInfoCard.tsx +++ b/src/components/Patient/PatientInfoCard.tsx @@ -1,5 +1,10 @@ import * as Notification from "../../Utils/Notifications"; - +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@/components/ui/tooltip"; import { CONSULTATION_SUGGESTION, DISCHARGE_REASONS, @@ -43,6 +48,7 @@ import { SkillModel } from "../Users/models"; import { AuthorizedForConsultationRelatedActions } from "../../CAREUI/misc/AuthorizedChild"; import LinkAbhaNumber from "../ABDM/LinkAbhaNumber/index"; import careConfig from "@careConfig"; +import { cn } from "@/lib/utils.js"; const formatSkills = (arr: SkillModel[]) => { const skills = arr.map((skill) => skill.skill_object.name); @@ -133,6 +139,11 @@ export default function PatientInfoCard(props: { prefetch: !!consultation?.treating_physician_object?.username, }); + const { data: healthFacility } = useQuery(routes.abdm.healthFacility.get, { + pathParams: { facility_id: patient.facility ?? "" }, + silent: true, + }); + return ( <> ) : ( - - {({ close }) => ( -
{ - close(); - setShowLinkABHANumber(true); - }} - > - - -

{t("link_abha_profile")}

-
-
- )} -
+ + + + + {({ close, disabled }) => ( +
{ + close(); + setShowLinkABHANumber(true); + }} + > + + +

{t("generate_link_abha")}

+
+
+ )} +
+
+ + {!healthFacility && ( + + {t("abha_disabled_due_to_no_health_facility")} + + )} +
+
))}
diff --git a/src/components/Patient/PatientRegister.tsx b/src/components/Patient/PatientRegister.tsx index a39330dd0ee..77f43c04251 100644 --- a/src/components/Patient/PatientRegister.tsx +++ b/src/components/Patient/PatientRegister.tsx @@ -28,7 +28,12 @@ import { import { useCallback, useReducer, useRef, useState } from "react"; import { navigate } from "raviger"; import { statusType, useAbortableEffect } from "@/common/utils"; - +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@/components/ui/tooltip"; import AccordionV2 from "@/components/Common/components/AccordionV2"; import AutocompleteFormField from "../Form/FormFields/Autocomplete"; import ButtonV2 from "@/components/Common/components/ButtonV2"; @@ -372,6 +377,11 @@ export const PatientRegister = (props: PatientRegisterProps) => { [id], ); + const { data: healthFacility } = useQuery(routes.abdm.healthFacility.get, { + pathParams: { facility_id: facilityId }, + silent: true, + }); + useQuery(routes.hcx.policies.list, { query: { patient: id, @@ -1015,16 +1025,28 @@ export const PatientRegister = (props: PatientRegisterProps) => {
{!state.form.abha_number && (
- + + + + + + {!healthFacility && ( + + {t("abha_disabled_due_to_no_health_facility")} + + )} + +
)} {showAlertMessage.show && (