Skip to content

Commit

Permalink
Merge pull request #403 from MeasureAuthoringTool/MAT-7652
Browse files Browse the repository at this point in the history
MAT-7652 do not replace FHIR model if thats the only using model for QICore measure/library
  • Loading branch information
adongare authored Dec 9, 2024
2 parents 419886b + 6c2289b commit a7b8715
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
17 changes: 16 additions & 1 deletion src/AceEditor/madie-ace-editor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ describe("synching the cql", () => {
expect(updatedContent.isUsingStatementChanged).toEqual(true);
});

test("Not to replace the using FHIR statement for QICore measure if it is the only using statement", async () => {
test("Not to replace the using FHIR statement for QICore measure if it is the only using statement with correct version", async () => {
const expectValue = "using FHIR version '4.0.1'";
const updatedContent = await updateEditorContent(
"using FHIR version '4.0.1'",
Expand All @@ -355,6 +355,21 @@ describe("synching the cql", () => {
expect(updatedContent.cql).toEqual(expectValue);
});

test("Correct the using FHIR model version for QICore measure if it is the only using statement but incorrect version", async () => {
const expectValue = "using FHIR version '4.0.1'";
const updatedContent = await updateEditorContent(
"using FHIR version '4.1.1'", //incorrect FHIR version
"",
"Test",
"",
"0.0.000",
"QI-Core",
"4.1.1",
"measureEditor"
);
expect(updatedContent.cql).toEqual(expectValue);
});

test("generated Cql has updated cql library name", async () => {
const expectValue = "library Testing version '0.0.000'";
const updatedContent = await updateEditorContent(
Expand Down
19 changes: 10 additions & 9 deletions src/AceEditor/madie-ace-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,22 @@ export const updateUsingStatements = (
let isCqlUpdated = false;
if (usingStatements?.length === 1) {
const { name, version, start } = usingStatements[0];
if (
measureModel !== name ||
modelVersion !== version.replace(/["']/g, "")
) {
// we want to keep FHIR if that's the only using model present for QICore.
const cleanedVersion = version.replace(/["']/g, "");
if (measureModel !== name || modelVersion !== cleanedVersion) {
// keep FHIR if that's the only using model present for QICore but update version if it was incorrect.
if (measureModel === "QICore" && name === "FHIR") {
parsedEditorCqlCopy.cqlArrayToBeFiltered[
start.line - 1
] = `using FHIR version '4.0.1'`;
if (cleanedVersion !== "4.0.1") {
parsedEditorCqlCopy.cqlArrayToBeFiltered[
start.line - 1
] = `using FHIR version '4.0.1'`;
isCqlUpdated = true;
}
} else {
parsedEditorCqlCopy.cqlArrayToBeFiltered[
start.line - 1
] = `using ${measureModel} version '${modelVersion}'`;
isCqlUpdated = true;
}
isCqlUpdated = true;
}
} else if (usingStatements?.length > 1) {
// to track if the usings statement was verified or not
Expand Down
4 changes: 2 additions & 2 deletions src/api/useFhirElmTranslationServiceApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe("Test FhirElmTranslationServiceApi", () => {
new FhirElmTranslationServiceApi(null, mockGetAccessToken);

try {
await fhirElmTranslationServiceApi.translateCqlToElm("test", true);
await fhirElmTranslationServiceApi.translateCqlToElm("mock cql", true);
} catch (error) {
expect(error).not.toBeNull();
expect(error.message).toBe(
Expand Down Expand Up @@ -104,7 +104,7 @@ describe("Test FhirElmTranslationServiceApi", () => {
new FhirElmTranslationServiceApi("test", mockGetAccessToken);

try {
await fhirElmTranslationServiceApi.translateCqlToElm("test", false);
await fhirElmTranslationServiceApi.translateCqlToElm("mock cql", false);
} catch (error) {
expect(error).not.toBeNull();
expect(error.message).toBe("Request failed with status code 404");
Expand Down

0 comments on commit a7b8715

Please sign in to comment.