From a288d648922319b71db027cb37e2b816a626bf2f Mon Sep 17 00:00:00 2001 From: vivek Date: Mon, 13 Nov 2023 22:48:49 +0530 Subject: [PATCH 1/2] Implemented Insurance Details Page --- src/Components/HCX/models.ts | 4 +- src/Components/Patient/InsuranceDetails.tsx | 102 ++++++++++++++++++++ src/Components/Patient/PatientHome.tsx | 78 ++++++++++++++- src/Redux/api.tsx | 2 + src/Routers/routes/PatientRoutes.tsx | 4 + 5 files changed, 187 insertions(+), 3 deletions(-) create mode 100644 src/Components/Patient/InsuranceDetails.tsx diff --git a/src/Components/HCX/models.ts b/src/Components/HCX/models.ts index 7e624c474d7..a8a9812d31d 100644 --- a/src/Components/HCX/models.ts +++ b/src/Components/HCX/models.ts @@ -26,8 +26,8 @@ export interface HCXPolicyModel { patient_object?: PatientModel; subscriber_id: string; policy_id: string; - insurer_id: string; - insurer_name: string; + insurer_id?: string; + insurer_name?: string; status?: HCXPolicyStatus; priority?: "Immediate" | "Normal" | "Deferred"; purpose?: "Auth Requirements" | "Benefits" | "Discovery" | "Validation"; diff --git a/src/Components/Patient/InsuranceDetails.tsx b/src/Components/Patient/InsuranceDetails.tsx new file mode 100644 index 00000000000..76069a6fe95 --- /dev/null +++ b/src/Components/Patient/InsuranceDetails.tsx @@ -0,0 +1,102 @@ +import { lazy } from "react"; + +import Page from "../Common/components/Page"; + +import useQuery from "../../Utils/request/useQuery"; +import routes from "../../Redux/api"; +import { HCXPolicyModel } from "../HCX/models"; + +const Loading = lazy(() => import("../Common/Loading")); + +interface IProps { + facilityId: string; + id: string; +} + +export const InsuranceDetails = (props: IProps) => { + const { facilityId, id } = props; + + const { data: insuranceDetials, loading } = useQuery(routes.listHCXPolicies, { + query: { + patient: id, + }, + }); + + if (loading) { + return ; + } + + return ( + + {loading ? ( + + ) : insuranceDetials?.count === 0 ? ( +
+ No Insurance Details Available +
+ ) : ( +
+ {insuranceDetials?.results.map((data: HCXPolicyModel) => ( +
+
+
+ Policy Details +
+ +
+
+
+ Member ID +
+
+ {data.subscriber_id || ""} +
+
+
+
+ Policy ID / Policy Name +
+
+ {data.policy_id || ""} +
+
+
+
+ Insurer ID +
+
+ {data.insurer_id || ""} +
+
+
+
+ Insurer Name +
+
+ {data.insurer_name || ""} +
+
+
+
+
+ ))} +
+ )} +
+ ); +}; diff --git a/src/Components/Patient/PatientHome.tsx b/src/Components/Patient/PatientHome.tsx index b6ceaf2e4dc..61f74d616cb 100644 --- a/src/Components/Patient/PatientHome.tsx +++ b/src/Components/Patient/PatientHome.tsx @@ -32,6 +32,8 @@ import UserAutocompleteFormField from "../Common/UserAutocompleteFormField"; import dayjs from "../../Utils/dayjs"; import { triggerGoal } from "../../Integrations/Plausible"; import useAuthUser from "../../Common/hooks/useAuthUser"; +import useQuery from "../../Utils/request/useQuery"; +import routes from "../../Redux/api"; const Loading = lazy(() => import("../Common/Loading")); @@ -91,6 +93,15 @@ export const PatientHome = (props: any) => { }); }; + const { data: insuranceDetials, loading: insuranceDetailsLoading } = useQuery( + routes.listHCXPolicies, + { + query: { + patient: id, + }, + } + ); + const handleAssignedVolunteer = () => { dispatch( patchPatient( @@ -975,7 +986,7 @@ export const PatientHome = (props: any) => {
@@ -1110,6 +1121,71 @@ export const PatientHome = (props: any) => {
+
+
+
+ Insurance Details +
+ + {insuranceDetials?.count == 0 || insuranceDetailsLoading ? ( +
+ No Insurance Data Available +
+ ) : ( +
+
+
+ Member ID +
+
+ {insuranceDetials?.results[0]?.subscriber_id || ""} +
+
+
+
+ Policy ID / Policy Name +
+
+ {insuranceDetials?.results[0]?.policy_id || ""} +
+
+
+
+ Insurer ID +
+
+ {insuranceDetials?.results[0]?.insurer_id || ""} +
+
+
+
+ Insurer Name +
+
+ {insuranceDetials?.results[0]?.insurer_name || ""} +
+
+ + {insuranceDetials?.count && insuranceDetials?.count > 1 && ( +
+
+ { + navigate( + `/facility/${patientData?.facility}/patient/${id}/insurance` + ); + }} + className="h-auto whitespace-pre-wrap border border-gray-500 bg-white text-black hover:bg-gray-300" + > + View All Details + +
+
+ )} +
+ )} +
+
diff --git a/src/Redux/api.tsx b/src/Redux/api.tsx index 1ff80b55304..f300c594b98 100644 --- a/src/Redux/api.tsx +++ b/src/Redux/api.tsx @@ -52,6 +52,7 @@ import { import { PatientModel } from "../Components/Patient/models"; import { IComment, IResource } from "../Components/Resource/models"; import { IShift } from "../Components/Shifting/models"; +import { HCXPolicyModel } from "../Components/HCX/models"; /** * A fake function that returns an empty object casted to type T @@ -1163,6 +1164,7 @@ const routes = { listHCXPolicies: { path: "/api/v1/hcx/policy/", method: "GET", + TRes: Type>(), }, createHCXPolicy: { diff --git a/src/Routers/routes/PatientRoutes.tsx b/src/Routers/routes/PatientRoutes.tsx index ae594d767ec..ce2798c4492 100644 --- a/src/Routers/routes/PatientRoutes.tsx +++ b/src/Routers/routes/PatientRoutes.tsx @@ -6,6 +6,7 @@ import PatientNotes from "../../Components/Patient/PatientNotes"; import { PatientRegister } from "../../Components/Patient/PatientRegister"; import { DetailRoute } from "../types"; import DeathReport from "../../Components/DeathReport/DeathReport"; +import { InsuranceDetails } from "../../Components/Patient/InsuranceDetails"; export default { "/patients": () => , @@ -21,6 +22,9 @@ export default { "/facility/:facilityId/patient/:id": ({ facilityId, id }: any) => ( ), + "/facility/:facilityId/patient/:id/insurance": ({ facilityId, id }: any) => ( + + ), "/facility/:facilityId/patient/:id/update": ({ facilityId, id }: any) => ( ), From 3eb5283f30c29e3726cec894a23c306ca873a8f0 Mon Sep 17 00:00:00 2001 From: vivek Date: Thu, 16 Nov 2023 21:27:36 +0530 Subject: [PATCH 2/2] implemented insurace details card --- src/Components/Patient/InsuranceDetails.tsx | 44 +--------- .../Patient/InsuranceDetailsCard.tsx | 78 +++++++++++++++++ src/Components/Patient/PatientHome.tsx | 86 +++---------------- 3 files changed, 94 insertions(+), 114 deletions(-) create mode 100644 src/Components/Patient/InsuranceDetailsCard.tsx diff --git a/src/Components/Patient/InsuranceDetails.tsx b/src/Components/Patient/InsuranceDetails.tsx index 76069a6fe95..dc8df8ff8a9 100644 --- a/src/Components/Patient/InsuranceDetails.tsx +++ b/src/Components/Patient/InsuranceDetails.tsx @@ -5,6 +5,7 @@ import Page from "../Common/components/Page"; import useQuery from "../../Utils/request/useQuery"; import routes from "../../Redux/api"; import { HCXPolicyModel } from "../HCX/models"; +import { InsuranceDetialsCard } from "./InsuranceDetailsCard"; const Loading = lazy(() => import("../Common/Loading")); @@ -52,48 +53,7 @@ export const InsuranceDetails = (props: IProps) => { data-testid="patient-details" > {insuranceDetials?.results.map((data: HCXPolicyModel) => ( -
-
-
- Policy Details -
- -
-
-
- Member ID -
-
- {data.subscriber_id || ""} -
-
-
-
- Policy ID / Policy Name -
-
- {data.policy_id || ""} -
-
-
-
- Insurer ID -
-
- {data.insurer_id || ""} -
-
-
-
- Insurer Name -
-
- {data.insurer_name || ""} -
-
-
-
-
+ ))}
)} diff --git a/src/Components/Patient/InsuranceDetailsCard.tsx b/src/Components/Patient/InsuranceDetailsCard.tsx new file mode 100644 index 00000000000..b928ce7bffd --- /dev/null +++ b/src/Components/Patient/InsuranceDetailsCard.tsx @@ -0,0 +1,78 @@ +import ButtonV2 from "../Common/components/ButtonV2"; +import { HCXPolicyModel } from "../HCX/models"; +import { navigate } from "raviger"; + +interface InsuranceDetails { + data?: HCXPolicyModel; + showViewAllDetails?: boolean; +} + +export const InsuranceDetialsCard = (props: InsuranceDetails) => { + const { data, showViewAllDetails } = props; + + return ( +
+
+
+ Policy Details +
+ {data ? ( +
+
+
+ Member ID +
+
+ {data.subscriber_id || ""} +
+
+
+
+ Policy ID / Policy Name +
+
+ {data.policy_id || ""} +
+
+
+
+ Insurer ID +
+
+ {data.insurer_id || ""} +
+
+
+
+ Insurer Name +
+
+ {data.insurer_name || ""} +
+
+ {showViewAllDetails && ( +
+
+ { + navigate( + `/facility/${data.patient_object?.facility_object?.id}/patient/${data.patient_object?.id}/insurance` + ); + }} + className="h-auto whitespace-pre-wrap border border-gray-500 bg-white text-black hover:bg-gray-300" + > + View All Details + +
+
+ )} +
+ ) : ( +
+ No Insurance Details Available +
+ )} +
+
+ ); +}; diff --git a/src/Components/Patient/PatientHome.tsx b/src/Components/Patient/PatientHome.tsx index 61f74d616cb..4988d7d1845 100644 --- a/src/Components/Patient/PatientHome.tsx +++ b/src/Components/Patient/PatientHome.tsx @@ -34,6 +34,7 @@ import { triggerGoal } from "../../Integrations/Plausible"; import useAuthUser from "../../Common/hooks/useAuthUser"; import useQuery from "../../Utils/request/useQuery"; import routes from "../../Redux/api"; +import { InsuranceDetialsCard } from "./InsuranceDetailsCard"; const Loading = lazy(() => import("../Common/Loading")); @@ -93,14 +94,12 @@ export const PatientHome = (props: any) => { }); }; - const { data: insuranceDetials, loading: insuranceDetailsLoading } = useQuery( - routes.listHCXPolicies, - { - query: { - patient: id, - }, - } - ); + const { data: insuranceDetials } = useQuery(routes.listHCXPolicies, { + query: { + patient: id, + limit: 1, + }, + }); const handleAssignedVolunteer = () => { dispatch( @@ -1121,71 +1120,14 @@ export const PatientHome = (props: any) => { -
-
-
- Insurance Details -
- - {insuranceDetials?.count == 0 || insuranceDetailsLoading ? ( -
- No Insurance Data Available -
- ) : ( -
-
-
- Member ID -
-
- {insuranceDetials?.results[0]?.subscriber_id || ""} -
-
-
-
- Policy ID / Policy Name -
-
- {insuranceDetials?.results[0]?.policy_id || ""} -
-
-
-
- Insurer ID -
-
- {insuranceDetials?.results[0]?.insurer_id || ""} -
-
-
-
- Insurer Name -
-
- {insuranceDetials?.results[0]?.insurer_name || ""} -
-
- {insuranceDetials?.count && insuranceDetials?.count > 1 && ( -
-
- { - navigate( - `/facility/${patientData?.facility}/patient/${id}/insurance` - ); - }} - className="h-auto whitespace-pre-wrap border border-gray-500 bg-white text-black hover:bg-gray-300" - > - View All Details - -
-
- )} -
- )} -
-
+ 1 + } + />