|
1 | 1 | import React from 'react';
|
2 | 2 | import { useTranslation } from 'react-i18next';
|
3 |
| -import { Button, Tile, Accordion, AccordionItem } from '@carbon/react'; |
4 |
| -import { ExtensionSlot, launchWorkspace, showModal } from '@openmrs/esm-framework'; |
| 3 | +import { |
| 4 | + Tag, |
| 5 | + StructuredListWrapper, |
| 6 | + StructuredListRow, |
| 7 | + StructuredListCell, |
| 8 | + StructuredListBody, |
| 9 | + Button, |
| 10 | + Accordion, |
| 11 | + AccordionItem, |
| 12 | +} from '@carbon/react'; |
| 13 | +import capitalize from 'lodash-es/capitalize'; |
5 | 14 | import { ListOrdersDetailsProps } from '../../types';
|
6 | 15 | import styles from './list-order-details.scss';
|
7 |
| -import { OrderDetail } from './order-detail.component'; |
8 |
| - |
| 16 | +import { ExtensionSlot, useLayoutType } from '@openmrs/esm-framework'; |
| 17 | +import { Edit } from '@carbon/react/icons'; |
9 | 18 | const ListOrderDetails: React.FC<ListOrdersDetailsProps> = (props) => {
|
10 | 19 | const { t } = useTranslation();
|
11 | 20 | const orders = props.groupedOrders?.orders;
|
| 21 | + const isTablet = useLayoutType() === 'tablet'; |
12 | 22 |
|
13 | 23 | return (
|
14 |
| - <div className={styles.ordersContainer}> |
| 24 | + <div> |
15 | 25 | {orders &&
|
16 | 26 | orders.map((row) => (
|
17 |
| - <Tile className={styles.orderTile}> |
18 |
| - <div> |
19 |
| - <OrderDetail label={t('date', 'Date').toUpperCase()} value={row.dateActivated} /> |
20 |
| - <OrderDetail label={t('orderNumber', 'Order number').toUpperCase()} value={row.orderNumber} /> |
21 |
| - <OrderDetail label={t('procedure', 'Procedure').toUpperCase()} value={row.display} /> |
22 |
| - <OrderDetail label={t('status', 'Status').toUpperCase()} value={row.fulfillerStatus} /> |
23 |
| - <OrderDetail label={t('urgency', 'Urgency').toUpperCase()} value={row.urgency} /> |
24 |
| - <OrderDetail label={t('orderer', 'Orderer').toUpperCase()} value={row.orderer?.display} /> |
25 |
| - <OrderDetail label={t('instructions', 'Instructions').toUpperCase()} value={row.instructions ?? '--'} /> |
| 27 | + <div className={styles.orderDetailsContainer}> |
| 28 | + <div className={styles.orderUrgency}></div> |
| 29 | + <div className={styles.orderHeader}> |
| 30 | + <span className={styles.orderNumber}> |
| 31 | + {t('orderNumbers', 'Order number:')} {row.orderNumber} |
| 32 | + </span> |
| 33 | + <span className={styles.orderDate}> |
| 34 | + {t('orderDate', 'Order Date:')} {row.dateActivated} |
| 35 | + </span> |
26 | 36 | </div>
|
27 |
| - |
28 |
| - <div className={styles.actionButtons}> |
29 |
| - {row.fulfillerStatus === 'New' || row.fulfillerStatus === 'RECEIVED' || row.fulfillerStatus == null ? ( |
30 |
| - <ExtensionSlot className={styles.menuLink} state={{ order: row }} name="tests-ordered-actions-slot" /> |
31 |
| - ) : row.fulfillerStatus === 'IN_PROGRESS' ? ( |
32 |
| - <ExtensionSlot |
33 |
| - className={styles.menuLink} |
34 |
| - state={{ order: row }} |
35 |
| - name="inprogress-tests-actions-slot" |
36 |
| - /> |
37 |
| - ) : row.fulfillerStatus === 'COMPLETED' ? ( |
38 |
| - <ExtensionSlot |
39 |
| - className={styles.menuLink} |
40 |
| - state={{ order: row }} |
41 |
| - name="completed-ordered-actions-slot" |
42 |
| - /> |
43 |
| - ) : ( |
44 |
| - <div></div> |
45 |
| - )} |
| 37 | + <div className={styles.orderStatus}> |
| 38 | + {t('orderStatus', 'Status:')} |
| 39 | + <Tag size="lg" type={row.fulfillerStatus ? 'green' : 'red'}> |
| 40 | + {row.fulfillerStatus || t('orderNotPicked', 'Order not picked')} |
| 41 | + </Tag> |
| 42 | + </div> |
| 43 | + <div> |
| 44 | + <div className={styles.orderUrgency}> |
| 45 | + <span className={styles.urgencyStatus}> |
| 46 | + {t('urgencyStatus', 'Urgency: ')} {capitalize(row.urgency)} |
| 47 | + </span> |
| 48 | + </div> |
| 49 | + <StructuredListWrapper> |
| 50 | + <StructuredListBody> |
| 51 | + <StructuredListRow> |
| 52 | + <StructuredListCell>{t('testOrdered', 'Test ordered: ')}</StructuredListCell> |
| 53 | + <StructuredListCell>{capitalize(row?.display)}</StructuredListCell> |
| 54 | + <br /> |
| 55 | + <StructuredListCell> |
| 56 | + <span className={styles.instructionLabel}>{t('orderInStruction', 'Instructions: ')}</span> |
| 57 | + <span className={styles.instructions}> |
| 58 | + {row.instructions ?? ( |
| 59 | + <Tag size="lg" type="red"> |
| 60 | + {t('NoInstructionLeft', 'No instructions are provided.')} |
| 61 | + </Tag> |
| 62 | + )} |
| 63 | + </span> |
| 64 | + </StructuredListCell> |
| 65 | + </StructuredListRow> |
| 66 | + </StructuredListBody> |
| 67 | + </StructuredListWrapper> |
46 | 68 | {row.fulfillerStatus === 'COMPLETED' && (
|
47 |
| - <div className={styles.accordionContainer}> |
48 |
| - <Accordion> |
49 |
| - <AccordionItem title={t('results', 'Results')}> |
| 69 | + <Accordion> |
| 70 | + <AccordionItem |
| 71 | + title={<span className={styles.accordionTitle}>{t('viewTestResults', 'View test results')}</span>} |
| 72 | + > |
| 73 | + <div className={styles.viewResults}> |
50 | 74 | <ExtensionSlot
|
51 | 75 | className={styles.labResultSlot}
|
52 | 76 | state={{ order: row }}
|
53 | 77 | name="completed-lab-order-results-slot"
|
54 | 78 | />
|
55 |
| - </AccordionItem> |
56 |
| - </Accordion> |
57 |
| - </div> |
| 79 | + </div> |
| 80 | + |
| 81 | + {row.fulfillerStatus === 'COMPLETED' && ( |
| 82 | + <ExtensionSlot |
| 83 | + className={styles.menuLink} |
| 84 | + state={{ order: row }} |
| 85 | + name="completed-ordered-actions-slot" |
| 86 | + /> |
| 87 | + )} |
| 88 | + </AccordionItem> |
| 89 | + </Accordion> |
58 | 90 | )}
|
| 91 | + <StructuredListRow> |
| 92 | + <StructuredListCell> |
| 93 | + <span className={styles.nameOrder}> |
| 94 | + {t('ordererName', 'Orderer Name: ')} {capitalize(row.orderer?.display)} |
| 95 | + </span> |
| 96 | + </StructuredListCell> |
| 97 | + </StructuredListRow> |
| 98 | + |
| 99 | + <div className={styles.buttonSection}> |
| 100 | + <div className={styles.actionButtons}> |
| 101 | + {row.fulfillerStatus === 'New' || |
| 102 | + row.fulfillerStatus === 'RECEIVED' || |
| 103 | + row.fulfillerStatus == null ? ( |
| 104 | + <> |
| 105 | + <div className={styles.actionButtons}> |
| 106 | + <div className={styles.rejectButton}> |
| 107 | + <ExtensionSlot state={{ order: row }} name="rejected-ordered-actions-slot" /> |
| 108 | + </div> |
| 109 | + <div className={styles.testsOrderedActions}> |
| 110 | + <ExtensionSlot state={{ order: row }} name="tests-ordered-actions-slot" /> |
| 111 | + </div> |
| 112 | + </div> |
| 113 | + </> |
| 114 | + ) : row.fulfillerStatus === 'IN_PROGRESS' ? ( |
| 115 | + <> |
| 116 | + <div className={styles.testsOrderedActions}> |
| 117 | + <ExtensionSlot |
| 118 | + className={styles.menuLink} |
| 119 | + state={{ order: row }} |
| 120 | + name="inprogress-tests-actions-slot" |
| 121 | + /> |
| 122 | + </div> |
| 123 | + </> |
| 124 | + ) : ( |
| 125 | + <div></div> |
| 126 | + )} |
| 127 | + </div> |
| 128 | + </div> |
59 | 129 | </div>
|
60 |
| - </Tile> |
| 130 | + </div> |
61 | 131 | ))}
|
62 | 132 | </div>
|
63 | 133 | );
|
|
0 commit comments