Skip to content

Commit d877c8e

Browse files
committed
Full class rename and browserify
1 parent 4912b9f commit d877c8e

File tree

16 files changed

+138
-91
lines changed

16 files changed

+138
-91
lines changed

examples/browser/cql4browsers.js

Lines changed: 88 additions & 29 deletions
Large diffs are not rendered by default.

src/cql-code-service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Code, ValueSetExpansion } from './datatypes/datatypes';
1+
import { Code, ValueSet } from './datatypes/datatypes';
22
import { TerminologyProvider, ValueSetDictionary, ValueSetObject } from './types';
33

44
export class CodeService implements TerminologyProvider {
@@ -12,16 +12,16 @@ export class CodeService implements TerminologyProvider {
1212
const codes = valueSetsJson[oid][version].map(
1313
(code: any) => new Code(code.code, code.system, code.version)
1414
);
15-
this.valueSets[oid][version] = new ValueSetExpansion(oid, version, codes);
15+
this.valueSets[oid][version] = new ValueSet(oid, version, codes);
1616
}
1717
}
1818
}
1919

20-
findValueSetsByOid(oid: string): ValueSetExpansion[] {
20+
findValueSetsByOid(oid: string): ValueSet[] {
2121
return this.valueSets[oid] ? Object.values(this.valueSets[oid]) : [];
2222
}
2323

24-
findValueSet(oid: string, version?: string): ValueSetExpansion | null {
24+
findValueSet(oid: string, version?: string): ValueSet | null {
2525
if (version != null) {
2626
return this.valueSets[oid] != null ? this.valueSets[oid][version] : null;
2727
} else {

src/cql.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
Interval,
2626
Quantity,
2727
Ratio,
28-
ValueSet
28+
CQLValueSet
2929
} from './datatypes/datatypes';
3030

3131
import { AnnotatedError } from './util/customErrors';
@@ -56,7 +56,7 @@ export {
5656
Interval,
5757
Quantity,
5858
Ratio,
59-
ValueSet
59+
CQLValueSet
6060
};
6161

6262
export default {
@@ -82,5 +82,5 @@ export default {
8282
Interval,
8383
Quantity,
8484
Ratio,
85-
ValueSet
85+
CQLValueSet
8686
};

src/datatypes/clinical.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class CodeSystem extends Vocabulary {
4545
}
4646
}
4747

48-
export class ValueSet extends Vocabulary {
48+
export class CQLValueSet extends Vocabulary {
4949
constructor(
5050
public id: string,
5151
public version?: string,
@@ -60,7 +60,7 @@ export class ValueSet extends Vocabulary {
6060
}
6161
}
6262

63-
export class ValueSetExpansion {
63+
export class ValueSet {
6464
constructor(public oid: string, public version?: string, public codes: any[] = []) {
6565
this.codes ||= [];
6666
}

src/elm/clinical.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class ValueSetDef extends Expression {
2828
})
2929
);
3030
}
31-
const valueset = new dt.ValueSet(this.id, this.version, this.name, codeSystems);
31+
const valueset = new dt.CQLValueSet(this.id, this.version, this.name, codeSystems);
3232
// ctx.rootContext().set(this.name, valueset); Note (2025): this seems to be unneccesary, remove completely in future if not needed
3333
return valueset;
3434
}
@@ -71,7 +71,7 @@ export class AnyInValueSet extends Expression {
7171
if (codes == null) {
7272
return false;
7373
}
74-
const valueset: dt.ValueSet = await this.valueset.execute(ctx);
74+
const valueset: dt.CQLValueSet = await this.valueset.execute(ctx);
7575
if (valueset == null || !valueset.isValueSet) {
7676
throw new Error('ValueSet must be provided to AnyInValueSet expression');
7777
}
@@ -98,7 +98,7 @@ export class InValueSet extends Expression {
9898
if (code == null) {
9999
return false;
100100
}
101-
const valueset: dt.ValueSet = await this.valueset.execute(ctx);
101+
const valueset: dt.CQLValueSet = await this.valueset.execute(ctx);
102102
if (valueset == null || !valueset.isValueSet) {
103103
throw new Error('ValueSet must be provided to InValueSet expression');
104104
}
@@ -117,7 +117,7 @@ export class ExpandValueSet extends Expression {
117117
}
118118

119119
async exec(ctx: Context) {
120-
const valueset: dt.ValueSet = await this.valueset.execute(ctx);
120+
const valueset: dt.CQLValueSet = await this.valueset.execute(ctx);
121121
if (valueset == null) {
122122
return null;
123123
} else if (!valueset.isValueSet) {

src/elm/external.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { resolveValueSet, typeIsArray } from '../util/util';
33
import { Context } from '../runtime/context';
44
import { build } from './builder';
55
import { RetrieveDetails } from '../types/cql-patient.interfaces';
6-
import { Code, ValueSet } from '../datatypes/clinical';
6+
import { Code, CQLValueSet } from '../datatypes/clinical';
77

88
export class Retrieve extends Expression {
99
datatype: string;
@@ -33,7 +33,7 @@ export class Retrieve extends Expression {
3333
};
3434

3535
if (this.codes) {
36-
const executedCodes: Code[] | ValueSet | undefined = await this.codes.execute(ctx);
36+
const executedCodes: Code[] | CQLValueSet | undefined = await this.codes.execute(ctx);
3737

3838
if (executedCodes == null) {
3939
return [];
@@ -43,7 +43,7 @@ export class Retrieve extends Expression {
4343
retrieveDetails.codes = executedCodes as Code[];
4444
} else if (executedCodes) {
4545
// retrieveDetails codes are expected to be expanded for external usage
46-
retrieveDetails.codes = await resolveValueSet(executedCodes as ValueSet, ctx);
46+
retrieveDetails.codes = await resolveValueSet(executedCodes as CQLValueSet, ctx);
4747
} else {
4848
retrieveDetails.codes = undefined;
4949
}

src/elm/overloaded.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as DT from './datetime';
88
import * as LIST from './list';
99
import * as IVL from './interval';
1010
import { Context } from '../runtime/context';
11-
import { ValueSet } from '../datatypes/clinical';
11+
import { CQLValueSet } from '../datatypes/clinical';
1212

1313
export class Equal extends Expression {
1414
constructor(json: any) {
@@ -44,10 +44,10 @@ export class Equivalent extends Expression {
4444
}
4545
}
4646
if (a.isValueSet) {
47-
a = await resolveValueSet(a as ValueSet, ctx);
47+
a = await resolveValueSet(a as CQLValueSet, ctx);
4848
}
4949
if (b.isValueSet) {
50-
b = await resolveValueSet(b as ValueSet, ctx);
50+
b = await resolveValueSet(b as CQLValueSet, ctx);
5151
}
5252
return equivalent(a, b);
5353
}

src/types/cql-code-service.interfaces.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ValueSetExpansion } from '../datatypes/datatypes';
1+
import { ValueSet } from '../datatypes/datatypes';
22

33
/*
44
* Lookup of all codes used based on their ValueSet
@@ -19,17 +19,14 @@ export interface ValueSetDictionary {
1919
*/
2020
export interface ValueSetObject {
2121
[oid: string]: {
22-
[version: string]: ValueSetExpansion;
22+
[version: string]: ValueSet;
2323
};
2424
}
2525

2626
/*
2727
* Structure of an implementation to look up ValueSets based on oid and version
2828
*/
2929
export interface TerminologyProvider {
30-
findValueSetsByOid: (oid: string) => ValueSetExpansion[] | Promise<ValueSetExpansion[]>;
31-
findValueSet: (
32-
oid: string,
33-
version?: string
34-
) => ValueSetExpansion | Promise<ValueSetExpansion> | null;
30+
findValueSetsByOid: (oid: string) => ValueSet[] | Promise<ValueSet[]>;
31+
findValueSet: (oid: string, version?: string) => ValueSet | Promise<ValueSet> | null;
3532
}

src/types/cql-patient.interfaces.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Code, ValueSetExpansion } from '../datatypes/clinical';
1+
import { Code, ValueSet } from '../datatypes/clinical';
22
import { Interval } from '../datatypes/interval';
33
import { AnyTypeSpecifier } from './type-specifiers.interfaces';
44

@@ -31,7 +31,7 @@ export interface RetrieveDetails {
3131
datatype: string;
3232
templateId?: string;
3333
codeProperty?: string;
34-
codes?: Code[] | ValueSetExpansion;
34+
codes?: Code[] | ValueSet;
3535
dateProperty?: string;
3636
dateRange?: Interval;
3737
}

src/util/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ValueSet, ValueSetExpansion } from '../datatypes/clinical';
1+
import { CQLValueSet, ValueSet } from '../datatypes/clinical';
22
import { Context } from '../runtime/context';
33

44
export type Direction = 'asc' | 'ascending' | 'desc' | 'descending';
@@ -111,7 +111,7 @@ async function merge<T>(left: T[], right: T[], compareFn: SortCompareFn<T>) {
111111
return [...sorted, ...left, ...right];
112112
}
113113

114-
export async function resolveValueSet(vs: ValueSet, ctx: Context): Promise<ValueSetExpansion> {
114+
export async function resolveValueSet(vs: CQLValueSet, ctx: Context): Promise<ValueSet> {
115115
// code service owns implementation of any valueset expansion caching
116116
const vsExpansion = await ctx.codeService.findValueSet(vs.id, vs.version);
117117
if (!vsExpansion) {

0 commit comments

Comments
 (0)