Skip to content

Commit

Permalink
(feat) updated the custom representation
Browse files Browse the repository at this point in the history
  • Loading branch information
its-kios09 committed Nov 21, 2024
1 parent 9cb1e0f commit 3cfef46
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/components/orders-table/list-order-details.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
margin-left: layout.$spacing-05;
margin-top: layout.$spacing-07;
}

.accordionContainer {
margin-top: layout.$spacing-03;
}
8 changes: 4 additions & 4 deletions src/components/orders-table/orders-data-table.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ import { formatDate, parseDate, usePagination } from '@openmrs/esm-framework';
import { Order } from '@openmrs/esm-patient-common-lib';
import React, { useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import usePatientAge, { useLabOrders, useSearchGroupedResults } from '../../laboratory-resource';
import { useLabOrders, useSearchGroupedResults } from '../../laboratory-resource';
import { FulfillerStatus, OrdersDataTableProps } from '../../types';
import ListOrderDetails from './list-order-details.component';
import styles from './orders-data-table.scss';
import { OrdersDateRangePicker } from './orders-date-range-picker';
import { PatientAge } from './patient-age.component';

const OrdersDataTable: React.FC<OrdersDataTableProps> = (props) => {
const { t } = useTranslation();
Expand All @@ -47,6 +46,7 @@ const OrdersDataTable: React.FC<OrdersDataTableProps> = (props) => {
dateActivated: formatDate(parseDate(order.dateActivated)),
patientName: order.patient?.display.split('-')[1],
patientUuid: order.patient?.uuid,
patientAge: order.patient?.person?.age,
status: order.fulfillerStatus ?? '--',
orderer: order.orderer,
};
Expand Down Expand Up @@ -114,7 +114,7 @@ const OrdersDataTable: React.FC<OrdersDataTableProps> = (props) => {
const columns = useMemo(() => {
return [
{ id: 0, header: t('patient', 'Patient'), key: 'patientName' },
{ id: 1, header: t('age', 'Age'), key: 'age' },
{ id: 1, header: t('age', 'Age'), key: 'patientAge' }, // Age is now included as a column
{ id: 2, header: t('totalOrders', 'Total Orders'), key: 'totalOrders' },
];
}, [t]);
Expand All @@ -129,9 +129,9 @@ const OrdersDataTable: React.FC<OrdersDataTableProps> = (props) => {
return paginatedLabOrders.map((order) => ({
id: order.patientId,
patientName: order.orders[0].patient?.display?.split('-')[1],
age: <PatientAge patientUuid={order.patientId} />,
orders: order.orders,
totalOrders: order.orders?.length,
patientAge: order.orders[0].patient?.person?.age,
}));
}, [paginatedLabOrders]);

Expand Down
11 changes: 0 additions & 11 deletions src/components/orders-table/patient-age.component.tsx

This file was deleted.

4 changes: 3 additions & 1 deletion src/laboratory-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export function useLabOrders(status: 'NEW' | FulfillerStatus = null, excludeCanc
const { laboratoryOrderTypeUuid } = useConfig();
const fulfillerStatus = useMemo(() => (status === 'NEW' ? null : status), [status]);
const newOrdersOnly = status === 'NEW';
let url = `${restBaseUrl}/order?orderTypes=${laboratoryOrderTypeUuid}&v=full`;
const customRepresentation =
'custom:(uuid,orderNumber,patient:(uuid,display,person:(uuid,display,age)),concept:(uuid,display),action,careSetting:(uuid,display,description,careSettingType,display),previousOrder,dateActivated,scheduledDate,dateStopped,autoExpireDate,encounter:(uuid,display),orderer:(uuid,display),orderReason,orderReasonNonCoded,orderType:(uuid,display,name,description,conceptClasses,parent),urgency,instructions,commentToFulfiller,display,fulfillerStatus,fulfillerComment,specimenSource,laterality,clinicalHistory,frequency,numberOfRepeats)';
let url = `${restBaseUrl}/order?orderTypes=${laboratoryOrderTypeUuid}&v=${customRepresentation}`;
url = fulfillerStatus ? url + `&fulfillerStatus=${fulfillerStatus}` : url;
url = excludeCanceled ? `${url}&excludeCanceledAndExpired=true&excludeDiscontinueOrders=true` : url;
// The usage of SWR's mutator seems to only suffice for cases where we don't apply a status filter
Expand Down
2 changes: 1 addition & 1 deletion src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"component": "rejectLabRequestAction",
"slot": "tests-ordered-actions-slot"
},
{
{
"name": "edit-lab-request-tests-ordered-action",
"component": "editLabRequestAction",
"slot": "completed-ordered-actions-slot"
Expand Down

0 comments on commit 3cfef46

Please sign in to comment.