Skip to content

Commit

Permalink
Merge branch 'develop' into issue#7354
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 committed May 28, 2024
2 parents ac24ceb + 71fb32e commit 8948eaa
Show file tree
Hide file tree
Showing 18 changed files with 438 additions and 283 deletions.
6 changes: 6 additions & 0 deletions cypress/e2e/users_spec/user_homepage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe("User Homepage", () => {
userPage.selectDistrict("Ernakulam");
userPage.typeInPhoneNumber(phone_number);
userPage.typeInAltPhoneNumber(alt_phone_number);
userPage.selectHomeFacility("Dummy Facility 40");
userPage.applyFilter();
userPage.verifyUrlafteradvancefilter();
userPage.checkUsernameText(usernameToTest);
Expand All @@ -46,13 +47,18 @@ describe("User Homepage", () => {
"WhatsApp no.: +919876543219",
);
userPage.verifyDataTestIdText("Role", "Role: Doctor");
userPage.verifyDataTestIdText(
"Home Facility",
"Home Facility: Dummy Facility 40",
);
userPage.verifyDataTestIdText("District", "District: Ernakulam");
userPage.clearFilters();
userPage.verifyDataTestIdNotVisible("First Name");
userPage.verifyDataTestIdNotVisible("Last Name");
userPage.verifyDataTestIdNotVisible("Phone Number");
userPage.verifyDataTestIdNotVisible("WhatsApp no.");
userPage.verifyDataTestIdNotVisible("Role");
userPage.verifyDataTestIdNotVisible("Home Facility");
userPage.verifyDataTestIdNotVisible("District");
});

Expand Down
4 changes: 4 additions & 0 deletions cypress/pageobject/Users/UserSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ export class UserPage {
cy.get("#alt_phone_number").click().type(altPhone);
}

selectHomeFacility(facility: string) {
cy.searchAndSelectOption("input[name='home_facility']", facility);
}

applyFilter() {
cy.get("#apply-filter").click();
}
Expand Down
40 changes: 37 additions & 3 deletions src/Components/CameraFeed/AssetBedSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Fragment } from "react";
import { AssetBedModel } from "../Assets/AssetTypes";
import { Listbox, Transition } from "@headlessui/react";
import CareIcon from "../../CAREUI/icons/CareIcon";
import { classNames } from "../../Utils/utils";

