Skip to content

Commit

Permalink
Added env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
ELiuHub committed Sep 28, 2022
1 parent 6dc4fda commit f294afa
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions amplify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ frontend:
- npm ci
build:
commands:
- echo "REACT_APP_EHR_ENDPOINT=$REACT_APP_EHR_ENDPOINT" >> .env
- echo "REACT_APP_EHR_CLIENT_ID=$REACT_APP_EHR_CLIENT_ID" >> .env
- npm run build
artifacts:
baseDirectory: build
Expand Down
8 changes: 4 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Navbar from './Components/navbar';
import Form from './Pages/form';
import Upload from './Pages/upload';
import Admin from './Pages/admin';
import Navbar from './components/navbar';
import Form from './pages/form';
import Upload from './pages/upload';
import Admin from './pages/admin';
import { Routes, Route } from 'react-router-dom'
import { Amplify } from 'aws-amplify';
import { withAuthenticator } from '@aws-amplify/ui-react';
Expand Down
4 changes: 2 additions & 2 deletions src/Pages/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function Form(props) {
const [version, setVersion] = useState();
const [formVersion, setFormVersion] = useState(1);

const baseEndpoint = 'http://localhost:4004/hapi-fhir-jpaserver/fhir/Questionnaire/';
const baseEndpoint = process.env.REACT_APP_EHR_ENDPOINT + '/Questionnaire/';

useEffect(() => {
fetchForms();
Expand Down Expand Up @@ -128,7 +128,7 @@ function Form(props) {
}

async function httpRequest(requestMethod, responseID) {
let qrEndpoint = 'http://localhost:4004/hapi-fhir-jpaserver/fhir/QuestionnaireResponse';
let qrEndpoint = process.env.REACT_APP_EHR_ENDPOINT + '/QuestionnaireResponse';
let formID = await getFormID()

if (requestMethod === 'post') {
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function Upload(props) {
const [availableForms, setAvailableForms] = useState([]);
const [selectedForm, setSelectedForm] = useState('');

const endpoint = 'http://localhost:4004/hapi-fhir-jpaserver/fhir/Questionnaire';
const endpoint = process.env.REACT_APP_EHR_ENDPOINT + '/Questionnaire';

useEffect(() => {
async function existingForms() {
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import FHIR from 'fhirclient';
import reportWebVitals from './reportWebVitals';

const root = ReactDOM.createRoot(document.getElementById('root'));
const ehrClientID = process.env.REACT_APP_EHR_CLIENT_ID

const smartFhirLaunch = () => {
FHIR.oauth2.init({
clientId: 'b1c89b87-db4f-440a-8e5e-2e3dd8e43992',
clientId: ehrClientID,
scope: 'launch patient/Patient.read patient/Questionnaire.read patient/Questionnaire.write patient/QuestionnaireResponse.read patient/QuestionnaireResponse.write openid profile online_access'
})
.then(client => {
Expand Down

0 comments on commit f294afa

Please sign in to comment.