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

MAT-7909: Changes to fix FHIRHelpers if it's aliased incorrectly #399

Merged
merged 1 commit into from
Dec 5, 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
17 changes: 17 additions & 0 deletions src/AceEditor/madie-ace-editor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,23 @@ describe("synching the cql", () => {
expect(updatedContent.isValueSetChanged).toEqual(false);
});

it("should replace incorrect alias for FHIRHelpers", async () => {
const expectValue =
"library MAT7909TestDefaultAlias version '0.0.000' using QICore version '4.1.1' include FHIRHelpers version '4.3.000' called FHIRHelpers valueset \"Bicarbonate lab test\": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.139' context Patient define \"Initial Population\": exists ( [Observation] O where O.value < 5 'mg') ";
const updatedContent = await updateEditorContent(
"library MAT7909TestDefaultAlias version '0.0.000' using QICore version '4.1.1' include FHIRHelpers version '4.3.000' called Dummy valueset \"Bicarbonate lab test\": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.139' context Patient define \"Initial Population\": exists ( [Observation] O where O.value < 5 'mg') ",
"library MAT7909TestDefaultAlias version '0.0.000'",
"MAT7909TestDefaultAlias",
"",
"0.0.000",
"QI-Core",
"4.1.1",
"measureEditor"
);
expect(updatedContent.cql).toEqual(expectValue);
expect(updatedContent.isFhirHelpersAliasChanged).toEqual(true);
});

test("replacing the error containing using content line to actual using content", async () => {
const expectValue = "using QICore version '4.1.1'";
const updatedContent = await updateEditorContent(
Expand Down
15 changes: 15 additions & 0 deletions src/AceEditor/madie-ace-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
isLibraryStatementChanged?: boolean;
isUsingStatementChanged?: boolean;
isValueSetChanged?: boolean;
isFhirHelpersAliasChanged?: boolean;
}

export const updateUsingStatements = (
Expand Down Expand Up @@ -258,6 +259,20 @@
] = `library ${libraryName} version '${libraryVersion}'`;
cqlUpdates.isLibraryStatementChanged = true;
}

//FHIRHelpers can not be aliased

//in includes find FHIRHelpers.. if it exists, check for Alias. If Alias isn't FHIRHelpers exactly,
parsedEditorCql.parsedCql.includes.forEach((include) => {
if (include.name === "FHIRHelpers" && include.called != "FHIRHelpers") {
//then modify and return .. also set cqlUpdates.isFhirHelpersAliasModified = true
const fhirHelpersIncludeLine =
parsedEditorCql.cqlArrayToBeFiltered[include.start.line - 1];
parsedEditorCql.cqlArrayToBeFiltered[include.start.line - 1] =
fhirHelpersIncludeLine.replace(include.called, "FHIRHelpers");
cqlUpdates.isFhirHelpersAliasChanged = true;
}
});
// update using statements if they are incorrect
const { isCqlUpdated, updatedCqlArray } = updateUsingStatements(
parsedEditorCql,
Expand Down Expand Up @@ -455,7 +470,7 @@
console.warn("Editor is not set! Cannot set annotations!", editor);
}
}
}, [parserAnnotations, inboundAnnotations, editor]);

Check warning on line 473 in src/AceEditor/madie-ace-editor.tsx

View workflow job for this annotation

GitHub Actions / Checkout, install, lint, build and test with coverage

React Hook useEffect has missing dependencies: 'customSetAnnotations' and 'validationsEnabled'. Either include them or remove the dependency array
const toggleSearchBox = () => {
// given the searchBox has not been instantiated we execCommand which also triggers show
//@ts-ignore
Expand Down Expand Up @@ -497,7 +512,7 @@
toggleSearchBox as EventListener
);
};
}, [editor, parseErrorMarkers, inboundErrorMarkers]);

Check warning on line 515 in src/AceEditor/madie-ace-editor.tsx

View workflow job for this annotation

GitHub Actions / Checkout, install, lint, build and test with coverage

React Hook useEffect has missing dependencies: 'toggleSearchBox' and 'validationsEnabled'. Either include them or remove the dependency array

useEffect(() => {
const cqlMode = new CqlMode();
Expand All @@ -509,14 +524,14 @@
debouncedParse.cancel();
}
};
}, [debouncedParse]);

Check warning on line 527 in src/AceEditor/madie-ace-editor.tsx

View workflow job for this annotation

GitHub Actions / Checkout, install, lint, build and test with coverage

React Hook useEffect has a missing dependency: 'validationsEnabled'. Either include it or remove the dependency array

useEffect(() => {
if (!_.isNil(value) && editor && validationsEnabled) {
setParsing(true);
debouncedParse(value, editor);
}
}, [value, editor, debouncedParse]);

Check warning on line 534 in src/AceEditor/madie-ace-editor.tsx

View workflow job for this annotation

GitHub Actions / Checkout, install, lint, build and test with coverage

React Hook useEffect has a missing dependency: 'validationsEnabled'. Either include it or remove the dependency array

useEffect(() => {
// This is to set aria-label on textarea for accessibility
Expand Down
Loading