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..e570a9b 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 that's the only using model present 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) {