Skip to content

Commit

Permalink
Merge pull request #399 from MeasureAuthoringTool/MAT-7909_FhirHelepr…
Browse files Browse the repository at this point in the history
…sAlias

MAT-7909: Changes to fix FHIRHelpers if it's aliased incorrectly
  • Loading branch information
gregory-akins authored Dec 5, 2024
2 parents ad689e7 + 8c3ca71 commit 04cb868
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
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 @@ export interface UpdatedCqlObject {
isLibraryStatementChanged?: boolean;
isUsingStatementChanged?: boolean;
isValueSetChanged?: boolean;
isFhirHelpersAliasChanged?: boolean;
}

export const updateUsingStatements = (
Expand Down Expand Up @@ -258,6 +259,20 @@ const updateCql = (
] = `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

0 comments on commit 04cb868

Please sign in to comment.