diff --git a/src/Components/PatientForm/FamilyFormSection2.tsx b/src/Components/PatientForm/FamilyFormSection2.tsx index 8804bfe..4af0152 100644 --- a/src/Components/PatientForm/FamilyFormSection2.tsx +++ b/src/Components/PatientForm/FamilyFormSection2.tsx @@ -2,27 +2,26 @@ import { Button, Checkbox, FormControl, FormControlLabel, FormGroup, FormLabel, import { useFormik } from "formik"; import * as yup from "yup"; import { LocalizationProvider, DatePicker } from '@mui/x-date-pickers'; +import React, { useEffect } from 'react'; -interface FormValues { - maritalStatus: string; - numberOfChildren: string; - ages: string; - occupation: string; - hoursPerWeek: number | string; - employer: string; - businessPhone: string; - spouseName: string; - spouseEmployer: string; - spouseBusinessPhone: string; - emergencyContact: string; - relationship: string; - spousePhone: string; +interface Patient { + maritalStatus: string | undefined, + numberOfChildren: string | undefined, + occupation: string | undefined, + hoursPerWeek: number | string | undefined, + employer: string | undefined, + businessPhone: string | undefined, + spouseName: string | undefined, + spouseEmployer: string | undefined, + spouseBusinessPhone: string | undefined, + emergencyContact: string | undefined, + relationship: string | undefined, + spousePhone: string | undefined, } const validationSchema = yup.object({ maritalStatus:yup.string().required("Marital Status is required"), numberOfChildren:yup.string().required("Full name is required"), - ages:yup.string().required("Full name is required"), occupation:yup.string().required("Occupation is required"), // hoursPerWeek: yup.number().required('Required'), // employer:yup.string().required("Full name is required"), @@ -35,31 +34,59 @@ const validationSchema = yup.object({ spousePhone:yup.string().matches(/^\d{10}$/, "Cell phone must be 10 digits"), }); -export default function FamilyFormSection(){ - const formik = useFormik({ - initialValues:{ - maritalStatus:'', - numberOfChildren:'', - ages:'', - occupation:'', - hoursPerWeek:'', - employer:'', - businessPhone:'', - spouseName:'', - spouseEmployer:'', - spouseBusinessPhone:'', - emergencyContact:'', - relationship:'', - spousePhone:'' - }, - validationSchema, - onSubmit:(values)=>{ - console.log(values); - } - }) +type Props = { + handleFormSection2Data:( + maritalStatus: string | undefined, + numberOfChildren: string | undefined, + occupation: string | undefined, + hoursPerWeek: number | string | undefined, + employer: string | undefined, + businessPhone: string | undefined, + spouseName: string | undefined, + spouseEmployer: string | undefined, + spouseBusinessPhone: string | undefined, + emergencyContact: string | undefined, + relationship: string | undefined, + spousePhone: string | undefined, + )=> void + } + + +export default function FamilyFormSection({handleFormSection2Data}:Props){ + const [patient, setPatient] = React.useState({ + maritalStatus:'', + numberOfChildren:'', + occupation:'', + hoursPerWeek:'', + employer:'', + businessPhone:'', + spouseName:'', + spouseEmployer:'', + spouseBusinessPhone:'', + emergencyContact:'', + relationship:'', + spousePhone:'' + }); + + useEffect(()=>{ + handleFormSection2Data( + patient.maritalStatus, + patient.numberOfChildren, + patient.occupation, + patient.hoursPerWeek, + patient.employer, + patient.businessPhone, + patient.spouseName, + patient.spouseEmployer, + patient.spouseBusinessPhone, + patient.emergencyContact, + patient.relationship, + patient.spousePhone, + ) + },[patient]) + return( <> -
@@ -68,9 +95,14 @@ export default function FamilyFormSection(){ aria-labelledby="demo-radio-buttons-group-label" defaultValue="married" name="maritalStatus" - onChange={formik.handleChange} - value={formik.values.maritalStatus} + value={patient.maritalStatus} sx={{display:'flex', flexDirection:'row'}} + onChange={(e)=>{ + setPatient((prevValues:any) => ({ + ...prevValues, + maritalStatus: e.target.value, + })); + }} // error={formik.touched.numberOfChildren && Boolean(formik.errors.maritalStatus)} // helperText={formik.touched.numberOfChildren && formik.errors.maritalStatus} > @@ -93,9 +125,14 @@ export default function FamilyFormSection(){ label="Number of Children/Ages" className='collapsable-form-style' name='numberOfChildren' - onChange={formik.handleChange} - value={formik.values.numberOfChildren} - onBlur={formik.handleBlur} + onChange={(e)=>{ + setPatient((prevValues:any) => ({ + ...prevValues, + numberOfChildren: e.target.value, + })); + }} + value={patient.numberOfChildren} + // onBlur={formik.handleBlur} // error={formik.touched.numberOfChildren && Boolean(formik.errors.numberOfChildren)} // helperText={formik.touched.numberOfChildren && formik.errors.numberOfChildren} /> @@ -107,9 +144,14 @@ export default function FamilyFormSection(){ label="Occupation" className='collapsable-form-style' name='occupation' - onChange={formik.handleChange} - value={formik.values.occupation} - onBlur={formik.handleBlur} + onChange={(e)=>{ + setPatient((prevValues:any) => ({ + ...prevValues, + occupation: e.target.value, + })); + }} + value={patient.occupation} + // onBlur={formik.handleBlur} // error={formik.touched.occupation && Boolean(formik.errors.occupation)} // helperText={formik.touched.occupation && formik.errors.occupation} /> @@ -122,9 +164,14 @@ export default function FamilyFormSection(){ type="number" className='collapsable-form-style' name='hoursPerWeek' - onChange={formik.handleChange} - value={formik.values.hoursPerWeek} - onBlur={formik.handleBlur} + onChange={(e)=>{ + setPatient((prevValues:any) => ({ + ...prevValues, + hoursPerWeek: e.target.value, + })); + }} + value={patient.hoursPerWeek} + // onBlur={formik.handleBlur} /> @@ -134,9 +181,14 @@ export default function FamilyFormSection(){ label="Employer" className='collapsable-form-style' name='employer' - onChange={formik.handleChange} - value={formik.values.employer} - onBlur={formik.handleBlur} + onChange={(e)=>{ + setPatient((prevValues:any) => ({ + ...prevValues, + employer: e.target.value, + })); + }} + value={patient.employer} + // onBlur={formik.handleBlur} /> @@ -146,9 +198,14 @@ export default function FamilyFormSection(){ type="number" className='collapsable-form-style' name='businessPhone' - onChange={formik.handleChange} - value={formik.values.businessPhone} - onBlur={formik.handleBlur} + onChange={(e)=>{ + setPatient((prevValues:any) => ({ + ...prevValues, + businessPhone: e.target.value, + })); + }} + value={patient.businessPhone} + // onBlur={formik.handleBlur} /> @@ -164,9 +221,14 @@ export default function FamilyFormSection(){ label="Spouse's Name" className='collapsable-form-style' name='spouseName' - onChange={formik.handleChange} - value={formik.values.spouseName} - onBlur={formik.handleBlur} + onChange={(e)=>{ + setPatient((prevValues:any) => ({ + ...prevValues, + spouseName: e.target.value, + })); + }} + value={patient.spouseName} + // onBlur={formik.handleBlur} /> @@ -175,9 +237,14 @@ export default function FamilyFormSection(){ label="Spouse's Employer" className='collapsable-form-style' name='spouseEmployer' - onChange={formik.handleChange} - value={formik.values.spouseEmployer} - onBlur={formik.handleBlur} + onChange={(e)=>{ + setPatient((prevValues:any) => ({ + ...prevValues, + spouseEmployer: e.target.value, + })); + }} + value={patient.spouseEmployer} + // onBlur={formik.handleBlur} /> @@ -187,9 +254,14 @@ export default function FamilyFormSection(){ type="number" className='collapsable-form-style' name='spouseBusinessPhone' - onChange={formik.handleChange} - value={formik.values.spouseBusinessPhone} - onBlur={formik.handleBlur} + onChange={(e)=>{ + setPatient((prevValues:any) => ({ + ...prevValues, + spouseBusinessPhone: e.target.value, + })); + }} + value={patient.spouseBusinessPhone} + // onBlur={formik.handleBlur} /> @@ -202,12 +274,16 @@ export default function FamilyFormSection(){ { + setPatient((prevValues:any) => ({ + ...prevValues, + emergencyContact: e.target.value, + })); + }} + value={patient.emergencyContact} + // onBlur={formik.handleBlur} /> @@ -216,9 +292,14 @@ export default function FamilyFormSection(){ label="Relationship" className='collapsable-form-style' name='relationship' - onChange={formik.handleChange} - value={formik.values.relationship} - onBlur={formik.handleBlur} + onChange={(e)=>{ + setPatient((prevValues:any) => ({ + ...prevValues, + relationship: e.target.value, + })); + }} + value={patient.relationship} + // onBlur={formik.handleBlur} /> @@ -228,13 +309,17 @@ export default function FamilyFormSection(){ label="Phone" className='collapsable-form-style' name='spousePhone' - onChange={formik.handleChange} - value={formik.values.spousePhone} - onBlur={formik.handleBlur} + onChange={(e)=>{ + setPatient((prevValues:any) => ({ + ...prevValues, + spousePhone: e.target.value, + })); + }} + value={patient.spousePhone} + // onBlur={formik.handleBlur} /> - ) }; diff --git a/src/Components/PatientForm/MedicalHistorySection3.tsx b/src/Components/PatientForm/MedicalHistorySection3.tsx index a9b28a2..c6897bb 100644 --- a/src/Components/PatientForm/MedicalHistorySection3.tsx +++ b/src/Components/PatientForm/MedicalHistorySection3.tsx @@ -2,19 +2,20 @@ 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 { useEffect } from 'react'; -interface FormValues { - physicianname: string; - physiciancity: string; - physicianstate: string; - physicianphone: string; - chiropractorName: string; - chiropractorState: string; - xray: boolean; - ctScan: boolean; - cdImages: boolean; - visitDetails: string; - cellPhoneProvider: string; +interface Patient { + physicianname: string |undefined; + physiciancity: string |undefined; + physicianstate: string |undefined; + physicianphone: string |undefined; + chiropractorName: string |undefined; + chiropractorState: string |undefined; + xray: string|undefined; + haveChiropractor: string|undefined; + reference: string|undefined; + visitDetails: string |undefined; + cellPhoneProvider: string |undefined; } const validationSchema = Yup.object({ @@ -24,35 +25,61 @@ const validationSchema = Yup.object({ phone: Yup.string().required('Required'), chiropractorName: Yup.string().required('Required'), xray: Yup.boolean().required('Required'), - ctScan: Yup.boolean().required('Required'), - cdImages: Yup.boolean().required('Required'), + haveChiropractor: Yup.boolean().required('Required'), + reference: Yup.boolean().required('Required'), visitDetails: Yup.string().required('Required'), cellPhoneProvider: Yup.string().required('Required'), }); -export default function MedicalHistoryForm(){ - const formik = useFormik({ - initialValues:{ - physicianname: '', - physiciancity: '', - physicianstate: '', - physicianphone: '', - chiropractorName: '', - chiropractorState: '', - xray: false, - ctScan: false, - cdImages: false, - visitDetails: '', - cellPhoneProvider: '', - }, - validationSchema, - onSubmit:(values)=>{ - console.log(values); - } - }) +type Props = { + handleFormSection3Data:( + physicianname?: string |undefined, + physiciancity?: string |undefined, + physicianstate?: string |undefined, + physicianphone?: string |undefined, + chiropractorName?: string |undefined, + chiropractorState?: string |undefined, + xray?: string|undefined, + haveChiropractor?: string|undefined, + reference?: string|undefined, + visitDetails?: string |undefined, + cellPhoneProvider?: string |undefined, + )=> void + } + +export default function MedicalHistoryForm({handleFormSection3Data}:Props){ + + const [patient, setPatient] = React.useState({ + physicianname: '', + physiciancity: '', + physicianstate: '', + physicianphone: '', + chiropractorName: '', + chiropractorState: '', + xray: '', + haveChiropractor: '', + reference: '', + visitDetails: '', + cellPhoneProvider: '', + }); + + useEffect(()=>{ + handleFormSection3Data( + patient.physicianname, + patient.physiciancity, + patient.physicianstate, + patient.physicianphone, + patient.chiropractorName, + patient.chiropractorState, + patient.xray, + patient.haveChiropractor, + patient.reference, + patient.visitDetails, + patient.cellPhoneProvider, + ) + },[patient]) return( <> -
Physician Hisory Information: @@ -63,9 +90,14 @@ export default function MedicalHistoryForm(){ variant="outlined" label="Family physician" name='physicianname' - onChange={formik.handleChange} - value={formik.values.physicianname} - onBlur={formik.handleBlur} + onChange={(e)=>{ + setPatient((prevValues) => ({ + ...prevValues, + physicianname: e.target.value, + })); + }} + value={patient.physicianname} + // onBlur={formik.handleBlur} /> @@ -73,9 +105,14 @@ export default function MedicalHistoryForm(){ variant="outlined" label="City" name='physiciancity' - onChange={formik.handleChange} - value={formik.values.physiciancity} - onBlur={formik.handleBlur} + onChange={(e)=>{ + setPatient((prevValues) => ({ + ...prevValues, + physiciancity: e.target.value, + })); + }} + value={patient.physiciancity} + // onBlur={formik.handleBlur} /> @@ -83,9 +120,14 @@ export default function MedicalHistoryForm(){ variant="outlined" label="State" name='physicianstate' - onChange={formik.handleChange} - value={formik.values.physicianstate} - onBlur={formik.handleBlur} + onChange={(e)=>{ + setPatient((prevValues) => ({ + ...prevValues, + physicianstate: e.target.value, + })); + }} + value={patient.physicianstate} + // onBlur={formik.handleBlur} /> @@ -94,9 +136,14 @@ export default function MedicalHistoryForm(){ label="Phone" type="number" name='physicianphone' - onChange={formik.handleChange} - value={formik.values.physicianphone} - onBlur={formik.handleBlur} + onChange={(e)=>{ + setPatient((prevValues) => ({ + ...prevValues, + physicianphone: e.target.value, + })); + }} + value={patient.physicianphone} + // onBlur={formik.handleBlur} /> @@ -115,7 +162,12 @@ export default function MedicalHistoryForm(){ aria-labelledby="demo-radio-buttons-group-label" // defaultValue="yes" name="radio-buttons-group" - onChange={formik.handleChange} + onChange={(e)=>{ + setPatient((prevValues) => ({ + ...prevValues, + haveChiropractor: e.target.value, + })); + }} sx={{display:'flex', flexDirection:'row'}} > } label="Yes" /> @@ -129,9 +181,14 @@ export default function MedicalHistoryForm(){ variant="outlined" label="Chiropractor's Name" name='chiropractorName' - onChange={formik.handleChange} - value={formik.values.chiropractorName} - onBlur={formik.handleBlur} + onChange={(e)=>{ + setPatient((prevValues) => ({ + ...prevValues, + chiropractorName: e.target.value, + })); + }} + value={patient.chiropractorName} + // onBlur={formik.handleBlur} /> @@ -140,9 +197,14 @@ export default function MedicalHistoryForm(){ variant="outlined" label="City/State" name='chiropractorState' - onChange={formik.handleChange} - value={formik.values.chiropractorState} - onBlur={formik.handleBlur} + onChange={(e)=>{ + setPatient((prevValues) => ({ + ...prevValues, + chiropractorState: e.target.value, + })); + }} + value={patient.chiropractorState} + // onBlur={formik.handleBlur} /> @@ -155,7 +217,12 @@ export default function MedicalHistoryForm(){ aria-labelledby="demo-radio-buttons-group-label" // defaultValue="yes" name="radio-buttons-group" - onChange={formik.handleChange} + onChange={(e)=>{ + setPatient((prevValues) => ({ + ...prevValues, + xray: e.target.value, + })); + }} sx={{display:'flex', flexDirection:'row'}} > } label="Yes" /> @@ -172,7 +239,12 @@ export default function MedicalHistoryForm(){ aria-labelledby="demo-radio-buttons-group-label" // defaultValue="physician" name="radio-buttons-group" - onChange={formik.handleChange} + onChange={(e)=>{ + setPatient((prevValues) => ({ + ...prevValues, + reference: e.target.value, + })); + }} sx={{display:'flex', flexDirection:'row'}} > } label="Friend" /> @@ -193,7 +265,12 @@ export default function MedicalHistoryForm(){ aria-labelledby="demo-radio-buttons-group-label" // defaultValue="email" name="radio-buttons-group" - onChange={formik.handleChange} + onChange={(e)=>{ + setPatient((prevValues) => ({ + ...prevValues, + cellPhoneProvider: e.target.value, + })); + }} sx={{display:'flex', flexDirection:'row'}} > } label="Email" /> @@ -201,7 +278,6 @@ export default function MedicalHistoryForm(){ - )} \ No newline at end of file diff --git a/src/Components/PatientForm/OtherDetails8.tsx b/src/Components/PatientForm/OtherDetails8.tsx index 295805a..3ad757c 100644 --- a/src/Components/PatientForm/OtherDetails8.tsx +++ b/src/Components/PatientForm/OtherDetails8.tsx @@ -1,10 +1,10 @@ import { Grid, FormLabel, TextField, FormControl, RadioGroup, FormControlLabel, Radio } from "@mui/material"; import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; -import React from "react"; +import React, { useEffect } from "react"; import { LocalizationProvider, DatePicker } from '@mui/x-date-pickers'; import dayjs from "dayjs"; -interface FormValues { +interface Patient { familyHistory: string; sleep: string; pillow:string; @@ -14,9 +14,21 @@ interface FormValues { menstralCycle: any; } -export default function OtherDetails8(){ + type Props = { + handleFormSection8Data:( + familyHistory: string|undefined, + sleep: string|undefined, + pillow:string|undefined, + orthotics:string|undefined, + brestExam: any, + pregnancy:string|undefined, + menstralCycle: any, + )=> void + } + +export default function OtherDetails8({handleFormSection8Data}:Props){ - const [values, setValues] = React.useState({ + const [patient, setPatient] = React.useState({ familyHistory: '', sleep: '', pillow:'', @@ -26,6 +38,18 @@ export default function OtherDetails8(){ menstralCycle: dayjs('2022-04-17'), }); + useEffect(()=>{ + handleFormSection8Data( + patient.familyHistory, + patient.sleep, + patient.pillow, + patient.orthotics, + patient.brestExam=dayjs(patient.brestExam), + patient.pregnancy, + patient.menstralCycle=dayjs(patient.menstralCycle) + ) + },[patient]) + const formatDate = (inputDate:any) => { const date = new Date(inputDate); const year = date.getUTCFullYear(); @@ -35,7 +59,8 @@ export default function OtherDetails8(){ return `${year}-${month}-${day}`; }; - console.log("dsfdsfsdf",values) + + return( <> @@ -48,7 +73,7 @@ export default function OtherDetails8(){ label="" name='explanation' onChange={(event:any) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, familyHistory: event.target.value, })); @@ -62,9 +87,9 @@ export default function OtherDetails8(){ { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, - educationLevel: event.target.value, + sleep: event.target.value, })); }} > @@ -81,7 +106,7 @@ export default function OtherDetails8(){ { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, pillow: event.target.value, })); @@ -99,7 +124,7 @@ export default function OtherDetails8(){ { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, orthotics: event.target.value, })); @@ -116,10 +141,10 @@ export default function OtherDetails8(){ { const formattedDate = formatDate(event) - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, brestExam: formattedDate, })); @@ -140,9 +165,9 @@ export default function OtherDetails8(){ { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, - orthotics: event.target.value, + pregnancy: event.target.value, })); }} > @@ -157,10 +182,10 @@ export default function OtherDetails8(){ { const formattedDate = formatDate(event) - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, menstralCycle: formattedDate, })); diff --git a/src/Components/PatientForm/PainAnalysisSection4.tsx b/src/Components/PatientForm/PainAnalysisSection4.tsx index d8509b4..395006e 100644 --- a/src/Components/PatientForm/PainAnalysisSection4.tsx +++ b/src/Components/PatientForm/PainAnalysisSection4.tsx @@ -2,51 +2,119 @@ 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), + })); + }; return( <> -
Issue Details: @@ -56,9 +124,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 +139,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 +168,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 +200,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 +224,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 +252,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 +274,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 +299,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 +323,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/PastTreatment5.tsx b/src/Components/PatientForm/PastTreatment5.tsx index 4268ffc..b8388c1 100644 --- a/src/Components/PatientForm/PastTreatment5.tsx +++ b/src/Components/PatientForm/PastTreatment5.tsx @@ -1,8 +1,9 @@ import { TextField, FormControlLabel,Grid,Checkbox, FormControl, FormLabel, Radio, RadioGroup } from '@mui/material'; import * as React from 'react'; import Table from '../Helper/AddNewTable'; +import { useEffect } from 'react'; -interface FormValues { +interface Patient { generalHealth: string; presentProblemBefore: string; ifYespresentProblemBefore:string; @@ -17,10 +18,27 @@ interface FormValues { supplementsOrDrugs: string; } +type Props = { + handleFormSection5Data:( + generalHealth: string|undefined, + presentProblemBefore: string|undefined, + ifYespresentProblemBefore:string|undefined, + ifYestreatmentProvided: string|undefined, + ifYesOutcome: string|undefined, + strokeBloodclotting: string|undefined, + ifYesstrokeBloodclotting: string|undefined, + dizzinessFetigue: string|undefined, + ifyesdizzinessFetigue: string|undefined, + antiColligent: string|undefined, + injuriesHospitalization: string|undefined, + supplementsOrDrugs: string|undefined, + )=> void +} -export default function PastTreatment5(){ - const [values, setValues] = React.useState({ +export default function PastTreatment5({handleFormSection5Data}:Props){ + + const [patient, setPatient] = React.useState({ generalHealth: '', presentProblemBefore: '', ifYespresentProblemBefore:'', @@ -35,7 +53,23 @@ export default function PastTreatment5(){ supplementsOrDrugs:'' }); - console.log("dsfdsfdsfg",values) + useEffect(()=>{ + handleFormSection5Data( + patient.generalHealth, + patient.presentProblemBefore, + patient.ifYespresentProblemBefore, + patient.ifYestreatmentProvided, + patient.ifYesOutcome, + patient.strokeBloodclotting, + patient.ifYesstrokeBloodclotting, + patient.dizzinessFetigue, + patient.ifyesdizzinessFetigue, + patient.antiColligent, + patient.injuriesHospitalization, + patient.supplementsOrDrugs, + ) + },[patient]) + return( <>
@@ -48,7 +82,7 @@ export default function PastTreatment5(){ name="painDuration" sx={{display:'flex', flexDirection:'row'}} onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, generalHealth: event.target.value, })); @@ -70,7 +104,7 @@ export default function PastTreatment5(){ name="painDuration" sx={{display:'flex', flexDirection:'row'}} onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, presentProblemBefore: event.target.value, })); @@ -88,9 +122,9 @@ export default function PastTreatment5(){ variant="outlined" label="If yes, when?" name='treatmentGoal' - disabled={values.presentProblemBefore!=='Yes'} + disabled={patient.presentProblemBefore!=='Yes'} onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, ifYespresentProblemBefore: event.target.value, })); @@ -102,9 +136,9 @@ export default function PastTreatment5(){ variant="outlined" label="Was treatment provided?If yes, by whom?" name='treatmentGoal' - disabled={values.presentProblemBefore!=='Yes'} + disabled={patient.presentProblemBefore!=='Yes'} onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, ifYestreatmentProvided: event.target.value, })); @@ -116,9 +150,9 @@ export default function PastTreatment5(){ variant="outlined" label="Outcome?" name='treatmentGoal' - disabled={values.presentProblemBefore!=='Yes'} + disabled={patient.presentProblemBefore!=='Yes'} onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, ifYesOutcome: event.target.value, })); @@ -134,7 +168,7 @@ export default function PastTreatment5(){ name="painDuration" sx={{display:'flex', flexDirection:'row'}} onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, strokeBloodclotting: event.target.value, })); @@ -151,9 +185,9 @@ export default function PastTreatment5(){ variant="outlined" label="If yes, when?" name='treatmentGoal' - disabled={values.strokeBloodclotting!=='Yes'} + disabled={patient.strokeBloodclotting!=='Yes'} onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, ifYesstrokeBloodclotting: event.target.value, })); @@ -168,7 +202,7 @@ export default function PastTreatment5(){ name="painDuration" sx={{display:'flex', flexDirection:'row'}} onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, dizzinessFetigue: event.target.value, })); @@ -185,9 +219,9 @@ export default function PastTreatment5(){ variant="outlined" label="If yes, when?" name='treatmentGoal' - disabled={values.dizzinessFetigue!=='Yes'} + disabled={patient.dizzinessFetigue!=='Yes'} onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, ifyesdizzinessFetigue: event.target.value, })); @@ -202,7 +236,7 @@ export default function PastTreatment5(){ name="painDuration" sx={{display:'flex', flexDirection:'row'}} onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, antiColligent: event.target.value, })); @@ -221,7 +255,7 @@ export default function PastTreatment5(){ name="painDuration" sx={{display:'flex', flexDirection:'row'}} onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, injuriesHospitalization: event.target.value, })); @@ -245,7 +279,7 @@ export default function PastTreatment5(){ label="" name='treatmentGoal' onChange={(event) => { - setValues((prevValues) => ({ + setPatient((prevValues) => ({ ...prevValues, supplementsOrDrugs: event.target.value, })); diff --git a/src/Components/PatientForm/PatientForm.tsx b/src/Components/PatientForm/PatientForm.tsx index 5999d78..9648897 100644 --- a/src/Components/PatientForm/PatientForm.tsx +++ b/src/Components/PatientForm/PatientForm.tsx @@ -21,22 +21,6 @@ import RecreationalHobbiesSection7 from './RecreationalHobbiesSection7'; import OtherDetails8 from './OtherDetails8'; import PatientImageMarker from '../ImageMarker/PatientImageMarker'; -interface Patient { - fullName: string; - homePhone: string; - cellPhone: string; - email: string; - age: number; - dateOfBirth: string; - socialSecurityNumber: string; - mailingAddress: string; - city: string; - state: string; - zipCode: string; - gender: string; - maritalStatus: string; - } - const Accordion = styled((props: AccordionProps) => ( ))(({ theme }) => ({ @@ -73,30 +57,291 @@ interface Patient { borderTop: '1px solid rgba(0, 0, 0, .125)', })); + + export default function PatientForm(){ const [expanded, setExpanded] = React.useState('panel1'); const [isChecked, setIsChecked] = React.useState(false); const [signature,setSignature]=React.useState(''); - - const [patient, setPatient] = React.useState({ - fullName: "", - homePhone: "", - cellPhone: "", - email: "", - age: 0, - dateOfBirth: "", - socialSecurityNumber: "", - mailingAddress: "", - city: "", - state: "", - zipCode: "", - gender: "", - maritalStatus: "", - }); + const [section1Data, setSection1Data] = React.useState({}); + const [section2Data, setSection2Data] = React.useState({}); + const [section3Data, setSection3Data] = React.useState({}); + const [section4Data, setSection4Data] = React.useState({}); + const [section5Data, setSection5Data] = React.useState({}); + const [section6Data, setSection6Data] = React.useState({}); + const [section7Data, setSection7Data] = React.useState({}); + const [section8Data, setSection8Data] = React.useState({}); + const [restructuredCurrentPatientData, setRestructuredCurrentPatientData] = React.useState({}); + const [allPatientData, setAllPatientData] = React.useState([]); + + const handleFormSection1Data = ( + fullName?: string|undefined, + homePhone?: string|undefined, + cellPhone?: string|undefined, + email?: string|undefined, + age?: number|undefined|string, + dateOfBirth?: string|undefined, + socialSecurityNumber?: string|undefined, + mailingAddress?: string|undefined, + city?: string|undefined, + state?: string|undefined, + zipCode?: string|undefined, + gender?: string|undefined, + ) =>{ + setSection1Data({ + fullName, + homePhone, + cellPhone, + email, + age, + dateOfBirth, + socialSecurityNumber, + mailingAddress, + city, + state, + zipCode, + gender, + }) + } + + const handleFormSection2Data = ( + maritalStatus: string | undefined, + numberOfChildren: string | undefined, + occupation: string | undefined, + hoursPerWeek: number | string | undefined, + employer: string | undefined, + businessPhone: string | undefined, + spouseName: string | undefined, + spouseEmployer: string | undefined, + spouseBusinessPhone: string | undefined, + emergencyContact: string | undefined, + relationship: string | undefined, + spousePhone: string | undefined, + ) =>{ + setSection2Data({ + maritalStatus, + numberOfChildren, + occupation, + hoursPerWeek, + employer, + businessPhone, + spouseName, + spouseEmployer, + spouseBusinessPhone, + emergencyContact, + relationship, + spousePhone, + }) + } + + const handleFormSection3Data = ( + physicianname: string |undefined, + physiciancity: string |undefined, + physicianstate: string |undefined, + physicianphone: string |undefined, + chiropractorName: string |undefined, + chiropractorState: string |undefined, + xray: string|undefined, + haveChiropractor: string|undefined, + reference: string|undefined, + visitDetails: string |undefined, + cellPhoneProvider: string |undefined, + ) =>{ + setSection3Data({ + physicianname, + physiciancity, + physicianstate, + physicianphone, + chiropractorName, + chiropractorState, + xray, + haveChiropractor, + reference, + visitDetails, + 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 handleFormSection5Data = ( + generalHealth: string|undefined, + presentProblemBefore: string|undefined, + ifYespresentProblemBefore:string|undefined, + ifYestreatmentProvided: string|undefined, + ifYesOutcome: string|undefined, + strokeBloodclotting: string|undefined, + ifYesstrokeBloodclotting: string|undefined, + dizzinessFetigue: string|undefined, + ifyesdizzinessFetigue: string|undefined, + antiColligent: string|undefined, + injuriesHospitalization: string|undefined, + supplementsOrDrugs: string|undefined, + ) =>{ + setSection5Data({ + generalHealth, + presentProblemBefore, + ifYespresentProblemBefore, + ifYestreatmentProvided, + ifYesOutcome, + strokeBloodclotting, + ifYesstrokeBloodclotting, + dizzinessFetigue, + ifyesdizzinessFetigue, + antiColligent, + injuriesHospitalization, + supplementsOrDrugs, + }) + } + + const handleFormSection6Data = ( + eyes: string|undefined, + IntestinesBowls: string|undefined, + jointsBones:string|undefined, + allergies: string|undefined, + earsNoseMouth: string|undefined, + urinary: string|undefined, + skin: string|undefined, + psychological: string|undefined, + heart: string|undefined, + muscles: string|undefined, + internalOrgans: string|undefined, + gynecological: string|undefined, + lungsBreathing: string|undefined, + nerves: string|undefined, + blood: string|undefined, + prostate: string|undefined, + explanation:string|undefined, + ) =>{ + setSection6Data({ + eyes, + IntestinesBowls, + jointsBones, + allergies, + earsNoseMouth, + urinary, + skin, + psychological, + heart, + muscles, + internalOrgans, + gynecological, + lungsBreathing, + nerves, + blood, + prostate, + explanation, + }) + } + + + const handleFormSection7Data = ( + hobbies: string|undefined, + educationLevel: string|undefined, + excercise: string|undefined, + excerciseExplanation: string|undefined, + tobacco: string|undefined, + tobaccoExplanation: string|undefined, + alcohol: string|undefined, + alcoholExplanation: string|undefined, + healthyDiet: string|undefined, + healthyDietExplanation: string|undefined, + sleep: string|undefined, + sleepExplanation: string|undefined, + workSchool: string|undefined, + workSchoolExplanation: string|undefined, + familyLife: string|undefined, + familyLifeExplanation: string|undefined, + drugs: string|undefined, + drugsExplanation:string|undefined, + ) =>{ + setSection7Data({ + hobbies, + educationLevel, + excercise, + excerciseExplanation, + tobacco, + tobaccoExplanation, + alcohol, + alcoholExplanation, + healthyDiet, + healthyDietExplanation, + sleep, + sleepExplanation, + workSchool, + workSchoolExplanation, + familyLife, + familyLifeExplanation, + drugs, + drugsExplanation, + }) + } + + const handleFormSection8Data = ( + familyHistory: string|undefined, + sleep: string|undefined, + pillow: string|undefined, + orthotics: string|undefined, + brestExam: any, + pregnancy: string|undefined, + menstralCycle: any, + ) =>{ + setSection8Data({ + familyHistory, + sleep, + pillow, + orthotics, + brestExam, + pregnancy, + menstralCycle, + }) + } - const handleSubmit = (event: React.FormEvent) => { - event.preventDefault(); + const handleSubmit = () => { + const newPatientData = { + section1: section1Data, + section2: section2Data, + section3: section3Data, + section4: section4Data, + section5: section5Data, + section6: section6Data, + section7: section7Data, + section8: section8Data, }; + + // Create a copy of the existing data array and push the new patient data + const updatedAllPatientData = [...allPatientData, newPatientData]; + + // Update the state with the new array + setAllPatientData(updatedAllPatientData); + + console.log("UpdatedallPatientData:", updatedAllPatientData); + }; + const handleExpandChange = (panel: string) => (event: React.SyntheticEvent, newExpanded: boolean) => { @@ -106,6 +351,7 @@ export default function PatientForm(){ const handleCheckboxChange = (event:any) => { setIsChecked(event.target.checked); }; + return( @@ -113,7 +359,7 @@ export default function PatientForm(){
- + {/* */} Confidential Patient Information @@ -129,7 +375,7 @@ export default function PatientForm(){ - + @@ -140,7 +386,7 @@ export default function PatientForm(){ - + @@ -150,7 +396,7 @@ export default function PatientForm(){ - + @@ -171,7 +417,7 @@ export default function PatientForm(){ - + @@ -181,7 +427,7 @@ export default function PatientForm(){ - + @@ -191,7 +437,7 @@ export default function PatientForm(){ - + @@ -201,7 +447,7 @@ export default function PatientForm(){ - + @@ -211,7 +457,7 @@ export default function PatientForm(){ - + @@ -242,17 +488,18 @@ export default function PatientForm(){ - + {/* */}