From 3a994d426947ca45c09b678d7c9b53def7384564 Mon Sep 17 00:00:00 2001 From: sonika <> Date: Mon, 4 Sep 2023 22:11:48 +0530 Subject: [PATCH] section4 data to main --- .../PatientForm/PainAnalysisSection4.tsx | 235 ++++++++++++------ src/Components/PatientForm/PatientForm.tsx | 31 ++- 2 files changed, 185 insertions(+), 81 deletions(-) diff --git a/src/Components/PatientForm/PainAnalysisSection4.tsx b/src/Components/PatientForm/PainAnalysisSection4.tsx index d8509b4..78e970e 100644 --- a/src/Components/PatientForm/PainAnalysisSection4.tsx +++ b/src/Components/PatientForm/PainAnalysisSection4.tsx @@ -2,51 +2,122 @@ import * as React from 'react'; import { Checkbox, FormControlLabel, TextField, FormGroup, Grid, FormControl, FormLabel, Radio, RadioGroup } from '@mui/material'; import { useFormik } from 'formik'; import * as Yup from 'yup'; +import path from 'path'; +import { useEffect } from 'react'; -interface FormValues { +interface Patient { chiefComplaint:string; + painWorse: string[]; + painBetter: string[]; painQuality: string[]; + painWorstTime: string[]; + currentComplaintIssues: string[]; painDuration: string; currentTreatment: string; - treatmentResults: string; treatmentGoal: string; + selfTreatment:string; + } + + type Props = { + handleFormSection4Data:( + chiefComplaint:string|undefined, + painWorse: any, + painBetter: any, + painQuality: any, + painWorstTime: any, + currentComplaintIssues: any, + painDuration: string|undefined, + currentTreatment: string|undefined, + treatmentGoal: string|undefined, + selfTreatment:string|undefined, + )=> void } - const validationSchema = Yup.object({ - chiefComplaint:Yup.array().required('Required'), - painQuality: Yup.array().required('Required'), - painDuration: Yup.string().required('Required'), - currentTreatment: Yup.string().required('Required'), - treatmentResults: Yup.string().required('Required'), - treatmentGoal: Yup.string().required('Required'), - }); -export default function PainAnalysisSection4(){ - const formik = useFormik({ - initialValues:{ - chiefComplaint:'', - painQuality:[], - painDuration:'', - currentTreatment:'', - treatmentResults:'', - treatmentGoal:'', - }, - validationSchema, - onSubmit:(values)=>{ - console.log(values); - } - }) - const handlePainQualityChange = (event: React.ChangeEvent) => { - if (event.target.checked) { - formik.setFieldValue('painQuality', [...formik.values.painQuality, event.target.value]); - } else { - formik.setFieldValue('painQuality', formik.values.painQuality.filter((item) => item !== event.target.value)); - } - }; +export default function PainAnalysisSection4({handleFormSection4Data}:Props){ + const [patient, setPatient] = React.useState({ + chiefComplaint:'', + painWorse:[], + painBetter:[], + painQuality:[], + painWorstTime:[], + currentComplaintIssues:[], + painDuration:'', + currentTreatment:'', + treatmentGoal:'', + selfTreatment:'', + }); + + useEffect(()=>{ + handleFormSection4Data( + patient.chiefComplaint, + patient.painWorse, + patient.painBetter, + patient.painQuality, + patient.painWorstTime, + patient.currentComplaintIssues, + patient.painDuration, + patient.currentTreatment, + patient.treatmentGoal, + patient.selfTreatment, + ) + },[patient]) + + const handlePainWorseChange = (event: React.ChangeEvent) => { + const { name, checked } = event.target; + setPatient((prevValues) => ({ + ...prevValues, + painWorse: checked + ? [...prevValues.painWorse, name] + : prevValues.painWorse.filter((item) => item !== name), + })); + }; + + const handlePainBetterChange = (event: React.ChangeEvent) => { + const { name, checked } = event.target; + setPatient((prevValues) => ({ + ...prevValues, + painBetter: checked + ? [...prevValues.painBetter, name] + : prevValues.painBetter.filter((item) => item !== name), + })); + }; + + const handlePainQualityChange = (event: React.ChangeEvent) => { + const { name, checked } = event.target; + setPatient((prevValues) => ({ + ...prevValues, + painQuality: checked + ? [...prevValues.painQuality, name] + : prevValues.painQuality.filter((item) => item !== name), + })); + }; + + const handlePainWorstTimeChange = (event: React.ChangeEvent) => { + const { name, checked } = event.target; + setPatient((prevValues) => ({ + ...prevValues, + painWorstTime: checked + ? [...prevValues.painWorstTime, name] + : prevValues.painWorstTime.filter((item) => item !== name), + })); + }; + + const handleCurrentComplaintIssuesTimeChange = (event: React.ChangeEvent) => { + const { name, checked } = event.target; + setPatient((prevValues) => ({ + ...prevValues, + currentComplaintIssues: checked + ? [...prevValues.currentComplaintIssues, name] + : prevValues.currentComplaintIssues.filter((item) => item !== name), + })); + }; + + + console.log("dskjjfdsgvd",patient) return( <> -
Issue Details: @@ -56,9 +127,13 @@ export default function PainAnalysisSection4(){ variant="outlined" label="How did your Chief complaint start?(ex-fell on ice)" name='chiefComplaint' - onChange={formik.handleChange} - value={formik.values.chiefComplaint} - onBlur={formik.handleBlur} + onChange={(e)=>{ + setPatient((prevValues) => ({ + ...prevValues, + chiefComplaint: e.target.value, + })); + }} + value={patient.chiefComplaint} /> @@ -67,29 +142,27 @@ export default function PainAnalysisSection4(){ What makes your pain worse? } + control={} label="Bending" /> } + control={} label="Standing" /> } + control={} label="Sitting" /> } + control={} label="Walking" /> } + control={} label="Others" /> - {formik.touched.painQuality && formik.errors.painQuality ? ( -
{formik.errors.painQuality}
- ) : null} + @@ -98,23 +171,23 @@ export default function PainAnalysisSection4(){ What makes your pain better? } + control={} label="laying down" /> } + control={} label="Standing" /> } + control={} label="Sitting" /> } + control={} label="Walking" /> } + control={} label="Others" /> @@ -130,25 +203,22 @@ export default function PainAnalysisSection4(){ label="Sharp" /> } + control={} label="Dull/Ache" /> } + control={} label="Throbbing" /> } + control={} label="Tingling/Numbness/Burning" /> } + control={} label="Others" /> - {formik.touched.painQuality && formik.errors.painQuality ? ( -
{formik.errors.painQuality}
- ) : null} @@ -157,29 +227,26 @@ export default function PainAnalysisSection4(){ What is the worst time for your pain? } + control={} label="Morning" /> } + control={} label="During day" /> } + control={} label="Evening" /> } + control={} label="Lying in bed" /> } + control={} label="Others" /> - {formik.touched.painQuality && formik.errors.painQuality ? ( -
{formik.errors.painQuality}
- ) : null} @@ -188,8 +255,13 @@ export default function PainAnalysisSection4(){ How much of the day do you experience your chief complaint? { + setPatient((prevValues) => ({ + ...prevValues, + painDuration: e.target.value, + })); + }} + value={patient.painDuration} sx={{display:'flex', flexDirection:'row'}} > } label="0-25%" /> @@ -205,19 +277,19 @@ export default function PainAnalysisSection4(){ Has your current complaint caused any of the following? } + control={} label="Muscle weakness" /> } + control={} label="Bowel/Bladder problem" /> } + control={} label="Digestion" /> } + control={} label="Cardiac/Respiratory" /> @@ -230,16 +302,18 @@ export default function PainAnalysisSection4(){ Have you tried any self treatment (ex-ice, heat, excercise) or taken any medication(over the counter or prescription)? { + setPatient((prevValues) => ({ + ...prevValues, + selfTreatment: e.target.value, + })); + }} + value={patient.selfTreatment} sx={{display:'flex', flexDirection:'row'}} > } label="Yes" /> } label="No" /> - {formik.touched.painDuration && formik.errors.painDuration ? ( -
{formik.errors.painDuration}
- ) : null} @@ -252,14 +326,17 @@ export default function PainAnalysisSection4(){ variant="outlined" label="What is your goal from treatment?(ex-play golf without pain)" name='treatmentGoal' - onChange={formik.handleChange} - value={formik.values.treatmentGoal} - onBlur={formik.handleBlur} + onChange={(e)=>{ + setPatient((prevValues) => ({ + ...prevValues, + treatmentGoal: e.target.value, + })); + }} + value={patient.treatmentGoal} /> - )} diff --git a/src/Components/PatientForm/PatientForm.tsx b/src/Components/PatientForm/PatientForm.tsx index 982a2a0..87dc51e 100644 --- a/src/Components/PatientForm/PatientForm.tsx +++ b/src/Components/PatientForm/PatientForm.tsx @@ -80,6 +80,7 @@ export default function PatientForm(){ const [section1Data, setSection1Data] = React.useState({}); const [section2Data, setSection2Data] = React.useState({}); const [section3Data, setSection3Data] = React.useState({}); + const [section4Data, setSection4Data] = React.useState({}); const handleFormSection1Data = ( fullName?: string|undefined, @@ -168,6 +169,32 @@ export default function PatientForm(){ cellPhoneProvider, }) } + + const handleFormSection4Data = ( + chiefComplaint:string|undefined, + painWorse: any, + painBetter: any, + painQuality: any, + painWorstTime: any, + currentComplaintIssues: any, + painDuration: string|undefined, + currentTreatment: string|undefined, + treatmentGoal: string|undefined, + selfTreatment:string|undefined, + ) =>{ + setSection4Data({ + chiefComplaint, + painWorse, + painBetter, + painQuality, + painWorstTime, + currentComplaintIssues, + painDuration, + currentTreatment, + treatmentGoal, + selfTreatment, + }) + } const handleSubmit = (event: React.FormEvent) => { event.preventDefault(); @@ -182,7 +209,7 @@ export default function PatientForm(){ setIsChecked(event.target.checked); }; - console.log(section3Data,"wyeytweevfde",section2Data) + console.log("wyeytweevfde",section4Data) return( @@ -237,7 +264,7 @@ export default function PatientForm(){ - +