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
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ VITE_USE_PHARMACY_IN_PREFETCH = true
VITE_INTERMEDIARY = http://localhost:3003
VITE_DISABLE_MEDICATION_STATUS = false
VITE_PHARMACY_ID = pharm0111
VITE_PACIO_EHR_URL = https://gw.interop.community/paciosandbox2/open/Bundle
VITE_PACIO_NEW_PRESCRIBER_ID=pra1234
13 changes: 6 additions & 7 deletions src/PrefetchTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
export class PrefetchTemplate {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did anything change in this file?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think its just linting

static generatePrefetchMap(settings = null) {
// If no settings provided, use defaults from data.js
const includePharmacy = settings?.includePharmacyInPreFetch ??
headerDefinitions.includePharmacyInPreFetch.default;
const pharmacyId = settings?.pharmacyId ??
headerDefinitions.pharmacyId.default;
const includePharmacy =
settings?.includePharmacyInPreFetch ?? headerDefinitions.includePharmacyInPreFetch.default;
const pharmacyId = settings?.pharmacyId ?? headerDefinitions.pharmacyId.default;

const prefetchMap = new Map();

Expand Down Expand Up @@ -64,7 +63,7 @@ export class PrefetchTemplate {
) {
const prefetchMap = PrefetchTemplate.generatePrefetchMap(settings);
const paramElementMap = PrefetchTemplate.generateParamElementMap();

var resolvedQueries = new Map();
for (var i = 0; i < prefetchKeys.length; i++) {
var prefetchKey = prefetchKeys[i];
Expand All @@ -73,7 +72,7 @@ export class PrefetchTemplate {
// Regex source: https://regexland.com/all-between-specified-characters/
var parametersToFill = query.match(/(?<={{).*?(?=}})/gs);
var resolvedQuery = query.slice();

if (parametersToFill) {
for (var j = 0; j < parametersToFill.length; j++) {
var unresolvedParameter = parametersToFill[j];
Expand Down Expand Up @@ -135,4 +134,4 @@ export class PrefetchTemplate {
getQuery() {
return this.query;
}
}
}
73 changes: 36 additions & 37 deletions src/components/RequestDashboard/Communication.jsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,44 @@
import { Button, Grid } from "@mui/material";
import { Button, Grid } from '@mui/material';
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any changes here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think its just linting

import DeleteIcon from '@mui/icons-material/Delete';
import useStyles from './styles';


const Communication = props => {
const classes = useStyles();
const { communication, deleteCommunication } = props;
const classes = useStyles();
const { communication, deleteCommunication } = props;

const convertTimeStamp = (timeStamp) => {
const date = new Date(timeStamp);
return date.toLocaleString();
};
const convertTimeStamp = timeStamp => {
const date = new Date(timeStamp);
return date.toLocaleString();
};

return (
<div>
<Grid container>
<Grid className={classes.communicationHeader} item xs={2}>
{`ID: ${communication.id}`}
</Grid>
<Grid className={classes.communicationHeader} item xs={8.7}>
{`Received: ${convertTimeStamp(communication.received)}`}
</Grid>
<Grid className={classes.communicationHeaderButton} item xs={1.3}>
<Button
fullWidth
variant="contained"
color="error"
startIcon={<DeleteIcon />}
onClick={() => {
deleteCommunication(communication.id);
}}
>
Clear
</Button>
</Grid>
<Grid className={classes.communicationDescription} item xs={12}>
{communication.payload[0].contentString}
</Grid>
</Grid>
</div>
);
return (
<div>
<Grid container>
<Grid className={classes.communicationHeader} item xs={2}>
{`ID: ${communication.id}`}
</Grid>
<Grid className={classes.communicationHeader} item xs={8.7}>
{`Received: ${convertTimeStamp(communication.received)}`}
</Grid>
<Grid className={classes.communicationHeaderButton} item xs={1.3}>
<Button
fullWidth
variant="contained"
color="error"
startIcon={<DeleteIcon />}
onClick={() => {
deleteCommunication(communication.id);
}}
>
Clear
</Button>
</Grid>
<Grid className={classes.communicationDescription} item xs={12}>
{communication.payload[0].contentString}
</Grid>
</Grid>
</div>
);
};

export default Communication;
export default Communication;
99 changes: 51 additions & 48 deletions src/components/RequestDashboard/CommunicationsDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Badge from '@mui/material/Badge';
import Dialog from '@mui/material/Dialog';
import DialogTitle from '@mui/material/DialogTitle';
import DialogContent from '@mui/material/DialogContent';
import { Refresh } from '@mui/icons-material'
import { Refresh } from '@mui/icons-material';

import { styled } from '@mui/material/styles';
import Paper from '@mui/material/Paper';
Expand All @@ -23,25 +23,23 @@ const CommunicationsDialog = props => {
open: false
});

const debugLog = (message) => {
const debugLog = message => {
console.log('CommunicationsDialog: ' + message);
};

useEffect(() => {
// reload on page load and dialog open
if (state.initialLoad) {
setState(prevState => ({ ...prevState, initialLoad: false}));
setState(prevState => ({ ...prevState, initialLoad: false }));
getCommunications();
}

const interval = setInterval(() => {
// page load...
getCommunications();

}, 1000 * 5) // reload every 5 seconds
}, 1000 * 5); // reload every 5 seconds

return () => clearInterval(interval);

});

const getCommunications = () => {
Expand All @@ -56,85 +54,90 @@ const CommunicationsDialog = props => {
loadCommunications(bundle);
});
}
}
};

const deleteCommunication = (id) => {
const deleteCommunication = id => {
debugLog('deleteCommunication: ' + id);
if (id) {
state.client.delete(`Communication/${id}`).then(() => {
debugLog(`Deleted communication: ${id}`);
getCommunications();
});
}
}
};

const loadCommunications = (bundle) => {
const loadCommunications = bundle => {
let count = bundle.length;
setState(prevState => ({ ...prevState, communicationCount: count, communications: bundle}));
setState(prevState => ({ ...prevState, communicationCount: count, communications: bundle }));
};

const handleClose = () => {
setState(prevState => ({ ...prevState, open: false}));
setState(prevState => ({ ...prevState, open: false }));
};

const Item = styled(Paper)(({ theme }) => ({
backgroundColor: theme.palette.mode === 'dark' ? '#1A2027' : '#EDF6FF',
...theme.typography.body2,
padding: theme.spacing(1),
textAlign: 'left',
color: theme.palette.text.secondary,
color: theme.palette.text.secondary
}));

const renderCommunications = () => {
return (
<Grid container spacing={2} sx={{ mt: 2 }}>
<Grid container spacing={2} sx={{ mt: 2 }}>
{state.communications.map(communication => {
return (
<Grid item xs={12} sm={12}>
<Item><Communication communication={communication} deleteCommunication={deleteCommunication}/></Item>
<Item>
<Communication
communication={communication}
deleteCommunication={deleteCommunication}
/>
</Item>
</Grid>
);
})}
</Grid>
</Grid>
);
}
};

return (
<span>
<span onClick={() => {
setState(prevState => ({ ...prevState, open: true, initialLoad: true}));
}} >
<Badge badgeContent={state.communicationCount} color="primary">
<NotificationsIcon sx={{ fontSize: 26, verticalAlign: 'middle' }} />
</Badge></span>
<Dialog fullWidth maxWidth='md' onClose={handleClose} open={state.open}>
<DialogTitle>
<Grid container>
<Grid item xs={10}>
<NotificationsIcon sx={{ fontSize: 26, verticalAlign: 'middle' }} />
Communications ({state.communicationCount})
</Grid>
<Grid item xs={2}>
<Button
variant="contained"
startIcon={<Refresh />}
onClick={() => {
getCommunications();
}}
>
Refresh
</Button>
<span
onClick={() => {
setState(prevState => ({ ...prevState, open: true, initialLoad: true }));
}}
>
<Badge badgeContent={state.communicationCount} color="primary">
<NotificationsIcon sx={{ fontSize: 26, verticalAlign: 'middle' }} />
</Badge>
</span>
<Dialog fullWidth maxWidth="md" onClose={handleClose} open={state.open}>
<DialogTitle>
<Grid container>
<Grid item xs={10}>
<NotificationsIcon sx={{ fontSize: 26, verticalAlign: 'middle' }} />
Communications ({state.communicationCount})
</Grid>
<Grid item xs={2}>
<Button
variant="contained"
startIcon={<Refresh />}
onClick={() => {
getCommunications();
}}
>
Refresh
</Button>
</Grid>
</Grid>
</Grid>
</DialogTitle>

<DialogContent>
{ renderCommunications() }
</DialogContent>
</DialogTitle>

</Dialog>
<DialogContent>{renderCommunications()}</DialogContent>
</Dialog>
</span>
);
};

export default CommunicationsDialog;
export default CommunicationsDialog;
7 changes: 2 additions & 5 deletions src/components/RequestDashboard/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import PatientSection from './PatientSection';
import SettingsSection from './SettingsSection';
import TasksSection from './TasksSection';


import { logout } from '../../util/auth';

const Home = props => {
Expand Down Expand Up @@ -86,9 +85,7 @@ const Home = props => {
{section ? (
<Grid className={classes.spacer} item xs={5}>
<span className={classes.loginIcon}>
<CommunicationsDialog
client={props.client} token={token}
/>
<CommunicationsDialog client={props.client} token={token} />
&nbsp;&nbsp;
<AccountBoxIcon sx={{ fontSize: 48, verticalAlign: 'middle' }} /> {token.name}
<Button variant="outlined" className={classes.whiteButton} onClick={logout}>
Expand Down Expand Up @@ -121,7 +118,7 @@ const Home = props => {
<TasksSection client={props.client} userName={token.name} userId={token.userId} />
</div>
<div className={settingsRenderClass}>
<SettingsSection client={props.client} />
<SettingsSection client={props.client} userId={token.userId} />
</div>
</div>
);
Expand Down
Loading