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

Iron man hotfix mat 6515 #519

Merged
merged 3 commits into from
Dec 8, 2023
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: 4 additions & 0 deletions src/api/CqmModelConversionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
PopulationSet,
MeasurePeriod,
ValueSet,
CodeSystem,
} from "cqm-models";
import { ServiceConfig } from "./ServiceContext";
import useServiceConfig from "./useServiceConfig";
Expand Down Expand Up @@ -282,6 +283,9 @@
elmJson.library?.valueSets?.def.forEach((valueSet: ValueSet) => {
valueSet.id = valueSet.id.replace("urn:oid:", "");
});
elmJson.library?.codeSystems?.def.forEach((codeSystem: CodeSystem) => {
codeSystem.id = codeSystem.id.replace("urn:oid:", "");

Check warning on line 287 in src/api/CqmModelConversionService.ts

View check run for this annotation

Codecov / codecov/patch

src/api/CqmModelConversionService.ts#L287

Added line #L287 was not covered by tests
});
const cqlLibrary = new CQLLibrary();
cqlLibrary.library_name = elmJson.library?.identifier.id;
cqlLibrary.library_version = elmJson.library?.identifier.version;
Expand Down
29 changes: 17 additions & 12 deletions src/api/TerminologyServiceApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { officeVisitValueSet } from "./__mocks__/OfficeVisitValueSet";
import { officeVisitMeasureBundle } from "./__mocks__/OfficeVisitMeasureBundle";
import { cqm_measure_basic } from "../mockdata/qdm/CMS108/cqm_measure_basic";
import { cqm_measure_basic_valueset } from "../mockdata/qdm/CMS108/cqm_measure_basic_valueset";
import { Measure as CqmMeasure } from "cqm-models";
import { Measure as CqmMeasure, ValueSet } from "cqm-models";
import * as _ from "lodash";

