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

Production release v24.24.0 #8014

Merged
merged 16 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion cypress/pageobject/Patient/PatientInvestigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class PatientInvestigation {
}

selectInvestigation(investigation: string) {
cy.get("#search-patient-investigation").click();
cy.get("#search-patient-investigation").type(investigation);
cy.verifyAndClickElement("#investigation-group", investigation);
cy.verifyAndClickElement("#investigation", "Investigation No. 1");
}
Expand Down
2 changes: 1 addition & 1 deletion src/CAREUI/interactive/FiltersSlideover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const AdvancedFilterButton = ({ onClick }: { onClick: () => void }) => {
<ButtonV2
ghost
border
className="w-full bg-white sm:w-auto"
className="w-full bg-white md:w-auto"
onClick={onClick}
id="advanced-filter"
>
Expand Down
15 changes: 15 additions & 0 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1370,3 +1370,18 @@ export const PATIENT_NOTES_THREADS = {
} as const;

export const RATION_CARD_CATEGORY = ["BPL", "APL", "NO_CARD"] as const;

export const DEFAULT_ALLOWED_EXTENSIONS = [
"image/*",
"video/*",
"audio/*",
"text/plain",
"text/csv",
"application/rtf",
"application/msword",
"application/vnd.oasis.opendocument.text",
"application/pdf",
"application/vnd.ms-excel",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/vnd.oasis.opendocument.spreadsheet,application/pdf",
];
74 changes: 48 additions & 26 deletions src/Components/Assets/AssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,40 +105,63 @@ const AssetsList = () => {
prefetch: !!(qParams.facility && qParams.location),
});

