Skip to content

Commit

Permalink
Merge branch 'develop' into fix#6429
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Nov 7, 2023
2 parents 8896de6 + 585cb5a commit 0535375
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 9 deletions.
12 changes: 9 additions & 3 deletions src/Components/Assets/AssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const AssetsList = () => {
status: qParams.status || "",
};

useQuery(routes.listAssets, {
const { loading } = useQuery(routes.listAssets, {
query: params,
onResponse: ({ res, data }) => {
if (res?.status === 200 && data) {
Expand Down Expand Up @@ -176,7 +176,13 @@ const AssetsList = () => {
);

let manageAssets = null;
if (assetsExist) {
if (loading) {
manageAssets = (
<div className="col-span-3 w-full py-8 text-center">
<Loading />
</div>
);
} else if (assetsExist) {
manageAssets = (
<div className="grid grid-cols-1 gap-2 md:-mx-8 md:grid-cols-2 lg:grid-cols-3">
{assets.map((asset: AssetData) => (
Expand Down Expand Up @@ -309,7 +315,7 @@ const AssetsList = () => {
<CountBlock
text="Total Assets"
count={totalCount}
loading={isLoading}
loading={loading}
icon="l-monitor-heart-rate"
className="flex-1"
/>
Expand Down
15 changes: 15 additions & 0 deletions src/Components/Facility/ConsultationDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ConsultationModel, ICD11DiagnosisModel } from "../models";
import {
getConsultation,
getPatient,
listAssetBeds,
listShiftRequests,
} from "../../../Redux/actions";
import { statusType, useAbortableEffect } from "../../../Common/utils";
Expand Down Expand Up @@ -88,6 +89,7 @@ export const ConsultationDetails = (props: any) => {
const [openDischargeSummaryDialog, setOpenDischargeSummaryDialog] =
useState(false);
const [openDischargeDialog, setOpenDischargeDialog] = useState(false);
const [isCameraAttached, setIsCameraAttached] = useState(false);

const getPatientGender = (patientData: any) =>
GENDER_TYPES.find((i) => i.id === patientData.gender)?.text;
Expand Down Expand Up @@ -126,6 +128,17 @@ export const ConsultationDetails = (props: any) => {
data.symptoms_text = symptoms.join(", ");
}
setConsultationData(data);
const assetRes = await dispatch(
listAssetBeds({
bed: data?.current_bed?.bed_object?.id,
})
);
const isCameraAttachedRes = assetRes.data.results.some(
(asset: { asset_object: { asset_class: string } }) => {
return asset?.asset_object?.asset_class === "ONVIF";
}
);
setIsCameraAttached(isCameraAttachedRes);
const id = res.data.patient;
const patientRes = await dispatch(getPatient({ id }));
if (patientRes?.data) {
Expand Down Expand Up @@ -336,6 +349,7 @@ export const ConsultationDetails = (props: any) => {
Doctor Connect
</button>
{patientData.last_consultation?.id &&
isCameraAttached &&
["DistrictAdmin", "StateAdmin", "Doctor"].includes(
authUser.user_type
) && (
Expand Down Expand Up @@ -507,6 +521,7 @@ export const ConsultationDetails = (props: any) => {
{CONSULTATION_TABS.map((p: OptionsType) => {
if (p.text === "FEED") {
if (
isCameraAttached === false || // No camera attached
consultationData?.discharge_date || // Discharged
!consultationData?.current_bed?.bed_object?.id || // Not admitted to bed
!["DistrictAdmin", "StateAdmin", "Doctor"].includes(
Expand Down
4 changes: 1 addition & 3 deletions src/Components/Facility/Consultations/Feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ export const Feed: React.FC<IFeedProps> = ({ consultationId, facilityId }) => {
...bedAssets.data,
results: bedAssets.data.results.filter(
(asset: { asset_object: { meta: { asset_type: string } } }) => {
return asset?.asset_object?.meta?.asset_type === "CAMERA"
? true
: false;
return asset?.asset_object?.meta?.asset_type === "CAMERA";
}
),
},
Expand Down
17 changes: 14 additions & 3 deletions src/Components/Patient/ManagePatients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ import Page from "../Common/components/Page.js";
import dayjs from "dayjs";
import { triggerGoal } from "../../Integrations/Plausible.js";
import useAuthUser from "../../Common/hooks/useAuthUser.js";
import useQuery from "../../Utils/request/useQuery.js";
import routes from "../../Redux/api.js";

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

Expand Down Expand Up @@ -477,6 +479,11 @@ export const PatientManager = () => {
[fetchFacilityBadgeName, fetchLocationBadgeName]
);

const { data: permittedFacilities } = useQuery(
routes.getPermittedFacilities,
{}
);

const LastAdmittedToTypeBadges = () => {
const badge = (key: string, value: any, id: string) => {
return (
Expand Down Expand Up @@ -781,9 +788,13 @@ export const PatientManager = () => {
<ButtonV2
id="add-patient-details"
onClick={() => {
qParams.facility
? navigate(`/facility/${qParams.facility}/patient`)
: setShowDialog(true);
if (qParams.facility)
navigate(`/facility/${qParams.facility}/patient`);
else if (permittedFacilities?.results.length === 1)
navigate(
`/facility/${permittedFacilities?.results[0].id}/patient`
);
else setShowDialog(true);
}}
className="w-full lg:w-fit"
>
Expand Down
1 change: 1 addition & 0 deletions src/Redux/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ const routes = {

getPermittedFacilities: {
path: "/api/v1/facility/",
TRes: Type<PaginatedResponse<FacilityModel>>(),
},

getAllFacilities: {
Expand Down

0 comments on commit 0535375

Please sign in to comment.