-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #732 from MeasureAuthoringTool/MAT-7864
MAT-7864 SPIKE/POC: How to Display Extensions as First Level Elements
- Loading branch information
Showing
13 changed files
with
1,384 additions
and
31 deletions.
There are no files selected for viewing
977 changes: 977 additions & 0 deletions
977
...easure/testCases/__mocks__/structuredDefinitions/StructureDefinition-us-core-ethnicity.ts
Large diffs are not rendered by default.
Oops, something went wrong.
4 changes: 3 additions & 1 deletion
4
src/components/editMeasure/testCases/api/models/StructureDefinitionDto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { StructureDefinition } from "fhir/r4"; | ||
|
||
export interface StructureDefinitionDto { | ||
resourceName: string; | ||
category: string; | ||
primaryCodePath: string; | ||
definition: string; | ||
definition: StructureDefinition; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...es/components/editTestCase/qiCore/LeftPanel/ElementsTab/builder/element/ElementEditor.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
...nents/editTestCase/qiCore/LeftPanel/ElementsTab/builder/element/SlicedExtensions.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import * as React from "react"; | ||
import { structuredDefinitionUSCoreEthnicity } from "../../../../../../../__mocks__/structuredDefinitions/StructureDefinition-us-core-ethnicity"; | ||
import { render, screen, waitFor } from "@testing-library/react"; | ||
import TypeEditor from "./TypeEditor"; | ||
import axios from "../../../../../../../../../../api/axios-instance"; | ||
import { FormikProvider } from "formik"; | ||
import { | ||
ApiContextProvider, | ||
ServiceConfig, | ||
} from "../../../../../../../../../../api/ServiceContext"; | ||
|
||
jest.mock("../../../../../../../../../../api/axios-instance"); | ||
const mockedAxios = axios as jest.Mocked<typeof axios>; | ||
|
||
jest.mock("@madie/madie-util", () => ({ | ||
useOktaTokens: jest.fn(() => ({ | ||
getAccessToken: () => "test.jwt", | ||
})), | ||
})); | ||
|
||
const mockServiceConfig = { | ||
fhirService: { | ||
baseUrl: "string", | ||
}, | ||
} as ServiceConfig; | ||
|
||
jest.mock("../../../../../../../../../../api/useServiceConfig", () => { | ||
return jest.fn(() => mockServiceConfig); | ||
}); | ||
|
||
const getNestedProperty = (obj, path) => { | ||
return path.split(".").reduce((current, key) => current && current[key], obj); | ||
}; | ||
|
||
const patientResource = { | ||
Patient: { | ||
"extention:ethnicity": undefined, | ||
}, | ||
}; | ||
|
||
//@ts-ignore | ||
const mockFormik: FormikContextType<any> = { | ||
values: { | ||
...patientResource, | ||
}, | ||
getFieldProps: (label) => { | ||
const name = getNestedProperty(patientResource, label); | ||
return { | ||
value: name, | ||
name, | ||
onChange: jest.fn(), | ||
onBlur: jest.fn(), | ||
}; | ||
}, | ||
handleChange: () => {}, | ||
setFieldValue: jest.fn(), | ||
}; | ||
|
||
describe("TypeEditor for profiled extensions/slices ", () => { | ||
it("should render form for Patient.extension:ethnicity", async () => { | ||
const handleChange = jest.fn(); | ||
const label = "Patient.extension:ethnicity"; | ||
const resource = { | ||
id: "dc41859f8107", | ||
resourceType: "Patient", | ||
meta: { | ||
profile: [ | ||
"http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient", | ||
], | ||
}, | ||
}; | ||
const qiCoreEthnicityStructureDefinition = { | ||
id: "Patient.extension:ethnicity", | ||
min: 0, | ||
max: 1, | ||
path: "Patient.extension", | ||
short: "(QI-Core)(USCDI) US Core ethnicity Extension", | ||
sliceName: "ethnicity", | ||
type: [ | ||
{ | ||
code: "Extension", | ||
profile: [ | ||
"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity", | ||
], | ||
}, | ||
], | ||
}; | ||
mockedAxios.get.mockResolvedValue({ | ||
data: { definition: structuredDefinitionUSCoreEthnicity }, | ||
}); | ||
|
||
render( | ||
<ApiContextProvider value={mockServiceConfig}> | ||
<FormikProvider value={mockFormik}> | ||
<TypeEditor | ||
type="Extension" | ||
resource={resource} | ||
required={false} | ||
value={undefined} | ||
onChange={handleChange} | ||
structureDefinition={qiCoreEthnicityStructureDefinition} | ||
parentStructureDefinition={null} | ||
label={label} | ||
canEdit={true} | ||
/> | ||
</FormikProvider> | ||
</ApiContextProvider> | ||
); | ||
await waitFor(() => { | ||
expect(screen.getByTestId("string-field-input-id")).toBeInTheDocument(); | ||
}); | ||
expect(screen.getByTestId("extension:ombCategory")).toBeInTheDocument(); | ||
expect(screen.getByTestId("extension:detailed")).toBeInTheDocument(); | ||
expect(screen.getByTestId("extension:text")).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.