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

Commit

Permalink
Merge branch 'develop' into MAT-6431a
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmcphillips authored Nov 27, 2023
2 parents 8ac922c + e29ab67 commit 30afc12
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 67 deletions.
40 changes: 15 additions & 25 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@
"@tanstack/react-table": "^8.9.3",
"allotment": "^1.19.0",
"classnames": "^2.3.1",
"cqm-execution": "4.1.3",
"cqm-models": "^4.1.2",
"cqm-execution": "4.1.4",
"dayjs": "^1.11.7",
"file-saver": "^2.0.5",
"jszip": "^3.10.1",
Expand All @@ -137,7 +136,8 @@
},
"overrides": {
"loader-utils@<2.0.3": "2.0.4",
"dset": "3.1.2"
"dset": "3.1.2",
"axios": "^1.6.1"
},
"types": "dist/madie-madie-patient.d.ts",
"browserslist": [
Expand Down
19 changes: 19 additions & 0 deletions src/api/useTestCaseServiceApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,25 @@ export class TestCaseServiceApi {
}
}

async importTestCasesQDM(
measureId: string,
testCasesImportRequest: TestCaseImportRequest[]
): Promise<TestCase[]> {
try {
return await axios.put(
`${this.baseUrl}/measures/${measureId}/test-cases/imports/qdm`,
testCasesImportRequest,
{
headers: {
Authorization: `Bearer ${this.getAccessToken()}`,
},
}
);
} catch (err) {
throw new Error(`Unable to create new test cases`);
}
}