interface Props {
options: AssetBedModel[];
Expand All @@ -10,7 +11,40 @@ interface Props {
onChange?: (value: AssetBedModel) => void;
}

export default function AssetBedSelect(props: Props) {
export default function CameraPresetSelect(props: Props) {
const label = props.label ?? defaultLabel;
return (
<>
<div className="hidden gap-2 whitespace-nowrap pr-2 md:flex">
{props.options
.slice(0, props.options.length > 5 ? 4 : 5)
.map((option) => (
<button
className={classNames(
"rounded-xl border px-2 py-0.5 text-xs transition-all duration-200 ease-in-out hover:bg-zinc-600",
props.value?.id === option.id
? "border-white bg-zinc-100 font-bold text-black"
: "border-white/50 text-zinc-100",
)}
onClick={() => props.onChange?.(option)}
>
{label(option)}
</button>
))}
{/* Desktop View */}
{props.options.length > 5 && (
<ShowMoreDropdown {...props} options={props.options.slice(4)} />
)}
</div>
<div className="md:hidden">
{/* Mobile View */}
<ShowMoreDropdown {...props} />
</div>
</>
);
}

const ShowMoreDropdown = (props: Props) => {
const selected = props.value;

const options = props.options.filter(({ meta }) => meta.type !== "boundary");
Expand All @@ -20,7 +54,7 @@ export default function AssetBedSelect(props: Props) {
return (
<Listbox value={selected} onChange={props.onChange}>
<div className="relative flex-1">
<Listbox.Button className="relative w-full cursor-default pr-6 text-right text-xs text-zinc-400 focus:outline-none disabled:cursor-not-allowed disabled:bg-transparent disabled:text-zinc-700 sm:text-sm">
<Listbox.Button className="relative w-full cursor-default pr-6 text-right text-xs text-white focus:outline-none disabled:cursor-not-allowed disabled:bg-transparent disabled:text-zinc-700 sm:text-sm md:pl-2">
<span className="block truncate">
{selected ? label(selected) : "No Preset"}
</span>
Expand Down Expand Up @@ -63,7 +97,7 @@ export default function AssetBedSelect(props: Props) {
</div>
</Listbox>
);
}
};

const defaultLabel = ({ bed_object, meta }: AssetBedModel) => {
return `${bed_object.name}: ${meta.preset_name}`;
Expand Down
15 changes: 12 additions & 3 deletions src/Components/CameraFeed/CameraFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import FeedNetworkSignal from "./FeedNetworkSignal";
import NoFeedAvailable from "./NoFeedAvailable";
import FeedControls from "./FeedControls";
import Fullscreen from "../../CAREUI/misc/Fullscreen";
import FeedWatermark from "./FeedWatermark";
import CareIcon from "../../CAREUI/icons/CareIcon";

interface Props {
children?: React.ReactNode;
Expand Down Expand Up @@ -86,7 +88,6 @@ export default function CameraFeed(props: Props) {
setState("loading");
initializeStream();
};

return (
<Fullscreen fullscreen={isFullscreen} onExit={() => setFullscreen(false)}>
<div
Expand All @@ -96,8 +97,13 @@ export default function CameraFeed(props: Props) {
)}
>
<div className="flex items-center justify-between bg-zinc-900 px-4 py-0.5">
<div className="flex items-center gap-1 md:gap-2">
{props.children}
<div className="flex w-full items-center justify-end gap-1 md:gap-4">
<span className="text-xs font-semibold text-white md:text-sm">
<CareIcon
icon="l-video"
className="hidden pr-2 text-base text-zinc-400 md:inline-block"
/>
{props.asset.name}
</span>
<div className={state === "loading" ? "animate-pulse" : ""}>
Expand All @@ -109,12 +115,12 @@ export default function CameraFeed(props: Props) {
/>
</div>
</div>
{props.children}
</div>

<div className="group relative aspect-video">
{/* Notifications */}
<FeedAlert state={state} />
{player.status === "playing" && <FeedWatermark />}

{/* No Feed informations */}
{state === "host_unreachable" && (
Expand Down Expand Up @@ -145,6 +151,7 @@ export default function CameraFeed(props: Props) {
url={streamUrl}
ref={playerRef.current as LegacyRef<ReactPlayer>}
controls={false}
pip={false}
playsinline
playing
muted
Expand All @@ -162,10 +169,12 @@ export default function CameraFeed(props: Props) {
</div>
) : (
<video
onContextMenu={(e) => e.preventDefault()}
className="absolute inset-0 w-full"
id="mse-video"
autoPlay
muted
disablePictureInPicture
playsInline
onPlay={player.onPlayCB}
onEnded={() => player.setStatus("stop")}
Expand Down
55 changes: 55 additions & 0 deletions src/Components/CameraFeed/FeedWatermark.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { useEffect, useRef } from "react";
import useAuthUser from "../../Common/hooks/useAuthUser";

export default function FeedWatermark() {
const me = useAuthUser();
return (
<>
<Watermark className="left-1/3 top-1/3 -translate-x-1/2 -translate-y-1/2">
{me.username}
</Watermark>
<Watermark className="right-1/3 top-1/3 -translate-y-1/2 translate-x-1/2">
{me.username}
</Watermark>
<Watermark className="bottom-1/3 left-1/3 -translate-x-1/2 translate-y-1/2">
{me.username}
</Watermark>
<Watermark className="bottom-1/3 right-1/3 translate-x-1/2 translate-y-1/2">
{me.username}
</Watermark>
</>
);
}

const Watermark = (props: { children: string; className: string }) => {
const ref = useRef<HTMLSpanElement>(null);
const parentRef = useRef<HTMLElement | null>(null);

// This adds the element back if the element was removed from the DOM
useEffect(() => {
parentRef.current = ref.current?.parentElement || null;
let animationFrameId: number;

const checkWatermark = () => {
const watermark = ref.current;
const parent = parentRef.current;
if (watermark && parent && !parent.contains(watermark)) {
parent.appendChild(watermark);
}
animationFrameId = requestAnimationFrame(checkWatermark);
};

animationFrameId = requestAnimationFrame(checkWatermark);

return () => cancelAnimationFrame(animationFrameId);
}, []);

return (
<span
ref={ref}
className={`absolute z-10 text-2xl font-bold text-white/30 ${props.className}`}
>
{props.children}
</span>
);
};
5 changes: 4 additions & 1 deletion src/Components/Common/SkillSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export const SkillSelect = (props: SkillSelectProps) => {

const { data } = await request(routes.getAllSkills, { query });
return data?.results.filter(
(skill) => !userSkills?.some((userSkill) => userSkill.id === skill.id),
(skill) =>
!userSkills?.some(
(userSkill) => userSkill.skill_object.id === skill.id,
),
);
},
[searchAll, userSkills],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => {
});
}}
>
<div className="flex w-36 items-center justify-end md:w-64">
<div className="flex items-center">
{presets ? (
<>
<AssetBedSelect
Expand All @@ -141,27 +141,30 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => {
{isUpdatingPreset ? (
<CareIcon
icon="l-spinner"
className="animate-spin text-base text-zinc-500 md:mx-2"
className="animate-spin text-base text-zinc-300 md:mx-2"
/>
) : (
<ButtonV2
size="small"
variant="secondary"
disabled={!hasMoved}
className="disabled:bg-transparent disabled:text-zinc-700"
className="hover:bg-zinc-700 disabled:bg-transparent"
ghost
tooltip={
hasMoved
? "Save current position to preset"
? "Save current position to selected preset"
: "Change camera position to update preset"
}
tooltipClassName={classNames(
"translate-y-8 text-xs",
hasMoved ? "-translate-x-20" : "-translate-x-28",
)}
tooltipClassName="translate-y-8 text-xs"
onClick={handleUpdatePreset}
>
<CareIcon icon="l-save" className="text-base" />
<CareIcon
icon="l-save"
className={classNames(
"text-base",
hasMoved ? "text-gray-200" : "text-gray-500",
)}
/>
</ButtonV2>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ import { BedModel } from "../models";
import HL7PatientVitalsMonitor from "../../VitalsMonitor/HL7PatientVitalsMonitor";
import VentilatorPatientVitalsMonitor from "../../VitalsMonitor/VentilatorPatientVitalsMonitor";
import useVitalsAspectRatioConfig from "../../VitalsMonitor/useVitalsAspectRatioConfig";
import {
CONSENT_PATIENT_CODE_STATUS_CHOICES,
CONSENT_TYPE_CHOICES,
DISCHARGE_REASONS,
SYMPTOM_CHOICES,
} from "../../../Common/constants";
import { DISCHARGE_REASONS, SYMPTOM_CHOICES } from "../../../Common/constants";
import PrescriptionsTable from "../../Medicine/PrescriptionsTable";
import Chip from "../../../CAREUI/display/Chip";
import {
Expand All @@ -25,7 +20,6 @@ import DailyRoundsList from "../Consultations/DailyRoundsList";
import EventsList from "./Events/EventsList";
import SwitchTabs from "../../Common/components/SwitchTabs";
import { getVitalsMonitorSocketUrl } from "../../VitalsMonitor/utils";
import { FileUpload } from "../../Patient/FileUpload";
import useQuery from "../../../Utils/request/useQuery";
import routes from "../../../Redux/api";
import CareIcon from "../../../CAREUI/icons/CareIcon";
Expand Down Expand Up @@ -723,47 +717,6 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
</div>
</div>
</div>
{(
props.consultationData.consent_records?.filter(
(record) => record.deleted !== true,
) || []
).length > 0 && (
<>
<div className="col-span-1 overflow-hidden rounded-lg bg-white p-4 shadow md:col-span-2">
<h3 className="text-lg font-semibold leading-relaxed text-gray-900">
Consent Records
</h3>
{props.consultationData.consent_records
?.filter((record) => record.deleted !== true)
?.map((record, i) => (
<div className="mt-4 border-b" key={i}>
<div className="font-bold">
{
CONSENT_TYPE_CHOICES.find(
(c) => c.id === record.type,
)?.text
}{" "}
{record.patient_code_status &&
`( ${
CONSENT_PATIENT_CODE_STATUS_CHOICES.find(
(c) => c.id === record.patient_code_status,
)?.text
} )`}
</div>
<FileUpload
changePageMetadata={false}
type="CONSENT_RECORD"
hideBack
unspecified
className="w-full"
consentId={record.id}
hideUpload
/>
</div>
))}
</div>
</>
)}
</div>
</div>
<div className="w-full pl-0 md:pl-4 xl:w-1/3">
Expand Down
11 changes: 8 additions & 3 deletions src/Components/Facility/ConsultationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -910,11 +910,16 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => {
/>

<div className="top-0 mt-5 flex grow-0 sm:mx-12">
<div className="fixed hidden h-full w-72 flex-col xl:flex">
<div className="fixed hidden w-72 flex-col xl:flex">
{Object.keys(sections).map((sectionTitle) => {
if (!isUpdate && ["Bed Status"].includes(sectionTitle)) {
return null;
}

if (isUpdate && sectionTitle === "Bed Status") {
return null;
}

const isCurrent = currentSection === sectionTitle;
const section = sections[sectionTitle as ConsultationFormSection];
return (
Expand Down Expand Up @@ -1265,7 +1270,7 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => {
</div>
)}

{["A", "DC"].includes(state.form.suggestion) && !isUpdate && (
{state.form.suggestion === "A" && !isUpdate && (
<div className="col-span-6 mb-6" ref={fieldRef["bed"]}>
<FieldLabel>Bed</FieldLabel>
<BedSelect
Expand Down Expand Up @@ -1481,7 +1486,7 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => {
</div>
</div>
</form>
{isUpdate && (
{state.form.suggestion === "A" && isUpdate && (
<>
<div className="mx-auto mt-4 max-w-4xl rounded bg-white px-11 py-8">
{sectionTitle("Bed Status")}
Expand Down
Loading

0 comments on commit 8948eaa

Please sign in to comment.