jest.mock("axios");
Expand Down Expand Up @@ -81,7 +81,7 @@ describe("TerminologyServiceApi Tests", () => {

terminologyService
.getQdmValueSetsExpansion(cqm_measure_basic)
.then((data) => {
.then((data: ValueSet[]) => {
expect(data.length).toEqual(2);
expect(data[0].display_name).toEqual("Encounter Inpatient");
expect(data[0].oid).toEqual("2.16.840.1.113883.3.666.5.307");
Expand Down Expand Up @@ -136,15 +136,18 @@ describe("TerminologyServiceApi Tests", () => {
const result = terminologyService.getCqlCodesForDRCs(cqm_measure_basic);
expect(result.length).toBe(3);

expect(result[0].code).toBe("drc-bdb8b89536181a411ad034378b7ceef6");
expect(result[0].system).toBe("LOINC");
expect(result[0].display).toBe("Housing status");
expect(result[1].code).toBe("160734000");
expect(result[1].system).toBe("SNOMEDCT");
expect(result[1].display).toBe("Lives in a nursing home (finding)");
expect(result[2].code).toBe("98181-1");
expect(result[2].system).toBe("LOINC");
expect(result[2].display).toBe("Medical equipment used");
expect(result[0].cqlCode.code).toBe("drc-bdb8b89536181a411ad034378b7ceef6");
expect(result[0].cqlCode.system).toBe("LOINC");
expect(result[0].cqlCode.display).toBe("Housing status");
expect(result[0].codeSystemOid).toBe("2.16.840.1.113883.6.1");
expect(result[1].cqlCode.code).toBe("160734000");
expect(result[1].cqlCode.system).toBe("SNOMEDCT");
expect(result[1].cqlCode.display).toBe("Lives in a nursing home (finding)");
expect(result[1].codeSystemOid).toBe("2.16.840.1.113883.6.96");
expect(result[2].cqlCode.code).toBe("98181-1");
expect(result[2].cqlCode.system).toBe("LOINC");
expect(result[2].cqlCode.display).toBe("Medical equipment used");
expect(result[2].codeSystemOid).toBe("2.16.840.1.113883.6.1");
});

it("test getCqlCodesForDRCs no codes", () => {
Expand All @@ -161,7 +164,8 @@ describe("TerminologyServiceApi Tests", () => {
});

it("test getValueSetsForDRCs", () => {
const result = terminologyService.getValueSetsForDRCs(cqm_measure_basic);
const result: ValueSet[] =
terminologyService.getValueSetsForDRCs(cqm_measure_basic);

expect(result.length).toBe(1);

Expand All @@ -171,6 +175,7 @@ describe("TerminologyServiceApi Tests", () => {
);
expect(result[0].concepts[0].code_system_name).toBe("LOINC");
expect(result[0].concepts[0].display_name).toBe("Housing status");
expect(result[0].concepts[0].code_system_oid).toBe("2.16.840.1.113883.6.1");
});

it("test getValueSetsForDRCs no value sets", () => {
Expand Down
30 changes: 22 additions & 8 deletions src/api/useTerminologyServiceApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ type ValueSetsSearchCriteria = {
valueSetParams: ValueSetSearchParams[];
};

type CQLCodeWithCodeSystemOid = {
cqlCode: CQL.CQLCode;
codeSystemOid: string;
};

export class TerminologyServiceApi {
constructor(private baseUrl: string, private getAccessToken: () => string) {}

Expand Down Expand Up @@ -173,9 +178,10 @@ export class TerminologyServiceApi {

getValueSetsForDRCs(cqmMeasure: CqmMeasure): ValueSet[] {
const drcValueSets = [];
const cqlCodes: CQL.CQLCode[] = this.getCqlCodesForDRCs(cqmMeasure);
if (cqlCodes) {
cqlCodes.forEach((cqlCode) => {
const cqlCodeWithCodeSystemOid: CQLCodeWithCodeSystemOid[] =
this.getCqlCodesForDRCs(cqmMeasure);
if (cqlCodeWithCodeSystemOid) {
cqlCodeWithCodeSystemOid.forEach(({ cqlCode, codeSystemOid }) => {
const drcOid = this.getDrcOid(cqmMeasure, cqlCode.code);
if (drcOid) {
const valueSet = {
Expand All @@ -184,7 +190,7 @@ export class TerminologyServiceApi {
concepts: [
{
code: cqlCode.code,
code_system_oid: cqlCode.system,
code_system_oid: codeSystemOid,
code_system_name: cqlCode.system,
code_system_version: cqlCode.version,
display_name: cqlCode.display,
Expand All @@ -199,23 +205,31 @@ export class TerminologyServiceApi {
return drcValueSets;
}

getCqlCodesForDRCs(cqmMeasure: CqmMeasure): CQL.CQLCode[] {
const cqlCodes: CQL.CQLCode[] = [];
getCqlCodesForDRCs(cqmMeasure: CqmMeasure): CQLCodeWithCodeSystemOid[] {
const cqlCodeWithCodeSystemOid: CQLCodeWithCodeSystemOid[] = [];
cqmMeasure?.cql_libraries?.forEach((library) => {
const codeDefs = library?.elm?.library?.codes?.def;
const codeSystemDefs = library?.elm?.library?.codeSystems?.def;
if (!_.isEmpty(codeDefs)) {
codeDefs.forEach((def) => {
// find associated CodeSystem for this code, so that we can get codeSystem oid
const codeSystem = codeSystemDefs.find(
(cs) => cs.name === def.codeSystem.name
);
const cqlCode = new CQL.Code(
def?.id, //code
def.codeSystem.name, //system
"N/A", //version,
def.display //display
);
cqlCodes.push(cqlCode);
cqlCodeWithCodeSystemOid.push({
cqlCode: cqlCode,
codeSystemOid: codeSystem.id,
});
});
}
});
return cqlCodes;
return cqlCodeWithCodeSystemOid;
}

getDrcOid(cqmMeasure: CqmMeasure, code: string): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,37 @@ export const RACE_CODE_OPTIONS: DataElementCode[] = [
{
code: "1002-5",
display: "American Indian or Alaska Native",
version: "1.2",
version: undefined,
system: "2.16.840.1.113883.6.238",
},
{
code: "2028-9",
display: "Asian",
version: "1.2",
version: undefined,
system: "2.16.840.1.113883.6.238",
},
{
code: "2054-5",
display: "Black or African American",
version: "1.2",
version: undefined,
system: "2.16.840.1.113883.6.238",
},
{
code: "2076-8",
display: "Native Hawaiian or Other Pacific Islander",
version: "1.2",
version: undefined,
system: "2.16.840.1.113883.6.238",
},
{
code: "2106-3",
display: "White",
version: "1.2",
version: undefined,
system: "2.16.840.1.113883.6.238",
},
{
code: "2131-1",
display: "Other Race",
version: "1.2",
version: undefined,
system: "2.16.840.1.113883.6.238",
},
];
Expand All @@ -59,13 +59,13 @@ export const GENDER_CODE_OPTIONS: DataElementCode[] = [
{
code: "F",
display: "Female",
version: "2022-11",
version: undefined,
system: "2.16.840.1.113883.5.1",
},
{
code: "M",
display: "Male",
version: "2022-11",
version: undefined,
system: "2.16.840.1.113883.5.1",
},
];
Expand All @@ -74,13 +74,13 @@ export const ETHNICITY_CODE_OPTIONS: DataElementCode[] = [
{
code: "2135-2",
display: "Hispanic or Latino",
version: "1.2",
version: undefined,
system: "2.16.840.1.113883.6.238",
},
{
code: "2186-5",
display: "Not Hispanic or Latino",
version: "1.2",
version: undefined,
system: "2.16.840.1.113883.6.238",
},
];
Expand Down
26 changes: 26 additions & 0 deletions src/mockdata/qdm/CMS108/cqm_measure_basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,32 @@ export const cqm_measure_basic = {
},
],
},
{
localId: "5",
locator: "9:1-9:55",
name: "SNOMEDCT",
id: "2.16.840.1.113883.6.96",
accessLevel: "Public",
annotation: [
{
type: "Annotation",
s: {
r: "5",
s: [
{
value: [
"",
"codesystem ",
'"SNOMEDCT"',
": ",
"'urn:oid:2.16.840.1.113883.6.96'",
],
},
],
},
},
],
},
],
},
valueSets: {
Expand Down
Loading