diff --git a/.env b/.env
index d4b9e1e..f6a3868 100644
--- a/.env
+++ b/.env
@@ -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
diff --git a/src/PrefetchTemplate.js b/src/PrefetchTemplate.js
index 573a880..7ee00ca 100644
--- a/src/PrefetchTemplate.js
+++ b/src/PrefetchTemplate.js
@@ -3,10 +3,9 @@
export class PrefetchTemplate {
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();
@@ -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];
@@ -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];
@@ -135,4 +134,4 @@ export class PrefetchTemplate {
getQuery() {
return this.query;
}
-}
\ No newline at end of file
+}
diff --git a/src/components/RequestDashboard/Communication.jsx b/src/components/RequestDashboard/Communication.jsx
new file mode 100644
index 0000000..05de736
--- /dev/null
+++ b/src/components/RequestDashboard/Communication.jsx
@@ -0,0 +1,44 @@
+import { Button, Grid } from '@mui/material';
+import DeleteIcon from '@mui/icons-material/Delete';
+import useStyles from './styles';
+
+const Communication = props => {
+ const classes = useStyles();
+ const { communication, deleteCommunication } = props;
+
+ const convertTimeStamp = timeStamp => {
+ const date = new Date(timeStamp);
+ return date.toLocaleString();
+ };
+
+ return (
+
+
+
+ {`ID: ${communication.id}`}
+
+
+ {`Received: ${convertTimeStamp(communication.received)}`}
+
+
+ }
+ onClick={() => {
+ deleteCommunication(communication.id);
+ }}
+ >
+ Clear
+
+
+
+ {communication.payload[0].contentString}
+
+
+
+ );
+};
+
+export default Communication;
diff --git a/src/components/RequestDashboard/CommunicationsDialog.jsx b/src/components/RequestDashboard/CommunicationsDialog.jsx
new file mode 100644
index 0000000..cfe387a
--- /dev/null
+++ b/src/components/RequestDashboard/CommunicationsDialog.jsx
@@ -0,0 +1,143 @@
+import { useEffect, useState } from 'react';
+
+import { Button, Grid } from '@mui/material';
+import NotificationsIcon from '@mui/icons-material/Notifications';
+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 { styled } from '@mui/material/styles';
+import Paper from '@mui/material/Paper';
+import Communication from './Communication';
+
+const CommunicationsDialog = props => {
+ const { client, token } = props;
+ const [state, setState] = useState({
+ client: client,
+ token: token,
+ initialLoad: true,
+ communicationCount: 0,
+ communications: [],
+ open: false
+ });
+
+ const debugLog = message => {
+ console.log('CommunicationsDialog: ' + message);
+ };
+
+ useEffect(() => {
+ // reload on page load and dialog open
+ if (state.initialLoad) {
+ setState(prevState => ({ ...prevState, initialLoad: false }));
+ getCommunications();
+ }
+
+ const interval = setInterval(() => {
+ // page load...
+ getCommunications();
+ }, 1000 * 5); // reload every 5 seconds
+
+ return () => clearInterval(interval);
+ });
+
+ const getCommunications = () => {
+ if (state.client) {
+ // try to read communications from FHIR server
+ state.client
+ .request(`Communication?recipient=${props.token?.userId}`, {
+ graph: false,
+ flat: true
+ })
+ .then(bundle => {
+ loadCommunications(bundle);
+ });
+ }
+ };
+
+ const deleteCommunication = id => {
+ debugLog('deleteCommunication: ' + id);
+ if (id) {
+ state.client.delete(`Communication/${id}`).then(() => {
+ debugLog(`Deleted communication: ${id}`);
+ getCommunications();
+ });
+ }
+ };
+
+ const loadCommunications = bundle => {
+ let count = bundle.length;
+ setState(prevState => ({ ...prevState, communicationCount: count, communications: bundle }));
+ };
+
+ const handleClose = () => {
+ 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
+ }));
+
+ const renderCommunications = () => {
+ return (
+
+ {state.communications.map(communication => {
+ return (
+
+ -
+
+
+
+ );
+ })}
+
+ );
+ };
+
+ return (
+
+ {
+ setState(prevState => ({ ...prevState, open: true, initialLoad: true }));
+ }}
+ >
+
+
+
+
+
+
+ );
+};
+
+export default CommunicationsDialog;
diff --git a/src/components/RequestDashboard/Home.jsx b/src/components/RequestDashboard/Home.jsx
index da8a9b0..ba322ec 100644
--- a/src/components/RequestDashboard/Home.jsx
+++ b/src/components/RequestDashboard/Home.jsx
@@ -6,6 +6,7 @@ import SettingsIcon from '@mui/icons-material/Settings';
import AccountBoxIcon from '@mui/icons-material/AccountBox';
import MedicalServicesIcon from '@mui/icons-material/MedicalServices';
+import CommunicationsDialog from './CommunicationsDialog';
import useStyles from './styles';
import PatientSection from './PatientSection';
import SettingsSection from './SettingsSection';
@@ -82,8 +83,10 @@ const Home = props => {
{/* spacer */}
{/** */}
{section ? (
-
+
+
+
{token.name}