From 376db8f06582ecfbd2cf010614a4762a32aeccba Mon Sep 17 00:00:00 2001 From: Greg Akins Date: Mon, 9 Dec 2024 09:40:39 -0500 Subject: [PATCH] MAT-7909: Fixed when alias is malformed --- src/AceEditor/madie-ace-editor.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/AceEditor/madie-ace-editor.tsx b/src/AceEditor/madie-ace-editor.tsx index e570a9b..b6d45d3 100644 --- a/src/AceEditor/madie-ace-editor.tsx +++ b/src/AceEditor/madie-ace-editor.tsx @@ -273,10 +273,18 @@ const updateCql = ( 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]; + const fhirHelpersIncludeLine: string[] = + parsedEditorCql.cqlArrayToBeFiltered[include.start.line - 1].split( + " " + ); + if (fhirHelpersIncludeLine[4].toLowerCase() === "called") { + fhirHelpersIncludeLine[5] = "FHIRHelpers"; + } else { + console.error("FHIRHelpers include statement was malformed"); + throw new Error("FHIRHelpers include statement was malformed"); + } parsedEditorCql.cqlArrayToBeFiltered[include.start.line - 1] = - fhirHelpersIncludeLine.replace(include.called, "FHIRHelpers"); + fhirHelpersIncludeLine.join(" "); cqlUpdates.isFhirHelpersAliasChanged = true; } });