Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' into MAT-7732-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmcphillips authored Oct 29, 2024
2 parents 0901d09 + 5908eed commit f85203b
Show file tree
Hide file tree
Showing 17 changed files with 535 additions and 131 deletions.
57 changes: 37 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"blueimp-md5": "^2.19.0",
"classnames": "^2.3.1",
"cqm-execution": "4.2.3",
"cqm-models": "^4.1.3",
"cqm-models": "^4.1.5",
"dayjs": "^1.11.7",
"fhir": "^4.11.1",
"file-saver": "^2.0.5",
Expand Down
18 changes: 10 additions & 8 deletions src/api/TestCaseServiceApi.test.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
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,
MeasureScoring,
Model,
PopulationType,
TestCase,
TestCaseExcelExportDto,
} from "@madie/madie-models";
import { waitFor } from "@testing-library/react";
import { addValues } from "../util/DefaultValueProcessor";
Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
10 changes: 8 additions & 2 deletions src/api/useTestCaseServiceApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,16 @@ export class TestCaseServiceApi {
}
}

async getTestCase(testCaseId: string, measureId: string): Promise<TestCase> {
async getTestCase(
testCaseId: string,
measureId: string,
validateTest: boolean
): Promise<TestCase> {
try {
const response = await axios.get<TestCase>(
`${this.baseUrl}/measures/${measureId}/test-cases/${testCaseId}`,
{
params: { validate: validateTest },
headers: {
Authorization: `Bearer ${this.getAccessToken()}`,
},
Expand Down Expand Up @@ -207,12 +212,13 @@ export class TestCaseServiceApi {
);
}

async validateTestCaseBundle(bundle: any) {
async validateTestCaseBundle(bundle: any, model: string) {
try {
const response = await axios.post<HapiOperationOutcome>(
`${this.baseUrl}/validations/bundles`,
bundle,
{
params: { model: model },
headers: {
Authorization: `Bearer ${this.getAccessToken()}`,
},
Expand Down
8 changes: 4 additions & 4 deletions src/components/common/quantityInput/QuantityInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ describe("QuantityInput Component", () => {
expect(quantityFieldInput.value).toBe("");
expect(onQuantityChange).toBeCalled();
userEvent.type(quantityFieldInput, "-1-");
await expect(onQuantityChange).toHaveBeenNthCalledWith(2, {
expect(onQuantityChange).toHaveBeenNthCalledWith(2, {
unit: "mg",
value: "-1",
value: -1,
});
userEvent.type(quantityFieldInput, "2.5/...-");
await expect(onQuantityChange).toHaveBeenNthCalledWith(6, {
expect(onQuantityChange).toHaveBeenNthCalledWith(6, {
unit: "mg",
value: "2.5",
value: 2.5,
});
});
});
2 changes: 1 addition & 1 deletion src/components/common/quantityInput/QuantityInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const QuantityInput = ({

const handleQuantityValueChange = (newValue) => {
const newQuantity: CQL.Quantity = {
value: newValue,
value: Number(newValue),
unit: currentQuantity.unit,
};
setCurrentQuantity(newQuantity);
Expand Down
2 changes: 1 addition & 1 deletion src/components/editTestCase/qdm/EditTestCase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React, { useState } from "react";
import { CQL, DataElement } from "cqm-models";
import { QDMDate, CQL, DataElement } from "cqm-models";
import {
DateField,
TimeField,
Button,
} from "@madie/madie-design-system/dist/react";
import dayjs from "dayjs";
import IntegerInput from "../../../../../../../common/IntegerInput/IntegerInput";
import "./DisplayAttributeInputs.scss";
import RatioInput from "../../../../../../../common/ratioInput/RatioInput";
Expand Down Expand Up @@ -57,27 +56,26 @@ const DisplayAttributeInputs = ({
};
const { cqmMeasureState } = useQdmExecutionContext();
const [cqmMeasure] = cqmMeasureState;

const displayAttributeInput = () => {
switch (attributeType) {
case "Date":
return (
<DateField
label="Date"
value={""}
value={attributeValue}
data-testid="date-input"
handleDateChange={(e) => {
const newDate = dayjs.utc(e);
const newCQLDate: CQL.Date = new CQL.Date(
newDate.year(),
newDate.month() + 1,
newDate.date()
);
handleDateChange={(date) => {
const newCQLDate = new QDMDate().cast({
year: date.year(),
month: date.month() + 1,
day: date.date(),
});
setAttributeValue(newCQLDate);
if (onChangeForComponentType) {
onChangeForComponentType(newCQLDate);
}
}}
onBlur={() => {}}
/>
);
case "DateTime":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import DateTimeInput from "../../../../../../../common/dateTimeInput/DateTimeInput";
import DateTimeInterval from "../../../../../../../common/dateTimeInterval/DateTimeInterval";
import { CQL } from "cqm-models";
import { QDMDate } from "cqm-models";
import "./Timing.scss";
import { PRIMARY_TIMING_ATTRIBUTES } from "../../../../../../../../util/QdmAttributeHelpers";
import * as _ from "lodash";
Expand All @@ -24,11 +24,10 @@ const Timing = ({ canEdit, onChange, selectedDataElement }) => {
const dateFormatToDisplay = (date) => {
if (date) {
const currentDate = dayjs();
const dayjsDate = dayjs(currentDate)
return dayjs(currentDate)
.set("year", date?.year)
.set("month", date?.month)
.set("month", date?.month - 1)
.set("date", date?.day);
return dayjsDate;
}
return;
};
Expand Down Expand Up @@ -82,11 +81,11 @@ const Timing = ({ canEdit, onChange, selectedDataElement }) => {
) || null
}
onChange={(newValue: any) => {
const newDate = new CQL.Date(
newValue.$y,
newValue.$M + 1,
newValue.$D
);
const newDate = new QDMDate().cast({
year: newValue.$y,
month: newValue.$M + 1,
day: newValue.$D,
});
handleChange(newDate, timingAttr.path);
}}
/>
Expand Down
8 changes: 5 additions & 3 deletions src/components/editTestCase/qiCore/EditTestCase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,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);
Expand Down Expand Up @@ -530,7 +530,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)) {
Expand Down Expand Up @@ -565,7 +566,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);
Expand Down
Loading

0 comments on commit f85203b

Please sign in to comment.