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
100 changes: 42 additions & 58 deletions src/containers/RequestBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import '../index.css';
import SettingsBox from '../components/SettingsBox/SettingsBox';
import RequestBox from '../components/RequestBox/RequestBox';
import buildRequest from '../util/buildRequest.js';
import { types, defaultValues } from '../util/data.js';
import { types, defaultValues, headerDefinitions } from '../util/data.js';
import { createJwt, setupKeys } from '../util/auth';

import env from 'env-var';
Expand All @@ -25,7 +25,7 @@ export default class RequestBuilder extends Component {
this.state = {
loading: false,
logs: [],
patient: {},
patient: {},
expanded: false,
patientList: [],
response: null,
Expand All @@ -38,26 +38,6 @@ export default class RequestBuilder extends Component {
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(),
cdsUrl: env.get('REACT_APP_CDS_SERVICE').asString(),
defaultUser: env.get('REACT_APP_DEFAULT_USER').asString(),
ehrUrl: env.get('REACT_APP_EHR_SERVER').asString(),
ehrUrlSentToRemsAdminForPreFetch: env
.get('REACT_APP_EHR_SERVER_TO_BE_SENT_TO_REMS_ADMIN_FOR_PREFETCH')
.asString(),
generateJsonToken: env.get('REACT_APP_GENERATE_JWT').asBool(),
includeConfig: true,
launchUrl: env.get('REACT_APP_LAUNCH_URL').asString(),
orderSelect: env.get('REACT_APP_ORDER_SELECT').asString(),
orderSign: env.get('REACT_APP_ORDER_SIGN').asString(),
patientFhirQuery: env.get('REACT_APP_PATIENT_FHIR_QUERY').asString(),
patientView: env.get('REACT_APP_PATIENT_VIEW').asString(),
pimsUrl: env.get('REACT_APP_PIMS_SERVER').asString(),
responseExpirationDays: env.get('REACT_APP_RESPONSE_EXPIRATION_DAYS').asInt(),
sendPrefetch: true,
smartAppUrl: env.get('REACT_APP_SMART_LAUNCH_URL').asString()
};

this.updateStateElement = this.updateStateElement.bind(this);
Expand All @@ -69,12 +49,16 @@ export default class RequestBuilder extends Component {
}

componentDidMount() {
// init settings
Object.keys(headerDefinitions).map((key) => {
this.setState({ [key]: headerDefinitions[key].default });
});
// load settings
JSON.parse(localStorage.getItem('reqgenSettings') || '[]').forEach((element) => {
try {
this.setState({[element[0]]: element[1]});
this.setState({ [element[0]]: element[1] });
} catch {
if(element[0]){
if (element[0]) {
console.log('Could not load setting:' + element[0]);
}
}
Expand Down Expand Up @@ -251,7 +235,7 @@ export default class RequestBuilder extends Component {
});
};
handleChange = () => (event, isExpanded) => {
this.setState({ expanded: isExpanded ? true: false});
this.setState({ expanded: isExpanded ? true : false });
};

render() {
Expand All @@ -276,23 +260,23 @@ export default class RequestBuilder extends Component {
</button>
</div>
<div>
<Modal open = {this.state.showSettings} onClose = {()=>{this.setState({showSettings:false});}} >
<div className = 'settings-box'>
<Modal open={this.state.showSettings} onClose={() => { this.setState({ showSettings: false }); }} >
<div className='settings-box'>
<SettingsBox
state={this.state}
consoleLog={this.consoleLog}
updateCB={this.updateStateElement}
/>
/>
</div>
</Modal>
</div>
<div style={{display: 'flex'}}>
<Accordion style={{width: '95%'}} expanded={this.state.expanded} onChange={this.handleChange()}>
<AccordionSummary
<div style={{ display: 'flex' }}>
<Accordion style={{ width: '95%' }} expanded={this.state.expanded} onChange={this.handleChange()}>
<AccordionSummary
expandIcon={<ExpandMoreIcon />}
aria-controls="panel1a-content"
id="panel1a-header"
style={{marginLeft: '45%'}}
style={{ marginLeft: '45%' }}
>
<Button variant="contained" startIcon={<PersonIcon />}>
Select a patient
Expand All @@ -302,37 +286,37 @@ export default class RequestBuilder extends Component {
{this.state.patientList.length > 0 && this.state.expanded ?
<div>
<Box>
{this.state.patientList instanceof Error
? this.renderError()
: <PatientSearchBar
getPatients = {this.getPatients}
searchablePatients={this.state.patientList}
client={this.props.client}
callback={this.updateStateElement}
callbackList={this.updateStateList}
callbackMap={this.updateStateMap}
// updatePrefetchCallback={PrefetchTemplate.generateQueries}
clearCallback={this.clearState}
ehrUrl={this.state.ehrUrl} // is this used?
options={this.state.codeValues}
responseExpirationDays={this.state.responseExpirationDays}
defaultUser={this.state.defaultUser}
/>}
{this.state.patientList instanceof Error
? this.renderError()
: <PatientSearchBar
getPatients={this.getPatients}
searchablePatients={this.state.patientList}
client={this.props.client}
callback={this.updateStateElement}
callbackList={this.updateStateList}
callbackMap={this.updateStateMap}
// updatePrefetchCallback={PrefetchTemplate.generateQueries}
clearCallback={this.clearState}
ehrUrl={this.state.ehrUrl} // is this used?
options={this.state.codeValues}
responseExpirationDays={this.state.responseExpirationDays}
defaultUser={this.state.defaultUser}
/>}
</Box>
</div>
: <span></span>
}

</AccordionDetails>
</Accordion>
<IconButton
color="primary"
onClick={() => this.getPatients()}
size="large"
>
<RefreshIcon fontSize="large" />
</IconButton>
</div>
</Accordion>
<IconButton
color="primary"
onClick={() => this.getPatients()}
size="large"
>
<RefreshIcon fontSize="large" />
</IconButton>
</div>
<div className="form-group container left-form">
<div>
{/*for the ehr launch */}
Expand Down
55 changes: 38 additions & 17 deletions src/util/data.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,92 @@
import env from 'env-var';

const headerDefinitions = {
alternativeTherapy: {
display: 'Alternative Therapy Cards Allowed',
type: 'check'
type: 'check',
default: env.get('REACT_APP_ALT_DRUG').asBool()
},
baseUrl: {
display: 'Base Server',
type: 'input'
type: 'input',
default: env.get('REACT_APP_EHR_BASE').asString()
},
cdsUrl: {
display: 'REMS Admin',
type: 'input'
type: 'input',
default: env.get('REACT_APP_CDS_SERVICE').asString()
},
defaultUser: {
display: 'Default User',
type: 'input'
type: 'input',
default: env.get('REACT_APP_DEFAULT_USER').asString()
},
ehrUrl: {
display: 'EHR Server',
type: 'input'
type: 'input',
default: env.get('REACT_APP_EHR_SERVER').asString()
},
ehrUrlSentToRemsAdminForPreFetch: {
display: 'EHR Server Sent to REMS Admin for Prefetch',
type: 'input'
type: 'input',
default: env
.get('REACT_APP_EHR_SERVER_TO_BE_SENT_TO_REMS_ADMIN_FOR_PREFETCH')
.asString()
},
generateJsonToken: {
display: 'Generate JSON Web Token',
type: 'check'
type: 'check',
default: env.get('REACT_APP_GENERATE_JWT').asBool()
},
includeConfig: {
display: 'Include Configuration in CRD Request',
type: 'check'
type: 'check',
default: true
},
launchUrl: {
display: 'DTR Launch URL (QuestionnaireForm)',
type: 'input'
type: 'input',
default: env.get('REACT_APP_LAUNCH_URL').asString()
},
orderSelect: {
display: 'Order Select Rest End Point',
type: 'input'
type: 'input',
default: env.get('REACT_APP_ORDER_SELECT').asString()
},
orderSign: {
display: 'Order Sign Rest End Point',
type: 'input'
type: 'input',
default: env.get('REACT_APP_ORDER_SIGN').asString()
},
patientFhirQuery: {
display: 'Patient FHIR Query',
type: 'input'
type: 'input',
default: env.get('REACT_APP_PATIENT_FHIR_QUERY').asString()
},
patientView: {
display: 'Patient View Rest End Point',
type: 'input'
type: 'input',
default: env.get('REACT_APP_PATIENT_VIEW').asString()
},
pimsUrl: {
display: 'PIMS Server',
type: 'input'
type: 'input',
default: env.get('REACT_APP_PIMS_SERVER').asString()
},
responseExpirationDays: {
display: 'In Progress Form Expiration Days',
type: 'input'
type: 'input',
default: env.get('REACT_APP_RESPONSE_EXPIRATION_DAYS').asInt()
},
sendPrefetch: {
display: 'Send Prefetch',
type: 'check'
type: 'check',
default: true
},
smartAppUrl: {
display: 'SMART App',
type: 'input'
type: 'input',
default: env.get('REACT_APP_SMART_LAUNCH_URL').asString()
}
};

Expand Down