diff --git a/src/api/TestCaseServiceApi.test.tsx b/src/api/TestCaseServiceApi.test.tsx index 7e399764e..1bc590d12 100644 --- a/src/api/TestCaseServiceApi.test.tsx +++ b/src/api/TestCaseServiceApi.test.tsx @@ -1,6 +1,9 @@ import { AxiosError, AxiosResponse } from "axios"; import axios from "./axios-instance"; -import { TestCaseServiceApi } from "./useTestCaseServiceApi"; +import { + QrdaGroupExportDTO, + TestCaseServiceApi, +} from "./useTestCaseServiceApi"; import { ScanValidationDto } from "./models/ScanValidationDto"; import { Measure, @@ -8,7 +11,6 @@ import { Model, PopulationType, TestCase, - TestCaseExcelExportDto, } from "@madie/madie-models"; import { waitFor } from "@testing-library/react"; import { addValues } from "../util/DefaultValueProcessor"; @@ -236,14 +238,14 @@ describe("TestCaseServiceApi Tests", () => { const resp = { status: 200, data: zippedQRDAData }; axios.put = jest.fn().mockResolvedValueOnce(resp); - const testCaseDtos: TestCaseExcelExportDto[] = [ + const groupDTOs: QrdaGroupExportDTO[] = [ { groupId: "1", - } as TestCaseExcelExportDto, + } as QrdaGroupExportDTO, ]; const qrdaData = await testCaseService.exportQRDA("testMeasureId", { measure: mockMeasure, - groupDTOs: testCaseDtos, + groupDTOs: groupDTOs, }); expect(axios.put).toBeCalledTimes(1); expect(qrdaData).toEqual(zippedQRDAData); @@ -255,15 +257,15 @@ describe("TestCaseServiceApi Tests", () => { }; axios.put = jest.fn().mockRejectedValueOnce(resp); - const testCaseDtos: TestCaseExcelExportDto[] = [ + const groupDTOs: QrdaGroupExportDTO[] = [ { groupId: "1", - } as TestCaseExcelExportDto, + } as QrdaGroupExportDTO, ]; try { await testCaseService.exportQRDA("testMeasureId", { measure: mockMeasure, - groupDTOs: testCaseDtos, + groupDTOs: groupDTOs, }); expect(axios.put).toBeCalledTimes(1); } catch (error) { diff --git a/src/api/useTestCaseServiceApi.ts b/src/api/useTestCaseServiceApi.ts index 99f3fc284..940dbd2f5 100644 --- a/src/api/useTestCaseServiceApi.ts +++ b/src/api/useTestCaseServiceApi.ts @@ -77,11 +77,16 @@ export class TestCaseServiceApi { } } - async getTestCase(testCaseId: string, measureId: string): Promise { + async getTestCase( + testCaseId: string, + measureId: string, + validateTest: boolean + ): Promise { try { const response = await axios.get( `${this.baseUrl}/measures/${measureId}/test-cases/${testCaseId}`, { + params: { validate: validateTest }, headers: { Authorization: `Bearer ${this.getAccessToken()}`, }, @@ -207,12 +212,13 @@ export class TestCaseServiceApi { ); } - async validateTestCaseBundle(bundle: any) { + async validateTestCaseBundle(bundle: any, model: string) { try { const response = await axios.post( `${this.baseUrl}/validations/bundles`, bundle, { + params: { model: model }, headers: { Authorization: `Bearer ${this.getAccessToken()}`, }, diff --git a/src/components/editTestCase/qdm/EditTestCase.tsx b/src/components/editTestCase/qdm/EditTestCase.tsx index b62a1b186..80d4b7ea7 100644 --- a/src/components/editTestCase/qdm/EditTestCase.tsx +++ b/src/components/editTestCase/qdm/EditTestCase.tsx @@ -134,7 +134,7 @@ const EditTestCase = () => { useEffect(() => { if (measure && measureId && id) { testCaseService.current - .getTestCase(id, measureId) + .getTestCase(id, measureId, false) .then((tc: TestCase) => { const nextTc = _.cloneDeep(tc); if (measure?.groups) { diff --git a/src/components/editTestCase/qiCore/EditTestCase.tsx b/src/components/editTestCase/qiCore/EditTestCase.tsx index e3153a183..cb8c9fab0 100644 --- a/src/components/editTestCase/qiCore/EditTestCase.tsx +++ b/src/components/editTestCase/qiCore/EditTestCase.tsx @@ -375,7 +375,7 @@ const EditTestCase = (props: EditTestCaseProps) => { const loadTestCase = () => { testCaseService.current - .getTestCase(id, measureId) + .getTestCase(id, measureId, true) .then((tc: TestCase) => { const nextTc = _.cloneDeep(tc); nextTc.json = standardizeJson(nextTc); @@ -542,7 +542,8 @@ const EditTestCase = (props: EditTestCaseProps) => { // Validate test case JSON prior to execution const validationResult = await testCaseService.current.validateTestCaseBundle( - JSON.parse(editorVal) + JSON.parse(editorVal), + measure.model ); const errors = handleHapiOutcome(validationResult); if (!_.isNil(errors) && errors.length > 0 && hasErrorSeverity(errors)) { @@ -577,7 +578,8 @@ const EditTestCase = (props: EditTestCaseProps) => { const executionResults = calculationOutput.results; const validationResult = await testCaseService.current.validateTestCaseBundle( - JSON.parse(editorVal) + JSON.parse(editorVal), + measure.model ); handleHapiOutcome(validationResult); setCalculationErrors(undefined);