Skip to content

Commit

Permalink
revert other changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker committed Sep 20, 2024
1 parent 84f366e commit 089d5f8
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .example.env
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions care.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ const careConfig = {
"https://[email protected]/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;
5 changes: 2 additions & 3 deletions src/Components/Facility/DischargeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -80,7 +80,6 @@ const DischargeModal = ({
const [isSendingDischargeApi, setIsSendingDischargeApi] = useState(false);
const [facility, setFacility] = useState<FacilityModel | null>(referred_to);
const [errors, setErrors] = useState<any>({});
const featureFlags = useFeatureFlags();

useEffect(() => {
setPreDischargeForm((prev) => ({
Expand Down Expand Up @@ -385,7 +384,7 @@ const DischargeModal = ({
)}
</div>

{featureFlags.includes("HCX_ENABLED") && (
{careConfig.hcx.enabled && (
// TODO: if policy and approved pre-auth exists
<div className="my-5 rounded p-5 shadow">
<h2 className="mb-2">Claim Insurance</h2>
Expand Down
5 changes: 2 additions & 3 deletions src/Components/HCX/InsuranceDetailsBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HCXPolicyModel[]> & { gridView?: boolean };

Expand Down Expand Up @@ -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 (
<div className="rounded-lg border-2 border-dashed border-secondary-200 p-4">
Expand Down Expand Up @@ -133,7 +132,7 @@ const InsuranceDetailEditCard = ({
value={policy.policy_id}
onChange={handleUpdate}
/>
{featureFlags.includes("HCX_ENABLED") ? (
{careConfig.hcx.enabled ? (
<InsurerAutocomplete
required
name="insurer_"
Expand Down
8 changes: 3 additions & 5 deletions src/Components/Patient/PatientInfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import FetchRecordsModal from "../ABDM/FetchRecordsModal.js";
import { AbhaNumberModel } from "../ABDM/types/abha.js";
import { SkillModel } from "../Users/models.js";
import { AuthorizedForConsultationRelatedActions } from "../../CAREUI/misc/AuthorizedChild.js";
import { useFeatureFlags } from "../../Utils/featureFlags.js";
import careConfig from "@careConfig";

const formatSkills = (arr: SkillModel[]) => {
const skills = arr.map((skill) => skill.skill_object.name);
Expand Down Expand Up @@ -135,8 +135,6 @@ export default function PatientInfoCard(props: {
prefetch: !!consultation?.treating_physician_object?.username,
});

const featureFlags = useFeatureFlags();

return (
<>
<DialogModal
Expand Down Expand Up @@ -667,7 +665,7 @@ export default function PatientInfoCard(props: {
],
]
.concat(
featureFlags.includes("HCX_ENABLED")
careConfig.hcx.enabled
? [
[
`/facility/${patient.facility}/patient/${patient.id}/consultation/${consultation?.id}/claims`,
Expand Down Expand Up @@ -737,7 +735,7 @@ export default function PatientInfoCard(props: {
</div>

<div>
{featureFlags.includes("ABDM_ENABLED") &&
{careConfig.abdm.enabled &&
(props.abhaNumber ? (
<>
<MenuItem>
Expand Down
11 changes: 3 additions & 8 deletions src/Components/Patient/PatientRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -514,15 +513,11 @@ export const PatientRegister = (props: PatientRegisterProps) => {
prefetch: !!facilityId,
});

const featureFlags = useFeatureFlags();

const validateForm = (form: any) => {
const errors: Partial<Record<keyof any, FieldError>> = {};

const insuranceDetailsError = insuranceDetails
.map((policy) =>
HCXPolicyValidator(policy, featureFlags.includes("HCX_ENABLED")),
)
.map((policy) => HCXPolicyValidator(policy, careConfig.hcx.enabled))
.find((error) => !!error);
setInsuranceDetailsError(insuranceDetailsError);

Expand Down Expand Up @@ -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 }) => {
Expand Down Expand Up @@ -1221,7 +1216,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
Import From External Results
</ButtonV2>
</div>
{featureFlags.includes("ABDM_ENABLED") && (
{careConfig.abdm.enabled && (
<div className="mb-8 overflow-visible rounded border border-secondary-200 p-4">
<h1 className="mb-4 text-left text-xl font-bold text-purple-500">
ABHA Details
Expand Down
4 changes: 1 addition & 3 deletions src/Routers/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
"/": () => <Redirect to="/facility" />,
Expand Down Expand Up @@ -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 };
}

Expand Down
2 changes: 1 addition & 1 deletion src/Utils/featureFlags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down

0 comments on commit 089d5f8

Please sign in to comment.