Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using serverUrl from state variable #100

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 6 additions & 4 deletions frontend/src/components/Patient.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ moment.locale('nb'); // Set calendar to be norwegian (bokmaal)

const axios = require('axios');

const QUESTIONNAIRE_ID = 235237;

const QUESTIONNAIRE_ID = 235237; // This should be parameter from EHR

function PatientName({ name = [] }) {
/*
Expand Down Expand Up @@ -89,7 +90,8 @@ export default class Patient extends React.Component {
If they exists, freetext, startDate and endDate are also loaded
*/
const fhirclient = this.context.client;
fhirclient.request(`http://launch.smarthealthit.org/v/r3/fhir/QuestionnaireResponse/_search?questionnaire=${QUESTIONNAIRE_ID}&patient=${fhirclient.patient.id}&status=in-progress`)

fhirclient.request(`${fhirclient.state.serverUrl}/QuestionnaireResponse/_search?questionnaire=${QUESTIONNAIRE_ID}&patient=${fhirclient.patient.id}&status=in-progress`)
.then((result) => {
if (result.total === 0) { return; }
this.setState({ responseID: result.entry[0].resource.id });
Expand Down Expand Up @@ -155,7 +157,7 @@ export default class Patient extends React.Component {
// Patient has no existing QuestionnairyResponse and a new one is created
if (this.state.responseID === null) {
options = {
url: 'http://launch.smarthealthit.org/v/r3/fhir/QuestionnaireResponse',
url: `${fhirclient.state.serverUrl}/QuestionnaireResponse`,
body: JSON.stringify(filledResponse),
headers,
method: 'POST',
Expand All @@ -164,7 +166,7 @@ export default class Patient extends React.Component {
// Patient has previously excisting QuestionnairyResponse
filledResponse.id = this.state.responseID;
options = {
url: `http://launch.smarthealthit.org/v/r3/fhir/QuestionnaireResponse/${this.state.responseID}`,
url: `${fhirclient.state.serverUrl}/QuestionnaireResponse/${this.state.responseID}`,
body: JSON.stringify(filledResponse),
headers,
method: 'PUT',
Expand Down