Skip to content

Commit

Permalink
Frontend Adjustments for ABDM Plug Conversion (#7817)
Browse files Browse the repository at this point in the history
  • Loading branch information
khavinshankar authored Sep 17, 2024
1 parent 3d82b31 commit 82a6700
Show file tree
Hide file tree
Showing 21 changed files with 68 additions and 87 deletions.
2 changes: 0 additions & 2 deletions cypress/e2e/users_spec/user_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ describe("Manage User", () => {

beforeEach(() => {
cy.restoreLocalStorage();
console.log(localStorage);
cy.clearLocalStorage(/filters--.+/);
console.log(localStorage);
cy.awaitUrl("/users");
});

Expand Down
2 changes: 0 additions & 2 deletions cypress/e2e/users_spec/user_profile.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ describe("Manage User Profile", () => {

beforeEach(() => {
cy.restoreLocalStorage();
console.log(localStorage);
cy.clearLocalStorage(/filters--.+/);
console.log(localStorage);
cy.awaitUrl("/user/profile");
});

Expand Down
4 changes: 2 additions & 2 deletions src/Components/ABDM/ABHAProfileModal.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import * as Notify from "../../Utils/Notifications";

import { AbhaObject } from "../Patient/models";
import CareIcon from "../../CAREUI/icons/CareIcon";
import DialogModal from "../Common/Dialog";
import QRCode from "qrcode.react";
import { formatDateTime } from "../../Utils/utils";
import { useRef } from "react";
import request from "../../Utils/request/request";
import routes from "../../Redux/api";
import { AbhaNumberModel } from "./types/abha";

interface IProps {
patientId?: string;
abha?: AbhaObject;
abha?: AbhaNumberModel;
show: boolean;
onClose: () => void;
}
Expand Down
20 changes: 9 additions & 11 deletions src/Components/ABDM/FetchRecordsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as Notification from "../../Utils/Notifications.js";

import ButtonV2 from "../Common/components/ButtonV2";
import DialogModal from "../Common/Dialog";
import { PatientModel } from "../Patient/models";
import TextFormField from "../Form/FormFields/TextFormField";
import { useState } from "react";
import {
Expand All @@ -20,19 +19,20 @@ import { useMessageListener } from "../../Common/hooks/useMessageListener.js";
import CircularProgress from "../Common/components/CircularProgress.js";
import CareIcon from "../../CAREUI/icons/CareIcon.js";
import { classNames } from "../../Utils/utils.js";
import { AbhaNumberModel } from "./types/abha.js";
import { ConsentHIType, ConsentPurpose } from "./types/consent.js";
import useNotificationSubscriptionState from "../../Common/hooks/useNotificationSubscriptionState.js";

const getDate = (value: any) =>
value && dayjs(value).isValid() && dayjs(value).toDate();

interface IProps {
patient: PatientModel;
abha?: AbhaNumberModel;
show: boolean;
onClose: () => void;
}

export default function FetchRecordsModal({ patient, show, onClose }: IProps) {
export default function FetchRecordsModal({ abha, show, onClose }: IProps) {
const [idVerificationStatus, setIdVerificationStatus] = useState<
"pending" | "in-progress" | "verified" | "failed"
>("pending");
Expand All @@ -53,9 +53,7 @@ export default function FetchRecordsModal({ patient, show, onClose }: IProps) {

useMessageListener((data) => {
if (data.type === "MESSAGE" && data.from === "patients/on_find") {
if (
data.message?.patient?.id === patient?.abha_number_object?.health_id
) {
if (data.message?.patient?.id === abha?.health_id) {
setIdVerificationStatus("verified");
setErrors({
...errors,
Expand Down Expand Up @@ -85,7 +83,7 @@ export default function FetchRecordsModal({ patient, show, onClose }: IProps) {

<div className="flex items-center gap-3">
<TextFormField
value={patient?.abha_number_object?.health_id as string}
value={abha?.health_id as string}
onChange={() => null}
disabled
label="Patient Identifier"
Expand All @@ -98,7 +96,7 @@ export default function FetchRecordsModal({ patient, show, onClose }: IProps) {
onClick={async () => {
const { res } = await request(routes.abha.findPatient, {
body: {
id: patient?.abha_number_object?.health_id,
id: abha?.health_id,
},
reattempts: 0,
});
Expand Down Expand Up @@ -214,7 +212,7 @@ export default function FetchRecordsModal({ patient, show, onClose }: IProps) {
setIsMakingConsentRequest(true);
const { res } = await request(routes.abha.createConsent, {
body: {
patient_abha: patient?.abha_number_object?.health_id as string,
patient_abha: abha?.health_id as string,
hi_types: hiTypes,
purpose,
from_time: fromDate,
Expand All @@ -229,8 +227,8 @@ export default function FetchRecordsModal({ patient, show, onClose }: IProps) {
});

navigate(
`/facility/${patient.facility}/abdm` ??
`/facility/${patient.facility}/patient/${patient.id}/consultation/${patient.last_consultation?.id}/abdm`,
`/facility/${abha?.patient_object?.facility}/abdm` ??
`/facility/${abha?.patient_object?.facility}/patient/${abha?.patient_object?.id}/consultation/${abha?.patient_object?.last_consultation?.id}/abdm`,
);
} else {
Notification.Error({
Expand Down
2 changes: 1 addition & 1 deletion src/Components/ABDM/LinkABHANumberModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ const ScanABHAQRSection = ({
dob: abha?.dob.replace(/\//g, "-"),
address: abha?.address,
"dist name": abha?.["dist name"] ?? abha?.district_name,
"state name": abha?.["state name"],
"state name": abha?.["state name"] ?? abha?.state_name,
},
});

Expand Down
26 changes: 9 additions & 17 deletions src/Components/ABDM/LinkCareContextModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ import * as Notification from "../../Utils/Notifications.js";
import ButtonV2 from "../Common/components/ButtonV2";
import DateFormField from "../Form/FormFields/DateFormField";
import DialogModal from "../Common/Dialog";
import { PatientModel } from "../Patient/models";
import TextFormField from "../Form/FormFields/TextFormField";
import { useState } from "react";
import routes from "../../Redux/api.js";
import request from "../../Utils/request/request.js";
import { AbhaNumberModel } from "./types/abha.js";

interface IProps {
consultationId: string;
patient: PatientModel;
abha?: AbhaNumberModel;
show: boolean;
onClose: () => void;
}

const LinkCareContextModal = ({
consultationId,
patient,
abha,
show,
onClose,
}: IProps) => {
Expand All @@ -33,15 +33,15 @@ const LinkCareContextModal = ({
>
<div className="flex items-center justify-between">
<TextFormField
value={patient?.abha_number_object?.name}
value={abha?.name}
onChange={() => null}
disabled
label="Name"
name="name"
error=""
/>
<TextFormField
value={patient?.abha_number_object?.gender}
value={abha?.gender}
onChange={() => null}
disabled
label="Gender"
Expand All @@ -52,11 +52,7 @@ const LinkCareContextModal = ({
<DateFormField
name="dob"
label="Date of Birth"
value={
patient?.abha_number_object?.date_of_birth
? new Date(patient?.abha_number_object?.date_of_birth)
: undefined
}
value={abha?.date_of_birth ? new Date(abha?.date_of_birth) : undefined}
onChange={() => null}
disabled
required
Expand Down Expand Up @@ -84,20 +80,16 @@ const LinkCareContextModal = ({
const { res } = await request(routes.abha.linkCareContext, {
body: {
consultation: consultationId,
name: patient?.abha_number_object?.name,
gender: patient?.abha_number_object?.gender,
dob: patient?.abha_number_object?.date_of_birth,
name: abha?.name,
gender: abha?.gender,
dob: abha?.date_of_birth,
},
reattempts: 0,
});
if (res?.status === 202) {
Notification.Success({
msg: "Care Context sucessfully linked!",
});
} else {
Notification.Error({
msg: "Error in linking Care Context!",
});
}
setIsLinkingCareContext(false);
onClose();
Expand Down
3 changes: 2 additions & 1 deletion src/Components/ABDM/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export interface ABHAQRContent {
address: string;
distlgd: string;
district_name?: string;
state_name?: string;
dob: string;
gender: "M" | "F" | "O";
hid?: string;
Expand All @@ -132,6 +133,6 @@ export interface ABHAQRContent {
hidn: string;
mobile: string;
name: string;
"state name": string;
"state name"?: string;
statelgd: string;
}
4 changes: 4 additions & 0 deletions src/Components/ABDM/types/abha.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { PatientModel } from "../../Patient/models";

export type AbhaNumberModel = {
id: number;
external_id: string;
Expand All @@ -18,4 +20,6 @@ export type AbhaNumberModel = {
email: string | null;
profile_photo: string | null;
new: boolean;
patient: string | null;
patient_object: PatientModel | null;
};
19 changes: 18 additions & 1 deletion src/Components/Facility/ConsultationDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ import { AssetBedModel } from "../../Assets/AssetTypes";
import PatientInfoCard from "../../Patient/PatientInfoCard";
import RelativeDateUserMention from "../../Common/RelativeDateUserMention";
import DiagnosesListAccordion from "../../Diagnosis/DiagnosesListAccordion";
import { AbhaNumberModel } from "../../ABDM/types/abha";
import routes from "../../../Redux/api";
import request from "../../../Utils/request/request";
import { CameraFeedPermittedUserTypes } from "../../../Utils/permissions";
import Error404 from "../../ErrorPages/404";

Expand Down Expand Up @@ -85,6 +88,7 @@ export const ConsultationDetails = (props: any) => {
{} as ConsultationModel,
);
const [patientData, setPatientData] = useState<PatientModel>({});
const [abhaNumberData, setAbhaNumberData] = useState<AbhaNumberModel>();
const [activeShiftingData, setActiveShiftingData] = useState<Array<any>>([]);
const [isCameraAttached, setIsCameraAttached] = useState(false);

Expand Down Expand Up @@ -137,6 +141,8 @@ export const ConsultationDetails = (props: any) => {
})
: false;
setIsCameraAttached(isCameraAttachedRes);

// Get patient data
const id = res.data.patient;
const patientRes = await dispatch(getPatient({ id }));
if (patientRes?.data) {
Expand All @@ -159,6 +165,16 @@ export const ConsultationDetails = (props: any) => {
setPatientData(data);
}

// Get abha number data
const { data: abhaNumberData } = await request(
routes.abha.getAbhaNumber,
{
pathParams: { abhaNumberId: id ?? "" },
silent: true,
},
);
setAbhaNumberData(abhaNumberData);

// Get shifting data
const shiftingRes = await dispatch(
listShiftRequests({ patient: id }, "shift-list-call"),
Expand Down Expand Up @@ -290,6 +306,7 @@ export const ConsultationDetails = (props: any) => {
<div className="size-full rounded-lg border bg-white text-black shadow">
<PatientInfoCard
patient={patientData}
abhaNumber={abhaNumberData}
consultation={consultationData}
fetchPatientData={fetchData}
consultationId={consultationId}
Expand Down Expand Up @@ -382,7 +399,7 @@ export const ConsultationDetails = (props: any) => {
return null; // Hide feed tab
}

if (p.text === "ABDM" && !patientData.abha_number) {
if (p.text === "ABDM" && !abhaNumberData?.abha_number) {
return null;
}

Expand Down
1 change: 0 additions & 1 deletion src/Components/Facility/Consultations/LiveFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ const LiveFeed = (props: any) => {
updatePreset: (option) => {
getCameraStatus({
onSuccess: async (data) => {
console.log({ currentPreset, data });
if (currentPreset?.asset_object?.id && data?.position) {
setLoading(option.loadingLabel);
console.log("Updating Preset");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const DataTable = (props: any) => {

const DataDescription = (props: any) => {
const { title, data } = props;
console.log("Data Description", title, data);

return (
<div>
Expand Down
4 changes: 0 additions & 4 deletions src/Components/Facility/Consultations/VentilatorPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ export const VentilatorPlot = (props: any) => {
})
.filter((p) => p.value !== null);

useEffect(() => {
console.log(bilateral);
}, [bilateral]);

return (
<div>
<div className="grid-row-1 grid gap-4 md:grid-cols-2">
Expand Down
1 change: 0 additions & 1 deletion src/Components/Facility/FacilityCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ export const FacilityCreate = (props: FacilityProps) => {
const handleSubmit = async (e: any) => {
e.preventDefault();
const validated = validateForm();
console.log(state.form);
if (validated) {
setIsLoading(true);
const data: FacilityRequest = {
Expand Down
3 changes: 0 additions & 3 deletions src/Components/Facility/FacilityHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import RecordMeta from "../../CAREUI/display/RecordMeta";
import Table from "../Common/components/Table";

import { navigate } from "raviger";
import { useMessageListener } from "../../Common/hooks/useMessageListener";
import { useTranslation } from "react-i18next";
import useAuthUser from "../../Common/hooks/useAuthUser.js";
import request from "../../Utils/request/request.js";
Expand Down Expand Up @@ -61,8 +60,6 @@ export const FacilityHome = ({ facilityId }: Props) => {
const [coverImageEdited, setCoverImageEdited] = useState(false);
const authUser = useAuthUser();

useMessageListener((data) => console.log(data));

const {
data: facilityData,
loading: isLoading,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ export default function ViewInvestigationSuggestions(props: {
return <Loading />;
}

console.log("Investigations: ", investigations);

return (
<div className="mt-5" id="investigation-suggestions">
<h3>{t("investigations_suggested")}</h3>
Expand Down Expand Up @@ -110,11 +108,6 @@ export default function ViewInvestigationSuggestions(props: {
const investigationMissed =
nextInvestigationTime &&
dayjs().isAfter(nextInvestigationTime);
console.log(
type,
nextFurthestInvestigation,
nextInvestigationTime,
);

return (
<li
Expand Down
2 changes: 0 additions & 2 deletions src/Components/Facility/Investigations/Reports/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ const InvestigationReports = ({ id }: any) => {
selectedInvestigations,
} = state as InitialState;

console.log("state", state);

const fetchInvestigationsData = useCallback(
async (
onSuccess: (
Expand Down
2 changes: 0 additions & 2 deletions src/Components/HCX/CreateClaimCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ export default function CreateClaimCard({
const [createdClaim, setCreatedClaim] = useState<HCXClaimModel>();
const [use_, setUse_] = useState(use);

console.log(items);

useEffect(() => {
async function autoFill() {
const latestApprovedPreAuthsRes = await dispatch(
Expand Down
Loading

0 comments on commit 82a6700

Please sign in to comment.