feature/patientSubmitData #2

Merged
vipeesh.p merged 9 commits from feature/patientSubmitData into develop 2023-09-05 09:04:04 +00:00
2 changed files with 124 additions and 32 deletions
Showing only changes of commit 867dac8327 - Show all commits

View File

@ -83,6 +83,7 @@ export default function PatientForm(){
const [section4Data, setSection4Data] = React.useState<any>({});
const [section5Data, setSection5Data] = React.useState<any>({});
const [section6Data, setSection6Data] = React.useState<any>({});
const [section7Data, setSection7Data] = React.useState<any>({});
const handleFormSection1Data = (
fullName?: string|undefined,
@ -267,6 +268,49 @@ export default function PatientForm(){
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 handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
@ -281,7 +325,7 @@ export default function PatientForm(){
setIsChecked(event.target.checked);
};
console.log("wyeytweevfde",section6Data)
console.log("wyeytweevfde",section7Data)
return(
@ -366,7 +410,7 @@ export default function PatientForm(){
</AccordionSummary>
<AccordionDetails>
<RecreationalHobbiesSection7/>
<RecreationalHobbiesSection7 handleFormSection7Data={handleFormSection7Data}/>
</AccordionDetails>
</Accordion>

View File

@ -1,7 +1,7 @@
import { FormControl, FormControlLabel, FormLabel, Grid, Radio, RadioGroup, TextField } from "@mui/material";
import React from "react";
import React, { useEffect } from "react";
interface FormValues {
interface Patient {
hobbies: string;
educationLevel: string;
excercise: string;
@ -22,8 +22,31 @@ interface FormValues {
drugsExplanation:string;
}
export default function RecreationalHobbiesSection7(){
const [values, setValues] = React.useState<FormValues>({
type Props = {
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,
)=> void
}
export default function RecreationalHobbiesSection7({handleFormSection7Data}:Props){
const [patient, setPatient] = React.useState<Patient>({
hobbies: '',
educationLevel: '',
excercise:'',
@ -43,6 +66,31 @@ export default function RecreationalHobbiesSection7(){
drugs: '',
drugsExplanation:''
});
useEffect(()=>{
handleFormSection7Data(
patient.hobbies,
patient.educationLevel,
patient.excercise,
patient.excerciseExplanation,
patient.tobacco,
patient.tobaccoExplanation,
patient.alcohol,
patient.alcoholExplanation,
patient.healthyDiet,
patient.healthyDietExplanation,
patient.sleep,
patient.sleepExplanation,
patient.workSchool,
patient.workSchoolExplanation,
patient.familyLife,
patient.familyLifeExplanation,
patient.drugs,
patient.drugsExplanation
)
},[patient])
return(
<>
@ -55,7 +103,7 @@ export default function RecreationalHobbiesSection7(){
label=""
name='explanation'
onChange={(event:any) => {
setValues((prevValues) => ({
setPatient((prevValues) => ({
...prevValues,
hobbies: event.target.value,
}));
@ -69,7 +117,7 @@ export default function RecreationalHobbiesSection7(){
<RadioGroup
sx={{display:'flex', flexDirection:'row'}}
onChange={(event) => {
setValues((prevValues) => ({
setPatient((prevValues) => ({
...prevValues,
educationLevel: event.target.value,
}));
@ -91,7 +139,7 @@ export default function RecreationalHobbiesSection7(){
name="painDuration"
sx={{display:'flex', flexDirection:'row'}}
onChange={(event) => {
setValues((prevValues) => ({
setPatient((prevValues) => ({
...prevValues,
excercise: event.target.value,
}));
@ -105,12 +153,12 @@ export default function RecreationalHobbiesSection7(){
<Grid item xs={6} className='collapsable-form-style-form7'>
<TextField
disabled={values.excercise!=='Yes'}
disabled={patient.excercise!=='Yes'}
variant="outlined"
label="Times per week?"
name='treatmentGoal'
onChange={(event) => {
setValues((prevValues) => ({
setPatient((prevValues) => ({
...prevValues,
excerciseExplanation: event.target.value,
}));
@ -125,7 +173,7 @@ export default function RecreationalHobbiesSection7(){
name="painDuration"
sx={{display:'flex', flexDirection:'row'}}
onChange={(event) => {
setValues((prevValues) => ({
setPatient((prevValues) => ({
...prevValues,
tobacco: event.target.value,
}));
@ -139,12 +187,12 @@ export default function RecreationalHobbiesSection7(){
<Grid item xs={6} className='collapsable-form-style-form7'>
<TextField
disabled={values.tobacco!=='Yes'}
disabled={patient.tobacco!=='Yes'}
variant="outlined"
label="Packs/Cans per day(If you have quit, when did you quit?)"
name='treatmentGoal'
onChange={(event) => {
setValues((prevValues) => ({
setPatient((prevValues) => ({
...prevValues,
excerciseExplanation: event.target.value,
}));
@ -159,7 +207,7 @@ export default function RecreationalHobbiesSection7(){
name="painDuration"
sx={{display:'flex', flexDirection:'row'}}
onChange={(event) => {
setValues((prevValues) => ({
setPatient((prevValues) => ({
...prevValues,
alcohol: event.target.value,
}));
@ -173,12 +221,12 @@ export default function RecreationalHobbiesSection7(){
<Grid item xs={6} className='collapsable-form-style-form7'>
<TextField
disabled={values.alcohol!=='Yes'}
disabled={patient.alcohol!=='Yes'}
variant="outlined"
label="How many drinks per week?"
name='treatmentGoal'
onChange={(event) => {
setValues((prevValues) => ({
setPatient((prevValues) => ({
...prevValues,
alcoholExplanation: event.target.value,
}));
@ -193,7 +241,7 @@ export default function RecreationalHobbiesSection7(){
name="painDuration"
sx={{display:'flex', flexDirection:'row'}}
onChange={(event) => {
setValues((prevValues) => ({
setPatient((prevValues) => ({
...prevValues,
healthyDiet: event.target.value,
}));
@ -207,12 +255,12 @@ export default function RecreationalHobbiesSection7(){
<Grid item xs={6} className='collapsable-form-style-form7'>
<TextField
disabled={values.healthyDiet!=='No'}
disabled={patient.healthyDiet!=='No'}
variant="outlined"
label="If no, explain"
name='treatmentGoal'
onChange={(event) => {
setValues((prevValues) => ({
setPatient((prevValues) => ({
...prevValues,
healthyDietExplanation: event.target.value,
}));
@ -227,7 +275,7 @@ export default function RecreationalHobbiesSection7(){
name="painDuration"
sx={{display:'flex', flexDirection:'row'}}
onChange={(event) => {
setValues((prevValues) => ({
setPatient((prevValues) => ({
...prevValues,
sleep: event.target.value,
}));
@ -241,12 +289,12 @@ export default function RecreationalHobbiesSection7(){
<Grid item xs={6} className='collapsable-form-style-form7'>
<TextField
disabled={values.sleep!=='No'}
disabled={patient.sleep!=='No'}
variant="outlined"
label="If no, explain"
name='treatmentGoal'
onChange={(event) => {
setValues((prevValues) => ({
setPatient((prevValues) => ({
...prevValues,
sleepExplanation: event.target.value,
}));
@ -261,7 +309,7 @@ export default function RecreationalHobbiesSection7(){
name="painDuration"
sx={{display:'flex', flexDirection:'row'}}
onChange={(event) => {
setValues((prevValues) => ({
setPatient((prevValues) => ({
...prevValues,
workSchool: event.target.value,
}));
@ -275,12 +323,12 @@ export default function RecreationalHobbiesSection7(){
<Grid item xs={6} className='collapsable-form-style-form7'>
<TextField
disabled={values.workSchool!=='Yes'}
disabled={patient.workSchool!=='Yes'}
variant="outlined"
label="If yes, explain"
name='treatmentGoal'
onChange={(event) => {
setValues((prevValues) => ({
setPatient((prevValues) => ({
...prevValues,
workSchool: event.target.value,
}));
@ -295,7 +343,7 @@ export default function RecreationalHobbiesSection7(){
name="painDuration"
sx={{display:'flex', flexDirection:'row'}}
onChange={(event) => {
setValues((prevValues) => ({
setPatient((prevValues) => ({
...prevValues,
familyLife: event.target.value,
}));
@ -309,12 +357,12 @@ export default function RecreationalHobbiesSection7(){
<Grid item xs={6} className='collapsable-form-style-form7'>
<TextField
disabled={values.familyLife!=='Yes'}
disabled={patient.familyLife!=='Yes'}
variant="outlined"
label="If yes, explain"
name='treatmentGoal'
onChange={(event) => {
setValues((prevValues) => ({
setPatient((prevValues) => ({
...prevValues,
familyLifeExplanation: event.target.value,
}));
@ -329,7 +377,7 @@ export default function RecreationalHobbiesSection7(){
name="painDuration"
sx={{display:'flex', flexDirection:'row'}}
onChange={(event) => {
setValues((prevValues) => ({
setPatient((prevValues) => ({
...prevValues,
drugs: event.target.value,
}));
@ -343,12 +391,12 @@ export default function RecreationalHobbiesSection7(){
<Grid item xs={6} className='collapsable-form-style-form7'>
<TextField
disabled={values.drugs!=='Yes'}
disabled={patient.drugs!=='Yes'}
variant="outlined"
label="If yes, explain"
name='treatmentGoal'
onChange={(event) => {
setValues((prevValues) => ({
setPatient((prevValues) => ({
...prevValues,
drugsExplanation: event.target.value,
}));