From 896f51bb3907a9e3103e3d77f4cb399353eda026 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Fri, 8 Dec 2023 18:44:57 +0530 Subject: [PATCH 01/18] fixes #6822; invalidate filters cache upon login attempt (#6823) --- src/Components/Auth/Login.tsx | 3 ++- src/Utils/utils.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Components/Auth/Login.tsx b/src/Components/Auth/Login.tsx index 58472c4ff25..4aad207c25a 100644 --- a/src/Components/Auth/Login.tsx +++ b/src/Components/Auth/Login.tsx @@ -12,7 +12,7 @@ import CircularProgress from "../Common/components/CircularProgress"; import { LocalStorageKeys } from "../../Common/constants"; import ReactMarkdown from "react-markdown"; import rehypeRaw from "rehype-raw"; -import { handleRedirection } from "../../Utils/utils"; +import { handleRedirection, invalidateFiltersCache } from "../../Utils/utils"; export const Login = (props: { forgot?: boolean }) => { const { @@ -91,6 +91,7 @@ export const Login = (props: { forgot?: boolean }) => { const handleSubmit = async (e: any) => { e.preventDefault(); + invalidateFiltersCache(); const valid = validateData(); if (valid) { // replaces button with spinner diff --git a/src/Utils/utils.ts b/src/Utils/utils.ts index 7e34d027020..4c4fdacbc28 100644 --- a/src/Utils/utils.ts +++ b/src/Utils/utils.ts @@ -459,3 +459,11 @@ export const scrollTo = (id: string | boolean) => { const element = document.querySelector(`#${id}`); element?.scrollIntoView({ behavior: "smooth", block: "center" }); }; + +export const invalidateFiltersCache = () => { + for (const key in localStorage) { + if (key.startsWith("filters--")) { + localStorage.removeItem(key); + } + } +}; From 05549b5cc08bfeeed0fab260043ee793063b5c37 Mon Sep 17 00:00:00 2001 From: Gokulram A Date: Mon, 11 Dec 2023 13:50:07 +0530 Subject: [PATCH 02/18] Added location type to location form (#6592) * Added location type to location form * fix adds location cypress test --- cypress/e2e/facility_spec/locations.cy.ts | 2 ++ src/Components/Assets/AssetTypes.tsx | 7 +++++ src/Components/Facility/AddLocationForm.tsx | 33 +++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/cypress/e2e/facility_spec/locations.cy.ts b/cypress/e2e/facility_spec/locations.cy.ts index f8006b126d4..59651c7c7c9 100644 --- a/cypress/e2e/facility_spec/locations.cy.ts +++ b/cypress/e2e/facility_spec/locations.cy.ts @@ -24,6 +24,8 @@ describe("Location Management Section", () => { cy.contains("Add New Location").click(); cy.get("[name='name']").type("Test Location"); cy.get("textarea[name='description']").type("Test Description"); + cy.get("#location-type").click(); + cy.get("#location-type-option-ICU").click(); cy.intercept(/\/api\/v1\/facility\/[\w-]+\/asset_location\//).as( "addLocation" ); diff --git a/src/Components/Assets/AssetTypes.tsx b/src/Components/Assets/AssetTypes.tsx index a894c87dcc5..041d3d0a81e 100644 --- a/src/Components/Assets/AssetTypes.tsx +++ b/src/Components/Assets/AssetTypes.tsx @@ -2,12 +2,19 @@ import { BedModel } from "../Facility/models"; import { PerformedByModel } from "../HCX/misc"; import { PatientModel } from "../Patient/models"; +export enum AssetLocationType { + OTHER = "OTHER", + WARD = "WARD", + ICU = "ICU", +} + export interface AssetLocationObject { id: string; name: string; description: string; created_date?: string; modified_date?: string; + location_type: AssetLocationType; middleware_address?: string; facility: { id: string; diff --git a/src/Components/Facility/AddLocationForm.tsx b/src/Components/Facility/AddLocationForm.tsx index e71b68cc95c..81d9bc0750c 100644 --- a/src/Components/Facility/AddLocationForm.tsx +++ b/src/Components/Facility/AddLocationForm.tsx @@ -12,6 +12,8 @@ import { Submit, Cancel } from "../Common/components/ButtonV2"; import TextFormField from "../Form/FormFields/TextFormField"; import TextAreaFormField from "../Form/FormFields/TextAreaFormField"; import Page from "../Common/components/Page"; +import { SelectFormField } from "../Form/FormFields/SelectFormField"; +import { AssetLocationType } from "../Assets/AssetTypes"; const Loading = lazy(() => import("../Common/Loading")); @@ -29,10 +31,12 @@ export const AddLocationForm = (props: LocationFormProps) => { const [description, setDescription] = useState(""); const [facilityName, setFacilityName] = useState(""); const [locationName, setLocationName] = useState(""); + const [locationType, setLocationType] = useState(""); const [errors, setErrors] = useState({ name: "", description: "", middlewareAddress: "", + locationType: "", }); const headerText = !locationId ? "Add Location" : "Update Location"; const buttonText = !locationId ? "Add Location" : "Update Location"; @@ -53,6 +57,7 @@ export const AddLocationForm = (props: LocationFormProps) => { setName(res?.data?.name || ""); setLocationName(res?.data?.name || ""); setDescription(res?.data?.description || ""); + setLocationType(res?.data?.location_type || ""); setMiddlewareAddress(res?.data?.middleware_address || ""); } setIsLoading(false); @@ -66,6 +71,7 @@ export const AddLocationForm = (props: LocationFormProps) => { name: "", description: "", middlewareAddress: "", + locationType: "", }; if (name.trim().length === 0) { @@ -73,6 +79,11 @@ export const AddLocationForm = (props: LocationFormProps) => { formValid = false; } + if (locationType.trim().length === 0) { + error.locationType = "Location Type is required"; + formValid = false; + } + if ( middlewareAddress && middlewareAddress.match( @@ -98,6 +109,7 @@ export const AddLocationForm = (props: LocationFormProps) => { name, description, middleware_address: middlewareAddress, + location_type: locationType, }; const res = await dispatchAction( @@ -172,6 +184,27 @@ export const AddLocationForm = (props: LocationFormProps) => { error={errors.description} /> +
+ title} + optionValue={({ value }) => value} + value={locationType} + required + onChange={({ value }) => setLocationType(value)} + error={errors.locationType} + /> +
Date: Wed, 13 Dec 2023 10:56:55 +0530 Subject: [PATCH 03/18] Fix investigation builder crash (#6755) * Fix investigation advice assignment in ConsultationForm * allow category selection if null --- src/Components/Facility/ConsultationForm.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index 1d4abbedc39..3207787a27d 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -400,7 +400,9 @@ export const ConsultationForm = (props: any) => { cause_of_death: res.data?.discharge_notes || "", death_datetime: res.data?.death_datetime || "", death_confirmed_doctor: res.data?.death_confirmed_doctor || "", - InvestigationAdvice: res.data.investigation, + InvestigationAdvice: Array.isArray(res.data.investigation) + ? res.data.investigation + : [], diagnoses: res.data.diagnoses.sort( (a: ConsultationDiagnosis, b: ConsultationDiagnosis) => ConditionVerificationStatuses.indexOf(a.verification_status) - @@ -410,7 +412,7 @@ export const ConsultationForm = (props: any) => { dispatch({ type: "set_form", form: { ...state.form, ...formData } }); setBed(formData.bed); - if (res.data.last_daily_round) { + if (res.data.last_daily_round && state.form.category) { setDisabledFields((fields) => [...fields, "category"]); } } else { From f8aae49f2c6f3bb21a574c10be107ba3e7bab3ad Mon Sep 17 00:00:00 2001 From: Pranshu Aggarwal <70687348+Pranshu1902@users.noreply.github.com> Date: Wed, 13 Dec 2023 10:57:08 +0530 Subject: [PATCH 04/18] fix responsiveness on patients page (#6759) * fix responsiveness * remove left margin --- src/Components/Patient/ManagePatients.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Components/Patient/ManagePatients.tsx b/src/Components/Patient/ManagePatients.tsx index 6a52d68130c..9988a7b9576 100644 --- a/src/Components/Patient/ManagePatients.tsx +++ b/src/Components/Patient/ManagePatients.tsx @@ -589,10 +589,10 @@ export const PatientManager = () => { )}
-
-
+
+
{patient.name} - + {formatAge(patient.age, patient.date_of_birth, true)}
From c015a29f28aa284d2b3f6b8cd47d48d32884d771 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Wed, 13 Dec 2023 10:57:42 +0530 Subject: [PATCH 05/18] fixes #6810; format date and time for discharge date (#6813) --- .../Facility/ConsultationDetails/ConsultationUpdatesTab.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx index 0d8a70781da..beac7f595a8 100644 --- a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx +++ b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx @@ -233,7 +233,7 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => { ? formatDate( props.consultationData.discharge_date ) - : "--/--/----"} + : "--/--/---- --:-- --"}
@@ -294,10 +294,10 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => { Discharge Date {" - "} {props.consultationData.discharge_date - ? formatDate( + ? formatDateTime( props.consultationData.discharge_date ) - : "--/--/----"} + : "--/--/---- --:-- --"}
From 1a6b3d3e1bf604882a76a419684c4e460d989229 Mon Sep 17 00:00:00 2001 From: Onkar Jadhav <56870381+Omkar76@users.noreply.github.com> Date: Wed, 13 Dec 2023 10:57:58 +0530 Subject: [PATCH 06/18] Allow occupancy button to resize on default font size change. Fixes #6805 (#6806) --- src/Components/Facility/FacilityCard.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Components/Facility/FacilityCard.tsx b/src/Components/Facility/FacilityCard.tsx index 900b6b00f47..c34fed49a6e 100644 --- a/src/Components/Facility/FacilityCard.tsx +++ b/src/Components/Facility/FacilityCard.tsx @@ -160,7 +160,7 @@ export const FacilityCard = (props: { facility: any; userType: any }) => {
0.85 ? "button-danger-border bg-red-500" : "button-primary-border bg-primary-100" @@ -178,7 +178,7 @@ export const FacilityCard = (props: { facility: any; userType: any }) => { )} />{" "}
0.85 ? "text-white" : "text-gray-700" From 9967daecddbfbfefcfc5d7157945559e1fd37a68 Mon Sep 17 00:00:00 2001 From: Ashesh <3626859+Ashesh3@users.noreply.github.com> Date: Wed, 13 Dec 2023 10:59:17 +0530 Subject: [PATCH 07/18] Refactor user delete permissions to allow StateAdmin and DistrictAdmin (#6781) * Refactor user delete permissions * Add user type validation --- src/Components/Facility/FacilityUsers.tsx | 12 ++++++++--- src/Components/Users/ManageUsers.tsx | 20 +++++++----------- src/Utils/utils.ts | 25 +++++++++++++++++++++++ 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/src/Components/Facility/FacilityUsers.tsx b/src/Components/Facility/FacilityUsers.tsx index aba12cc3833..ca2e1d0e363 100644 --- a/src/Components/Facility/FacilityUsers.tsx +++ b/src/Components/Facility/FacilityUsers.tsx @@ -3,7 +3,12 @@ import CountBlock from "../../CAREUI/display/Count"; import CareIcon from "../../CAREUI/icons/CareIcon"; import { RESULTS_PER_PAGE_LIMIT } from "../../Common/constants"; import * as Notification from "../../Utils/Notifications.js"; -import { classNames, isUserOnline, relativeTime } from "../../Utils/utils"; +import { + classNames, + isUserOnline, + relativeTime, + showUserDelete, +} from "../../Utils/utils"; import Pagination from "../Common/Pagination"; import UserDetails from "../Common/UserDetails"; import ButtonV2 from "../Common/components/ButtonV2"; @@ -16,6 +21,7 @@ import useAuthUser from "../../Common/hooks/useAuthUser"; import request from "../../Utils/request/request"; import routes from "../../Redux/api"; import useQuery from "../../Utils/request/useQuery"; +import { UserModel } from "../Users/models"; const Loading = lazy(() => import("../Common/Loading")); @@ -256,7 +262,7 @@ export default function FacilityUsers(props: any) { facilityUserData && facilityUserData.results && facilityUserData.results.length && - (userList = facilityUserData.results.map((user: any) => { + (userList = facilityUserData.results.map((user: UserModel) => { return (
) : null} - {authUser.user_type === "StateAdmin" && ( + {showUserDelete(authUser, user) && (
+ {consultation?.last_daily_round && ( +
+ +
+ )}
{!!consultation?.discharge_date && ( diff --git a/src/Components/Patient/models.tsx b/src/Components/Patient/models.tsx index af69d8464bc..3a856a04765 100644 --- a/src/Components/Patient/models.tsx +++ b/src/Components/Patient/models.tsx @@ -301,6 +301,14 @@ export interface DailyRoundsModel { created_date?: string; modified_date?: string; taken_at?: string; + consciousness_level?: + | "UNRESPONSIVE" + | "RESPONDS_TO_PAIN" + | "RESPONDS_TO_VOICE" + | "ALERT" + | "AGITATED_OR_CONFUSED" + | "ONSET_OF_AGITATION_AND_CONFUSION" + | "UNKNOWN"; rounds_type: (typeof DailyRoundTypes)[number]; last_updated_by_telemedicine?: boolean; created_by_telemedicine?: boolean; From cdbe306ffb860544cfc4eaa3267da7821fb4e516 Mon Sep 17 00:00:00 2001 From: Vedant Jain <129421822+jainvedant392@users.noreply.github.com> Date: Wed, 13 Dec 2023 19:33:02 +0530 Subject: [PATCH 10/18] Add loading screen in index.html (#6836) --- index.html | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 58cb9fffcd1..83c80ef3214 100644 --- a/index.html +++ b/index.html @@ -34,7 +34,34 @@ -
+
+ +
+ +
+