From b1470271e66b0af5e7fc6e1ac991b021cb51cec7 Mon Sep 17 00:00:00 2001 From: Bodhish Thomas Date: Sun, 15 Dec 2024 22:33:18 +0530 Subject: [PATCH 1/6] Cleanup capacity related fields from facility (#9436) Co-authored-by: rithviknishad Co-authored-by: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> --- .../e2e/facility_spec/FacilityCreation.cy.ts | 374 ++------- .../e2e/facility_spec/FacilityHomepage.cy.ts | 18 - .../e2e/facility_spec/FacilityManage.cy.ts | 64 -- .../e2e/patient_spec/PatientHomepage.cy.ts | 4 - .../e2e/resource_spec/ResourcesHomepage.cy.ts | 8 +- .../pageobject/Facility/FacilityCreation.ts | 269 +----- cypress/pageobject/Facility/FacilityHome.ts | 7 +- cypress/pageobject/Facility/FacilityManage.ts | 34 - cypress/pageobject/Resource/ResourcePage.ts | 4 + cypress/pageobject/utils/constants.ts | 116 ++- cypress/support/commands.ts | 18 + cypress/support/index.ts | 5 + package-lock.json | 8 +- package.json | 2 +- src/Routers/routes/FacilityRoutes.tsx | 7 - src/Utils/request/api.tsx | 109 +-- src/components/ExternalResult/models.ts | 18 - src/components/Facility/BedCapacity.tsx | 301 ------- src/components/Facility/BedTypeCard.tsx | 181 ---- .../Facility/FacilityBedCapacity.tsx | 126 --- src/components/Facility/FacilityCreate.tsx | 776 +++++------------- src/components/Facility/FacilityHome.tsx | 47 +- .../Facility/FacilityHomeTriage.tsx | 89 -- src/components/Facility/FacilityList.tsx | 35 +- src/components/Facility/FacilityStaffList.tsx | 138 ---- src/components/Facility/StaffCapacity.tsx | 241 ------ src/components/Facility/StaffCountCard.tsx | 118 --- src/components/Facility/TriageForm.tsx | 321 -------- src/components/Facility/models.tsx | 33 - src/components/Patient/PatientRegister.tsx | 4 +- 30 files changed, 459 insertions(+), 3016 deletions(-) delete mode 100644 src/components/ExternalResult/models.ts delete mode 100644 src/components/Facility/BedCapacity.tsx delete mode 100644 src/components/Facility/BedTypeCard.tsx delete mode 100644 src/components/Facility/FacilityBedCapacity.tsx delete mode 100644 src/components/Facility/FacilityHomeTriage.tsx delete mode 100644 src/components/Facility/FacilityStaffList.tsx delete mode 100644 src/components/Facility/StaffCapacity.tsx delete mode 100644 src/components/Facility/StaffCountCard.tsx delete mode 100644 src/components/Facility/TriageForm.tsx diff --git a/cypress/e2e/facility_spec/FacilityCreation.cy.ts b/cypress/e2e/facility_spec/FacilityCreation.cy.ts index f644c9829d3..d2893166745 100644 --- a/cypress/e2e/facility_spec/FacilityCreation.cy.ts +++ b/cypress/e2e/facility_spec/FacilityCreation.cy.ts @@ -1,20 +1,25 @@ -import { advanceFilters } from "pageobject/utils/advanceFilterHelpers"; +import { + generateFacilityName, + generatePhoneNumber, + generateRandomAddress, +} from "pageobject/utils/constants"; 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"; import { nonAdminRoles } from "../../pageobject/utils/userConfig"; -describe("Facility Creation", () => { - let facilityUrl1: string; +describe("Facility Creation with multiple user roles", () => { const facilityPage = new FacilityPage(); const loginPage = new LoginPage(); - const facilityHome = new FacilityHome(); - const manageUserPage = new ManageUserPage(); - const facilityFeature = [ + const facilityName = generateFacilityName(); + const facilityNumber = generatePhoneNumber(); + const facilityAddress = generateRandomAddress(false); + const facilityUpdatedNumber = generatePhoneNumber(); + const facilityUpdatedName = generateFacilityName(); + const facilityUpdatedAddress = generateRandomAddress(true); + const facilityFeatures = [ "CT Scan", "X-Ray", "Maternity Care", @@ -22,22 +27,6 @@ describe("Facility Creation", () => { "Operation Theater", "Blood Bank", ]; - const bedCapacity = "10"; - const bedOccupancy = "5"; - const oxygenCapacity = "100"; - const oxygenExpected = "80"; - const totalCapacity = "20"; - const totalOccupancy = "10"; - const doctorCapacity = "5"; - const totalDoctor = "10"; - const facilityName = "Cypress Facility"; - const facilityName2 = "Dummy Facility 40"; - const facilityAddress = "cypress address"; - const facilityUpdateAddress = "cypress updated address"; - const facilityNumber = "9898469865"; - const triageDate = "02122023"; - const initialTriageValue = "60"; - const modifiedTriageValue = "50"; const facilityErrorMessage = [ "Required", "Required", @@ -50,22 +39,11 @@ describe("Facility Creation", () => { "Required", "Invalid Phone Number", ]; - const bedErrorMessage = [ - "This field is required", - "Total capacity cannot be 0", - "This field is required", - ]; - const doctorErrorMessage = [ - "This field is required", - "This field is required", - ]; - 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", @@ -77,44 +55,6 @@ describe("Facility Creation", () => { 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(() => { @@ -128,262 +68,72 @@ describe("Facility Creation", () => { cy.awaitUrl("/facility"); }); - it("Verify Facility Triage Function", () => { - // mandatory field error throw - facilityHome.typeFacilitySearch(facilityName2); - advanceFilters.verifyFilterBadgePresence( - "Facility/District Name", - facilityName2, - true, - ); - facilityHome.assertFacilityInCard(facilityName2); - facilityHome.verifyURLContains(facilityName2); - facilityPage.visitAlreadyCreatedFacility(); - facilityPage.scrollToFacilityTriage(); - facilityPage.clickAddFacilityTriage(); - manageUserPage.clickSubmit(); - cy.verifyErrorMessages(triageErrorMessage); - // create a entry and verify reflection - facilityPage.fillEntryDate(triageDate); - facilityPage.fillTriageEntryFields( - initialTriageValue, - initialTriageValue, - initialTriageValue, - initialTriageValue, - initialTriageValue, - ); - manageUserPage.clickSubmit(); - // edit the entry and verify reflection - facilityPage.scrollToFacilityTriage(); - facilityPage.verifyTriageTableContains(initialTriageValue); - facilityPage.clickEditButton(); - facilityPage.fillTriageEntryFields( - modifiedTriageValue, - modifiedTriageValue, - modifiedTriageValue, - modifiedTriageValue, - modifiedTriageValue, - ); - manageUserPage.clickSubmit(); - facilityPage.scrollToFacilityTriage(); - facilityPage.verifyTriageTableContains(modifiedTriageValue); - // validate error of filling data on same date already data exist and verify reflection - facilityPage.scrollToFacilityTriage(); - facilityPage.clickAddFacilityTriage(); - facilityPage.fillEntryDate(triageDate); - facilityPage.clickButtonsMultipleTimes("button#submit"); - }); - - it("Create a new facility with multiple bed and doctor capacity", () => { - // create facility with multiple capacity and verify form error message for facility form + it("Create a new facility with all fields | Edit Existing Data | Verify its reflection", () => { + // Create a new facility facilityPage.visitCreateFacilityPage(); - facilityPage.submitForm(); - cy.verifyErrorMessages(facilityErrorMessage); - facilityPage.fillBasicDetails(testFacilityData.basic); + facilityPage.fillBasicDetails({ + ...testFacilityData.basic, + features: facilityFeatures, + }); facilityPage.fillLocationDetails(testFacilityData.location); - facilityPage.fillOxygenDetails(testFacilityData.oxygen); - facilityPage.submitForm(); - cy.closeNotification(); - // add the bed capacity - facilityPage.selectBedType("Oxygen Supported Bed"); - facilityPage.fillTotalCapacity(bedCapacity); - facilityPage.fillCurrentlyOccupied(bedOccupancy); - facilityPage.clickbedcapcityaddmore(); - cy.closeNotification(); - facilityPage.selectBedType("Ordinary Bed"); - facilityPage.fillTotalCapacity(bedCapacity); - facilityPage.fillCurrentlyOccupied(bedOccupancy); - facilityPage.clickbedcapcityaddmore(); - cy.closeNotification(); - facilityPage.getTotalBedCapacity().contains(totalCapacity); - facilityPage.getTotalBedCapacity().contains(totalOccupancy); - facilityPage.clickcancelbutton(); - // create multiple bed capacity and verify card reflection - facilityPage.selectAreaOfSpecialization("General Medicine"); - facilityPage.fillDoctorCount(doctorCapacity); - facilityPage.clickdoctorcapacityaddmore(); - cy.closeNotification(); - facilityPage.selectAreaOfSpecialization("Pulmonology"); - facilityPage.fillDoctorCount(doctorCapacity); - facilityPage.clickdoctorcapacityaddmore(); - cy.closeNotification(); - facilityPage.getTotalDoctorCapacity().contains(doctorCapacity); - facilityPage.clickcancelbutton(); - facilityPage.verifyfacilitynewurl(); - // verify the facility card - facilityPage.getFacilityName().contains(facilityName).should("be.visible"); - facilityPage - .getAddressDetailsView() - .contains(facilityAddress) - .should("be.visible"); - facilityPage - .getPhoneNumberView() - .contains(facilityNumber) - .should("be.visible"); - facilityPage - .getFacilityAvailableFeatures() - .invoke("text") - .then((text) => { - facilityFeature.forEach((feature) => { - expect(text).to.contain(feature); - }); - }); - facilityPage.getFacilityOxygenInfo().scrollIntoView(); - facilityPage - .getFacilityOxygenInfo() - .contains(oxygenCapacity) - .should("be.visible"); - facilityPage.getFacilityTotalBedCapacity().scrollIntoView(); - facilityPage.getFacilityTotalBedCapacity().contains(totalCapacity); - facilityPage.getFacilityTotalBedCapacity().contains(totalOccupancy); - facilityPage.getFacilityTotalDoctorCapacity().scrollIntoView(); - facilityPage.getFacilityTotalDoctorCapacity().contains(totalDoctor); - // verify the delete functionality - cy.get("#manage-facility-dropdown button").scrollIntoView(); - facilityPage.clickManageFacilityDropdown(); - facilityPage.clickDeleteFacilityOption(); - facilityPage.confirmDeleteFacility(); - cy.verifyNotification("Facility deleted successfully"); - }); - - it("Create a new facility with single bed and doctor capacity", () => { - 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 - .getAddressDetailsView() - .contains(facilityAddress) - .should("be.visible"); - facilityPage - .getPhoneNumberView() - .contains(facilityNumber) - .should("be.visible"); - // verify the facility homepage - facilityHome.navigateToFacilityHomepage(); - facilityHome.typeFacilitySearch(facilityName); - advanceFilters.verifyFilterBadgePresence( - "Facility/District Name", + facilityPage.selectLocation("Kochi, Kerala"); + facilityPage.clickSaveFacilityButton(); + facilityPage.verifyFacilityCreatedNotification(); + // verify the facility card info + cy.verifyContentPresence("#facility-details-card", [ facilityName, - true, - ); - facilityHome.assertFacilityInCard(facilityName); - facilityHome.verifyURLContains(facilityName); - }); - - 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.fillBasicDetails(noCapacityData.basic); - facilityPage.fillLocationDetails(noCapacityData.location); - facilityPage.submitForm(); - // add no bed capacity and verify form error message - facilityPage.isVisibleselectBedType(); - facilityPage.saveAndExitBedCapacityForm(); - cy.verifyErrorMessages(bedErrorMessage); - facilityPage.clickcancelbutton(); - // add no doctor capacity and verify form error message - facilityPage.isVisibleAreaOfSpecialization(); - facilityPage.clickdoctorcapacityaddmore(); - cy.verifyErrorMessages(doctorErrorMessage); - facilityPage.clickcancelbutton(); - cy.url().then((newUrl) => { - facilityUrl1 = newUrl; - }); - // verify the created facility details - facilityPage.getFacilityName().contains(facilityName).should("be.visible"); - facilityPage - .getAddressDetailsView() - .contains(facilityAddress) - .should("be.visible"); - facilityPage - .getPhoneNumberView() - .contains(facilityNumber) - .should("be.visible"); - }); - - it("Update the existing facility", () => { - // update a existing dummy data facility - facilityPage.visitUpdateFacilityPage(facilityUrl1); + facilityAddress, + facilityNumber, + ]); + // Edit the facility data facilityPage.clickManageFacilityDropdown(); facilityPage.clickUpdateFacilityOption(); - facilityPage.selectFacilityType(facilityType); - facilityPage.fillAddress(facilityUpdateAddress); - facilityPage.fillOxygenCapacity(oxygenCapacity); - facilityPage.fillExpectedOxygenRequirement(oxygenExpected); - facilityPage.selectLocation("Kochi, Kerala"); - facilityPage.submitForm(); - cy.url().should("not.include", "/update"); - // verify the updated data - facilityPage.getFacilityOxygenInfo().scrollIntoView(); - facilityPage - .getFacilityOxygenInfo() - .contains(oxygenCapacity) - .should("be.visible"); - facilityPage.getAddressDetailsView().scrollIntoView(); - facilityPage - .getAddressDetailsView() - .contains(facilityUpdateAddress) - .should("be.visible"); + facilityPage.typeFacilityName(facilityUpdatedName, true); + facilityPage.typeFacilityPhoneNumber(facilityUpdatedNumber, true); + facilityPage.typeFacilityAddress(facilityUpdatedAddress, true); + facilityPage.clickUpdateFacilityButton(); + facilityPage.verifyFacilityUpdatedNotification(); + // verify the facility card updated info + cy.verifyContentPresence("#facility-details-card", [ + facilityUpdatedName, + facilityUpdatedAddress, + facilityUpdatedNumber, + ]); }); - it("Configure the existing facility", () => { - facilityPage.visitUpdateFacilityPage(facilityUrl1); + it("Create a new facility with only mandatory fields | Delete the facility", () => { + // Create a new facility + facilityPage.visitCreateFacilityPage(); + facilityPage.fillBasicDetails(testFacilityData.basic); + facilityPage.fillLocationDetails(testFacilityData.location); + facilityPage.clickSaveFacilityButton(); + facilityPage.verifyFacilityCreatedNotification(); + // verify the facility card info + cy.verifyContentPresence("#facility-details-card", [ + facilityName, + facilityAddress, + facilityNumber, + ]); + // verify the delete facility functionality facilityPage.clickManageFacilityDropdown(); - facilityPage.clickConfigureFacilityOption(); - facilityPage.fillMiddleWareAddress("dev_middleware.coronasafe.live"); - facilityPage.clickupdateMiddleWare(); - facilityPage.verifySuccessNotification( - "Facility middleware updated successfully", - ); + facilityPage.clickDeleteFacilityOption(); + facilityPage.confirmDeleteFacility(); + cy.verifyNotification(`${facilityName} deleted successfully`); }); it("Should display error when district admin tries to create facility in a different district", () => { + // Verify the entire form error message facilityPage.visitCreateFacilityPage(); - facilityPage.fillFacilityName(facilityName); - facilityPage.selectFacilityType(facilityType); + facilityPage.clickSaveFacilityButton(); + cy.verifyErrorMessages(facilityErrorMessage); + // Verify the user access based error message + facilityPage.fillBasicDetails(testFacilityData.basic); facilityPage.fillPincode("682001"); facilityPage.selectStateOnPincode("Kerala"); facilityPage.selectDistrictOnPincode("Kottayam"); facilityPage.selectLocalBody("Arpookara"); facilityPage.selectWard("5"); - facilityPage.fillAddress(facilityAddress); - facilityPage.fillPhoneNumber(facilityNumber); - facilityPage.submitForm(); + facilityPage.clickSaveFacilityButton(); facilityPage.verifyErrorNotification( "You do not have permission to perform this action.", ); diff --git a/cypress/e2e/facility_spec/FacilityHomepage.cy.ts b/cypress/e2e/facility_spec/FacilityHomepage.cy.ts index 680ce6fa2ce..0aa8518a6d1 100644 --- a/cypress/e2e/facility_spec/FacilityHomepage.cy.ts +++ b/cypress/e2e/facility_spec/FacilityHomepage.cy.ts @@ -21,8 +21,6 @@ describe("Facility Homepage Function", () => { const patientPage = new PatientPage(); const facilityLocation = new FacilityLocation(); const facilitiesAlias = "downloadFacilitiesCSV"; - const doctorsAlias = "downloadDoctorsCSV"; - const triagesAlias = "downloadTriagesCSV"; const facilityName = "Dummy Facility 40"; const facilityLocaion = "Dummy Location"; const stateName = "Kerala"; @@ -118,23 +116,7 @@ describe("Facility Homepage Function", () => { // Verify Facility Export facilityHome.csvDownloadIntercept(facilitiesAlias, ""); facilityHome.clickExportButton(); - facilityHome.clickMenuItem("Facilities"); facilityHome.verifyDownload(facilitiesAlias); - // Verify Doctor Export - facilityHome.csvDownloadIntercept(doctorsAlias, "&doctors"); - facilityHome.clickExportButton(); - facilityHome.clickMenuItem("Doctors"); - facilityHome.verifyDownload(doctorsAlias); - // Verify Triage Export - facilityHome.csvDownloadIntercept(triagesAlias, "&triage"); - facilityHome.clickExportButton(); - facilityHome.clickMenuItem("Triages"); - facilityHome.verifyDownload(triagesAlias); - }); - - it("Verify Capacity Export Functionality", () => { - facilityHome.clickExportButton(); - facilityHome.clickMenuItem("Capacities"); }); it("Verify Facility Detail page redirection to CNS and Live Minitoring ", () => { diff --git a/cypress/e2e/facility_spec/FacilityManage.cy.ts b/cypress/e2e/facility_spec/FacilityManage.cy.ts index 9f1523768c1..3930f470160 100644 --- a/cypress/e2e/facility_spec/FacilityManage.cy.ts +++ b/cypress/e2e/facility_spec/FacilityManage.cy.ts @@ -21,12 +21,6 @@ describe("Facility Manage Functions", () => { /Health Facility config updated successfully|Health ID registration failed/; const facilityHfrId = "IN180000018"; const facilityUpdatedHfrId = "IN180000020"; - const doctorCapacity = "5"; - const doctorModifiedCapacity = "7"; - const totalCapacity = "100"; - const currentOccupied = "80"; - const totalUpdatedCapacity = "120"; - const currentUpdatedOccupied = "100"; before(() => { loginPage.loginByRole("districtAdmin"); @@ -116,64 +110,6 @@ describe("Facility Manage Functions", () => { facilityManage.verifyHfrIdValue(facilityUpdatedHfrId); }); - it("Modify doctor capacity in Facility detail page", () => { - // Add a doctor capacity - facilityManage.clickFacilityAddDoctorTypeButton(); - facilityPage.selectAreaOfSpecialization("Pulmonology"); - facilityPage.fillDoctorCount(doctorCapacity); - facilityPage.saveAndExitDoctorForm(); - facilityManage.verifySuccessMessageVisibilityAndContent( - "Staff count added successfully", - ); - facilityManage.verifyTotalDoctorCapacity(doctorCapacity); - // edit a existing doctor - facilityManage.clickEditFacilityDoctorCapacity(); - facilityPage.fillDoctorCount(doctorModifiedCapacity); - facilityPage.clickdoctorcapacityaddmore(); - facilityManage.verifySuccessMessageVisibilityAndContent( - "Staff count updated successfully", - ); - facilityManage.verifyTotalDoctorCapacity(doctorModifiedCapacity); - // delete a bed - facilityManage.clickDeleteFacilityDoctorCapacity(); - facilityManage.clickButtonWithText("Delete"); - facilityManage.verifySuccessMessageVisibilityAndContent( - "Staff specialization type deleted successfully", - ); - }); - - it("Modify bed capacity in Facility detail page", () => { - // add multiple new bed capacity - facilityManage.clickFacilityAddBedTypeButton(); - facilityPage.selectBedType("Isolation Bed"); - facilityPage.fillTotalCapacity(totalCapacity); - facilityPage.fillCurrentlyOccupied(currentOccupied); - facilityPage.saveAndExitBedCapacityForm(); - facilityManage.verifySuccessMessageVisibilityAndContent( - "Bed capacity added successfully", - ); - cy.closeNotification(); - facilityManage.verifyFacilityBedCapacity(totalCapacity); - facilityManage.verifyFacilityBedCapacity(currentOccupied); - // edit a existing bed - facilityManage.clickEditFacilityBedCapacity(); - facilityPage.fillTotalCapacity(totalUpdatedCapacity); - facilityPage.fillCurrentlyOccupied(currentUpdatedOccupied); - facilityPage.clickbedcapcityaddmore(); - facilityManage.verifySuccessMessageVisibilityAndContent( - "Bed capacity updated successfully", - ); - cy.closeNotification(); - facilityManage.verifyFacilityBedCapacity(totalUpdatedCapacity); - facilityManage.verifyFacilityBedCapacity(currentUpdatedOccupied); - // delete a bed - facilityManage.clickDeleteFacilityBedCapacity(); - facilityManage.clickButtonWithText("Delete"); - facilityManage.verifySuccessMessageVisibilityAndContent( - "Bed type deleted successfully", - ); - }); - afterEach(() => { cy.saveLocalStorage(); }); diff --git a/cypress/e2e/patient_spec/PatientHomepage.cy.ts b/cypress/e2e/patient_spec/PatientHomepage.cy.ts index a120e282a2d..8949fc3e324 100644 --- a/cypress/e2e/patient_spec/PatientHomepage.cy.ts +++ b/cypress/e2e/patient_spec/PatientHomepage.cy.ts @@ -54,7 +54,6 @@ describe("Patient Homepage present functionalities", () => { patientHome.verifyPatientAdmittedBeforeDate(patientToDateBadge); patientHome.verifyPatientAdmittedAfterDate(patientFromDateBadge); cy.clearAllFilters(); - patientHome.verifyTotalPatientCount("1"); }); it("Facility Geography based advance filters applied in the patient tab", () => { @@ -71,7 +70,6 @@ describe("Patient Homepage present functionalities", () => { patientHome.verifyFacilityLsgBadgeContent(facilityLsgBody); patientHome.verifyFacilityDistrictContent(facilityDistrict); cy.clearAllFilters(); - patientHome.verifyTotalPatientCount("1"); }); it("Patient diagnosis based advance filters applied in the patient tab", () => { @@ -104,7 +102,6 @@ describe("Patient Homepage present functionalities", () => { patientHome.verifyDifferentialDiagnosisBadgeContent(patientIcdDiagnosis); // Clear the badges and verify the patient count along with badges cy.clearAllFilters(); - patientHome.verifyTotalPatientCount("1"); // Apply Any and confirmed diagonsis to verify patient count 17 advanceFilters.clickAdvancedFiltersButton(); patientHome.selectAnyIcdDiagnosis(patientIcdDiagnosis, patientIcdDiagnosis); @@ -142,7 +139,6 @@ describe("Patient Homepage present functionalities", () => { patientHome.verifyMedicoBadgeContent("false"); // Clear the badges and verify the patient count along with badges cy.clearAllFilters(); - patientHome.verifyTotalPatientCount("1"); }); it("Export the live patient list based on a date range", () => { diff --git a/cypress/e2e/resource_spec/ResourcesHomepage.cy.ts b/cypress/e2e/resource_spec/ResourcesHomepage.cy.ts index 23077a71ed8..160884978fd 100644 --- a/cypress/e2e/resource_spec/ResourcesHomepage.cy.ts +++ b/cypress/e2e/resource_spec/ResourcesHomepage.cy.ts @@ -20,14 +20,15 @@ describe("Resource Page", () => { beforeEach(() => { cy.restoreLocalStorage(); cy.clearLocalStorage(/filters--.+/); - cy.awaitUrl("/resource"); }); it("Checks if all download button works", () => { + resourcePage.navigationToResourcePage(); resourcePage.verifyDownloadButtonWorks(); }); it("Switch between active/completed", () => { + resourcePage.navigationToResourcePage(); resourcePage.spyResourceApi(); resourcePage.clickCompletedResources(); resourcePage.verifyCompletedResources(); @@ -37,6 +38,7 @@ describe("Resource Page", () => { }); it("Switch between list view and board view", () => { + resourcePage.navigationToResourcePage(); resourcePage.clickListViewButton(); resourcePage.clickBoardViewButton(); }); @@ -68,7 +70,7 @@ describe("Resource Page", () => { }); it("Update the status of resource", () => { - cy.visit(createdResource); + cy.awaitUrl(createdResource); resourcePage.clickUpdateStatus(); resourcePage.updateStatus("APPROVED"); resourcePage.clickSubmitButton(); @@ -78,7 +80,7 @@ describe("Resource Page", () => { }); it("Post comment for a resource", () => { - cy.visit(createdResource); + cy.awaitUrl(createdResource); resourcePage.addCommentForResource("Test comment"); resourcePage.clickPostCommentButton(); resourcePage.verifySuccessNotification("Comment added successfully"); diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index e59dfef09f3..9776433e523 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -16,31 +16,6 @@ export interface FacilityData { 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 { @@ -60,15 +35,8 @@ class FacilityPage { advanceFilters.selectLocalBody(localBody); } - visitUpdateFacilityPage(url: string) { - cy.intercept("GET", "**/api/v1/facility/**").as("getFacilities"); - cy.visit(url); - cy.wait("@getFacilities").its("response.statusCode").should("eq", 200); - cy.get("#manage-facility-dropdown button").should("be.visible"); - } - - fillFacilityName(name: string) { - cy.get("#name").click().clear().click().type(name); + typeFacilityName(name: string, clearBeforeTyping: boolean = false) { + cy.typeIntoField("#name", name, { clearBeforeTyping }); } fillPincode(pincode: string) { @@ -80,90 +48,29 @@ class FacilityPage { cy.get("[role='option']").contains(ward).click(); } - fillAddress(address: string) { - cy.get("#address").click().type(address); - } - - fillPhoneNumber(phoneNumber: string) { - cy.get("#phone_number").type(phoneNumber); - } - - submitForm() { - cy.get("button#submit").click(); - } - - selectBedType(bedType: string) { - cy.clickAndSelectOption("div#bed-type button", bedType); - } - - isVisibleselectBedType() { - cy.get("div#bed-type button").should("be.visible"); - } - - fillTotalCapacity(capacity: string) { - cy.get("input#total-capacity").click().clear().click().type(capacity); - } - - fillCurrentlyOccupied(occupied: string) { - cy.get("input#currently-occupied").click().clear().click().type(occupied); - } - - saveAndExitBedCapacityForm() { - cy.get("button#bed-capacity-save-and-exit").click(); - } - - selectAreaOfSpecialization(area: string) { - cy.get("div#area-of-specialization button").click(); - cy.get("[role='option']").contains(area).click(); + typeFacilityAddress(address: string, clearBeforeTyping: boolean = false) { + cy.typeIntoField("#address", address, { clearBeforeTyping }); } - isVisibleAreaOfSpecialization() { - cy.get("div#area-of-specialization button").should("be.visible"); - } - - fillDoctorCount(count: string) { - cy.get("input#count").click().clear().click().type(count); - } - - fillOxygenCapacity(capacity: string) { - cy.get("#oxygen_capacity").click().clear().type(capacity); - } - - fillExpectedOxygenRequirement(requirement: string) { - cy.get("#expected_oxygen_requirement").click().clear().type(requirement); - } - - fillBTypeCylinderCapacity(capacity: string) { - cy.get("#type_b_cylinders").click().clear().type(capacity); - } - - fillExpectedBTypeCylinderRequirement(requirement: string) { - cy.get("#expected_type_b_cylinders").focus().clear(); - cy.get("#expected_type_b_cylinders").focus().type(requirement); - } - - fillCTypeCylinderCapacity(capacity: string) { - cy.get("#type_c_cylinders").click().clear().type(capacity); - } - - fillExpectedCTypeCylinderRequirement(requirement: string) { - cy.get("#expected_type_c_cylinders").focus().clear(); - cy.get("#expected_type_c_cylinders").focus().type(requirement); + typeFacilityPhoneNumber( + phoneNumber: string, + clearBeforeTyping: boolean = false, + ) { + cy.typeIntoField("#phone_number", phoneNumber, { clearBeforeTyping }); } - fillDTypeCylinderCapacity(capacity: string) { - cy.get("#type_d_cylinders").click().clear().type(capacity); + clickSaveFacilityButton() { + cy.verifyAndClickElement("#submit", "Save Facility"); } - fillExpectedDTypeCylinderRequirement(requirement: string) { - cy.get("#expected_type_d_cylinders").focus().clear(); - cy.get("#expected_type_d_cylinders").focus().type(requirement); + verifyFacilityCreatedNotification() { + cy.verifyNotification("Facility added successfully"); + cy.closeNotification(); } - saveAndExitDoctorForm() { - cy.intercept("GET", "**/api/v1/facility/**").as("createFacilities"); - cy.get("button#save-and-exit").click(); - cy.wait("@createFacilities").its("response.statusCode").should("eq", 200); + verifyFacilityUpdatedNotification() { + cy.verifyNotification("Facility updated successfully"); + cy.closeNotification(); } clickManageFacilityDropdown() { @@ -178,6 +85,10 @@ class FacilityPage { cy.get("#update-facility").contains("Update Facility").click(); } + clickUpdateFacilityButton() { + cy.verifyAndClickElement("#submit", "Update Facility"); + } + clickConfigureFacilityOption() { cy.get("#configure-facility").contains("Configure Facility").click(); } @@ -199,22 +110,6 @@ class FacilityPage { cy.get("#inventory-management").click(); } - getTotalBedCapacity() { - return cy.get("#total-bed-capacity"); - } - - getFacilityTotalBedCapacity() { - return cy.get("#facility-bed-capacity-details"); - } - - getFacilityTotalDoctorCapacity() { - return cy.get("#facility-doctor-capacity-details"); - } - - getTotalDoctorCapacity() { - return cy.get("#total-doctor-capacity"); - } - getFacilityName() { return cy.get("#facility-name"); } @@ -231,10 +126,6 @@ class FacilityPage { return cy.get("#facility-available-features"); } - getFacilityOxygenInfo() { - return cy.get("#facility-oxygen-info"); - } - clickResourceRequestOption() { cy.get("#resource-request").contains("Resource Request").click(); } @@ -243,64 +134,10 @@ class FacilityPage { cy.get("#delete-facility").contains("Delete Facility").click(); } - scrollToFacilityTriage() { - cy.get("#add-facility-triage").scrollIntoView(); - } - - fillTriageEntryFields( - visited: string, - homeQuarantine: string, - isolation: string, - referred: string, - confirmedPositive: string, - ) { - cy.get("#num_patients_visited").clear().click().type(visited); - cy.get("#num_patients_home_quarantine") - .clear() - .click() - .type(homeQuarantine); - cy.get("#num_patients_isolation").clear().click().type(isolation); - cy.get("#num_patient_referred").clear().click().type(referred); - cy.get("#num_patient_confirmed_positive") - .clear() - .click() - .type(confirmedPositive); - } - - fillEntryDate(date: string) { - cy.clickAndTypeDate("#entry_date", date); - } - - clickEditButton() { - cy.get("#edit-button").click(); - } - - clickButtonsMultipleTimes(selector: string) { - cy.get(selector).each(($button) => { - cy.wrap($button).click(); - }); - } - - verifyTriageTableContains(value: string) { - cy.get("#triage-table").contains(value); - } - - clickAddFacilityTriage() { - cy.get("#add-facility-triage").click(); - } - clickfacilityfeatureoption() { cy.get("#features").click(); } - clickbedcapcityaddmore() { - cy.get("#bed-capacity-save").click(); - } - - clickdoctorcapacityaddmore() { - cy.get("#doctor-save").click(); - } - clickcancelbutton() { cy.get("#cancel").click(); } @@ -509,30 +346,15 @@ class FacilityPage { // Fill location details this.fillLocationDetails(data.location); - // Fill oxygen details if provided - if (data.oxygen) { - this.fillOxygenDetails(data.oxygen); - } - - this.submitForm(); + this.clickSaveFacilityButton(); 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.typeFacilityName(basic.name); this.selectFacilityType(basic.type); if (basic.features?.length) { @@ -543,8 +365,8 @@ class FacilityPage { this.clickfacilityfeatureoption(); } - this.fillAddress(basic.address); - this.fillPhoneNumber(basic.phoneNumber); + this.typeFacilityAddress(basic.address); + this.typeFacilityPhoneNumber(basic.phoneNumber); if (basic.location) { this.selectLocation(basic.location); @@ -558,47 +380,6 @@ class FacilityPage { 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 bbf5945453e..24f7d321628 100644 --- a/cypress/pageobject/Facility/FacilityHome.ts +++ b/cypress/pageobject/Facility/FacilityHome.ts @@ -1,7 +1,6 @@ class FacilityHome { // Selectors exportButton = "#export-button"; - menuItem = "[role='menuitem']"; // Operations clickExportButton() { @@ -10,7 +9,7 @@ class FacilityHome { } navigateToFacilityHomepage() { - cy.visit("/facility"); + cy.awaitUrl("/facility"); } assertFacilityInCard(facilityName: string) { @@ -29,10 +28,6 @@ class FacilityHome { cy.get("#facility-search").click().clear().type(facilityName); } - clickMenuItem(itemName: string) { - cy.get(this.menuItem).contains(itemName).click(); - } - csvDownloadIntercept(alias: string, queryParam: string) { cy.intercept("GET", `**/api/v1/facility/?csv${queryParam}`).as(alias); } diff --git a/cypress/pageobject/Facility/FacilityManage.ts b/cypress/pageobject/Facility/FacilityManage.ts index e7eecddab3c..00d9f642bbc 100644 --- a/cypress/pageobject/Facility/FacilityManage.ts +++ b/cypress/pageobject/Facility/FacilityManage.ts @@ -18,30 +18,6 @@ class FacilityManage { cy.get("#save-cover-image").click(); } - verifyTotalDoctorCapacity(expectedCapacity: string) { - cy.get("#facility-doctor-totalcapacity").contains(expectedCapacity); - } - - verifyFacilityBedCapacity(expectedCapacity: string) { - cy.get("#facility-bed-capacity-details").contains(expectedCapacity); - } - - clickEditFacilityDoctorCapacity() { - cy.get("#edit-facility-doctorcapacity").click(); - } - - clickEditFacilityBedCapacity() { - cy.get("#edit-facility-bedcapacity").click(); - } - - clickDeleteFacilityDoctorCapacity() { - cy.get("#delete-facility-doctorcapacity").click(); - } - - clickDeleteFacilityBedCapacity() { - cy.get("#delete-facility-bedcapacity").click(); - } - clickFacilityConfigureButton() { cy.get("#configure-facility").should("be.visible"); cy.get("#configure-facility").click(); @@ -90,16 +66,6 @@ class FacilityManage { cy.get("#hf_id").should("have.value", expectedValue); } - clickFacilityAddDoctorTypeButton() { - cy.get("#facility-add-doctortype").scrollIntoView(); - cy.get("#facility-add-doctortype").click(); - } - - clickFacilityAddBedTypeButton() { - 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(); diff --git a/cypress/pageobject/Resource/ResourcePage.ts b/cypress/pageobject/Resource/ResourcePage.ts index 730d3dd9148..c01c60baec5 100644 --- a/cypress/pageobject/Resource/ResourcePage.ts +++ b/cypress/pageobject/Resource/ResourcePage.ts @@ -28,6 +28,10 @@ class ResourcePage { cy.contains("button", "Active").click(); } + navigationToResourcePage() { + cy.awaitUrl("/resource"); + } + verifyActiveResources() { cy.wait("@resource").its("response.statusCode").should("eq", 200); cy.contains("button", "Active").should("have.class", "text-white"); diff --git a/cypress/pageobject/utils/constants.ts b/cypress/pageobject/utils/constants.ts index 053d0561ce8..90baf3b6d4b 100644 --- a/cypress/pageobject/utils/constants.ts +++ b/cypress/pageobject/utils/constants.ts @@ -1,10 +1,122 @@ -export function generatePhoneNumber(): string { +function generatePhoneNumber(): string { const array = new Uint32Array(1); window.crypto.getRandomValues(array); const randomNum = (array[0] % 900000000) + 100000000; return "9" + randomNum.toString(); } -export function generateEmergencyPhoneNumber(): string { +function generateEmergencyPhoneNumber(): string { return generatePhoneNumber(); } + +function generateFacilityName(): string { + const prefixes = [ + "GHC", + "NHC", + "SHC", + "Apollo", + "General", + "St. Mary's", + "Central", + "Kochi", + ]; + const locations = [ + "North", + "South", + "East", + "West", + "Downtown", + "Metro", + "Springfield", + "Ernakulam", + ]; + const identifiers = [ + () => Math.floor(Math.random() * 100), // Numeric IDs + () => `Zone-${Math.floor(Math.random() * 10)}`, // Zone IDs + () => `Block-${String.fromCharCode(65 + Math.floor(Math.random() * 26))}`, // Alphabetic Blocks + ]; + const suffixes = [ + "Meta", + "Prime", + "Care", + "Wellness", + "Clinic", + "Center", + "Specialists", + "Hospital", + ]; + + const randomPrefix = prefixes[Math.floor(Math.random() * prefixes.length)]; + const randomLocation = + locations[Math.floor(Math.random() * locations.length)]; + const randomIdentifier = + identifiers[Math.floor(Math.random() * identifiers.length)](); + const randomSuffix = suffixes[Math.floor(Math.random() * suffixes.length)]; + + // Randomize the format of the name + const formats = [ + `${randomPrefix} ${randomLocation}-${randomIdentifier} ${randomSuffix}`, + `${randomLocation} ${randomPrefix} ${randomSuffix}`, + `${randomPrefix} ${randomLocation} ${randomSuffix}`, + ]; + + return formats[Math.floor(Math.random() * formats.length)]; +} + +function generateRandomAddress(multiline: boolean = false): string { + const localities = [ + "Marine Drive", + "Fort Kochi", + "Thevara", + "Vyttila", + "Edappally", + "Palarivattom", + "Kakkanad", + "Mattancherry", + "Kaloor", + "Tripunithura", + ]; + const neighborhoods = [ + "Lane 1", + "Lane 2", + "North Block", + "East End", + "West Side", + "Central Area", + "Market Road", + "Garden Street", + "Highland Avenue", + ]; + const districts = ["Kochi", "Ernakulam"]; + const states = ["Kerala"]; + const pincode = Math.floor(682000 + Math.random() * 1000).toString(); // Generate random pincodes in the 682XXX range. + + const randomLocality = + localities[Math.floor(Math.random() * localities.length)]; + const randomNeighborhood = + neighborhoods[Math.floor(Math.random() * neighborhoods.length)]; + const randomDistrict = + districts[Math.floor(Math.random() * districts.length)]; + const randomState = states[Math.floor(Math.random() * states.length)]; + + // Create address components + const addressParts = [ + randomNeighborhood, + randomLocality, + randomDistrict, + randomState, + `Pincode: ${pincode}`, + ]; + + // Return address as single line or multiline + // If 'multiline' is false, return address as a single line + // If 'multiline' is true, return address with each component on a new line + return multiline ? addressParts.join("\n") : addressParts.join(", "); +} + +export { + generatePhoneNumber, + generateEmergencyPhoneNumber, + generateFacilityName, + generateRandomAddress, +}; diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 0268beebc42..f5bbcf42290 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -241,3 +241,21 @@ Cypress.Commands.add("verifyErrorMessages", (errorMessages: string[]) => { }); }); }); + +Cypress.Commands.add( + "typeIntoField", + ( + selector: string, + value: string, + options: { clearBeforeTyping?: boolean } = {}, + ) => { + const { clearBeforeTyping = false } = options; + const inputField = cy.get(selector); + + if (clearBeforeTyping) { + inputField.clear(); // Clear the input field + } + + inputField.click().type(value); // Click and type the new value + }, +); diff --git a/cypress/support/index.ts b/cypress/support/index.ts index 831ee71a5bc..fa01326698c 100644 --- a/cypress/support/index.ts +++ b/cypress/support/index.ts @@ -46,6 +46,11 @@ declare global { texts: string[], ): Chainable; verifyErrorMessages(errorMessages: string[]): Chainable; + typeIntoField( + selector: string, + value: string, + options?: { clearBeforeTyping?: boolean }, + ): Chainable; } } } diff --git a/package-lock.json b/package-lock.json index 41d7fcfff8c..6e57456063b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,7 +40,7 @@ "clsx": "^2.1.1", "cmdk": "^1.0.4", "cross-env": "^7.0.3", - "cypress": "^13.16.0", + "cypress": "^13.15.2", "dayjs": "^1.11.13", "echarts": "^5.5.1", "echarts-for-react": "^3.0.2", @@ -7807,9 +7807,9 @@ "license": "MIT" }, "node_modules/cypress": { - "version": "13.16.0", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.16.0.tgz", - "integrity": "sha512-g6XcwqnvzXrqiBQR/5gN+QsyRmKRhls1y5E42fyOvsmU7JuY+wM6uHJWj4ZPttjabzbnRvxcik2WemR8+xT6FA==", + "version": "13.15.2", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.15.2.tgz", + "integrity": "sha512-ARbnUorjcCM3XiPwgHKuqsyr5W9Qn+pIIBPaoilnoBkLdSC2oLQjV1BUpnmc7KR+b7Avah3Ly2RMFnfxr96E/A==", "hasInstallScript": true, "dependencies": { "@cypress/request": "^3.0.6", diff --git a/package.json b/package.json index 15392d09410..3db351e974b 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "clsx": "^2.1.1", "cmdk": "^1.0.4", "cross-env": "^7.0.3", - "cypress": "^13.16.0", + "cypress": "^13.15.2", "dayjs": "^1.11.13", "echarts": "^5.5.1", "echarts-for-react": "^3.0.2", diff --git a/src/Routers/routes/FacilityRoutes.tsx b/src/Routers/routes/FacilityRoutes.tsx index 8c942518996..bf5d67ca67c 100644 --- a/src/Routers/routes/FacilityRoutes.tsx +++ b/src/Routers/routes/FacilityRoutes.tsx @@ -5,7 +5,6 @@ import { FacilityCreate } from "@/components/Facility/FacilityCreate"; import { FacilityHome } from "@/components/Facility/FacilityHome"; import { FacilityList } from "@/components/Facility/FacilityList"; import FacilityUsers from "@/components/Facility/FacilityUsers"; -import { TriageForm } from "@/components/Facility/TriageForm"; import ResourceCreate from "@/components/Resource/ResourceCreate"; import { AppRoutes } from "@/Routers/AppRouter"; @@ -36,12 +35,6 @@ const FacilityRoutes: AppRoutes = { "/facility/:facilityId/resource/new": ({ facilityId }) => ( ), - "/facility/:facilityId/triage": ({ facilityId }) => ( - - ), - "/facility/:facilityId/triage/:id": ({ facilityId, id }) => ( - - ), ...FacilityLocationRoutes, ...FacilityInventoryRoutes, }; diff --git a/src/Utils/request/api.tsx b/src/Utils/request/api.tsx index e7df6312c84..86886291f11 100644 --- a/src/Utils/request/api.tsx +++ b/src/Utils/request/api.tsx @@ -10,11 +10,6 @@ import { PatientAssetBed, } from "@/components/Assets/AssetTypes"; import { ICD11DiagnosisModel } from "@/components/Diagnosis/types"; -import { - IDeleteBedCapacity, - ILocalBodies, - ILocalBodyByDistrict, -} from "@/components/ExternalResult/models"; import { EventGeneric, type Type, @@ -27,7 +22,6 @@ import { Investigation } from "@/components/Facility/Investigations/Reports/type import { InvestigationSessionType } from "@/components/Facility/Investigations/investigationsTab"; import { BedModel, - CapacityModal, CommentModel, ConsultationModel, CreateBedBody, @@ -35,7 +29,6 @@ import { DailyRoundsBody, DailyRoundsRes, DistrictModel, - DoctorModal, FacilityModel, FacilityRequest, FacilitySpokeModel, @@ -51,7 +44,6 @@ import { MinimumQuantityItemResponse, PatientNotesEditModel, PatientNotesModel, - PatientStatsModel, PatientTransferResponse, ResourceModel, ShiftingModel, @@ -530,23 +522,6 @@ const routes = { method: "GET", TRes: Type(), }, - downloadFacilityCapacity: { - path: "/api/v1/facility/?csv&capacity", - method: "GET", - TRes: Type(), - }, - downloadFacilityDoctors: { - path: "/api/v1/facility/?csv&doctors", - method: "GET", - TRes: Type(), - }, - - downloadFacilityTriage: { - path: "/api/v1/facility/?csv&triage", - method: "GET", - TRes: Type(), - }, - downloadPatients: { path: "/api/v1/patient/?csv", method: "GET", @@ -634,86 +609,6 @@ const routes = { TRes: Type>(), }, - // Hospital Beds - createCapacity: { - path: "/api/v1/facility/{facilityId}/capacity/", - method: "POST", - TRes: Type(), - }, - - createDoctor: { - path: "/api/v1/facility/{facilityId}/hospital_doctor/", - method: "POST", - TRes: Type(), - TBody: Type(), - }, - - getCapacity: { - path: "/api/v1/facility/{facilityId}/capacity/", - TRes: Type>(), - }, - - getCapacityBed: { - path: "/api/v1/facility/{facilityId}/capacity/{bed_id}/", - TRes: Type(), - }, - - deleteCapacityBed: { - path: "/api/v1/facility/{facilityId}/capacity/{bed_id}/", - method: "DELETE", - TRes: Type(), - }, - - listDoctor: { - path: "/api/v1/facility/{facilityId}/hospital_doctor/", - TRes: Type>(), - }, - getDoctor: { - path: "/api/v1/facility/{facilityId}/hospital_doctor/{id}/", - TRes: Type(), - }, - - updateCapacity: { - path: "/api/v1/facility/{facilityId}/capacity/{bed_id}/", - method: "PUT", - TRes: Type(), - }, - - updateDoctor: { - path: "/api/v1/facility/{facilityId}/hospital_doctor/{id}/", - method: "PUT", - TRes: Type(), - }, - - deleteDoctor: { - path: "/api/v1/facility/{facilityId}/hospital_doctor/{area}/", - method: "DELETE", - TRes: Type>(), - }, - - //Triage - createTriage: { - path: "/api/v1/facility/{facilityId}/patient_stats/", - method: "POST", - TBody: Type(), - TRes: Type(), - }, - getTriage: { - path: "/api/v1/facility/{facilityId}/patient_stats/", - TRes: Type>(), - }, - - getTriageDetails: { - path: "/api/v1/facility/{facilityId}/patient_stats/{id}/", - TRes: Type(), - }, - - // //Care Center - // createCenter: { - // path: "/api/v1/carecenter/", - // method: 'POST' - // } - // Patient searchPatient: { @@ -813,12 +708,12 @@ const routes = { getAllLocalBodyByDistrict: { path: "/api/v1/district/{id}/get_all_local_body/", method: "GET", - TRes: Type(), + TRes: Type(), }, getLocalbodyByDistrict: { path: "/api/v1/district/{id}/local_bodies/", method: "GET", - TRes: Type(), + TRes: Type(), }, // Local Body diff --git a/src/components/ExternalResult/models.ts b/src/components/ExternalResult/models.ts deleted file mode 100644 index bc5f8d29e03..00000000000 --- a/src/components/ExternalResult/models.ts +++ /dev/null @@ -1,18 +0,0 @@ -export interface ILocalBodies { - id: number; - name: string; - state: number; - number: number; - body_type: number; - localbody_code: string; - district: number; -} -export interface IDeleteBedCapacity { - detail: string; -} - -export interface ILocalBodyByDistrict { - id: number; - name: string; - state: number; -} diff --git a/src/components/Facility/BedCapacity.tsx b/src/components/Facility/BedCapacity.tsx deleted file mode 100644 index 156dc6adce6..00000000000 --- a/src/components/Facility/BedCapacity.tsx +++ /dev/null @@ -1,301 +0,0 @@ -import { useEffect, useReducer, useState } from "react"; -import { useTranslation } from "react-i18next"; - -import { Cancel, Submit } from "@/components/Common/ButtonV2"; -import { CapacityModal, OptionsType } from "@/components/Facility/models"; -import { SelectFormField } from "@/components/Form/FormFields/SelectFormField"; -import TextFormField from "@/components/Form/FormFields/TextFormField"; -import { FieldChangeEvent } from "@/components/Form/FormFields/Utils"; - -import { BED_TYPES } from "@/common/constants"; - -import * as Notification from "@/Utils/Notifications"; -import routes from "@/Utils/request/api"; -import request from "@/Utils/request/request"; - -interface BedCapacityProps extends CapacityModal { - facilityId: string; - handleClose: () => void; - handleUpdate: () => void; - className?: string; - id?: number; -} - -const initForm: any = { - bedType: "", - totalCapacity: "", - currentOccupancy: "", -}; - -const initialState = { - form: { ...initForm }, - errors: { ...initForm }, -}; - -const bedCountReducer = (state = initialState, action: any) => { - switch (action.type) { - case "set_form": { - return { - ...state, - form: action.form, - }; - } - case "set_error": { - return { - ...state, - errors: action.errors, - }; - } - default: - return state; - } -}; - -export const BedCapacity = (props: BedCapacityProps) => { - const { t } = useTranslation(); - const { facilityId, handleClose, handleUpdate, className, id } = props; - const [state, dispatch] = useReducer(bedCountReducer, initialState); - const [isLastOptionType, setIsLastOptionType] = useState(false); - const [bedTypes, setBedTypes] = useState( - BED_TYPES.map((o) => ({ id: o, text: t(`bed_type__${o}`) })), - ); - const [isLoading, setIsLoading] = useState(false); - - const headerText = !id ? "Add Bed Capacity" : "Edit Bed Capacity"; - const buttonText = !id - ? `Save ${!isLastOptionType ? "& Add More" : "Bed Capacity"}` - : "Update Bed Capacity"; - - async function fetchCapacityBed() { - setIsLoading(true); - if (!id) { - // Add Form functionality - const capacityQuery = await request(routes.getCapacity, { - pathParams: { facilityId: props.facilityId }, - }); - if (capacityQuery?.data) { - const existingData = capacityQuery.data?.results; - // if all options are diabled - if (existingData.length === BED_TYPES.length) { - setBedTypes([]); - setIsLoading(false); - return; - } - // disable existing bed types - const updatedBedTypes = BED_TYPES.map((type) => { - const isExisting = existingData.find( - (i: CapacityModal) => i.room_type === type, - ); - return { - id: type, - text: t(`bed_type__${type}`), - disabled: !!isExisting, - }; - }); - setBedTypes(updatedBedTypes); - } - } else { - // Edit Form functionality - const capacityQuery = await request(routes.getCapacityBed, { - pathParams: { facilityId: props.facilityId, bed_id: id.toString() }, - }); - if (capacityQuery.data) { - dispatch({ - type: "set_form", - form: { - bedType: capacityQuery.data.room_type, - totalCapacity: capacityQuery.data.total_capacity, - currentOccupancy: capacityQuery.data.current_capacity, - }, - }); - } - } - setIsLoading(false); - } - - useEffect(() => { - fetchCapacityBed(); - }, []); - - useEffect(() => { - const lastBedType = - bedTypes.filter((i: OptionsType) => i.disabled).length === - BED_TYPES.length - 1; - setIsLastOptionType(lastBedType); - }, [bedTypes]); - - const handleChange = (e: FieldChangeEvent) => { - const form = { ...state.form }; - form[e.name] = e.value; - dispatch({ type: "set_form", form }); - }; - - const validateData = () => { - const errors = { ...initForm }; - let invalidForm = false; - Object.keys(state.form).forEach((field) => { - if (!state.form[field]) { - errors[field] = t("field_required"); - invalidForm = true; - } else if ( - field === "currentOccupancy" && - Number(state.form[field] < 0) - ) { - errors[field] = "Occupied cannot be negative"; - invalidForm = true; - } else if ( - field === "currentOccupancy" && - Number(state.form[field]) > Number(state.form.totalCapacity) - ) { - errors[field] = "Occupied must be less than or equal to total capacity"; - invalidForm = true; - } - if (field === "totalCapacity" && Number(state.form[field]) === 0) { - errors[field] = "Total capacity cannot be 0"; - invalidForm = true; - } else if (field === "totalCapacity" && Number(state.form[field]) < 0) { - errors[field] = "Total capacity cannot be negative"; - invalidForm = true; - } - }); - if (invalidForm) { - dispatch({ type: "set_error", errors }); - return false; - } - dispatch({ type: "set_error", errors }); - return true; - }; - - const handleSubmit = async (e: any, btnType = "Save") => { - e.preventDefault(); - const valid = validateData(); - if (valid) { - setIsLoading(true); - const bodyData = { - room_type: Number(state.form.bedType), - total_capacity: Number(state.form.totalCapacity), - current_capacity: Number(state.form.currentOccupancy), - }; - const { data } = await request( - id ? routes.updateCapacity : routes.createCapacity, - { - pathParams: { facilityId, ...(id ? { bed_id: id.toString() } : {}) }, - body: bodyData, - }, - ); - setIsLoading(false); - if (data) { - const updatedBedTypes = bedTypes.map((type) => { - return { - ...type, - disabled: data.room_type !== type.id ? type.disabled : true, - }; - }); - setBedTypes(updatedBedTypes); - // reset form - dispatch({ type: "set_form", form: initForm }); - // show success message - if (!id) { - Notification.Success({ - msg: "Bed capacity added successfully", - }); - } else { - Notification.Success({ - msg: "Bed capacity updated successfully", - }); - } - handleUpdate(); - } - if (btnType == "Save and Exit") handleClose(); - } - }; - - return ( -
- {isLoading ? ( -
-
- - Loading... -
-
- ) : ( -
- !type.disabled)} - optionLabel={(option) => option.text} - optionValue={(option) => option.id} - onChange={handleChange} - disabled={!!id} - error={state.errors.bedType} - /> -
- - -
- -
- - {headerText === "Add Bed Capacity" && ( - handleSubmit(e, "Save and Exit")} - label="Save Bed Capacity" - /> - )} - {!isLastOptionType && ( - handleSubmit(e)} - label={buttonText} - /> - )} -
-
- )} -
- ); -}; diff --git a/src/components/Facility/BedTypeCard.tsx b/src/components/Facility/BedTypeCard.tsx deleted file mode 100644 index 99244bd7eb1..00000000000 --- a/src/components/Facility/BedTypeCard.tsx +++ /dev/null @@ -1,181 +0,0 @@ -import { useEffect, useState } from "react"; - -import RecordMeta from "@/CAREUI/display/RecordMeta"; -import CareIcon from "@/CAREUI/icons/CareIcon"; - -import ButtonV2 from "@/components/Common/ButtonV2"; -import ConfirmDialog from "@/components/Common/ConfirmDialog"; -import DialogModal from "@/components/Common/Dialog"; -import { BedCapacity } from "@/components/Facility/BedCapacity"; - -import { NonReadOnlyUsers } from "@/Utils/AuthorizeFor"; -import * as Notification from "@/Utils/Notifications"; -import routes from "@/Utils/request/api"; -import request from "@/Utils/request/request"; - -interface BedTypeCardProps { - facilityId?: string; - bedCapacityId?: number; - room_type?: number; - label: string; - used: number; - total: number; - lastUpdated?: string; - removeBedType?: (bedTypeId: number | undefined) => void; - handleUpdate: () => void; -} - -export const BedTypeCard: React.FC = ({ - facilityId, - bedCapacityId, - room_type, - label, - used, - total, - lastUpdated, - removeBedType, - handleUpdate, -}) => { - const [isRefreshing, setIsRefreshing] = useState(false); - const [openDeleteDialog, setOpenDeleteDialog] = useState(false); - const [open, setOpen] = useState(false); - const [selectedId, setSelectedId] = useState(-1); - const handleDeleteSubmit = async () => { - if (room_type) { - const { res } = await request(routes.deleteCapacityBed, { - pathParams: { - facilityId: facilityId ?? "", - bed_id: room_type.toString(), - }, - }); - if (res?.status == 204) { - Notification.Success({ - msg: "Bed type deleted successfully", - }); - setOpenDeleteDialog(false); - if (removeBedType) { - removeBedType(bedCapacityId); - } - } - } - }; - - useEffect(() => { - if (isRefreshing) { - setTimeout(() => { - setIsRefreshing(false); - }, 500); - } - }, [isRefreshing]); - - const usedPercent = total ? Math.round((used / total) * 100) : 0; - - return ( -
-
-
- {label} -
- - {usedPercent}% - -
-
- {used} / {total} -
-
-
-
-
- -
- {" "} - Currently Occupied / Total Capacity{" "} -
- {facilityId ? ( -
-
- {lastUpdated && ( - - )} -
-
- { - setSelectedId(room_type || 0); - setOpen(true); - }} - authorizeFor={NonReadOnlyUsers} - className="tooltip bg-opacity/20 flex aspect-square h-7 w-7 flex-col items-center justify-center rounded bg-secondary-300 px-4 py-0" - variant="secondary" - ghost - > - - Edit - - - setOpenDeleteDialog(true)} - authorizeFor={NonReadOnlyUsers} - className="tooltip bg-opacity/10 flex aspect-square h-7 w-7 flex-col items-center justify-center rounded bg-red-100 px-4 py-0 hover:bg-red-200" - variant="secondary" - ghost - > - - Delete - -
-
- ) : ( -
- )} -
- setOpenDeleteDialog(false)} - title={`Delete ${label}?`} - description="You will not be able to access this bed type later." - action="Delete" - variant="danger" - onConfirm={handleDeleteSubmit} - /> - {open && ( - setOpen(false)} - title="Update Bed Capacity" - className="max-w-lg md:min-w-[650px]" - > - { - setOpen(false); - }} - handleUpdate={() => { - handleUpdate(); - setOpen(false); - }} - id={selectedId} - /> - - )} -
- ); -}; - -export default BedTypeCard; diff --git a/src/components/Facility/FacilityBedCapacity.tsx b/src/components/Facility/FacilityBedCapacity.tsx deleted file mode 100644 index cf0ac28a24a..00000000000 --- a/src/components/Facility/FacilityBedCapacity.tsx +++ /dev/null @@ -1,126 +0,0 @@ -import { useState } from "react"; -import { useTranslation } from "react-i18next"; - -import CareIcon from "@/CAREUI/icons/CareIcon"; - -import ButtonV2 from "@/components/Common/ButtonV2"; -import DialogModal from "@/components/Common/Dialog"; -import { BedCapacity } from "@/components/Facility/BedCapacity"; -import BedTypeCard from "@/components/Facility/BedTypeCard"; - -import { BED_TYPES } from "@/common/constants"; - -import { NonReadOnlyUsers } from "@/Utils/AuthorizeFor"; -import routes from "@/Utils/request/api"; -import useTanStackQueryInstead from "@/Utils/request/useQuery"; - -export const FacilityBedCapacity = (props: any) => { - const { t } = useTranslation(); - - const [bedCapacityModalOpen, setBedCapacityModalOpen] = useState(false); - - const capacityQuery = useTanStackQueryInstead(routes.getCapacity, { - pathParams: { facilityId: props.facilityId }, - }); - - let capacityList: any = null; - if (!capacityQuery.data || !capacityQuery.data.results.length) { - capacityList = ( -
- No Bed Types Found -
- ); - } else { - const totalBedCount = capacityQuery.data.results.reduce( - (acc, x) => acc + (x.total_capacity ? x.total_capacity : 0), - 0, - ); - const totalOccupiedBedCount = capacityQuery.data.results.reduce( - (acc, x) => acc + (x.current_capacity ? x.current_capacity : 0), - 0, - ); - - capacityList = ( -
- { - return; - }} - /> - {BED_TYPES.map((x) => { - const res = capacityQuery.data?.results.find((data) => { - return data.room_type === x; - }); - if ( - res && - res.current_capacity !== undefined && - res.total_capacity !== undefined - ) { - const removeCurrentBedType = (bedTypeId: number | undefined) => { - if (capacityQuery.data !== undefined) { - capacityQuery.data.results.filter((i) => i.id !== bedTypeId); - capacityQuery.refetch(); - } - }; - return ( - { - capacityQuery.refetch(); - }} - /> - ); - } - })} -
- ); - } - - return ( -
-
-
-
Bed Capacity
- setBedCapacityModalOpen(true)} - authorizeFor={NonReadOnlyUsers} - > - - Add More Bed Types - -
-
{capacityList}
-
- - {bedCapacityModalOpen && ( - setBedCapacityModalOpen(false)} - title="Add Bed Capacity" - className="max-w-md md:min-w-[600px]" - > - setBedCapacityModalOpen(false)} - handleUpdate={async () => { - capacityQuery.refetch(); - }} - /> - - )} -
- ); -}; diff --git a/src/components/Facility/FacilityCreate.tsx b/src/components/Facility/FacilityCreate.tsx index 37b98492c6f..84af22aabee 100644 --- a/src/components/Facility/FacilityCreate.tsx +++ b/src/components/Facility/FacilityCreate.tsx @@ -16,18 +16,8 @@ import ButtonV2, { Cancel, Submit } from "@/components/Common/ButtonV2"; import GLocationPicker from "@/components/Common/GLocationPicker"; import Loading from "@/components/Common/Loading"; import Page from "@/components/Common/Page"; -import Steps, { Step } from "@/components/Common/Steps"; -import { BedCapacity } from "@/components/Facility/BedCapacity"; -import BedTypeCard from "@/components/Facility/BedTypeCard"; import SpokeFacilityEditor from "@/components/Facility/SpokeFacilityEditor"; -import { StaffCapacity } from "@/components/Facility/StaffCapacity"; -import StaffCountCard from "@/components/Facility/StaffCountCard"; -import { - CapacityModal, - DistrictModel, - DoctorModal, - FacilityRequest, -} from "@/components/Facility/models"; +import { DistrictModel, FacilityRequest } from "@/components/Facility/models"; import { PhoneNumberValidator } from "@/components/Form/FieldValidators"; import PhoneNumberFormField from "@/components/Form/FormFields/PhoneNumberFormField"; import RadioFormField from "@/components/Form/FormFields/RadioFormField"; @@ -43,11 +33,7 @@ import { FormAction } from "@/components/Form/Utils"; import useAppHistory from "@/hooks/useAppHistory"; import useAuthUser from "@/hooks/useAuthUser"; -import { - BED_TYPES, - FACILITY_FEATURE_TYPES, - FACILITY_TYPES, -} from "@/common/constants"; +import { FACILITY_FEATURE_TYPES, FACILITY_TYPES } from "@/common/constants"; import { phonePreg, validateLatitude, @@ -86,14 +72,6 @@ type FacilityForm = { latitude: string; longitude: string; pincode: string; - oxygen_capacity?: number; - type_b_cylinders?: number; - type_c_cylinders?: number; - type_d_cylinders?: number; - expected_oxygen_requirement?: number; - expected_type_b_cylinders?: number; - expected_type_c_cylinders?: number; - expected_type_d_cylinders?: number; }; const initForm: FacilityForm = { @@ -110,14 +88,6 @@ const initForm: FacilityForm = { latitude: "", longitude: "", pincode: "", - oxygen_capacity: undefined, - type_b_cylinders: undefined, - type_c_cylinders: undefined, - type_d_cylinders: undefined, - expected_oxygen_requirement: undefined, - expected_type_b_cylinders: undefined, - expected_type_c_cylinders: undefined, - expected_type_d_cylinders: undefined, }; const initError: Record = Object.assign( @@ -152,13 +122,8 @@ export const FacilityCreate = (props: FacilityProps) => { initialState, ); const [isLoading, setIsLoading] = useState(false); - const [currentStep, setCurrentStep] = useState(1); - const [createdFacilityId, setCreatedFacilityId] = useState(""); + const [showAutoFilledPincode, setShowAutoFilledPincode] = useState(false); - const [capacityData, setCapacityData] = useState>([]); - const [doctorData, setDoctorData] = useState>([]); - const [bedCapacityKey, setBedCapacityKey] = useState(0); - const [docCapacityKey, setDocCapacityKey] = useState(0); const [stateId, setStateId] = useState(); const [districtId, setDistrictId] = useState(); const [localBodyId, setLocalBodyId] = useState(); @@ -200,43 +165,6 @@ export const FacilityCreate = (props: FacilityProps) => { prefetch: !!districtId, }); - const getSteps = (): Step[] => { - return [ - { - id: 1, - name: "Facility details", - onClick: () => { - setCurrentStep(1); - }, - status: currentStep === 1 ? "current" : "complete", - disabled: currentStep > 1, - }, - { - id: 2, - name: "Bed Capacity", - onClick: () => { - setCurrentStep(2); - }, - status: - currentStep === 2 - ? "current" - : currentStep > 2 - ? "complete" - : "upcoming", - disabled: createdFacilityId == "", - }, - { - id: 3, - name: "Staff Capacity", - onClick: () => { - setCurrentStep(3); - }, - disabled: createdFacilityId == "", - status: currentStep === 3 ? "current" : "upcoming", - }, - ]; - }; - const { data: wardData, loading: isWardLoading } = useTanStackQueryInstead( routes.getWardByLocalBody, { @@ -276,14 +204,6 @@ export const FacilityCreate = (props: FacilityProps) => { longitude: data.longitude ? parseFloat(data.longitude).toFixed(7) : "", - type_b_cylinders: data.type_b_cylinders, - type_c_cylinders: data.type_c_cylinders, - type_d_cylinders: data.type_d_cylinders, - expected_type_b_cylinders: data.expected_type_b_cylinders, - expected_type_c_cylinders: data.expected_type_c_cylinders, - expected_type_d_cylinders: data.expected_type_d_cylinders, - expected_oxygen_requirement: data.expected_oxygen_requirement, - oxygen_capacity: data.oxygen_capacity, }; dispatch({ type: "set_form", form: formData }); setStateId(data.state); @@ -469,32 +389,6 @@ export const FacilityCreate = (props: FacilityProps) => { latitude: state.form.latitude, longitude: state.form.longitude, phone_number: parsePhoneNumber(state.form.phone_number), - oxygen_capacity: state.form.oxygen_capacity - ? state.form.oxygen_capacity - : 0, - type_b_cylinders: state.form.type_b_cylinders - ? state.form.type_b_cylinders - : 0, - type_c_cylinders: state.form.type_c_cylinders - ? state.form.type_c_cylinders - : 0, - type_d_cylinders: state.form.type_d_cylinders - ? state.form.type_d_cylinders - : 0, - expected_oxygen_requirement: state.form.expected_oxygen_requirement - ? state.form.expected_oxygen_requirement - : 0, - expected_type_b_cylinders: state.form.expected_type_b_cylinders - ? state.form.expected_type_b_cylinders - : 0, - - expected_type_c_cylinders: state.form.expected_type_c_cylinders - ? state.form.expected_type_c_cylinders - : 0, - - expected_type_d_cylinders: state.form.expected_type_d_cylinders - ? state.form.expected_type_d_cylinders - : 0, }; const { res, data: requestData } = facilityId @@ -515,14 +409,12 @@ export const FacilityCreate = (props: FacilityProps) => { Notification.Success({ msg: "Facility added successfully", }); - setCreatedFacilityId(String(id)); - setCurrentStep(2); } else { Notification.Success({ msg: "Facility updated successfully", }); - navigate(`/facility/${facilityId}`); } + navigate(`/facility/${id}`); } setIsLoading(false); } @@ -532,112 +424,6 @@ export const FacilityCreate = (props: FacilityProps) => { return ; } - let capacityList: any = null; - let totalBedCount = 0; - let totalOccupiedBedCount = 0; - - if (!capacityData || !capacityData.length) { - capacityList = ( -
- {t("no_bed_types_found")} -
- ); - } else { - capacityData.forEach((x) => { - totalBedCount += x.total_capacity ? x.total_capacity : 0; - totalOccupiedBedCount += x.current_capacity ? x.current_capacity : 0; - }); - - capacityList = ( -
- { - return; - }} - /> - {BED_TYPES.map((x) => { - const res = capacityData.find((data) => { - return data.room_type === x; - }); - if (res) { - const removeCurrentBedType = (bedTypeId: number | undefined) => { - setCapacityData((state) => - state.filter((i) => i.id !== bedTypeId), - ); - setBedCapacityKey((bedCapacityKey) => bedCapacityKey + 1); - }; - return ( - { - const { res, data } = await request(routes.getCapacity, { - pathParams: { facilityId: createdFacilityId }, - }); - if (res?.ok && data) { - setCapacityData(data.results); - } - }} - /> - ); - } - })} -
- ); - } - let doctorList: any = null; - if (!doctorData || !doctorData.length) { - doctorList = ( -
- {t("no_staff")} -
- ); - } else { - doctorList = ( -
- {doctorData.map((data: DoctorModal) => { - const removeCurrentDoctorData = (doctorId: number | undefined) => { - setDoctorData((state) => - state.filter((i: DoctorModal) => i.id !== doctorId), - ); - setDocCapacityKey((docCapacityKey) => docCapacityKey + 1); - }; - - return ( - { - const { res, data } = await request(routes.listDoctor, { - pathParams: { facilityId: createdFacilityId }, - }); - if (res?.ok && data) { - setDoctorData(data.results); - } - }} - {...data} - removeDoctor={removeCurrentDoctorData} - /> - ); - })} -
- ); - } - const field = (name: string) => { return { name, @@ -649,370 +435,210 @@ export const FacilityCreate = (props: FacilityProps) => { }; }; - switch (currentStep) { - case 3: - return ( - - -
- { - navigate(`/facility/${createdFacilityId}`); - }} - handleUpdate={async () => { - const { res, data } = await request(routes.listDoctor, { - pathParams: { facilityId: createdFacilityId }, - }); - if (res?.ok && data) { - setDoctorData(data.results); - } + return ( + + +
+
handleSubmit(e)}> + { + dispatch({ type: "set_state", state: newState }); + setStateId(newState.form.state); + setDistrictId(newState.form.district); + setLocalBodyId(newState.form.local_body); }} + formData={state.form} /> -
-
-
-
{t("staff_list")}
-
-
- {doctorList} -
-
-
- ); - case 2: - return ( - - -
- { - setCurrentStep(3); - }} - handleUpdate={async () => { - const { res, data } = await request(routes.getCapacity, { - pathParams: { facilityId: createdFacilityId }, - }); - if (res?.ok && data) { - setCapacityData(data.results); - } - }} - /> -
-
-
-
- {t("bed_capacity")} -
-
-
{capacityList}
-
-
- ); - case 1: - default: - return ( - - {!facilityId && } - -
- handleSubmit(e)}> - { - dispatch({ type: "set_state", state: newState }); - setStateId(newState.form.state); - setDistrictId(newState.form.district); - setLocalBodyId(newState.form.local_body); - }} - formData={state.form} +
+ o.text} + optionValue={(o) => o.text} + /> + + o.name} + optionValue={(o) => o.id} + /> +
+ -
- o.text} - optionValue={(o) => o.text} - /> - - o.name} - optionValue={(o) => o.id} - /> -
- - {showAutoFilledPincode && ( -
- - - State and district auto-filled from pincode - -
- )} + {showAutoFilledPincode && ( +
+ + + State and district auto-filled from pincode +
- o.name} - optionValue={(o) => o.id} - onChange={(event) => { - handleChange(event); - if (!event) return; - setStateId(event.value); - }} - /> - o.name} - optionValue={(o) => o.id} - onChange={(event) => { - handleChange(event); - if (!event) return; - setDistrictId(event.value); - }} - /> - o.name} - optionValue={(o) => o.id} - onChange={(event) => { - handleChange(event); - if (!event) return; - setLocalBodyId(event.value); - }} - /> - { - return { - id: e.id, - name: e.number + ": " + e.name, - }; - })} - optionLabel={(o) => o.name} - optionValue={(o) => o.id} - /> - - + o.name} + optionValue={(o) => o.id} + onChange={(event) => { + handleChange(event); + if (!event) return; + setStateId(event.value); + }} + /> + o.name} + optionValue={(o) => o.id} + onChange={(event) => { + handleChange(event); + if (!event) return; + setDistrictId(event.value); + }} + /> + o.name} + optionValue={(o) => o.id} + onChange={(event) => { + handleChange(event); + if (!event) return; + setLocalBodyId(event.value); + }} + /> + { + return { + id: e.id, + name: e.number + ": " + e.name, + }; + })} + optionLabel={(o) => o.name} + optionValue={(o) => o.id} + /> + + + {facilityId && ( +
+

{t("spokes")}

+ - {facilityId && ( -
-

{t("spokes")}

- -
- )} -
- } - min={0} - /> - } - label={t("expected_burn_rate")} - min={0} - /> - - } - min={0} - /> - } - min={0} - /> - } - min={0} - /> - } - label={t("expected_burn_rate")} - min={0} - /> - } - min={0} - /> - } - min={0} - /> -
- - {careConfig.kasp.enabled && ( - (o ? "Yes" : "No")} - optionValue={(o) => String(o)} - /> - )}
+ )} + {careConfig.kasp.enabled && ( + (o ? "Yes" : "No")} + optionValue={(o) => String(o)} + /> + )} +
-
- +
+ -
- - <> - - - - - Select location from map - - - - - - - null} - handleOnSelectCurrentLocation={ - handleSelectCurrentLocation - } - /> - - - - -
- } - placeholder="Longitude" - /> -
-
- goBack()} /> - -
- +
+ + <> + + + + + Select location from map + + + + + + + null} + handleOnSelectCurrentLocation={ + handleSelectCurrentLocation + } + /> + + + + +
+ } + placeholder="Longitude" + />
- - - ); - } -}; - -const FieldUnit = ({ unit }: { unit: string }) => { - return

{unit}

; +
+ goBack()} /> + +
+ +
+ + + ); }; diff --git a/src/components/Facility/FacilityHome.tsx b/src/components/Facility/FacilityHome.tsx index cf671a51530..1808a1087ee 100644 --- a/src/components/Facility/FacilityHome.tsx +++ b/src/components/Facility/FacilityHome.tsx @@ -22,11 +22,7 @@ import Loading from "@/components/Common/Loading"; import { LocationSelect } from "@/components/Common/LocationSelect"; import DropdownMenu, { DropdownItem } from "@/components/Common/Menu"; import Page from "@/components/Common/Page"; -import Table from "@/components/Common/Table"; -import { FacilityBedCapacity } from "@/components/Facility/FacilityBedCapacity"; import FacilityBlock from "@/components/Facility/FacilityBlock"; -import { FacilityHomeTriage } from "@/components/Facility/FacilityHomeTriage"; -import { FacilityStaffList } from "@/components/Facility/FacilityStaffList"; import { FieldLabel } from "@/components/Form/FormFields/FormField"; import useAuthUser from "@/hooks/useAuthUser"; @@ -215,7 +211,10 @@ export const FacilityHome = ({ facilityId }: Props) => { onClick={() => setEditCoverImage(true)} className="md:mr-2 lg:mr-6 lg:h-80 lg:w-80" /> -
+

@@ -488,44 +487,6 @@ export const FacilityHome = ({ facilityId }: Props) => {

- - - -
-

{t("oxygen_information")}

-
- - - - - ); }; diff --git a/src/components/Facility/FacilityHomeTriage.tsx b/src/components/Facility/FacilityHomeTriage.tsx deleted file mode 100644 index 25d2e0a7334..00000000000 --- a/src/components/Facility/FacilityHomeTriage.tsx +++ /dev/null @@ -1,89 +0,0 @@ -import { navigate } from "raviger"; - -import CareIcon from "@/CAREUI/icons/CareIcon"; - -import ButtonV2 from "@/components/Common/ButtonV2"; -import Table from "@/components/Common/Table"; - -import { NonReadOnlyUsers } from "@/Utils/AuthorizeFor"; -import routes from "@/Utils/request/api"; -import useTanStackQueryInstead from "@/Utils/request/useQuery"; - -interface FacilityHomeTriageProps { - facilityId: string; -} - -export function FacilityHomeTriage({ facilityId }: FacilityHomeTriageProps) { - const { data } = useTanStackQueryInstead(routes.getTriage, { - pathParams: { facilityId }, - }); - - const tableRows = - data?.results?.map((result) => [ - String(result.entry_date), - String(result.num_patients_visited), - String(result.num_patients_home_quarantine), - String(result.num_patients_isolation), - String(result.num_patient_referred), - String(result.num_patient_confirmed_positive), - navigate(`/facility/${facilityId}/triage/${result.id}`)} - authorizeFor={NonReadOnlyUsers} - > - Edit - , - ]) ?? []; - - const tableHeadings = [ - "Date", - "Total Triaged", - "Advised Home Quarantine", - "Suspects Isolated", - "Referred", - "Confirmed positives", - "Actions", - ]; - - return ( -
-
-
-
Corona Triage
- navigate(`/facility/${facilityId}/triage`)} - authorizeFor={NonReadOnlyUsers} - > - - Add Triage - -
- -
-
- - {tableRows.length === 0 && ( - <> -
-
- No Data Found -
- - )} - - - - ); -} diff --git a/src/components/Facility/FacilityList.tsx b/src/components/Facility/FacilityList.tsx index 0c1164649ca..f62f630dcaa 100644 --- a/src/components/Facility/FacilityList.tsx +++ b/src/components/Facility/FacilityList.tsx @@ -157,30 +157,17 @@ export const FacilityList = () => { options={
advancedFilter.setShow(true)} /> - +
+ +
} > diff --git a/src/components/Facility/FacilityStaffList.tsx b/src/components/Facility/FacilityStaffList.tsx deleted file mode 100644 index 5a3cd512ba9..00000000000 --- a/src/components/Facility/FacilityStaffList.tsx +++ /dev/null @@ -1,138 +0,0 @@ -import { useState } from "react"; -import { useTranslation } from "react-i18next"; - -import CareIcon from "@/CAREUI/icons/CareIcon"; - -import ButtonV2 from "@/components/Common/ButtonV2"; -import DialogModal from "@/components/Common/Dialog"; -import Pagination from "@/components/Common/Pagination"; -import { StaffCapacity } from "@/components/Facility/StaffCapacity"; -import DoctorsCountCard from "@/components/Facility/StaffCountCard"; -import { DoctorModal } from "@/components/Facility/models"; -import { DoctorIcon } from "@/components/TeleIcu/Icons/DoctorIcon"; - -import useFilters from "@/hooks/useFilters"; - -import { DOCTOR_SPECIALIZATION } from "@/common/constants"; - -import { NonReadOnlyUsers } from "@/Utils/AuthorizeFor"; -import routes from "@/Utils/request/api"; -import useTanStackQueryInstead from "@/Utils/request/useQuery"; - -export const FacilityStaffList = (props: any) => { - const { t } = useTranslation(); - const [doctorCapacityModalOpen, setDoctorCapacityModalOpen] = useState(false); - const { qParams, resultsPerPage, updatePage } = useFilters({ limit: 15 }); - const [totalDoctors, setTotalDoctors] = useState(0); - - const { data: doctorsList, refetch } = useTanStackQueryInstead( - routes.listDoctor, - { - pathParams: { facilityId: props.facilityId }, - query: { - limit: resultsPerPage, - offset: (qParams.page - 1) * resultsPerPage, - }, - onResponse: ({ res, data }) => { - if (res?.ok && data) { - let totalCount = 0; - data.results.map((doctor: DoctorModal) => { - if (doctor.count) { - totalCount += doctor.count; - } - }); - setTotalDoctors(totalCount); - } - }, - }, - ); - - let doctorList: any = null; - if (!doctorsList || !doctorsList.results.length) { - doctorList = ( -
- {t("no_staff")} -
- ); - } else { - doctorList = ( -
-
-
-
-
- -
-
-
- {t("total_staff")} -
-

{totalDoctors}

-
-
-
-
- - {doctorsList.results.map((data: DoctorModal) => { - return ( - { - refetch(); - }} - {...data} - removeDoctor={() => refetch()} - /> - ); - })} -
- ); - } - - return ( -
-
-
-
Staff Capacity
- setDoctorCapacityModalOpen(true)} - disabled={doctorList.length === DOCTOR_SPECIALIZATION.length} - authorizeFor={NonReadOnlyUsers} - > - - Add Staff Types - -
-
- {doctorList} -
-
- - {doctorCapacityModalOpen && ( - setDoctorCapacityModalOpen(false)} - title="Add Staff Capacity" - className="max-w-md md:min-w-[600px]" - > - setDoctorCapacityModalOpen(false)} - handleUpdate={async () => { - refetch(); - }} - /> - - )} - updatePage(page)} - /> -
- ); -}; diff --git a/src/components/Facility/StaffCapacity.tsx b/src/components/Facility/StaffCapacity.tsx deleted file mode 100644 index 53235dd68d0..00000000000 --- a/src/components/Facility/StaffCapacity.tsx +++ /dev/null @@ -1,241 +0,0 @@ -import { useReducer, useState } from "react"; -import { useTranslation } from "react-i18next"; - -import ButtonV2, { Cancel } from "@/components/Common/ButtonV2"; -import { DoctorModal } from "@/components/Facility/models"; -import { - FieldErrorText, - FieldLabel, -} from "@/components/Form/FormFields/FormField"; -import TextFormField from "@/components/Form/FormFields/TextFormField"; -import { FieldChangeEventHandler } from "@/components/Form/FormFields/Utils"; -import SelectMenuV2 from "@/components/Form/SelectMenuV2"; - -import { DOCTOR_SPECIALIZATION } from "@/common/constants"; - -import * as Notification from "@/Utils/Notifications"; -import routes from "@/Utils/request/api"; -import request from "@/Utils/request/request"; -import useTanStackQueryInstead from "@/Utils/request/useQuery"; - -interface DoctorCapacityProps extends DoctorModal { - facilityId: string; - handleClose: () => void; - handleUpdate: () => void; - className?: string; - id?: number; -} - -const initForm: any = { - area: "", - count: "", -}; - -const initialState = { - form: { ...initForm }, - errors: { ...initForm }, -}; - -const doctorCapacityReducer = (state = initialState, action: any) => { - switch (action.type) { - case "set_form": { - return { - ...state, - form: action.form, - }; - } - case "set_error": { - return { - ...state, - errors: action.errors, - }; - } - default: - return state; - } -}; - -const getAllowedDoctorTypes = (existing?: DoctorModal[]) => { - if (!existing) return [...DOCTOR_SPECIALIZATION]; - - return DOCTOR_SPECIALIZATION.map((specialization) => { - const disabled = existing.some((i) => i.area === specialization.id); - return { ...specialization, disabled }; - }); -}; - -export const StaffCapacity = (props: DoctorCapacityProps) => { - const { t } = useTranslation(); - const { facilityId, handleClose, handleUpdate, className, id } = props; - const [state, dispatch] = useReducer(doctorCapacityReducer, initialState); - const [isLoading, setIsLoading] = useState(false); - - const specializationsQuery = useTanStackQueryInstead(routes.listDoctor, { - pathParams: { facilityId }, - query: { - limit: DOCTOR_SPECIALIZATION.length - 1, - }, - }); - - const { loading } = useTanStackQueryInstead(routes.getDoctor, { - pathParams: { facilityId, id: `${id}` }, - prefetch: !!id, - onResponse: ({ data }) => { - if (!data) return; - dispatch({ - type: "set_form", - form: { area: data.area, count: data.count }, - }); - }, - }); - - const doctorTypes = getAllowedDoctorTypes(specializationsQuery.data?.results); - - const isLastOptionType = - doctorTypes.filter((i) => i.disabled).length === - DOCTOR_SPECIALIZATION.length - 1; - - const headerText = !id ? "Add Staff Capacity" : "Edit Staff Capacity"; - const buttonText = !id - ? `Save ${!isLastOptionType ? "& Add More" : "Staff Capacity"}` - : "Update Staff Capacity"; - - const validateData = () => { - const errors = { ...initForm }; - let invalidForm = false; - Object.keys(state.form).forEach((field) => { - if (!state.form[field]) { - errors[field] = t("field_required"); - invalidForm = true; - } - if (field === "count" && state.form[field] < 0) { - errors[field] = "Staff count cannot be negative"; - invalidForm = true; - } - }); - if (invalidForm) { - dispatch({ type: "set_error", errors }); - return false; - } - dispatch({ type: "set_error", errors }); - return true; - }; - - const handleFormFieldChange: FieldChangeEventHandler = (event) => { - const form = { ...state.form, [event.name]: event.value }; - dispatch({ type: "set_form", form }); - }; - - const handleSubmit = async (e: any) => { - const submitBtnID = e.currentTarget?.id; - e.preventDefault(); - const valid = validateData(); - if (valid) { - setIsLoading(true); - const data = { - area: Number(state.form.area), - count: Number(state.form.count), - }; - const { res } = await (id - ? request(routes.updateDoctor, { - pathParams: { facilityId, id: `${id}` }, - body: data, - }) - : request(routes.createDoctor, { - pathParams: { facilityId }, - body: data, - })); - setIsLoading(false); - if (res?.ok) { - specializationsQuery.refetch(); - dispatch({ type: "set_form", form: initForm }); - if (!id) { - Notification.Success({ msg: "Staff count added successfully" }); - } else { - Notification.Success({ msg: "Staff count updated successfully" }); - } - } - handleUpdate(); - - if (submitBtnID === "save-and-exit") handleClose(); - } - }; - - return ( -
- {isLoading || loading || specializationsQuery.loading ? ( -
-
- - Loading... -
-
- ) : ( -
-
- - Staff Type - - type.id == state.form.area)?.id} - options={ - id ? doctorTypes : doctorTypes.filter((type) => !type.disabled) - } - optionLabel={(option) => option.text} - optionValue={(option) => option.id} - requiredError={state.errors.area.length !== 0} - onChange={(e) => - handleFormFieldChange({ - name: "area", - value: e || "", - }) - } - disabled={!!id} - /> - -
-
- -
-
- handleClose()} /> - {!isLastOptionType && headerText === "Add Staff Capacity" && ( - - Save Staff Capacity - - )} - - {buttonText} - -
-
- )} -
- ); -}; diff --git a/src/components/Facility/StaffCountCard.tsx b/src/components/Facility/StaffCountCard.tsx deleted file mode 100644 index 0c0984172b1..00000000000 --- a/src/components/Facility/StaffCountCard.tsx +++ /dev/null @@ -1,118 +0,0 @@ -import { useState } from "react"; - -import ButtonV2 from "@/components/Common/ButtonV2"; -import ConfirmDialog from "@/components/Common/ConfirmDialog"; -import DialogModal from "@/components/Common/Dialog"; -import { StaffCapacity } from "@/components/Facility/StaffCapacity"; -import { DoctorModal } from "@/components/Facility/models"; -import { DoctorIcon } from "@/components/TeleIcu/Icons/DoctorIcon"; - -import { DOCTOR_SPECIALIZATION } from "@/common/constants"; - -import { NonReadOnlyUsers } from "@/Utils/AuthorizeFor"; -import * as Notification from "@/Utils/Notifications"; -import routes from "@/Utils/request/api"; -import request from "@/Utils/request/request"; - -interface DoctorsCountProps extends DoctorModal { - facilityId: string; - removeDoctor: (doctorId: number | undefined) => void; - handleUpdate: () => void; -} - -const StaffCountCard = (props: DoctorsCountProps) => { - const specialization = DOCTOR_SPECIALIZATION.find((i) => i.id === props.area); - const [openDeleteDialog, setOpenDeleteDialog] = useState(false); - const [open, setOpen] = useState(false); - const [selectedId, setSelectedId] = useState(-1); - - const handleDeleteSubmit = async () => { - if (!props.area) return; - - const { res } = await request(routes.deleteDoctor, { - pathParams: { facilityId: props.facilityId, area: `${props.area}` }, - }); - - if (res?.ok) { - props.removeDoctor(props.id); - Notification.Success({ - msg: "Staff specialization type deleted successfully", - }); - } - }; - - const handleDeleteClose = () => { - setOpenDeleteDialog(false); - }; - - return ( -
-
-
-
- -
-
-
- {specialization?.text} -
-

{props.count}

-
-
-
- { - setSelectedId(props.area || 0); - setOpen(true); - }} - authorizeFor={NonReadOnlyUsers} - > - Edit - - setOpenDeleteDialog(true)} - authorizeFor={NonReadOnlyUsers} - > - Delete - -
- -
- {open && ( - setOpen(false)} - title="Update Staff Capacity" - > - { - setOpen(false); - }} - handleUpdate={() => { - props.handleUpdate(); - setOpen(false); - }} - id={selectedId} - /> - - )} -
- ); -}; - -export default StaffCountCard; diff --git a/src/components/Facility/TriageForm.tsx b/src/components/Facility/TriageForm.tsx deleted file mode 100644 index 607adb0172f..00000000000 --- a/src/components/Facility/TriageForm.tsx +++ /dev/null @@ -1,321 +0,0 @@ -import dayjs from "dayjs"; -import { useReducer, useState } from "react"; -import { useTranslation } from "react-i18next"; - -import Card from "@/CAREUI/display/Card"; -import CareIcon from "@/CAREUI/icons/CareIcon"; - -import { Cancel, Submit } from "@/components/Common/ButtonV2"; -import ConfirmDialog from "@/components/Common/ConfirmDialog"; -import Loading from "@/components/Common/Loading"; -import Page from "@/components/Common/Page"; -import { PatientStatsModel } from "@/components/Facility/models"; -import DateFormField from "@/components/Form/FormFields/DateFormField"; -import TextFormField from "@/components/Form/FormFields/TextFormField"; -import { FieldChangeEvent } from "@/components/Form/FormFields/Utils"; - -import useAppHistory from "@/hooks/useAppHistory"; - -import * as Notification from "@/Utils/Notifications"; -import routes from "@/Utils/request/api"; -import request from "@/Utils/request/request"; -import useTanStackQueryInstead from "@/Utils/request/useQuery"; -import { dateQueryString, scrollTo } from "@/Utils/utils"; - -interface Props extends PatientStatsModel { - facilityId: string; - id?: string; -} - -const initForm: any = { - entry_date: null, - num_patients_visited: "", - num_patients_home_quarantine: "", - num_patients_isolation: "", - num_patient_referred: "", - num_patient_confirmed_positive: "", -}; - -const initialState = { - form: { ...initForm }, - errors: { ...initForm }, -}; - -const triageFormReducer = (state = initialState, action: any) => { - switch (action.type) { - case "set_form": { - return { - ...state, - form: action.form, - }; - } - case "set_error": { - return { - ...state, - errors: action.errors, - }; - } - default: - return state; - } -}; - -export const TriageForm = ({ facilityId, id }: Props) => { - const { t } = useTranslation(); - const { goBack } = useAppHistory(); - const [state, dispatch] = useReducer(triageFormReducer, initialState); - const [isLoading, setIsLoading] = useState(false); - const [openModalForExistingTriage, setOpenModalForExistingTriage] = - useState(false); - const headerText = !id ? "Add Triage" : "Edit Triage"; - const buttonText = !id ? "Save Triage" : "Update Triage"; - - const triageDetailsQuery = useTanStackQueryInstead(routes.getTriageDetails, { - pathParams: { facilityId, id: id! }, - prefetch: !!id, - onResponse: ({ data }) => { - if (!data) return; - dispatch({ - type: "set_form", - form: { - ...data, - entry_date: data.entry_date ? dayjs(data.entry_date).toDate() : null, - }, - }); - }, - }); - - const patientStatsQuery = useTanStackQueryInstead(routes.getTriage, { - pathParams: { facilityId }, - }); - - const patientStatsData = patientStatsQuery.data?.results ?? []; - - const facilityQuery = useTanStackQueryInstead(routes.getAnyFacility, { - pathParams: { id: facilityId }, - }); - const facilityName = facilityQuery.data?.name ?? ""; - - const validateForm = () => { - const errors = { ...initForm }; - let invalidForm = false; - Object.keys(state.form).forEach((field, _) => { - switch (field) { - case "entry_date": - if (!state.form[field]) { - errors[field] = t("field_required"); - invalidForm = true; - } - return; - case "num_patients_visited": - case "num_patients_home_quarantine": - case "num_patients_isolation": - case "num_patient_referred": - case "num_patient_confirmed_positive": - if (state.form[field] != null && state.form[field] < 0) { - errors[field] = "Value must be greater than or equal to 0"; - invalidForm = true; - } - return; - - default: - return; - } - }); - if (invalidForm) { - dispatch({ type: "set_error", errors }); - const firstError = Object.keys(errors).find((e) => errors[e]); - if (firstError) { - scrollTo(firstError); - } - return false; - } - dispatch({ type: "set_error", errors }); - return true; - }; - const isTriageExist = (data: any) => { - if ( - patientStatsData.filter( - (triageData) => triageData.entry_date === data.entry_date, - ).length === 1 - ) { - return true; - } - return false; - }; - - const handleSubmit = async () => { - setOpenModalForExistingTriage(false); - const validForm = validateForm(); - if (validForm) { - const data = { - entry_date: dateQueryString(state.form.entry_date), - num_patients_visited: Number(state.form.num_patients_visited), - num_patients_home_quarantine: Number( - state.form.num_patients_home_quarantine, - ), - num_patients_isolation: Number(state.form.num_patients_isolation), - num_patient_referred: Number(state.form.num_patient_referred), - num_patient_confirmed_positive: Number( - state.form.num_patient_confirmed_positive, - ), - }; - //proceed if the triage does not exist or proceed has allowed to proceed after seeing the modal or it's a edit feature of the same date - if ( - !isTriageExist(data) || - openModalForExistingTriage || - buttonText === "Update Triage" - ) { - setOpenModalForExistingTriage(false); - setIsLoading(true); - const { res } = await request(routes.createTriage, { - pathParams: { facilityId }, - body: data, - }); - setIsLoading(false); - if (res?.ok) { - dispatch({ type: "set_form", form: initForm }); - if (id) { - Notification.Success({ msg: "Triage updated successfully" }); - } else { - Notification.Success({ msg: "Triage created successfully" }); - } - goBack(); - } - } else { - setOpenModalForExistingTriage(true); - } - } - }; - - const handleFormFieldChange = (event: FieldChangeEvent) => { - dispatch({ - type: "set_form", - form: { ...state.form, [event.name]: event.value }, - }); - }; - - if ( - isLoading || - facilityQuery.loading || - triageDetailsQuery.loading || - patientStatsQuery.loading - ) { - return ; - } - - return ( -
- - - -

A Triage already exist on this date

-
- } - description="A Triage already exist on this date, If you wish to proceed then the existing triage will be over - written!" - variant="danger" - show={openModalForExistingTriage} - onClose={() => setOpenModalForExistingTriage(false)} - className="w-[48rem]" - action="Proceed" - onConfirm={handleSubmit} - /> - -
- -
{ - e.preventDefault(); - handleSubmit(); - }} - > -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
-
- goBack()} /> - -
- -
-
- - - ); -}; diff --git a/src/components/Facility/models.tsx b/src/components/Facility/models.tsx index a984efe6283..d25258be12d 100644 --- a/src/components/Facility/models.tsx +++ b/src/components/Facility/models.tsx @@ -67,16 +67,8 @@ export interface FacilityModel { latitude: number; longitude: number; }; - oxygen_capacity?: number; phone_number?: string; - type_b_cylinders?: number; - type_c_cylinders?: number; - type_d_cylinders?: number; middleware_address?: string; - expected_type_b_cylinders?: number; - expected_type_c_cylinders?: number; - expected_type_d_cylinders?: number; - expected_oxygen_requirement?: number; local_body_object?: LocalBodyModel; district_object?: DistrictModel; state_object?: StateModel; @@ -115,20 +107,6 @@ export interface FacilitySpokeRequest { export interface FacilitySpokeErrors {} -export interface CapacityModal { - id?: number; - room_type?: number; - modified_date?: any; - total_capacity?: number; - current_capacity?: number; -} - -export interface DoctorModal { - id?: number; - area?: number; - count?: number; -} - export interface OptionsType { id: number; text: string; @@ -225,17 +203,6 @@ export interface ConsultationModel { has_consents?: (typeof CONSENT_TYPE_CHOICES)[number]["id"][]; } -export interface PatientStatsModel { - id?: string; - entryDate?: string; - num_patients_visited?: number; - num_patients_home_quarantine?: number; - num_patients_isolation?: number; - num_patient_referred?: number; - entry_date?: string; - num_patient_confirmed_positive?: number; -} - export interface DupPatientModel { id: number; gender: string; diff --git a/src/components/Patient/PatientRegister.tsx b/src/components/Patient/PatientRegister.tsx index eb0594baa82..daca5e90a21 100644 --- a/src/components/Patient/PatientRegister.tsx +++ b/src/components/Patient/PatientRegister.tsx @@ -14,13 +14,13 @@ import Loading from "@/components/Common/Loading"; import PageTitle from "@/components/Common/PageTitle"; import Spinner from "@/components/Common/Spinner"; import Error404 from "@/components/ErrorPages/404"; -import { ILocalBodies } from "@/components/ExternalResult/models"; import DuplicatePatientDialog from "@/components/Facility/DuplicatePatientDialog"; import TransferPatientDialog from "@/components/Facility/TransferPatientDialog"; import { DistrictModel, DupPatientModel, FacilityModel, + LocalBodyModel, WardModel, } from "@/components/Facility/models"; import { @@ -205,7 +205,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { const [isLocalbodyLoading, setIsLocalbodyLoading] = useState(false); const [isWardLoading, setIsWardLoading] = useState(false); const [districts, setDistricts] = useState([]); - const [localBody, setLocalBody] = useState([]); + const [localBody, setLocalBody] = useState([]); const [ward, setWard] = useState([]); const [ageInputType, setAgeInputType] = useState< "date_of_birth" | "age" | "alert_for_age" From f84c7df63cd4f89eabceabb6a82003733f5f6997 Mon Sep 17 00:00:00 2001 From: G O Ashwin Praveen <143274955+ashwinpraveengo@users.noreply.github.com> Date: Mon, 16 Dec 2024 11:06:00 +0530 Subject: [PATCH 2/6] Fix alignment issue in timestamp in Created and Last Modified for Patient Dashboard (#9410) --- src/components/Facility/ConsultationDetails/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Facility/ConsultationDetails/index.tsx b/src/components/Facility/ConsultationDetails/index.tsx index 11f24f92968..62f8afdae80 100644 --- a/src/components/Facility/ConsultationDetails/index.tsx +++ b/src/components/Facility/ConsultationDetails/index.tsx @@ -331,7 +331,7 @@ export const ConsultationDetails = (props: any) => {
-
+
Created:   {
-
+
Last Modified:   Date: Mon, 16 Dec 2024 11:09:13 +0530 Subject: [PATCH 3/6] Fix phone number field overflow in search component on firefox (#9378) --- src/components/Form/FormFields/PhoneNumberFormField.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/Form/FormFields/PhoneNumberFormField.tsx b/src/components/Form/FormFields/PhoneNumberFormField.tsx index 8b6566de8f7..72a3e0c3076 100644 --- a/src/components/Form/FormFields/PhoneNumberFormField.tsx +++ b/src/components/Form/FormFields/PhoneNumberFormField.tsx @@ -3,6 +3,8 @@ import { useCallback, useEffect, useMemo, useState } from "react"; import React from "react"; import { useTranslation } from "react-i18next"; +import { cn } from "@/lib/utils"; + import CareIcon from "@/CAREUI/icons/CareIcon"; import { @@ -20,7 +22,6 @@ import phoneCodesJson from "@/common/static/countryPhoneAndFlags.json"; import { CountryData, - classNames, formatPhoneNumber as formatPhoneNumberUtil, getCountryCode, humanizeStrings, @@ -138,7 +139,7 @@ const PhoneNumberFormField = React.forwardRef( id={field.id} name={field.name} autoComplete={props.autoComplete ?? "tel"} - className={classNames( + className={cn( "cui-input-base h-full pl-14 tracking-widest sm:leading-6", field.error && "border-danger-500", field.className, From 5d9885bfd5fd8490bbf98aaa803b68b5c4a4d3ba Mon Sep 17 00:00:00 2001 From: Srijan Tripathi <72181144+srijantrpth@users.noreply.github.com> Date: Mon, 16 Dec 2024 11:15:11 +0530 Subject: [PATCH 4/6] Fix: Inconsistency in Title during creation of Resouce Request #9440 (#9442) --- public/locale/en.json | 4 ++-- public/locale/hi.json | 4 ++-- public/locale/kn.json | 4 ++-- public/locale/ml.json | 4 ++-- public/locale/ta.json | 4 ++-- src/components/Resource/ResourceCreate.tsx | 4 ++-- src/components/Resource/ResourceDetails.tsx | 2 +- src/components/Resource/ResourceDetailsUpdate.tsx | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/public/locale/en.json b/public/locale/en.json index b9418edd719..2ceaf310fac 100644 --- a/public/locale/en.json +++ b/public/locale/en.json @@ -1249,8 +1249,8 @@ "req_atleast_one_uppercase": "Require at least one upper case", "request-sample-test": "Service Request", "request_consent": "Request Consent", - "request_description": "Description of Request", - "request_description_placeholder": "Type your description here", + "request_reason": "Reason of Request", + "request_reason_placeholder": "Type your description here", "request_sample_test": "Request Sample Test", "request_title": "Request Title", "request_title_placeholder": "Type your title here", diff --git a/public/locale/hi.json b/public/locale/hi.json index 9e6a667ba23..568ce0499f6 100644 --- a/public/locale/hi.json +++ b/public/locale/hi.json @@ -643,8 +643,8 @@ "req_atleast_one_lowercase": "कम से कम एक लोअर केस अक्षर की आवश्यकता है", "req_atleast_one_symbol": "कम से कम एक प्रतीक की आवश्यकता है", "req_atleast_one_uppercase": "कम से कम एक अपर केस की आवश्यकता है", - "request_description": "अनुरोध का विवरण", - "request_description_placeholder": "अपना विवरण यहाँ लिखें", + "request_reason": "अनुरोध का विवरण", + "request_reason_placeholder": "अपना विवरण यहाँ लिखें", "request_title": "शीर्षक का अनुरोध करें", "request_title_placeholder": "अपना शीर्षक यहाँ लिखें", "required": "आवश्यक", diff --git a/public/locale/kn.json b/public/locale/kn.json index faf50da3a23..4907cdd2d8c 100644 --- a/public/locale/kn.json +++ b/public/locale/kn.json @@ -645,8 +645,8 @@ "req_atleast_one_lowercase": "ಕನಿಷ್ಠ ಒಂದು ಸಣ್ಣ ಅಕ್ಷರದ ಅಗತ್ಯವಿದೆ", "req_atleast_one_symbol": "ಕನಿಷ್ಠ ಒಂದು ಚಿಹ್ನೆಯ ಅಗತ್ಯವಿದೆ", "req_atleast_one_uppercase": "ಕನಿಷ್ಠ ಒಂದು ದೊಡ್ಡ ಪ್ರಕರಣದ ಅಗತ್ಯವಿದೆ", - "request_description": "ವಿನಂತಿಯ ವಿವರಣೆ", - "request_description_placeholder": "ನಿಮ್ಮ ವಿವರಣೆಯನ್ನು ಇಲ್ಲಿ ಟೈಪ್ ಮಾಡಿ", + "request_reason": "ವಿನಂತಿಯ ವಿವರಣೆ", + "request_reason_placeholder": "ನಿಮ್ಮ ವಿವರಣೆಯನ್ನು ಇಲ್ಲಿ ಟೈಪ್ ಮಾಡಿ", "request_title": "ವಿನಂತಿ ಶೀರ್ಷಿಕೆ", "request_title_placeholder": "ನಿಮ್ಮ ಶೀರ್ಷಿಕೆಯನ್ನು ಇಲ್ಲಿ ಟೈಪ್ ಮಾಡಿ", "required": "ಅಗತ್ಯವಿದೆ", diff --git a/public/locale/ml.json b/public/locale/ml.json index 33dadcf9fb7..b875a64dd02 100644 --- a/public/locale/ml.json +++ b/public/locale/ml.json @@ -644,8 +644,8 @@ "req_atleast_one_lowercase": "കുറഞ്ഞത് ഒരു ചെറിയ അക്ഷരമെങ്കിലും ആവശ്യമാണ്", "req_atleast_one_symbol": "കുറഞ്ഞത് ഒരു ചിഹ്നമെങ്കിലും ആവശ്യമാണ്", "req_atleast_one_uppercase": "കുറഞ്ഞത് ഒരു വലിയ കേസെങ്കിലും ആവശ്യമാണ്", - "request_description": "അഭ്യർത്ഥനയുടെ വിവരണം", - "request_description_placeholder": "നിങ്ങളുടെ വിവരണം ഇവിടെ ടൈപ്പ് ചെയ്യുക", + "request_reason": "അഭ്യർത്ഥനയുടെ വിവരണം", + "request_reason_placeholder": "നിങ്ങളുടെ വിവരണം ഇവിടെ ടൈപ്പ് ചെയ്യുക", "request_title": "പേര് അഭ്യർത്ഥിക്കുക", "request_title_placeholder": "നിങ്ങളുടെ തലക്കെട്ട് ഇവിടെ ടൈപ്പ് ചെയ്യുക", "required": "ആവശ്യമാണ്", diff --git a/public/locale/ta.json b/public/locale/ta.json index 694efd52e20..cfe12b5fa6a 100644 --- a/public/locale/ta.json +++ b/public/locale/ta.json @@ -643,8 +643,8 @@ "req_atleast_one_lowercase": "குறைந்தபட்சம் ஒரு சிறிய எழுத்து தேவை", "req_atleast_one_symbol": "குறைந்தது ஒரு சின்னம் தேவை", "req_atleast_one_uppercase": "குறைந்தபட்சம் ஒரு பெரிய வழக்கு தேவை", - "request_description": "கோரிக்கையின் விளக்கம்", - "request_description_placeholder": "உங்கள் விளக்கத்தை இங்கே தட்டச்சு செய்யவும்", + "request_reason": "கோரிக்கையின் விளக்கம்", + "request_reason_placeholder": "உங்கள் விளக்கத்தை இங்கே தட்டச்சு செய்யவும்", "request_title": "தலைப்பு கோரிக்கை", "request_title_placeholder": "உங்கள் தலைப்பை இங்கே தட்டச்சு செய்யவும்", "required": "தேவை", diff --git a/src/components/Resource/ResourceCreate.tsx b/src/components/Resource/ResourceCreate.tsx index 4786164aa93..7c3e79cc4cb 100644 --- a/src/components/Resource/ResourceCreate.tsx +++ b/src/components/Resource/ResourceCreate.tsx @@ -309,11 +309,11 @@ export default function ResourceCreate(props: resourceProps) {
- Description of Request:{" "} + Reason of Request{" "} {data.reason || "--"}
diff --git a/src/components/Resource/ResourceDetailsUpdate.tsx b/src/components/Resource/ResourceDetailsUpdate.tsx index 46f92ca27db..b4ca02b7b45 100644 --- a/src/components/Resource/ResourceDetailsUpdate.tsx +++ b/src/components/Resource/ResourceDetailsUpdate.tsx @@ -297,7 +297,7 @@ export const ResourceDetailsUpdate = (props: resourceProps) => { placeholder="Type your description here" value={state.form.reason} onChange={handleChange} - label="Description of request*" + label="Reason of Request*" error={state.errors.reason} />
From 89cefea26ef24565134cab4401d83807506169c0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 11:19:37 +0530 Subject: [PATCH 5/6] Bump i18next-browser-languagedetector from 8.0.0 to 8.0.2 (#9370) Bumps [i18next-browser-languagedetector](https://github.com/i18next/i18next-browser-languageDetector) from 8.0.0 to 8.0.2. - [Changelog](https://github.com/i18next/i18next-browser-languageDetector/blob/master/CHANGELOG.md) - [Commits](https://github.com/i18next/i18next-browser-languageDetector/compare/v8.0.0...v8.0.2) --- updated-dependencies: - dependency-name: i18next-browser-languagedetector dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6e57456063b..94a84d3d179 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,7 +47,7 @@ "events": "^3.3.0", "hi-profiles": "^1.1.0", "i18next": "^23.16.4", - "i18next-browser-languagedetector": "^8.0.0", + "i18next-browser-languagedetector": "^8.0.2", "i18next-http-backend": "^3.0.1", "postcss-loader": "^8.1.1", "qrcode.react": "^4.1.0", @@ -10609,9 +10609,9 @@ } }, "node_modules/i18next-browser-languagedetector": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/i18next-browser-languagedetector/-/i18next-browser-languagedetector-8.0.0.tgz", - "integrity": "sha512-zhXdJXTTCoG39QsrOCiOabnWj2jecouOqbchu3EfhtSHxIB5Uugnm9JaizenOy39h7ne3+fLikIjeW88+rgszw==", + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/i18next-browser-languagedetector/-/i18next-browser-languagedetector-8.0.2.tgz", + "integrity": "sha512-shBvPmnIyZeD2VU5jVGIOWP7u9qNG3Lj7mpaiPFpbJ3LVfHZJvVzKR4v1Cb91wAOFpNw442N+LGPzHOHsten2g==", "license": "MIT", "dependencies": { "@babel/runtime": "^7.23.2" diff --git a/package.json b/package.json index 3db351e974b..e5eaf3342c9 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "events": "^3.3.0", "hi-profiles": "^1.1.0", "i18next": "^23.16.4", - "i18next-browser-languagedetector": "^8.0.0", + "i18next-browser-languagedetector": "^8.0.2", "i18next-http-backend": "^3.0.1", "postcss-loader": "^8.1.1", "qrcode.react": "^4.1.0", From 96bc802ec57505b4e53e46f4f58514998bdb066e Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:34:59 +0530 Subject: [PATCH 6/6] Fixed Redirection of Critical care updation (#9453) --- src/components/Patient/DailyRounds.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Patient/DailyRounds.tsx b/src/components/Patient/DailyRounds.tsx index f0c78522e40..cf43a5adab9 100644 --- a/src/components/Patient/DailyRounds.tsx +++ b/src/components/Patient/DailyRounds.tsx @@ -411,7 +411,7 @@ export const DailyRounds = (props: any) => { ); } else { navigate( - `/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}/log_updates/${obj.id}/update`, + `/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}/log_updates/${obj.id}/critical_care/update`, ); } }