From cfe7f0b280b4a5665ff5423b84e1661c6548a21b Mon Sep 17 00:00:00 2001 From: adongare Date: Thu, 5 Dec 2024 17:11:55 -0500 Subject: [PATCH] MAT-7652 CQL Validation - Multiple Using Statements --- src/AceEditor/madie-ace-editor.test.tsx | 4 ++-- src/AceEditor/madie-ace-editor.tsx | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/AceEditor/madie-ace-editor.test.tsx b/src/AceEditor/madie-ace-editor.test.tsx index 666b3bb..d99f98b 100644 --- a/src/AceEditor/madie-ace-editor.test.tsx +++ b/src/AceEditor/madie-ace-editor.test.tsx @@ -340,8 +340,8 @@ describe("synching the cql", () => { expect(updatedContent.isUsingStatementChanged).toEqual(true); }); - test("replacing the error containing using content line to actual using content with FHIR", async () => { - const expectValue = "using QICore version '4.1.1'"; + test("Not to replace the using FHIR statement for QICore measure if it is the only using statement", async () => { + const expectValue = "using FHIR version '4.0.1'"; const updatedContent = await updateEditorContent( "using FHIR version '4.0.1'", "", diff --git a/src/AceEditor/madie-ace-editor.tsx b/src/AceEditor/madie-ace-editor.tsx index 6741f3b..24dbce9 100644 --- a/src/AceEditor/madie-ace-editor.tsx +++ b/src/AceEditor/madie-ace-editor.tsx @@ -90,9 +90,16 @@ export const updateUsingStatements = ( measureModel !== name || modelVersion !== version.replace(/["']/g, "") ) { - parsedEditorCqlCopy.cqlArrayToBeFiltered[ - start.line - 1 - ] = `using ${measureModel} version '${modelVersion}'`; + // we want to keep FHIR if there is only one using model for QICore. + if (measureModel === "QICore" && name === "FHIR") { + parsedEditorCqlCopy.cqlArrayToBeFiltered[ + start.line - 1 + ] = `using FHIR version '4.0.1'`; + } else { + parsedEditorCqlCopy.cqlArrayToBeFiltered[ + start.line - 1 + ] = `using ${measureModel} version '${modelVersion}'`; + } isCqlUpdated = true; } } else if (usingStatements?.length > 1) {