diff --git a/cypress/e2e/assets_spec/asset_homepage.cy.ts b/cypress/e2e/assets_spec/asset_homepage.cy.ts index a2c1c7734d2..388f19424a4 100644 --- a/cypress/e2e/assets_spec/asset_homepage.cy.ts +++ b/cypress/e2e/assets_spec/asset_homepage.cy.ts @@ -62,7 +62,7 @@ describe("Asset Tab", () => { it("Filter Asset", () => { assetFilters.filterAssets( - "Dummy Facility 1", + "Dummy Facility 40", "INTERNAL", "ACTIVE", "ONVIF Camera", @@ -70,7 +70,7 @@ describe("Asset Tab", () => { ); assetFilters.clickadvancefilter(); assetFilters.clickslideoverbackbutton(); // to verify the back button doesn't clear applied filters - assetFilters.assertFacilityText("Dummy Facility 1"); + assetFilters.assertFacilityText("Dummy Facility 40"); assetFilters.assertAssetTypeText("INTERNAL"); assetFilters.assertAssetClassText("ONVIF"); assetFilters.assertStatusText("ACTIVE"); @@ -89,7 +89,7 @@ describe("Asset Tab", () => { it("Import new asset", () => { assetPage.selectassetimportbutton(); assetPage.selectImportOption(); - assetPage.selectImportFacility("Dummy Facility 1"); + assetPage.selectImportFacility("Dummy Facility 40"); assetPage.importAssetFile(); assetPage.selectImportLocation("Camera Loc"); assetPage.clickImportAsset(); diff --git a/cypress/e2e/assets_spec/assets_creation.cy.ts b/cypress/e2e/assets_spec/assets_creation.cy.ts index dde4e0d0e8b..63f8bee50c8 100644 --- a/cypress/e2e/assets_spec/assets_creation.cy.ts +++ b/cypress/e2e/assets_spec/assets_creation.cy.ts @@ -25,7 +25,7 @@ describe("Asset", () => { it("Verify asset creation fields throws error if empty", () => { assetPage.createAsset(); - assetPage.selectFacility("Dummy Facility 1"); + assetPage.selectFacility("Dummy Facility 40"); assetPage.clickCreateAsset(); assetPage.verifyEmptyAssetNameError(); @@ -39,7 +39,7 @@ describe("Asset", () => { it("Create an Asset", () => { assetPage.createAsset(); - assetPage.selectFacility("Dummy Facility 1"); + assetPage.selectFacility("Dummy Facility 40"); assetPage.selectLocation("Camera Loc"); assetPage.selectAssetType("Internal"); assetPage.selectAssetClass("ONVIF Camera"); @@ -139,7 +139,7 @@ describe("Asset", () => { it("Add an vital monitor asset and configure it", () => { assetPage.createAsset(); - assetPage.selectFacility("Dummy Facility 1"); + assetPage.selectFacility("Dummy Facility 40"); assetPage.selectLocation("Camera Loc"); assetPage.selectAssetType("Internal"); assetPage.selectAssetClass("HL7 Vitals Monitor"); diff --git a/cypress/e2e/assets_spec/assets_manage.cy.ts b/cypress/e2e/assets_spec/assets_manage.cy.ts index 92a4f5be9b8..3a47ebec8df 100644 --- a/cypress/e2e/assets_spec/assets_manage.cy.ts +++ b/cypress/e2e/assets_spec/assets_manage.cy.ts @@ -17,7 +17,7 @@ describe("Asset", () => { const facilityPage = new FacilityPage(); const assetSearchPage = new AssetSearchPage(); const assetFilters = new AssetFilters(); - const fillFacilityName = "Dummy Facility 1"; + const fillFacilityName = "Dummy Facility 40"; const assetname = "Dummy Camera"; const locationName = "Dummy Location 1"; const initiallocationName = "Camera Location"; diff --git a/cypress/e2e/death_report_spec/death_report.cy.ts b/cypress/e2e/death_report_spec/death_report.cy.ts index c051e1ee776..846c31f7a90 100644 --- a/cypress/e2e/death_report_spec/death_report.cy.ts +++ b/cypress/e2e/death_report_spec/death_report.cy.ts @@ -12,9 +12,8 @@ describe("Death Report", () => { beforeEach(() => { cy.restoreLocalStorage(); cy.clearLocalStorage(/filters--.+/); - cy.awaitUrl("/"); + cy.awaitUrl("/patients"); cy.intercept("**/api/v1/patient/**").as("getPatients"); - cy.get("#facility-patients").contains("Patients").click({ force: true }); cy.url().should("include", "/patients"); cy.wait("@getPatients").get("a[data-cy=patient]").first().click(); cy.url().then((url) => { diff --git a/cypress/e2e/facility_spec/facility_creation.cy.ts b/cypress/e2e/facility_spec/facility_creation.cy.ts index f8001584ac3..ea27938c7e9 100644 --- a/cypress/e2e/facility_spec/facility_creation.cy.ts +++ b/cypress/e2e/facility_spec/facility_creation.cy.ts @@ -30,7 +30,7 @@ describe("Facility Creation", () => { const doctorCapacity = "5"; const totalDoctor = "10"; const facilityName = "cypress facility"; - const facilityName2 = "Dummy Facility 1"; + const facilityName2 = "Dummy Facility 40"; const facilityAddress = "cypress address"; const facilityUpdateAddress = "cypress updated address"; const facilityNumber = "9898469865"; @@ -297,13 +297,6 @@ describe("Facility Creation", () => { facilityPage.verifySuccessNotification("Facility updated successfully"); }); - it("Delete a facility", () => { - facilityPage.visitUpdateFacilityPage(facilityUrl1); - facilityPage.clickManageFacilityDropdown(); - facilityPage.clickDeleteFacilityOption(); - facilityPage.confirmDeleteFacility(); - }); - afterEach(() => { cy.saveLocalStorage(); }); diff --git a/cypress/e2e/facility_spec/facility_homepage.cy.ts b/cypress/e2e/facility_spec/facility_homepage.cy.ts index 7269c3a2581..2ed666ac842 100644 --- a/cypress/e2e/facility_spec/facility_homepage.cy.ts +++ b/cypress/e2e/facility_spec/facility_homepage.cy.ts @@ -18,11 +18,12 @@ describe("Facility Homepage Function", () => { const capacitiesAlias = "downloadCapacitiesCSV"; const doctorsAlias = "downloadDoctorsCSV"; const triagesAlias = "downloadTriagesCSV"; - const facilityname = "Dummy Facility 1"; - const statename = "Kerala"; + const facilityName = "Dummy Facility 40"; + const facilityLocaion = "Dummy Location"; + const stateName = "Kerala"; const district = "Ernakulam"; - const localbody = "Aikaranad"; - const facilitytype = "Private Hospital"; + const localBody = "Aikaranad"; + const facilityType = "Private Hospital"; before(() => { loginPage.loginAsDisctrictAdmin(); @@ -58,16 +59,16 @@ describe("Facility Homepage Function", () => { it("Verify the functionality of advance filter", () => { userPage.clickAdvancedFilters(); - facilityPage.selectState(statename); + facilityPage.selectState(stateName); facilityPage.selectDistrict(district); - facilityPage.selectLocalBody(localbody); - facilityPage.clickUpdateFacilityType(facilitytype); + facilityPage.selectLocalBody(localBody); + facilityPage.clickUpdateFacilityType(facilityType); userPage.applyFilter(); - facilityPage.verifyStateBadgeContent(statename); + facilityPage.verifyStateBadgeContent(stateName); facilityPage.verifyDistrictBadgeContent(district); - facilityPage.verifyLocalBodyBadgeContent(localbody); - facilityPage.verifyFacilityTypeBadgeContent(facilitytype); - manageUserPage.assertFacilityInCard(facilityname); + facilityPage.verifyLocalBodyBadgeContent(localBody); + facilityPage.verifyFacilityTypeBadgeContent(facilityType); + manageUserPage.assertFacilityInCard(facilityName); userPage.clearFilters(); userPage.verifyDataTestIdNotVisible("State"); userPage.verifyDataTestIdNotVisible("District"); @@ -80,10 +81,10 @@ describe("Facility Homepage Function", () => { assetPagination.navigateToNextPage(); assetPagination.navigateToPreviousPage(); // search for a facility - manageUserPage.typeFacilitySearch(facilityname); - facilityPage.verifyFacilityBadgeContent(facilityname); - manageUserPage.assertFacilityInCard(facilityname); - facilityHome.verifyURLContains(facilityname); + manageUserPage.typeFacilitySearch(facilityName); + facilityPage.verifyFacilityBadgeContent(facilityName); + manageUserPage.assertFacilityInCard(facilityName); + facilityHome.verifyURLContains(facilityName); }); it("Verify Facility Export Functionality", () => { @@ -113,6 +114,25 @@ describe("Facility Homepage Function", () => { facilityHome.clickSearchButton(); }); + it("Verify Facility Detail page redirection to CNS and Live Minitoring ", () => { + userPage.clickAdvancedFilters(); + facilityPage.selectState(stateName); + facilityPage.selectDistrict(district); + facilityPage.selectLocalBody(localBody); + userPage.applyFilter(); + // go to cns page in the facility details page + manageUserPage.assertFacilityInCard(facilityName); + facilityHome.clickViewFacilityDetails(); + facilityHome.clickFacilityCnsButton(); + facilityHome.verifyCnsUrl(); + facilityHome.navigateBack(); + // go to live monitoring page in the facility details page + facilityHome.clickFacilityLiveMonitorButton(); + facilityHome.selectLocation(facilityLocaion); + facilityHome.clickLiveMonitorButton(); + facilityHome.verifyLiveMonitorUrl(); + }); + afterEach(() => { cy.saveLocalStorage(); }); diff --git a/cypress/e2e/facility_spec/facility_manage.cy.ts b/cypress/e2e/facility_spec/facility_manage.cy.ts new file mode 100644 index 00000000000..11c75949af1 --- /dev/null +++ b/cypress/e2e/facility_spec/facility_manage.cy.ts @@ -0,0 +1,175 @@ +import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress"; +import LoginPage from "../../pageobject/Login/LoginPage"; +import FacilityManage from "../../pageobject/Facility/FacilityManage"; +import FacilityPage from "../../pageobject/Facility/FacilityCreation"; +import { v4 as uuidv4 } from "uuid"; + +describe("Facility Manage Functions", () => { + const loginPage = new LoginPage(); + const facilityManage = new FacilityManage(); + const facilityPage = new FacilityPage(); + const facilityMiddlewareUpdateButton = "Update"; + const facilityMiddleware = "dev-middleware.coronasafe.live"; + const facilityUpdatedMiddleware = "updated.coronasafe.live"; + const facilityMiddlewareSuccessfullNotification = + "Facility updated successfully"; + const facilityHrfidUpdateButton = "Link Health Facility"; + const facilityHrfidSuccessfullNotification = + "Health Facility config updated successfully"; + const facilityHrfId = uuidv4(); + const facilityUpdatedHrfId = uuidv4(); + const doctorCapacity = "5"; + const doctorModifiedCapacity = "7"; + const totalCapacity = "100"; + const currentOccupied = "80"; + const totalUpdatedCapacity = "120"; + const currentUpdatedOccupied = "100"; + + before(() => { + loginPage.loginAsDisctrictAdmin(); + cy.saveLocalStorage(); + }); + + beforeEach(() => { + cy.viewport(1280, 720); + cy.restoreLocalStorage(); + cy.clearLocalStorage(/filters--.+/); + cy.awaitUrl("/"); + facilityPage.visitAlreadyCreatedFacility(); + }); + + it("Facility Cover Image button functionality", () => { + // It's only button functionality because we can't access S3 bucket in local + facilityManage.clickCoverImage(); + facilityManage.verifyUploadButtonVisible(); + facilityManage.uploadCoverImage("facilitycoverimage.jpg"); + facilityManage.clickSaveCoverImage(); + }); + + it("Configure Facility Middleware", () => { + facilityPage.clickManageFacilityDropdown(); + facilityManage.clickFacilityConfigureButton(); + facilityManage.verifyMiddlewareAddressVisible(); + // verify mandatory field error message + facilityManage.clickButtonWithText(facilityMiddlewareUpdateButton); + facilityManage.checkErrorMessageVisibility( + "Middleware Address is required" + ); + // add middleware and verify the notification + facilityManage.typeMiddlewareAddress(facilityMiddleware); + facilityManage.clickButtonWithText(facilityMiddlewareUpdateButton); + facilityManage.verifySuccessMessageVisibilityAndContent( + facilityMiddlewareSuccessfullNotification + ); + // update the existing middleware + facilityPage.clickManageFacilityDropdown(); + facilityManage.clickFacilityConfigureButton(); + facilityManage.verifyMiddlewareAddressVisible(); + facilityManage.typeMiddlewareAddress(facilityUpdatedMiddleware); + facilityManage.clickButtonWithText(facilityMiddlewareUpdateButton); + facilityManage.verifySuccessMessageVisibilityAndContent( + facilityMiddlewareSuccessfullNotification + ); + // verify the updated middleware + facilityPage.clickManageFacilityDropdown(); + facilityManage.clickFacilityConfigureButton(); + facilityManage.verifyMiddlewareAddressValue(facilityUpdatedMiddleware); + }); + + it("Configure Facility Health ID", () => { + facilityPage.clickManageFacilityDropdown(); + facilityManage.clickFacilityConfigureButton(); + // verify mandatory field error message + facilityManage.clickButtonWithText(facilityHrfidUpdateButton); + facilityManage.checkErrorMessageVisibility( + "Health Facility Id is required" + ); + // add facility health ID and verify notification + facilityManage.typeHrfId(facilityHrfId); + facilityManage.clickButtonWithText(facilityHrfidUpdateButton); + facilityManage.verifySuccessMessageVisibilityAndContent( + facilityHrfidSuccessfullNotification + ); + // update the existing middleware + facilityPage.clickManageFacilityDropdown(); + facilityManage.clickFacilityConfigureButton(); + facilityManage.typeHrfId(facilityUpdatedHrfId); + facilityManage.clickButtonWithText(facilityHrfidUpdateButton); + facilityManage.verifySuccessMessageVisibilityAndContent( + facilityHrfidSuccessfullNotification + ); + // verify its reflection + facilityPage.clickManageFacilityDropdown(); + facilityManage.clickFacilityConfigureButton(); + facilityManage.verifyHrfIdValue(facilityUpdatedHrfId); + }); + + it("Modify doctor capacity in Facility detail page", () => { + // Add a doctor capacity + facilityManage.clickFacilityAddDoctorTypeButton(); + facilityPage.selectAreaOfSpecialization("General Medicine"); + facilityPage.fillDoctorCount(doctorCapacity); + facilityPage.saveAndExitDoctorForm(); + facilityManage.verifySuccessMessageVisibilityAndContent( + "Doctor count added successfully" + ); + facilityManage.verifyTotalDoctorCapacity(doctorCapacity); + // edit a existing doctor + facilityManage.clickEditFacilityDoctorCapacity(); + facilityPage.fillDoctorCount(doctorModifiedCapacity); + facilityPage.clickdoctorcapacityaddmore(); + facilityManage.verifySuccessMessageVisibilityAndContent( + "Doctor count updated successfully" + ); + facilityManage.verifyTotalDoctorCapacity(doctorModifiedCapacity); + // delete a bed + facilityManage.clickDeleteFacilityDoctorCapacity(); + facilityManage.clickButtonWithText("Delete"); + facilityManage.verifySuccessMessageVisibilityAndContent( + "Doctor specialization type deleted successfully" + ); + }); + + it("Modify bed capacity in Facility detail page", () => { + // add multiple new bed capacity + facilityManage.clickFacilityAddBedTypeButton(); + facilityPage.selectBedType("Oxygen beds"); + facilityPage.fillTotalCapacity(totalCapacity); + facilityPage.fillCurrentlyOccupied(currentOccupied); + facilityPage.saveAndExitBedCapacityForm(); + facilityManage.verifySuccessMessageVisibilityAndContent( + "Bed capacity added successfully" + ); + 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" + ); + facilityManage.verifyFacilityBedCapacity(totalUpdatedCapacity); + facilityManage.verifyFacilityBedCapacity(currentUpdatedOccupied); + // delete a bed + facilityManage.clickDeleteFacilityBedCapacity(); + facilityManage.clickButtonWithText("Delete"); + facilityManage.verifySuccessMessageVisibilityAndContent( + "Bed type deleted successfully" + ); + }); + + it("Delete a existing facility and verify the error message", () => { + facilityPage.clickManageFacilityDropdown(); + facilityPage.clickDeleteFacilityOption(); + facilityPage.confirmDeleteFacility(); + facilityManage.verifySuccessMessageVisibilityAndContent( + "You do not have permission to perform this action." + ); + }); + + afterEach(() => { + cy.saveLocalStorage(); + }); +}); diff --git a/cypress/e2e/facility_spec/locations.cy.ts b/cypress/e2e/facility_spec/locations.cy.ts index d39464ce14b..62905b87744 100644 --- a/cypress/e2e/facility_spec/locations.cy.ts +++ b/cypress/e2e/facility_spec/locations.cy.ts @@ -50,18 +50,27 @@ describe("Location Management Section", () => { cy.restoreLocalStorage(); cy.clearLocalStorage(/filters--.+/); cy.awaitUrl("/"); - cy.intercept("GET", "**/api/v1/facility/**").as("getFacilities"); - cy.get("[id='facility-details']").first().click(); - cy.wait("@getFacilities").its("response.statusCode").should("eq", 200); - cy.get("h1.text-3xl.font-bold", { timeout: 10000 }).should("be.visible"); - cy.get("#manage-facility-dropdown button").should("be.visible"); - cy.get("[id='manage-facility-dropdown']").scrollIntoView().click(); - cy.get("[id=location-management]").click(); + facilityPage.visitAlreadyCreatedFacility(); + facilityPage.clickManageFacilityDropdown(); + facilityLocation.clickFacilityLocationManagement(); }); it("Add a Bed to facility location along with duplication and deleting a bed", () => { // mandatory field verification in bed creation - facilityLocation.clickManageBedButton(); + cy.get("body").then(($body) => { + if ($body.find("#manage-bed-button:visible").length) { + // If the '#manage-bed-button' is visible + facilityLocation.clickManageBedButton(); + } else { + // If the '#manage-bed-button' is not visible + facilityLocation.clickAddNewLocationButton(); + facilityPage.fillFacilityName(locationName); + facilityLocation.selectLocationType(locationType); + assetPage.clickassetupdatebutton(); + facilityLocation.clickNotification(); + facilityLocation.clickManageBedButton(); + } + }); facilityLocation.clickAddBedButton(); assetPage.clickassetupdatebutton(); userCreationPage.verifyErrorMessages(EXPECTED_BED_ERROR_MESSAGES); @@ -106,6 +115,7 @@ describe("Location Management Section", () => { facilityLocation.selectLocationType(locationType); facilityLocation.fillMiddlewareAddress(locationMiddleware); assetPage.clickassetupdatebutton(); + facilityLocation.clickNotification(); // verify the reflection facilityLocation.verifyLocationName(locationName); facilityLocation.verifyLocationType(locationType); @@ -134,6 +144,7 @@ describe("Location Management Section", () => { facilityLocation.selectBedType(bedType); facilityLocation.setMultipleBeds(numberOfBeds); assetPage.clickassetupdatebutton(); + facilityLocation.clickNotification(); // verify the bed creation facilityLocation.verifyBedBadge(bedType); facilityLocation.verifyBedBadge(bedStatus); diff --git a/cypress/e2e/patient_spec/patient_crud.cy.ts b/cypress/e2e/patient_spec/patient_crud.cy.ts index 66c8b35e236..38eec604758 100644 --- a/cypress/e2e/patient_spec/patient_crud.cy.ts +++ b/cypress/e2e/patient_spec/patient_crud.cy.ts @@ -35,7 +35,7 @@ describe("Patient Creation with consultation", () => { it("Create a new patient with no consultation", () => { patientPage.createPatient(); - patientPage.selectFacility("dummy facility"); + patientPage.selectFacility("dummy facility 40"); patientPage.patientformvisibility(); patientPage.enterPatientDetails( phone_number, diff --git a/cypress/e2e/resource_spec/filter.cy.ts b/cypress/e2e/resource_spec/filter.cy.ts index c457f867ed4..d9f5f50c16f 100644 --- a/cypress/e2e/resource_spec/filter.cy.ts +++ b/cypress/e2e/resource_spec/filter.cy.ts @@ -16,7 +16,7 @@ describe("Resource filter", () => { cy.intercept(/\/api\/v1\/getallfacilities/).as("facilities_filter"); cy.contains("Filters").click(); cy.get("[name='origin_facility']") - .type("Dummy Facility 1") + .type("Dummy Facility 40") .wait("@facilities_filter"); cy.get("[role='option']").first().click(); cy.contains("Apply").click(); diff --git a/cypress/e2e/resource_spec/resources.cy.ts b/cypress/e2e/resource_spec/resources.cy.ts index a774023059f..7077f4082a2 100644 --- a/cypress/e2e/resource_spec/resources.cy.ts +++ b/cypress/e2e/resource_spec/resources.cy.ts @@ -41,7 +41,7 @@ describe("Resource Page", () => { it("Create a resource request", () => { cy.visit("/facility"); - cy.get("#search").click().type("dummy facility 1"); + cy.get("#search").click().type("dummy facility 40"); cy.intercept("GET", "**/api/v1/facility/**").as("loadFacilities"); cy.get("#facility-details").click(); cy.wait("@loadFacilities").its("response.statusCode").should("eq", 200); diff --git a/cypress/e2e/users_spec/user_creation.cy.ts b/cypress/e2e/users_spec/user_creation.cy.ts index 55d4b3bef1a..72d2e7f15f4 100644 --- a/cypress/e2e/users_spec/user_creation.cy.ts +++ b/cypress/e2e/users_spec/user_creation.cy.ts @@ -15,7 +15,7 @@ describe("User Creation", () => { const userCreationPage = new UserCreationPage(); const facilityPage = new FacilityPage(); const assetSearchPage = new AssetSearchPage(); - const fillFacilityName = "Dummy Facility 1"; + const fillFacilityName = "Dummy Facility 40"; const makeid = (length: number) => { let result = ""; const characters = "abcdefghijklmnopqrstuvwxyz0123456789"; diff --git a/cypress/e2e/users_spec/user_manage.cy.ts b/cypress/e2e/users_spec/user_manage.cy.ts index 35818751526..05e84715be1 100644 --- a/cypress/e2e/users_spec/user_manage.cy.ts +++ b/cypress/e2e/users_spec/user_manage.cy.ts @@ -16,7 +16,7 @@ describe("Manage User", () => { const usernameforworkinghour = "devdistrictadmin"; const usernamerealname = "Dummy Doctor"; const facilitytolinkusername = "Dummy Shifting Center"; - const facilitytolinkskill = "Dummy Facility 1"; + const facilitytolinkskill = "Dummy Facility 40"; const workinghour = "23"; const linkedskill = "General Medicine"; diff --git a/cypress/e2e/users_spec/user_profile.cy.ts b/cypress/e2e/users_spec/user_profile.cy.ts index b6fe64b2455..3f3202eb423 100644 --- a/cypress/e2e/users_spec/user_profile.cy.ts +++ b/cypress/e2e/users_spec/user_profile.cy.ts @@ -17,7 +17,7 @@ describe("Manage User Profile", () => { const doctorYoE = "10"; const medicalCouncilRegistration = "1234567890"; - const facilitySearch = "Dummy Facility 1"; + const facilitySearch = "Dummy Facility 40"; before(() => { loginPage.loginAsDevDoctor(); diff --git a/cypress/fixtures/facilitycoverimage.jpg b/cypress/fixtures/facilitycoverimage.jpg new file mode 100644 index 00000000000..95923ab68fb Binary files /dev/null and b/cypress/fixtures/facilitycoverimage.jpg differ diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index bb6cf0e19f2..6be99cf5758 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -26,7 +26,7 @@ class FacilityPage { } fillFacilityName(name: string) { - cy.get("#name").clear().type(name); + cy.get("#name").click().clear().click().type(name); } fillPincode(pincode: string) { @@ -75,11 +75,11 @@ class FacilityPage { } fillTotalCapacity(capacity: string) { - cy.get("input#total-capacity").click().type(capacity); + cy.get("input#total-capacity").click().clear().click().type(capacity); } fillCurrentlyOccupied(occupied: string) { - cy.get("input#currently-occupied").click().type(occupied); + cy.get("input#currently-occupied").click().clear().click().type(occupied); } saveAndExitBedCapacityForm() { @@ -96,7 +96,7 @@ class FacilityPage { } fillDoctorCount(count: string) { - cy.get("input#count").click().type(count); + cy.get("input#count").click().clear().click().type(count); } fillOxygenCapacity(capacity: string) { @@ -321,6 +321,7 @@ class FacilityPage { cy.intercept("GET", "**/api/v1/facility/**").as("getFacilities"); cy.get("[id='facility-details']").first().click(); cy.wait("@getFacilities").its("response.statusCode").should("eq", 200); + cy.get("h1.text-3xl.font-bold", { timeout: 10000 }).should("be.visible"); } verifyFacilityBadgeContent(expectedText: string) { diff --git a/cypress/pageobject/Facility/FacilityHome.ts b/cypress/pageobject/Facility/FacilityHome.ts index 03f2be9b19b..fa163757584 100644 --- a/cypress/pageobject/Facility/FacilityHome.ts +++ b/cypress/pageobject/Facility/FacilityHome.ts @@ -31,10 +31,34 @@ class FacilityHome { cy.url().should("include", "/cns"); } + verifyLiveMonitorUrl() { + cy.url().should("include", "/live-monitoring?location="); + } + clickFacilityNotifyButton() { cy.get("#facility-notify").first().click(); } + clickLiveMonitorButton() { + cy.get("#live-monitoring-button").scrollIntoView(); + cy.get("#live-monitoring-button").click(); + } + + clickFacilityLiveMonitorButton() { + cy.get("#facility-detailspage-livemonitoring").scrollIntoView(); + cy.get("#facility-detailspage-livemonitoring").click(); + } + + clickFacilityCnsButton() { + cy.get("#facility-detailspage-cns").scrollIntoView(); + cy.get("#facility-detailspage-cns").click(); + } + + selectLocation(location) { + cy.get("#location").click().type(location); + cy.get("li[role=option]").contains(location).click(); + } + verifyFacilityDetailsUrl() { cy.url().should("match", /\/facility\/[\w-]+/); } diff --git a/cypress/pageobject/Facility/FacilityLocation.ts b/cypress/pageobject/Facility/FacilityLocation.ts index 8924119510f..b332d06ebf0 100644 --- a/cypress/pageobject/Facility/FacilityLocation.ts +++ b/cypress/pageobject/Facility/FacilityLocation.ts @@ -3,6 +3,10 @@ class FacilityLocation { cy.get("#add-new-location").click(); } + clickFacilityLocationManagement() { + cy.get("[id=location-management]").click(); + } + clickEditLocationButton() { cy.get("#edit-location-button").click(); } @@ -52,6 +56,10 @@ class FacilityLocation { cy.get("#add-new-bed").click(); } + clickNotification() { + cy.get(".pnotify").click(); + } + enterBedName(name: string) { cy.get("#bed-name").click().clear().click().type(name); } diff --git a/cypress/pageobject/Facility/FacilityManage.ts b/cypress/pageobject/Facility/FacilityManage.ts new file mode 100644 index 00000000000..69cdaf669e2 --- /dev/null +++ b/cypress/pageobject/Facility/FacilityManage.ts @@ -0,0 +1,92 @@ +class FacilityManage { + clickCoverImage() { + cy.get("#facility-coverimage").click({ force: true }); + } + + verifyUploadButtonVisible() { + cy.get("#upload-cover-image").should("be.visible"); + } + + uploadCoverImage(fileName) { + cy.get("#upload-cover-image") + .selectFile(`cypress/fixtures/${fileName}`, { force: true }) + .wait(100); // Adjust the wait time as needed + } + + verifyTotalDoctorCapacity(expectedCapacity) { + cy.get("#facility-doctor-totalcapacity").contains(expectedCapacity); + } + + verifyFacilityBedCapacity(expectedCapacity) { + 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(); + } + + clickSaveCoverImage() { + cy.get("#save-cover-image").scrollIntoView(); + cy.get("#save-cover-image").click(); + } + + clickFacilityConfigureButton() { + cy.get("#configure-facility").should("be.visible"); + cy.get("#configure-facility").click(); + } + + verifyMiddlewareAddressVisible() { + cy.get("#middleware_address").should("be.visible"); + } + + clickButtonWithText(text) { + cy.get("button#submit").contains(text).click(); + } + + checkErrorMessageVisibility(text) { + cy.get(".error-text").contains(text).should("be.visible"); + } + + typeMiddlewareAddress(address) { + cy.get("#middleware_address").click().clear().click().type(address); + } + + typeHrfId(address) { + cy.get("#hf_id").click().clear().click().type(address); + } + + verifySuccessMessageVisibilityAndContent(text) { + cy.get(".pnotify-text").should("be.visible").and("contain", text); + } + + verifyMiddlewareAddressValue(expectedValue) { + cy.get("#middleware_address").should("have.value", expectedValue); + } + + verifyHrfIdValue(expectedValue) { + 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(); + } +} +export default FacilityManage; diff --git a/cypress/pageobject/Patient/PatientConsultation.ts b/cypress/pageobject/Patient/PatientConsultation.ts index 7528b30da06..8570b2b8e7a 100644 --- a/cypress/pageobject/Patient/PatientConsultation.ts +++ b/cypress/pageobject/Patient/PatientConsultation.ts @@ -47,7 +47,7 @@ export class PatientConsultationPage { cy.get("#icd11-search input[role='combobox']") .scrollIntoView() .click() - .type("1A"); + .type("1A00"); cy.get("#icd11-search [role='option']") .contains("1A00 Cholera") .scrollIntoView() diff --git a/netlify.toml b/netlify.toml index f23b951ff21..a98fd0f5352 100644 --- a/netlify.toml +++ b/netlify.toml @@ -21,6 +21,6 @@ status = 200 [[headers]] for = "/*" [headers.values] - cache-control = ''' - max-age=0, - no-store''' + cache-control = "max-age=0, no-store" + X-Frame-Options = "DENY" + X-Content-Type-Options = "nosniff" diff --git a/public/config.json b/public/config.json index 74e509fee59..9398e28c410 100644 --- a/public/config.json +++ b/public/config.json @@ -1,5 +1,4 @@ { - "dashboard_url": "https://dashboard.coronasafe.in", "github_url": "https://github.com/coronasafe", "coronasafe_url": "https://coronasafe.network?ref=care", "site_url": "care.coronasafe.in", @@ -23,4 +22,4 @@ "sample_format_asset_import": "https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=11JaEhNHdyCHth4YQs_44YaRlP77Rrqe81VSEfg1glko&exportFormat=xlsx", "sample_format_external_result_import": "/External-Results-Template.csv", "enable_abdm": true -} \ No newline at end of file +} diff --git a/src/Common/hooks/useConfig.ts b/src/Common/hooks/useConfig.ts index 15e456ea571..79addd71c8b 100644 --- a/src/Common/hooks/useConfig.ts +++ b/src/Common/hooks/useConfig.ts @@ -8,7 +8,7 @@ interface ILogo { } export interface IConfig { - dashboard_url: string; + dashboard_url?: string; github_url: string; coronasafe_url: string; site_url: string; diff --git a/src/Common/hooks/useFilters.tsx b/src/Common/hooks/useFilters.tsx index 117a14ba418..dd08a2442a5 100644 --- a/src/Common/hooks/useFilters.tsx +++ b/src/Common/hooks/useFilters.tsx @@ -8,6 +8,7 @@ import { classNames } from "../../Utils/utils"; export type FilterState = Record; export type FilterParamKeys = string | string[]; + interface FilterBadgeProps { name: string; value?: string; @@ -18,7 +19,13 @@ interface FilterBadgeProps { * A custom hook wrapped around raviger's `useQueryParams` hook to ease handling * of pagination and filters. */ -export default function useFilters({ limit = 14 }: { limit?: number }) { +export default function useFilters({ + limit = 14, + cacheBlacklist = [], +}: { + limit?: number; + cacheBlacklist?: string[]; +}) { const { t } = useTranslation(); const { kasp_string } = useConfig(); const hasPagination = limit > 0; @@ -29,8 +36,14 @@ export default function useFilters({ limit = 14 }: { limit?: number }) { query: QueryParam, options?: setQueryParamsOptions ) => { + const updatedQParams = { ...query }; + + for (const param of cacheBlacklist) { + delete updatedQParams[param]; + } + _setQueryParams(query, options); - updateFiltersCache(query); + updateFiltersCache(updatedQParams); }; const updateQuery = (filter: FilterState) => { diff --git a/src/Components/ABDM/LinkABHANumberModal.tsx b/src/Components/ABDM/LinkABHANumberModal.tsx index f5da5fedfb9..47b29b805ae 100644 --- a/src/Components/ABDM/LinkABHANumberModal.tsx +++ b/src/Components/ABDM/LinkABHANumberModal.tsx @@ -55,7 +55,7 @@ export default function LinkABHANumberModal({ ...props }: Props) { const [currentStep, setCurrentStep] = useState("AadhaarVerification"); - const [transactionId, setTransactionId] = useState("sds"); + const [transactionId, setTransactionId] = useState(""); const title = (
@@ -73,9 +73,6 @@ export default function LinkABHANumberModal({
{currentStep === "ScanExistingQR" && ( { - setCurrentStep("AadhaarVerification"); - }} patientId={patientId} onSuccess={onSuccess} closeModal={props.onClose} @@ -88,9 +85,6 @@ export default function LinkABHANumberModal({ setTransactionId(transactionId); setCurrentStep("MobileVerification"); }} - onSignin={() => { - setCurrentStep("ScanExistingQR"); - }} /> )} @@ -116,19 +110,37 @@ export default function LinkABHANumberModal({ /> )}
+ +
+ {["AadhaarVerification", "MobileVerification", "HealthIDCreation"].find( + (step) => step === currentStep + ) ? ( +

setCurrentStep("ScanExistingQR")} + className="cursor-pointer text-center text-sm text-blue-800" + > + Already have an ABHA number +

+ ) : ( +

setCurrentStep("AadhaarVerification")} + className="cursor-pointer text-center text-sm text-blue-800" + > + Don't have an ABHA Number +

+ )} +
); } interface ScanABHAQRSectionProps { - onSignup: () => void; patientId?: string; onSuccess?: (abha: any) => void; closeModal: () => void; } const ScanABHAQRSection = ({ - onSignup, patientId, onSuccess, closeModal, @@ -155,15 +167,18 @@ const ScanABHAQRSection = ({ return (
{ - if ([2, 7, 12].includes(value.length)) { - if (qrValue.length && qrValue[qrValue.length - 1] === "-") { - value.slice(value.length - 1); - } else { - value += "-"; + if (value[0] && !isNaN(Number(value[0]))) { + // 92-1234-1234-1234 + if ([2, 7, 12].includes(value.length)) { + if (qrValue.length && qrValue[qrValue.length - 1] === "-") { + value.slice(value.length - 1); + } else { + value += "-"; + } } } setQrValue(value); @@ -230,16 +245,11 @@ const ScanABHAQRSection = ({ error="" /> )} -
- - Don't have an ABHA Number - +
<> {txnId ? ( { let response = null; @@ -299,9 +309,14 @@ const ScanABHAQRSection = ({ Link ) : authMethods.length ? ( - + {authMethods.map((method) => ( { const { res, data } = await request( routes.abha.initiateAbdmAuthentication, @@ -321,6 +336,7 @@ const ScanABHAQRSection = ({ ) : ( { const { res, data } = await request( routes.abha.searchByHealthId, @@ -353,13 +369,9 @@ const ScanABHAQRSection = ({ interface VerifyAadhaarSectionProps { onVerified: (transactionId: string) => void; - onSignin: () => void; } -const VerifyAadhaarSection = ({ - onVerified, - onSignin, -}: VerifyAadhaarSectionProps) => { +const VerifyAadhaarSection = ({ onVerified }: VerifyAadhaarSectionProps) => { const [aadhaarNumber, setAadhaarNumber] = useState(""); const [aadhaarNumberError, setAadhaarNumberError] = useState(); @@ -563,15 +575,10 @@ const VerifyAadhaarSection = ({ /> )} -
- - Already have an ABHA number - +
<> {otpSent && ( - + {(verified && "Verified") || (isVerifyingOtp ? "Verifying..." : "Verify")} @@ -736,8 +747,9 @@ const VerifyMobileSection = ({

)} -
+
{otpDispatched && ( - + {(verified && "Verified") || (isVerifyingOtp ? "Verifying..." : "Verify")} @@ -831,8 +847,9 @@ const CreateHealthIDSection = ({
)} -
+
{ resultsPerPage, } = useFilters({ limit: 18, + cacheBlacklist: ["search"], }); const [assets, setAssets] = useState([{} as AssetData]); const [isLoading, setIsLoading] = useState(false); diff --git a/src/Components/Common/Sidebar/Sidebar.tsx b/src/Components/Common/Sidebar/Sidebar.tsx index 9d378df4267..af450d9583d 100644 --- a/src/Components/Common/Sidebar/Sidebar.tsx +++ b/src/Components/Common/Sidebar/Sidebar.tsx @@ -147,13 +147,15 @@ const StatelessSidebar = ({ handleOverflow={handleOverflow} onClickCB={() => onItemClick && onItemClick(false)} /> - } - external - handleOverflow={handleOverflow} - /> + {dashboard_url && ( + } + external + handleOverflow={handleOverflow} + /> + )}
diff --git a/src/Components/Common/components/Menu.tsx b/src/Components/Common/components/Menu.tsx index 3292031eebb..218e897d3e7 100644 --- a/src/Components/Common/components/Menu.tsx +++ b/src/Components/Common/components/Menu.tsx @@ -18,6 +18,7 @@ interface DropdownMenuProps { disabled?: boolean | undefined; className?: string | undefined; itemClassName?: string | undefined; + containerClassName?: string | undefined; } export default function DropdownMenu({ @@ -26,7 +27,10 @@ export default function DropdownMenu({ ...props }: DropdownMenuProps) { return ( -
+
import("../Common/Loading")); export default function ResultList() { @@ -29,7 +30,10 @@ export default function ResultList() { FilterBadges, advancedFilter, resultsPerPage, - } = useFilters({ limit: 14 }); + } = useFilters({ + limit: 14, + cacheBlacklist: ["mobile_number", "name"], + }); const [showDialog, setShowDialog] = useState(false); const [selectedFacility, setSelectedFacility] = useState({ name: "", diff --git a/src/Components/Facility/BedTypeCard.tsx b/src/Components/Facility/BedTypeCard.tsx index 67e22f31f42..f2af4bd7a1c 100644 --- a/src/Components/Facility/BedTypeCard.tsx +++ b/src/Components/Facility/BedTypeCard.tsx @@ -111,6 +111,7 @@ export const BedTypeCard: React.FC = ({
{ setSelectedId(room_type || 0); setOpen(true); @@ -125,6 +126,7 @@ export const BedTypeCard: React.FC = ({ 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" diff --git a/src/Components/Facility/CoverImageEditModal.tsx b/src/Components/Facility/CoverImageEditModal.tsx index 4d723214604..11fd8b57107 100644 --- a/src/Components/Facility/CoverImageEditModal.tsx +++ b/src/Components/Facility/CoverImageEditModal.tsx @@ -248,7 +248,10 @@ const CoverImageEditModal = ({
-
{ @@ -75,6 +76,7 @@ const DoctorsCountCard = (props: DoctorsCountProps) => { Edit setOpenDeleteDialog(true)} diff --git a/src/Components/Facility/FacilityBedCapacity.tsx b/src/Components/Facility/FacilityBedCapacity.tsx index d33caf3f7cb..30d67bfcf33 100644 --- a/src/Components/Facility/FacilityBedCapacity.tsx +++ b/src/Components/Facility/FacilityBedCapacity.tsx @@ -87,6 +87,7 @@ export const FacilityBedCapacity = (props: any) => {
Bed Capacity
setBedCapacityModalOpen(true)} authorizeFor={NonReadOnlyUsers} diff --git a/src/Components/Facility/FacilityDoctorList.tsx b/src/Components/Facility/FacilityDoctorList.tsx index d9a8b0d1a37..fddc1973aa3 100644 --- a/src/Components/Facility/FacilityDoctorList.tsx +++ b/src/Components/Facility/FacilityDoctorList.tsx @@ -46,7 +46,7 @@ export const FacilityDoctorList = (props: any) => {
-
+
Total Doctors
@@ -88,6 +88,7 @@ export const FacilityDoctorList = (props: any) => {
Doctors List
setDoctorCapacityModalOpen(true)} disabled={doctorList.length === DOCTOR_SPECIALIZATION.length} @@ -97,7 +98,9 @@ export const FacilityDoctorList = (props: any) => { Add Doctor Types
-
{doctorList}
+
+ {doctorList} +
{doctorCapacityModalOpen && ( diff --git a/src/Components/Facility/FacilityHome.tsx b/src/Components/Facility/FacilityHome.tsx index 52a7cd24027..6f42dab00a6 100644 --- a/src/Components/Facility/FacilityHome.tsx +++ b/src/Components/Facility/FacilityHome.tsx @@ -104,7 +104,10 @@ export const FacilityHome = (props: any) => { authUser.user_type === "StateAdmin"; const editCoverImageTooltip = hasPermissionToEditCoverImage && ( -
+
{`${hasCoverImage ? "Edit" : "Upload"}`}
@@ -391,6 +394,7 @@ export const FacilityHome = (props: any) => {
{ const LiveMonitoringButton = () => { const facilityId = useSlug("facility"); const [location, setLocation] = useState(); + const authUser = useAuthUser(); + + const permittedUserTypes = ["StateAdmin", "DistrictAdmin", "Doctor"]; return ( - - - - Live Monitoring - - + {permittedUserTypes.includes(authUser.user_type) && ( + + + + Live Monitoring + + + )} + {
{ resultsPerPage, } = useFilters({ limit: 14, + cacheBlacklist: ["search"], }); let manageFacilities: any = null; const { user_type } = useAuthUser(); diff --git a/src/Components/Form/SelectMenuV2.tsx b/src/Components/Form/SelectMenuV2.tsx index 464a754cebe..2e277b40b4f 100644 --- a/src/Components/Form/SelectMenuV2.tsx +++ b/src/Components/Form/SelectMenuV2.tsx @@ -101,7 +101,7 @@ const SelectMenuV2 = (props: SelectMenuProps) => { {value.icon}
)} -

+

{value.selectedLabel}

diff --git a/src/Components/Medicine/CreatePrescriptionForm.tsx b/src/Components/Medicine/CreatePrescriptionForm.tsx index 2725ab4e728..e62004756f9 100644 --- a/src/Components/Medicine/CreatePrescriptionForm.tsx +++ b/src/Components/Medicine/CreatePrescriptionForm.tsx @@ -137,7 +137,17 @@ export default function CreatePrescriptionForm(props: { ); } -export const PRESCRIPTION_ROUTES = ["ORAL", "IV", "IM", "SC"]; +export const PRESCRIPTION_ROUTES = [ + "ORAL", + "IV", + "IM", + "SC", + "INHALATION", + "NASOGASTRIC", + "INTRATHECAL", + "TRANSDERMAL", + "RECTAL", +] as const; export const PRESCRIPTION_FREQUENCIES = { STAT: { slots: 1, diff --git a/src/Components/Medicine/MedicineAdministrationSheet/AdministrationEventCell.tsx b/src/Components/Medicine/MedicineAdministrationSheet/AdministrationEventCell.tsx index 1bcfc24a80a..c62af53c8bb 100644 --- a/src/Components/Medicine/MedicineAdministrationSheet/AdministrationEventCell.tsx +++ b/src/Components/Medicine/MedicineAdministrationSheet/AdministrationEventCell.tsx @@ -1,7 +1,7 @@ import dayjs from "../../../Utils/dayjs"; import { MedicineAdministrationRecord, Prescription } from "../models"; import CareIcon from "../../../CAREUI/icons/CareIcon"; -import { classNames, formatDateTime, formatTime } from "../../../Utils/utils"; +import { classNames, formatDateTime } from "../../../Utils/utils"; import DialogModal from "../../Common/Dialog"; import PrescrpitionActivityTimeline from "../PrescrpitionTimeline"; import { useState } from "react"; @@ -21,10 +21,10 @@ export default function AdministrationEventCell({ refetch, }: Props) { const [showTimeline, setShowTimeline] = useState(false); - // Check if cell belongs to an administered prescription + // Check if cell belongs to an administered prescription (including start and excluding end) const administered = administrations .filter((administration) => - dayjs(administration.administered_date).isBetween(start, end) + dayjs(administration.administered_date).isBetween(start, end, null, "[)") ) .sort( (a, b) => @@ -46,9 +46,7 @@ export default function AdministrationEventCell({ show={showTimeline} >
- Administrations between{" "} - {formatTime(start, "HH:mm")} and{" "} - {formatTime(end, "HH:mm")} on{" "} + Administrations on{" "} {formatDateTime(start, "DD/MM/YYYY")} diff --git a/src/Components/Medicine/PrescriptionDetailCard.tsx b/src/Components/Medicine/PrescriptionDetailCard.tsx index 4333eeb1a88..0e1f28e9654 100644 --- a/src/Components/Medicine/PrescriptionDetailCard.tsx +++ b/src/Components/Medicine/PrescriptionDetailCard.tsx @@ -86,7 +86,10 @@ export default function PrescriptionDetailCard({ {prescription.medicine_object?.name ?? prescription.medicine_old} - + {prescription.route && t("PRESCRIPTION_ROUTE_" + prescription.route)} diff --git a/src/Components/Medicine/models.ts b/src/Components/Medicine/models.ts index 4fca9b6f972..b97e2c52252 100644 --- a/src/Components/Medicine/models.ts +++ b/src/Components/Medicine/models.ts @@ -1,4 +1,5 @@ import { PerformedByModel } from "../HCX/misc"; +import { PRESCRIPTION_ROUTES } from "./CreatePrescriptionForm"; export const DOSAGE_UNITS = [ "mg", @@ -16,7 +17,7 @@ interface BasePrescription { medicine?: string; medicine_object?: MedibaseMedicine; medicine_old?: string; - route?: "ORAL" | "IV" | "IM" | "SC"; + route?: (typeof PRESCRIPTION_ROUTES)[number]; dosage: DosageValue; notes?: string; meta?: object; diff --git a/src/Components/Patient/FileUpload.tsx b/src/Components/Patient/FileUpload.tsx index d1dedc5e2ff..02de804f162 100644 --- a/src/Components/Patient/FileUpload.tsx +++ b/src/Components/Patient/FileUpload.tsx @@ -165,7 +165,6 @@ export const FileUpload = (props: FileUploadProps) => { const [fileUrl, setFileUrl] = useState(""); const [audioName, setAudioName] = useState(""); const [audioFileError, setAudioFileError] = useState(""); - const [contentType, setcontentType] = useState(""); const [downloadURL, setDownloadURL] = useState(); const FACING_MODE_USER = "user"; const FACING_MODE_ENVIRONMENT = { exact: "environment" }; @@ -248,7 +247,7 @@ export const FileUpload = (props: FileUploadProps) => { fetch(webRef.current.getScreenshot()) .then((res) => res.blob()) .then((blob) => { - const myFile = new File([blob], "image.png", { + const myFile = new File([blob], `image.${blob.type.split("/").pop()}`, { type: blob.type, }); setFile(myFile); @@ -919,7 +918,6 @@ export const FileUpload = (props: FileUploadProps) => { ); const ext: string = fileName.split(".")[1]; - setcontentType(header_content_type[ext]); if (ExtImage.includes(ext)) { const options = { @@ -943,7 +941,7 @@ export const FileUpload = (props: FileUploadProps) => { const config = { headers: { - "Content-type": contentType, + "Content-type": file?.type, "Content-disposition": "inline", }, onUploadProgress: (progressEvent: any) => { @@ -1022,6 +1020,7 @@ export const FileUpload = (props: FileUploadProps) => { name: filename, associating_id: getAssociatedId(), file_category: category, + mime_type: f?.type, }; dispatch(createUpload(requestData)) .then(uploadfile) @@ -1052,8 +1051,12 @@ export const FileUpload = (props: FileUploadProps) => { const internal_name = response.data.internal_name; const f = audioBlob; if (f === undefined) return; - const newFile = new File([f], `${internal_name}`, { type: "audio/mpeg" }); + const newFile = new File([f], `${internal_name}`, { type: f.type }); const config = { + headers: { + "Content-type": newFile?.type, + "Content-disposition": "inline", + }, onUploadProgress: (progressEvent: any) => { const percentCompleted = Math.round( (progressEvent.loaded * 100) / progressEvent.total @@ -1106,6 +1109,7 @@ export const FileUpload = (props: FileUploadProps) => { name: filename, associating_id: getAssociatedId(), file_category: category, + mime_type: audioBlob?.type, }; dispatch(createUpload(requestData)) .then(uploadAudiofile) @@ -1535,6 +1539,7 @@ export const FileUpload = (props: FileUploadProps) => { title="changeFile" onChange={onFileChange} type="file" + accept="image/*,video/*,audio/*,text/plain,text/csv,application/rtf,application/msword,application/vnd.oasis.opendocument.text,application/pdf,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.oasis.opendocument.spreadsheet,application/pdf" hidden /> diff --git a/src/Components/Patient/ManagePatients.tsx b/src/Components/Patient/ManagePatients.tsx index 0f9a6656f67..6f1fa4cafeb 100644 --- a/src/Components/Patient/ManagePatients.tsx +++ b/src/Components/Patient/ManagePatients.tsx @@ -99,6 +99,12 @@ export const PatientManager = () => { resultsPerPage, } = useFilters({ limit: 12, + cacheBlacklist: [ + "name", + "patient_no", + "phone_number", + "emergency_phone_number", + ], }); const [selectedFacility, setSelectedFacility] = useState({ name: "", diff --git a/src/Components/Patient/SampleViewAdmin.tsx b/src/Components/Patient/SampleViewAdmin.tsx index 085616adfac..5aca767e480 100644 --- a/src/Components/Patient/SampleViewAdmin.tsx +++ b/src/Components/Patient/SampleViewAdmin.tsx @@ -26,6 +26,7 @@ import CountBlock from "../../CAREUI/display/Count"; import CareIcon from "../../CAREUI/icons/CareIcon"; import { AdvancedFilterButton } from "../../CAREUI/interactive/FiltersSlideover"; import Page from "../Common/components/Page"; + const Loading = lazy(() => import("../Common/Loading")); export default function SampleViewAdmin() { @@ -38,6 +39,7 @@ export default function SampleViewAdmin() { resultsPerPage, } = useFilters({ limit: 10, + cacheBlacklist: ["patient_name", "district_name"], }); const dispatch: any = useDispatch(); const initialData: any[] = []; @@ -58,6 +60,7 @@ export default function SampleViewAdmin() { const res = await dispatch(getAnyFacility(qParams.facility)); setFacilityName(res?.data?.name); } + fetchData(); }, [dispatch, qParams.facility]); diff --git a/src/Components/Shifting/BoardView.tsx b/src/Components/Shifting/BoardView.tsx index 9c96daa0e59..ed29a16b8d5 100644 --- a/src/Components/Shifting/BoardView.tsx +++ b/src/Components/Shifting/BoardView.tsx @@ -29,6 +29,7 @@ const ScrollingComponent = withScrolling("div"); export default function BoardView() { const { qParams, updateQuery, FilterBadges, advancedFilter } = useFilters({ limit: -1, + cacheBlacklist: ["patient_name"], }); const { wartime_shifting } = useConfig(); diff --git a/src/Components/Shifting/ListView.tsx b/src/Components/Shifting/ListView.tsx index ec11f4cf91f..45a484af933 100644 --- a/src/Components/Shifting/ListView.tsx +++ b/src/Components/Shifting/ListView.tsx @@ -36,7 +36,7 @@ export default function ListView() { FilterBadges, advancedFilter, resultsPerPage, - } = useFilters({}); + } = useFilters({ cacheBlacklist: ["patient_name"] }); const [modalFor, setModalFor] = useState({ externalId: undefined, diff --git a/src/Components/Users/ManageUsers.tsx b/src/Components/Users/ManageUsers.tsx index 300f9846a89..597ddefba19 100644 --- a/src/Components/Users/ManageUsers.tsx +++ b/src/Components/Users/ManageUsers.tsx @@ -44,7 +44,10 @@ export default function ManageUsers() { FilterBadges, advancedFilter, resultsPerPage, - } = useFilters({ limit: 18 }); + } = useFilters({ + limit: 18, + cacheBlacklist: ["username"], + }); let manageUsers: any = null; const [expandSkillList, setExpandSkillList] = useState(false); const [expandFacilityList, setExpandFacilityList] = useState(false); diff --git a/src/Locale/en/Medicine.json b/src/Locale/en/Medicine.json index d32015e7618..f15bd7c802f 100644 --- a/src/Locale/en/Medicine.json +++ b/src/Locale/en/Medicine.json @@ -40,6 +40,11 @@ "PRESCRIPTION_ROUTE_IV": "IV", "PRESCRIPTION_ROUTE_IM": "IM", "PRESCRIPTION_ROUTE_SC": "S/C", + "PRESCRIPTION_ROUTE_INHALATION": "Inhalation", + "PRESCRIPTION_ROUTE_NASOGASTRIC": "Nasogastric/Gastrostomy tube", + "PRESCRIPTION_ROUTE_INTRATHECAL": "intrathecal injection", + "PRESCRIPTION_ROUTE_TRANSDERMAL": "Transdermal", + "PRESCRIPTION_ROUTE_RECTAL": "Rectal", "PRESCRIPTION_FREQUENCY_STAT": "Imediately", "PRESCRIPTION_FREQUENCY_OD": "Once daily", "PRESCRIPTION_FREQUENCY_HS": "Night only", diff --git a/src/Routers/routes/FacilityLocationRoutes.tsx b/src/Routers/routes/FacilityLocationRoutes.tsx index aa08661da8b..81896b48c98 100644 --- a/src/Routers/routes/FacilityLocationRoutes.tsx +++ b/src/Routers/routes/FacilityLocationRoutes.tsx @@ -4,6 +4,7 @@ import { AddLocationForm } from "../../Components/Facility/AddLocationForm"; import { BedManagement } from "../../Components/Facility/BedManagement"; import LocationManagement from "../../Components/Facility/LocationManagement"; import CentralLiveMonitoring from "../../Components/CameraFeed/CentralLiveMonitoring"; +import { AuthorizeUserRoute } from "../../Utils/AuthorizeFor"; export default { "/facility/:facilityId/location": ({ facilityId }: any) => ( @@ -37,6 +38,8 @@ export default { ), "/facility/:facilityId/live-monitoring": (props: any) => ( - + + + ), }; diff --git a/src/Utils/AuthorizeFor.tsx b/src/Utils/AuthorizeFor.tsx index 0ba40755205..614325ddd25 100644 --- a/src/Utils/AuthorizeFor.tsx +++ b/src/Utils/AuthorizeFor.tsx @@ -1,6 +1,15 @@ import { UserRole } from "../Common/constants"; +import React from "react"; +import useAuthUser from "../Common/hooks/useAuthUser"; +import Error404 from "../Components/ErrorPages/404"; export type AuthorizedForCB = (userType: UserRole) => boolean; + +interface AuthorizeUserRouteProps { + userTypes: UserRole[]; + children: React.ReactNode; +} + export type AuthorizedElementProps = { /** * Restrict access of this button to specific roles. @@ -26,3 +35,15 @@ export const Anyone = () => true; export default function (userTypes: UserRole[]) { return (userType: UserRole) => userTypes.includes(userType); } + +export const AuthorizeUserRoute: React.FC = ({ + userTypes, + children, +}) => { + const authUser = useAuthUser(); + if (userTypes.includes(authUser.user_type)) { + return <>{children}; + } else { + return ; + } +};