second-opinion

 treatement-details-form:--

index.tsx:---

// import { useState } from "react";
// import { useNavigate } from "react-router-dom";
// import { THEME_COLORS } from "../../../theme/color";
// import {
// background,
// flex,
// padding,
// gap,
// border,
// margin,
// screen,
// } from "@ebh/capsule/theme";
// import { useToast } from "@ebh/capsule";
// import { Button } from "@ebh/capsule";
// import { useScreen } from "@ebh/capsule/hooks";
// import { FormProvider, useForm } from "react-hook-form";
// import { yupResolver } from "@hookform/resolvers/yup";
// import {
// defaultSecondMedicalOpinionValues,
// SecondMedicalOpinionData,
// SecondMedicalOpinionSchema,
// } from "./schema";
// import MedicalCondition from "../Symptoms-Treatment-details";
// import { usePatientMembers } from "../../../api/hooks/corporate-benfits/second-opinion/fetch-patient-details";
// import { useSubmitConsultation } from "../../../api/hooks/corporate-benfits/second-opinion/submit-patient-details";
// import { css } from "@emotion/react";
// import LoadingScreen from "../../loading-screen";
// import { calculateAge } from "../../../utils/calculate-age";
// import { ASK_QUERY_ROUTES, Second_Opinion_ROUTES } from "../../../routes";
// import { useSecondOpinionContext } from "../../../context/second-opinion-context";
// import HeaderBack from "../../../components/header-back";
// const SecondOpinion = () => {
// const { queryType, clinicalSpeciality, setPatientDetails, setSlug} =
// useSecondOpinionContext();
// const navigate = useNavigate();
// const isPhone = !useScreen("md");
// const [dependentSlug, setDependentSlug] = useState("");
// const Toast = useToast();
// const {
// data: patientProfileList,
// isFetching: isPatientFetching,
// isLoading: isPatientLoading,
// } = usePatientMembers();

// const submitConsultationMutation = useSubmitConsultation();

// const methods = useForm<SecondMedicalOpinionData>({
// defaultValues: defaultSecondMedicalOpinionValues,
// resolver: yupResolver(SecondMedicalOpinionSchema()),
// mode: "onChange",
// });

// const {
// control,
// handleSubmit,
// reset,
// formState: { errors },
// watch,
// } = methods;

// const patientname = watch("consultationDetails.patient");
// const isFormDisabled = !patientname;

// const handleReset = () => {
// reset(defaultSecondMedicalOpinionValues);
// };

// const isLoadingOverall = isPatientLoading || isPatientFetching;

// const submitSecondOpinion = (data: SecondMedicalOpinionData) => {
// const dob = data?.consultationDetails?.dateOfBirth;
// const age = calculateAge(dob);

// setPatientDetails({
// name: data?.consultationDetails?.name || "",
// age: String(age),
// gender: data?.consultationDetails?.gender || "",
// email: data?.consultationDetails?.emailId || "",
// mobileNumber: data?.consultationDetails?.mobileNumber || "",
// });

// const isOther = data?.consultationDetails?.patient === "Others";
// const consulatationData = {
// patient_full_name: data?.consultationDetails?.name,
// patient_gender: data?.consultationDetails?.gender ?? "",
// patient_dob: data?.consultationDetails?.dateOfBirth ?? "",
// ...(!isOther && { patient_slug: dependentSlug ?? "" }),
// patient_email: data?.consultationDetails?.emailId ?? "",
// patient_mobile: data?.consultationDetails?.mobileNumber ?? "",
// ...(isOther && { new_patient: true }),
// };

// handleSubmitConsultationAPI(consulatationData);
// };

// const handleSubmitConsultationAPI = (payload: any) => {
// submitConsultationMutation.mutate(payload, {
// onSuccess: () => {
// reset(defaultSecondMedicalOpinionValues);

// setSlug(dependentSlug);

