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

KPMP-5566_add-participant-clinical-info #270

Merged
merged 7 commits into from
Oct 28, 2024
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
3 changes: 0 additions & 3 deletions src/actions/Clinical/clinicalDatasetAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ export const fetchAndSetSummaryDatasets = (participant_id) => {
export const fetchAndSetClinicalDatasets = (participant_id) => {
return async (dispatch) => {
let clinicalDatasets = await fetchParticipantClinicalDataset(participant_id);
if (clinicalDatasets) {
clinicalDatasets = JSON.parse(clinicalDatasets.clinicalData);
}
clinicalDatasets = mapClinicalKeysToPresentationStyle(clinicalDatasets);
dispatch(setClinicalDatasets(clinicalDatasets));
}
Expand Down
46 changes: 28 additions & 18 deletions src/helpers/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const fetchParticipantSummaryDataset = async (redcapId) => {
const query = gql`
query participantSummaryDataset($redcapId: String!) {
participantSummaryDataset(redcapId: $redcapId){
tissueType
enrollmentCategory
redcapId
}
}`;
Expand Down Expand Up @@ -66,21 +66,31 @@ export const fetchParticipantExperimentCounts = async (redcapId) => {
};

export const fetchParticipantClinicalDataset = async (redcapId) => {
const query = gql`
query participantSummaryDataset($redcapId: String!) {
participantSummaryDataset(redcapId: $redcapId){
clinicalData
}
}`;
const response = await apolloClient.query({
query: query,
variables: {
redcapId: redcapId
const query = gql`
query {
getParticipantClinicalDataset(redcapId: "${redcapId}"){
kdigoStage
baselineEgfr
proteinuria
a1c
albuminuria
diabetesHistory
diabetesDuration
hypertensionHistory
hypertensionDuration
onRaasBlockade
race
}
});
if (response && response.data && response.data.participantSummaryDataset) {
return response.data.participantSummaryDataset;
} else {
store.dispatch(sendMessageToBackend("Could not retrieve participantSummaryDataset (clinical data): " + response.error));
}
};
}`;
const response = await apolloClient.query({
query: query,
variables: {
redcapId: redcapId
}
});
if (response && response.data && response.data.getParticipantClinicalDataset) {
return response.data.getParticipantClinicalDataset;
} else {
store.dispatch(sendMessageToBackend("Could not retrieve getParticipantClinicalDataset (clinical data): " + response.error));
}
};
66 changes: 33 additions & 33 deletions src/helpers/dataHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,56 +76,56 @@ export const mapClinicalKeysToPresentationStyle = (data) => {
if (!data || data === {}) {
return result;
}
if (data['A1c (%) (Binned)']) {
result['A1C (%)'] = data['A1c (%) (Binned)'] ? data['A1c (%) (Binned)'] : "";
if (data.a1c) {
result['A1C (%)'] = data.a1c ? data.a1c : "";
}
if (data['Albuminuria (mg) (Binned)']) {
result['Albuminuria (mg)'] = data['Albuminuria (mg) (Binned)'] ? data['Albuminuria (mg) (Binned)'] : "";
if (data.albuminuria) {
result['Albuminuria (mg)'] = data.albuminuria ? data.albuminuria : "";
}
if (data['Baseline eGFR (ml/min/1.73m2) (Binned)']) {
result['Baseline eGFR (ml/min/1.73m2)'] = data['Baseline eGFR (ml/min/1.73m2) (Binned)'] ? data['Baseline eGFR (ml/min/1.73m2) (Binned)'].replace(' ml/min/1.73m2', '') : "";
if (data.baselineEgfr) {
result['Baseline eGFR (ml/min/1.73m2)'] = data.baselineEgfr ? data.baselineEgfr.replace(' ml/min/1.73m2', '') : "";
}
if (data['Diabetes Duration (Years)']) {
result['Diabetes Duration (Years)'] = data['Diabetes Duration (Years)'] ? data['Diabetes Duration (Years)'].replace(' Years', '') : "";
if (data.diabetesDuration) {
result['Diabetes Duration (Years)'] = data.diabetesDuration ? data.diabetesDuration.replace(' Years', '') : "";
}
if (data['Diabetes History']) {
result['Diabetes History'] = data['Diabetes History'] ? data['Diabetes History'] : "";
if (data.diabetesHistory) {
result['Diabetes History'] = data.diabetesHistory ? data.diabetesHistory : "";
}
if (data['Hypertension Duration (Years)']) {
result['Hypertension Duration (years)'] = data['Hypertension Duration (Years)'] ? data['Hypertension Duration (Years)'].replace(' Years', '') : "";
if (data.hypertensionDuration) {
result['Hypertension Duration (years)'] = data.hypertensionDuration ? data.hypertensionDuration.replace(' Years', '') : "";
}
if (data['Hypertension History']) {
result['Hypertension History'] = data['Hypertension History'] ? data['Hypertension History'] : "";
if (data.hypertensionHistory) {
result['Hypertension History'] = data.hypertensionHistory ? data.hypertensionHistory : "";
}
if (data['KDIGO Stage']) {
result['KDIGO Stage'] = data['KDIGO Stage'] ? data['KDIGO Stage'] : "";
if (data.kdigoStage) {
result['KDIGO Stage'] = data.kdigoStage ? data.kdigoStage : "";
}
if (data['On RAAS Blockade']) {
result['On RAAS Blockade'] = data['On RAAS Blockade'] ? data['On RAAS Blockade'] : "";
if (data.onRaasBlockade) {
result['On RAAS Blockade'] = data.onRaasBlockade ? data.onRaasBlockade : "";
}
if (data['Proteinuria (mg) (Binned)']) {
result['Proteinuria (mg)'] = data['Proteinuria (mg) (Binned)'] ? data['Proteinuria (mg) (Binned)'] : "";
if (data.proteinuria) {
result['Proteinuria (mg)'] = data.proteinuria ? data.proteinuria : "";
}
if (data['Race']) {
result['Ethnicity'] = data['Race'] ? data['Race'] : "";
if (data.race) {
result['Ethnicity'] = data.race ? data.race : "";
}
if (data['Age (Years) (Binned)']) {
result['Age (Years)'] = data['Age (Years) (Binned)'] ? data['Age (Years) (Binned)'].replace(' Years', '') : "";
if (data.age) {
result['Age (Years)'] = data.age ? data.age.replace(' Years', '') : "";
}

if (data['Sample Type']) {
result['Sample Type'] = data['Sample Type'] ? data['Sample Type'] : "";
if (data.sampleType) {
result['Sample Type'] = data.sampleType ? data.sampleType : "";
}

if (data['Sex']) {
result['Sex'] = data['Sex'] ? data['Sex'] : "";
if (data.sex) {
result['Sex'] = data.sex ? data.sex : "";
}
if (data['Protocol']) {
result['Protocol'] = data['Protocol'] ? data['Protocol'] : "";
if (data.protocol) {
result['Protocol'] = data.protocol ? data.protocol : "";
}
if (data['Tissue Source']) {
result['Tissue Source'] = data['Tissue Source'] ? data['Tissue Source'] : "";
if (data.tissueSource) {
result['Tissue Source'] = data.tissueSource ? data.tissueSource : "";
}

return result;
};
};
182 changes: 94 additions & 88 deletions src/helpers/dataHelper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,109 +68,115 @@ describe('dataHelper', () => {

describe('mapClinicalKeysToPresentationStyle', () => {
it('should return remapped values when object params given', () => {
let clinicalUnmapped = {};
clinicalUnmapped['A1c (%) (Binned)']= "test-a1c";
clinicalUnmapped['Albuminuria (mg) (Binned)'] = "test-albuminuria";
clinicalUnmapped['Baseline eGFR (ml/min/1.73m2) (Binned)'] = "test-baseline_egfr";
clinicalUnmapped['Diabetes Duration (Years)'] = "test-diabetes_duration";
clinicalUnmapped['Diabetes History'] = "test-diabetes_history";
clinicalUnmapped['Hypertension Duration (Years)'] = "test-hypertension_duration";
clinicalUnmapped['Hypertension History'] = "test-hypertension_history";
clinicalUnmapped['KDIGO Stage'] = "test-kdigo_stage";
clinicalUnmapped['On RAAS Blockade'] = "test-on_raas_blockade";
clinicalUnmapped['Proteinuria (mg) (Binned)'] = "test-proteinuria";
clinicalUnmapped['Race'] = "test-Ethnicity";
clinicalUnmapped['Age (Years) (Binned)'] = "test-Age";
clinicalUnmapped['Sex'] = "test-sex";
clinicalUnmapped['Protocol'] = "test-Protocol";
clinicalUnmapped['Sample Type'] = "test-Sample Type";
clinicalUnmapped['Tissue Source'] = "test-Tissue Source";
let clinicalUnmapped = {
"a1c": "test-a1c",
"albuminuria": "test-albuminuria",
"baselineEgfr": "test-baseline_egfr",
"diabetesDuration": "test-diabetes_duration",
"diabetesHistory": "test-diabetes_history",
"hypertensionDuration": "test-hypertension_duration",
"hypertensionHistory": "test-hypertension_history",
"kdigoStage": "testdkigo_stage",
"onRaasBlockade": "test-on_raas_blockade",
"proteinuria": "proteinuria",
"race": "test-Ethnicity",
"age": "test-Age",
"sex": "test-sex",
"protocol": "test-protocol",
"sampleType": "test-sample_type",
"tissueSource": "test-tissue_source"
};
const clinicalMappingResult = mapClinicalKeysToPresentationStyle(clinicalUnmapped);
const expectedClinicalMapping = {};
expectedClinicalMapping['A1C (%)']= "test-a1c";
expectedClinicalMapping['Albuminuria (mg)'] = "test-albuminuria";
expectedClinicalMapping['Baseline eGFR (ml/min/1.73m2)'] = "test-baseline_egfr";
expectedClinicalMapping['Diabetes Duration (Years)'] = "test-diabetes_duration";
expectedClinicalMapping['Diabetes History'] = "test-diabetes_history";
expectedClinicalMapping['Hypertension Duration (years)'] = "test-hypertension_duration";
expectedClinicalMapping['Hypertension History'] = "test-hypertension_history";
expectedClinicalMapping['KDIGO Stage'] = "test-kdigo_stage";
expectedClinicalMapping['On RAAS Blockade'] = "test-on_raas_blockade";
expectedClinicalMapping['Proteinuria (mg)'] = "test-proteinuria";
expectedClinicalMapping['Ethnicity'] = "test-Ethnicity";
expectedClinicalMapping['Age (Years)'] = "test-Age";
expectedClinicalMapping['Sex'] = "test-sex";
expectedClinicalMapping['Protocol'] = "test-Protocol";
expectedClinicalMapping['Sample Type'] = "test-Sample Type";
expectedClinicalMapping['Tissue Source'] = "test-Tissue Source";
const expectedClinicalMapping = {
'A1C (%)': "test-a1c",
'Albuminuria (mg)': 'test-albuminuria',
'Baseline eGFR (ml/min/1.73m2)': 'test-baseline_egfr',
'Diabetes Duration (Years)': 'test-diabetes_duration',
'Diabetes History': 'test-diabetes_history',
'Hypertension Duration (years)': 'test-hypertension_duration',
'Hypertension History': 'test-hypertension_history',
'KDIGO Stage': 'testdkigo_stage',
'On RAAS Blockade': 'test-on_raas_blockade',
'Proteinuria (mg)': 'proteinuria',
'Ethnicity': 'test-Ethnicity',
'Age (Years)': 'test-Age',
'Sample Type': 'test-sample_type',
'Sex': 'test-sex',
'Protocol': 'test-protocol',
'Tissue Source': 'test-tissue_source'
}
expect(clinicalMappingResult).toEqual(expectedClinicalMapping);
}),
it('should return remapped values when object params given even when bad data is sent', () => {
let clinicalUnmapped = {};
clinicalUnmapped['A1c (%) (EXAMPLE SHOULD BE BINNED)']= "test-a1c";
clinicalUnmapped['Albuminuria (mg) (Binned)'] = "test-albuminuria";
let clinicalUnmapped = {
"a1c": "test-a1c",
"albuminuria": "test-albuminuria",
};
const clinicalMappingResult = mapClinicalKeysToPresentationStyle(clinicalUnmapped);
const expectedClinicalMapping = {};
expectedClinicalMapping['A1C (%)']= "";
expectedClinicalMapping['Albuminuria (mg)'] = "test-albuminuria";
expectedClinicalMapping['Baseline eGFR (ml/min/1.73m2)'] = "";
expectedClinicalMapping['Diabetes Duration (Years)'] = "";
expectedClinicalMapping['Diabetes History'] = "";
expectedClinicalMapping['Hypertension Duration (years)'] = "";
expectedClinicalMapping['Hypertension History'] = "";
expectedClinicalMapping['KDIGO Stage'] = "";
expectedClinicalMapping['On RAAS Blockade'] = "";
expectedClinicalMapping['Proteinuria (mg)'] = "";
expectedClinicalMapping['Ethnicity'] = "";
expectedClinicalMapping['Age (Years)'] = "";
expectedClinicalMapping['Sex'] = "";
expectedClinicalMapping['Protocol'] = "";
expectedClinicalMapping['Sample Type'] = "";
expectedClinicalMapping['Tissue Source'] = "";
const expectedClinicalMapping = {
'A1C (%)': "test-a1c",
'Albuminuria (mg)': 'test-albuminuria',
'Baseline eGFR (ml/min/1.73m2)': '',
'Diabetes Duration (Years)': '',
'Diabetes History': '',
'Hypertension Duration (years)': '',
'Hypertension History': '',
'KDIGO Stage': '',
'On RAAS Blockade': '',
'Proteinuria (mg)': '',
'Ethnicity': '',
'Age (Years)': '',
'Sample Type': '',
'Sex': '',
'Protocol': '',
'Tissue Source': ''
};
expect(clinicalMappingResult).toEqual(expectedClinicalMapping);
}),
it('should return remapped values when empty object params given', () => {
let clinicalUnmapped = {};
const clinicalMappingResult = mapClinicalKeysToPresentationStyle(clinicalUnmapped);
const expectedClinicalMapping = {};
expectedClinicalMapping['A1C (%)']= "";
expectedClinicalMapping['Albuminuria (mg)'] = "";
expectedClinicalMapping['Baseline eGFR (ml/min/1.73m2)'] = "";
expectedClinicalMapping['Diabetes Duration (Years)'] = "";
expectedClinicalMapping['Diabetes History'] = "";
expectedClinicalMapping['Hypertension Duration (years)'] = "";
expectedClinicalMapping['Hypertension History'] = "";
expectedClinicalMapping['KDIGO Stage'] = "";
expectedClinicalMapping['On RAAS Blockade'] = "";
expectedClinicalMapping['Proteinuria (mg)'] = "";
expectedClinicalMapping['Ethnicity'] = "";
expectedClinicalMapping['Age (Years)'] = "";
expectedClinicalMapping['Sex'] = "";
expectedClinicalMapping['Protocol'] = "";
expectedClinicalMapping['Sample Type'] = "";
expectedClinicalMapping['Tissue Source'] = "";
const expectedClinicalMapping = {
'A1C (%)': "",
'Albuminuria (mg)': '',
'Baseline eGFR (ml/min/1.73m2)': '',
'Diabetes Duration (Years)': '',
'Diabetes History': '',
'Hypertension Duration (years)': '',
'Hypertension History': '',
'KDIGO Stage': '',
'On RAAS Blockade': '',
'Proteinuria (mg)': '',
'Ethnicity': '',
'Age (Years)': '',
'Sample Type': '',
'Sex': '',
'Protocol': '',
'Tissue Source': ''
};
expect(clinicalMappingResult).toEqual(expectedClinicalMapping);
}),
it('should return remapped values when null params given', () => {
let clinicalUnmapped = null;
const clinicalMappingResult = mapClinicalKeysToPresentationStyle(clinicalUnmapped);
const expectedClinicalMapping = {};
expectedClinicalMapping['A1C (%)']= "";
expectedClinicalMapping['Albuminuria (mg)'] = "";
expectedClinicalMapping['Baseline eGFR (ml/min/1.73m2)'] = "";
expectedClinicalMapping['Diabetes Duration (Years)'] = "";
expectedClinicalMapping['Diabetes History'] = "";
expectedClinicalMapping['Hypertension Duration (years)'] = "";
expectedClinicalMapping['Hypertension History'] = "";
expectedClinicalMapping['KDIGO Stage'] = "";
expectedClinicalMapping['On RAAS Blockade'] = "";
expectedClinicalMapping['Proteinuria (mg)'] = "";
expectedClinicalMapping['Ethnicity'] = "";
expectedClinicalMapping['Age (Years)'] = "";
expectedClinicalMapping['Sex'] = "";
expectedClinicalMapping['Protocol'] = "";
expectedClinicalMapping['Sample Type'] = "";
expectedClinicalMapping['Tissue Source'] = "";
const expectedClinicalMapping = {
'A1C (%)': "",
'Albuminuria (mg)': '',
'Baseline eGFR (ml/min/1.73m2)': '',
'Diabetes Duration (Years)': '',
'Diabetes History': '',
'Hypertension Duration (years)': '',
'Hypertension History': '',
'KDIGO Stage': '',
'On RAAS Blockade': '',
'Proteinuria (mg)': '',
'Ethnicity': '',
'Age (Years)': '',
'Sample Type': '',
'Sex': '',
'Protocol': '',
'Tissue Source': ''
};
expect(clinicalMappingResult).toEqual(expectedClinicalMapping);
})
})
Expand Down
Loading