diff --git a/.example.env b/.example.env index 87082129e92..127db15e710 100644 --- a/.example.env +++ b/.example.env @@ -67,6 +67,8 @@ REACT_STILL_WATCHING_IDLE_TIMEOUT= REACT_STILL_WATCHING_PROMPT_DURATION= # Feature flags +REACT_ENABLE_HCX=true +REACT_ENABLE_ABDM=true REACT_WARTIME_SHIFTING=true # JWT token refresh interval (in milliseconds) (default: 5 minutes) diff --git a/care.config.ts b/care.config.ts index 4ad8fd84654..e3effeca1b0 100644 --- a/care.config.ts +++ b/care.config.ts @@ -95,6 +95,14 @@ const careConfig = { "https://8801155bd0b848a09de9ebf6f387ebc8@sentry.io/5183632", environment: env.REACT_SENTRY_ENVIRONMENT || "staging", }, + + hcx: { + enabled: env.REACT_ENABLE_HCX === "true", + }, + + abdm: { + enabled: (env.REACT_ENABLE_ABDM ?? "true") === "true", + }, } as const; export default careConfig; diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index d05d36a30a3..ac86ff02c55 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -27,7 +27,7 @@ import { FieldError } from "../Form/FieldValidators"; import { useTranslation } from "react-i18next"; import useConfirmedAction from "../../Common/hooks/useConfirmedAction"; import ConfirmDialog from "../Common/ConfirmDialog"; -import { useFeatureFlags } from "../../Utils/featureFlags"; +import careConfig from "@careConfig"; interface PreDischargeFormInterface { new_discharge_reason: number | null; @@ -80,7 +80,6 @@ const DischargeModal = ({ const [isSendingDischargeApi, setIsSendingDischargeApi] = useState(false); const [facility, setFacility] = useState(referred_to); const [errors, setErrors] = useState({}); - const featureFlags = useFeatureFlags(); useEffect(() => { setPreDischargeForm((prev) => ({ @@ -385,7 +384,7 @@ const DischargeModal = ({ )} - {featureFlags.includes("HCX_ENABLED") && ( + {careConfig.hcx.enabled && ( // TODO: if policy and approved pre-auth exists

Claim Insurance

diff --git a/src/Components/HCX/InsuranceDetailsBuilder.tsx b/src/Components/HCX/InsuranceDetailsBuilder.tsx index b7ba094b86c..2c51d3b90d3 100644 --- a/src/Components/HCX/InsuranceDetailsBuilder.tsx +++ b/src/Components/HCX/InsuranceDetailsBuilder.tsx @@ -12,7 +12,7 @@ import { useDispatch } from "react-redux"; import { HCXActions } from "../../Redux/actions"; import { classNames } from "../../Utils/utils"; import InsurerAutocomplete from "./InsurerAutocomplete"; -import { useFeatureFlags } from "../../Utils/featureFlags"; +import careConfig from "@careConfig"; type Props = FormFieldBaseProps & { gridView?: boolean }; @@ -97,7 +97,6 @@ const InsuranceDetailEditCard = ({ policy.insurer_id && policy.insurer_name ? { code: policy.insurer_id, name: policy.insurer_name } : undefined; - const featureFlags = useFeatureFlags(); return (
@@ -133,7 +132,7 @@ const InsuranceDetailEditCard = ({ value={policy.policy_id} onChange={handleUpdate} /> - {featureFlags.includes("HCX_ENABLED") ? ( + {careConfig.hcx.enabled ? ( { const skills = arr.map((skill) => skill.skill_object.name); @@ -135,8 +135,6 @@ export default function PatientInfoCard(props: { prefetch: !!consultation?.treating_physician_object?.username, }); - const featureFlags = useFeatureFlags(); - return ( <>
- {featureFlags.includes("ABDM_ENABLED") && + {careConfig.abdm.enabled && (props.abhaNumber ? ( <> diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index b706d75ee1d..033d0187649 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -75,7 +75,6 @@ import _ from "lodash"; import { ILocalBodies } from "../ExternalResult/models.js"; import { useTranslation } from "react-i18next"; import careConfig from "@careConfig"; -import { useFeatureFlags } from "../../Utils/featureFlags.js"; const Loading = lazy(() => import("../Common/Loading")); const PageTitle = lazy(() => import("../Common/PageTitle")); @@ -514,15 +513,11 @@ export const PatientRegister = (props: PatientRegisterProps) => { prefetch: !!facilityId, }); - const featureFlags = useFeatureFlags(); - const validateForm = (form: any) => { const errors: Partial> = {}; const insuranceDetailsError = insuranceDetails - .map((policy) => - HCXPolicyValidator(policy, featureFlags.includes("HCX_ENABLED")), - ) + .map((policy) => HCXPolicyValidator(policy, careConfig.hcx.enabled)) .find((error) => !!error); setInsuranceDetailsError(insuranceDetailsError); @@ -832,7 +827,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { body: policy, }); - if (featureFlags.includes("HCX_ENABLED") && policyData?.id) { + if (careConfig.hcx.enabled && policyData?.id) { await request(routes.hcxCheckEligibility, { body: { policy: policyData?.id }, onResponse: ({ res }) => { @@ -1221,7 +1216,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { Import From External Results
- {featureFlags.includes("ABDM_ENABLED") && ( + {careConfig.abdm.enabled && (

ABHA Details diff --git a/src/Routers/AppRouter.tsx b/src/Routers/AppRouter.tsx index 930fde191aa..60e0f9411d5 100644 --- a/src/Routers/AppRouter.tsx +++ b/src/Routers/AppRouter.tsx @@ -28,7 +28,6 @@ import ExternalResultRoutes from "./routes/ExternalResultRoutes"; import { DetailRoute } from "./types"; import useAuthUser from "../Common/hooks/useAuthUser"; import careConfig from "@careConfig"; -import { useFeatureFlags } from "../Utils/featureFlags"; const Routes = { "/": () => , @@ -60,11 +59,10 @@ const Routes = { export default function AppRouter() { const authUser = useAuthUser(); - const featureFlags = useFeatureFlags(); let routes = Routes; - if (featureFlags.includes("HCX_ENABLED")) { + if (careConfig.hcx.enabled) { routes = { ...routes, ...HCXRoutes }; } diff --git a/src/Utils/featureFlags.tsx b/src/Utils/featureFlags.tsx index 7a1f4b79d1a..f5fe4ca0bd6 100644 --- a/src/Utils/featureFlags.tsx +++ b/src/Utils/featureFlags.tsx @@ -4,7 +4,7 @@ import routes from "../Redux/api"; import useAuthUser from "../Common/hooks/useAuthUser"; import { FacilityModel } from "../Components/Facility/models"; -export type FeatureFlag = "HCX_ENABLED" | "ABDM_ENABLED" | "SCRIBE_ENABLED"; +export type FeatureFlag = "SCRIBE_ENABLED"; // "HCX_ENABLED" | "ABDM_ENABLED" | export interface FeatureFlagsResponse { user_flags: FeatureFlag[];