Skip to content

Commit

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

MAT-8006: Fixed when alias is malformed
  • Loading branch information
gregory-akins authored Dec 9, 2024
2 parents a7b8715 + 9bd8998 commit 4e0095b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
36 changes: 35 additions & 1 deletion src/AceEditor/madie-ace-editor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,24 @@ describe("synching the cql", () => {
expect(updatedContent.isValueSetChanged).toEqual(false);
});

it("should replace incorrect alias for FHIRHelpers", async () => {
it("should replace incorrect alias for FHIRHelpers ; alias has spaces", async () => {
const expectValue =
"library MAT7909TestDefaultAlias version '0.0.000' using QICore version '4.1.1' include FHIRHelpers version '4.3.000' called FHIRHelpers Helpers 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 F Helpers 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);
});

it("should replace incorrect alias for FHIRHelpers single line CQL", 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(
Expand All @@ -324,6 +341,23 @@ describe("synching the cql", () => {
expect(updatedContent.isFhirHelpersAliasChanged).toEqual(true);
});

it("should replace incorrect alias for FHIRHelpers; multiple line cql ", async () => {
const expectValue =
"library MAT7909TestDefaultAlias version '0.0.000'\n using QICore version '4.1.1'\n include FHIRHelpers version '4.3.000' called FHIRHelpers\n valueset \"Bicarbonate lab test\": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.139'\n context Patient\n define \"Initial Population\":\n exists ( [Observation] O where O.value < 5 'mg')\n ";
const updatedContent = await updateEditorContent(
"library MAT7909TestDefaultAlias version '0.0.000'\n using QICore version '4.1.1'\n include FHIRHelpers version '4.3.000' called Dummy\n valueset \"Bicarbonate lab test\": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.139'\n context Patient\n define \"Initial Population\":\n exists ( [Observation] O where O.value < 5 'mg')\n ",
"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: 10 additions & 5 deletions src/AceEditor/madie-ace-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,21 @@ const updateCql = (
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];
const correctFhirHelpersIncludeLine: string = ` FHIRHelpers version ${include.version} called FHIRHelpers`;
const incorrectFhirHelpersIncludeLine: string =
parsedEditorCql.cqlArrayToBeFiltered[
include.start.line - 1
].substring(include.start.position + 1, include.stop.position + 1);

parsedEditorCql.cqlArrayToBeFiltered[include.start.line - 1] =
fhirHelpersIncludeLine.replace(include.called, "FHIRHelpers");
parsedEditorCql.cqlArrayToBeFiltered[include.start.line - 1].replace(
incorrectFhirHelpersIncludeLine,
correctFhirHelpersIncludeLine
);
cqlUpdates.isFhirHelpersAliasChanged = true;
}
});
Expand Down

0 comments on commit 4e0095b

Please sign in to comment.