// if (
// queryType === "second_opinion" &&
// clinicalSpeciality === "Medical Query"
// ) {
// navigate(Second_Opinion_ROUTES.PatientDetail);
// }
// if (
// queryType === "free_query" &&
// (clinicalSpeciality === "Medical Query" || "Diet And Nutrition")
// ) {
// navigate(ASK_QUERY_ROUTES.Medical_Details);
// }
// },
// onError: (error: Error) => {
// const message = error.message || "Something went wrong!";
// Toast(message, "error");
// },
// });
// };
// const headerTitleMap: Record<string, string> = {
// free_query: "Ask a Doctor",
// second_opinion: "Second Medical Opinion",
// };

// const headerTitle = headerTitleMap[queryType] ?? "";
// return (
// <>
// {/* Navigation Bar */}

// <div
// css={[
// screen("md", padding(20, "x"), padding(2, "y")),
// padding(4, "x"),
// background("tertiary-100"),
// ]}
// >
// <HeaderBack title={headerTitle} />
// </div>
// <FormProvider {...methods}>
// <form
// onSubmit={handleSubmit(submitSecondOpinion, (formErrors) => {
// console.error("Validation failed", formErrors);
// })}
// css={[margin(20, "bottom")]}>
// <div
// css={[
// margin(1, "y"),
// screen("md", margin(5, "y")),
// ]}
// >
// <MedicalCondition
// control={control}
// errors={errors}
// isFormDisabled={isFormDisabled}
// familyRelationsList={patientProfileList?.dependents_list}
// setDependentSlug={setDependentSlug}
// />
// </div>

// <div
// css={[
// flex("row", "justify-between"),
// gap(2),
// padding(3),
// background("white"),
// css({
// position: "fixed",
// bottom: 0,
// left: 0,
// right: 0,
// zIndex: 10,
// }),
// border(2, "gray-100"),
// screen(
// "md",
// css({
// position: "static",
// zIndex: "auto",
// borderTop: `1px solid ${THEME_COLORS["tertiary-200"]}`,
// borderBottom:0,
// borderLeft:0,
// borderRight:0
// }),
// padding(10, "x")
// ),
// ]}>
// {!isPhone && (
// <Button type="button" variant="secondary" onClick={handleReset}>
// Reset
// </Button>
// )}
// <Button
// type="submit"
// css={[{ flex: 1 }, screen("md", { flex: 0 })]}>
// Add
// </Button>
// </div>
// </form>
// </FormProvider>
// {isLoadingOverall && (
// <div
// css={[
// flex("center"),
// padding(5),
// {
// position: "fixed",
// top: "50%",
// left: "50%",
// transform: "translate(-50%, -50%)",
// zIndex: 1000,
// },
// ]}
// >
// <LoadingScreen />
// </div>
// )}
// </>
// );
// };

// export default SecondOpinion;

second-medical-patient-details:index.tsx:

// import { useForm, FormProvider } from "react-hook-form";
// import { yupResolver } from "@hookform/resolvers/yup";
// import { useRef, useState } from "react";
// import { useToast } from "@ebh/capsule";
// import { margin, flex, padding,screen} from "@ebh/capsule/theme";
// import { useSmoSpecialities } from "../../../api/hooks/corporate-benfits/second-opinion/fetch-second-medical-speciality";
// import { useSubmitQuery } from "../../../api/hooks/corporate-benfits/second-opinion/submit-second-medical-details";
// import { useNavigate } from "react-router-dom";

// import LoadingScreen from "../../loading-screen";
// import {
// SecondMedicalOpinionConsultationSchema,
// defaultQuickConsultationValues,
// SecondMedicalOpinionConsultationData,
// UploadedFile,
// } from "./schema";

// import { Second_Opinion_ROUTES } from "../../../routes";
// import PatientInfoCard from "./partials/patient-info-card";
// import FormFields from "./partials/form-fields";
// import UploadedDrawer from "./partials/upload-drawer";
// import SubmitFooter from "./partials/submit-footer";
// import { useSecondOpinionContext } from "../../../context/second-opinion-context";

