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

Allow to set headers on FHIR calls (fixes #13) #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,15 @@ Note that these config files are in `json5` format which is like a loose version
Any config file might contain the following options:

- `server` - an object describing the FHIR API server
- `server.url` - The base URL of the FHIR API server to use. Note that the picker will only work with open servers that do not require authorization.
- `server.type` - The FHIR version. Currently this can be `DSTU-2` or `STU-3` or `R4`.
- `server.tags` - An array of tag objects to be rendered in the tags auto-complete menu. This defaults to an empty array and in that case the tag selection widget will not have a drop-down menu options but it will still allow you to search by typing some tag manually. In other words, using an empty array is like saying that we just don't know what tags (if any) are available on that server. The list of tags might look like this:
- `server.url` - The base URL of the FHIR API server to use. Note that the picker will only work with open servers that do not require authorization unless the headers option is added.
- `server.headers` - Optional headers (as key/value) to send to the FHIR server. Please note that any secret credentials used here are sent to the client browser and are accessible using developper tools. Headers might look like this:
```js
{
Authorization: "Bearer my-token"
}
```
- `server.type` - The FHIR version. Currently this can be `DSTU-2` or `STU-3` or `R4`.
- `server.tags` - An array of tag objects to be rendered in the tags auto-complete menu. This defaults to an empty array and in that case the tag selection widget will not have a drop-down menu options but it will still allow you to search by typing some tag manually. In other words, using an empty array is like saying that we just don't know what tags (if any) are available on that server. The list of tags might look like this:
```js
[
{
Expand Down
2 changes: 1 addition & 1 deletion src/components/PatientDetail/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class PatientDetail extends React.Component

// Find $everything
.then(state => {
return getAllPages({ url: `${server.url}/Patient/${state.patient.id}/$everything?_count=500` })
return getAllPages({ url: `${server.url}/Patient/${state.patient.id}/$everything?_count=500`, headers: server.headers })
.then(data => {
let groups = {};
data.forEach(entry => {
Expand Down
5 changes: 5 additions & 0 deletions src/lib/PatientSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import moment from "moment"
import { CODE_SYSTEMS } from "./constants"
import { parseQueryString, request } from "."
import { intVal, getPath } from "."
import $ from "jquery"

/**
* This is just a helper class that is used as a query builder. It has some
Expand Down Expand Up @@ -819,6 +820,10 @@ export default class PatientSearch
}
};

if (server.headers) {
options.headers = $.extend(true, options.headers, server.headers);
}

return this.getPatientIDs(server)
.then(ids => {
if (ids.length) {
Expand Down