diff --git a/src/Components/ABDM/ABDMFacilityRecords.tsx b/src/Components/ABDM/ABDMFacilityRecords.tsx new file mode 100644 index 00000000000..823d8905e27 --- /dev/null +++ b/src/Components/ABDM/ABDMFacilityRecords.tsx @@ -0,0 +1,146 @@ +import { Link } from "raviger"; +import routes from "../../Redux/api"; +import useQuery from "../../Utils/request/useQuery"; +import { formatDateTime } from "../../Utils/utils"; +import Loading from "../Common/Loading"; +import Page from "../Common/components/Page"; + +interface IProps { + facilityId: string; +} + +const TableHeads = [ + "Patient", + "Status", + "Created On", + "Requested By", + "Health Information Range", + "Expires On", + "HI Profiles", +]; + +export default function ABDMFacilityRecords({ facilityId }: IProps) { + const { data: consentsResult, loading } = useQuery(routes.listConsents, { + query: { facility: facilityId, ordering: "-created_date" }, + }); + + if (loading) { + return ; + } + + return ( + +
+
+
+
+
+ {/* eslint-disable-next-line tailwindcss/migration-from-tailwind-2 */} +
+ + + + {TableHeads.map((head) => ( + + ))} + + + + + {consentsResult?.results.map((consent) => ( + + + + + + + + + + + + + + + + + + ))} + +
+ {head} + + View +
+ {consent.patient_abha_object?.name} +

+ ({consent.patient_abha}) +

+
+ {consent.status} + + {formatDateTime(consent.created_date)} + + {`${consent.requester?.first_name} ${consent.requester?.last_name}`.trim()} +

+ ({consent.requester.username}) +

+
+ {formatDateTime( + consent.consent_artefacts?.[0]?.from_time ?? + consent.from_time + )}{" "} +
+ {formatDateTime( + consent.consent_artefacts?.[0]?.to_time ?? + consent.to_time + )} +
+ {formatDateTime( + consent.consent_artefacts?.[0]?.expiry ?? + consent.expiry + )} + +
+ {( + consent.consent_artefacts?.[0]?.hi_types ?? + consent.hi_types + )?.map((hiType) => ( + + {hiType} + + ))} +
+
+
+ {consent.consent_artefacts?.map((artefact, i) => + artefact.status === "GRANTED" ? ( + + View Artefact {i + 1} + + ) : ( +

+ Artefact {i + 1} +

+ ) + )} +
+
+
+
+
+
+
+
+ ); +} diff --git a/src/Components/ABDM/FetchRecordsModal.tsx b/src/Components/ABDM/FetchRecordsModal.tsx index cd437e5a330..85ced7de043 100644 --- a/src/Components/ABDM/FetchRecordsModal.tsx +++ b/src/Components/ABDM/FetchRecordsModal.tsx @@ -44,7 +44,7 @@ export default function FetchRecordsModal({ patient, show, onClose }: IProps) { const [isMakingConsentRequest, setIsMakingConsentRequest] = useState(false); const [hiTypes, setHiTypes] = useState([]); const [expiryDate, setExpiryDate] = useState( - dayjs().add(30, "days").toDate() + dayjs().add(5, "minutes").toDate() ); const [errors, setErrors] = useState({}); @@ -196,7 +196,8 @@ export default function FetchRecordsModal({ patient, show, onClose }: IProps) { }); navigate( - `/facility/${patient.facility}/patient/${patient.id}/consultation/${patient.last_consultation?.id}/abdm` + `/facility/${patient.facility}/abdm` ?? + `/facility/${patient.facility}/patient/${patient.id}/consultation/${patient.last_consultation?.id}/abdm` ); } else { Notification.Error({ diff --git a/src/Components/ABDM/HealthInformation.tsx b/src/Components/ABDM/HealthInformation.tsx index fddf228bbd6..a0d0d874c86 100644 --- a/src/Components/ABDM/HealthInformation.tsx +++ b/src/Components/ABDM/HealthInformation.tsx @@ -11,6 +11,7 @@ interface IProps { export default function HealthInformation({ artefactId }: IProps) { const { data, loading, error } = useQuery(routes.getHealthInformation, { pathParams: { artefactId }, + silent: true, }); if (loading) { diff --git a/src/Components/ABDM/types/abha.ts b/src/Components/ABDM/types/abha.ts new file mode 100644 index 00000000000..d45986e8f8f --- /dev/null +++ b/src/Components/ABDM/types/abha.ts @@ -0,0 +1,21 @@ +export type AbhaNumberModel = { + id: number; + external_id: string; + created_date: string; + modified_date: string; + abha_number: string; + health_id: string; + name: string; + first_name: string | null; + middle_name: string | null; + last_name: string | null; + gender: "F" | "M" | "O"; + date_of_birth: string | null; + address: string | null; + district: string | null; + state: string | null; + pincode: string | null; + email: string | null; + profile_photo: string | null; + new: boolean; +}; diff --git a/src/Components/ABDM/types/consent.ts b/src/Components/ABDM/types/consent.ts index 5fbfdd910c3..d900f7355dc 100644 --- a/src/Components/ABDM/types/consent.ts +++ b/src/Components/ABDM/types/consent.ts @@ -1,4 +1,5 @@ import { UserBaseModel } from "../../Users/models"; +import { AbhaNumberModel } from "./abha"; export type ConsentPurpose = | "CAREMGT" @@ -68,5 +69,6 @@ export type ConsentArtefactModel = { export type ConsentRequestModel = { requester: UserBaseModel; + patient_abha_object: AbhaNumberModel; consent_artefacts: ConsentArtefactModel[]; } & ConsentModel; diff --git a/src/Components/Facility/FacilityHome.tsx b/src/Components/Facility/FacilityHome.tsx index 15317b1b56c..ca53c6c5eea 100644 --- a/src/Components/Facility/FacilityHome.tsx +++ b/src/Components/Facility/FacilityHome.tsx @@ -596,6 +596,13 @@ export const FacilityHome = (props: any) => { > View Users + navigate(`/facility/${facilityId}/abdm`)} + icon={} + > + View ABDM Records + (), }, createConsent: { diff --git a/src/Routers/AppRouter.tsx b/src/Routers/AppRouter.tsx index e3bf7f90a31..d61968a62e9 100644 --- a/src/Routers/AppRouter.tsx +++ b/src/Routers/AppRouter.tsx @@ -74,6 +74,7 @@ import SessionExpired from "../Components/ErrorPages/SessionExpired"; import ManagePrescriptions from "../Components/Medicine/ManagePrescriptions"; import CentralNursingStation from "../Components/Facility/CentralNursingStation"; import HealthInformation from "../Components/ABDM/HealthInformation"; +import ABDMFacilityRecords from "../Components/ABDM/ABDMFacilityRecords"; export default function AppRouter() { const { main_logo, enable_hcx } = useConfig(); @@ -406,6 +407,9 @@ export default function AppRouter() { "/abdm/health-information/:id": ({ id }: { id: string }) => ( ), + "/facility/:facilityId/abdm": ({ facilityId }: any) => ( + + ), "/session-expired": () => , "/not-found": () => , };