diff --git a/cypress/e2e/assets_spec/assets_manage.cy.ts b/cypress/e2e/assets_spec/assets_manage.cy.ts index 1f89facd0a3..34c554b374e 100644 --- a/cypress/e2e/assets_spec/assets_manage.cy.ts +++ b/cypress/e2e/assets_spec/assets_manage.cy.ts @@ -12,6 +12,9 @@ describe("Asset", () => { const assetSearchPage = new AssetSearchPage(); const assetFilters = new AssetFilters(); const fillFacilityName = "Dummy Facility 1"; + const assetname = "Dummy Camera"; + const locationName = "Dummy Location 1"; + const initiallocationName = "Camera Location"; before(() => { loginPage.loginAsDisctrictAdmin(); @@ -23,6 +26,57 @@ describe("Asset", () => { cy.awaitUrl("/assets"); }); + it("Create & Edit a service history and verify reflection", () => { + assetSearchPage.typeSearchKeyword(assetname); + assetSearchPage.pressEnter(); + assetSearchPage.verifyBadgeContent(assetname); + assetSearchPage.clickAssetByName(assetname); + assetPage.clickupdatedetailbutton(); + assetPage.scrollintonotes(); + assetPage.enterAssetNotes("Dummy Notes"); + assetPage.enterAssetservicedate("01092023"); + assetPage.clickassetupdatebutton(); + assetPage.scrollintoservicehistory(); + assetPage.clickedithistorybutton(); + assetPage.scrollintonotes(); + assetPage.enterAssetNotes("Dummy Notes Editted"); + assetPage.clickassetupdatebutton(); + assetPage.scrollintoservicehistory(); + assetPage.viewassetservicehistorybutton(); + assetPage.openassetservicehistory(); + assetPage.verifyassetupdateservicehistory(); + assetPage.viewassetservicehistorybutton(); + }); + + it("Create a asset transaction and verify history", () => { + assetSearchPage.typeSearchKeyword(assetname); + assetSearchPage.pressEnter(); + assetSearchPage.verifyBadgeContent(assetname); + assetSearchPage.clickAssetByName(assetname); + assetPage.clickupdatedetailbutton(); + assetPage.clickassetlocation(locationName); + assetPage.clickUpdateAsset(); + assetPage.verifyassetlocation(locationName); + assetPage.verifytransactionStatus(initiallocationName, locationName); + }); + + it("Verify Facility Asset Page Redirection", () => { + cy.visit("/facility"); + assetSearchPage.typeSearchKeyword(fillFacilityName); + assetSearchPage.pressEnter(); + facilityPage.verifyFacilityBadgeContent(fillFacilityName); + facilityPage.visitAlreadyCreatedFacility(); + facilityPage.clickManageFacilityDropdown(); + facilityPage.clickCreateAssetFacilityOption(); + facilityPage.verifyfacilitycreateassetredirection(); + facilityPage.verifyassetfacilitybackredirection(); + facilityPage.clickManageFacilityDropdown(); + facilityPage.clickviewAssetFacilityOption(); + facilityPage.verifyfacilityviewassetredirection(); + assetFilters.assertFacilityText(fillFacilityName); + facilityPage.verifyassetfacilitybackredirection(); + }); + it("Delete an Asset", () => { assetPage.openCreatedAsset(); assetPage.interceptDeleteAssetApi(); diff --git a/cypress/e2e/patient_spec/patient_crud.cy.ts b/cypress/e2e/patient_spec/patient_crud.cy.ts index b55732fa440..fcfd97039f7 100644 --- a/cypress/e2e/patient_spec/patient_crud.cy.ts +++ b/cypress/e2e/patient_spec/patient_crud.cy.ts @@ -33,6 +33,7 @@ describe("Patient Creation with consultation", () => { it("Create a new patient with no consultation", () => { patientPage.createPatient(); patientPage.selectFacility("dummy facility"); + patientPage.patientformvisibility(); patientPage.enterPatientDetails( phone_number, emergency_phone_number, @@ -69,6 +70,7 @@ describe("Patient Creation with consultation", () => { patientPage.interceptFacilities(); patientPage.visitUpdatePatientUrl(); patientPage.verifyStatusCode(); + patientPage.patientformvisibility(); updatePatientPage.enterPatientDetails( "Test E2E User Edited", "O+", @@ -113,6 +115,7 @@ describe("Patient Creation with consultation", () => { patientConsultationPage.selectSymptoms("ASYMPTOMATIC"); patientConsultationPage.enterConsultationDetails( + "Stable", "Examination details and Clinical conditions", "70", "170", diff --git a/cypress/pageobject/Asset/AssetCreation.ts b/cypress/pageobject/Asset/AssetCreation.ts index b939c31405f..45356a1a4e7 100644 --- a/cypress/pageobject/Asset/AssetCreation.ts +++ b/cypress/pageobject/Asset/AssetCreation.ts @@ -276,4 +276,78 @@ export class AssetPage { cy.get("#submit").contains("Import").click(); cy.wait("@importAsset").its("response.statusCode").should("eq", 201); } + + clickupdatedetailbutton() { + cy.get("[data-testid=asset-update-button]").click(); + } + + scrollintonotes() { + cy.get("#notes").scrollIntoView(); + } + + enterAssetNotes(text) { + cy.get("#notes").click().clear(); + cy.get("#notes").click().type(text); + } + + enterAssetservicedate(text) { + cy.get("input[name='last_serviced_on']").click(); + cy.get("#date-input").click().type(text); + } + + clickassetupdatebutton() { + cy.get("#submit").click(); + } + + viewassetservicehistorybutton() { + cy.get("#view-service-history").should("be.visible"); + } + + openassetservicehistory() { + cy.get("#view-service-history").click(); + cy.get("#view-asset-edit-history").first().click(); + } + + verifyassetupdateservicehistory() { + cy.get("#edit-history-asset-servicedon").should("have.text", "01/09/2023"); + cy.get("#edit-history-asset-note").should( + "have.text", + "Dummy Notes Editted" + ); + cy.get("#view-history-back-button").contains("Back").click(); + cy.get("#view-history-back-button").contains("Close").click(); + } + + scrollintoservicehistory() { + cy.get("#service-history").scrollIntoView(); + } + + clickedithistorybutton() { + cy.get("#edit-service-history").click(); + } + + verifytransactionStatus(initiallocationName: string, locationName: string) { + cy.get("#transaction-history").scrollIntoView(); + cy.get("#transaction-history table tbody tr:first-child td:eq(0)").should( + "contain", + initiallocationName + ); + cy.get("#transaction-history table tbody tr:first-child td:eq(1)").should( + "contain", + locationName + ); + } + + verifyassetlocation(locationName: string) { + cy.get("#asset-current-location").should("contain", locationName); + } + + clickassetlocation(locationName: string) { + cy.get("#clear-button").click(); + cy.get("[data-testid=asset-location-input] button").click(); + cy.get("[data-testid=asset-location-input] button") + .click() + .type(locationName); + cy.get("[role='option']").contains(locationName).click(); + } } diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index 0c12d4655fd..42ec6d8fd7c 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -191,9 +191,7 @@ class FacilityPage { } verifyfacilitycreateassetredirection() { - cy.intercept("GET", "**/api/v1/facility/**").as("getNewAssets"); cy.url().should("include", "/assets/new"); - cy.wait("@getNewAssets").its("response.statusCode").should("eq", 200); } verifyassetfacilitybackredirection() { @@ -205,9 +203,7 @@ class FacilityPage { } verifyfacilityviewassetredirection() { - cy.intercept("GET", "**api/v1/getallfacilities/**").as("getViewAssets"); cy.url().should("include", "/assets?facility="); - cy.wait("@getViewAssets").its("response.statusCode").should("eq", 200); } clickManageInventory() { diff --git a/cypress/pageobject/Patient/PatientConsultation.ts b/cypress/pageobject/Patient/PatientConsultation.ts index c0ba0c260d8..6937559d548 100644 --- a/cypress/pageobject/Patient/PatientConsultation.ts +++ b/cypress/pageobject/Patient/PatientConsultation.ts @@ -16,12 +16,14 @@ export class PatientConsultationPage { } fillIllnessHistory(history: string) { + cy.wait(5000); cy.get("#history_of_present_illness").scrollIntoView(); cy.get("#history_of_present_illness").should("be.visible"); cy.get("#history_of_present_illness").click().type(history); } enterConsultationDetails( + category: string, examinationDetails: string, weight: string, height: string, @@ -30,6 +32,11 @@ export class PatientConsultationPage { verificationBy: string ) { cy.get("#symptoms").click(); + cy.get("#category") + .click() + .then(() => { + cy.get("[role='option']").contains(category).click(); + }); cy.get("#examination_details").click().type(examinationDetails); cy.get("#weight").click().type(height); cy.get("#height").click().type(weight); @@ -38,10 +45,12 @@ export class PatientConsultationPage { cy.get( "#icd11_diagnoses_object input[placeholder='Select'][role='combobox']" ) + .scrollIntoView() .click() .type("1A"); cy.get("#icd11_diagnoses_object [role='option']") .contains("1A03 Intestinal infections due to Escherichia coli") + .scrollIntoView() .click(); cy.get("label[for='icd11_diagnoses_object']").click(); cy.wait("@getIcdResults").its("response.statusCode").should("eq", 200); diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index 9b8df4a287e..4fcd43dc490 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -124,4 +124,8 @@ export class PatientPage { verifyStatusCode() { cy.wait("@getFacilities").its("response.statusCode").should("eq", 200); } + + patientformvisibility() { + cy.get("[data-testid='current-address']").scrollIntoView(); + } } diff --git a/src/Components/Assets/AssetManage.tsx b/src/Components/Assets/AssetManage.tsx index 4565c48b33d..84325d704aa 100644 --- a/src/Components/Assets/AssetManage.tsx +++ b/src/Components/Assets/AssetManage.tsx @@ -231,6 +231,7 @@ const AssetManage = (props: AssetManageProps) => { { setServiceEditData({ ...service, open: true }); @@ -240,6 +241,7 @@ const AssetManage = (props: AssetManageProps) => { {
{item.label}
-
+
{item.content || "--"}
@@ -513,7 +518,10 @@ const AssetManage = (props: AssetManageProps) => { asset?.asset_class && asset?.asset_class != AssetClass.NONE && }
Service History
-
+
@@ -540,7 +548,10 @@ const AssetManage = (props: AssetManageProps) => {
Transaction History
-
+
diff --git a/src/Components/Assets/AssetServiceEditModal.tsx b/src/Components/Assets/AssetServiceEditModal.tsx index 75c9dd9fc60..66d44d11907 100644 --- a/src/Components/Assets/AssetServiceEditModal.tsx +++ b/src/Components/Assets/AssetServiceEditModal.tsx @@ -97,7 +97,10 @@ export const AssetServiceEditModal = (props: { {edit.edited_by.username}

-
+
@@ -124,19 +127,25 @@ export const AssetServiceEditModal = (props: {

Serviced On

-

+

{formatDate(editRecord.serviced_on)}

Notes

-

{editRecord.note || "-"}

+

+ {editRecord.note || "-"} +

)}
{ editRecord ? setEditRecord(undefined) : props.handleClose(); diff --git a/src/Components/ExternalResult/FacilitiesSelectDialogue.tsx b/src/Components/ExternalResult/FacilitiesSelectDialogue.tsx index 763d92f2d1f..7239e0b912d 100644 --- a/src/Components/ExternalResult/FacilitiesSelectDialogue.tsx +++ b/src/Components/ExternalResult/FacilitiesSelectDialogue.tsx @@ -34,7 +34,7 @@ const FacilitiesSelectDialog = (props: Props) => { diff --git a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx index 705b3d9479a..1b89f3980e1 100644 --- a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx +++ b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx @@ -10,7 +10,7 @@ import useVitalsAspectRatioConfig from "../../VitalsMonitor/useVitalsAspectRatio import { DISCHARGE_REASONS, SYMPTOM_CHOICES } from "../../../Common/constants"; import PrescriptionsTable from "../../Medicine/PrescriptionsTable"; import Chip from "../../../CAREUI/display/Chip"; -import { formatDate, formatDateTime } from "../../../Utils/utils"; +import { formatAge, formatDate, formatDateTime } from "../../../Utils/utils"; import ReadMore from "../../Common/components/Readmore"; import { DailyRoundsList } from "../Consultations/DailyRoundsList"; @@ -621,7 +621,12 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
Age {" - "} - {props.patientData.age ?? "-"} + {props.patientData.age !== undefined // 0 is a valid age, so we need to check for undefined + ? formatAge( + props.patientData.age, + props.patientData.date_of_birth + ) + : "-"}
diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx index 356257f9ac6..403f1752704 100644 --- a/src/Components/Facility/ConsultationDetails/index.tsx +++ b/src/Components/Facility/ConsultationDetails/index.tsx @@ -5,7 +5,11 @@ import { SYMPTOM_CHOICES, } from "../../../Common/constants"; import { ConsultationModel, ICD11DiagnosisModel } from "../models"; -import { getConsultation, getPatient } from "../../../Redux/actions"; +import { + getConsultation, + getPatient, + listShiftRequests, +} from "../../../Redux/actions"; import { statusType, useAbortableEffect } from "../../../Common/utils"; import { lazy, useCallback, useState } from "react"; import ToolTip from "../../Common/utils/Tooltip"; @@ -50,10 +54,26 @@ export interface ConsultationTabProps { patientData: PatientModel; } +const TABS = { + UPDATES: ConsultationUpdatesTab, + FEED: ConsultationFeedTab, + SUMMARY: ConsultationSummaryTab, + MEDICINES: ConsultationMedicinesTab, + FILES: ConsultationFilesTab, + INVESTIGATIONS: ConsultationInvestigationsTab, + ABG: ConsultationABGTab, + NURSING: ConsultationNursingTab, + NEUROLOGICAL_MONITORING: ConsultationNeurologicalMonitoringTab, + VENTILATOR: ConsultationVentilatorTab, + NUTRITION: ConsultationNursingTab, + PRESSURE_SORE: ConsultationPressureSoreTab, + DIALYSIS: ConsultationDialysisTab, +}; + export const ConsultationDetails = (props: any) => { const { t } = useTranslation(); const { facilityId, patientId, consultationId } = props; - const tab = props.tab.toUpperCase(); + const tab = props.tab.toUpperCase() as keyof typeof TABS; const dispatch: any = useDispatch(); const [isLoading, setIsLoading] = useState(false); const [showDoctors, setShowDoctors] = useState(false); @@ -63,6 +83,7 @@ export const ConsultationDetails = (props: any) => { {} as ConsultationModel ); const [patientData, setPatientData] = useState({}); + const [activeShiftingData, setActiveShiftingData] = useState>([]); const [openDischargeSummaryDialog, setOpenDischargeSummaryDialog] = useState(false); const [openDischargeDialog, setOpenDischargeDialog] = useState(false); @@ -124,6 +145,15 @@ export const ConsultationDetails = (props: any) => { }; setPatientData(data); } + + // Get shifting data + const shiftingRes = await dispatch( + listShiftRequests({ patient: id }, "shift-list-call") + ); + if (shiftingRes?.data?.results) { + const data = shiftingRes.data.results; + setActiveShiftingData(data); + } } else { navigate("/not-found"); } @@ -142,22 +172,6 @@ export const ConsultationDetails = (props: any) => { }); }, []); - const TABS = { - UPDATES: ConsultationUpdatesTab, - FEED: ConsultationFeedTab, - SUMMARY: ConsultationSummaryTab, - MEDICINES: ConsultationMedicinesTab, - FILES: ConsultationFilesTab, - INVESTIGATIONS: ConsultationInvestigationsTab, - ABG: ConsultationABGTab, - NURSING: ConsultationNursingTab, - NEUROLOGICAL_MONITORING: ConsultationNeurologicalMonitoringTab, - VENTILATOR: ConsultationVentilatorTab, - NUTRITION: ConsultationNursingTab, - PRESSURE_SORE: ConsultationPressureSoreTab, - DIALYSIS: ConsultationDialysisTab, - }; - const consultationTabProps: ConsultationTabProps = { consultationId, facilityId, @@ -168,6 +182,19 @@ export const ConsultationDetails = (props: any) => { const SelectedTab = TABS[tab]; + const hasActiveShiftingRequest = () => { + if (activeShiftingData.length > 0) { + return [ + "PENDING", + "APPROVED", + "DESTINATION APPROVED", + "PATIENT TO BE PICKED UP", + ].includes(activeShiftingData[activeShiftingData.length - 1].status); + } + + return false; + }; + if (isLoading) { return ; } @@ -265,17 +292,33 @@ export const ConsultationDetails = (props: any) => {
{!consultationData.discharge_date && (
- - navigate( - `/facility/${patientData.facility}/patient/${patientData.id}/shift/new` - ) - } - className="btn btn-primary m-1 w-full hover:text-white" - > - - Shift Patient - + {hasActiveShiftingRequest() ? ( + + navigate( + `/shifting/${ + activeShiftingData[activeShiftingData.length - 1].id + }` + ) + } + className="btn btn-primary m-1 w-full hover:text-white" + > + + Track Shifting + + ) : ( + + navigate( + `/facility/${patientData.facility}/patient/${patientData.id}/shift/new` + ) + } + className="btn btn-primary m-1 w-full hover:text-white" + > + + Shift Patient + + )}