From 63a28a565cde5f735e8d74bb5c0bcefdd75f34ae Mon Sep 17 00:00:00 2001 From: Khavin Shankar Date: Mon, 21 Oct 2024 18:44:24 +0530 Subject: [PATCH] disable abha number linking when health facility id is not present --- src/Components/Patient/PatientInfoCard.tsx | 66 +++++++++++++++------- src/Components/Patient/PatientRegister.tsx | 44 +++++++++++---- src/Locale/en.json | 2 + 3 files changed, 81 insertions(+), 31 deletions(-) diff --git a/src/Components/Patient/PatientInfoCard.tsx b/src/Components/Patient/PatientInfoCard.tsx index 7e3a9563799..deb3708451c 100644 --- a/src/Components/Patient/PatientInfoCard.tsx +++ b/src/Components/Patient/PatientInfoCard.tsx @@ -1,5 +1,10 @@ import * as Notification from "../../Utils/Notifications.js"; - +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@/Components/ui/tooltip"; import { CONSULTATION_SUGGESTION, DISCHARGE_REASONS, @@ -43,6 +48,7 @@ import { SkillModel } from "../Users/models.js"; import { AuthorizedForConsultationRelatedActions } from "../../CAREUI/misc/AuthorizedChild.js"; import LinkAbhaNumber from "../ABDM/LinkAbhaNumber"; 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 8cfd1a74ce3..cb007bb224f 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 "../Common/components/AccordionV2"; import AutocompleteFormField from "../Form/FormFields/Autocomplete.js"; import ButtonV2 from "../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, @@ -1013,16 +1023,28 @@ export const PatientRegister = (props: PatientRegisterProps) => {
{!state.form.abha_number && (
- + + + + + + {!healthFacility && ( + + {t("abha_disabled_due_to_no_health_facility")} + + )} + +
)} {showAlertMessage.show && ( diff --git a/src/Locale/en.json b/src/Locale/en.json index e516ec61733..e54fcf451e2 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", @@ -666,6 +667,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",