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

(refactor) 03-2973: Remove dead code from the results viewer implementation #1751

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,5 +1,4 @@
import React, { createContext, useReducer, useEffect, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import isObject from 'lodash/isObject';
import { parseTime } from '../panel-timeline/helpers';
import {
Expand Down Expand Up @@ -42,7 +41,6 @@ export interface FilterProviderProps {

const FilterProvider = ({ roots, children }: FilterProviderProps) => {
const [state, dispatch] = useReducer(reducer, initialState);
const { t } = useTranslation();

const actions = useMemo(
() => ({
Expand Down Expand Up @@ -72,7 +70,7 @@ const FilterProvider = ({ roots, children }: FilterProviderProps) => {
};
}
const tests: ReducerState['tests'] = activeTests?.length
? Object.fromEntries(Object.entries(state.tests).filter(([name, entry]) => activeTests.includes(name)))
? Object.fromEntries(Object.entries(state.tests).filter(([name]) => activeTests.includes(name)))
: state.tests;

const allTimes = [
Expand Down
Expand Up @@ -42,8 +42,7 @@ const FilterSet: React.FC<FilterSetProps> = ({ hideFilterSetHeader = false }) =>
const [showSearchInput, setShowSearchInput] = useState(false);

const handleInputChange = useCallback(
(e) => {
setSearchTerm(searchTerm);
(searchTerm) => {
Comment on lines 44 to +45
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for this change?
Changing the event to a string will not work, until you make change in the said onClick function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vasharma05 should I revert it to the original? Also help explain abit more as I haven't understood what you mean by the "the said onClick function". But this was my thought process: When the such term changes, the handleInputChange function is called with the search term passed as an argument. We then use that search term to get the filtered results. Previously 'e' was not being used anywhere in the handleInputChange function and I didn't understand why we are using an event as a parameter yet handleInputChange is being passed a string. Also though that maybe setting the search term( setSearchTerm(searchTerm) ) to the same value is kinda redudant. Thats how I thought about it. I am willing to be corrected

const filteredData = roots.filter((node) => filterTreeNode(searchTerm, node));
setTreeDataFiltered(filteredData);
},
Expand Down
Expand Up @@ -2,7 +2,7 @@ import React, { useCallback, useContext, useEffect, useRef, useState } from 'rea
import classNames from 'classnames';
import { useTranslation } from 'react-i18next';
import { EmptyState } from '@openmrs/esm-patient-common-lib';
import { ConfigurableLink, useLayoutType, usePatient } from '@openmrs/esm-framework';
import { ConfigurableLink, usePatient } from '@openmrs/esm-framework';
import { Grid, ShadowBox } from '../panel-timeline/helpers';
import { makeThrottled, testResultsBasePath } from '../helpers';
import type {
Expand Down Expand Up @@ -188,7 +188,6 @@ const TimelineDataGroup = ({ parent, subRows, xScroll, setXScroll, panelName, se
const {
data: {
parsedTime: { timeColumns, sortedTimes },
rowData,
},
} = timelineData;

Expand Down Expand Up @@ -216,7 +215,7 @@ const TimelineDataGroup = ({ parent, subRows, xScroll, setXScroll, panelName, se
}
}, [handleScroll]);

const onIntersect = (entries, observer) => {
const onIntersect = (entries) => {
entries.forEach((entry) => {
if (entry.intersectionRatio > 0.5) {
// setPanelName(parent.display);
Expand Down Expand Up @@ -263,7 +262,6 @@ export const GroupedTimeline = () => {
const [xScroll, setXScroll] = useState(0);
const { t } = useTranslation();
let shownGroups = 0;
const tablet = useLayoutType() === 'tablet';

const {
data: {
Expand Down
Expand Up @@ -55,7 +55,7 @@ const useGetManyObstreeData = (uuidArray: Array<string>) => {
return `${restBaseUrl}/obstree?patient=${patientUuid}&concept=${uuidArray[index]}`;
} else return null;
};
const { data, error, isLoading } = useSWRInfinite(getObstreeUrl, openmrsFetch, {
const { data, error } = useSWRInfinite(getObstreeUrl, openmrsFetch, {
initialSize: uuidArray.length,
revalidateIfStale: false,
revalidateOnFocus: false,
Expand Down
Expand Up @@ -46,7 +46,7 @@ function useFilteredOverviewData(patientUuid: string, filter: (filterProps: Pane

const ExternalOverview: React.FC<ExternalOverviewProps> = ({ patientUuid, filter }) => {
const { t } = useTranslation();
const { overviewData, loaded, error } = useFilteredOverviewData(patientUuid, filter);
const { overviewData, loaded } = useFilteredOverviewData(patientUuid, filter);

const cardTitle = t('recentResults', 'Recent Results');
const handleSeeAll = useCallback(() => {
Expand Down
Expand Up @@ -20,7 +20,7 @@ const RecentOverview: React.FC<RecentOverviewProps> = ({ patientUuid, basePath }
const { t } = useTranslation();
const isTablet = useLayoutType() === 'tablet';
const cardTitle = t('recentResults', 'Recent Results');
const { overviewData, loaded, error } = useOverviewData(patientUuid);
const { overviewData, loaded } = useOverviewData(patientUuid);

return (
<RecentResultsGrid>
Expand Down
Expand Up @@ -31,7 +31,7 @@ export function useObservations() {
},
[patientUuid],
);
const { data, error, size, setSize, isLoading } = useSWRInfinite<
const { data, size, setSize, isLoading } = useSWRInfinite<
FetchResponse<FhirResponse<FHIRObservationResource>>,
Error
>(getUrl, openmrsFetch, {
Expand Down Expand Up @@ -72,7 +72,7 @@ function useConcepts(conceptUuids: Array<string>) {
},
[conceptUuids],
);
const { data, error, isLoading } = useSWRInfinite<FetchResponse<Concept>>(getUrl, openmrsFetch, {
const { data, isLoading } = useSWRInfinite<FetchResponse<Concept>>(getUrl, openmrsFetch, {
initialSize: conceptUuids?.length ?? 1,
revalidateIfStale: false,
revalidateOnFocus: false,
Expand All @@ -95,7 +95,7 @@ function useConcepts(conceptUuids: Array<string>) {

export default function usePanelData() {
const { observations: fhirObservations, conceptUuids, isLoading: isLoadingObservations } = useObservations();
const { isLoading: isLoadingConcepts, concepts } = useConcepts(conceptUuids);
const { concepts } = useConcepts(conceptUuids);

const conceptData: Record<string, ConceptMeta> = useMemo(
() =>
Expand Down
Expand Up @@ -81,7 +81,7 @@ function PrintModal({ patientUuid, closeDialog }) {
age: age(patient?.patient?.birthDate),
gender: getGender(patient?.patient?.gender),
location: patient?.patient?.address?.[0].city,
identifiers: identifiers?.length ? identifiers.map(({ value, type }) => value) : [],
identifiers: identifiers?.length ? identifiers.map(({ value }) => value) : [],
};
}, [patient, t, excludePatientIdentifierCodeTypes?.uuids]);

Expand Down
@@ -1,6 +1,6 @@
import React from 'react';
import { Button, Header } from '@carbon/react';
import { ArrowLeft, Close } from '@carbon/react/icons';
import { ArrowLeft } from '@carbon/react/icons';
import styles from './tablet-overlay.scss';

interface OverlayProps {
Expand Down
Expand Up @@ -63,7 +63,6 @@ interface TrendlineProps {
const Trendline: React.FC<TrendlineProps> = ({
patientUuid,
conceptUuid,
basePath,
hideTrendlineHeader = false,
showBackToTimelineButton = false,
}) => {
Expand Down