From c5e9b5ddbbe3bb960d9fc359cf35ef28cdc60c4c Mon Sep 17 00:00:00 2001 From: Aakash Singh Date: Wed, 6 Nov 2024 22:15:18 +0530 Subject: [PATCH] [production-patch] Fix investigations crashes and same day discharge (#9029) Co-authored-by: JavidSumra <112365664+JavidSumra@users.noreply.github.com> --- src/components/Common/DateInputV2.tsx | 10 ++++++++++ .../Facility/Investigations/Reports/index.tsx | 4 ++-- .../Facility/Investigations/Reports/utils.tsx | 7 ++++--- .../Facility/Investigations/ShowInvestigation.tsx | 5 +++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/components/Common/DateInputV2.tsx b/src/components/Common/DateInputV2.tsx index 87a29debe5b..627abdcf327 100644 --- a/src/components/Common/DateInputV2.tsx +++ b/src/components/Common/DateInputV2.tsx @@ -190,6 +190,16 @@ const DateInputV2: React.FC = ({ year = datePickerHeaderDate.getFullYear(), ) => { const date = new Date(year, month, day); + if ( + min && + max && + min.getDate() === max.getDate() && + day === min.getDate() && + month === min.getMonth() && + year === min.getFullYear() + ) { + return true; + } if (min) if (date < min) return false; if (max) if (date > max) return false; return true; diff --git a/src/components/Facility/Investigations/Reports/index.tsx b/src/components/Facility/Investigations/Reports/index.tsx index 246d50f94bd..e4e54c36994 100644 --- a/src/components/Facility/Investigations/Reports/index.tsx +++ b/src/components/Facility/Investigations/Reports/index.tsx @@ -1,7 +1,7 @@ import { useCallback, useReducer, useState } from "react"; import { InvestigationGroup, InvestigationType } from ".."; -import { chain } from "lodash-es"; +import _ from "lodash"; import { useTranslation } from "react-i18next"; import routes from "../../../../Redux/api"; import * as Notification from "../../../../Utils/Notifications"; @@ -172,7 +172,7 @@ const InvestigationReports = ({ id }: any) => { ), ); - const investigationList = chain(data) + const investigationList = _.chain(data) .flatMap((i) => i?.data?.results) .compact() .flatten() diff --git a/src/components/Facility/Investigations/Reports/utils.tsx b/src/components/Facility/Investigations/Reports/utils.tsx index eed1afc571e..3c01cf8bba4 100644 --- a/src/components/Facility/Investigations/Reports/utils.tsx +++ b/src/components/Facility/Investigations/Reports/utils.tsx @@ -1,8 +1,9 @@ -import { memoize, chain, findIndex } from "lodash-es"; +import _ from "lodash"; +import { memoize, findIndex } from "lodash-es"; import { InvestigationResponse } from "./types"; export const transformData = memoize((data: InvestigationResponse) => { - const sessions = chain(data) + const sessions = _.chain(data) .map((value: any) => { return { ...value.session_object, @@ -13,7 +14,7 @@ export const transformData = memoize((data: InvestigationResponse) => { .uniqBy("session_external_id") .orderBy("session_created_date", "desc") .value(); - const groupByInvestigation = chain(data) + const groupByInvestigation = _.chain(data) .groupBy("investigation_object.external_id") .values() .value(); diff --git a/src/components/Facility/Investigations/ShowInvestigation.tsx b/src/components/Facility/Investigations/ShowInvestigation.tsx index 00fe2c33549..f923d2bb2da 100644 --- a/src/components/Facility/Investigations/ShowInvestigation.tsx +++ b/src/components/Facility/Investigations/ShowInvestigation.tsx @@ -1,4 +1,5 @@ -import { set, chain } from "lodash-es"; +import _ from "lodash"; +import { set } from "lodash-es"; import { useCallback, useReducer } from "react"; import routes from "../../../Redux/api"; import * as Notification from "../../../Utils/Notifications"; @@ -147,7 +148,7 @@ export default function ShowInvestigation(props: ShowInvestigationProps) { }; const handleUpdateCancel = useCallback(() => { - const changedValues = chain(state.initialValues) + const changedValues = _.chain(state.initialValues) .map((val: any, _key: string) => ({ id: val?.id, initialValue: val?.notes || val?.value || null,