Skip to content

Commit

Permalink
Merge branch 'develop' into fix#6134
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Sep 26, 2023
2 parents 6fb5182 + f0d3470 commit fddc9d2
Show file tree
Hide file tree
Showing 21 changed files with 273 additions and 42 deletions.
54 changes: 54 additions & 0 deletions cypress/e2e/assets_spec/assets_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
74 changes: 74 additions & 0 deletions cypress/pageobject/Asset/AssetCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
2 changes: 0 additions & 2 deletions cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,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() {
Expand Down
17 changes: 14 additions & 3 deletions src/Components/Assets/AssetManage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ const AssetManage = (props: AssetManageProps) => {
</td>
<td className="gap-4 whitespace-nowrap px-6 py-4 text-left text-sm leading-5">
<ButtonV2
id="edit-service-history"
authorizeFor={NonReadOnlyUsers}
onClick={() => {
setServiceEditData({ ...service, open: true });
Expand All @@ -240,6 +241,7 @@ const AssetManage = (props: AssetManageProps) => {
<CareIcon icon="l-pen" className="text-lg" />
</ButtonV2>
<ButtonV2
id="view-service-history"
authorizeFor={NonReadOnlyUsers}
tooltip={service.edits?.length < 2 ? "No previous edits" : ""}
tooltipClassName="tooltip-left"
Expand Down Expand Up @@ -296,7 +298,10 @@ const AssetManage = (props: AssetManageProps) => {
</div>
<div className="break-words text-gray-700">{item.label}</div>
</div>
<div className="ml-8 grow-0 break-words text-lg font-semibold">
<div
className="ml-8 grow-0 break-words text-lg font-semibold"
id="asset-current-location"
>
{item.content || "--"}
</div>
</div>
Expand Down Expand Up @@ -513,7 +518,10 @@ const AssetManage = (props: AssetManageProps) => {
asset?.asset_class &&
asset?.asset_class != AssetClass.NONE && <Uptime assetId={asset?.id} />}
<div className="mb-4 mt-8 text-xl font-semibold">Service History</div>
<div className="min-w-full overflow-hidden overflow-x-auto align-middle shadow sm:rounded-lg">
<div
className="min-w-full overflow-hidden overflow-x-auto align-middle shadow sm:rounded-lg"
id="service-history"
>
<table className="min-w-full divide-y divide-gray-200">
<thead>
<tr>
Expand All @@ -540,7 +548,10 @@ const AssetManage = (props: AssetManageProps) => {
</table>
</div>
<div className="mb-4 mt-8 text-xl font-semibold">Transaction History</div>
<div className="min-w-full overflow-hidden overflow-x-auto align-middle shadow sm:rounded-lg">
<div
className="min-w-full overflow-hidden overflow-x-auto align-middle shadow sm:rounded-lg"
id="transaction-history"
>
<table className="min-w-full divide-y divide-gray-200">
<thead>
<tr>
Expand Down
15 changes: 12 additions & 3 deletions src/Components/Assets/AssetServiceEditModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ export const AssetServiceEditModal = (props: {
{edit.edited_by.username}
</p>
</div>
<div className="flex items-center justify-center">
<div
className="flex items-center justify-center"
id="view-asset-edit-history"
>
<CareIcon icon="l-eye" className="text-lg" />
</div>
</div>
Expand All @@ -124,19 +127,25 @@ export const AssetServiceEditModal = (props: {
<p className="text-sm font-medium text-gray-500">
Serviced On
</p>
<p className="text-gray-900">
<p
className="text-gray-900"
id="edit-history-asset-servicedon"
>
{formatDate(editRecord.serviced_on)}
</p>
</div>
<div className="mt-4 grow">
<p className="text-sm font-medium text-gray-500">Notes</p>
<p className="text-gray-900">{editRecord.note || "-"}</p>
<p className="text-gray-900" id="edit-history-asset-note">
{editRecord.note || "-"}
</p>
</div>
</div>
</div>
)}
<div className="flex justify-end">
<ButtonV2
id="view-history-back-button"
variant="secondary"
onClick={() => {
editRecord ? setEditRecord(undefined) : props.handleClose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -621,7 +621,12 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
<div>
Age {" - "}
<span className="font-semibold">
{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
)
: "-"}
</span>
</div>
<div>
Expand Down
13 changes: 7 additions & 6 deletions src/Components/Facility/DischargeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const DischargeModal = ({
const [latestClaim, setLatestClaim] = useState<HCXClaimModel>();
const [isCreateClaimLoading, setIsCreateClaimLoading] = useState(false);
const [isSendingDischargeApi, setIsSendingDischargeApi] = useState(false);
const [facility, setFacility] = useState<FacilityModel>({ id: 0, name: "" }); // for referred to external
const [facility, setFacility] = useState<FacilityModel>();
const [errors, setErrors] = useState<any>({});

const fetchLatestClaim = useCallback(async () => {
Expand Down Expand Up @@ -186,12 +186,13 @@ const DischargeModal = ({
const prescriptionActions = PrescriptionActions(consultationData.id ?? "");

const handleFacilitySelect = (selected: FacilityModel) => {
setFacility(selected ? selected : facility);
const { id, name } = selected;
setFacility(selected);
const { id, name } = selected || {};
const isExternal = id === -1;
setPreDischargeForm((prev) => ({
...prev,
...(isExternal ? { referred_to_external: name } : { referred_to: id }),
referred_to: isExternal ? null : id,
referred_to_external: isExternal ? name : null,
}));
};

Expand Down Expand Up @@ -238,8 +239,8 @@ const DischargeModal = ({
handleFacilitySelect(selected as FacilityModel)
}
selected={facility}
showAll={true}
freeText={true}
showAll
freeText
multiple={false}
errors={errors?.referred_to}
className="mb-4"
Expand Down
12 changes: 10 additions & 2 deletions src/Components/Facility/Investigations/Reports/ReportTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getColorIndex, rowColor, transformData } from "./utils";

import ButtonV2 from "../../../Common/components/ButtonV2";
import { InvestigationResponse } from "./types";
import { formatDateTime } from "../../../../Utils/utils";
import { formatAge, formatDateTime } from "../../../../Utils/utils";
import { FC } from "react";

const ReportRow = ({ data, name, min, max }: any) => {
Expand Down Expand Up @@ -53,6 +53,7 @@ interface ReportTableProps {
patientDetails?: {
name: string;
age: number;
date_of_birth: string;
hospitalName: string;
};
investigationData: InvestigationResponse;
Expand Down Expand Up @@ -83,7 +84,14 @@ const ReportTable: FC<ReportTableProps> = ({
{patientDetails && (
<div className="flex flex-col gap-1 p-1">
<p>Name: {patientDetails.name}</p>
<p>Age: {patientDetails.age}</p>
<p>
Age:{" "}
{formatAge(
patientDetails.age,
patientDetails.date_of_birth,
true
)}
</p>
<p>Hospital: {patientDetails.hospitalName}</p>
</div>
)}
Expand Down
5 changes: 4 additions & 1 deletion src/Components/Facility/Investigations/Reports/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ const InvestigationReports = ({ id }: any) => {
const [patientDetails, setPatientDetails] = useState<{
name: string;
age: number;
date_of_birth: string;
hospitalName: string;
}>({ name: "", age: -1, hospitalName: "" });
}>({ name: "", age: -1, date_of_birth: "", hospitalName: "" });
const [state, dispatch] = useReducer(
investigationReportsReducer,
initialState
Expand Down Expand Up @@ -220,13 +221,15 @@ const InvestigationReports = ({ id }: any) => {
setPatientDetails({
name: res.data.name,
age: res.data.age,
date_of_birth: res.data.date_of_birth,
hospitalName: res.data.facility_object.name,
});
}
} else {
setPatientDetails({
name: "",
age: -1,
date_of_birth: "",
hospitalName: "",
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/Components/Facility/LegacyMonitorCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import CareIcon from "../../CAREUI/icons/CareIcon";
import { PatientModel } from "../Patient/models";
import LegacyPatientVitalsCard from "../Patient/LegacyPatientVitalsCard";
import { AssetLocationObject } from "../Assets/AssetTypes";
import { formatAge } from "../../Utils/utils";

interface MonitorCardProps {
facilityId: string;
Expand All @@ -28,7 +29,7 @@ export const LegacyMonitorCard = ({
{patient.name}
</Link>
<span>
{patient.age}y |{" "}
{formatAge(patient.age, patient.date_of_birth)} |{" "}
{GENDER_TYPES.find((g) => g.id === patient.gender)?.icon}
</span>
<span className="flex flex-1 items-center justify-end gap-2 text-end">
Expand Down
Loading

0 comments on commit fddc9d2

Please sign in to comment.