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-7652 do not replace FHIR model if thats the only using model for QICore measure/library #403

Merged
merged 4 commits into from
Dec 9, 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: 16 additions & 1 deletion src/AceEditor/madie-ace-editor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ describe("synching the cql", () => {
expect(updatedContent.isUsingStatementChanged).toEqual(true);
});

test("Not to replace the using FHIR statement for QICore measure if it is the only using statement", async () => {
test("Not to replace the using FHIR statement for QICore measure if it is the only using statement with correct version", async () => {
const expectValue = "using FHIR version '4.0.1'";
const updatedContent = await updateEditorContent(
"using FHIR version '4.0.1'",
Expand All @@ -355,6 +355,21 @@ describe("synching the cql", () => {
expect(updatedContent.cql).toEqual(expectValue);
});

test("Correct the using FHIR model version for QICore measure if it is the only using statement but incorrect version", async () => {
const expectValue = "using FHIR version '4.0.1'";
const updatedContent = await updateEditorContent(
"using FHIR version '4.1.1'", //incorrect FHIR version
"",
"Test",
"",
"0.0.000",
"QI-Core",
"4.1.1",
"measureEditor"
);
expect(updatedContent.cql).toEqual(expectValue);
});

test("generated Cql has updated cql library name", async () => {
const expectValue = "library Testing version '0.0.000'";
const updatedContent = await updateEditorContent(
Expand Down
19 changes: 10 additions & 9 deletions src/AceEditor/madie-ace-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,22 @@
let isCqlUpdated = false;
if (usingStatements?.length === 1) {
const { name, version, start } = usingStatements[0];
if (
measureModel !== name ||
modelVersion !== version.replace(/["']/g, "")
) {
// we want to keep FHIR if that's the only using model present for QICore.
const cleanedVersion = version.replace(/["']/g, "");
if (measureModel !== name || modelVersion !== cleanedVersion) {
// keep FHIR if that's the only using model present for QICore but update version if it was incorrect.
if (measureModel === "QICore" && name === "FHIR") {
parsedEditorCqlCopy.cqlArrayToBeFiltered[
start.line - 1
] = `using FHIR version '4.0.1'`;
if (cleanedVersion !== "4.0.1") {
parsedEditorCqlCopy.cqlArrayToBeFiltered[
start.line - 1
] = `using FHIR version '4.0.1'`;
isCqlUpdated = true;
}
} else {
parsedEditorCqlCopy.cqlArrayToBeFiltered[
start.line - 1
] = `using ${measureModel} version '${modelVersion}'`;
isCqlUpdated = true;
}
isCqlUpdated = true;
}
} else if (usingStatements?.length > 1) {
// to track if the usings statement was verified or not
Expand Down Expand Up @@ -477,7 +478,7 @@
console.warn("Editor is not set! Cannot set annotations!", editor);
}
}
}, [parserAnnotations, inboundAnnotations, editor]);

Check warning on line 481 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 @@ -519,7 +520,7 @@
toggleSearchBox as EventListener
);
};
}, [editor, parseErrorMarkers, inboundErrorMarkers]);

Check warning on line 523 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 @@ -531,14 +532,14 @@
debouncedParse.cancel();
}
};
}, [debouncedParse]);

Check warning on line 535 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 542 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
4 changes: 2 additions & 2 deletions src/api/useFhirElmTranslationServiceApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe("Test FhirElmTranslationServiceApi", () => {
new FhirElmTranslationServiceApi(null, mockGetAccessToken);

try {
await fhirElmTranslationServiceApi.translateCqlToElm("test", true);
await fhirElmTranslationServiceApi.translateCqlToElm("mock cql", true);
} catch (error) {
expect(error).not.toBeNull();
expect(error.message).toBe(
Expand Down Expand Up @@ -104,7 +104,7 @@ describe("Test FhirElmTranslationServiceApi", () => {
new FhirElmTranslationServiceApi("test", mockGetAccessToken);

try {
await fhirElmTranslationServiceApi.translateCqlToElm("test", false);
await fhirElmTranslationServiceApi.translateCqlToElm("mock cql", false);
} catch (error) {
expect(error).not.toBeNull();
expect(error.message).toBe("Request failed with status code 404");
Expand Down
Loading