// export default function SecondMedicalPatientDetail() {
// const {
// setIsPaid,
// setAskQuerySlug,
// setCharges,
// slug,
// setPrescriptionDetails,
// } = useSecondOpinionContext();
// const [isDrawerOpen, setDrawerOpen] = useState(false);
// const [uploadedFiles, setUploadedFiles] = useState<UploadedFile[]>([]);
// const [selectedDocType, setSelectedDocType] = useState("");
// const { data, isLoading } = useSmoSpecialities();
// const secondopinion = data?.[0];
// const navigate = useNavigate();
// const toast = useToast();
// const docupload = useRef<HTMLInputElement>(null);
// const methods = useForm<SecondMedicalOpinionConsultationData>({
// defaultValues: defaultQuickConsultationValues,
// resolver: yupResolver(SecondMedicalOpinionConsultationSchema()),
// mode: "onChange",
// });
// const {
// control,
// handleSubmit,
// formState: { errors },
// register,
// watch,
// } = methods;
// const watchedQuestion = watch("prescriptionDetails.question");
// const { mutate: QuerySubmit } = useSubmitQuery();
// const submitQuery = (formDataRaw: SecondMedicalOpinionConsultationData) => {
// if (
// !secondopinion?.clinic_name ||
// !secondopinion?.ask_corner_second_opinion_fee
// )
// return;
// const formData = new FormData();
// formData.append("query_type", "second_opinion");
// formData.append("clinical_speciality", secondopinion.clinic_name);
// formData.append("patient_slug", slug);
// formData.append("ask_query", formDataRaw.prescriptionDetails.question);
// formData.append("symptoms", formDataRaw.prescriptionDetails.symptoms);
// formData.append("treatment", formDataRaw.prescriptionDetails.treatement);
// formData.append("medication", formDataRaw.prescriptionDetails.medicine);
// formData.append(
// "final_payment_amount",
// String(secondopinion.ask_corner_second_opinion_fee)
// );
// uploadedFiles.forEach((file) =>
// formData.append("documents", file.file, file.name)
// );
// setPrescriptionDetails({
// question: formDataRaw.prescriptionDetails.question,
// symptoms: formDataRaw.prescriptionDetails.symptoms,
// treatment: formDataRaw.prescriptionDetails.treatement,
// medicine: formDataRaw.prescriptionDetails.medicine,
// uploadRecord: true,
// });
// QuerySubmit(formData, {
// onSuccess: (data) => {
// const charges = secondopinion.ask_corner_second_opinion_fee;
// const isPaid = charges !== 0;
// setIsPaid(isPaid);
// setAskQuerySlug(data?.submitted_query_data?.ask_query_slug || "");
// setCharges(String(charges));
// navigate(Second_Opinion_ROUTES.Summary_Detail);
// },
// onError: (err) => console.error("Query submission failed", err),
// });
// };

// return (
// <FormProvider {...methods}>
// <form
// onSubmit={(e) => {
// e.preventDefault();
// handleSubmit(submitQuery)(e);
// }}
// css={[margin(20, "bottom")]}
// >
// <div>
// <PatientInfoCard />
// <div
// css={[
// padding(4,'x'),
// ,screen("md",
// padding(2, "y"),
// padding(8, "x"),)
// ]}
// >
// <FormFields
// control={control}
// errors={errors}
// register={register}
// watchedQuestion={watchedQuestion}
// setSelectedDocType={setSelectedDocType}
// selectedDocType={selectedDocType}
// docupload={docupload}
// toast={toast}
// uploadedFiles={uploadedFiles}
// setUploadedFiles={setUploadedFiles}
// setDrawerOpen={setDrawerOpen}
// />

// </div>
// <SubmitFooter />
// </div>
// </form>

// {isLoading && (
// <div
// css={[
// flex("center"),
// padding(5),
// {
// position: "fixed",
// top: "50%",
// left: "50%",
// transform: "translate(-50%, -50%)",
// zIndex: 1000,
// },
// ]}
// >
// <LoadingScreen />
// </div>
// )}

