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

O3-1634: UI Fixes for Test results viewer in Tablet and Small Desktop #893

Merged
merged 7 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/esm-patient-common-lib/src/types/test-results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface ObsRecord {

export interface ObsMetaInfo {
[_: string]: any;
assessValue?: (value: number) => OBSERVATION_INTERPRETATION;
assessValue?: (value: string) => OBSERVATION_INTERPRETATION;
}

export interface ConceptRecord {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface ReducerAction {

export interface ObservationData {
obsDatetime: string;
value: number;
value: string;
interpretation: OBSERVATION_INTERPRETATION;
}
export interface TestData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,23 @@ const PanelNameCorner: React.FC<PanelNameCornerProps> = ({ showShadow, panelName
<TimeSlots className={`${styles.cornerGridElement} ${showShadow ? styles.shadow : ''}`}>{panelName}</TimeSlots>
);

const NewRowStartCell = ({ title, range, units, conceptUuid, shadow = false }) => {
const NewRowStartCell = ({ title, range, units, conceptUuid, shadow = false, isString = false }) => {
const { patientUuid } = usePatient();

if (isString) {
<div
className={styles.rowStartCell}
style={{
boxShadow: shadow ? '8px 0 20px 0 rgba(0,0,0,0.15)' : undefined,
}}
>
<span className={styles.trendlineLink}>{title}</span>
vasharma05 marked this conversation as resolved.
Show resolved Hide resolved
<span className={styles.rangeUnits}>
{range} {units}
</span>
</div>;
}

return (
<div
className={styles.rowStartCell}
Expand Down Expand Up @@ -91,7 +105,8 @@ const DataRows: React.FC<DataRowsProps> = ({ timeColumns, rowData, sortedTimes,
<Grid dataColumns={timeColumns.length} padding style={{ gridColumn: 'span 2' }}>
{rowData.map((row, index) => {
const obs = row.entries;
const { units = '', range = '' } = row;
const { units = '', range = '', obs: values } = row;
const isString = isNaN(parseFloat(values?.[0]?.value));
return (
<React.Fragment key={index}>
<NewRowStartCell
Expand All @@ -101,6 +116,7 @@ const DataRows: React.FC<DataRowsProps> = ({ timeColumns, rowData, sortedTimes,
title: row.display,
shadow: showShadow,
conceptUuid: row.conceptUuid,
isString,
}}
/>
<GridItems {...{ sortedTimes, obs, zebra: !!(index % 2) }} />
Expand Down Expand Up @@ -276,8 +292,8 @@ export const GroupedTimeline = () => {
}
if (activeTests && timelineData && loaded) {
return (
<div className={styles.timelineHeader} style={{ top: tablet ? '7rem' : '6.5rem' }}>
<div className={styles.timelineHeader} style={{ top: tablet ? '7rem' : '6.5rem' }}>
<div className={styles.timelineHeader} style={{ top: '6.5rem' }}>
<div className={styles.timelineHeader} style={{ top: '6.5rem' }}>
<div className={styles.dateHeaderContainer}>
<PanelNameCorner showShadow={true} panelName={panelName} />
<DateHeaderGrid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,28 +152,32 @@ export function exist(...args: any[]): boolean {

export const assessValue =
(meta: ObsMetaInfo) =>
(value: number): OBSERVATION_INTERPRETATION => {
if (exist(meta.hiAbsolute) && value > meta.hiAbsolute) {
(value: string): OBSERVATION_INTERPRETATION => {
if (isNaN(parseFloat(value))) {
return 'NORMAL';
}
const numericValue = parseFloat(value);
if (exist(meta.hiAbsolute) && numericValue > meta.hiAbsolute) {
return 'OFF_SCALE_HIGH';
}

if (exist(meta.hiCritical) && value > meta.hiCritical) {
if (exist(meta.hiCritical) && numericValue > meta.hiCritical) {
return 'CRITICALLY_HIGH';
}

if (exist(meta.hiNormal) && value > meta.hiNormal) {
if (exist(meta.hiNormal) && numericValue > meta.hiNormal) {
return 'HIGH';
}

if (exist(meta.lowAbsolute) && value < meta.lowAbsolute) {
if (exist(meta.lowAbsolute) && numericValue < meta.lowAbsolute) {
return 'OFF_SCALE_LOW';
}

if (exist(meta.lowCritical) && value < meta.lowCritical) {
if (exist(meta.lowCritical) && numericValue < meta.lowCritical) {
return 'CRITICALLY_LOW';
}

if (exist(meta.lowNormal) && value < meta.lowNormal) {
if (exist(meta.lowNormal) && numericValue < meta.lowNormal) {
return 'LOW';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,40 @@ export const TimelineCell: React.FC<{
);
};

export const RowStartCell = ({ title, range, units, shadow = false, testUuid }) => (
<div
className={styles['row-start-cell']}
style={{
boxShadow: shadow ? '8px 0 20px 0 rgba(0,0,0,0.15)' : undefined,
}}
>
<span className={styles['trendline-link']}>
<ConfigurableLink to={`${testResultsBasePath(`/patient/${patientUuid}/chart`)}/trendline/${testUuid}`}>
{title}
</ConfigurableLink>
</span>
<span className={styles['range-units']}>
{range} {units}
</span>
</div>
);
export const RowStartCell = ({ title, range, units, shadow = false, testUuid, isString = false }) => {
if (isString) {
return (
<div
className={styles['row-start-cell']}
style={{
boxShadow: shadow ? '8px 0 20px 0 rgba(0,0,0,0.15)' : undefined,
}}
>
<span className={styles['trendline-link']}>{title}</span>
<span className={styles['range-units']}>
{range} {units}
</span>
</div>
);
}
return (
<div
className={styles['row-start-cell']}
style={{
boxShadow: shadow ? '8px 0 20px 0 rgba(0,0,0,0.15)' : undefined,
}}
>
<span className={styles['trendline-link']}>
vasharma05 marked this conversation as resolved.
Show resolved Hide resolved
<ConfigurableLink to={`${testResultsBasePath(`/patient/${patientUuid}/chart`)}/trendline/${testUuid}`}>
{title}
</ConfigurableLink>
</span>
<span className={styles['range-units']}>
{range} {units}
</span>
</div>
);
};

export const TimeSlots: React.FC<{
children?: React.ReactNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const DataRows: React.FC<DataRowsProps> = ({ timeColumns, rowData, sortedTimes,
title,
shadow: showShadow,
testUuid,
isString: isNaN(parseFloat(obs?.[0]?.value)),
}}
/>
<GridItems {...{ sortedTimes, obs, zebra: !!(rowCount % 2) }} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@

.trendline-link {
@include type.type-style('body-compact-01');
color: $interactive-01;
cursor: pointer;
}

Expand Down
122 changes: 81 additions & 41 deletions packages/esm-patient-test-results-app/src/panel-view/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import usePanelData from './usePanelData';
import { Column, DataTableSkeleton, Button } from '@carbon/react';
import { Search as SearchIcon } from '@carbon/react/icons';
import styles from './panel-view.scss';
import { useLayoutType } from '@openmrs/esm-framework';
import { navigate, useLayoutType } from '@openmrs/esm-framework';
import PanelTimelineComponent from '../panel-timeline';
import { ObsRecord } from './types';
import { useTranslation } from 'react-i18next';
import { EmptyState } from '@openmrs/esm-patient-common-lib';
import Trendline from '../trendline/trendline.component';
import Overlay from '../tablet-overlay/tablet-overlay.component';
import { testResultsBasePath } from '../helpers';

interface PanelViewProps {
expanded: boolean;
Expand All @@ -34,49 +36,87 @@ const PanelView: React.FC<PanelViewProps> = ({ expanded, testUuid, basePath, typ
}
}, [panels, activePanel, layout]);

const navigateBackFromTrendlineView = useCallback(() => {
navigate({
to: testResultsBasePath(`/patient/${patientUuid}/chart`),
});
}, [patientUuid]);

if (isTablet) {
return (
<>
<div>
<PanelViewHeader isTablet={isTablet} />
{!isLoading ? (
panels.length > 0 ? (
panels.map((panel) => (
<LabSetPanel
panel={panel}
observations={[panel, ...panel.relatedObs]}
setActivePanel={setActivePanel}
activePanel={activePanel}
/>
))
) : (
<EmptyState displayText={t('panels', 'panels')} headerTitle={t('noPanelsFound', 'No panels found')} />
)
) : (
<DataTableSkeleton columns={3} />
)}
</div>
{activePanel ? (
<Overlay close={() => setActivePanel(null)} headerText={activePanel?.name}>
<PanelTimelineComponent groupedObservations={groupedObservations} activePanel={activePanel} />
</Overlay>
) : null}
{trendlineView ? (
<Overlay close={navigateBackFromTrendlineView} headerText={activePanel?.name}>
<Trendline patientUuid={patientUuid} conceptUuid={testUuid} basePath={basePath} />
</Overlay>
) : null}
</>
);
}

return (
<>
{!isTablet && (
<Column sm={16} lg={fullWidthPanels ? 12 : 5}>
<>
<PanelViewHeader isTablet={isTablet} />
{!isLoading ? (
panels.length > 0 ? (
panels.map((panel) => (
<LabSetPanel
panel={panel}
observations={[panel, ...panel.relatedObs]}
setActivePanel={setActivePanel}
activePanel={activePanel}
/>
))
) : (
<EmptyState displayText={t('panels', 'panels')} headerTitle={t('noPanelsFound', 'No panels found')} />
)
<div className={styles.leftSection}>
<>
<PanelViewHeader isTablet={isTablet} />
{!isLoading ? (
panels.length > 0 ? (
panels.map((panel) => (
<LabSetPanel
panel={panel}
observations={[panel, ...panel.relatedObs]}
setActivePanel={setActivePanel}
activePanel={activePanel}
/>
))
) : (
<DataTableSkeleton columns={3} />
)}
</>
</Column>
)}
<Column
sm={16}
lg={fullWidthPanels ? 0 : 7}
className={isTablet ? styles.headerMarginTablet : styles.headerMargin}
>
{isLoading ? (
<DataTableSkeleton columns={3} />
) : trendlineView ? (
<Trendline patientUuid={patientUuid} conceptUuid={testUuid} basePath={basePath} showBackToTimelineButton />
) : activePanel ? (
<PanelTimelineComponent groupedObservations={groupedObservations} activePanel={activePanel} />
) : (
<EmptyState
headerTitle={t('noPanelSelected', 'No panel selected')}
displayText={t('observations', 'Observations')}
/>
)}
</Column>
<EmptyState displayText={t('panels', 'panels')} headerTitle={t('noPanelsFound', 'No panels found')} />
)
) : (
<DataTableSkeleton columns={3} />
)}
</>
</div>
<div className={`${styles.headerMargin} ${styles.rightSection}`}>
<div className={styles.stickySection}>
{isLoading ? (
<DataTableSkeleton columns={3} />
) : trendlineView ? (
<Trendline patientUuid={patientUuid} conceptUuid={testUuid} basePath={basePath} showBackToTimelineButton />
) : activePanel ? (
<PanelTimelineComponent groupedObservations={groupedObservations} activePanel={activePanel} />
) : (
<EmptyState
headerTitle={t('noPanelSelected', 'No panel selected')}
displayText={t('observations', 'Observations')}
/>
)}
</div>
</div>
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@use '@carbon/styles/scss/spacing';
@use '@carbon/styles/scss/type';
@import '~@openmrs/esm-styleguide/src/vars';
@import '../results-viewer/results-viewer.styles.scss';

.panelViewHeader {
display: flex;
Expand All @@ -18,9 +19,9 @@
@include type.type-style('heading-compact-02');
}

.headerMargin, .headerMarginTablet {
.stickySection {
top: 9rem;
position: sticky;
top: 3rem;
}

.headerMargin {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { RowData } from '../filter/filter-types';
import styles from './result-panel.scss';
import {
DataTable,
Expand All @@ -15,7 +14,7 @@ import {
} from '@carbon/react';
import { getClass } from './helper';
import { ObsRecord } from './types';
import { formatDate, isDesktop, useLayoutType, usePatient } from '@openmrs/esm-framework';
import { formatDate, isDesktop, useLayoutType } from '@openmrs/esm-framework';

interface LabSetPanelProps {
panel: ObsRecord;
Expand Down Expand Up @@ -82,7 +81,7 @@ const LabSetPanel: React.FC<LabSetPanelProps> = ({ panel, observations, activePa
id: test.id,
testName: test.name,
value: {
content: <span>{`${test.value} ${test.meta?.units}`}</span>,
content: <span>{`${test.value} ${test.meta?.units ?? ''}`}</span>,
},
interpretation: test.interpretation,
})),
Expand Down
Loading