Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions backend/src/routes/doctorOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',

Expand Down
151 changes: 90 additions & 61 deletions frontend/src/views/DoctorOrders/OrderCard/OrderCard.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<DoctorOrder[]>([]);

const [doctorOrder, getDoctorOrders] = useState<DoctorOrder[]>([]);

//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 (
<Card><h1>No orders yet.</h1></Card>
<Card style={{padding: '15px' }}>
<h1>No orders yet.</h1>
</Card>
);
} else {
return (
<Card sx={{ bgcolor: '#F5F5F7' }}>
{doctorOrder.map((row) =>
{doctorOrder.map(row => (
<Card key={row.caseNumber} sx={{ minWidth: 275, margin: 2, boxShadow: '10px' }}>
{/* 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 && (
<Card>
<CardContent>
<Box>
<Typography variant='h5' component='div'>
<Box>
<Typography variant="h5" component="div">
{row.patientName}
</Typography>
<Typography variant='h5' component='div' color='text.secondary'>
<Typography variant="h5" component="div" color="text.secondary">
DOB: {row.patientDOB}
</Typography>
{/* <Typography sx={{ fontSize: 14 }} color='text.secondary' gutterBottom>
Case # {row.caseNumber}
</Typography> */}
<Typography component='div' sx={{ mb: 2 }} variant='h6'>
<Typography component="div" sx={{ mb: 2 }} variant="h6">
{row.drugNames}
</Typography>
</Box>
</Typography>
</Box>
<TableContainer component={Paper}>
<Table sx={{ minWidth: 650 }} aria-label='simple table'>
<Table sx={{ minWidth: 650 }} aria-label="simple table">
<TableHead sx={{ fontWeight: 'bold' }}>
<TableRow sx={{ fontWeight: 'bold' }}>
<TableCell align='left'>Dispense Status</TableCell>
<TableCell align='right'>Quanitities</TableCell>
<TableCell align='right'>Drug Price</TableCell>
<TableCell align='right'>Total</TableCell>
<TableCell align='right'>Doctor Name</TableCell>
<TableCell align='right'>Doctor ID</TableCell>
<TableCell align='right'>Doctor Contact</TableCell>
<TableCell align='right'>Doctor Email</TableCell>
<TableCell align='right'>Pickup Date</TableCell>
<TableCell align="left">Dispense Status</TableCell>
<TableCell align="right">Quanitities</TableCell>
<TableCell align="right">Drug Price</TableCell>
<TableCell align="right">Total</TableCell>
<TableCell align="right">Doctor Name</TableCell>
<TableCell align="right">Doctor ID</TableCell>
<TableCell align="right">Doctor Contact</TableCell>
<TableCell align="right">Doctor Email</TableCell>
<TableCell align="right">Pickup Date</TableCell>
</TableRow>
</TableHead>
<TableBody>
<TableRow>
<TableCell align='left'>{row.dispenseStatus}</TableCell>
<TableCell align='right'>{row.quanitities}</TableCell>
<TableCell align='right'>{row.drugPrice}</TableCell>
<TableCell align='right'>{row.total}</TableCell>
<TableCell align='right'>{row.doctorName}</TableCell>
<TableCell align='right'>{row.doctorID}</TableCell>
<TableCell align='right'>{row.doctorContact}</TableCell>
<TableCell align='right'>{row.doctorEmail}</TableCell>
<TableCell align='right'>{row.pickupDate}</TableCell>
<TableCell align="left">{row.dispenseStatus}</TableCell>
<TableCell align="right">{row.quanitities}</TableCell>
<TableCell align="right">{row.drugPrice}</TableCell>
<TableCell align="right">{row.total}</TableCell>
<TableCell align="right">{row.doctorName}</TableCell>
<TableCell align="right">{row.doctorID}</TableCell>
<TableCell align="right">{row.doctorContact}</TableCell>
<TableCell align="right">{row.doctorEmail}</TableCell>
<TableCell align="right">{row.pickupDate}</TableCell>
</TableRow>
</TableBody>
</Table>
Expand All @@ -121,21 +131,40 @@ const OrderCard = (props: any) => {
<CardActions>
<Box sx={{ marginLeft: 'auto', mr: '8px' }}>
<EtasuPopUp data={row} />
{(props.tabStatus === 'Pending') ? <VerifyButton data={{row, getAllDoctorOrders}}/> : ''}
{(props.tabStatus === 'Approved') ? <PickedUpButton data={{row, getAllDoctorOrders}}/> : ''}
{/* <Button variant='contained' size='small' onClick={}>Verify Order</Button> */}
{props.tabStatus === 'Pending' && (
<VerifyButton data={{ row, getAllDoctorOrders }} />
)}
{props.tabStatus === 'Approved' && (
<PickedUpButton data={{ row, getAllDoctorOrders }} />
)}
</Box>
</CardActions>
</Card>
: '' }
)}
</Card>
)}
<Box sx={{ marginLeft: 'auto', m: '8px', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<Button onClick={deleteAll} variant='outlined' color='error' size='small' sx={{ mr: '10px' }}>Remove All</Button>
))}
<Box
sx={{
marginLeft: 'auto',
m: '8px',
display: 'flex',
justifyContent: 'center',
alignItems: 'center'
}}
>
<Button
onClick={deleteAll}
variant="outlined"
color="error"
size="small"
sx={{ mr: '10px' }}
>
Remove All
</Button>
</Box>
</Card>
);
}
};

export default OrderCard;
export default OrderCard;