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

[ENH] Added Assessment Tool annoatatoins to the JSON output file #588

Merged
merged 4 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion components/annot-tool-groups.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
:title="label">
<annot-single-tool
:name="identifier"
:uniqueColumnValues="provideUniqueValues(identifier)"
:unique-column-values="provideUniqueValues(identifier)"
rmanaem marked this conversation as resolved.
Show resolved Hide resolved
@declareMissing="changeMissingStatus(Object.assign($event, {markAsMissing: true}))" />
</b-tab>

Expand Down
15 changes: 12 additions & 3 deletions cypress/e2e/app/simple-e2etest.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ describe("End to end test using a simple UI path through the app", () => {

["Subject ID", 1],
["Age", 1],
["Diagnosis", 1]
["Diagnosis", 1],
["Assessment Tool", 1]
]
};

Expand Down Expand Up @@ -79,6 +80,12 @@ describe("End to end test using a simple UI path through the app", () => {
// D. Categorize "age" as "Age" and "group" as "Diagnosis"
cy.categorizeColumn("Age", p_dataset["category_columns"]["Age"][0]);
cy.categorizeColumn("Diagnosis", p_dataset["category_columns"]["Diagnosis"][0]);
cy.categorizeColumn("Assessment Tool", p_dataset["category_columns"]["Assessment Tool"][0]);

cy.get("[data-cy='toolgroup-select']").type("MOCA{enter}");
cy.get("[data-cy='assessment-tool-table']").contains("MOCA").click();
cy.get("[data-cy='assessment-column-table']").contains("iq").click();


// Since Age and subject ID have been categorized
// annotation page is no accessible.
Expand Down Expand Up @@ -116,8 +123,6 @@ describe("End to end test using a simple UI path through the app", () => {
cy.get("[data-cy='isControlButton_1']").type("Acute{enter}");
cy.get("[data-cy='categoricalSelector_2']").type("Hearing{enter}");



// D. Assert that next page nav and button are enabled for download page
cy.assertNextPageAccess("download", true);

Expand All @@ -138,6 +143,10 @@ describe("End to end test using a simple UI path through the app", () => {
cy.readFile('cypress/downloads/' + folderStateAfter[folderStateAfter.length - 1]).then((fileContent) => {
expect(fileContent.group.Annotations.Levels.HC.Label).to.eq("Healthy Control");
expect(fileContent.group.Annotations.Levels.HC.TermURL).to.eq("ncit:C94342");
expect(fileContent.iq.Annotations.IsAbout.Label).to.eq("Assessment tool");
expect(fileContent.iq.Annotations.IsAbout.TermURL).to.eq("nb:Assessment");
expect(fileContent.iq.Annotations.IsPartOf.Label).to.eq("MOCA");
expect(fileContent.iq.Annotations.IsPartOf.TermURL).to.eq("cogAtlas:MOCA");
});
});

Expand Down
52 changes: 52 additions & 0 deletions cypress/unit/store-getter-getAssessmentToolJSONOutput.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { getters } from "~/store";

let store = {

getters: getters,

state: {
dataDictionary: {
annotated: {
column1: {
Description: "Some cool description here.",
missingValues: ["Missing"]
}
}
},
toolTerms: [
{
label: "MOCA",
identifier: "cogAtlas:MOCA",
selected: false
}
],
columnToToolMap: {
column1: "cogAtlas:MOCA"
}

}
};

describe("getAssessmentToolJSONOutput", () => {

it("Make sure Assessment tool json output is schema compliant", () => {

// Act - Get formatted json output data for discrete value column
rmanaem marked this conversation as resolved.
Show resolved Hide resolved
const output = store.getters.getAssessmentToolJSONOutput(store.state)("column1");
expect(output).to.deep.equal(
{
Annotations: {
IsAbout: {
"TermURL": "nb:Assessment",
"Label": "Assessment tool"
},
"IsPartOf": {
"TermURL": "cogAtlas:MOCA",
"Label": "MOCA"
},
MissingValues: ["Missing"]
},
Description: "Some cool description here."
});
});
});
42 changes: 42 additions & 0 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,43 @@ export const getters = {
return p_state.categories[p_category].componentName;
},

getAssessmentToolJSONOutput: (p_state) => (p_columnName) => {
const annotatedDictColumn = p_state.dataDictionary.annotated[p_columnName];
const formattedOutput = {
Annotations: {
IsAbout: {
TermURL: "nb:Assessment",
Label: "Assessment tool"
},
IsPartOf: {
TermURL: "",
Label: ""
},
MissingValues: []
}
};
const tool = p_state.columnToToolMap[p_columnName];

p_state.toolTerms.forEach(term => {
if ( term.identifier === tool ) {
formattedOutput.Annotations.IsPartOf.Label = term.label;
formattedOutput.Annotations.IsPartOf.TermURL = term.identifier;
}
});

Object.keys(annotatedDictColumn).forEach(columnEntry => {
rmanaem marked this conversation as resolved.
Show resolved Hide resolved

if ( "missingValues" !== columnEntry && "valueMap" !== columnEntry ) {

formattedOutput[columnEntry] = annotatedDictColumn[columnEntry];
}
});

formattedOutput.Annotations.MissingValues = annotatedDictColumn.missingValues;

return formattedOutput;
},

getCategoricalJsonOutput: (p_state) => (p_columnName) => {

// 0. Initialize output object
Expand Down Expand Up @@ -456,6 +493,11 @@ export const getters = {
Identifies: "participant"
}
};
break;

case "annot-tool-groups":
columnOutput = p_getters.getAssessmentToolJSONOutput(columnName);
break;
}

}
Expand Down
Loading