async scanImportFile(file: any): Promise<ScanValidationDto> {
try {
const formData = new FormData();
Expand Down
2 changes: 0 additions & 2 deletions src/components/common/Identifier/IdentifierInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const IdentifierInput = ({
value={identifier.namingSystem}
label={namingLabel}
disabled={!canEdit}
placeholder={`${namingPlaceholder}`}
id={`identifier-field-${namingPlaceholder}`}
data-testid={`identifier-field-${namingPlaceholder}`}
inputProps={{
Expand All @@ -63,7 +62,6 @@ const IdentifierInput = ({
value={identifier.value}
label={valueLabel}
disabled={!canEdit}
placeholder={`${valueLabel}`}
id={`identifier-value-field-${valueLabel}`}
data-testid={`identifier-value-field-${valueLabel}`}
inputProps={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ import {
Paper,
} from "@mui/material";
import Button from "@mui/material/Button";
import {
processPatientBundlesForQDM,
readImportFile,
} from "../../../../util/FhirImportHelper";
import { readImportFile } from "../../../../util/FhirImportHelper";
import { useDropzone } from "react-dropzone";
import { Toast } from "@madie/madie-design-system/dist/react";
import "./TestCaseImportDialog.css";
import * as _ from "lodash";
import useTestCaseServiceApi from "../../../../api/useTestCaseServiceApi";
import { ScanValidationDto } from "../../../../api/models/ScanValidationDto";
import { TestCaseImportRequest } from "@madie/madie-models";

const TestCaseImportFromBonnieDialogQDM = ({ open, handleClose, onImport }) => {
const [file, setFile] = useState(null);
Expand Down Expand Up @@ -91,6 +89,19 @@ const TestCaseImportFromBonnieDialogQDM = ({ open, handleClose, onImport }) => {
},
});

function processPatientBundlesForQDM(
bonniePatients
): TestCaseImportRequest[] {
const testCases: TestCaseImportRequest[] = [];
for (const patient of bonniePatients) {
testCases.push({
patientId: "",
json: JSON.stringify(patient),
} as TestCaseImportRequest);
}
return testCases;
}

const renderFileDrop = () => {
return (
<Paper style={{ padding: 20 }}>
Expand Down
7 changes: 5 additions & 2 deletions src/components/testCaseLanding/qdm/TestCaseList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ const useTestCaseServiceMockResolved = {
.fn()
.mockResolvedValue(["Series 1", "Series 2"]),
createTestCases: jest.fn().mockResolvedValue([]),
importTestCasesQDM: jest.fn().mockResolvedValue([]),
} as unknown as TestCaseServiceApi;

// mocking measureService
Expand Down Expand Up @@ -1111,7 +1112,7 @@ describe("TestCaseList component", () => {
expect(nextState).toEqual([]);
});

it("should display import error when createTestCases call fails", async () => {
it("should display import error when importTestCasesQDM call fails", async () => {
(checkUserCanEdit as jest.Mock).mockClear().mockImplementation(() => true);
(useFeatureFlags as jest.Mock).mockClear().mockImplementation(() => ({
importTestCases: true,
Expand All @@ -1122,7 +1123,9 @@ describe("TestCaseList component", () => {
getTestCaseSeriesForMeasure: jest
.fn()
.mockResolvedValue(["Series 1", "Series 2"]),
createTestCases: jest.fn().mockRejectedValueOnce(new Error("BAD THINGS")),
importTestCasesQDM: jest
.fn()
.mockRejectedValueOnce(new Error("BAD THINGS")),
} as unknown as TestCaseServiceApi;

useTestCaseServiceMock.mockImplementation(() => {
Expand Down
21 changes: 9 additions & 12 deletions src/components/testCaseLanding/qdm/TestCaseList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import React, { useEffect, useRef, useState } from "react";
import "twin.macro";
import "styled-components/macro";
import * as _ from "lodash";
import { Group, TestCase, MeasureErrorType } from "@madie/madie-models";
import { QDMPatient } from "cqm-models";
import {
Group,
MeasureErrorType,
TestCaseImportRequest,
} from "@madie/madie-models";
import { useParams } from "react-router-dom";
import calculationService from "../../../api/CalculationService";
import { DetailedPopulationGroupResult } from "fqm-execution/build/types/Calculator";
Expand All @@ -26,6 +29,7 @@ import qdmCalculationService, {
CqmExecutionResultsByPatient,
} from "../../../api/QdmCalculationService";
import TestCaseImportFromBonnieDialogQDM from "../common/import/TestCaseImportFromBonnieDialogQDM";
import { QDMPatient, DataElement } from "cqm-models";

export const IMPORT_ERROR =
"An error occurred while importing your test cases. Please try again, or reach out to the Help Desk.";
Expand Down Expand Up @@ -286,22 +290,15 @@ const TestCaseList = (props: TestCaseListProps) => {
? Object.keys(calculationOutput).length
: 0;

const onTestCaseImport = async (testCases: TestCase[]) => {
const onTestCaseImport = async (testCases: TestCaseImportRequest[]) => {
setImportDialogState({ ...importDialogState, open: false });
setLoadingState(() => ({
loading: true,
message: "Importing Test Cases...",
}));
testCases = testCases.map((testCase) => {
if (testCase.json) {
testCase.json = JSON.stringify(
new QDMPatient(JSON.parse(testCase.json))
);
}
return testCase;
});

try {
await testCaseService.current.createTestCases(measureId, testCases);
await testCaseService.current.importTestCasesQDM(measureId, testCases);
retrieveTestCases();
} catch (error) {
setErrors((prevState) => [...prevState, IMPORT_ERROR]);
Expand Down
19 changes: 0 additions & 19 deletions src/util/FhirImportHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,6 @@ export function processPatientBundles(patientBundles): TestCase[] {
return testCases;
}

export function processPatientBundlesForQDM(bonniePatients): TestCase[] {
const testCases: TestCase[] = [];
for (const patient of bonniePatients) {
const familyName = patient?.familyName || "";
const givenName = patient?.givenNames?.[0] || "";

testCases.push({
id: "",
title: givenName,
series: familyName,
description: patient?.notes,
createdAt: new Date().toISOString(),
json: JSON.stringify(patient.qdmPatient, null, 4),
groupPopulations: [],
} as TestCase);
}
return testCases;
}

// TODO: Refactor to dedup with useTestCaseService::readTestCaseFile
export function readImportFile(importFile): Promise<string> {
return new Promise((resolve, reject) => {
Expand Down

0 comments on commit 30afc12

Please sign in to comment.