Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 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
@@ -1,6 +1,6 @@
{
"name": "@madie/madie-models",
"version": "1.4.72",
"version": "1.4.73",
"description": "Models for MADiE Project",
"scripts": {
"build": "tsc",
Expand Down
10 changes: 10 additions & 0 deletions src/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,13 @@ export function getModelShortName(model: string): string {
export function isFhirModel(model: string | undefined | null): boolean {
return Boolean(model) && model !== Model.QDM_5_6;
}

/**
* Returns the model family used in export artifact names: "QDM" for QDM models,
* "FHIR" for every FHIR-based model (QI-Core, US-Core, US Quality Core).
*/
export function getModelFamily(model: string): string | undefined {
if (model) {
return isFhirModel(model) ? "FHIR" : "QDM";
}
}
28 changes: 26 additions & 2 deletions src/__tests__/Model.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { Model, MODEL_SHORT_NAMES, getModelShortName, isFhirModel } from "../Model";
import {
Model,
MODEL_SHORT_NAMES,
getModelShortName,
isFhirModel,
getModelFamily,
} from "../Model";

test("Verifies that Model has the correct attributes", () => {
expect(Model.QICORE.valueOf()).toEqual("QI-Core v4.1.1");
Expand All @@ -25,7 +31,9 @@ test("getModelShortName returns correct shortNames", () => {
});

test("getModelShortName throws for an unknown model string", () => {
expect(() => getModelShortName("Unknown Model v1.0")).toThrow("Unknown model");
expect(() => getModelShortName("Unknown Model v1.0")).toThrow(
"Unknown model"
);
});

test("isFhirModel returns true for all non-QDM models", () => {
Expand All @@ -42,3 +50,19 @@ test("isFhirModel returns false for QDM and empty/falsy values", () => {
expect(isFhirModel("")).toBe(false);
expect(isFhirModel(undefined)).toBe(false);
});

test("getModelFamily returns FHIR for every FHIR-based model", () => {
expect(getModelFamily(Model.QICORE)).toBe("FHIR");
expect(getModelFamily(Model.QICORE_6_0_0)).toBe("FHIR");
expect(getModelFamily(Model.FHIR_4_0_1)).toBe("FHIR");
expect(getModelFamily(Model.US_CORE_6_1_0)).toBe("FHIR");
expect(getModelFamily(Model.US_QUALITY_0_5_0)).toBe("FHIR");
});

test("getModelFamily returns QDM for QDM models", () => {
expect(getModelFamily(Model.QDM_5_6)).toBe("QDM");
});

test("getModelFamily returns undefined for empty model", () => {
expect(getModelFamily("")).toBeUndefined();
});
Loading