// <UploadedDrawer
// isDrawerOpen={isDrawerOpen}
// setDrawerOpen={setDrawerOpen}
// uploadedFiles={uploadedFiles}
// setUploadedFiles={setUploadedFiles}
// />
// </FormProvider>
// );
// }

...........

first-opinion:--
medical-details-form:--
index.tsx:--

// import { useForm, FormProvider } from "react-hook-form";
// import { yupResolver } from "@hookform/resolvers/yup";
// import { useNavigate } from "react-router-dom";
// import { useSubmitQuery } from "../../../api/hooks/corporate-benfits/second-opinion/submit-second-medical-details";
// import { margin } from "@ebh/capsule/theme";
// import FormFields from "./partials/form-fields";
// import DietFormFields from "./partials/diet-and-nutrition-form-fields";
// import * as MedicalSchema from "./schema";
// import * as DietSchema from "./schemadietandnutrition";
// import { ASK_QUERY_ROUTES } from "../../../routes";
// import { useSecondOpinionContext } from "../../../context/second-opinion-context";
// import PatientInfoCard from "../../second-opinion/second-medical-patient-detail/partials/patient-info-card";
// import SubmitFooter from "../../second-opinion/second-medical-patient-detail/partials/submit-footer";
// type MedicalFormData = MedicalSchema.SecondMedicalOpinionConsultationData;
// type DietFormData = DietSchema.SecondMedicalOpinionConsultationData;
// import { SECOND_MEDICAL_OPINION_DETAILS } from "../../../constants";
// import { Cookies } from "react-cookie";
// const handleSubmitConsultationAPI = (
// payload: any,
// QuerySubmit: any,
// navigate: any
// ) => {
// QuerySubmit(payload, {
// onSuccess: () => {
// navigate(ASK_QUERY_ROUTES.Review_Details);
// },
// onError: (err: any) => console.error("Query submission failed", err),
// });
// };
// const cookies = new Cookies();

// // Payload creators
// const getDietConsultationPayload = (
// formData: DietFormData,
// queryType: string,
// clinicalSpeciality: string,
// slug: string
// ) => {
// const heightInInches =
// Number(formData.prescriptionDetails.heightFt || 0) * 12 +
// Number(formData.prescriptionDetails.heightIn || 0);

// return {
// query_type: queryType,
// clinical_speciality: clinicalSpeciality,
// patient_slug: slug||
// cookies.get(SECOND_MEDICAL_OPINION_DETAILS.SMO_PATIENT_SLUG),
// height_weight: `${heightInInches},${
// formData.prescriptionDetails.weight ?? ""
// }`,
// eating_habits: formData.prescriptionDetails.eatinghabits ?? "",
// diet_details: formData.prescriptionDetails.dietdetails ?? "",
// ask_query: formData.prescriptionDetails.query ?? "",
// };
// };

// const getMedicalConsultationPayload = (
// formData: MedicalFormData,
// queryType: string,
// clinicalSpeciality: string,
// slug: string
// ) => {
// return {
// query_type: queryType,
// clinical_speciality: clinicalSpeciality,
// patient_slug: slug||
// cookies.get(SECOND_MEDICAL_OPINION_DETAILS.SMO_PATIENT_SLUG),
// symptoms: formData.prescriptionDetails.symptoms ?? "",
// treatment: formData.prescriptionDetails.treatement ?? "",
// medication: formData.prescriptionDetails.medicine ?? "",
// ask_query: formData.prescriptionDetails.question ?? "",
// };
// };

// export default function MedicalDetails() {
// const {
// queryType,
// clinicalSpeciality,
// slug,
// setAskQueryDetails,
// setClinicalQueryDetails,
// } = useSecondOpinionContext();

// const navigate = useNavigate();

// const { mutate: QuerySubmit } = useSubmitQuery();

// // Diet form
// if (clinicalSpeciality === "Diet and Nutrition") {
// const methods = useForm<DietFormData>({
// defaultValues: DietSchema.defaultQuickConsultationValues,
// resolver: yupResolver(
// DietSchema.SecondMedicalOpinionConsultationSchema()
// ),
// mode: "onChange",
// });

