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

Fix: make sure hare concept id is part of histogram and overlap queries #1228

Merged
Merged
Changes from 1 commit
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
77 changes: 12 additions & 65 deletions src/Analysis/GWASV2/Utils/cohortMiddlewareApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,6 @@ import { headers } from '../../../configs';

const hareConceptId = 2000007027;

export const fetchConceptStatsByHare = async (
cohortDefinitionId,
selectedCovariates,
selectedDichotomousCovariates,
sourceId,
) => {
const variablesPayload = {
variables: [
...selectedDichotomousCovariates.map(({ uuid, ...withNoId }) => withNoId),
...selectedCovariates.map((c) => ({
variable_type: 'concept',
concept_id: c.concept_id,
})),
],
};
const conceptStatsEndPoint = `${cohortMiddlewarePath}concept-stats/by-source-id/${sourceId}/by-cohort-definition-id/${cohortDefinitionId}/breakdown-by-concept-id/${hareConceptId}`;
const reqBody = {
method: 'POST',
credentials: 'include',
headers,
body: JSON.stringify(variablesPayload),
};
const response = await fetch(conceptStatsEndPoint, reqBody);
if (!response.ok) {
const message = `An error has occured: ${response.status}`;
throw new Error(message);
}
return response.json();
};

export const fetchOverlapInfo = async (
sourceId,
caseCohortDefinitionId,
controlCohortDefinitionId,
selectedHare,
selectedCovariates,
selectedDichotomousCovariates,
) => {
const variablesPayload = {
variables: [
...selectedDichotomousCovariates.map(({ uuid, ...withNoId }) => withNoId),
...selectedCovariates.map((c) => ({
variable_type: 'concept',
concept_id: c.concept_id,
})),
],
};
const statsEndPoint = `${cohortMiddlewarePath}cohort-stats/check-overlap/by-source-id/${sourceId}/by-case-control-cohort-definition-ids/${caseCohortDefinitionId}/${controlCohortDefinitionId}/filter-by-concept-id-and-value/${hareConceptId}/${selectedHare.concept_value_as_concept_id}`;
const reqBody = {
method: 'POST',
credentials: 'include',
headers,
body: JSON.stringify(variablesPayload),
};
const response = await fetch(statsEndPoint, reqBody);
if (!response.ok) {
const message = `An error has occured: ${response.status}`;
throw new Error(message);
}
return response.json();
};

// Basically a copy of fetchOverlapInfo above, but without the HARE arguments:
export const fetchSimpleOverlapInfo = async (
sourceId,
cohortAId,
Expand All @@ -76,7 +13,12 @@ export const fetchSimpleOverlapInfo = async (
outcome,
) => {
const variablesPayload = {
variables: [...selectedCovariates, outcome],
variables: [...selectedCovariates, outcome,
// add extra filter to make sure we only count persons that have a HARE group as well:
{
variable_type: 'concept',
concept_id: hareConceptId,
}],
};
const statsEndPoint = `${cohortMiddlewarePath}cohort-stats/check-overlap/by-source-id/${sourceId}/by-cohort-definition-ids/${cohortAId}/${cohortBId}`;
const reqBody = {
Expand All @@ -101,7 +43,12 @@ export const fetchHistogramInfo = async (
selectedConceptId,
) => {
const variablesPayload = {
variables: [...selectedCovariates, outcome],
variables: [...selectedCovariates, outcome,
// add extra filter to make sure we only count persons that have a HARE group as well:
{
variable_type: 'concept',
concept_id: hareConceptId,
}],
};
const endPoint = `${cohortMiddlewarePath}histogram/by-source-id/${sourceId}/by-cohort-definition-id/${cohortId}/by-histogram-concept-id/${selectedConceptId}`;
const reqBody = {
Expand Down