From 303225458d82c493a62faa38d92d77f519b47be6 Mon Sep 17 00:00:00 2001 From: vipeeshpavithran Date: Thu, 7 Sep 2023 14:15:12 +0530 Subject: [PATCH] Added image marker values to json data --- .../ImageMarker/ViewPatientImageMarker.tsx | 37 +- src/Components/PatientForm/PatientForm.tsx | 1159 +++++++++-------- 2 files changed, 646 insertions(+), 550 deletions(-) diff --git a/src/Components/ImageMarker/ViewPatientImageMarker.tsx b/src/Components/ImageMarker/ViewPatientImageMarker.tsx index 6564ca4..495dfae 100644 --- a/src/Components/ImageMarker/ViewPatientImageMarker.tsx +++ b/src/Components/ImageMarker/ViewPatientImageMarker.tsx @@ -1,30 +1,35 @@ -import React, { useEffect, useState } from 'react' +import React, { useEffect, useState } from 'react'; import ImageMarker, { Marker } from 'react-image-marker'; import humanImage from '../../Assets/human_body_3d.jpg'; -import './PatientImageMarker.css' +import './PatientImageMarker.css'; import Rating from './Rating'; -type Props = {} +type Props = {}; const ViewPatientImageMarker = (props: Props) => { const saved = JSON.parse(localStorage.getItem('entry') || '{}'); return ( -
+
How much pain? - {saved.entries?.map((entry: any, index: number) => ( -
- {entry.index} - {}} disabled/> -
- ))} -
-
- + {saved.entries?.map((entry: any, index: number) => ( +
+ {entry.index} + {}} + disabled + />
+ ))} +
+
+ +
- ) -} + ); +}; -export default ViewPatientImageMarker; \ No newline at end of file +export default ViewPatientImageMarker; diff --git a/src/Components/PatientForm/PatientForm.tsx b/src/Components/PatientForm/PatientForm.tsx index 9e0c603..d043916 100644 --- a/src/Components/PatientForm/PatientForm.tsx +++ b/src/Components/PatientForm/PatientForm.tsx @@ -1,9 +1,20 @@ import * as React from 'react'; import Typography from '@mui/material/Typography'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; -import Footer from "../Footer"; -import Header from "../Header"; -import {Button, Checkbox, FormControlLabel, FormGroup, FormLabel, Grid, Paper, Radio, RadioGroup, TextField } from '@mui/material'; +import Footer from '../Footer'; +import Header from '../Header'; +import { + Button, + Checkbox, + FormControlLabel, + FormGroup, + FormLabel, + Grid, + Paper, + Radio, + RadioGroup, + TextField, +} from '@mui/material'; import PersonalSection from './PersonalSection1'; import { styled } from '@mui/material/styles'; import ArrowForwardIosSharpIcon from '@mui/icons-material/ArrowForwardIosSharp'; @@ -23,362 +34,370 @@ import PatientImageMarker from '../ImageMarker/PatientImageMarker'; import ViewPatientImageMarker from '../ImageMarker/ViewPatientImageMarker'; import AlertDialog from '../Helper/AlertDialogBox'; - const Accordion = styled((props: AccordionProps) => ( - - ))(({ theme }) => ({ - border: `1px solid ${theme.palette.divider}`, - '&:not(:last-child)': { - borderBottom: 0, - }, - '&:before': { - display: 'none', - }, - })); - - const AccordionSummary = styled((props: AccordionSummaryProps) => ( - } - {...props} - /> - ))(({ theme }) => ({ - backgroundColor: - theme.palette.mode === 'dark' - ? 'rgba(255, 255, 255, .05)' - : 'rgba(0, 0, 0, .03)', - flexDirection: 'row-reverse', - '& .MuiAccordionSummary-expandIconWrapper.Mui-expanded': { - transform: 'rotate(90deg)', - }, - '& .MuiAccordionSummary-content': { - marginLeft: theme.spacing(1), - }, - })); - - const AccordionDetails = styled(MuiAccordionDetails)(({ theme }) => ({ - padding: theme.spacing(2), - borderTop: '1px solid rgba(0, 0, 0, .125)', - })); +const Accordion = styled((props: AccordionProps) => ( + +))(({ theme }) => ({ + border: `1px solid ${theme.palette.divider}`, + '&:not(:last-child)': { + borderBottom: 0, + }, + '&:before': { + display: 'none', + }, +})); -type Props={ - type:any; -} +const AccordionSummary = styled((props: AccordionSummaryProps) => ( + } + {...props} + /> +))(({ theme }) => ({ + backgroundColor: + theme.palette.mode === 'dark' + ? 'rgba(255, 255, 255, .05)' + : 'rgba(0, 0, 0, .03)', + flexDirection: 'row-reverse', + '& .MuiAccordionSummary-expandIconWrapper.Mui-expanded': { + transform: 'rotate(90deg)', + }, + '& .MuiAccordionSummary-content': { + marginLeft: theme.spacing(1), + }, +})); -export default function PatientForm({type}:Props){ - const [alertProps, setAlertProps] = React.useState({}); - const [expanded, setExpanded] = React.useState('panel1'); - const [isChecked, setIsChecked] = React.useState(false); - const [signature,setSignature]=React.useState(''); - 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 [allPatientData, setAllPatientData] = React.useState([]); +const AccordionDetails = styled(MuiAccordionDetails)(({ theme }) => ({ + padding: theme.spacing(2), + borderTop: '1px solid rgba(0, 0, 0, .125)', +})); - 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, - }) - } +type Props = { + type: any; +}; - 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, - }) - } +export default function PatientForm({ type }: Props) { + const [alertProps, setAlertProps] = React.useState({}); + const [expanded, setExpanded] = React.useState('panel1'); + const [isChecked, setIsChecked] = React.useState(false); + const [signature, setSignature] = React.useState(''); + 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 [allPatientData, setAllPatientData] = React.useState([]); - 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 = () => { - const newPatientData = { - personalInformation: section1Data, - familyInformation: section2Data, - medicalHistory: section3Data, - injuryDetails: section4Data, - pastTreatment: section5Data, - systemReviewQuestions: section6Data, - recreationalActivities: section7Data, - otherDetails: 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); - - localStorage.setItem('patientData', JSON.stringify(newPatientData)); - - if ( - section1Data.fullName !== "" && section1Data.cellPhone && - /^\d{10}$/.test(section1Data.cellPhone) && section1Data.email && - /^\S+@\S+\.\S+$/.test(section1Data.email) && section1Data.age && - section1Data.age !== "" && Number(section1Data.age) >= 0 && section1Data.mailingAddress && - section1Data.mailingAddress !== "" ){ - TextFile(); - }else{ - setAlertProps({ - open: true, - severity: 'error', - message: 'Please fill all the mandatory fields with valid data!', - duration: 4000, - }); - } + 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 = () => { + const saved = JSON.parse(localStorage.getItem('entry') || '{}'); + const newPatientData = { + personalInformation: section1Data, + familyInformation: section2Data, + medicalHistory: section3Data, + injuryDetails: section4Data, + pastTreatment: section5Data, + systemReviewQuestions: section6Data, + recreationalActivities: section7Data, + otherDetails: section8Data, + injuryPainDetails: saved.entries, + }; + + // 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); + + localStorage.setItem('patientData', JSON.stringify(newPatientData)); + + if ( + section1Data.fullName !== '' && + section1Data.cellPhone && + /^\d{10}$/.test(section1Data.cellPhone) && + section1Data.email && + /^\S+@\S+\.\S+$/.test(section1Data.email) && + section1Data.age && + section1Data.age !== '' && + Number(section1Data.age) >= 0 && + section1Data.mailingAddress && + section1Data.mailingAddress !== '' + ) { + TextFile(); + } else { + setAlertProps({ + open: true, + severity: 'error', + message: 'Please fill all the mandatory fields with valid data!', + duration: 4000, + }); + } + }; + const TextFile = () => { - const element = document.createElement("a"); + const element = document.createElement('a'); //@ts-ignore - const textFile = new Blob([localStorage.getItem('patientData')], {type: 'text/json'}); + const textFile = new Blob([localStorage.getItem('patientData')], { + type: 'text/json', + }); element.href = URL.createObjectURL(textFile); - element.download = "patientData.json"; - document.body.appendChild(element); + element.download = 'patientData.json'; + document.body.appendChild(element); element.click(); - } - + }; const handleExpandChange = (panel: string) => (event: React.SyntheticEvent, newExpanded: boolean) => { setExpanded(newExpanded ? panel : false); }; - - const handleCheckboxChange = (event:any) => { + + const handleCheckboxChange = (event: any) => { setIsChecked(event.target.checked); }; @@ -386,205 +405,277 @@ export default function PatientForm({type}:Props){ setAlertProps({}); }; - //@ts-ignore - const patientData = localStorage.getItem('patientData') ? JSON.parse(localStorage.getItem('patientData')) : []; + const patientData = localStorage.getItem('patientData') + ? //@ts-ignore + JSON.parse(localStorage.getItem('patientData')) + : []; - console.log("dfsdfdsf",patientData) - - return( - <> - {alertProps && alertProps.open && ( - - )} - -
- - {/*
*/} - - Confidential Patient Information - - - - - } - aria-controls="panel1a-content" - id="panel1a-header" - > - Patient's Personal Information - - - - - - - + console.log('dfsdfdsf', patientData); - - - Patient's Family Information - + return ( + <> + {alertProps && alertProps.open && ( + + )} + +
+ + {/* */} + + Confidential Patient Information + + + + } + aria-controls='panel1a-content' + id='panel1a-header' + > + + Patient's Personal Information + + - - - - + + + + - - - Patient's Medical History Information - - - - - - - - - - Patient's Injury Image - - - - { - type === 'fill' ? - - : - - } - - - + + + + Patient's Family Information + + + + + + - - - Patient's Injury Details - - - - - - + + + + Patient's Medical History Information + + - - - Patient's Past Treatment Details - - - - - - + + + + - - - System Review Questions - - - - - - + + + + Patient's Injury Image + + - - - Recreational Activities/Hobbies Details - - - - - - + + {type === 'fill' ? ( + + ) : ( + + )} + + - - - Other Details - - - - - - + + + + Patient's Injury Details + + - - - - } - label="I hereby state that all the information I have provided is complete and truthful and that I have fully disclosed my health history." - /> - - + + + + - - { - setSignature(event.target.value) - }} - /> - - - - - - - {/* */} - - -