// const {
// control,
// register,
// handleSubmit,
// formState: { errors },
// watch,
// } = methods;

// const watchedDietDetails = watch("prescriptionDetails.dietdetails");
// const watchedQuery = watch("prescriptionDetails.query");

// const submitDietQuery = (formData: DietFormData) => {
// const payload = getDietConsultationPayload(
// formData,
// queryType ?? "",
// clinicalSpeciality ?? "",
// slug ?? ""
// );

// setAskQueryDetails({
// heightWeight: payload?.height_weight || "",
// eatingHabits: payload?.eating_habits || "",
// dietDetails: payload?.diet_details || "",
// askQuery: payload?.ask_query || "",
// });
// handleSubmitConsultationAPI(payload, QuerySubmit, navigate);
// };

// return (
// <FormProvider {...methods}>
// <form
// onSubmit={(e) => {
// e.preventDefault();
// handleSubmit(submitDietQuery)(e);
// }}
// css={[margin(20, "bottom")]}
// >
// <div>
// <PatientInfoCard />
// <DietFormFields
// control={control}
// errors={errors}
// register={register}
// watchedDietDetails={watchedDietDetails}
// watchedQuery={watchedQuery}
// />
// <SubmitFooter />
// </div>
// </form>
// </FormProvider>
// );
// }

// // Medical form
// const methods = useForm<MedicalFormData>({
// defaultValues: MedicalSchema.defaultQuickConsultationValues,
// resolver: yupResolver(
// MedicalSchema.SecondMedicalOpinionConsultationSchema()
// ),
// mode: "onChange",
// });

// const {
// control,
// register,
// handleSubmit,
// formState: { errors },
// watch,
// } = methods;

// const watchedQuestion = watch("prescriptionDetails.question");

// const submitMedicalQuery = (formData: MedicalFormData) => {
// const payload = getMedicalConsultationPayload(
// formData,
// queryType ?? "",
// clinicalSpeciality ?? "",
// slug ?? ""
// );

// setClinicalQueryDetails({
// symptoms: payload?.symptoms || "",
// treatment: payload?.treatment || "",
// medication: payload?.medication || "",
// askQuery: payload?.ask_query || "",
// });
// handleSubmitConsultationAPI(payload, QuerySubmit, navigate);
// };

// return (
// <FormProvider {...methods}>
// <form
// onSubmit={(e) => {
// e.preventDefault();
// handleSubmit(submitMedicalQuery)(e);
// }}
// css={[margin(20, "bottom")]}
// >
// <div css={[]}>
// <PatientInfoCard />
// <FormFields
// control={control}
// errors={errors}
// register={register}
// watchedQuestion={watchedQuestion}
// />
// <SubmitFooter />
// </div>
// </form>
// </FormProvider>
// );
// }


fetchappointhistory.ts:-import { useQuery } from "@tanstack/react-query";

import { getSecondOpinionQueries } from "../../../corporate-benefits/second-opinion";
import { GetSecondOpinionQueriesResponse } from "../../../../modules/second-opinion/interface";
import { Cookies } from "react-cookie";
// import { USER_DATA } from "../../../../constants";
interface UseSecondOpinionQueriesProps {
queryType: string;
}

export const useSecondOpinionQueries = ({
queryType,
}: UseSecondOpinionQueriesProps) => {
const cookies = new Cookies();
// const patient_slug = cookies.get(USER_DATA.USER_SLUG); //"patient_slug"
// const patient_slug = cookies.get("patient_slug");
const patient_slug = "iwE6ncUipKeP4GdueS3ueSzI";
return useQuery<GetSecondOpinionQueriesResponse>({
queryKey: ["secondOpinionQueries", [patient_slug, queryType]],
queryFn: () => getSecondOpinionQueries(patient_slug, queryType),
enabled: !!patient_slug,
});
};

...



...

Comments

Popular posts from this blog

interview questions js[ Anurag Singh ProCodrr]

reactnative_creation