Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Consultation Camera Feed to use newer camera feed components #7654

Merged
merged 23 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
13f5f76
Migrate consultation feed to use newer camera feed components
rithviknishad Apr 18, 2024
03b4673
remove console logs
rithviknishad Apr 18, 2024
2e5b196
adds plausible tracking
rithviknishad Apr 18, 2024
ab47c1c
remove unused code
rithviknishad Apr 18, 2024
a9c924b
Revert "remove unused code"
rithviknishad Apr 18, 2024
d3af2ec
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad Apr 18, 2024
2ebc89a
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad Apr 22, 2024
7d8bb6a
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad Apr 24, 2024
07235c0
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad Apr 25, 2024
0d9ff72
fix responsiveness and full screen issues
rithviknishad Apr 25, 2024
c6fa212
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
nihal467 Apr 29, 2024
bf09845
Adds support for updating presets in consultation camera feed
rithviknishad Apr 30, 2024
e718b46
disable update preset if camera not moved
rithviknishad Apr 30, 2024
05869a0
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad May 7, 2024
ac1d00b
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad May 17, 2024
a6ff6da
fix loading state issue
rithviknishad May 17, 2024
7682993
revert unintended changes
rithviknishad May 17, 2024
75fc5b0
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
nihal467 May 21, 2024
8e8a357
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad May 22, 2024
69436e0
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad May 22, 2024
f61661f
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad May 22, 2024
c164ab7
Merge branch 'develop' into migrate-consultation-feed-to-newer-compon…
rithviknishad May 22, 2024
b3ecfa4
fix responsiveness of tooltip
rithviknishad May 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/Components/CameraFeed/AssetBedSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,20 @@ export default function AssetBedSelect(props: Props) {

const selected = props.value;

const label = (obj: AssetBedModel) => {
return props.bed
? obj.meta.preset_name
: `${obj.bed_object.name}: ${obj.meta.preset_name}`;
};

const options = data?.results.filter(({ meta }) => meta.type !== "boundary");

return (
<Listbox value={selected} onChange={props.onChange} disabled={loading}>
<div className="relative">
<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">
<span className="block truncate">
{selected?.bed_object.name ?? "No Preset"}
{selected ? label(selected) : "No Preset"}
</span>
<span className="pointer-events-none absolute inset-y-0 right-0 mt-1 flex items-center">
<CareIcon icon="l-angle-down" className="text-lg text-zinc-500" />
Expand All @@ -46,7 +54,7 @@ export default function AssetBedSelect(props: Props) {
leaveTo="opacity-0"
>
<Listbox.Options className="absolute z-20 mt-1 max-h-48 w-full overflow-auto rounded-b-lg bg-zinc-900/75 py-1 text-base shadow-lg ring-1 ring-white/5 backdrop-blur-sm focus:outline-none sm:text-sm md:max-h-60">
{data?.results.map((obj) => (
{options?.map((obj) => (
<Listbox.Option
key={obj.id}
className={({ active }) =>
Expand All @@ -63,7 +71,7 @@ export default function AssetBedSelect(props: Props) {
selected ? "font-bold text-white" : "font-normal"
}`}
>
{obj.bed_object.name}: {obj.meta.preset_name}
{label(obj)}
</span>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,48 @@
import { lazy } from "react";
import { Feed } from "../Consultations/Feed";
import { lazy, useState } from "react";
import { ConsultationTabProps } from "./index";
import { AssetBedModel, AssetData } from "../../Assets/AssetTypes";
import routes from "../../../Redux/api";
import useQuery from "../../../Utils/request/useQuery";
import CameraFeed from "../../CameraFeed/CameraFeed";
import Loading from "../../Common/Loading";
import AssetBedSelect from "../../CameraFeed/AssetBedSelect";
import { triggerGoal } from "../../../Integrations/Plausible";
import useAuthUser from "../../../Common/hooks/useAuthUser";

const PageTitle = lazy(() => import("../../Common/PageTitle"));

export const ConsultationFeedTab = (props: ConsultationTabProps) => {
const authUser = useAuthUser();
const bed = props.consultationData.current_bed?.bed_object;

const [asset, setAsset] = useState<AssetData>();
const [preset, setPreset] = useState<AssetBedModel>();

const { loading } = useQuery(routes.listAssetBeds, {
query: { bed: bed?.id },
prefetch: !!bed,
onResponse: ({ data }) => {
if (!data) {
return;
}

const preset = data.results.find(
(obj) =>
obj.asset_object.meta?.asset_type === "CAMERA" &&
obj.meta.type !== "boundary",
);

if (preset) {
setPreset(preset);
setAsset(preset.asset_object);
}
},
});

if (!bed) {
return <span>No bed allocated</span>;
}

return (
<div>
<PageTitle
Expand All @@ -13,10 +51,46 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => {
hideBack={true}
focusOnLoad={true}
/>
<Feed
facilityId={props.facilityId}
consultationId={props.consultationId}
/>
{loading || !asset ? (
<Loading />
) : (
<CameraFeed
asset={asset}
silent
preset={preset?.meta.position}
onStreamError={() => {
triggerGoal("Camera Feed Viewed", {
consultationId: props.consultationId,
userId: authUser.id,
result: "error",
});
}}
onStreamSuccess={() => {
triggerGoal("Camera Feed Viewed", {
consultationId: props.consultationId,
userId: authUser.id,
result: "success",
});
}}
>
<div className="w-64">
<AssetBedSelect
asset={asset}
bed={bed}
value={preset}
onChange={(value) => {
triggerGoal("Camera Preset Clicked", {
presetName: preset?.meta?.preset_name,
consultationId: props.consultationId,
userId: authUser.id,
result: "success",
});
setPreset(value);
}}
/>
</div>
</CameraFeed>
)}
</div>
);
};
51 changes: 0 additions & 51 deletions src/Components/Facility/ConsultationDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,57 +208,6 @@ export const ConsultationDetails = (props: any) => {
selected === true ? "border-primary-500 text-primary-600 border-b-2" : ""
}`;

// const ShowDiagnosis = ({
// diagnoses = [],
// label = "Diagnosis",
// nshow = 2,
// }: {
// diagnoses: ICD11DiagnosisModel[] | undefined;
// label: string;
// nshow?: number;
// }) => {
// const [showMore, setShowMore] = useState(false);

// return diagnoses.length ? (
// <div className="w-full text-sm">
// <p className="font-semibold leading-relaxed">{label}</p>
// {diagnoses.slice(0, !showMore ? nshow : undefined).map((diagnosis) =>
// diagnosis.id === consultationData.icd11_principal_diagnosis ? (
// <div className="relative flex items-center gap-2">
// <p>{diagnosis.label}</p>
// <div>
// <ToolTip text="Principal Diagnosis" position="BOTTOM">
// <CareIcon icon="l-stethoscope" className="rounded-lg bg-primary-500 p-1 text-2xl text-white"/>
// </ToolTip>
// </div>
// </div>
// ) : (
// <p>{diagnosis.label}</p>
// )
// )}
// {diagnoses.length > nshow && (
// <>
// {!showMore ? (
// <a
// onClick={() => setShowMore(true)}
// className="cursor-pointer text-sm text-blue-600 hover:text-blue-300"
// >
// show more
// </a>
// ) : (
// <a
// onClick={() => setShowMore(false)}
// className="cursor-pointer text-sm text-blue-600 hover:text-blue-300"
// >
// show less
// </a>
// )}
// </>
// )}
// </div>
// ) : null;
// };

return (
<div>
<div className="px-2 pb-2">
Expand Down
Loading