Skip to content

Commit

Permalink
[production-patch] Fix investigations crashes and same day discharge (#…
Browse files Browse the repository at this point in the history
…9029)

Co-authored-by: JavidSumra <[email protected]>
  • Loading branch information
sainak and JavidSumra authored Nov 6, 2024
1 parent 0ab7af0 commit c5e9b5d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/components/Common/DateInputV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ const DateInputV2: React.FC<Props> = ({
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;
Expand Down
4 changes: 2 additions & 2 deletions src/components/Facility/Investigations/Reports/index.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -172,7 +172,7 @@ const InvestigationReports = ({ id }: any) => {
),
);

const investigationList = chain(data)
const investigationList = _.chain(data)
.flatMap((i) => i?.data?.results)
.compact()
.flatten()
Expand Down
7 changes: 4 additions & 3 deletions src/components/Facility/Investigations/Reports/utils.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions src/components/Facility/Investigations/ShowInvestigation.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c5e9b5d

Please sign in to comment.