{
);
}
- if (assetType === "VENTILATOR") {
+ if (asset.asset_class === "VENTILATOR") {
return (
{
}}
backUrl={`/facility/${facilityId}/assets/${assetId}`}
>
-
+ refetch()}
+ />
);
};
diff --git a/src/Components/Assets/AssetManage.tsx b/src/Components/Assets/AssetManage.tsx
index 143ca2add29..7b3d39314eb 100644
--- a/src/Components/Assets/AssetManage.tsx
+++ b/src/Components/Assets/AssetManage.tsx
@@ -26,16 +26,16 @@ import { UserRole, USER_TYPES } from "../../Common/constants";
import ConfirmDialog from "../Common/ConfirmDialog";
import RecordMeta from "../../CAREUI/display/RecordMeta";
import { useTranslation } from "react-i18next";
-const PageTitle = lazy(() => import("../Common/PageTitle"));
const Loading = lazy(() => import("../Common/Loading"));
import * as Notification from "../../Utils/Notifications.js";
-import AuthorizeFor, { NonReadOnlyUsers } from "../../Utils/AuthorizeFor";
+import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor";
import Uptime from "../Common/Uptime";
import useAuthUser from "../../Common/hooks/useAuthUser";
import dayjs from "dayjs";
import RelativeDateUserMention from "../Common/RelativeDateUserMention";
import { AssetServiceEditModal } from "./AssetServiceEditModal";
import { warrantyAmcValidityChip } from "./AssetsList";
+import Page from "../Common/components/Page";
interface AssetManageProps {
assetId: string;
@@ -232,6 +232,7 @@ const AssetManage = (props: AssetManageProps) => {
{
setServiceEditData({ ...service, open: true });
@@ -241,6 +242,7 @@ const AssetManage = (props: AssetManageProps) => {
{
{item.label}
-
@@ -330,18 +335,28 @@ const AssetManage = (props: AssetManageProps) => {
};
return (
-
-
+
+
+ Export as JSON
+
+ }
+ >
{
{asset?.name}
-
-
-
- Export as JSON
-
-
+
+
+ {assetClassProp.name}
+
+
+
+ {asset?.description}
+ {asset?.asset_type === "INTERNAL" ? (
+
+ ) : (
+
+ )}
{asset?.status === "ACTIVE" ? (
) : (
@@ -398,7 +414,9 @@ const AssetManage = (props: AssetManageProps) => {
)}
- {asset?.description}
+
+ {asset?.description}
+
{[
@@ -407,19 +425,6 @@ const AssetManage = (props: AssetManageProps) => {
icon: "location-pin-alt",
content: asset?.location_object.name,
},
- {
- label: "Asset Type",
- icon: "apps",
- content:
- asset?.asset_type === "INTERNAL"
- ? "Internal Asset"
- : "External Asset",
- },
- {
- label: "Asset Class",
- icon: assetClassProp.icon,
- content: assetClassProp.name,
- },
{
label: "Asset QR Code ID",
icon: "qrcode-scan",
@@ -457,7 +462,6 @@ const AssetManage = (props: AssetManageProps) => {
}
id="configure-asset"
data-testid="asset-configure-button"
- authorizeFor={AuthorizeFor(["DistrictAdmin", "StateAdmin"])}
>
{t("configure")}
@@ -518,7 +522,10 @@ const AssetManage = (props: AssetManageProps) => {
asset?.asset_class &&
asset?.asset_class != AssetClass.NONE &&
}
Service History
-
+
@@ -545,7 +552,10 @@ const AssetManage = (props: AssetManageProps) => {
Transaction History
-
+
@@ -590,7 +600,7 @@ const AssetManage = (props: AssetManageProps) => {
viewOnly={serviceEditData.viewOnly}
/>
)}
-
+
);
};
diff --git a/src/Components/Assets/AssetServiceEditModal.tsx b/src/Components/Assets/AssetServiceEditModal.tsx
index 75c9dd9fc60..66d44d11907 100644
--- a/src/Components/Assets/AssetServiceEditModal.tsx
+++ b/src/Components/Assets/AssetServiceEditModal.tsx
@@ -97,7 +97,10 @@ export const AssetServiceEditModal = (props: {
{edit.edited_by.username}
-
@@ -124,19 +127,25 @@ export const AssetServiceEditModal = (props: {
Serviced On
-
+
{formatDate(editRecord.serviced_on)}
Notes
-
{editRecord.note || "-"}
+
+ {editRecord.note || "-"}
+
)}
{
editRecord ? setEditRecord(undefined) : props.handleClose();
diff --git a/src/Components/Assets/AssetType/HL7Monitor.tsx b/src/Components/Assets/AssetType/HL7Monitor.tsx
index b19190ed410..55f4d0c258e 100644
--- a/src/Components/Assets/AssetType/HL7Monitor.tsx
+++ b/src/Components/Assets/AssetType/HL7Monitor.tsx
@@ -15,6 +15,7 @@ import CareIcon from "../../../CAREUI/icons/CareIcon";
import TextFormField from "../../Form/FormFields/TextFormField";
import HL7PatientVitalsMonitor from "../../VitalsMonitor/HL7PatientVitalsMonitor";
import VentilatorPatientVitalsMonitor from "../../VitalsMonitor/VentilatorPatientVitalsMonitor";
+import useAuthUser from "../../../Common/hooks/useAuthUser";
interface HL7MonitorProps {
assetId: string;
@@ -31,7 +32,7 @@ const HL7Monitor = (props: HL7MonitorProps) => {
const [isLoading, setIsLoading] = useState(true);
const [localipAddress, setLocalIPAddress] = useState("");
const [ipadrdress_error, setIpAddress_error] = useState("");
-
+ const authUser = useAuthUser();
const dispatch = useDispatch();
useEffect(() => {
@@ -87,40 +88,42 @@ const HL7Monitor = (props: HL7MonitorProps) => {
return (
-
-
-
-
- {["HL7MONITOR"].includes(assetType) && (
-
-
+ {["DistrictAdmin", "StateAdmin"].includes(authUser.user_type) && (
+
+ {["HL7MONITOR"].includes(assetType) && (
+
+
+
+ )}
+
+ )}
{assetType === "HL7MONITOR" && (
void;
}
-const ONVIFCamera = (props: ONVIFCameraProps) => {
- const { assetId, facilityId, asset } = props;
+const ONVIFCamera = ({ assetId, facilityId, asset, onUpdated }: Props) => {
const [isLoading, setIsLoading] = useState(true);
const [assetType, setAssetType] = useState("");
const [middlewareHostname, setMiddlewareHostname] = useState("");
@@ -42,9 +43,8 @@ const ONVIFCamera = (props: ONVIFCameraProps) => {
const [refreshPresetsHash, setRefreshPresetsHash] = useState(
Number(new Date())
);
- const [refreshHash, setRefreshHash] = useState(Number(new Date()));
const dispatch = useDispatch();
-
+ const authUser = useAuthUser();
useEffect(() => {
const fetchFacility = async () => {
const res = await dispatch(getPermittedFacility(facilityId));
@@ -87,14 +87,10 @@ const ONVIFCamera = (props: ONVIFCameraProps) => {
dispatch(partialUpdateAsset(assetId, data))
);
if (res?.status === 200) {
- Notification.Success({
- msg: "Asset Configured Successfully",
- });
- setRefreshHash(Number(new Date()));
+ Notification.Success({ msg: "Asset Configured Successfully" });
+ onUpdated?.();
} else {
- Notification.Error({
- msg: "Something went wrong..!",
- });
+ Notification.Error({ msg: "Something went wrong..!" });
}
setLoadingSetConfiguration(false);
} else {
@@ -147,61 +143,62 @@ const ONVIFCamera = (props: ONVIFCameraProps) => {
return (
-
+ {["DistrictAdmin", "StateAdmin"].includes(authUser.user_type) && (
+
+ )}
{assetType === "ONVIF" ? (
{
+ if (isCopied) {
+ const timeout = setTimeout(() => {
+ setIsCopied(false);
+ }, 2000);
+ return () => clearTimeout(timeout);
+ }
+ }, [isCopied]);
+
return (
{asset.manufacturer}
-
-
+
+
{Object.keys(details).map((key) => (
{key}
-
+
{details[key as keyof typeof details] || "--"}
+ {key === "Serial Number" && (
+
+ setIsCopied(true)}
+ >
+ {isCopied ? (
+
+ {t("copied_to_clipboard")}
+
+ ) : (
+
+ )}
+
+ Copy to clipboard
+
+ )}
))}
+
diff --git a/src/Components/CriticalCareRecording/NeurologicalMonitoring/CriticalCare__NeurologicalMonitoringEditor.res b/src/Components/CriticalCareRecording/NeurologicalMonitoring/CriticalCare__NeurologicalMonitoringEditor.res
index f3f789e9dcd..35d137e0414 100644
--- a/src/Components/CriticalCareRecording/NeurologicalMonitoring/CriticalCare__NeurologicalMonitoringEditor.res
+++ b/src/Components/CriticalCareRecording/NeurologicalMonitoring/CriticalCare__NeurologicalMonitoringEditor.res
@@ -485,7 +485,7 @@ let make = (~updateCB, ~neurologicalMonitoring, ~id, ~consultationId) => {
{str("Glasgow Coma Scale")}
-
{str("Eye Open")}
+
{str("Eye Opening Response")}
{Js.Array.mapi(
(x, i) =>
diff --git a/src/Components/CriticalCareRecording/types/CriticalCare__NeurologicalMonitoring.res b/src/Components/CriticalCareRecording/types/CriticalCare__NeurologicalMonitoring.res
index 1e8804c7524..f42ca5c140d 100644
--- a/src/Components/CriticalCareRecording/types/CriticalCare__NeurologicalMonitoring.res
+++ b/src/Components/CriticalCareRecording/types/CriticalCare__NeurologicalMonitoring.res
@@ -45,25 +45,25 @@ let make = (
~limbResponseLowerExtremityRight,
~limbResponseLowerExtremityLeft,
) => {
- inPronePosition: inPronePosition,
- consciousnessLevel: consciousnessLevel,
- consciousnessLevelDetails: consciousnessLevelDetails,
- leftPupilSize: leftPupilSize,
- leftPupilSizeDetails: leftPupilSizeDetails,
- leftPupilLightReaction: leftPupilLightReaction,
- leftPupilLightReactionDetails: leftPupilLightReactionDetails,
- rightPupilSize: rightPupilSize,
- rightPupilSizeDetails: rightPupilSizeDetails,
- rightPupilLightReaction: rightPupilLightReaction,
- rightPupilLightReactionDetails: rightPupilLightReactionDetails,
- glasgowEyeOpen: glasgowEyeOpen,
- glasgowVerbalResponse: glasgowVerbalResponse,
- glasgowMotorResponse: glasgowMotorResponse,
- glasgowTotalCalculated: glasgowTotalCalculated,
- limbResponseUpperExtremityRight: limbResponseUpperExtremityRight,
- limbResponseUpperExtremityLeft: limbResponseUpperExtremityLeft,
- limbResponseLowerExtremityRight: limbResponseLowerExtremityRight,
- limbResponseLowerExtremityLeft: limbResponseLowerExtremityLeft,
+ inPronePosition,
+ consciousnessLevel,
+ consciousnessLevelDetails,
+ leftPupilSize,
+ leftPupilSizeDetails,
+ leftPupilLightReaction,
+ leftPupilLightReactionDetails,
+ rightPupilSize,
+ rightPupilSizeDetails,
+ rightPupilLightReaction,
+ rightPupilLightReactionDetails,
+ glasgowEyeOpen,
+ glasgowVerbalResponse,
+ glasgowMotorResponse,
+ glasgowTotalCalculated,
+ limbResponseUpperExtremityRight,
+ limbResponseUpperExtremityLeft,
+ limbResponseLowerExtremityRight,
+ limbResponseLowerExtremityLeft,
}
let makeConsciousnessLevel = consciousnessLevel => {
@@ -173,8 +173,8 @@ let limpResponseToString = limpResponse => {
let eyeOpenToString = eyeOpen => {
switch eyeOpen {
- | 1 => "1 - None"
- | 2 => "2 - Pain"
+ | 1 => "1 - No Response"
+ | 2 => "2 - To Pain"
| 3 => "3 - To Speech"
| 4 => "4 - Spontaneous"
| _ => "Unknown"
@@ -183,23 +183,23 @@ let eyeOpenToString = eyeOpen => {
let motorResposneToString = eyeOpen => {
switch eyeOpen {
- | 1 => "1 - None"
- | 2 => "2 - Incomprehensible words/Moans to pain"
+ | 1 => "1 - No Response"
+ | 2 => "2 - Abnormal Extension"
| 3 => "3 - Abnormal Flexion"
- | 4 => "4 - Withdrawing"
- | 5 => "5 - Localizing/Withdrawl to touch"
- | 6 => "6 - Obeying/Normal Activity"
+ | 4 => "4 - Flexion/Withdrawal to pain"
+ | 5 => "5 - Moves to localized pain"
+ | 6 => "6 - Obeys commands/Normal Activity"
| _ => "Unknown"
}
}
let verbalResposneToString = eyeOpen => {
switch eyeOpen {
- | 1 => "1 - None"
+ | 1 => "1 - No Response"
| 2 => "2 - Incomprehensible words/Moans to pain"
| 3 => "3 - Inappropriate words/Cry to pain"
| 4 => "4 - Confused/Irritable"
- | 5 => "5 - Oriented/Coos/Babbies"
+ | 5 => "5 - Oriented to Time, Place and Person"
| _ => "Unknown"
}
}
diff --git a/src/Components/ExternalResult/FacilitiesSelectDialogue.tsx b/src/Components/ExternalResult/FacilitiesSelectDialogue.tsx
index 763d92f2d1f..7239e0b912d 100644
--- a/src/Components/ExternalResult/FacilitiesSelectDialogue.tsx
+++ b/src/Components/ExternalResult/FacilitiesSelectDialogue.tsx
@@ -34,7 +34,7 @@ const FacilitiesSelectDialog = (props: Props) => {
diff --git a/src/Components/ExternalResult/ResultList.tsx b/src/Components/ExternalResult/ResultList.tsx
index 18de6f29134..74fbf8430b0 100644
--- a/src/Components/ExternalResult/ResultList.tsx
+++ b/src/Components/ExternalResult/ResultList.tsx
@@ -6,7 +6,7 @@ import { externalResultList } from "../../Redux/actions";
import ListFilter from "./ListFilter";
import FacilitiesSelectDialogue from "./FacilitiesSelectDialogue";
import { FacilityModel } from "../Facility/models";
-import parsePhoneNumberFromString from "libphonenumber-js";
+import { parsePhoneNumber } from "../../Utils/utils";
import SearchInput from "../Form/SearchInput";
import useFilters from "../../Common/hooks/useFilters";
import CareIcon from "../../CAREUI/icons/CareIcon";
@@ -65,7 +65,7 @@ export default function ResultList() {
page: qParams.page || 1,
name: qParams.name || "",
mobile_number: qParams.mobile_number
- ? parsePhoneNumberFromString(qParams.mobile_number)?.format("E.164")
+ ? parsePhoneNumber(qParams.mobile_number) ?? ""
: "",
wards: qParams.wards || undefined,
local_bodies: qParams.local_bodies || undefined,
diff --git a/src/Components/Facility/AssetCreate.tsx b/src/Components/Facility/AssetCreate.tsx
index 1e6eead5242..156d738857a 100644
--- a/src/Components/Facility/AssetCreate.tsx
+++ b/src/Components/Facility/AssetCreate.tsx
@@ -30,13 +30,12 @@ import TextAreaFormField from "../Form/FormFields/TextAreaFormField";
import TextFormField from "../Form/FormFields/TextFormField";
import { navigate } from "raviger";
-import { parsePhoneNumberFromString } from "libphonenumber-js";
import { parseQueryParams } from "../../Utils/primitives";
import useAppHistory from "../../Common/hooks/useAppHistory";
import { useDispatch } from "react-redux";
import useVisibility from "../../Utils/useVisibility";
import { validateEmailAddress } from "../../Common/validation";
-import { dateQueryString } from "../../Utils/utils.js";
+import { dateQueryString, parsePhoneNumber } from "../../Utils/utils.js";
import dayjs from "../../Utils/dayjs";
import DateInputV2 from "../Common/DateInputV2.js";
@@ -341,7 +340,7 @@ const AssetCreate = (props: AssetProps) => {
support_email: support_email,
support_phone: support_phone.startsWith("1800")
? support_phone
- : parsePhoneNumberFromString(support_phone)?.format("E.164"),
+ : parsePhoneNumber(support_phone),
qr_code_id: qrCodeId !== "" ? qrCodeId : null,
manufacturer: manufacturer,
warranty_amc_end_of_validity: warranty_amc_end_of_validity
diff --git a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx
index 705b3d9479a..1b89f3980e1 100644
--- a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx
+++ b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx
@@ -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";
@@ -621,7 +621,12 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
Age {" - "}
- {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
+ )
+ : "-"}
diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx
index affdb2756cd..403f1752704 100644
--- a/src/Components/Facility/ConsultationDetails/index.tsx
+++ b/src/Components/Facility/ConsultationDetails/index.tsx
@@ -5,10 +5,14 @@ import {
SYMPTOM_CHOICES,
} from "../../../Common/constants";
import { ConsultationModel, ICD11DiagnosisModel } from "../models";
-import { getConsultation, getPatient } from "../../../Redux/actions";
+import {
+ getConsultation,
+ getPatient,
+ listShiftRequests,
+} from "../../../Redux/actions";
import { statusType, useAbortableEffect } from "../../../Common/utils";
import { lazy, useCallback, useState } from "react";
-
+import ToolTip from "../../Common/utils/Tooltip";
import ButtonV2 from "../../Common/components/ButtonV2";
import CareIcon from "../../../CAREUI/icons/CareIcon";
import DischargeModal from "../DischargeModal";
@@ -23,7 +27,7 @@ import { navigate } from "raviger";
import { useDispatch } from "react-redux";
import { useQueryParams } from "raviger";
import { useTranslation } from "react-i18next";
-import { triggerGoal } from "../../Common/Plausible";
+import { triggerGoal } from "../../../Integrations/Plausible";
import useAuthUser from "../../../Common/hooks/useAuthUser";
import { ConsultationUpdatesTab } from "./ConsultationUpdatesTab";
import { ConsultationABGTab } from "./ConsultationABGTab";
@@ -50,10 +54,26 @@ export interface ConsultationTabProps {
patientData: PatientModel;
}
+const TABS = {
+ UPDATES: ConsultationUpdatesTab,
+ FEED: ConsultationFeedTab,
+ SUMMARY: ConsultationSummaryTab,
+ MEDICINES: ConsultationMedicinesTab,
+ FILES: ConsultationFilesTab,
+ INVESTIGATIONS: ConsultationInvestigationsTab,
+ ABG: ConsultationABGTab,
+ NURSING: ConsultationNursingTab,
+ NEUROLOGICAL_MONITORING: ConsultationNeurologicalMonitoringTab,
+ VENTILATOR: ConsultationVentilatorTab,
+ NUTRITION: ConsultationNursingTab,
+ PRESSURE_SORE: ConsultationPressureSoreTab,
+ DIALYSIS: ConsultationDialysisTab,
+};
+
export const ConsultationDetails = (props: any) => {
const { t } = useTranslation();
const { facilityId, patientId, consultationId } = props;
- const tab = props.tab.toUpperCase();
+ const tab = props.tab.toUpperCase() as keyof typeof TABS;
const dispatch: any = useDispatch();
const [isLoading, setIsLoading] = useState(false);
const [showDoctors, setShowDoctors] = useState(false);
@@ -63,6 +83,7 @@ export const ConsultationDetails = (props: any) => {
{} as ConsultationModel
);
const [patientData, setPatientData] = useState
({});
+ const [activeShiftingData, setActiveShiftingData] = useState>([]);
const [openDischargeSummaryDialog, setOpenDischargeSummaryDialog] =
useState(false);
const [openDischargeDialog, setOpenDischargeDialog] = useState(false);
@@ -124,6 +145,15 @@ export const ConsultationDetails = (props: any) => {
};
setPatientData(data);
}
+
+ // Get shifting data
+ const shiftingRes = await dispatch(
+ listShiftRequests({ patient: id }, "shift-list-call")
+ );
+ if (shiftingRes?.data?.results) {
+ const data = shiftingRes.data.results;
+ setActiveShiftingData(data);
+ }
} else {
navigate("/not-found");
}
@@ -142,22 +172,6 @@ export const ConsultationDetails = (props: any) => {
});
}, []);
- const TABS = {
- UPDATES: ConsultationUpdatesTab,
- FEED: ConsultationFeedTab,
- SUMMARY: ConsultationSummaryTab,
- MEDICINES: ConsultationMedicinesTab,
- FILES: ConsultationFilesTab,
- INVESTIGATIONS: ConsultationInvestigationsTab,
- ABG: ConsultationABGTab,
- NURSING: ConsultationNursingTab,
- NEUROLOGICAL_MONITORING: ConsultationNeurologicalMonitoringTab,
- VENTILATOR: ConsultationVentilatorTab,
- NUTRITION: ConsultationNursingTab,
- PRESSURE_SORE: ConsultationPressureSoreTab,
- DIALYSIS: ConsultationDialysisTab,
- };
-
const consultationTabProps: ConsultationTabProps = {
consultationId,
facilityId,
@@ -168,6 +182,19 @@ export const ConsultationDetails = (props: any) => {
const SelectedTab = TABS[tab];
+ const hasActiveShiftingRequest = () => {
+ if (activeShiftingData.length > 0) {
+ return [
+ "PENDING",
+ "APPROVED",
+ "DESTINATION APPROVED",
+ "PATIENT TO BE PICKED UP",
+ ].includes(activeShiftingData[activeShiftingData.length - 1].status);
+ }
+
+ return false;
+ };
+
if (isLoading) {
return ;
}
@@ -191,10 +218,20 @@ export const ConsultationDetails = (props: any) => {
return diagnoses.length ? (
{label}
-
- {diagnoses.slice(0, !showMore ? nshow : undefined).map((diagnosis) => (
-
{diagnosis.label}
- ))}
+ {diagnoses.slice(0, !showMore ? nshow : undefined).map((diagnosis) =>
+ diagnosis.id === consultationData.icd11_principal_diagnosis ? (
+
+
{diagnosis.label}
+
+
+
+
+
+
+ ) : (
+
{diagnosis.label}
+ )
+ )}
{diagnoses.length > nshow && (
<>
{!showMore ? (
@@ -255,17 +292,33 @@ export const ConsultationDetails = (props: any) => {
{!consultationData.discharge_date && (
-
- navigate(
- `/facility/${patientData.facility}/patient/${patientData.id}/shift/new`
- )
- }
- className="btn btn-primary m-1 w-full hover:text-white"
- >
-
- Shift Patient
-
+ {hasActiveShiftingRequest() ? (
+
+ navigate(
+ `/shifting/${
+ activeShiftingData[activeShiftingData.length - 1].id
+ }`
+ )
+ }
+ className="btn btn-primary m-1 w-full hover:text-white"
+ >
+
+ Track Shifting
+
+ ) : (
+
+ navigate(
+ `/facility/${patientData.facility}/patient/${patientData.id}/shift/new`
+ )
+ }
+ className="btn btn-primary m-1 w-full hover:text-white"
+ >
+
+ Shift Patient
+
+ )}
{
triggerGoal("Doctor Connect Clicked", {
@@ -359,22 +412,6 @@ export const ConsultationDetails = (props: any) => {
)*/}
- {consultationData.icd11_principal_diagnosis && (
-
- d.id === consultationData.icd11_principal_diagnosis
- )!,
- ]}
- />
- )}
-
{
{
consultationData.deprecated_verified_by) && (
- Verified By:{" "}
+ Treating Physician:{" "}
{consultationData.verified_by_object
? `${consultationData.verified_by_object.first_name} ${consultationData.verified_by_object.last_name}`
diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx
index 49028a62953..01a5f02b7b1 100644
--- a/src/Components/Facility/ConsultationForm.tsx
+++ b/src/Components/Facility/ConsultationForm.tsx
@@ -97,7 +97,7 @@ type FormDetails = {
procedure: ProcedureType[];
investigation: InvestigationType[];
is_telemedicine: BooleanStrings;
- action?: string;
+ action?: number;
assigned_to: string;
assigned_to_object: UserModel | null;
special_instruction: string;
@@ -123,7 +123,7 @@ const initForm: FormDetails = {
facility: "",
admitted: "false",
admitted_to: "",
- category: "Comfort",
+ category: "",
admission_date: new Date(),
discharge_date: null,
referred_to: "",
@@ -143,7 +143,7 @@ const initForm: FormDetails = {
procedure: [],
investigation: [],
is_telemedicine: "false",
- action: "NO_ACTION",
+ action: 10,
assigned_to: "",
assigned_to_object: null,
special_instruction: "",
@@ -279,15 +279,14 @@ export const ConsultationForm = (props: any) => {
setIsLoading(true);
const res = await dispatchAction(getPatient({ id: patientId }));
if (res.data) {
- setPatientName(res.data.name);
- setFacilityName(res.data.facility_object.name);
if (isUpdate) {
- const form = { ...state.form };
- form.action = TELEMEDICINE_ACTIONS.find(
- (a) => a.id === res.data.action
- )?.text;
- dispatch({ type: "set_form", form });
+ dispatch({
+ type: "set_form",
+ form: { ...state.form, action: res.data.action },
+ });
}
+ setPatientName(res.data.name);
+ setFacilityName(res.data.facility_object.name);
}
} else {
setPatientName("");
@@ -302,6 +301,49 @@ export const ConsultationForm = (props: any) => {
!!state.form.symptoms.length && !state.form.symptoms.includes(1);
const isOtherSymptomsSelected = state.form.symptoms.includes(9);
+ const handleFormFieldChange: FieldChangeEventHandler = (event) => {
+ if (event.name === "consultation_status" && event.value === "1") {
+ dispatch({
+ type: "set_form",
+ form: {
+ ...state.form,
+ consultation_status: 1,
+ symptoms: [1],
+ symptoms_onset_date: new Date(),
+ category: "Critical",
+ suggestion: "DD",
+ },
+ });
+ } else if (event.name === "suggestion" && event.value === "DD") {
+ dispatch({
+ type: "set_form",
+ form: {
+ ...state.form,
+ suggestion: "DD",
+ consultation_notes: "Patient declared dead",
+ verified_by: "Declared Dead",
+ },
+ });
+ } else if (
+ event.name === "icd11_diagnoses_object" ||
+ event.name === "icd11_provisional_diagnoses_object"
+ ) {
+ dispatch({
+ type: "set_form",
+ form: {
+ ...state.form,
+ [event.name]: event.value,
+ icd11_principal_diagnosis: undefined,
+ },
+ });
+ } else {
+ dispatch({
+ type: "set_form",
+ form: { ...state.form, [event.name]: event.value },
+ });
+ }
+ };
+
const fetchData = useCallback(
async (status: statusType) => {
if (!patientId) setIsLoading(true);
@@ -331,8 +373,8 @@ export const ConsultationForm = (props: any) => {
admitted_to: res.data.admitted_to ? res.data.admitted_to : "",
category: res.data.category
? PATIENT_CATEGORIES.find((i) => i.text === res.data.category)
- ?.id ?? "Comfort"
- : "Comfort",
+ ?.id ?? ""
+ : "",
patient_no: res.data.patient_no ?? "",
OPconsultation: res.data.consultation_notes,
is_telemedicine: `${res.data.is_telemedicine}`,
@@ -352,7 +394,7 @@ export const ConsultationForm = (props: any) => {
death_confirmed_doctor: res.data?.death_confirmed_doctor || "",
InvestigationAdvice: res.data.investigation,
};
- dispatch({ type: "set_form", form: formData });
+ dispatch({ type: "set_form", form: { ...state.form, ...formData } });
setBed(formData.bed);
if (res.data.last_daily_round) {
@@ -364,7 +406,7 @@ export const ConsultationForm = (props: any) => {
setIsLoading(false);
}
},
- [dispatchAction, id]
+ [dispatchAction, id, patientName, patientId]
);
useAbortableEffect(
@@ -539,7 +581,7 @@ export const ConsultationForm = (props: any) => {
case "verified_by": {
if (state.form.suggestion !== "DD" && !state.form[field]) {
- errors[field] = "Please fill verified by";
+ errors[field] = "Please fill treating physician";
invalidForm = true;
break;
}
@@ -745,49 +787,6 @@ export const ConsultationForm = (props: any) => {
}
};
- const handleFormFieldChange: FieldChangeEventHandler = (event) => {
- if (event.name === "consultation_status" && event.value === "1") {
- dispatch({
- type: "set_form",
- form: {
- ...state.form,
- consultation_status: 1,
- symptoms: [1],
- symptoms_onset_date: new Date(),
- category: "Critical",
- suggestion: "DD",
- },
- });
- } else if (event.name === "suggestion" && event.value === "DD") {
- dispatch({
- type: "set_form",
- form: {
- ...state.form,
- suggestion: "DD",
- consultation_notes: "Patient declared dead",
- verified_by: "Declared Dead",
- },
- });
- } else if (
- event.name === "icd11_diagnoses_object" ||
- event.name === "icd11_provisional_diagnoses_object"
- ) {
- dispatch({
- type: "set_form",
- form: {
- ...state.form,
- [event.name]: event.value,
- icd11_principal_diagnosis: undefined,
- },
- });
- } else {
- dispatch({
- type: "set_form",
- form: { ...state.form, [event.name]: event.value },
- });
- }
- };
-
const handleDoctorSelect = (event: FieldChangeEvent) => {
if (event.value?.id) {
dispatch({
@@ -1321,7 +1320,7 @@ export const ConsultationForm = (props: any) => {
>
{
option.desc}
- optionValue={(option) => option.text}
+ optionDescription={() => ""}
/>
diff --git a/src/Components/Facility/Consultations/Feed.tsx b/src/Components/Facility/Consultations/Feed.tsx
index 84b3e62ef9e..75ab72d168c 100644
--- a/src/Components/Facility/Consultations/Feed.tsx
+++ b/src/Components/Facility/Consultations/Feed.tsx
@@ -30,7 +30,7 @@ import { useDispatch } from "react-redux";
import { useHLSPLayer } from "../../../Common/hooks/useHLSPlayer";
import useKeyboardShortcut from "use-keyboard-shortcut";
import useFullscreen from "../../../Common/hooks/useFullscreen.js";
-import { triggerGoal } from "../../Common/Plausible.js";
+import { triggerGoal } from "../../../Integrations/Plausible.js";
import useAuthUser from "../../../Common/hooks/useAuthUser.js";
interface IFeedProps {
diff --git a/src/Components/Facility/Consultations/NeurologicalTables.tsx b/src/Components/Facility/Consultations/NeurologicalTables.tsx
index 79a0675a708..89e9d598604 100644
--- a/src/Components/Facility/Consultations/NeurologicalTables.tsx
+++ b/src/Components/Facility/Consultations/NeurologicalTables.tsx
@@ -411,7 +411,9 @@ export const NeurologicalTable = (props: any) => {
Scale Description
-
Eye Open
+
+ Eye Opening Response
+
{EYE_OPEN_SCALE.map((x: any) => (
();
const [isCreateClaimLoading, setIsCreateClaimLoading] = useState(false);
const [isSendingDischargeApi, setIsSendingDischargeApi] = useState(false);
- const [facility, setFacility] = useState
({ id: 0, name: "" }); // for referred to external
+ const [facility, setFacility] = useState();
const [errors, setErrors] = useState({});
const fetchLatestClaim = useCallback(async () => {
@@ -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,
}));
};
@@ -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"
diff --git a/src/Components/Facility/FacilityCard.tsx b/src/Components/Facility/FacilityCard.tsx
index e66fc4f3cc2..43e515cec93 100644
--- a/src/Components/Facility/FacilityCard.tsx
+++ b/src/Components/Facility/FacilityCard.tsx
@@ -9,7 +9,7 @@ import ButtonV2, { Cancel, Submit } from "../Common/components/ButtonV2";
import * as Notification from "../../Utils/Notifications.js";
import Chip from "../../CAREUI/display/Chip";
import CareIcon from "../../CAREUI/icons/CareIcon";
-import { parsePhoneNumber } from "libphonenumber-js";
+import { formatPhoneNumber, parsePhoneNumber } from "../../Utils/utils";
import DialogModal from "../Common/Dialog";
import TextAreaFormField from "../Form/FormFields/TextAreaFormField";
import useConfig from "../../Common/hooks/useConfig";
@@ -147,10 +147,9 @@ export const FacilityCard = (props: { facility: any; userType: any }) => {
href={`tel:${facility.phone_number}`}
className="text-sm font-semibold tracking-wider"
>
- {parsePhoneNumber(
- facility.phone_number as string,
- "IN"
- ).formatInternational() || "-"}
+ {formatPhoneNumber(
+ parsePhoneNumber(facility.phone_number as string) ?? "-"
+ )}
diff --git a/src/Components/Facility/FacilityCreate.tsx b/src/Components/Facility/FacilityCreate.tsx
index d1243daaf1d..e742caefb82 100644
--- a/src/Components/Facility/FacilityCreate.tsx
+++ b/src/Components/Facility/FacilityCreate.tsx
@@ -26,7 +26,11 @@ import {
listDoctor,
updateFacility,
} from "../../Redux/actions";
-import { getPincodeDetails, includesIgnoreCase } from "../../Utils/utils";
+import {
+ getPincodeDetails,
+ includesIgnoreCase,
+ parsePhoneNumber,
+} from "../../Utils/utils";
import {
phonePreg,
validateLatitude,
@@ -51,11 +55,11 @@ import TextAreaFormField from "../Form/FormFields/TextAreaFormField";
import TextFormField from "../Form/FormFields/TextFormField";
import { navigate } from "raviger";
-import { parsePhoneNumberFromString } from "libphonenumber-js";
import useAppHistory from "../../Common/hooks/useAppHistory";
import useConfig from "../../Common/hooks/useConfig";
import { useDispatch } from "react-redux";
import { useTranslation } from "react-i18next";
+import { PhoneNumberValidator } from "../Form/FieldValidators.js";
const Loading = lazy(() => import("../Common/Loading"));
@@ -434,11 +438,11 @@ export const FacilityCreate = (props: FacilityProps) => {
return;
case "phone_number":
// eslint-disable-next-line no-case-declarations
- const phoneNumber = parsePhoneNumberFromString(state.form[field]);
+ const phoneNumber = state.form[field];
if (
- !state.form[field] ||
- !phoneNumber?.isPossible() ||
- !phonePreg(String(phoneNumber?.number))
+ !phoneNumber ||
+ !PhoneNumberValidator()(phoneNumber) === undefined ||
+ !phonePreg(phoneNumber)
) {
errors[field] = t("invalid_phone_number");
invalidForm = true;
@@ -488,9 +492,7 @@ export const FacilityCreate = (props: FacilityProps) => {
kasp_empanelled: JSON.parse(state.form.kasp_empanelled),
latitude: state.form.latitude || null,
longitude: state.form.longitude || null,
- phone_number: parsePhoneNumberFromString(
- state.form.phone_number
- )?.format("E.164"),
+ phone_number: parsePhoneNumber(state.form.phone_number),
oxygen_capacity: state.form.oxygen_capacity
? state.form.oxygen_capacity
: 0,
diff --git a/src/Components/Facility/FacilityHome.tsx b/src/Components/Facility/FacilityHome.tsx
index 81e7fa4906f..15317b1b56c 100644
--- a/src/Components/Facility/FacilityHome.tsx
+++ b/src/Components/Facility/FacilityHome.tsx
@@ -575,6 +575,7 @@ export const FacilityHome = (props: any) => {
Resource Request
navigate(`/facility/${facilityId}/assets/new`)}
authorizeFor={NonReadOnlyUsers}
icon={ }
@@ -582,12 +583,14 @@ export const FacilityHome = (props: any) => {
Create Asset
navigate(`/assets?facility=${facilityId}`)}
icon={ }
>
View Assets
navigate(`/facility/${facilityId}/users`)}
icon={ }
>
diff --git a/src/Components/Facility/Investigations/Reports/ReportTable.tsx b/src/Components/Facility/Investigations/Reports/ReportTable.tsx
index 0826ff904fc..1f20ec94180 100644
--- a/src/Components/Facility/Investigations/Reports/ReportTable.tsx
+++ b/src/Components/Facility/Investigations/Reports/ReportTable.tsx
@@ -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) => {
@@ -53,6 +53,7 @@ interface ReportTableProps {
patientDetails?: {
name: string;
age: number;
+ date_of_birth: string;
hospitalName: string;
};
investigationData: InvestigationResponse;
@@ -83,7 +84,14 @@ const ReportTable: FC = ({
{patientDetails && (
Name: {patientDetails.name}
-
Age: {patientDetails.age}
+
+ Age:{" "}
+ {formatAge(
+ patientDetails.age,
+ patientDetails.date_of_birth,
+ true
+ )}
+
Hospital: {patientDetails.hospitalName}
)}
diff --git a/src/Components/Facility/Investigations/Reports/index.tsx b/src/Components/Facility/Investigations/Reports/index.tsx
index c4c69bc9169..ab5380c62ca 100644
--- a/src/Components/Facility/Investigations/Reports/index.tsx
+++ b/src/Components/Facility/Investigations/Reports/index.tsx
@@ -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
@@ -220,6 +221,7 @@ 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,
});
}
@@ -227,6 +229,7 @@ const InvestigationReports = ({ id }: any) => {
setPatientDetails({
name: "",
age: -1,
+ date_of_birth: "",
hospitalName: "",
});
}
diff --git a/src/Components/Facility/LegacyMonitorCard.tsx b/src/Components/Facility/LegacyMonitorCard.tsx
index 9f9fb8f1ea0..61bff3d607b 100644
--- a/src/Components/Facility/LegacyMonitorCard.tsx
+++ b/src/Components/Facility/LegacyMonitorCard.tsx
@@ -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;
@@ -28,7 +29,7 @@ export const LegacyMonitorCard = ({
{patient.name}
- {patient.age}y |{" "}
+ {formatAge(patient.age, patient.date_of_birth)} |{" "}
{GENDER_TYPES.find((g) => g.id === patient.gender)?.icon}
diff --git a/src/Components/Facility/TreatmentSummary.tsx b/src/Components/Facility/TreatmentSummary.tsx
index dbca307d38b..3fbd80ac8b2 100644
--- a/src/Components/Facility/TreatmentSummary.tsx
+++ b/src/Components/Facility/TreatmentSummary.tsx
@@ -10,7 +10,7 @@ import { statusType, useAbortableEffect } from "../../Common/utils";
import { PatientModel } from "../Patient/models";
import { GENDER_TYPES } from "../../Common/constants";
-import { formatDate, formatDateTime } from "../../Utils/utils";
+import { formatAge, formatDate, formatDateTime } from "../../Utils/utils";
const Loading = lazy(() => import("../Common/Loading"));
const TreatmentSummary = (props: any) => {
@@ -132,7 +132,8 @@ const TreatmentSummary = (props: any) => {
- Age : {patientData.age}
+ Age : {" "}
+ {formatAge(patientData.age, patientData.date_of_birth, true)}
Date of admission :
diff --git a/src/Components/Facility/models.tsx b/src/Components/Facility/models.tsx
index cc34140e7a9..de2c6af698a 100644
--- a/src/Components/Facility/models.tsx
+++ b/src/Components/Facility/models.tsx
@@ -223,5 +223,4 @@ export interface CurrentBed {
export type ICD11DiagnosisModel = {
id: string;
label: string;
- parentId: string | null;
};
diff --git a/src/Components/Form/AutoCompleteAsync.tsx b/src/Components/Form/AutoCompleteAsync.tsx
index d06067af957..5f33c6388c5 100644
--- a/src/Components/Form/AutoCompleteAsync.tsx
+++ b/src/Components/Form/AutoCompleteAsync.tsx
@@ -7,6 +7,7 @@ import {
MultiSelectOptionChip,
dropdownOptionClassNames,
} from "./MultiSelectMenuV2";
+import { useTranslation } from "react-i18next";
interface Props {
name?: string;
@@ -23,6 +24,7 @@ interface Props {
placeholder?: string;
disabled?: boolean;
error?: string;
+ required?: boolean;
onBlur?: () => void;
onFocus?: () => void;
}
@@ -42,11 +44,13 @@ const AutoCompleteAsync = (props: Props) => {
className = "",
placeholder,
disabled = false,
+ required = false,
error,
} = props;
const [data, setData] = useState([]);
const [query, setQuery] = useState("");
const [loading, setLoading] = useState(false);
+ const { t } = useTranslation();
const hasSelection =
(!multiple && selected) || (multiple && selected?.length > 0);
@@ -86,9 +90,7 @@ const AutoCompleteAsync = (props: Props) => {
: placeholder || "Start typing to search..."
}
displayValue={() =>
- hasSelection && !multiple
- ? optionLabel && optionLabel(selected)
- : ""
+ hasSelection && !multiple ? optionLabel?.(selected) : ""
}
onChange={({ target }) => setQuery(target.value)}
onFocus={props.onFocus}
@@ -100,6 +102,20 @@ const AutoCompleteAsync = (props: Props) => {
/>
+ {hasSelection && !loading && !required && (
+
+ {
+ e.preventDefault();
+ onChange(null);
+ }}
+ />
+
+ {t("clear_selection")}
+
+
+ )}
{loading ? (
) : (
diff --git a/src/Components/Form/FormFields/Autocomplete.tsx b/src/Components/Form/FormFields/Autocomplete.tsx
index dcf3ab5e8b6..c4b3ea3686e 100644
--- a/src/Components/Form/FormFields/Autocomplete.tsx
+++ b/src/Components/Form/FormFields/Autocomplete.tsx
@@ -157,6 +157,7 @@ export const Autocomplete =
(props: AutocompleteProps) => {
placeholder={props.placeholder ?? "Select"}
displayValue={(value: any) => value?.label || ""}
onChange={(event) => setQuery(event.target.value.toLowerCase())}
+ onBlur={() => value && setQuery("")}
autoComplete="off"
/>
@@ -164,7 +165,7 @@ export const Autocomplete = (props: AutocompleteProps) => {
{value?.icon}
{value && !props.isLoading && !props.required && (
-