From a747a13bb94b7ac1eadf4e962ff1147d42fdf90c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thor=20Stenb=C3=A6k?= Date: Tue, 27 Oct 2020 14:54:22 +0100 Subject: [PATCH 1/2] Using serverUrl from state variable --- frontend/src/components/Patient.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Patient.js b/frontend/src/components/Patient.js index 0496480..51ea365 100644 --- a/frontend/src/components/Patient.js +++ b/frontend/src/components/Patient.js @@ -18,7 +18,7 @@ moment.locale('nb'); // Set calendar to be norwegian (bokmaal) const axios = require('axios'); -const QUESTIONNAIRE_ID = 235192; +const QUESTIONNAIRE_ID = 235192; //This should be parameter from EHR function PatientName({ name = [] }) { const entry = name.find((nameRecord) => nameRecord.use === 'official') || name[0]; @@ -79,7 +79,8 @@ export default class Patient extends React.Component { formData = () => { 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 }); @@ -137,7 +138,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', @@ -146,7 +147,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', From 691c7cac34bbb7b36d90cb4077dec856acc12794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thor=20Stenb=C3=A6k?= Date: Fri, 30 Oct 2020 20:25:00 +0100 Subject: [PATCH 2/2] Removed code style errors --- frontend/src/components/Patient.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Patient.js b/frontend/src/components/Patient.js index 51ea365..619e9c1 100644 --- a/frontend/src/components/Patient.js +++ b/frontend/src/components/Patient.js @@ -18,7 +18,7 @@ moment.locale('nb'); // Set calendar to be norwegian (bokmaal) const axios = require('axios'); -const QUESTIONNAIRE_ID = 235192; //This should be parameter from EHR +const QUESTIONNAIRE_ID = 235192; // This should be parameter from EHR function PatientName({ name = [] }) { const entry = name.find((nameRecord) => nameRecord.use === 'official') || name[0]; @@ -79,7 +79,7 @@ export default class Patient extends React.Component { formData = () => { const fhirclient = this.context.client; - + fhirclient.request(`${fhirclient.state.serverUrl}/QuestionnaireResponse/_search?questionnaire=${QUESTIONNAIRE_ID}&patient=${fhirclient.patient.id}&status=in-progress`) .then((result) => { if (result.total === 0) { return; }