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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ REACT_APP_GENERATE_JWT = true
REACT_APP_ORDER_SIGN = rems-order-sign
REACT_APP_ORDER_SELECT = rems-order-select
REACT_APP_PATIENT_VIEW = rems-patient-view
REACT_APP_PATIENT_FHIR_QUERY = Patient?_sort=identifier&_count=12
REACT_APP_USER = alice
REACT_APP_PASSWORD = alice
REACT_APP_PUBLIC_KEYS = http://localhost:3001/public_keys
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ Following are a list of modifiable paths:
| REACT_APP_EHR_LINK | `http://localhost:8080/ehr-server/` |
| HTTPS | `false` |
| HTTPS_KEY_PATH | `server.key` |
| HTTPS_CERT_PATH | `server.cert` |
| HTTPS_CERT_PATH | `server.cert` |
| REACT_APP_PATIENT_FHIR_QUERY | `Patient?_sort=identifier&_count=12` |
9 changes: 5 additions & 4 deletions src/components/RequestBox/RequestBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,14 @@ export default class RequestBox extends Component {
};

getPatients = () => {
//passes and sets patients when the "select patient is clicked"
this.setState({ openPatient: true });


this.props.client
.request('Patient?_sort=identifier&_count=12', { flat: true })
.request(this.props.patientFhirQuery, { flat: true })
.then(result => {
this.setState({
patientList: result
patientList: result,
openPatient: true
});
})
.catch(e => {
Expand Down
62 changes: 32 additions & 30 deletions src/components/SMARTBox/PatientBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class PatientBox extends Component {
componentDidMount() {
// get requests and responses on open of patients
this.getRequests();
this.getResponses();
this.getResponses(); // TODO: PatientBox should not be rendering itself, needs to recieve its state from parent
}

getCoding(resource) {
Expand Down Expand Up @@ -250,26 +250,26 @@ export default class PatientBox extends Component {
// find the matching medication in the references
const medication = result?.references?.[medicationReference];
if (medication) {
const code = medication?.code?.coding?.[0];

if (code) {
// add the reference as a contained resource to the request
if (!e?.contained) {
e.contained = [];
e.contained.push(medication);
} else {
// only add to contained if not already in there
let found = false;
e?.contained.forEach(c => {
if (c.id === medication.id) {
found = true;
}
});
if (!found) {
e?.contained.push(medication);
const code = medication?.code?.coding?.[0];

if (code) {
// add the reference as a contained resource to the request
if (!e?.contained) {
e.contained = [];
e.contained.push(medication);
} else {
// only add to contained if not already in there
let found = false;
e?.contained.forEach(c => {
if (c.id === medication.id) {
found = true;
}
});
if (!found) {
e?.contained.push(medication);
}
}
}
}
}
});
Expand Down Expand Up @@ -359,19 +359,21 @@ export default class PatientBox extends Component {

getQuestionnaireTitles() {
const promises = [];
if (this.state.questionnaireResponses.data.length > 0) {
for (const canonical of this.state.questionnaireResponses.data.map(
questionnaireResponse => questionnaireResponse.questionnaire
)) {
promises.push(
this.props.client
.request(canonical)
.then(questionnaire => [canonical, questionnaire.title || canonical])
);
if (this.state.questionnaireResponses.data) {
if (this.state.questionnaireResponses.data.length > 0) {
for (const canonical of this.state.questionnaireResponses.data.map(
questionnaireResponse => questionnaireResponse.questionnaire
)) {
promises.push(
this.props.client
.request(canonical)
.then(questionnaire => [canonical, questionnaire.title || canonical])
);
}
Promise.all(promises).then(pairs => {
this.setState({ questionnaireTitles: Object.fromEntries(pairs) });
});
}
Promise.all(promises).then(pairs => {
this.setState({ questionnaireTitles: Object.fromEntries(pairs) });
});
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/containers/RequestBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default class RequestBuilder extends Component {
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(),
Expand Down Expand Up @@ -229,6 +230,7 @@ export default class RequestBuilder extends Component {
ref={this.requestBox}
loading={this.state.loading}
consoleLog={this.consoleLog}
patientFhirQuery ={this.state.patientFhirQuery}
/>
</div>
<br />
Expand Down
4 changes: 4 additions & 0 deletions src/util/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ const headerDefinitions = {
display: 'Order Sign Rest End Point',
type: 'input'
},
patientFhirQuery: {
display: 'Patient FHIR Query',
type: 'input'
},
patientView: {
display: 'Patient View Rest End Point',
type: 'input'
Expand Down