Skip to content

Commit

Permalink
Merge pull request #739 from MeasureAuthoringTool/MAT-8157/fixedTheAc…
Browse files Browse the repository at this point in the history
…tCodeDeleteBug

MAT-8157 fixed code deletion bug
  • Loading branch information
sb-prateekkeerthi authored Jan 14, 2025
2 parents b931a6e + e4ad2da commit 11662c4
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 8 deletions.
49 changes: 49 additions & 0 deletions src/components/editMeasure/editor/MeasureEditor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1106,4 +1106,53 @@ define function MeasureObservation(e Encounter):
);
});
});

it("should remove cql code successfully for QI Core measures", async () => {
(synchingEditorCqlContent as jest.Mock)
.mockClear()
.mockImplementation(() => {
return {
cql: "library RemoveCodeTest version '0.0.000'\nusing QICore version '4.1.1'",
isLibraryStatementChanged: false,
isUsingStatementChanged: false,
isValueSetChanged: false,
};
});
(validateContent as jest.Mock).mockClear().mockImplementation(() => {
return Promise.resolve({
errors: [],
translation: null,
externalErrors: [],
});
});
const measureWithCqlCodes = {
...measure,
model: Model.QICORE,
cql:
"library RemoveCodeTest version '0.0.000'\n" +
"\n" +
"using QICore version '4.1.1'\n" +
"\n" +
"codesystem \"RXNORM:05022022\": 'http://www.nlm.nih.gov/research/umls/rxnorm' version '05022022'\n" +
"code \"1 ML digoxin 0.1 MG/ML Injection (123)\": '204504' from \"RXNORM:05022022\" display '1 ML digoxin 0.1 MG/ML Injection'",
} as Measure;
const cqlWithNoCodes =
"library RemoveCodeTest version '0.0.000'\nusing QICore version '4.1.1'";
mockedAxios.put.mockImplementation((args) => {
if (args && args.startsWith(serviceConfig.measureService.baseUrl)) {
return Promise.resolve({ data: measureWithCqlCodes });
}
});
renderEditor(measureWithCqlCodes);
const removeCodeBtn = await screen.findByText("Remove code");
expect(removeCodeBtn).toBeInTheDocument();
userEvent.click(removeCodeBtn);
await waitFor(() => {
const editor = screen.getByTestId("measure-editor");
expect(editor).toHaveValue(cqlWithNoCodes);
});
expect(screen.getByTestId("measure-editor-toast")).toHaveTextContent(
"Code 204504 and code system RXNORM has been successfully removed from the CQL"
);
});
});
17 changes: 9 additions & 8 deletions src/components/editMeasure/editor/MeasureEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -636,14 +636,15 @@ const MeasureEditor = () => {
};

const getIncludedCodeWithSystemVersion = (selectedCode, model) => {
if (
(model === Model.QICORE || model === Model.QICORE_6_0_0) &&
selectedCode.codeSystem === "SNOMEDCT"
) {
const url = selectedCode.fhirVersion.replace(/['"]/g, "");
if (selectedCode?.fhirVersion?.startsWith("http://")) {
const parts = url.split("/");
return `${selectedCode.codeSystem}:${parts[parts.length - 1]}`;
if (model === Model.QICORE || model === Model.QICORE_6_0_0) {
if (selectedCode.codeSystem === "SNOMEDCT") {
const url = selectedCode.fhirVersion.replace(/['"]/g, "");
if (selectedCode?.fhirVersion?.startsWith("http://")) {
const parts = url.split("/");
return `${selectedCode.codeSystem}:${parts[parts.length - 1]}`;
}
} else {
return `${selectedCode.codeSystem}:${selectedCode.fhirVersion}`;
}
} else {
return `${selectedCode.codeSystem}:${selectedCode.svsVersion}`;
Expand Down

0 comments on commit 11662c4

Please sign in to comment.