const getAssetIdFromQR = async (assetUrl: string) => {
function isValidURL(url: string) {
try {
new URL(url);
return true;
} catch (_) {
return false;
}
}

const accessAssetIdFromQR = async (assetURL: string) => {
try {
setIsLoading(true);
setIsScannerActive(false);
const params = parseQueryParams(assetUrl);
if (!isValidURL(assetURL)) {
setIsLoading(false);
Notification.Error({
msg: "Invalid QR code scanned !!!",
});
return;
}
const params = parseQueryParams(assetURL);
// QR Maybe searchParams "asset" or "assetQR"
// If no params found, then use assetText
const assetId = params.asset || params.assetQR;

if (assetId) {
const { data } = await request(routes.listAssets, {
query: { qr_code_id: assetId },
const { data } = await request(routes.listAssetQR, {
pathParams: { qr_code_id: assetId },
});
if (!data) {
setIsLoading(false);
Notification.Error({
msg: "Invalid QR code scanned !!!",
});
return;
}
const { data: assetData } = await request(routes.listAssets, {
query: { qr_code_id: assetId, limit: 1 },
});
if (assetData?.results.length === 1) {
navigate(
`/facility/${assetData.results[0].location_object.facility?.id}/assets/${assetData.results[0].id}`,
);
} else {
setIsLoading(false);
Notification.Error({
msg: "Asset not found !!!",
});
}
} else {
setIsLoading(false);
Notification.Error({
msg: "Invalid QR code scanned !!!",
});
return data?.results[0].id;
}
} catch (err) {
console.log(err);
}
};

const checkValidAssetId = async (assetId: string) => {
const { data: assetData } = await request(routes.getAsset, {
pathParams: { external_id: assetId },
});
try {
if (assetData) {
navigate(
`/facility/${assetData.location_object.facility?.id}/assets/${assetId}`,
);
}
} catch (err) {
console.log(err);
setIsLoading(false);
Notification.Error({
msg: "Invalid QR code scanned !!!",
});
}
};

Expand All @@ -159,8 +182,7 @@ const AssetsList = () => {
<Scanner
onResult={async (text) => {
if (text) {
const assetId = await getAssetIdFromQR(text);
checkValidAssetId(assetId ?? text);
await accessAssetIdFromQR(text);
}
}}
onError={(e) => {
Expand Down
23 changes: 22 additions & 1 deletion src/Components/Common/FilePreviewDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ type FilePreviewProps = {
fixedWidth?: boolean;
};

const previewExtensions = [
".html",
".htm",
".pdf",
".mp4",
".webm",
".jpg",
".jpeg",
".png",
".gif",
".webp",
];

const FilePreviewDialog = (props: FilePreviewProps) => {
const { show, onClose, file_state, setFileState, downloadURL, fileUrl } =
props;
Expand Down Expand Up @@ -130,13 +143,21 @@ const FilePreviewDialog = (props: FilePreviewProps) => {
}}
pageNumber={page}
/>
) : (
) : previewExtensions.includes(file_state.extension) ? (
<iframe
sandbox=""
title="Source Files"
src={fileUrl}
className="h-[75vh] w-full"
/>
) : (
<div className="flex h-full w-full flex-col items-center justify-center">
<CareIcon
icon="l-file"
className="mb-4 text-5xl text-gray-600"
/>
Can't preview this file. Try downloading it.
</div>
)}
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/Components/Common/SortDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ export default function SortDropdownMenu(props: Props) {
<DropdownMenu
title={props.label ?? t("sort_by")}
variant="secondary"
className="border border-primary-500 bg-white"
className="w-full border border-primary-500 bg-white md:w-auto"
icon={<CareIcon icon="l-sort" />}
containerClassName="w-full md:w-auto"
>
{props.options.map(({ isAscending, value }) => (
<DropdownItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,11 @@ let make = (
(state.ventilator_interface !=
CriticalCare__VentilatorParameters.decodeVentilatorInterfaceType(
ventilatorInterfaceOptions[0].value,
) ||
switch state.bilateral_air_entry {
| Some(true) => true
| _ => false
} ||
switch (state.etco2) {
| Some(intValue) => true
| None => false
})
) &&
state.ventilator_interface !=
CriticalCare__VentilatorParameters.decodeVentilatorInterfaceType(
ventilatorInterfaceOptions[3].value,
))
) {
toggleOpen()
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from "react";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import AutocompleteFormField from "../../Form/FormFields/Autocomplete";
import {
Expand All @@ -10,6 +10,7 @@ import ConditionVerificationStatusMenu from "../ConditionVerificationStatusMenu"
import { classNames, mergeQueryOptions } from "../../../Utils/utils";
import useQuery from "../../../Utils/request/useQuery";
import routes from "../../../Redux/api";
import { Error } from "../../../Utils/Notifications";

interface AddICD11DiagnosisProps {
className?: string;
Expand All @@ -24,7 +25,15 @@ export default function AddICD11Diagnosis(props: AddICD11DiagnosisProps) {
const [adding, setAdding] = useState(false);
const hasError = !!props.disallowed.find((d) => d?.id === selected?.id);

const { data, loading, refetch } = useQuery(routes.listICD11Diagnosis);
const { res, data, loading, refetch } = useQuery(routes.listICD11Diagnosis, {
silent: true,
});

useEffect(() => {
if (res?.status === 500) {
Error({ msg: "ICD-11 Diagnosis functionality is facing issues." });
}
}, [res?.status]);

const handleAdd = async (status: CreateDiagnosis["verification_status"]) => {
if (!selected) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ export default function ConsultationDiagnosisEntry(props: Props) {
? "font-semibold text-primary-500"
: "font-normal",
!isActive && "text-gray-500 line-through",
!object.diagnosis_object?.label && "italic text-gray-500",
)}
>
{object.diagnosis_object?.label}
{object.diagnosis_object?.label ||
"Unable to retrieve this ICD-11 diagnosis at the moment"}
</span>
<div className="flex items-center justify-end gap-2 sm:flex-row md:absolute md:inset-y-0 md:right-2 md:justify-normal">
<div className="w-32">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@ const PrincipalDiagnosisSelect = <T extends Option>(props: Props<T>) => {
}}
errorClassName="hidden"
/>
{diagnosis && (
<span className="mt-3 flex w-full flex-wrap justify-center gap-x-1 px-2 text-center text-gray-900">
<p>This encounter will be categorised under:</p>
<p className="font-bold">{diagnosis.chapter}</p>
</span>
)}
{diagnosis &&
(diagnosis.chapter ? (
<span className="mt-3 flex w-full flex-wrap justify-center gap-x-1 px-2 text-center text-gray-900">
<p>This encounter will be categorised under:</p>
<p className="font-bold">{diagnosis.chapter}</p>
</span>
) : (
<span className="mt-3 flex w-full flex-wrap justify-center gap-x-1 px-2 text-center italic text-gray-700">
This encounter will not be categorised under any chapter as the
diagnosis does not fall under a chapter.
</span>
))}
</div>
</div>
);
Expand Down
11 changes: 9 additions & 2 deletions src/Components/Diagnosis/DiagnosesListAccordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ConsultationDiagnosis,
} from "./types";
import { useTranslation } from "react-i18next";
import { compareBy } from "../../Utils/utils";
import { classNames, compareBy } from "../../Utils/utils";
import { useState } from "react";
import CareIcon from "../../CAREUI/icons/CareIcon";
import ButtonV2 from "../Common/components/ButtonV2";
Expand Down Expand Up @@ -96,7 +96,14 @@ const DiagnosesOfStatus = ({ diagnoses }: Props) => {
<ul className="text-sm">
{diagnoses.map((diagnosis) => (
<li key={diagnosis.id} className="flex items-center gap-2">
<span>{diagnosis.diagnosis_object?.label}</span>
<span
className={classNames(
!diagnosis.diagnosis_object?.label && "italic text-gray-500",
)}
>
{diagnosis.diagnosis_object?.label ||
"Unable to resolve ICD-11 diagnosis at the moment"}
</span>
</li>
))}
</ul>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Diagnosis/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PerformedByModel } from "../HCX/misc";
export type ICD11DiagnosisModel = {
id: string;
label: string;
chapter: string;
chapter?: string;
};

export const ActiveConditionVerificationStatuses = [
Expand Down
10 changes: 9 additions & 1 deletion src/Components/Facility/ConsultationDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import PatientInfoCard from "../../Patient/PatientInfoCard";
import RelativeDateUserMention from "../../Common/RelativeDateUserMention";
import DiagnosesListAccordion from "../../Diagnosis/DiagnosesListAccordion";
import { CameraFeedPermittedUserTypes } from "../../../Utils/permissions";
import Error404 from "../../ErrorPages/404";

const Loading = lazy(() => import("../../Common/Loading"));
const PageTitle = lazy(() => import("../../Common/PageTitle"));
Expand Down Expand Up @@ -68,7 +69,10 @@ const TABS = {

export const ConsultationDetails = (props: any) => {
const { facilityId, patientId, consultationId } = props;
const tab = props.tab.toUpperCase() as keyof typeof TABS;
let tab = undefined;
if (Object.keys(TABS).includes(props.tab.toUpperCase())) {
tab = props.tab.toUpperCase() as keyof typeof TABS;
}
const dispatch: any = useDispatch();
const [isLoading, setIsLoading] = useState(false);
const [showDoctors, setShowDoctors] = useState(false);
Expand Down Expand Up @@ -194,6 +198,10 @@ export const ConsultationDetails = (props: any) => {
patientData,
};

if (!tab) {
return <Error404 />;
}

const SelectedTab = TABS[tab];

if (isLoading) {
Expand Down
10 changes: 6 additions & 4 deletions src/Components/Facility/ConsultationForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Notification from "../../Utils/Notifications.js";

import { BedModel, ConsentRecord, FacilityModel } from "./models";
import { BedModel, FacilityModel } from "./models";
import {
CONSULTATION_SUGGESTION,
DISCHARGE_REASONS,
Expand Down Expand Up @@ -119,7 +119,6 @@ type FormDetails = {
death_confirmed_doctor: string;
InvestigationAdvice: InvestigationType[];
procedures: ProcedureType[];
consent_records: ConsentRecord[];
};

const initForm: FormDetails = {
Expand Down Expand Up @@ -170,7 +169,6 @@ const initForm: FormDetails = {
death_confirmed_doctor: "",
InvestigationAdvice: [],
procedures: [],
consent_records: [],
};

const initError = Object.assign(
Expand Down Expand Up @@ -1359,7 +1357,11 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => {
>
<FieldLabel>Procedures</FieldLabel>
<ProcedureBuilder
procedures={state.form.procedure}
procedures={
Array.isArray(state.form.procedure)
? state.form.procedure
: []
}
setProcedures={(procedure) => {
handleFormFieldChange({
name: "procedure",
Expand Down
Loading
Loading