Skip to content

Commit

Permalink
O3-3660 Show trend results in a modal
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaud authored and CynthiaKamau committed Jul 31, 2024
1 parent 0280655 commit 53f0d0f
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 5 deletions.
5 changes: 5 additions & 0 deletions packages/esm-patient-labs-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ export const addLabOrderWorkspace = getAsyncLifecycle(
() => import('./lab-orders/add-lab-order/add-lab-order.workspace'),
options,
);

export const resultsViewerDialog = getAsyncLifecycle(
() => import('./test-results/panel-timeline/results-dialog.comoponent'),
options,
);
4 changes: 4 additions & 0 deletions packages/esm-patient-labs-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
"component": "labOrderPanel",
"slot": "order-basket-slot",
"order": 2
},
{
"name": "results-viewer-dialog",
"component": "resultsViewerDialog"
}
],
"pages": [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as React from 'react';
import classNames from 'classnames';
import { ConfigurableLink, formatDate, formatTime, parseDate } from '@openmrs/esm-framework';
import { formatDate, formatTime, parseDate, showModal } from '@openmrs/esm-framework';
import { type OBSERVATION_INTERPRETATION, getPatientUuidFromUrl } from '@openmrs/esm-patient-common-lib';
import { type ParsedTimeType } from '../filter/filter-types';
import { testResultsBasePath } from '../helpers';
import type { ObsRecord } from '../../types';
import styles from './timeline.scss';
import { Button } from '@carbon/react';

export const parseTime: (sortedTimes: Array<string>) => ParsedTimeType = (sortedTimes) => {
const yearColumns: Array<{ year: string; size: number }> = [],
Expand Down Expand Up @@ -116,6 +116,15 @@ export const TimelineCell: React.FC<{

export const RowStartCell = ({ title, range, units, shadow = false, testUuid, isString = false }) => {
const patientUuid = getPatientUuidFromUrl();
const launchResultsDialog = (patientUuid: string, title: string, testUuid: string) => {
const dispose = showModal('results-viewer-dialog', {
closeDeleteModal: () => dispose(),
patientUuid,
title,
testUuid,
});
};

return (
<div
className={styles['row-start-cell']}
Expand All @@ -125,9 +134,12 @@ export const RowStartCell = ({ title, range, units, shadow = false, testUuid, is
>
<span className={styles['trendline-link']}>
{!isString ? (
<ConfigurableLink to={`${testResultsBasePath(`/patient/${patientUuid}/chart`)}/trendline/${testUuid}`}>
<p
className={styles['trendline-link-view']}
onClick={() => launchResultsDialog(patientUuid, title, testUuid)}
>
{title}
</ConfigurableLink>
</p>
) : (
title
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import { ModalHeader } from '@carbon/react';
import { ModalBody } from '@carbon/react';
import Trendline from '../trendline/trendline.component';
import { basePath } from '@openmrs/esm-patient-chart-app/src/constants';

interface ResultsModalProps {
closeDeleteModal: () => void;
patientUuid: string;
title: string;
testUuid: string;
range: any;
units: any;
}

const ResultsModal: React.FC<ResultsModalProps> = ({ closeDeleteModal, patientUuid, testUuid }) => {
return (
<div>
<ModalHeader title="Trendline" closeModal={closeDeleteModal} />
<ModalBody>
<Trendline patientUuid={patientUuid} conceptUuid={testUuid} basePath={basePath} />
</ModalBody>
</div>
);
};

export default ResultsModal;
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,12 @@
.recent-results-grid::-webkit-scrollbar {
display: none;
}

.trendline-link-view {
color: #0f62fe;
cursor: pointer;
}

.trendline-link-view:hover {
text-decoration: underline;
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const Trendline: React.FC<TrendlineProps> = ({
const { obs, display: chartTitle, hiNormal, lowNormal, units: leftAxisTitle, range: referenceRange } = trendlineData;
const bottomAxisTitle = t('date', 'Date');
const [range, setRange] = useState<[Date, Date]>();
const [showResultsTable, setShowResultsTable] = useState(false);

const [upperRange, lowerRange] = useMemo(() => {
if (obs.length === 0) {
Expand Down Expand Up @@ -235,7 +236,19 @@ const Trendline: React.FC<TrendlineProps> = ({
<RangeSelector setLowerRange={setLowerRange} upperRange={upperRange} />
<LineChart data={data} options={chartOptions} />
</TrendLineBackground>
<DrawTable {...{ tableData, tableHeaderData }} />

{showResultsTable ? (
<>
<Button kind="ghost" onClick={() => setShowResultsTable(false)} className={styles['show-hide-table']}>
{t('hideResultsTable', 'Hide results table')}
</Button>
<DrawTable {...{ tableData, tableHeaderData }} />
</>
) : (
<Button kind="ghost" onClick={() => setShowResultsTable(true)} className={styles['show-hide-table']}>
{t('showResultsTable', 'Show results table')}
</Button>
)}
</div>
);
};
Expand Down
2 changes: 2 additions & 0 deletions packages/esm-patient-labs-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"female": "Female",
"full": "Full",
"goToDrugOrderForm": "Order form",
"hideResultsTable": "Hide results table",
"labOrders": "Lab orders",
"labReferenceNumber": "Lab reference number",
"male": "Male",
Expand Down Expand Up @@ -58,6 +59,7 @@
"searchResultsMatchesForTerm_one": "{{count}} result for \"{{searchTerm}}\"",
"searchResultsMatchesForTerm_other": "{{count}} results for \"{{searchTerm}}\"",
"seeAllResults": "See all results",
"showResultsTable": "Show results table",
"showTree": "Show tree",
"split": "Split",
"startDate": "Start date",
Expand Down

0 comments on commit 53f0d0f

Please sign in to comment.