From b6df9a1af1c3320854a14155c352ad8781b83d03 Mon Sep 17 00:00:00 2001 From: Shivank Kacker Date: Wed, 11 Dec 2024 23:03:41 +0530 Subject: [PATCH 1/4] Scribe Enhancements support PR (#9265) --- public/locale/en.json | 1 + src/style/CAREUI.css | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/public/locale/en.json b/public/locale/en.json index 9f0bc5ecf12..a37d6b4b115 100644 --- a/public/locale/en.json +++ b/public/locale/en.json @@ -1418,6 +1418,7 @@ "total_patients": "Total Patients", "total_staff": "Total Staff", "total_users": "Total Users", + "transcribe_again": "Transcribe Again", "transcript_edit_info": "You can update this if we made an error", "transcript_information": "This is what we heard", "transfer_allowed": "Transfer Allowed", diff --git a/src/style/CAREUI.css b/src/style/CAREUI.css index 2acc88a2b05..e65c2c5554e 100644 --- a/src/style/CAREUI.css +++ b/src/style/CAREUI.css @@ -177,4 +177,9 @@ button.button-alert-ghost { @apply enabled:hover:bg-alert-100 } } hr { @apply border border-secondary-300 +} +.plain-audio::-webkit-media-controls-enclosure { + border-radius: 0; + background: transparent; + padding: 0px; } \ No newline at end of file From 27b7228aa9554add6bf683e977d4c04455712746 Mon Sep 17 00:00:00 2001 From: Pooranjoy Bhattacharya Date: Wed, 11 Dec 2024 23:12:23 +0530 Subject: [PATCH 2/4] Bug-Fix: Patient's Age parsing discrepancy during XLS export in Sample Management System (#9247) --- src/components/Patient/SampleViewAdmin.tsx | 41 +++++++++++++--------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/components/Patient/SampleViewAdmin.tsx b/src/components/Patient/SampleViewAdmin.tsx index dcb98d9f28c..ff269c90358 100644 --- a/src/components/Patient/SampleViewAdmin.tsx +++ b/src/components/Patient/SampleViewAdmin.tsx @@ -117,22 +117,31 @@ export default function SampleViewAdmin() { }); }; - const parseExportData = (data: string) => - data - .trim() - .split("\n") - .map((row: string) => - row - .trim() - .split(",") - .map((field: string) => - new Date(field).toString() === "Invalid Date" - ? field - : formatDateTime(field), - ) - .join(","), - ) - .join("\n"); + const parseExportData = (data: string) => { + const [header, ...rows] = data.trim().split("\n"); + const headerColumns = header.split(",").map((col) => col.trim()); + + return [ + header, + ...rows.map((row) => { + const columns = row.split(",").map((field, index) => { + const header = headerColumns[index]; + + if (header === "Patient Age") { + return field.trim(); + } + + if (["Date of Sample", "Date of Result"].includes(header)) { + const formattedDate = formatDateTime(field.trim()); + return formattedDate === "Invalid Date" ? "" : formattedDate; + } + return field.includes(",") ? `"${field.trim()}"` : field.trim(); + }); + + return columns.join(","); + }), + ].join("\n"); + }; let sampleList: any[] = []; if (sampeleData?.count) { From 981a281103aec9d32c827ba1bfb4f1c441f4ae2b Mon Sep 17 00:00:00 2001 From: Jacob John Jeevan <40040905+Jacobjeevan@users.noreply.github.com> Date: Wed, 11 Dec 2024 23:13:36 +0530 Subject: [PATCH 3/4] Facility bed capacity verification test (#9145) --- .../e2e/facility_spec/FacilityCreation.cy.ts | 156 ++++++++++++------ .../e2e/facility_spec/FacilityHomepage.cy.ts | 59 +++++++ .../PatientConsultationCreation.cy.ts | 8 +- .../patient_spec/PatientRegistration.cy.ts | 75 +++++---- .../pageobject/Facility/FacilityCreation.ts | 148 ++++++++++++++++- cypress/pageobject/Facility/FacilityHome.ts | 20 ++- .../pageobject/Facility/FacilityLocation.ts | 2 +- cypress/pageobject/Facility/FacilityManage.ts | 8 + cypress/pageobject/Patient/PatientCreation.ts | 105 ++++++++++++ cypress/pageobject/Patient/PatientHome.ts | 4 + .../Patient/PatientTreatmentPlan.ts | 2 +- src/components/Facility/FacilityCard.tsx | 2 +- src/components/Patient/PatientHome.tsx | 6 +- 13 files changed, 489 insertions(+), 106 deletions(-) diff --git a/cypress/e2e/facility_spec/FacilityCreation.cy.ts b/cypress/e2e/facility_spec/FacilityCreation.cy.ts index 78ce17d8b9e..f644c9829d3 100644 --- a/cypress/e2e/facility_spec/FacilityCreation.cy.ts +++ b/cypress/e2e/facility_spec/FacilityCreation.cy.ts @@ -1,6 +1,8 @@ import { advanceFilters } from "pageobject/utils/advanceFilterHelpers"; -import FacilityPage from "../../pageobject/Facility/FacilityCreation"; +import FacilityPage, { + FacilityData, +} from "../../pageobject/Facility/FacilityCreation"; import FacilityHome from "../../pageobject/Facility/FacilityHome"; import LoginPage from "../../pageobject/Login/LoginPage"; import ManageUserPage from "../../pageobject/Users/ManageUserPage"; @@ -59,6 +61,61 @@ describe("Facility Creation", () => { ]; const triageErrorMessage = ["This field is required"]; const facilityType = "Primary Health Centres"; + const testFacilityData: FacilityData = { + basic: { + name: facilityName, + type: facilityType, + features: facilityFeature, + address: facilityAddress, + phoneNumber: facilityNumber, + location: "Kochi, Kerala", + }, + location: { + pincode: "682001", + state: "Kerala", + district: "Ernakulam", + localBody: "Aluva", + ward: "4", + }, + oxygen: { + capacity: oxygenCapacity, + expected: oxygenExpected, + bType: { + capacity: oxygenCapacity, + expected: oxygenExpected, + }, + cType: { + capacity: oxygenCapacity, + expected: oxygenExpected, + }, + dType: { + capacity: oxygenCapacity, + expected: oxygenExpected, + }, + }, + beds: [ + { + type: "Oxygen Supported Bed", + totalCapacity: bedCapacity, + occupied: bedOccupancy, + }, + { + type: "Ordinary Bed", + totalCapacity: bedCapacity, + occupied: bedOccupancy, + }, + ], + doctors: [ + { + specialization: "General Medicine", + count: doctorCapacity, + }, + { + specialization: "Pulmonology", + count: doctorCapacity, + }, + ], + }; before(() => { loginPage.loginByRole("districtAdmin"); @@ -122,32 +179,12 @@ describe("Facility Creation", () => { facilityPage.visitCreateFacilityPage(); facilityPage.submitForm(); cy.verifyErrorMessages(facilityErrorMessage); - facilityPage.fillFacilityName(facilityName); - facilityPage.selectFacilityType(facilityType); - facilityPage.clickfacilityfeatureoption(); - facilityFeature.forEach((featureText) => { - cy.get("[role='option']").contains(featureText).click(); - }); - facilityPage.clickfacilityfeatureoption(); - facilityPage.fillPincode("682001"); - facilityPage.selectStateOnPincode("Kerala"); - facilityPage.selectDistrictOnPincode("Ernakulam"); - facilityPage.selectLocalBody("Aluva"); - facilityPage.selectWard("4"); - facilityPage.fillAddress(facilityAddress); - facilityPage.fillPhoneNumber(facilityNumber); - facilityPage.fillOxygenCapacity(oxygenCapacity); - facilityPage.fillExpectedOxygenRequirement(oxygenExpected); - facilityPage.fillBTypeCylinderCapacity(oxygenCapacity); - facilityPage.fillExpectedBTypeCylinderRequirement(oxygenExpected); - facilityPage.fillCTypeCylinderCapacity(oxygenCapacity); - facilityPage.fillExpectedCTypeCylinderRequirement(oxygenExpected); - facilityPage.fillDTypeCylinderCapacity(oxygenCapacity); - facilityPage.fillExpectedDTypeCylinderRequirement(oxygenExpected); - facilityPage.selectLocation("Kochi, Kerala"); + facilityPage.fillBasicDetails(testFacilityData.basic); + facilityPage.fillLocationDetails(testFacilityData.location); + facilityPage.fillOxygenDetails(testFacilityData.oxygen); facilityPage.submitForm(); cy.closeNotification(); - // create multiple bed capacity and verify card reflection + // add the bed capacity facilityPage.selectBedType("Oxygen Supported Bed"); facilityPage.fillTotalCapacity(bedCapacity); facilityPage.fillCurrentlyOccupied(bedOccupancy); @@ -210,27 +247,32 @@ describe("Facility Creation", () => { }); it("Create a new facility with single bed and doctor capacity", () => { - facilityPage.visitCreateFacilityPage(); - facilityPage.fillFacilityName(facilityName); - facilityPage.selectFacilityType(facilityType); - facilityPage.fillPincode("682001"); - facilityPage.selectStateOnPincode("Kerala"); - facilityPage.selectDistrictOnPincode("Ernakulam"); - facilityPage.selectLocalBody("Aluva"); - facilityPage.selectWard("4"); - facilityPage.fillAddress(facilityAddress); - facilityPage.fillPhoneNumber(facilityNumber); - facilityPage.submitForm(); - // add the bed capacity - facilityPage.selectBedType("Oxygen Supported Bed"); - facilityPage.fillTotalCapacity(oxygenCapacity); - facilityPage.fillCurrentlyOccupied(oxygenExpected); - facilityPage.saveAndExitBedCapacityForm(); - // add the doctor capacity - facilityPage.selectAreaOfSpecialization("General Medicine"); - facilityPage.fillDoctorCount(doctorCapacity); - facilityPage.saveAndExitDoctorForm(); - facilityPage.verifyfacilitynewurl(); + const singleCapacityData = { + ...testFacilityData, + // Remove features, location, and oxygen that aren't used in this test + basic: { + ...testFacilityData.basic, + features: undefined, + location: undefined, + }, + oxygen: undefined, + // Override with single bed capacity + beds: [ + { + type: "Oxygen Supported Bed", + totalCapacity: oxygenCapacity, + occupied: oxygenExpected, + }, + ], + // Override with single doctor capacity + doctors: [ + { + specialization: "General Medicine", + count: doctorCapacity, + }, + ], + }; + facilityPage.createNewFacility(singleCapacityData); // verify the created facility details facilityPage.getFacilityName().contains(facilityName).should("be.visible"); facilityPage @@ -254,16 +296,20 @@ describe("Facility Creation", () => { }); it("Create a new facility with no bed and doctor capacity", () => { + const noCapacityData = { + ...testFacilityData, + basic: { + ...testFacilityData.basic, + features: undefined, + location: undefined, + }, + oxygen: undefined, + beds: [], + doctors: [], + }; facilityPage.visitCreateFacilityPage(); - facilityPage.fillFacilityName(facilityName); - facilityPage.selectFacilityType(facilityType); - facilityPage.fillPincode("682001"); - facilityPage.selectStateOnPincode("Kerala"); - facilityPage.selectDistrictOnPincode("Ernakulam"); - facilityPage.selectLocalBody("Aluva"); - facilityPage.selectWard("4"); - facilityPage.fillAddress(facilityAddress); - facilityPage.fillPhoneNumber(facilityNumber); + facilityPage.fillBasicDetails(noCapacityData.basic); + facilityPage.fillLocationDetails(noCapacityData.location); facilityPage.submitForm(); // add no bed capacity and verify form error message facilityPage.isVisibleselectBedType(); diff --git a/cypress/e2e/facility_spec/FacilityHomepage.cy.ts b/cypress/e2e/facility_spec/FacilityHomepage.cy.ts index 6f01baac714..680ce6fa2ce 100644 --- a/cypress/e2e/facility_spec/FacilityHomepage.cy.ts +++ b/cypress/e2e/facility_spec/FacilityHomepage.cy.ts @@ -1,4 +1,7 @@ // FacilityCreation +import FacilityLocation from "pageobject/Facility/FacilityLocation"; +import { PatientPage } from "pageobject/Patient/PatientCreation"; +import PatientPredefined from "pageobject/Patient/PatientPredefined"; import { pageNavigation } from "pageobject/utils/paginationHelpers"; import FacilityPage from "../../pageobject/Facility/FacilityCreation"; @@ -14,6 +17,9 @@ describe("Facility Homepage Function", () => { const facilityNotify = new FacilityNotify(); const facilityPage = new FacilityPage(); const manageUserPage = new ManageUserPage(); + const patientPredefined = new PatientPredefined(); + const patientPage = new PatientPage(); + const facilityLocation = new FacilityLocation(); const facilitiesAlias = "downloadFacilitiesCSV"; const doctorsAlias = "downloadDoctorsCSV"; const triagesAlias = "downloadTriagesCSV"; @@ -25,6 +31,9 @@ describe("Facility Homepage Function", () => { const facilityType = "Private Hospital"; const notificationErrorMsg = "Message cannot be empty"; const notificationMessage = "Test Notification"; + const facilityWithNoAvailableBeds = "Dummy Facility 12"; + const locationName = "Test-location"; + const locationType = "WARD"; before(() => { loginPage.loginByRole("districtAdmin"); @@ -32,6 +41,7 @@ describe("Facility Homepage Function", () => { }); beforeEach(() => { + cy.viewport(1280, 720); cy.restoreLocalStorage(); cy.clearLocalStorage(/filters--.+/); cy.awaitUrl("/facility"); @@ -199,6 +209,55 @@ describe("Facility Homepage Function", () => { facilityNotify.closeNotificationSlide(); loginPage.ensureLoggedIn(); loginPage.clickSignOutBtn(); + loginPage.loginManuallyAsDistrictAdmin(); + loginPage.ensureLoggedIn(); + }); + + it("Verify the bed capacity badge reflection", () => { + facilityHome.typeFacilitySearch(facilityWithNoAvailableBeds); + facilityHome.assertFacilityInCard(facilityWithNoAvailableBeds); + cy.url().then((url) => { + const facilityUrl = url.toString(); + facilityHome.verifyOccupancyBadgeVisibility(); + facilityHome.assertFacilityBadgeContent("0", "0"); + + // create a new patient in the facility + cy.visit("/patients"); + patientPage.createPatient(); + patientPage.selectFacility(facilityWithNoAvailableBeds); + patientPredefined.createPatient(); + patientPage.patientformvisibility(); + patientPage.clickCreatePatient(); + patientPage.verifyPatientIsCreated(); + // navigate to facility page and verify the occupancy badge + cy.visit(facilityUrl); + facilityHome.verifyOccupancyBadgeVisibility(); + facilityHome.assertFacilityBadgeContent("1", "0"); + facilityHome.assertFacilityBadgeBackgroundColor("rgb(239, 68, 68)"); + // create a new location and add a bed to the facility + facilityLocation.navigateToFacilityLocationManagement( + facilityWithNoAvailableBeds, + ); + // create new location and add a bed to the facility + facilityLocation.clickAddNewLocationButton(); + facilityLocation.fillLocationDetails( + locationName, + undefined, + locationType, + undefined, + ); + facilityLocation.clickAddLocationButton(); + facilityLocation.verifyAddLocationSuccessfulMesssage(); + facilityLocation.clickManageBedButton(locationName); + facilityLocation.clickAddBedButton(); + facilityLocation.fillBedForm("Bed 1", "Test Description", "Regular", 2); + facilityLocation.clickSubmitBedsButton(); + + // verify the occupancy badge reflection + cy.visit(facilityUrl); + facilityHome.verifyOccupancyBadgeVisibility(); + facilityHome.assertFacilityBadgeContent("1", "2"); + }); }); afterEach(() => { diff --git a/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts b/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts index 4191d63b3e2..a257d127942 100644 --- a/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts +++ b/cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts @@ -90,7 +90,7 @@ describe("Patient Consultation in multiple combination", () => { patientTreatmentPlan.typeTreatmentPlan(patientTreatment); patientTreatmentPlan.typePatientGeneralInstruction(generalInstruction); patientTreatmentPlan.typeSpecialInstruction(specialInstruction); - patientTreatmentPlan.fillTreatingPhysican(doctorName); + patientTreatmentPlan.fillTreatingPhysician(doctorName); cy.clickSubmitButton("Create Consultation"); // the above submit should fail as IP number is missing patientConsultationPage.typePatientNumber(patientIpNumber); @@ -254,7 +254,7 @@ describe("Patient Consultation in multiple combination", () => { patientInvestigation.selectInvestigationFrequency("6"); // Add advice and treating physican patientTreatmentPlan.typePatientGeneralInstruction(generalInstruction); - patientTreatmentPlan.fillTreatingPhysican(doctorName); + patientTreatmentPlan.fillTreatingPhysician(doctorName); // add review after and add action patientTreatmentPlan.selectReviewAfter("15 mins"); patientTreatmentPlan.selectAction("Specialist Required"); @@ -311,7 +311,7 @@ describe("Patient Consultation in multiple combination", () => { // no investigation patientTreatmentPlan.typePatientGeneralInstruction(generalInstruction); // no review after and no action - patientTreatmentPlan.fillTreatingPhysican(doctorName); + patientTreatmentPlan.fillTreatingPhysician(doctorName); cy.clickSubmitButton("Create Consultation"); cy.verifyNotification("Patient discharged successfully"); // verify the Discharge Reason, Diagnosis, treatment physican @@ -362,7 +362,7 @@ describe("Patient Consultation in multiple combination", () => { patientConsultationPage.selectPatientPrincipalDiagnosis(diagnosis4); // no investigation for the patient patientTreatmentPlan.typePatientGeneralInstruction(generalInstruction); - patientTreatmentPlan.fillTreatingPhysican(doctorName); + patientTreatmentPlan.fillTreatingPhysician(doctorName); // no review after and no action cy.clickSubmitButton("Create Consultation"); // Create a shifting request diff --git a/cypress/e2e/patient_spec/PatientRegistration.cy.ts b/cypress/e2e/patient_spec/PatientRegistration.cy.ts index a7c869401cd..b11d0f8f585 100644 --- a/cypress/e2e/patient_spec/PatientRegistration.cy.ts +++ b/cypress/e2e/patient_spec/PatientRegistration.cy.ts @@ -1,6 +1,8 @@ -import FacilityPage from "../../pageobject/Facility/FacilityCreation"; import LoginPage from "../../pageobject/Login/LoginPage"; -import { PatientPage } from "../../pageobject/Patient/PatientCreation"; +import { + PatientData, + PatientPage, +} from "../../pageobject/Patient/PatientCreation"; import PatientInsurance from "../../pageobject/Patient/PatientInsurance"; import PatientMedicalHistory from "../../pageobject/Patient/PatientMedicalHistory"; import PatientTransfer from "../../pageobject/Patient/PatientTransfer"; @@ -30,7 +32,6 @@ const getRelativeDateString = (deltaDays = 0) => { describe("Patient Creation with consultation", () => { const loginPage = new LoginPage(); const patientPage = new PatientPage(); - const facilityPage = new FacilityPage(); const patientTransfer = new PatientTransfer(); const patientInsurance = new PatientInsurance(); const patientMedicalHistory = new PatientMedicalHistory(); @@ -68,6 +69,38 @@ describe("Patient Creation with consultation", () => { const patientTransferFacility = "Dummy Shifting Center"; const patientTransferName = "Dummy Patient Twelve"; const patientOccupation = "Student"; + const newPatientData: PatientData = { + facility: patientFacility, + phoneNumber: phone_number, + isEmergencyNumber: true, + age: age.toString(), + name: patientOneName, + gender: patientOneGender, + address: patientOneAddress, + pincode: patientOnePincode, + state: patientOneState, + district: patientOneDistrict, + localBody: patientOneLocalbody, + ward: patientOneWard, + occupation: patientOccupation, + socioeconomicStatus: "MIDDLE_CLASS", + domesticHealthcareSupport: "FAMILY_MEMBER", + medicalHistory: { + presentHealth: patientOnePresentHealth, + ongoingMedication: patientOneOngoingMedication, + conditions: [ + { index: 2, condition: "Diabetes" }, + { index: 3, condition: "Heart Disease" }, + { index: 4, condition: "HyperTension" }, + { index: 5, condition: "Kidney Diseases" }, + { index: 6, condition: "Lung Diseases/Asthma" }, + { index: 7, condition: "Cancer" }, + { index: 8, condition: "Other" }, + ], + allergies: patientOneAllergies, + }, + bloodGroup: patientOneBloodGroup, + }; before(() => { loginPage.loginByRole("districtAdmin"); @@ -81,41 +114,7 @@ describe("Patient Creation with consultation", () => { }); it("Create a new patient with all field in registration form and no consultation", () => { - // patient details with all the available fields except covid - patientPage.createPatient(); - patientPage.selectFacility(patientFacility); - patientPage.patientformvisibility(); - // Patient Details page - patientPage.typePatientPhoneNumber(phone_number); - patientPage.checkPhoneNumberIsEmergencyNumber(); - patientPage.typePatientAge(age.toString()); - patientPage.typePatientName(patientOneName); - patientPage.selectPatientGender(patientOneGender); - patientPage.typePatientAddress(patientOneAddress); - facilityPage.fillPincode(patientOnePincode); - facilityPage.selectStateOnPincode(patientOneState); - facilityPage.selectDistrictOnPincode(patientOneDistrict); - facilityPage.selectLocalBody(patientOneLocalbody); - facilityPage.selectWard(patientOneWard); - patientPage.selectPatientOccupation(patientOccupation); - patientPage.selectSocioeconomicStatus("MIDDLE_CLASS"); - patientPage.selectDomesticHealthcareSupport("FAMILY_MEMBER"); - // Patient Medical History - patientMedicalHistory.typePatientPresentHealth(patientOnePresentHealth); - patientMedicalHistory.typePatientOngoingMedication( - patientOneOngoingMedication, - ); - patientMedicalHistory.typeMedicalHistory(2, "Diabetes"); - patientMedicalHistory.typeMedicalHistory(3, "Heart Disease"); - patientMedicalHistory.typeMedicalHistory(4, "HyperTension"); - patientMedicalHistory.typeMedicalHistory(5, "Kidney Diseases"); - patientMedicalHistory.typeMedicalHistory(6, "Lung Diseases/Asthma"); - patientMedicalHistory.typeMedicalHistory(7, "Cancer"); - patientMedicalHistory.typeMedicalHistory(8, "Other"); - patientMedicalHistory.typePatientAllergies(patientOneAllergies); - patientPage.selectPatientBloodGroup(patientOneBloodGroup); - patientPage.clickCreatePatient(); - patientPage.verifyPatientIsCreated(); + patientPage.createPatientWithData(newPatientData); // Verify the patient details patientPage.clickCancelButton(); cy.wait(3000); diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index 4c064956fcc..e59dfef09f3 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -1,5 +1,48 @@ import { advanceFilters } from "pageobject/utils/advanceFilterHelpers"; +export interface FacilityData { + basic: { + name: string; + type: string; + features?: string[]; + address: string; + phoneNumber: string; + location?: string; + }; + location: { + pincode: string; + state: string; + district: string; + localBody: string; + ward: string; + }; + oxygen?: { + capacity: string; + expected: string; + bType?: { + capacity: string; + expected: string; + }; + cType?: { + capacity: string; + expected: string; + }; + dType?: { + capacity: string; + expected: string; + }; + }; + beds?: Array<{ + type: string; + totalCapacity: string; + occupied: string; + }>; + doctors?: Array<{ + specialization: string; + count: string; + }>; +} + class FacilityPage { visitCreateFacilityPage() { cy.intercept("GET", "**/facility/create").as("getCreateFacilities"); @@ -405,9 +448,8 @@ class FacilityPage { } selectDistrictOnPincode(districtName: string) { - this.getDistrictElement() - .scrollIntoView() - .wait(2000) + this.getDistrictElement().as("district").scrollIntoView().wait(2000); + cy.get("@district") .should("be.visible") .then(($element) => { const text = $element.text(); @@ -457,6 +499,106 @@ class FacilityPage { clickSetMinimumQuantity() { cy.get("#set-minimum-quantity").click(); } + + createNewFacility(data: FacilityData) { + this.visitCreateFacilityPage(); + + // Fill basic details + this.fillBasicDetails(data.basic); + + // Fill location details + this.fillLocationDetails(data.location); + + // Fill oxygen details if provided + if (data.oxygen) { + this.fillOxygenDetails(data.oxygen); + } + + this.submitForm(); + cy.closeNotification(); + + // Add bed capacity if provided + if (data.beds) { + this.addBedCapacities(data.beds); + } + + // Add doctor capacity if provided + if (data.doctors) { + this.addDoctorCapacities(data.doctors); + } + + this.verifyfacilitynewurl(); + return this; + } + + fillBasicDetails(basic: FacilityData["basic"]) { + this.fillFacilityName(basic.name); + this.selectFacilityType(basic.type); + + if (basic.features?.length) { + this.clickfacilityfeatureoption(); + basic.features.forEach((feature) => { + cy.get("[role='option']").contains(feature).click(); + }); + this.clickfacilityfeatureoption(); + } + + this.fillAddress(basic.address); + this.fillPhoneNumber(basic.phoneNumber); + + if (basic.location) { + this.selectLocation(basic.location); + } + } + + fillLocationDetails(location: FacilityData["location"]) { + this.fillPincode(location.pincode); + this.selectStateOnPincode(location.state); + this.selectDistrictOnPincode(location.district); + this.selectLocalBody(location.localBody); + this.selectWard(location.ward); + } + + fillOxygenDetails(oxygen: NonNullable) { + this.fillOxygenCapacity(oxygen.capacity); + this.fillExpectedOxygenRequirement(oxygen.expected); + + if (oxygen.bType) { + this.fillBTypeCylinderCapacity(oxygen.bType.capacity); + this.fillExpectedBTypeCylinderRequirement(oxygen.bType.expected); + } + + if (oxygen.cType) { + this.fillCTypeCylinderCapacity(oxygen.cType.capacity); + this.fillExpectedCTypeCylinderRequirement(oxygen.cType.expected); + } + + if (oxygen.dType) { + this.fillDTypeCylinderCapacity(oxygen.dType.capacity); + this.fillExpectedDTypeCylinderRequirement(oxygen.dType.expected); + } + } + + addBedCapacities(beds: NonNullable) { + beds.forEach((bed) => { + this.selectBedType(bed.type); + this.fillTotalCapacity(bed.totalCapacity); + this.fillCurrentlyOccupied(bed.occupied); + this.clickbedcapcityaddmore(); + cy.closeNotification(); + }); + this.clickcancelbutton(); + } + + addDoctorCapacities(doctors: NonNullable) { + doctors.forEach((doctor) => { + this.selectAreaOfSpecialization(doctor.specialization); + this.fillDoctorCount(doctor.count); + this.clickdoctorcapacityaddmore(); + cy.closeNotification(); + }); + this.clickcancelbutton(); + } } export default FacilityPage; diff --git a/cypress/pageobject/Facility/FacilityHome.ts b/cypress/pageobject/Facility/FacilityHome.ts index fe8585b48be..bbf5945453e 100644 --- a/cypress/pageobject/Facility/FacilityHome.ts +++ b/cypress/pageobject/Facility/FacilityHome.ts @@ -50,8 +50,9 @@ class FacilityHome { } clickFacilityNotifyButton() { - cy.get("#facility-notify", { timeout: 10000 }).should("be.visible"); - cy.get("#facility-notify").focus().click(); + cy.get("#facility-notify").as("facilityNotify"); + cy.get("@facilityNotify", { timeout: 10000 }).should("be.visible"); + cy.get("@facilityNotify").first().click(); } clickLiveMonitorButton() { @@ -114,6 +115,21 @@ class FacilityHome { const encodedText = encodeURIComponent(searchText).replace(/%20/g, "+"); this.getURL().should("include", `search=${encodedText}`); } + + assertFacilityBadgeContent(occupied: string, total: string) { + cy.get('[data-test-id="occupancy-badge-text"]').should( + "contain.text", + `Occupancy: ${occupied} / ${total}`, + ); + } + + assertFacilityBadgeBackgroundColor(color: string) { + cy.get('[data-test-id="occupancy-badge"]').should( + "have.css", + "background-color", + color, + ); + } } export default FacilityHome; diff --git a/cypress/pageobject/Facility/FacilityLocation.ts b/cypress/pageobject/Facility/FacilityLocation.ts index 9cb23f9fba0..2932dfb8dcd 100644 --- a/cypress/pageobject/Facility/FacilityLocation.ts +++ b/cypress/pageobject/Facility/FacilityLocation.ts @@ -50,7 +50,7 @@ class FacilityLocation { } clickAddNewLocationButton() { - cy.get("#add-new-location").click(); + cy.get("#add-new-location").click({ force: true }); } typeLocationName(locationName: string) { diff --git a/cypress/pageobject/Facility/FacilityManage.ts b/cypress/pageobject/Facility/FacilityManage.ts index 9a32a5be36f..e7eecddab3c 100644 --- a/cypress/pageobject/Facility/FacilityManage.ts +++ b/cypress/pageobject/Facility/FacilityManage.ts @@ -99,5 +99,13 @@ class FacilityManage { cy.get("#facility-add-bedtype").scrollIntoView(); cy.get("#facility-add-bedtype").click(); } + + visitViewPatients() { + cy.intercept("GET", "**/api/v1/facility/**").as("getFacilityPatients"); + cy.get("#view-patient-facility-list").scrollIntoView().click(); + cy.wait("@getFacilityPatients") + .its("response.statusCode") + .should("eq", 200); + } } export default FacilityManage; diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index febf31b33b5..635aac3c4d2 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -1,6 +1,36 @@ // PatientPage.ts +import FacilityPage from "pageobject/Facility/FacilityCreation"; + +import PatientMedicalHistory from "./PatientMedicalHistory"; let patient_url = ""; +const facilityPage = new FacilityPage(); +const patientMedicalHistory = new PatientMedicalHistory(); + +export interface PatientData { + facility: string; + phoneNumber: string; + isEmergencyNumber?: boolean; + age: string | number; + name: string; + gender: string; + address: string; + pincode: string; + state: string; + district: string; + localBody: string; + ward: string; + occupation?: string; + socioeconomicStatus?: string; + domesticHealthcareSupport?: string; + medicalHistory?: { + presentHealth?: string; + ongoingMedication?: string; + conditions?: { index: number; condition: string }[]; + allergies?: string; + }; + bloodGroup?: string; +} export class PatientPage { createPatient() { @@ -22,6 +52,16 @@ export class PatientPage { .contains(patientName); } + visitPatientWithNoConsultation(patientName: string) { + cy.get("#name").click().type(patientName); + cy.intercept("GET", "**/api/v1/patient/**").as("getPatient"); + cy.get("#patient-name-list").contains(patientName).click(); + cy.wait("@getPatient").its("response.statusCode").should("eq", 200); + cy.get("#patient-name").should("be.visible").contains(patientName); + cy.get("#create-consultation").should("be.visible"); + this.clickCreateConsultationOnPatientPageWithNoConsultation(); + } + selectFacility(facilityName: string) { cy.typeAndSelectOption("input[name='facilities']", facilityName); cy.clickSubmitButton("Select"); @@ -154,6 +194,10 @@ export class PatientPage { cy.wait("@updatePatient").its("response.statusCode").should("eq", 200); } + clickCreateConsultationOnPatientPageWithNoConsultation() { + cy.get("#create-consultation").should("be.visible").click(); + } + verifyPatientUpdated() { cy.url().should("include", "/patient"); } @@ -237,4 +281,65 @@ export class PatientPage { patientformvisibility() { cy.get("[data-testid='current-address']").scrollIntoView(); } + + createPatientWithData(data: PatientData) { + this.createPatient(); + this.selectFacility(data.facility); + this.patientformvisibility(); + + this.typePatientPhoneNumber(data.phoneNumber); + if (data.isEmergencyNumber) { + this.checkPhoneNumberIsEmergencyNumber(); + } + this.typePatientAge(data.age.toString()); + this.typePatientName(data.name); + this.selectPatientGender(data.gender); + this.typePatientAddress(data.address); + + facilityPage.fillPincode(data.pincode); + facilityPage.selectStateOnPincode(data.state); + facilityPage.selectDistrictOnPincode(data.district); + facilityPage.selectLocalBody(data.localBody); + facilityPage.selectWard(data.ward); + + if (data.occupation) { + this.selectPatientOccupation(data.occupation); + } + if (data.socioeconomicStatus) { + this.selectSocioeconomicStatus(data.socioeconomicStatus); + } + if (data.domesticHealthcareSupport) { + this.selectDomesticHealthcareSupport(data.domesticHealthcareSupport); + } + + if (data.medicalHistory) { + if (data.medicalHistory.presentHealth) { + patientMedicalHistory.typePatientPresentHealth( + data.medicalHistory.presentHealth, + ); + } + if (data.medicalHistory.ongoingMedication) { + patientMedicalHistory.typePatientOngoingMedication( + data.medicalHistory.ongoingMedication, + ); + } + if (data.medicalHistory.conditions) { + data.medicalHistory.conditions.forEach(({ index, condition }) => { + patientMedicalHistory.typeMedicalHistory(index, condition); + }); + } + if (data.medicalHistory.allergies) { + patientMedicalHistory.typePatientAllergies( + data.medicalHistory.allergies, + ); + } + } + + if (data.bloodGroup) { + this.selectPatientBloodGroup(data.bloodGroup); + } + + this.clickCreatePatient(); + this.verifyPatientIsCreated(); + } } diff --git a/cypress/pageobject/Patient/PatientHome.ts b/cypress/pageobject/Patient/PatientHome.ts index 36cad15f0e5..a2147f70378 100644 --- a/cypress/pageobject/Patient/PatientHome.ts +++ b/cypress/pageobject/Patient/PatientHome.ts @@ -18,6 +18,10 @@ class PatientHome { cy.wait("@getPatients").its("response.statusCode").should("eq", 200); } + typePatientName(patientName: string) { + cy.typeAndSelectOption("input[name='name']", patientName); + } + typePatientCreatedBeforeDate(startDate: string) { cy.clickAndTypeDate("input[name='created_date_start']", startDate); } diff --git a/cypress/pageobject/Patient/PatientTreatmentPlan.ts b/cypress/pageobject/Patient/PatientTreatmentPlan.ts index 02b2f9b150d..7b4e08c8071 100644 --- a/cypress/pageobject/Patient/PatientTreatmentPlan.ts +++ b/cypress/pageobject/Patient/PatientTreatmentPlan.ts @@ -3,7 +3,7 @@ class PatientTreatmentPlan { cy.get("#consultation_notes").type(instruction); } - fillTreatingPhysican(doctor: string) { + fillTreatingPhysician(doctor: string) { cy.typeAndSelectOption("#treating_physician", doctor); } diff --git a/src/components/Facility/FacilityCard.tsx b/src/components/Facility/FacilityCard.tsx index 0d9c5678d4c..fbebe8a8d0a 100644 --- a/src/components/Facility/FacilityCard.tsx +++ b/src/components/Facility/FacilityCard.tsx @@ -106,7 +106,7 @@ export const FacilityCard = (props: { {t("live_patients_total_beds")} {" "} -
+
{t("occupancy")}: {facility.patient_count} /{" "} {facility.bed_count}{" "}
diff --git a/src/components/Patient/PatientHome.tsx b/src/components/Patient/PatientHome.tsx index a63f3202f98..8feea3c6d35 100644 --- a/src/components/Patient/PatientHome.tsx +++ b/src/components/Patient/PatientHome.tsx @@ -225,7 +225,10 @@ export const PatientHome = (props: { />
-

+

{patientData.name}

@@ -243,6 +246,7 @@ export const PatientHome = (props: { patientData?.last_consultation?.discharge_date) && (
From 05d89f4e301aaa1a96889053d36823268150844c Mon Sep 17 00:00:00 2001 From: Raj kumar <150310085+rajku-dev@users.noreply.github.com> Date: Wed, 11 Dec 2024 23:14:35 +0530 Subject: [PATCH 4/4] Changes on Assigning/Reassigning/Unassigning Volunteer to Patient (#9330) --- public/locale/en.json | 7 +++++-- src/components/Patient/PatientHome.tsx | 25 +++++++++++++++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/public/locale/en.json b/public/locale/en.json index a37d6b4b115..4fb925ac941 100644 --- a/public/locale/en.json +++ b/public/locale/en.json @@ -354,6 +354,7 @@ "asset_type": "Asset Type", "assets": "Assets", "assign": "Assign", + "unassign":"Unassign", "assign_a_volunteer_to": "Assign a volunteer to {{name}}", "assign_bed": "Assign Bed", "assign_to_volunteer": "Assign to a Volunteer", @@ -1483,6 +1484,7 @@ "update_record_for_asset": "Update record for asset", "update_shift_request": "Update Shift Request", "update_status_details": "Update Status/Details", + "update_volunteer": "Reassign Volunteer", "updated": "Updated", "updated_on": "Updated On", "updating": "Updating", @@ -1553,9 +1555,10 @@ "vitals_monitor": "Vitals Monitor", "vitals_present": "Vitals Monitor present", "voice_autofill": "Voice Autofill", - "volunteer_assigned": "Volunteer assigned successfuly", + "volunteer_assigned": "Volunteer assigned successfully", "volunteer_contact": "Volunteer Contact", - "volunteer_unassigned": "Volunteer unassigned successfuly", + "volunteer_update" : "Volunteer updated successfully", + "volunteer_unassigned": "Volunteer unassigned successfully", "ward": "Ward", "warranty_amc_expiry": "Warranty / AMC Expiry", "weekly_working_hours_error": "Average weekly working hours must be a number between 0 and 168", diff --git a/src/components/Patient/PatientHome.tsx b/src/components/Patient/PatientHome.tsx index 8feea3c6d35..b69ae75751e 100644 --- a/src/components/Patient/PatientHome.tsx +++ b/src/components/Patient/PatientHome.tsx @@ -91,6 +91,8 @@ export const PatientHome = (props: { }); const handleAssignedVolunteer = async () => { + const previousVolunteerId = patientData?.assigned_to; + const { res, data } = await request(routes.patchPatient, { pathParams: { id: patientData.id as string, @@ -99,20 +101,29 @@ export const PatientHome = (props: { assigned_to: (assignedVolunteer as UserBareMinimum)?.id || null, }, }); + if (res?.ok && data) { setPatientData(data); - if (!assignedVolunteer) { + + if (!previousVolunteerId && assignedVolunteer) { Notification.Success({ msg: t("volunteer_assigned"), }); - } else { + } else if (previousVolunteerId && assignedVolunteer) { + Notification.Success({ + msg: t("volunteer_update"), + }); + } else if (!assignedVolunteer) { Notification.Success({ msg: t("volunteer_unassigned"), }); } + refetch(); } + setOpenAssignVolunteerDialog(false); + if (errors["assignedVolunteer"]) delete errors["assignedVolunteer"]; }; @@ -530,7 +541,9 @@ export const PatientHome = (props: { > {" "} - {t("assign_to_volunteer")} + {patientData.assigned_to + ? t("update_volunteer") + : t("assign_to_volunteer")}
@@ -713,7 +726,11 @@ export const PatientHome = (props: { />

} - action={t("assign")} + action={ + assignedVolunteer || !patientData.assigned_to + ? t("assign") + : t("unassign") + } onConfirm={handleAssignedVolunteer} />