diff --git a/src/components/ConsoleBox/ConsoleBox.js b/src/components/ConsoleBox/ConsoleBox.js
deleted file mode 100644
index 056f7226..00000000
--- a/src/components/ConsoleBox/ConsoleBox.js
+++ /dev/null
@@ -1,69 +0,0 @@
-import { Button } from '@mui/material';
-import React, { Component } from 'react';
-
-export default class ConsoleBox extends Component {
- constructor(props) {
- super(props);
- this.state = {
- showStatus: 'hideConsole',
- headerStatus: 'collapseHeader'
- };
-
- this.toggleConsole = this.toggleConsole.bind(this);
- }
-
- handleAddition = (e, { value }) => {
- this.setState({
- options: [{ text: value, value }, ...this.state.options]
- });
- };
-
- handleChange = (e, { value }) => {
- this.props.updateCB(this.props.elementName, value);
- this.setState({ currentValue: value });
- };
-
- toggleConsole() {
- if (this.state.showStatus === 'showConsole') {
- this.setState({ showStatus: 'hideConsole' });
- this.setState({ headerStatus: 'collapseHeader' });
- } else {
- this.setState({ showStatus: 'showConsole' });
- this.setState({ headerStatus: 'showHeader' });
- }
- }
-
- render() {
- try {
- var objDiv = document.getElementById('your_div');
- if (objDiv) {
- objDiv.scrollTop = objDiv.scrollHeight;
- }
- } catch (error) {
- console.log('Encountered error', error);
- }
- let i = 0;
- return (
-
- Code: {this.state.code ? this.state.code : this.emptyField}
+ Code: {this.props.code ? this.props.code : this.emptyField}
- System: {this.state.codeSystem ? shortNameMap[this.state.codeSystem] : this.emptyField}
+ System: {this.props.codeSystem ? shortNameMap[this.props.codeSystem] : this.emptyField}
- Display: {this.state.display ? this.state.display : this.emptyField}
+ Display: {this.props.display ? this.props.display : this.emptyField}
);
}
renderPrefetchedResources() {
- const prefetchMap = new Map(Object.entries(this.state.prefetchedResources));
+ const prefetchMap = new Map(Object.entries(this.props.prefetchedResources));
if (prefetchMap.size > 0) {
return this.renderRequestResources(prefetchMap);
}
@@ -305,7 +230,7 @@ export default class RequestBox extends Component {
launchSmartOnFhirApp = () => {
console.log('Launch SMART on FHIR App');
- let userId = this.state.prefetchedResources?.practitioner?.id;
+ let userId = this.props.prefetchedResources?.practitioner?.id;
if (!userId) {
console.log(
'Practitioner not populated from prefetch, using default from config: ' +
@@ -315,12 +240,12 @@ export default class RequestBox extends Component {
}
let link = {
- appContext: 'user=' + userId + '&patient=' + this.state.patient.id,
+ appContext: 'user=' + userId + '&patient=' + this.props.patient.id,
type: 'smart',
url: this.props.smartAppUrl
};
- retrieveLaunchContext(link, this.state.patient.id, this.props.client.state).then(result => {
+ retrieveLaunchContext(link, this.props.patient.id, this.props.client.state).then(result => {
link = result;
console.log(link);
// launch the application in a new window
@@ -346,10 +271,10 @@ export default class RequestBox extends Component {
response = undefined;
if (!this.isOrderNotSelected()) {
- if (Object.keys(this.state.request).length > 0) {
- order = `${this.state.request.resourceType}/${this.state.request.id}`;
- if (this.state.request.insurance && this.state.request.insurance.length > 0) {
- coverage = `${this.state.request.insurance[0].reference}`;
+ if (Object.keys(this.props.request).length > 0) {
+ order = `${this.props.request.resourceType}/${this.props.request.id}`;
+ if (this.props.request.insurance && this.props.request.insurance.length > 0) {
+ coverage = `${this.props.request.insurance[0].reference}`;
}
}
}
@@ -362,8 +287,8 @@ export default class RequestBox extends Component {
}
}
- if (Object.keys(this.state.response).length > 0) {
- response = `QuestionnaireResponse/${this.state.response.id}`;
+ if (Object.keys(this.props.response).length > 0) {
+ response = `QuestionnaireResponse/${this.props.response.id}`;
}
if (order && response) {
@@ -380,7 +305,7 @@ export default class RequestBox extends Component {
let linkCopy = Object.assign({}, link);
- return retrieveLaunchContext(linkCopy, this.state.patient.id, this.props.client.state).then(
+ return retrieveLaunchContext(linkCopy, this.props.patient.id, this.props.client.state).then(
result => {
linkCopy = result;
return linkCopy;
@@ -396,9 +321,9 @@ export default class RequestBox extends Component {
// build the NewRx Message
var newRx = buildNewRxRequest(
- this.state.prefetchedResources.patient,
- this.state.prefetchedResources.practitioner,
- this.state.request
+ this.props.prefetchedResources.patient,
+ this.props.prefetchedResources.practitioner,
+ this.props.request
);
console.log('Prepared NewRx:');
@@ -428,11 +353,11 @@ export default class RequestBox extends Component {
};
isOrderNotSelected() {
- return Object.keys(this.state.request).length === 0;
+ return Object.keys(this.props.request).length === 0;
}
isPatientNotSelected() {
- return Object.keys(this.state.patient).length === 0;
+ return Object.keys(this.props.patient).length === 0;
}
// SnackBar
@@ -448,69 +373,39 @@ export default class RequestBox extends Component {
const { open } = this.state;
return (
-
-
-
- {/* Patient selection pop up and search */}
-
- {this.state.patientList instanceof Error
- ? this.renderError()
- : }
-
-
-
-
}>
- Select a patient
-
-
- {this.state.patient.id ? (
- Patient ID: {this.state.patient.id}
- ) : (
- No patient selected
- )}
-
-
- {this.renderPatientInfo()}
- {this.renderPrefetchedResources()}
-
+ { this.props.patient.id ? (
+
+
+
+ Patient ID: {this.props.patient.id}
+
+
+ {this.renderPatientInfo()}
+ {this.renderPrefetchedResources()}
+
+
+
+
+
+
+
+
+
+
-
- {this.state.patient.id ? (
-
-
-
-
-
-
-
-
+ )}
+
-
- ) : (
-
- )}
);
}
diff --git a/src/components/RequestBox/request.css b/src/components/RequestBox/request.css
index 2da628c9..14b6aedd 100644
--- a/src/components/RequestBox/request.css
+++ b/src/components/RequestBox/request.css
@@ -12,10 +12,10 @@
.request {
border: 1px solid black;
- height:375px;
+ height: auto;
padding: 10px;
border-radius: 5px;
- background-color: rgb(248, 248, 248)
+ background-color: rgb(248, 248, 248);
}
.select-button{
@@ -123,4 +123,8 @@
.empty-field {
color: dimgrey;
font-style: italic;
+}
+
+.patient-info {
+ margin: 5px;
}
\ No newline at end of file
diff --git a/src/components/SMARTBox/PatientBox.js b/src/components/SMARTBox/PatientBox.js
index af8001ff..ea337028 100644
--- a/src/components/SMARTBox/PatientBox.js
+++ b/src/components/SMARTBox/PatientBox.js
@@ -118,7 +118,7 @@ export default class PatientBox extends Component {
updateValues(patient) {
this.props.callback('patient', patient);
- this.props.callback('openPatient', false);
+ this.props.callback('expanded', false);
this.props.clearCallback();
if (this.state.request) {
const request = JSON.parse(this.state.request);
@@ -134,6 +134,10 @@ export default class PatientBox extends Component {
}
} else {
this.updatePrefetchRequest(null, patient, this.props.defaultUser);
+ this.props.callback('request', {});
+ this.props.callback('code', null);
+ this.props.callback('codeSystem', null);
+ this.props.callback('display', null);
}
if (this.state.response) {
@@ -323,7 +327,6 @@ export default class PatientBox extends Component {
}
getRequests() {
- console.log(this.props.client);
const patientId = this.props.patient.id;
this.getDeviceRequest(patientId);
this.getServiceRequest(patientId);
diff --git a/src/components/SMARTBox/smart.css b/src/components/SMARTBox/smart.css
index 69043330..243de77e 100644
--- a/src/components/SMARTBox/smart.css
+++ b/src/components/SMARTBox/smart.css
@@ -86,6 +86,7 @@ html{
.select-btn {
height: 40px;
align-self: center;
+ margin-top: 25px !important;
}
.emptyForm {
diff --git a/src/containers/RequestBuilder.js b/src/containers/RequestBuilder.js
index 777538cd..f6eed7b8 100644
--- a/src/containers/RequestBuilder.js
+++ b/src/containers/RequestBuilder.js
@@ -1,16 +1,23 @@
import React, { Component } from 'react';
-
+import { Button, Box, IconButton } from '@mui/material';
+import PersonIcon from '@mui/icons-material/Person';
+import RefreshIcon from '@mui/icons-material/Refresh';
import DisplayBox from '../components/DisplayBox/DisplayBox';
-import ConsoleBox from '../components/ConsoleBox/ConsoleBox';
import '../index.css';
-import '../components/ConsoleBox/consoleBox.css';
import SettingsBox from '../components/SettingsBox/SettingsBox';
import RequestBox from '../components/RequestBox/RequestBox';
import buildRequest from '../util/buildRequest.js';
-import { types } from '../util/data.js';
-import { createJwt } from '../util/auth';
+import { types, defaultValues } from '../util/data.js';
+import { createJwt, setupKeys } from '../util/auth';
+
import env from 'env-var';
import FHIR from 'fhirclient';
+import Accordion from '@mui/material/Accordion';
+import AccordionSummary from '@mui/material/AccordionSummary';
+import AccordionDetails from '@mui/material/AccordionDetails';
+import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
+
+import PatientSearchBar from '../components/RequestBox/PatientSearchBar/PatientSearchBar';
export default class RequestBuilder extends Component {
constructor(props) {
@@ -18,11 +25,19 @@ export default class RequestBuilder extends Component {
this.state = {
loading: false,
logs: [],
- patient: {},
+ patient: {},
+ expanded: false,
+ patientList: [],
response: null,
+ code: null,
+ codeSystem: null,
+ display: null,
+ prefetchedResources: new Map(),
+ request: {},
showSettings: false,
token: null,
client: this.props.client,
+ codeValues: defaultValues,
// Configurable values
alternativeTherapy: env.get('REACT_APP_ALT_DRUG').asBool(),
baseUrl: env.get('REACT_APP_EHR_BASE').asString(),
@@ -57,6 +72,8 @@ export default class RequestBuilder extends Component {
if (!this.state.client) {
this.reconnectEhr();
} else {
+ // Call patients on load of page
+ this.getPatients();
this.setState({ baseUrl: this.state.client.state.serverUrl });
this.setState({ ehrUrl: this.state.client.state.serverUrl });
}
@@ -84,8 +101,15 @@ export default class RequestBuilder extends Component {
updateStateElement = (elementName, text) => {
this.setState({ [elementName]: text });
+ // if the patientFhirQuery is updated, make a call to get the patients
+ if (elementName === 'patientFhirQuery') {
+ setTimeout(() => {
+ this.getPatients();
+ }, 1000);
+ }
};
+
timeout = time => {
let controller = new AbortController();
setTimeout(() => controller.abort(), time * 1000);
@@ -177,6 +201,48 @@ export default class RequestBuilder extends Component {
this.requestBox.current.replaceRequestAndSubmit(resource);
}
+ getPatients = () => {
+ this.props.client
+ .request(this.state.patientFhirQuery, { flat: true })
+ .then(result => {
+ this.setState({
+ patientList: result,
+ });
+ })
+ .catch(e => {
+ this.setState({
+ patientList: e
+ });
+ });
+ };
+
+ updateStateList = (elementName, text) => {
+ this.setState(prevState => {
+ return { [elementName]: [...prevState[elementName], text] };
+ });
+ };
+
+ updateStateMap = (elementName, key, text) => {
+ this.setState(prevState => {
+ if (!prevState[elementName][key]) {
+ prevState[elementName][key] = [];
+ }
+ return { [elementName]: { ...prevState[elementName], [key]: text } };
+ });
+ };
+
+ clearState = () => {
+ this.setState({
+ prefetchedResources: new Map(),
+ practitioner: {},
+ coverage: {},
+ response: {}
+ });
+ };
+ handleChange = () => (event, isExpanded) => {
+ this.setState({ expanded: isExpanded ? true: false});
+ };
+
render() {
return (
@@ -198,15 +264,66 @@ export default class RequestBuilder extends Component {
Reconnect EHR
-
-
+
+ {/* */}
{this.state.showSettings && (
-
- )}
+
+
+
+ )}
+
+
+
+ }
+ aria-controls="panel1a-content"
+ id="panel1a-header"
+ style={{marginLeft: '45%'}}
+ >
+ }>
+ Select a patient
+
+
+
+ {this.state.patientList.length > 0 && this.state.expanded ?
+
+
+ {this.state.patientList instanceof Error
+ ? this.renderError()
+ : }
+
+
+ :
+ }
+
+
+
+
this.getPatients()}
+ size="large"
+ >
+
+
+
+
{/*for the ehr launch */}
-
-
-
-
-
-
diff --git a/src/index.css b/src/index.css
index 5ab4fed4..19229868 100644
--- a/src/index.css
+++ b/src/index.css
@@ -15,8 +15,6 @@ body {
box-shadow: none;
}
-
-
.floating-label {
position: absolute;
pointer-events: none;
@@ -307,11 +305,12 @@ input:not(:focus):not([value=""]):valid ~ .floating-label{
}
.nav-header{
- margin-bottom: 10px;
- height: 55px;
- padding:10px;
- border-bottom: 1px solid black;
- background-color: #005B94;
+ margin-bottom: 10px;
+ display: flow;
+ height: 55px;
+ padding:10px;
+ border-bottom: 1px solid black;
+ background-color: #005B94;
}
.loading{
@@ -325,4 +324,9 @@ input:not(:focus):not([value=""]):valid ~ .floating-label{
.title {
margin-bottom: 65px;
+}
+
+.settings-box {
+ width: 50%;
+ margin-left: 20px;
}
\ No newline at end of file