-
Notifications
You must be signed in to change notification settings - Fork 44
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
fix/HIV app and Guppy #558
Changes from all commits
b7b685b
6ed7472
98a1579
1d5827f
a9dfdc7
0d790ff
486cad1
5d785d2
1dd7906
46e2c68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,10 @@ class ExplorerFilter extends React.Component { | |
} | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
componentDidUpdate() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to address a warning found in console while testing using dev.html. |
||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
import React from 'react'; | ||
import FileSaver from 'file-saver'; | ||
import { arrangerGraphqlPath } from '../localconf'; | ||
import { fetchWithCreds } from '../actions'; | ||
import { | ||
guppyGraphQLUrl, | ||
arrangerGraphqlPath, | ||
useGuppyForExplorer, | ||
} from '../configs'; | ||
|
||
class HIVCohortFilterCase extends React.Component { | ||
// Base class for the 3 NDH cohort filter apps. Meant to facilitate code reuse | ||
static performQuery(queryString) { | ||
static performQuery(queryString, variableString) { | ||
const graphqlUrl = useGuppyForExplorer ? guppyGraphQLUrl : arrangerGraphqlPath; | ||
return fetchWithCreds({ | ||
path: `${arrangerGraphqlPath}`, | ||
body: JSON.stringify({ | ||
path: `${graphqlUrl}`, | ||
body: variableString ? JSON.stringify({ | ||
query: queryString, | ||
variables: JSON.parse(variableString), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the case where we use arranger, variableString will be undefined right? And I think that will lead to the error Uncaught SyntaxError: Unexpected token u in JSON at position 0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice catch! fixed in 1dd7906 |
||
}) : JSON.stringify({ | ||
query: queryString, | ||
}), | ||
method: 'POST', | ||
|
@@ -87,6 +95,55 @@ class HIVCohortFilterCase extends React.Component { | |
} | ||
|
||
getFollowupsBuckets = (key, keyRange) => { | ||
if (useGuppyForExplorer) { | ||
const queryString = ` | ||
query ($filter: JSON) { | ||
follow_up (filter: $filter, accessibility: all, first: 10000) { | ||
subject_id | ||
visit_number | ||
thrpyv | ||
visit_date | ||
fposdate | ||
frstdthd | ||
leu3n | ||
submitter_id | ||
viral_load | ||
} | ||
_aggregation { | ||
follow_up (filter: $filter, accessibility: all) { | ||
_totalCount | ||
} | ||
} | ||
} | ||
`; | ||
const variableString = ` | ||
{ | ||
"filter": { | ||
"AND": [ | ||
{ | ||
"in": { | ||
"${key}": ["${keyRange.join('","')}"] | ||
} | ||
}, | ||
{ | ||
"=": { | ||
"hiv_status": "positive" | ||
} | ||
} | ||
] | ||
} | ||
}`; | ||
return HIVCohortFilterCase.performQuery(queryString, variableString).then((res) => { | ||
if (!res | ||
|| !res.data | ||
|| !res.data.follow_up) { | ||
throw new Error('Error while querying subjects with HIV'); | ||
} | ||
return res.data.follow_up; | ||
}); | ||
} | ||
|
||
// below are for arranger | ||
const query = ` | ||
{ | ||
follow_up { | ||
|
@@ -115,7 +172,6 @@ class HIVCohortFilterCase extends React.Component { | |
viral_load | ||
} | ||
} | ||
|
||
} | ||
} | ||
}`; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to address a warning found in console while testing using dev.html.
Warning: ExplorerFilter.getSnapshotBeforeUpdate(): A snapshot value (or null) must be returned. You have returned undefined.