diff --git a/src/Components/Interface/Patient.tsx b/src/Components/Interface/Patient.tsx
new file mode 100644
index 0000000..a566837
--- /dev/null
+++ b/src/Components/Interface/Patient.tsx
@@ -0,0 +1,14 @@
+export interface Patient {
+ fullName: string;
+ homePhone: string;
+ cellPhone: string;
+ email: string;
+ age: number | string;
+ dateOfBirth: string;
+ socialSecurityNumber: string;
+ mailingAddress: string;
+ city: string;
+ state: string;
+ zipCode: string;
+ gender: string;
+}
diff --git a/src/Components/PatientForm/PatientForm.tsx b/src/Components/PatientForm/PatientForm.tsx
index bc4216e..355e1df 100644
--- a/src/Components/PatientForm/PatientForm.tsx
+++ b/src/Components/PatientForm/PatientForm.tsx
@@ -35,7 +35,8 @@ import PatientImageMarker from '../ImageMarker/PatientImageMarker';
import ViewPatientImageMarker from '../ImageMarker/ViewPatientImageMarker';
import AlertDialog from '../Helper/AlertDialogBox';
import SignatureComponent from '../Helper/SignatureComponent';
-import { Link, useLocation } from 'react-router-dom';
+import { Link, useLocation } from 'react-router-dom';
+import { Patient } from '../Interface/Patient';
const Accordion = styled((props: AccordionProps) => (
@@ -91,36 +92,11 @@ export default function PatientForm({ type }: Props) {
const [section7Data, setSection7Data] = React.useState({});
const [section8Data, setSection8Data] = React.useState({});
const [allPatientData, setAllPatientData] = React.useState([]);
- const [patientDetailsButtonFlag, setPatientDetailsButtonFlag ] = React.useState(false)
+ const [patientDetailsButtonFlag, setPatientDetailsButtonFlag] =
+ React.useState(false);
- 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 handleFormSection1Data = (patient: Patient) => {
+ setSection1Data(patient);
};
const handleFormSection2Data = (
@@ -375,7 +351,7 @@ export default function PatientForm({ type }: Props) {
section1Data.mailingAddress !== ''
) {
TextFile();
- setPatientDetailsButtonFlag(true)
+ setPatientDetailsButtonFlag(true);
setAlertProps({
open: true,
severity: 'success',
@@ -659,11 +635,16 @@ export default function PatientForm({ type }: Props) {
{type !== 'display' ? (
<>
-
-
- Signature:
-
-
+
+
+ {' '}
+ Signature:
+
+
+
@@ -708,37 +689,35 @@ export default function PatientForm({ type }: Props) {
- {patientDetailsButtonFlag && type!=='display'?
-
-
- :null}
+ {patientDetailsButtonFlag && type !== 'display' ? (
+
+
+
+ ) : null}
- {type=='display'?
-
-
- :null}
+ {type == 'display' ? (
+
+
+
+ ) : null}
@@ -171,20 +136,20 @@ export default function PersonalSection({
}}
onBlur={(e) => {
if (!/^\d{10}$/.test(e.target.value)) {
- setPatient((prevValues: any) => ({
+ setErrors((prevValues: any) => ({
...prevValues,
cellPhoneError: true,
}));
} else {
- setPatient((prevValues: any) => ({
+ setErrors((prevValues: any) => ({
...prevValues,
cellPhoneError: false,
}));
}
}}
- error={patient.cellPhoneError}
+ error={errors.cellPhoneError}
helperText={
- patient.cellPhoneError
+ errors.cellPhoneError
? 'Please enter a valid 10-digit phone number'
: ''
}
@@ -238,7 +203,11 @@ export default function PersonalSection({
label='Email'
name='email'
placeholder='Please enter your email'
- value={type == 'display' ? patientDataDiplay && patientDataDiplay.email : patient.email}
+ value={
+ type == 'display'
+ ? patientDataDiplay && patientDataDiplay.email
+ : patient.email
+ }
disabled={type == 'display'}
onChange={(e) => {
setPatient((prevValues: any) => ({
@@ -248,20 +217,20 @@ export default function PersonalSection({
}}
onBlur={(e) => {
if (!/^\S+@\S+\.\S+$/.test(e.target.value)) {
- setPatient((prevValues: any) => ({
+ setErrors((prevValues: any) => ({
...prevValues,
emailError: true,
}));
} else {
- setPatient((prevValues: any) => ({
+ setErrors((prevValues: any) => ({
...prevValues,
emailError: false,
}));
}
}}
- error={patient.emailError}
+ error={errors.emailError}
helperText={
- patient.emailError ? 'Please enter a valid email address' : ''
+ errors.emailError ? 'Please enter a valid email address' : ''
}
/>
@@ -281,7 +250,11 @@ export default function PersonalSection({
name='age'
type='number'
placeholder='Please enter your age'
- value={type == 'display' ? patientDataDiplay && patientDataDiplay.age : patient.age}
+ value={
+ type == 'display'
+ ? patientDataDiplay && patientDataDiplay.age
+ : patient.age
+ }
disabled={type == 'display'}
onChange={(e) => {
setPatient((prevValues: any) => ({
@@ -291,19 +264,19 @@ export default function PersonalSection({
}}
onBlur={(e) => {
if (e.target.value === '') {
- setPatient((prevValues: any) => ({
+ setErrors((prevValues: any) => ({
...prevValues,
ageError: true,
}));
} else {
- setPatient((prevValues: any) => ({
+ setErrors((prevValues: any) => ({
...prevValues,
ageError: false,
}));
}
}}
- error={patient.ageError}
- helperText={patient.ageError ? 'Please enter your age' : ''}
+ error={errors.ageError}
+ helperText={errors.ageError ? 'Please enter your age' : ''}
/>
@@ -396,20 +369,20 @@ export default function PersonalSection({
}}
onBlur={(e) => {
if (e.target.value === '') {
- setPatient((prevValues: any) => ({
+ setErrors((prevValues: any) => ({
...prevValues,
mailingAddressError: true,
}));
} else {
- setPatient((prevValues: any) => ({
+ setErrors((prevValues: any) => ({
...prevValues,
mailingAddressError: false,
}));
}
}}
- error={patient.mailingAddressError}
+ error={errors.mailingAddressError}
helperText={
- patient.mailingAddressError
+ errors.mailingAddressError
? 'Please enter your mailing address'
: ''
}
@@ -429,7 +402,11 @@ export default function PersonalSection({
variant='outlined'
label='State'
name='state'
- value={type == 'display' ? patientDataDiplay && patientDataDiplay.state : patient.state}
+ value={
+ type == 'display'
+ ? patientDataDiplay && patientDataDiplay.state
+ : patient.state
+ }
disabled={type == 'display'}
onChange={(e) => {
setPatient((prevValues: any) => ({
@@ -453,7 +430,11 @@ export default function PersonalSection({
variant='outlined'
label='City'
name='city'
- value={type == 'display' ? patientDataDiplay && patientDataDiplay.city : patient.city}
+ value={
+ type == 'display'
+ ? patientDataDiplay && patientDataDiplay.city
+ : patient.city
+ }
disabled={type == 'display'}
onChange={(e) => {
setPatient((prevValues: any) => ({
@@ -478,7 +459,9 @@ export default function PersonalSection({
label='Zip Code'
name='zipCode'
value={
- type == 'display' ? patientDataDiplay && patientDataDiplay.zipCode : patient.zipCode
+ type == 'display'
+ ? patientDataDiplay && patientDataDiplay.zipCode
+ : patient.zipCode
}
disabled={type == 'display'}
onChange={(e) => {
@@ -507,7 +490,9 @@ export default function PersonalSection({
{