Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable abha number linking when health facility id is not present #8908

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
66 changes: 46 additions & 20 deletions src/components/Patient/PatientInfoCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import * as Notification from "../../Utils/Notifications";

import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";
import {
CONSULTATION_SUGGESTION,
DISCHARGE_REASONS,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 (
<>
<DialogModal
Expand Down Expand Up @@ -781,25 +792,40 @@ export default function PatientInfoCard(props: {
</MenuItem>
</>
) : (
<MenuItem>
{({ close }) => (
<div
className="dropdown-item-primary pointer-events-auto m-2 flex cursor-pointer items-center justify-start gap-2 rounded border-0 p-2 text-sm font-normal transition-all duration-200 ease-in-out"
onClick={() => {
close();
setShowLinkABHANumber(true);
}}
>
<span className="flex w-full items-center justify-start gap-2">
<CareIcon
icon="l-link"
className="text-lg text-primary-500"
/>
<p>{t("link_abha_profile")}</p>
</span>
</div>
)}
</MenuItem>
<TooltipProvider>
<Tooltip>
<TooltipTrigger>
<MenuItem disabled={!healthFacility}>
{({ close, disabled }) => (
<div
className={cn(
"dropdown-item-primary pointer-events-auto m-2 flex cursor-pointer items-center justify-start gap-2 rounded border-0 p-2 text-sm font-normal transition-all duration-200 ease-in-out",
disabled && "pointer-events-none opacity-30",
)}
onClick={() => {
close();
setShowLinkABHANumber(true);
}}
>
<span className="flex w-full items-center justify-start gap-2">
<CareIcon
icon="l-link"
className="text-lg text-primary-500"
/>
<p>{t("generate_link_abha")}</p>
</span>
</div>
)}
</MenuItem>
</TooltipTrigger>

{!healthFacility && (
<TooltipContent className="max-w-sm break-words text-sm">
{t("abha_disabled_due_to_no_health_facility")}
</TooltipContent>
)}
</Tooltip>
</TooltipProvider>
))}
</div>
<div>
Expand Down
44 changes: 33 additions & 11 deletions src/components/Patient/PatientRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1015,16 +1025,28 @@ export const PatientRegister = (props: PatientRegisterProps) => {
</div>
{!state.form.abha_number && (
<div className="flex justify-center md:justify-end">
<Button
variant="outline_primary"
onClick={(e) => {
e.preventDefault();
setShowLinkAbhaNumberModal(true);
}}
>
<CareIcon icon="l-user-square" className="mr-2" />
<span>Generate/Link ABHA Number</span>
</Button>
<TooltipProvider>
<Tooltip>
<TooltipTrigger>
<Button
variant="outline_primary"
disabled={!healthFacility}
onClick={(e) => {
e.preventDefault();
setShowLinkAbhaNumberModal(true);
}}
>
<CareIcon icon="l-user-square" className="mr-2" />
<span>{t("generate_link_abha")}</span>
</Button>
</TooltipTrigger>
{!healthFacility && (
<TooltipContent className="max-w-sm break-words text-sm">
{t("abha_disabled_due_to_no_health_facility")}
</TooltipContent>
)}
</Tooltip>
</TooltipProvider>
</div>
)}
{showAlertMessage.show && (
Expand Down
Loading