From 83dc92fd31cf5f50f775d6e6e4c40e9b567368b9 Mon Sep 17 00:00:00 2001 From: Yuvraj Singh <98007961+SinghYuvraj0506@users.noreply.github.com> Date: Thu, 7 Mar 2024 07:07:12 +0530 Subject: [PATCH] Fix: Improving Facility type options (#7314) * changed facility type in constants and default value in initialState in createFacility * Update facility creation and form initialization * Add required validation for facility type field * Fix typo in facility types * Fix cypress tests * Fix cypress tests --------- Co-authored-by: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Co-authored-by: Ashesh3 <3626859+Ashesh3@users.noreply.github.com> --- .../e2e/facility_spec/facility_creation.cy.ts | 16 +++++++- .../patient_spec/patient_consultation.cy.ts | 2 +- src/Common/constants.tsx | 37 ++++++++++--------- .../PrescriptionDropdown.tsx | 1 - src/Components/Facility/ConsultationForm.tsx | 5 ++- src/Components/Facility/FacilityCreate.tsx | 5 ++- 6 files changed, 41 insertions(+), 25 deletions(-) diff --git a/cypress/e2e/facility_spec/facility_creation.cy.ts b/cypress/e2e/facility_spec/facility_creation.cy.ts index f318f422893..679929d347b 100644 --- a/cypress/e2e/facility_spec/facility_creation.cy.ts +++ b/cypress/e2e/facility_spec/facility_creation.cy.ts @@ -1,5 +1,13 @@ // FacilityCreation -import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress"; +import { + cy, + describe, + before, + beforeEach, + it, + afterEach, + expect, +} from "local-cypress"; import FacilityPage from "../../pageobject/Facility/FacilityCreation"; import LoginPage from "../../pageobject/Login/LoginPage"; import FacilityHome from "../../pageobject/Facility/FacilityHome"; @@ -38,6 +46,7 @@ describe("Facility Creation", () => { const initialTriageValue = "60"; const modifiedTriageValue = "50"; const facilityErrorMessage = [ + "Required", "Required", "Invalid Pincode", "Required", @@ -115,6 +124,7 @@ describe("Facility Creation", () => { facilityPage.submitForm(); userCreationPage.verifyErrorMessages(facilityErrorMessage); facilityPage.fillFacilityName(facilityName); + facilityPage.clickUpdateFacilityType("Primary Health Centres"); facilityPage.clickfacilityfeatureoption(); facilityFeature.forEach((featureText) => { cy.get("[role='option']").contains(featureText).click(); @@ -202,6 +212,7 @@ describe("Facility Creation", () => { it("Create a new facility with single bed and doctor capacity", () => { facilityPage.visitCreateFacilityPage(); facilityPage.fillFacilityName(facilityName); + facilityPage.clickUpdateFacilityType("Primary Health Centres"); facilityPage.fillPincode("682001"); facilityPage.selectStateOnPincode("Kerala"); facilityPage.selectDistrictOnPincode("Ernakulam"); @@ -241,6 +252,7 @@ describe("Facility Creation", () => { it("Create a new facility with no bed and doctor capacity", () => { facilityPage.visitCreateFacilityPage(); facilityPage.fillFacilityName(facilityName); + facilityPage.clickUpdateFacilityType("Primary Health Centres"); facilityPage.fillPincode("682001"); facilityPage.selectStateOnPincode("Kerala"); facilityPage.selectDistrictOnPincode("Ernakulam"); @@ -279,7 +291,7 @@ describe("Facility Creation", () => { facilityPage.visitUpdateFacilityPage(facilityUrl1); facilityPage.clickManageFacilityDropdown(); facilityPage.clickUpdateFacilityOption(); - facilityPage.clickUpdateFacilityType("Govt Hospital"); + facilityPage.clickUpdateFacilityType("Primary Health Centres"); facilityPage.fillAddress(facilityUpdateAddress); facilityPage.fillOxygenCapacity(oxygenCapacity); facilityPage.fillExpectedOxygenRequirement(oxygenExpected); diff --git a/cypress/e2e/patient_spec/patient_consultation.cy.ts b/cypress/e2e/patient_spec/patient_consultation.cy.ts index f4e3b1f91de..99565a24cc4 100644 --- a/cypress/e2e/patient_spec/patient_consultation.cy.ts +++ b/cypress/e2e/patient_spec/patient_consultation.cy.ts @@ -36,7 +36,7 @@ describe("Patient Consultation in multiple combination", () => { const patientWeight = "70"; const patientHeight = "170"; const medicineOne = "DOLO"; - const patientIpNumber = "192.168"; + const patientIpNumber = Math.random().toString(36).substring(7); before(() => { loginPage.loginAsDisctrictAdmin(); diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index 19c00a6fb01..e452ed5abb2 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -106,38 +106,41 @@ export const VEHICLE_TYPES: Array = [ export const FACILITY_TYPES: Array = [ // { id: 1, text: "Educational Inst" }, - { id: 2, text: "Private Hospital" }, - { id: 3, text: "Other" }, // { id: 4, text: "Hostel" }, // { id: 5, text: "Hotel" }, // { id: 6, text: "Lodge" }, - { id: 7, text: "TeleMedicine" }, - { id: 8, text: "Govt Hospital" }, - { id: 9, text: "Labs" }, { id: 800, text: "Primary Health Centres" }, - { id: 801, text: "24x7 Public Health Centres" }, { id: 802, text: "Family Health Centres" }, { id: 803, text: "Community Health Centres" }, - { id: 820, text: "Urban Primary Health Center" }, - { id: 830, text: "Taluk Hospitals" }, - { id: 831, text: "Taluk Headquarters Hospitals" }, { id: 840, text: "Women and Child Health Centres" }, - { id: 850, text: "General hospitals" }, + { id: 830, text: "Taluk Hospitals" }, { id: 860, text: "District Hospitals" }, { id: 870, text: "Govt Medical College Hospitals" }, - - { id: 900, text: "Co-operative hospitals" }, + { id: 9, text: "Govt Labs" }, + { id: 10, text: "Private Labs" }, + { id: 7, text: "TeleMedicine" }, + { id: 2, text: "Private Hospital" }, { id: 910, text: "Autonomous healthcare facility" }, + { id: 1300, text: "Shifting Centre" }, + { id: 1500, text: "Request Approving Center" }, + { id: 1510, text: "Request Fulfilment Center" }, + { id: 3, text: "Other" }, + + // { id: 8, text: "Govt Hospital" }, + // { id: 801, text: "24x7 Public Health Centres" }, + // { id: 820, text: "Urban Primary Health Center" }, + // { id: 831, text: "Taluk Headquarters Hospitals" }, + // { id: 850, text: "General hospitals" }, + + // { id: 900, text: "Co-operative hospitals" }, + + // { id: 950, text: "Corona Testing Labs" }, + // { id: 1000, text: "Corona Care Centre" }, - { id: 950, text: "Corona Testing Labs" }, - { id: 1000, text: "Corona Care Centre" }, // { id: 1010, text: "COVID-19 Domiciliary Care Center" }, // { id: 1100, text: "First Line Treatment Centre" }, // { id: 1200, text: "Second Line Treatment Center" }, - { id: 1300, text: "Shifting Centre" }, // { id: 1400, text: "Covid Management Center" }, - { id: 1500, text: "Request Approving Center" }, - { id: 1510, text: "Request Fulfilment Center" }, // { id: 1600, text: "District War Room" }, ]; diff --git a/src/Components/Common/prescription-builder/PrescriptionDropdown.tsx b/src/Components/Common/prescription-builder/PrescriptionDropdown.tsx index 5730e4bcdfe..b147fbfc636 100644 --- a/src/Components/Common/prescription-builder/PrescriptionDropdown.tsx +++ b/src/Components/Common/prescription-builder/PrescriptionDropdown.tsx @@ -14,7 +14,6 @@ export function PrescriptionDropdown(props: { onFocus?: () => void; onBlur?: () => void; }) { - props.tips = []; const { options, tips, value, setValue } = props; const [open, setOpen] = useState(false); diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index 66dbb711afa..a063ce91a8d 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -694,7 +694,7 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { const validated = validateForm(); if (validated) { setIsLoading(true); - const data = { + const data: any = { symptoms: state.form.symptoms, other_symptoms: isOtherSymptomsSelected ? state.form.other_symptoms @@ -713,7 +713,6 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { history_of_present_illness: state.form.history_of_present_illness, treatment_plan: state.form.treatment_plan, discharge_date: state.form.discharge_date, - patient_no: state.form.patient_no, create_diagnoses: isUpdate ? undefined : state.form.create_diagnoses, treating_physician: state.form.treating_physician, investigation: state.form.InvestigationAdvice, @@ -764,6 +763,8 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { bed: bed && bed instanceof Array ? bed[0]?.id : bed?.id, }; + if (state.form.patient_no) data["patient_no"] = state.form.patient_no; + const res = await dispatchAction( id ? updateConsultation(id!, data) : createConsultation(data) ); diff --git a/src/Components/Facility/FacilityCreate.tsx b/src/Components/Facility/FacilityCreate.tsx index 69f02aa91ee..f52df5e95ee 100644 --- a/src/Components/Facility/FacilityCreate.tsx +++ b/src/Components/Facility/FacilityCreate.tsx @@ -65,7 +65,7 @@ interface FacilityProps { } type FacilityForm = { - facility_type: string; + facility_type?: string; name: string; state: number; district: number; @@ -89,7 +89,7 @@ type FacilityForm = { }; const initForm: FacilityForm = { - facility_type: "Private Hospital", + facility_type: undefined, name: "", state: 0, district: 0, @@ -366,6 +366,7 @@ export const FacilityCreate = (props: FacilityProps) => { let invalidForm = false; Object.keys(state.form).forEach((field) => { switch (field) { + case "facility_type": case "name": case "address": if (!state.form[field]) {