From 4b26bff5389d6de42ccb195f7e7a2c1f740c58e7 Mon Sep 17 00:00:00 2001 From: Manasvi Gaur Date: Wed, 17 Apr 2024 15:47:18 +0530 Subject: [PATCH 01/12] Fixed #7610 Toggle Emergency Contact No. From Phone Number --- src/Components/Patient/PatientRegister.tsx | 65 ++++++++++++++-------- 1 file changed, 41 insertions(+), 24 deletions(-) diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index 3be6b985dda..6b9073f492f 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -62,6 +62,7 @@ import useQuery from "../../Utils/request/useQuery.js"; import routes from "../../Redux/api.js"; import request from "../../Utils/request/request.js"; import SelectMenuV2 from "../Form/SelectMenuV2.js"; +import Checkbox from "../Common/components/CheckBox.js"; const Loading = lazy(() => import("../Common/Loading")); const PageTitle = lazy(() => import("../Common/PageTitle")); @@ -81,7 +82,7 @@ const medicalHistoryChoices = MEDICAL_HISTORY_CHOICES.reduce( ...acc, { [`medical_history_${cur.id}`]: "" }, ], - [], + [] ); const genderTypes = GENDER_TYPES; const diseaseStatus = [...DISEASE_STATUS]; @@ -146,7 +147,7 @@ const initForm: any = { const initError = Object.assign( {}, - ...Object.keys(initForm).map((k) => ({ [k]: "" })), + ...Object.keys(initForm).map((k) => ({ [k]: "" })) ); const initialState = { @@ -174,7 +175,7 @@ const patientFormReducer = (state = initialState, action: any) => { }; export const parseOccupationFromExt = (occupation: Occupation) => { const occupationObject = OCCUPATION_TYPES.find( - (item) => item.value === occupation, + (item) => item.value === occupation ); return occupationObject?.id; }; @@ -219,8 +220,10 @@ export const PatientRegister = (props: PatientRegisterProps) => { const [showLinkAbhaNumberModal, setShowLinkAbhaNumberModal] = useState(false); const [showAutoFilledPincode, setShowAutoFilledPincode] = useState(false); const [insuranceDetails, setInsuranceDetails] = useState( - [], + [] ); + const [isEmergencyNumberEnabled, setIsEmergencyNumberEnabled] = + useState(false); const [insuranceDetailsError, setInsuranceDetailsError] = useState(); @@ -471,14 +474,14 @@ export const PatientRegister = (props: PatientRegisterProps) => { const medicalHistory = MEDICAL_HISTORY_CHOICES.find( (j) => String(j.text).toLowerCase() === - String(i.disease).toLowerCase(), + String(i.disease).toLowerCase() ); if (medicalHistory) { formData.medical_history.push(Number(medicalHistory.id)); (formData as any)[`medical_history_${medicalHistory.id}`] = i.details; } - }, + } ); dispatch({ type: "set_form", @@ -495,7 +498,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { setIsLoading(false); } }, - [id], + [id] ); useQuery(routes.listHCXPolicies, { @@ -513,7 +516,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { }); const { data: stateData, loading: isStateLoading } = useQuery( - routes.statesList, + routes.statesList ); useAbortableEffect( @@ -522,7 +525,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { fetchData(status); } }, - [dispatch, fetchData], + [dispatch, fetchData] ); const { data: facilityObject } = useQuery(routes.getAnyFacility, { @@ -805,16 +808,16 @@ export const PatientRegister = (props: PatientRegisterProps) => { permanent_address: formData.sameAddress ? formData.address : formData.permanent_address - ? formData.permanent_address - : undefined, + ? formData.permanent_address + : undefined, present_health: formData.present_health ? formData.present_health : undefined, contact_with_confirmed_carrier: JSON.parse( - formData.contact_with_confirmed_carrier, + formData.contact_with_confirmed_carrier ), contact_with_suspected_carrier: JSON.parse( - formData.contact_with_suspected_carrier, + formData.contact_with_suspected_carrier ), estimated_contact_date: (JSON.parse(formData.contact_with_confirmed_carrier) || @@ -833,7 +836,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { ? Number(formData.number_of_primary_contacts) : undefined, number_of_secondary_contacts: Number( - formData.number_of_secondary_contacts, + formData.number_of_secondary_contacts ) ? Number(formData.number_of_secondary_contacts) : undefined, @@ -887,7 +890,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { }, }); } - }), + }) ); dispatch({ type: "set_form", form: initForm }); @@ -898,7 +901,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { title: "Patient Added Successfully", }); navigate( - `/facility/${facilityId}/patient/${requestData.id}/consultation`, + `/facility/${facilityId}/patient/${requestData.id}/consultation` ); } else { Notification.Success({ @@ -925,7 +928,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { pincode, }, }: any, - field: any, + field: any ) => { const values: any = {}; if (id) values["abha_number"] = id; @@ -1008,7 +1011,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { const duplicateList = !id ? data.results : data.results.filter( - (item: DupPatientModel) => item.patient_id !== id, + (item: DupPatientModel) => item.patient_id !== id ); if (duplicateList.length) { setStatusDialog({ @@ -1231,7 +1234,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { onSuccess={(data: any) => { if (id) { navigate( - `/facility/${facilityId}/patient/${id}`, + `/facility/${facilityId}/patient/${id}` ); return; } @@ -1303,6 +1306,14 @@ export const PatientRegister = (props: PatientRegisterProps) => { }} types={["mobile", "landline"]} /> + + setIsEmergencyNumberEnabled(checked) + } + />
{ label="Emergency contact number" required types={["mobile", "landline"]} + disabled={isEmergencyNumberEnabled} + value={ + isEmergencyNumberEnabled + ? field("phone_number").value + : initForm.emergency_phone_number + } />
@@ -1505,7 +1522,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { field("pincode").onChange(e); handlePincodeChange( e, - field("pincode").onChange, + field("pincode").onChange ); }} /> @@ -1807,11 +1824,11 @@ export const PatientRegister = (props: PatientRegisterProps) => { opened={ JSON.parse( field("contact_with_confirmed_carrier") - .value ?? "{}", + .value ?? "{}" ) || JSON.parse( field("contact_with_suspected_carrier") - .value ?? "{}", + .value ?? "{}" ) } > @@ -1885,7 +1902,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { { return renderMedicalHistory( i.id as number, i.text, - field, + field ); })}
From aed8edb5aa58e6bc3237724a641477b9b717830e Mon Sep 17 00:00:00 2001 From: Manasvi Gaur <120303997+manasvi-gaur@users.noreply.github.com> Date: Wed, 17 Apr 2024 16:12:36 +0530 Subject: [PATCH 02/12] lint checks --- src/Components/Patient/PatientRegister.tsx | 48 +++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index 6b9073f492f..165511e66fb 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -82,7 +82,7 @@ const medicalHistoryChoices = MEDICAL_HISTORY_CHOICES.reduce( ...acc, { [`medical_history_${cur.id}`]: "" }, ], - [] + [], ); const genderTypes = GENDER_TYPES; const diseaseStatus = [...DISEASE_STATUS]; @@ -147,7 +147,7 @@ const initForm: any = { const initError = Object.assign( {}, - ...Object.keys(initForm).map((k) => ({ [k]: "" })) + ...Object.keys(initForm).map((k) => ({ [k]: "" })), ); const initialState = { @@ -175,7 +175,7 @@ const patientFormReducer = (state = initialState, action: any) => { }; export const parseOccupationFromExt = (occupation: Occupation) => { const occupationObject = OCCUPATION_TYPES.find( - (item) => item.value === occupation + (item) => item.value === occupation, ); return occupationObject?.id; }; @@ -220,7 +220,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { const [showLinkAbhaNumberModal, setShowLinkAbhaNumberModal] = useState(false); const [showAutoFilledPincode, setShowAutoFilledPincode] = useState(false); const [insuranceDetails, setInsuranceDetails] = useState( - [] + [], ); const [isEmergencyNumberEnabled, setIsEmergencyNumberEnabled] = useState(false); @@ -474,14 +474,14 @@ export const PatientRegister = (props: PatientRegisterProps) => { const medicalHistory = MEDICAL_HISTORY_CHOICES.find( (j) => String(j.text).toLowerCase() === - String(i.disease).toLowerCase() + String(i.disease).toLowerCase(), ); if (medicalHistory) { formData.medical_history.push(Number(medicalHistory.id)); (formData as any)[`medical_history_${medicalHistory.id}`] = i.details; } - } + }, ); dispatch({ type: "set_form", @@ -498,7 +498,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { setIsLoading(false); } }, - [id] + [id], ); useQuery(routes.listHCXPolicies, { @@ -516,7 +516,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { }); const { data: stateData, loading: isStateLoading } = useQuery( - routes.statesList + routes.statesList, ); useAbortableEffect( @@ -525,7 +525,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { fetchData(status); } }, - [dispatch, fetchData] + [dispatch, fetchData], ); const { data: facilityObject } = useQuery(routes.getAnyFacility, { @@ -808,16 +808,16 @@ export const PatientRegister = (props: PatientRegisterProps) => { permanent_address: formData.sameAddress ? formData.address : formData.permanent_address - ? formData.permanent_address - : undefined, + ? formData.permanent_address + : undefined, present_health: formData.present_health ? formData.present_health : undefined, contact_with_confirmed_carrier: JSON.parse( - formData.contact_with_confirmed_carrier + formData.contact_with_confirmed_carrier, ), contact_with_suspected_carrier: JSON.parse( - formData.contact_with_suspected_carrier + formData.contact_with_suspected_carrier, ), estimated_contact_date: (JSON.parse(formData.contact_with_confirmed_carrier) || @@ -836,7 +836,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { ? Number(formData.number_of_primary_contacts) : undefined, number_of_secondary_contacts: Number( - formData.number_of_secondary_contacts + formData.number_of_secondary_contacts, ) ? Number(formData.number_of_secondary_contacts) : undefined, @@ -890,7 +890,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { }, }); } - }) + }), ); dispatch({ type: "set_form", form: initForm }); @@ -901,7 +901,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { title: "Patient Added Successfully", }); navigate( - `/facility/${facilityId}/patient/${requestData.id}/consultation` + `/facility/${facilityId}/patient/${requestData.id}/consultation`, ); } else { Notification.Success({ @@ -928,7 +928,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { pincode, }, }: any, - field: any + field: any, ) => { const values: any = {}; if (id) values["abha_number"] = id; @@ -1011,7 +1011,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { const duplicateList = !id ? data.results : data.results.filter( - (item: DupPatientModel) => item.patient_id !== id + (item: DupPatientModel) => item.patient_id !== id, ); if (duplicateList.length) { setStatusDialog({ @@ -1234,7 +1234,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { onSuccess={(data: any) => { if (id) { navigate( - `/facility/${facilityId}/patient/${id}` + `/facility/${facilityId}/patient/${id}`, ); return; } @@ -1522,7 +1522,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { field("pincode").onChange(e); handlePincodeChange( e, - field("pincode").onChange + field("pincode").onChange, ); }} /> @@ -1824,11 +1824,11 @@ export const PatientRegister = (props: PatientRegisterProps) => { opened={ JSON.parse( field("contact_with_confirmed_carrier") - .value ?? "{}" + .value ?? "{}", ) || JSON.parse( field("contact_with_suspected_carrier") - .value ?? "{}" + .value ?? "{}", ) } > @@ -1903,7 +1903,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { opened={ String( field("is_declared_positive").value - ) === "true" + ) === "true", } className="mt-4" > @@ -1996,7 +1996,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { return renderMedicalHistory( i.id as number, i.text, - field + field, ); })} From f7985f54ee5c5887b9135990398aab5f094bdf68 Mon Sep 17 00:00:00 2001 From: Manasvi Gaur <120303997+manasvi-gaur@users.noreply.github.com> Date: Wed, 17 Apr 2024 16:15:30 +0530 Subject: [PATCH 03/12] Update PatientRegister.tsx --- src/Components/Patient/PatientRegister.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index 165511e66fb..5859c60da07 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -1903,7 +1903,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { opened={ String( field("is_declared_positive").value - ) === "true", + ) === "true" } className="mt-4" > From 1fd8ba342beeb76e83852d735d508696e83b4207 Mon Sep 17 00:00:00 2001 From: Manasvi Gaur <120303997+manasvi-gaur@users.noreply.github.com> Date: Wed, 17 Apr 2024 16:18:08 +0530 Subject: [PATCH 04/12] Update PatientRegister.tsx --- src/Components/Patient/PatientRegister.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index 5859c60da07..bfd099a3eac 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -1902,7 +1902,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { Date: Thu, 18 Apr 2024 21:16:08 +0530 Subject: [PATCH 05/12] changeRequest done --- src/Components/Patient/PatientRegister.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index 6b9073f492f..1a004c3221a 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -748,7 +748,9 @@ export const PatientRegister = (props: PatientRegisterProps) => { const data = { abha_number: state.form.abha_number, phone_number: parsePhoneNumber(formData.phone_number), - emergency_phone_number: parsePhoneNumber(formData.emergency_phone_number), + emergency_phone_number: isEmergencyNumberEnabled + ? parsePhoneNumber(formData.phone_number) + : parsePhoneNumber(formData.emergency_phone_number), date_of_birth: ageInputType === "date_of_birth" ? dateQueryString(formData.date_of_birth) @@ -1328,7 +1330,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { value={ isEmergencyNumberEnabled ? field("phone_number").value - : initForm.emergency_phone_number + : field("emergency_phone_number").value } /> From d76a0326db063a88c8df6ef303af96315122ed9a Mon Sep 17 00:00:00 2001 From: Manasvi Gaur Date: Wed, 24 Apr 2024 16:23:54 +0530 Subject: [PATCH 06/12] change request done --- src/Components/Patient/PatientRegister.tsx | 83 +++++++++++++--------- 1 file changed, 48 insertions(+), 35 deletions(-) diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index 9d51264f904..cd1e3e29201 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -82,7 +82,7 @@ const medicalHistoryChoices = MEDICAL_HISTORY_CHOICES.reduce( ...acc, { [`medical_history_${cur.id}`]: "" }, ], - [], + [] ); const genderTypes = GENDER_TYPES; const diseaseStatus = [...DISEASE_STATUS]; @@ -147,7 +147,7 @@ const initForm: any = { const initError = Object.assign( {}, - ...Object.keys(initForm).map((k) => ({ [k]: "" })), + ...Object.keys(initForm).map((k) => ({ [k]: "" })) ); const initialState = { @@ -175,7 +175,7 @@ const patientFormReducer = (state = initialState, action: any) => { }; export const parseOccupationFromExt = (occupation: Occupation) => { const occupationObject = OCCUPATION_TYPES.find( - (item) => item.value === occupation, + (item) => item.value === occupation ); return occupationObject?.id; }; @@ -220,7 +220,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { const [showLinkAbhaNumberModal, setShowLinkAbhaNumberModal] = useState(false); const [showAutoFilledPincode, setShowAutoFilledPincode] = useState(false); const [insuranceDetails, setInsuranceDetails] = useState( - [], + [] ); const [isEmergencyNumberEnabled, setIsEmergencyNumberEnabled] = useState(false); @@ -469,19 +469,22 @@ export const PatientRegister = (props: PatientRegisterProps) => { : null, }; formData.sameAddress = data.address === data.permanent_address; + setIsEmergencyNumberEnabled( + data.phone_number === data.emergency_phone_number + ); (data.medical_history ? data.medical_history : []).forEach( (i: any) => { const medicalHistory = MEDICAL_HISTORY_CHOICES.find( (j) => String(j.text).toLowerCase() === - String(i.disease).toLowerCase(), + String(i.disease).toLowerCase() ); if (medicalHistory) { formData.medical_history.push(Number(medicalHistory.id)); (formData as any)[`medical_history_${medicalHistory.id}`] = i.details; } - }, + } ); dispatch({ type: "set_form", @@ -498,7 +501,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { setIsLoading(false); } }, - [id], + [id] ); useQuery(routes.listHCXPolicies, { @@ -516,7 +519,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { }); const { data: stateData, loading: isStateLoading } = useQuery( - routes.statesList, + routes.statesList ); useAbortableEffect( @@ -525,7 +528,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { fetchData(status); } }, - [dispatch, fetchData], + [dispatch, fetchData] ); const { data: facilityObject } = useQuery(routes.getAnyFacility, { @@ -748,9 +751,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { const data = { abha_number: state.form.abha_number, phone_number: parsePhoneNumber(formData.phone_number), - emergency_phone_number: isEmergencyNumberEnabled - ? parsePhoneNumber(formData.phone_number) - : parsePhoneNumber(formData.emergency_phone_number), + emergency_phone_number: parsePhoneNumber(formData.emergency_phone_number), date_of_birth: ageInputType === "date_of_birth" ? dateQueryString(formData.date_of_birth) @@ -810,16 +811,16 @@ export const PatientRegister = (props: PatientRegisterProps) => { permanent_address: formData.sameAddress ? formData.address : formData.permanent_address - ? formData.permanent_address - : undefined, + ? formData.permanent_address + : undefined, present_health: formData.present_health ? formData.present_health : undefined, contact_with_confirmed_carrier: JSON.parse( - formData.contact_with_confirmed_carrier, + formData.contact_with_confirmed_carrier ), contact_with_suspected_carrier: JSON.parse( - formData.contact_with_suspected_carrier, + formData.contact_with_suspected_carrier ), estimated_contact_date: (JSON.parse(formData.contact_with_confirmed_carrier) || @@ -838,7 +839,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { ? Number(formData.number_of_primary_contacts) : undefined, number_of_secondary_contacts: Number( - formData.number_of_secondary_contacts, + formData.number_of_secondary_contacts ) ? Number(formData.number_of_secondary_contacts) : undefined, @@ -892,7 +893,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { }, }); } - }), + }) ); dispatch({ type: "set_form", form: initForm }); @@ -903,7 +904,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { title: "Patient Added Successfully", }); navigate( - `/facility/${facilityId}/patient/${requestData.id}/consultation`, + `/facility/${facilityId}/patient/${requestData.id}/consultation` ); } else { Notification.Success({ @@ -930,7 +931,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { pincode, }, }: any, - field: any, + field: any ) => { const values: any = {}; if (id) values["abha_number"] = id; @@ -1013,7 +1014,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { const duplicateList = !id ? data.results : data.results.filter( - (item: DupPatientModel) => item.patient_id !== id, + (item: DupPatientModel) => item.patient_id !== id ); if (duplicateList.length) { setStatusDialog({ @@ -1236,7 +1237,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { onSuccess={(data: any) => { if (id) { navigate( - `/facility/${facilityId}/patient/${id}`, + `/facility/${facilityId}/patient/${id}` ); return; } @@ -1305,6 +1306,12 @@ export const PatientRegister = (props: PatientRegisterProps) => { onChange={(event) => { if (!id) duplicateCheck(event.value); field("phone_number").onChange(event); + if (isEmergencyNumberEnabled) { + field("emergency_phone_number").onChange({ + name: field("emergency_phone_number").name, + value: event.value, + }); + } }} types={["mobile", "landline"]} /> @@ -1312,9 +1319,20 @@ export const PatientRegister = (props: PatientRegisterProps) => { label="Is the phone number an emergency number?" className="font-bold" checked={isEmergencyNumberEnabled} - onCheck={(checked) => - setIsEmergencyNumberEnabled(checked) - } + onCheck={(checked) => { + setIsEmergencyNumberEnabled(checked); + checked + ? field("emergency_phone_number").onChange({ + name: field("emergency_phone_number") + .name, + value: field("phone_number").value, + }) + : field("emergency_phone_number").onChange({ + name: field("emergency_phone_number") + .name, + value: initForm.emergency_phone_number, + }); + }} />
{ required types={["mobile", "landline"]} disabled={isEmergencyNumberEnabled} - value={ - isEmergencyNumberEnabled - ? field("phone_number").value - : field("emergency_phone_number").value - } />
@@ -1524,7 +1537,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { field("pincode").onChange(e); handlePincodeChange( e, - field("pincode").onChange, + field("pincode").onChange ); }} /> @@ -1826,11 +1839,11 @@ export const PatientRegister = (props: PatientRegisterProps) => { opened={ JSON.parse( field("contact_with_confirmed_carrier") - .value ?? "{}", + .value ?? "{}" ) || JSON.parse( field("contact_with_suspected_carrier") - .value ?? "{}", + .value ?? "{}" ) } > @@ -1904,7 +1917,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { { return renderMedicalHistory( i.id as number, i.text, - field, + field ); })}
From bf34a9f56f2e51744770535536b0bb788af3b54f Mon Sep 17 00:00:00 2001 From: Manasvi Gaur Date: Thu, 25 Apr 2024 18:27:48 +0530 Subject: [PATCH 07/12] cyp_update --- .../patient_spec/patient_registration.cy.ts | 31 +++++------ cypress/pageobject/Patient/PatientCreation.ts | 9 +++- src/Components/Patient/PatientRegister.tsx | 51 ++++++++++--------- 3 files changed, 49 insertions(+), 42 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_registration.cy.ts b/cypress/e2e/patient_spec/patient_registration.cy.ts index 28b92340654..d0f8b2fcda3 100644 --- a/cypress/e2e/patient_spec/patient_registration.cy.ts +++ b/cypress/e2e/patient_spec/patient_registration.cy.ts @@ -79,6 +79,7 @@ describe("Patient Creation with consultation", () => { patientPage.patientformvisibility(); // Patient Details page patientPage.typePatientPhoneNumber(phone_number); + patientPage.clickEmergencyPhoneNumberCheckbox(); patientPage.typePatientEmergencyNumber(emergency_phone_number); patientPage.typePatientAge(age.toString()); patientPage.typePatientName(patientOneName); @@ -93,7 +94,7 @@ describe("Patient Creation with consultation", () => { // Patient Medical History patientMedicalHistory.typePatientPresentHealth(patientOnePresentHealth); patientMedicalHistory.typePatientOngoingMedication( - patientOneOngoingMedication + patientOneOngoingMedication, ); patientMedicalHistory.typeMedicalHistory(2, "Diabetes"); patientMedicalHistory.typeMedicalHistory(3, "Heart Disease"); @@ -118,7 +119,7 @@ describe("Patient Creation with consultation", () => { emergency_phone_number, yearOfBirth, patientOneBloodGroup, - patientOccupation + patientOccupation, ); patientMedicalHistory.verifyPatientMedicalDetails( patientOnePresentHealth, @@ -130,7 +131,7 @@ describe("Patient Creation with consultation", () => { "Kidney Diseases", "Lung Diseases/Asthma", "Cancer", - "Other" + "Other", ); // verify its presence in the patient detail page cy.visit("/patients"); @@ -155,43 +156,43 @@ describe("Patient Creation with consultation", () => { patientInsurance.typePatientInsuranceDetail( patientOneFirstInsuranceId, "subscriber_id", - patientOneFirstSubscriberId + patientOneFirstSubscriberId, ); patientInsurance.typePatientInsuranceDetail( patientOneFirstInsuranceId, "policy_id", - patientOneFirstPolicyId + patientOneFirstPolicyId, ); patientInsurance.typePatientInsuranceDetail( patientOneFirstInsuranceId, "insurer_id", - patientOneFirstInsurerId + patientOneFirstInsurerId, ); patientInsurance.typePatientInsuranceDetail( patientOneFirstInsuranceId, "insurer_name", - patientOneFirstInsurerName + patientOneFirstInsurerName, ); patientInsurance.clickAddInsruanceDetails(); patientInsurance.typePatientInsuranceDetail( patientOneSecondInsuranceId, "subscriber_id", - patientOneSecondSubscriberId + patientOneSecondSubscriberId, ); patientInsurance.typePatientInsuranceDetail( patientOneSecondInsuranceId, "policy_id", - patientOneSecondPolicyId + patientOneSecondPolicyId, ); patientInsurance.typePatientInsuranceDetail( patientOneSecondInsuranceId, "insurer_id", - patientOneSecondInsurerId + patientOneSecondInsurerId, ); patientInsurance.typePatientInsuranceDetail( patientOneSecondInsuranceId, "insurer_name", - patientOneSecondInsurerName + patientOneSecondInsurerName, ); patientPage.clickUpdatePatient(); cy.wait(3000); @@ -207,7 +208,7 @@ describe("Patient Creation with consultation", () => { emergency_phone_number, yearOfBirth, patientOneUpdatedBloodGroup, - patientOccupation + patientOccupation, ); // Verify No medical history patientMedicalHistory.verifyNoSymptosPresent("Diabetes"); @@ -220,7 +221,7 @@ describe("Patient Creation with consultation", () => { patientOneFirstSubscriberId, patientOneFirstPolicyId, patientOneFirstInsurerId, - patientOneFirstInsurerName + patientOneFirstInsurerName, ); patientInsurance.clickPatientInsuranceViewDetail(); cy.wait(3000); @@ -228,13 +229,13 @@ describe("Patient Creation with consultation", () => { patientOneFirstSubscriberId, patientOneFirstPolicyId, patientOneFirstInsurerId, - patientOneFirstInsurerName + patientOneFirstInsurerName, ); patientInsurance.verifyPatientPolicyDetails( patientOneSecondSubscriberId, patientOneSecondPolicyId, patientOneSecondInsurerId, - patientOneSecondInsurerName + patientOneSecondInsurerName, ); }); diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index 01bdfdb8cbb..d4f52a33e21 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -41,7 +41,12 @@ export class PatientPage { cy.get("#phone_number-div").click().type(phoneNumber); } + clickEmergencyPhoneNumberCheckbox() { + cy.get("#emergency_contact_checkbox").check(); + } + typePatientEmergencyNumber(phoneNumber: string) { + cy.get("#emergency_contact_checkbox").should("not.be.checked"); cy.get("#emergency_phone_number-div").click().type(phoneNumber); } @@ -145,7 +150,7 @@ export class PatientPage { emergencyPhoneNumber, yearOfBirth, bloodGroup, - occupation + occupation, ) { cy.url().should("include", "/facility/"); cy.get("[data-testid=patient-dashboard]").then(($dashboard) => { @@ -166,7 +171,7 @@ export class PatientPage { patientState, patientDistrict, patientLocalbody, - patientWard + patientWard, ) { cy.get("[data-testid=patient-details]").then(($dashboard) => { cy.url().should("include", "/facility/"); diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index b9a47768034..41f1aec7c89 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -83,7 +83,7 @@ const medicalHistoryChoices = MEDICAL_HISTORY_CHOICES.reduce( ...acc, { [`medical_history_${cur.id}`]: "" }, ], - [] + [], ); const genderTypes = GENDER_TYPES; const diseaseStatus = [...DISEASE_STATUS]; @@ -148,7 +148,7 @@ const initForm: any = { const initError = Object.assign( {}, - ...Object.keys(initForm).map((k) => ({ [k]: "" })) + ...Object.keys(initForm).map((k) => ({ [k]: "" })), ); const initialState = { @@ -176,7 +176,7 @@ const patientFormReducer = (state = initialState, action: any) => { }; export const parseOccupationFromExt = (occupation: Occupation) => { const occupationObject = OCCUPATION_TYPES.find( - (item) => item.value === occupation + (item) => item.value === occupation, ); return occupationObject?.id; }; @@ -221,7 +221,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { const [showLinkAbhaNumberModal, setShowLinkAbhaNumberModal] = useState(false); const [showAutoFilledPincode, setShowAutoFilledPincode] = useState(false); const [insuranceDetails, setInsuranceDetails] = useState( - [] + [], ); const [isEmergencyNumberEnabled, setIsEmergencyNumberEnabled] = useState(false); @@ -471,21 +471,21 @@ export const PatientRegister = (props: PatientRegisterProps) => { }; formData.sameAddress = data.address === data.permanent_address; setIsEmergencyNumberEnabled( - data.phone_number === data.emergency_phone_number + data.phone_number === data.emergency_phone_number, ); (data.medical_history ? data.medical_history : []).forEach( (i: any) => { const medicalHistory = MEDICAL_HISTORY_CHOICES.find( (j) => String(j.text).toLowerCase() === - String(i.disease).toLowerCase() + String(i.disease).toLowerCase(), ); if (medicalHistory) { formData.medical_history.push(Number(medicalHistory.id)); (formData as any)[`medical_history_${medicalHistory.id}`] = i.details; } - } + }, ); dispatch({ type: "set_form", @@ -502,7 +502,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { setIsLoading(false); } }, - [id] + [id], ); useQuery(routes.listHCXPolicies, { @@ -520,7 +520,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { }); const { data: stateData, loading: isStateLoading } = useQuery( - routes.statesList + routes.statesList, ); useAbortableEffect( @@ -529,7 +529,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { fetchData(status); } }, - [dispatch, fetchData] + [dispatch, fetchData], ); const { data: facilityObject } = useQuery(routes.getAnyFacility, { @@ -812,16 +812,16 @@ export const PatientRegister = (props: PatientRegisterProps) => { permanent_address: formData.sameAddress ? formData.address : formData.permanent_address - ? formData.permanent_address - : undefined, + ? formData.permanent_address + : undefined, present_health: formData.present_health ? formData.present_health : undefined, contact_with_confirmed_carrier: JSON.parse( - formData.contact_with_confirmed_carrier + formData.contact_with_confirmed_carrier, ), contact_with_suspected_carrier: JSON.parse( - formData.contact_with_suspected_carrier + formData.contact_with_suspected_carrier, ), estimated_contact_date: (JSON.parse(formData.contact_with_confirmed_carrier) || @@ -840,7 +840,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { ? Number(formData.number_of_primary_contacts) : undefined, number_of_secondary_contacts: Number( - formData.number_of_secondary_contacts + formData.number_of_secondary_contacts, ) ? Number(formData.number_of_secondary_contacts) : undefined, @@ -894,7 +894,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { }, }); } - }) + }), ); dispatch({ type: "set_form", form: initForm }); @@ -905,7 +905,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { title: "Patient Added Successfully", }); navigate( - `/facility/${facilityId}/patient/${requestData.id}/consultation` + `/facility/${facilityId}/patient/${requestData.id}/consultation`, ); } else { Notification.Success({ @@ -932,7 +932,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { pincode, }, }: any, - field: any + field: any, ) => { const values: any = {}; if (id) values["abha_number"] = id; @@ -1015,7 +1015,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { const duplicateList = !id ? data.results : data.results.filter( - (item: DupPatientModel) => item.patient_id !== id + (item: DupPatientModel) => item.patient_id !== id, ); if (duplicateList.length) { setStatusDialog({ @@ -1238,7 +1238,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { onSuccess={(data: any) => { if (id) { navigate( - `/facility/${facilityId}/patient/${id}` + `/facility/${facilityId}/patient/${id}`, ); return; } @@ -1319,6 +1319,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { { setIsEmergencyNumberEnabled(checked); @@ -1538,7 +1539,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { field("pincode").onChange(e); handlePincodeChange( e, - field("pincode").onChange + field("pincode").onChange, ); }} /> @@ -1840,11 +1841,11 @@ export const PatientRegister = (props: PatientRegisterProps) => { opened={ JSON.parse( field("contact_with_confirmed_carrier") - .value ?? "{}" + .value ?? "{}", ) || JSON.parse( field("contact_with_suspected_carrier") - .value ?? "{}" + .value ?? "{}", ) } > @@ -1918,7 +1919,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { { return renderMedicalHistory( i.id as number, i.text, - field + field, ); })} From 269e811a019f8491ed1647a9bc1d99637617107b Mon Sep 17 00:00:00 2001 From: Manasvi Gaur Date: Thu, 25 Apr 2024 18:52:04 +0530 Subject: [PATCH 08/12] cyp_update done --- cypress/pageobject/Patient/PatientCreation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index d4f52a33e21..26eecb378e0 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -38,7 +38,7 @@ export class PatientPage { } typePatientPhoneNumber(phoneNumber: string) { - cy.get("#phone_number-div").click().type(phoneNumber); + cy.get("#phone_number").click().type(phoneNumber); } clickEmergencyPhoneNumberCheckbox() { From 5a7e426e1f6fdc5361d987f5b848185d85a24d1c Mon Sep 17 00:00:00 2001 From: Manasvi Gaur Date: Thu, 25 Apr 2024 19:05:16 +0530 Subject: [PATCH 09/12] done --- cypress/pageobject/Patient/PatientCreation.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index 26eecb378e0..1d84f4566be 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -41,12 +41,7 @@ export class PatientPage { cy.get("#phone_number").click().type(phoneNumber); } - clickEmergencyPhoneNumberCheckbox() { - cy.get("#emergency_contact_checkbox").check(); - } - typePatientEmergencyNumber(phoneNumber: string) { - cy.get("#emergency_contact_checkbox").should("not.be.checked"); cy.get("#emergency_phone_number-div").click().type(phoneNumber); } From 6164c6e2ab7c972dbe00bf53e83a2bcf53d6f21c Mon Sep 17 00:00:00 2001 From: Manasvi Gaur Date: Thu, 25 Apr 2024 19:05:45 +0530 Subject: [PATCH 10/12] done --- cypress/e2e/patient_spec/patient_registration.cy.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/cypress/e2e/patient_spec/patient_registration.cy.ts b/cypress/e2e/patient_spec/patient_registration.cy.ts index d0f8b2fcda3..21001684bea 100644 --- a/cypress/e2e/patient_spec/patient_registration.cy.ts +++ b/cypress/e2e/patient_spec/patient_registration.cy.ts @@ -79,7 +79,6 @@ describe("Patient Creation with consultation", () => { patientPage.patientformvisibility(); // Patient Details page patientPage.typePatientPhoneNumber(phone_number); - patientPage.clickEmergencyPhoneNumberCheckbox(); patientPage.typePatientEmergencyNumber(emergency_phone_number); patientPage.typePatientAge(age.toString()); patientPage.typePatientName(patientOneName); From e906e8fd36940b4377ced40f4c980483d409291c Mon Sep 17 00:00:00 2001 From: Manasvi Gaur Date: Thu, 25 Apr 2024 19:17:46 +0530 Subject: [PATCH 11/12] cyp_done --- cypress/pageobject/Patient/PatientCreation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index 1d84f4566be..d4d2998704f 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -42,7 +42,7 @@ export class PatientPage { } typePatientEmergencyNumber(phoneNumber: string) { - cy.get("#emergency_phone_number-div").click().type(phoneNumber); + cy.get("#emergency_phone_number").click().type(phoneNumber); } typePatientDateOfBirth(dateOfBirth: string) { From 8314974e445c26564bebdfec85728ad11f777401 Mon Sep 17 00:00:00 2001 From: khavinshankar Date: Tue, 7 May 2024 14:04:59 +0530 Subject: [PATCH 12/12] add test to check phone number is emergency number --- cypress/e2e/patient_spec/patient_registration.cy.ts | 12 ++++-------- cypress/pageobject/Patient/PatientCreation.ts | 4 ++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_registration.cy.ts b/cypress/e2e/patient_spec/patient_registration.cy.ts index 21001684bea..634b6d5c81f 100644 --- a/cypress/e2e/patient_spec/patient_registration.cy.ts +++ b/cypress/e2e/patient_spec/patient_registration.cy.ts @@ -2,10 +2,7 @@ import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress"; import LoginPage from "../../pageobject/Login/LoginPage"; import { PatientPage } from "../../pageobject/Patient/PatientCreation"; import FacilityPage from "../../pageobject/Facility/FacilityCreation"; -import { - generatePhoneNumber, - generateEmergencyPhoneNumber, -} from "../../pageobject/utils/constants"; +import { generatePhoneNumber } from "../../pageobject/utils/constants"; import PatientTransfer from "../../pageobject/Patient/PatientTransfer"; import PatientExternal from "../../pageobject/Patient/PatientExternal"; import PatientInsurance from "../../pageobject/Patient/PatientInsurance"; @@ -27,7 +24,6 @@ describe("Patient Creation with consultation", () => { const patientInsurance = new PatientInsurance(); const patientMedicalHistory = new PatientMedicalHistory(); const phone_number = generatePhoneNumber(); - const emergency_phone_number = generateEmergencyPhoneNumber(); const age = calculateAge(); const patientFacility = "Dummy Facility 40"; const patientDateOfBirth = "01012001"; @@ -79,7 +75,7 @@ describe("Patient Creation with consultation", () => { patientPage.patientformvisibility(); // Patient Details page patientPage.typePatientPhoneNumber(phone_number); - patientPage.typePatientEmergencyNumber(emergency_phone_number); + patientPage.checkPhoneNumberIsEmergencyNumber(); patientPage.typePatientAge(age.toString()); patientPage.typePatientName(patientOneName); patientPage.selectPatientGender(patientOneGender); @@ -115,7 +111,7 @@ describe("Patient Creation with consultation", () => { age, patientOneName, phone_number, - emergency_phone_number, + phone_number, yearOfBirth, patientOneBloodGroup, patientOccupation, @@ -204,7 +200,7 @@ describe("Patient Creation with consultation", () => { age, patientOneName, phone_number, - emergency_phone_number, + phone_number, yearOfBirth, patientOneUpdatedBloodGroup, patientOccupation, diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index d4d2998704f..078302f1ee2 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -45,6 +45,10 @@ export class PatientPage { cy.get("#emergency_phone_number").click().type(phoneNumber); } + checkPhoneNumberIsEmergencyNumber() { + cy.get("#emergency_contact_checkbox > div > input").click(); + } + typePatientDateOfBirth(dateOfBirth: string) { cy.clickAndSelectOption("#patientAge", "DOB"); cy.get("#date_of_birth").scrollIntoView();