From 707058b37391b245e811c6abb3b19f6926e0e6b3 Mon Sep 17 00:00:00 2001 From: Joyce Quach Date: Thu, 27 Jul 2023 18:02:10 -0400 Subject: [PATCH 1/2] Update OrderCard and updateRx route to hide View ETASU button and prevent from moving Picked Up order back to Verified state --- backend/src/routes/doctorOrders.js | 6 + .../DoctorOrders/OrderCard/OrderCard.tsx | 151 +++++++++++------- 2 files changed, 96 insertions(+), 61 deletions(-) diff --git a/backend/src/routes/doctorOrders.js b/backend/src/routes/doctorOrders.js index 4a6e849..5e703ea 100644 --- a/backend/src/routes/doctorOrders.js +++ b/backend/src/routes/doctorOrders.js @@ -60,6 +60,12 @@ router.patch('/api/updateRx/:id', async (req, res) => { const order = await doctorOrder.findById(req.params.id).exec(); console.log('found by id!'); + console.log('order', order); + if (order.dispenseStatus === 'Picked Up') { + console.log('Do not update prescription if it is picked up, it was verified before'); + return; + } + // Reaching out to REMS Admin finding by pt name and drug name // '/etasu/met/patient/:patientFirstName/:patientLastName/:patientDOB/drug/:drugName', diff --git a/frontend/src/views/DoctorOrders/OrderCard/OrderCard.tsx b/frontend/src/views/DoctorOrders/OrderCard/OrderCard.tsx index e6b47ef..82c4eb8 100644 --- a/frontend/src/views/DoctorOrders/OrderCard/OrderCard.tsx +++ b/frontend/src/views/DoctorOrders/OrderCard/OrderCard.tsx @@ -1,4 +1,18 @@ -import { Box, Button, Card, CardActions, CardContent, Paper, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Typography } from '@mui/material'; +import { + Box, + Button, + Card, + CardActions, + CardContent, + Paper, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + Typography +} from '@mui/material'; import axios from 'axios'; import { useEffect, useState } from 'react'; import EtasuPopUp from './EtasuPopUp/EtasuPopUp'; @@ -21,98 +35,94 @@ interface DoctorOrder { pickupDate?: string; dispenseStatus?: string; metRequirements: { - stakeholderId: string, - completed: boolean, - metRequirementId: string, - requirementName: string, - requirementDescription: string - }[] + stakeholderId: string; + completed: boolean; + metRequirementId: string; + requirementName: string; + requirementDescription: string; + }[]; } const OrderCard = (props: any) => { + const [doctorOrder, setDoctorOrders] = useState([]); - const [doctorOrder, getDoctorOrders] = useState([]); - - //remove all doctorOrders + //remove all doctorOrders const deleteAll = async () => { const orders = await axios.delete('/doctorOrders/api/deleteAll'); - getDoctorOrders(orders.data); + setDoctorOrders(orders.data); console.log('Deleting all Doctor Orders'); }; const url = '/doctorOrders/api/getRx'; - // Running after component renders to call api + // Running after component renders to call api useEffect(() => { getAllDoctorOrders(); }, []); const getAllDoctorOrders = () => { - axios.get(url) + axios + .get(url) .then(function (response) { - - // console.log('Prescription: '); - // console.log(response.data); - const AllDoctorOrders = response.data; - //Adding data to state - getDoctorOrders(AllDoctorOrders); + const allDoctorOrders = response.data; + setDoctorOrders(allDoctorOrders); }) - .catch(error => console.error('Error: $(error')); + .catch(error => console.error(`Error: ${error}`)); }; - - if (doctorOrder.length < 0) { + if (doctorOrder.length < 1) { return ( -

No orders yet.

+ +

No orders yet.

+
); } else { return ( - {doctorOrder.map((row) => + {doctorOrder.map(row => ( {/* Checking dispense status for the right tab to display it correctly */} - {(props.tabStatus === row.dispenseStatus) ? + {/* TODO: We should add an endpoint with the ability to fetch doctor orders based on the + tab/dispense status instead of fetching all doctor orders and filtering them out on the frontend. */} + {props.tabStatus === row.dispenseStatus && ( - - + + {row.patientName} - + DOB: {row.patientDOB} - {/* - Case # {row.caseNumber} - */} - + {row.drugNames} - - + + - +
- Dispense Status - Quanitities - Drug Price - Total - Doctor Name - Doctor ID - Doctor Contact - Doctor Email - Pickup Date + Dispense Status + Quanitities + Drug Price + Total + Doctor Name + Doctor ID + Doctor Contact + Doctor Email + Pickup Date - {row.dispenseStatus} - {row.quanitities} - {row.drugPrice} - {row.total} - {row.doctorName} - {row.doctorID} - {row.doctorContact} - {row.doctorEmail} - {row.pickupDate} + {row.dispenseStatus} + {row.quanitities} + {row.drugPrice} + {row.total} + {row.doctorName} + {row.doctorID} + {row.doctorContact} + {row.doctorEmail} + {row.pickupDate}
@@ -121,21 +131,40 @@ const OrderCard = (props: any) => { - {(props.tabStatus === 'Pending') ? : ''} - {(props.tabStatus === 'Approved') ? : ''} - {/* */} + {props.tabStatus === 'Pending' && ( + + )} + {props.tabStatus === 'Approved' && ( + + )}
- : '' } + )}
- )} - - + ))} + +
); } }; -export default OrderCard; \ No newline at end of file +export default OrderCard; From 4bd6ca5f7860d7475693828599a53ea96680f67e Mon Sep 17 00:00:00 2001 From: KeeyanGhoreshi Date: Fri, 28 Jul 2023 16:42:27 -0400 Subject: [PATCH 2/2] minor styling --- frontend/src/views/DoctorOrders/OrderCard/OrderCard.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/views/DoctorOrders/OrderCard/OrderCard.tsx b/frontend/src/views/DoctorOrders/OrderCard/OrderCard.tsx index 82c4eb8..de771e9 100644 --- a/frontend/src/views/DoctorOrders/OrderCard/OrderCard.tsx +++ b/frontend/src/views/DoctorOrders/OrderCard/OrderCard.tsx @@ -71,7 +71,7 @@ const OrderCard = (props: any) => { if (doctorOrder.length < 1) { return ( - +

No orders yet.

);