Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAT-7246 QDM - Remove Value Set Versions from CQL and notify user #564

Merged
merged 4 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 42 additions & 19 deletions src/components/editMeasure/editor/MeasureEditor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,6 @@ jest.mock("@madie/madie-util", () => ({
}));

const MEASURE_CREATEDBY = "[email protected]"; //#nosec

const elmTranslationWithNoErrors: ElmTranslation = {
externalErrors: [],
errorExceptions: [],
library: null,
};

const translationErrors = [
{
startLine: 4,
Expand Down Expand Up @@ -211,7 +204,12 @@ describe("MeasureEditor component", () => {
(synchingEditorCqlContent as jest.Mock)
.mockClear()
.mockImplementation(() => {
return "library testCql version '0.0.000'";
return {
cql: "library testCql version '0.0.000'",
isLibraryStatementChanged: true,
isUsingStatementChanged: false,
isValueSetChanged: false,
};
});

mockedAxios.put.mockImplementation((args) => {
Expand All @@ -234,7 +232,7 @@ describe("MeasureEditor component", () => {
await waitFor(() => {
const successText = getByTestId("generic-success-text-header");
expect(successText.textContent).toEqual(
"Changes saved successfully but the following issues were found"
"CQL updated successfully but the following issues were found"
);
expect(mockedAxios.put).toHaveBeenCalledTimes(1);
});
Expand All @@ -251,7 +249,12 @@ describe("MeasureEditor component", () => {
(synchingEditorCqlContent as jest.Mock)
.mockClear()
.mockImplementation(() => {
return "library testCql version '0.0.000'";
return {
cql: "library testCql version '0.0.000'",
isLibraryStatementChanged: true,
isUsingStatementChanged: false,
isValueSetChanged: false,
};
});

mockedAxios.put.mockImplementation((args) => {
Expand Down Expand Up @@ -279,7 +282,7 @@ describe("MeasureEditor component", () => {
await waitFor(() => {
const successText = getByTestId("generic-success-text-header");
expect(successText.textContent).toEqual(
"Changes saved successfully but the following issues were found"
"CQL updated successfully but the following issues were found"
);
expect(mockedAxios.put).toHaveBeenCalledTimes(1);
});
Expand Down Expand Up @@ -315,7 +318,12 @@ describe("MeasureEditor component", () => {
(synchingEditorCqlContent as jest.Mock)
.mockClear()
.mockImplementation(() => {
return "library testCql version '0.0.000'";
return {
cql: "library testCql version '0.0.000'",
isLibraryStatementChanged: true,
isUsingStatementChanged: false,
isValueSetChanged: false,
};
});

isUsingEmpty.mockClear().mockImplementation(() => true);
Expand All @@ -340,7 +348,7 @@ describe("MeasureEditor component", () => {
await waitFor(() => {
const successText = getByTestId("generic-success-text-header");
expect(successText.textContent).toEqual(
"Changes saved successfully but the following issues were found"
"CQL updated successfully but the following issues were found"
);
expect(mockedAxios.put).toHaveBeenCalledTimes(1);
});
Expand All @@ -359,7 +367,12 @@ describe("MeasureEditor component", () => {
(synchingEditorCqlContent as jest.Mock)
.mockClear()
.mockImplementation(() => {
return "librarydwwd Test2dvh3wd version '0.0.000'";
return {
cql: "librarydwwd Test2dvh3wd version '0.0.000'",
isLibraryStatementChanged: true,
isUsingStatementChanged: false,
isValueSetChanged: false,
};
});

const { getByTestId } = renderEditor(measure);
Expand All @@ -377,7 +390,7 @@ describe("MeasureEditor component", () => {
await waitFor(() => {
const successMessage = getByTestId("generic-success-text-header");
expect(successMessage.textContent).toEqual(
"Changes saved successfully but the following issues were found"
"CQL updated successfully but the following issues were found"
);
expect(mockedAxios.put).toHaveBeenCalledTimes(1);
});
Expand All @@ -400,7 +413,12 @@ describe("MeasureEditor component", () => {
(synchingEditorCqlContent as jest.Mock)
.mockClear()
.mockImplementation(() => {
return "library AdvancedIllnessandFrailtyExclusion version '1.0.001'\nusing QI-Core version '4.1.1'";
return {
cql: "library AdvancedIllnessandFrailtyExclusion version '1.0.001'\nusing QI-Core version '4.1.1'",
isLibraryStatementChanged: true,
isUsingStatementChanged: false,
isValueSetChanged: false,
};
});

isUsingEmpty.mockClear().mockImplementation(() => false);
Expand All @@ -421,7 +439,7 @@ describe("MeasureEditor component", () => {
const saveButton = screen.getByRole("button", { name: "Save" });
userEvent.click(saveButton);
const saveSuccess = await screen.findByText(
"CQL updated successfully! Library Statement or Using Statement were incorrect. MADiE has overwritten them to ensure proper CQL."
"CQL updated successfully but the following issues were found"
);
expect(saveSuccess).toBeInTheDocument();
expect(mockedAxios.put).toHaveBeenCalledTimes(1);
Expand All @@ -443,7 +461,12 @@ describe("MeasureEditor component", () => {
(synchingEditorCqlContent as jest.Mock)
.mockClear()
.mockImplementation(() => {
return "library AdvancedIllnessandFrailtyExclusion version '1.0.001'\nusing QI-Core version '4.1.1'";
return {
cql: "library AdvancedIllnessandFrailtyExclusion version '1.0.001'\nusing QI-Core version '4.1.1'",
isLibraryStatementChanged: true,
isUsingStatementChanged: true,
isValueSetChanged: false,
};
});

isUsingEmpty.mockClear().mockImplementation(() => false);
Expand All @@ -463,7 +486,7 @@ describe("MeasureEditor component", () => {
const saveButton = screen.getByRole("button", { name: "Save" });
userEvent.click(saveButton);
const saveSuccess = await screen.findByText(
"CQL updated successfully! Library Statement or Using Statement were incorrect. MADiE has overwritten them to ensure proper CQL."
"CQL updated successfully but the following issues were found"
);
expect(saveSuccess).toBeInTheDocument();
expect(mockedAxios.put).toHaveBeenCalledTimes(1);
Expand Down
66 changes: 42 additions & 24 deletions src/components/editMeasure/editor/MeasureEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ const MeasureEditor = () => {
// set success message
const [success, setSuccess] = useState({
status: undefined,
message: undefined,
primaryMessage: undefined,
secondaryMessages: undefined,
});
const [error, setError] = useState(false);
// const [elmTranslationError, setElmTranslationError] = useState(null); // should not be own error, modified to error message
Expand Down Expand Up @@ -279,12 +280,13 @@ const MeasureEditor = () => {
setProcessing(true);
setSuccess({
status: undefined,
message: undefined,
primaryMessage: undefined,
secondaryMessages: undefined,
});
//Get model name and version
const using = measure?.model.split(" v");

const inSyncCql = await synchingEditorCqlContent(
const updatedCqlObj = await synchingEditorCqlContent(
editorValue,
measure?.cql,
measure?.cqlLibraryName,
Expand All @@ -296,8 +298,8 @@ const MeasureEditor = () => {
);

const results = await Promise.allSettled([
updateElmAnnotations(inSyncCql),
hasParserErrors(inSyncCql),
updateElmAnnotations(updatedCqlObj.cql),
hasParserErrors(updatedCqlObj.cql),
]);

if (results[0].status === "rejected") {
Expand Down Expand Up @@ -331,7 +333,7 @@ const MeasureEditor = () => {
const cqlErrors = parseErrors || cqlElmErrors;
const newMeasure: Measure = {
...measure,
cql: inSyncCql,
cql: updatedCqlObj.cql,
elmJson:
validationResult && JSON.stringify(validationResult?.translation),
cqlErrors,
Expand Down Expand Up @@ -368,24 +370,36 @@ const MeasureEditor = () => {
setCodeMap(new Map<string, Code>());
setEditorVal(newMeasure?.cql);
setIsCQLUnchanged(true);
if (isUsingEmpty(editorValue)) {
setSuccess({
status: "success",
message:
"CQL updated successfully but was missing a Using statement. Please add in a valid model and version.",
});
} else {
const successMessage =
inSyncCql !== editorValue
? {
status: "success",
message:
"CQL updated successfully! Library Statement or Using Statement were incorrect. MADiE has overwritten them to ensure proper CQL.",
}
: { status: "success", message: "CQL saved successfully" };

setSuccess(successMessage);
let primaryMessage = "CQL updated successfully";
const secondaryMessages = [];
if (isUsingEmpty(editorVal)) {
secondaryMessages.push(
"Missing a using statement. Please add in a valid model and version."
);
}
if (updatedCqlObj.isLibraryStatementChanged) {
secondaryMessages.push(
"Library statement was incorrect. MADiE has overwritten it."
);
}
if (updatedCqlObj.isUsingStatementChanged) {
secondaryMessages.push(
"Using statement was incorrect. MADiE has overwritten it."
);
}
if (updatedCqlObj.isValueSetChanged) {
secondaryMessages.push(
"MADiE does not currently support use of value set version directly in measures at this time. Your value set versions have been removed. Please use the relevant manifest for value set expansion for testing."
);
}
if (secondaryMessages.length > 0) {
primaryMessage += " but the following issues were found";
}
setSuccess({
status: "success",
primaryMessage,
secondaryMessages,
});
if (codeName) {
setToastMessage(
`code ${codeName} ${
Expand Down Expand Up @@ -533,7 +547,11 @@ const MeasureEditor = () => {
[handleApplyValueSet]
);
const handleMadieEditorValue = (val: string) => {
setSuccess({ status: undefined, message: undefined });
setSuccess({
status: undefined,
primaryMessage: undefined,
secondaryMessages: undefined,
});
setError(false);
setEditorVal(val);
setValuesetMsg(null);
Expand Down
2 changes: 1 addition & 1 deletion src/components/editMeasure/editor/StatusHandler.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
line-height: normal;
}
.secondary {
margin-bottom: 5px;
margin-bottom: 12px;
~ ul,
~ ol {
margin-bottom: 0;
Expand Down
Loading
Loading