From 5e1f12a2d4f2b119ec853827e3522c99747fb400 Mon Sep 17 00:00:00 2001 From: Zach Robin Date: Sun, 7 Jan 2024 20:46:58 -0800 Subject: [PATCH 1/2] Updated Console Log and comments For RxStatus --- src/components/RequestBox/RequestBox.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/components/RequestBox/RequestBox.js b/src/components/RequestBox/RequestBox.js index 35deb168..48cd1add 100644 --- a/src/components/RequestBox/RequestBox.js +++ b/src/components/RequestBox/RequestBox.js @@ -386,10 +386,10 @@ export default class RequestBox extends Component { } /** - * Send the NewRxRequestMessage to the Pharmacy Information System (PIMS) + * Send NewRx for new Medication to the Pharmacy Information System (PIMS) */ sendRx = e => { - console.log('sendRx: ' + this.props.pimsUrl); + console.log('Sending NewRx to: ' + this.props.pimsUrl); // build the NewRx Message var newRx = buildNewRxRequest( @@ -397,11 +397,13 @@ export default class RequestBox extends Component { this.state.prefetchedResources.practitioner, this.state.request ); + + console.log('Prepared NewRx:'); console.log(newRx); + const serializer = new XMLSerializer(); - // send the message to the Pharmacy - this.props.consoleLog('Sending Rx to PIMS', types.info); + // Sending NewRx to the Pharmacy fetch(this.props.pimsUrl, { method: 'POST', //mode: 'no-cors', @@ -412,14 +414,11 @@ export default class RequestBox extends Component { body: serializer.serializeToString(newRx) }) .then(response => { - console.log('sendRx response: '); + console.log('Successfully sent NewRx to PIMS'); console.log(response); - this.props.consoleLog('Successfully sent Rx to PIMS', types.info); }) .catch(error => { - console.log('sendRx error: '); - this.props.consoleLog('Server returned error sending Rx to PIMS: ', types.error); - this.props.consoleLog(error.message); + console.log('sendRx Error - unable to send NewRx to PIMS: '); console.log(error); }); }; @@ -451,7 +450,7 @@ export default class RequestBox extends Component { {this.state.patientList instanceof Error ? this.renderError() : Date: Mon, 8 Jan 2024 01:26:15 -0800 Subject: [PATCH 2/2] snackbar notification added --- src/components/RequestBox/RequestBox.js | 35 ++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/components/RequestBox/RequestBox.js b/src/components/RequestBox/RequestBox.js index 48cd1add..723e9a9b 100644 --- a/src/components/RequestBox/RequestBox.js +++ b/src/components/RequestBox/RequestBox.js @@ -1,13 +1,15 @@ import PersonIcon from '@mui/icons-material/Person'; import { Box, Button, ButtonGroup, Modal } from '@mui/material'; +import MuiAlert from '@mui/material/Alert'; +import Snackbar from '@mui/material/Snackbar'; import _ from 'lodash'; import React, { Component } from 'react'; import buildNewRxRequest from '../../util/buildScript.2017071.js'; -import { defaultValues, shortNameMap, types } from '../../util/data'; +import { defaultValues, shortNameMap } from '../../util/data'; import { getAge } from '../../util/fhir'; import { retrieveLaunchContext } from '../../util/util'; -import './request.css'; import InProgressFormBox from './InProgressFormBox/InProgressFormBox.js'; +import './request.css'; import PatientSearchBar from './PatientSearchBar/PatientSearchBar.js'; @@ -42,7 +44,8 @@ export default class RequestBox extends Component { display: null, request: {}, gatherCount: 0, - response: {} + response: {}, + open: false }; this.renderRequestResources = this.renderRequestResources.bind(this); @@ -416,6 +419,7 @@ export default class RequestBox extends Component { .then(response => { console.log('Successfully sent NewRx to PIMS'); console.log(response); + this.handleRxResponse(); }) .catch(error => { console.log('sendRx Error - unable to send NewRx to PIMS: '); @@ -431,10 +435,17 @@ export default class RequestBox extends Component { return Object.keys(this.state.patient).length === 0; } + // SnackBar + handleRxResponse = () => this.setState({ open: true }); + + handleClose = () => this.setState({ open: false }); + + render() { const disableSendToCRD = this.isOrderNotSelected() || this.props.loading; const disableSendRx = this.isOrderNotSelected() || this.props.loading; const disableLaunchSmartOnFhir = this.isPatientNotSelected(); + const { open } = this.state; return (
@@ -499,6 +510,24 @@ export default class RequestBox extends Component { Sign Order + + + Success! NewRx Recieved By Pharmacy + +
) : (