@medplum/core 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -7
- package/dist/cjs/client.d.ts +1 -0
- package/dist/cjs/fhirlexer/parse.d.ts +18 -2
- package/dist/cjs/fhirmapper/parse.d.ts +2 -2
- package/dist/cjs/fhirpath/atoms.d.ts +28 -53
- package/dist/cjs/fhirpath/parse.d.ts +37 -0
- package/dist/cjs/format.d.ts +2 -1
- package/dist/cjs/{index.js → index.cjs} +999 -996
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.min.cjs +1 -0
- package/dist/cjs/search.d.ts +2 -1
- package/dist/esm/{base-schema.json.js → base-schema.json.mjs} +1 -1
- package/dist/esm/{base-schema.json.js.map → base-schema.json.mjs.map} +1 -1
- package/dist/esm/{cache.js → cache.mjs} +2 -2
- package/dist/esm/cache.mjs.map +1 -0
- package/dist/esm/client.d.ts +1 -0
- package/dist/esm/{client.js → client.mjs} +264 -268
- package/dist/esm/client.mjs.map +1 -0
- package/dist/esm/{crypto.js → crypto.mjs} +4 -7
- package/dist/esm/crypto.mjs.map +1 -0
- package/dist/esm/{eventtarget.js → eventtarget.mjs} +2 -2
- package/dist/esm/eventtarget.mjs.map +1 -0
- package/dist/esm/fhirlexer/parse.d.ts +18 -2
- package/dist/esm/fhirlexer/{parse.js → parse.mjs} +35 -10
- package/dist/esm/fhirlexer/parse.mjs.map +1 -0
- package/dist/esm/fhirlexer/{tokenize.js → tokenize.mjs} +12 -12
- package/dist/esm/fhirlexer/tokenize.mjs.map +1 -0
- package/dist/esm/fhirmapper/parse.d.ts +2 -2
- package/dist/esm/fhirpath/atoms.d.ts +28 -53
- package/dist/esm/fhirpath/{atoms.js → atoms.mjs} +79 -62
- package/dist/esm/fhirpath/atoms.mjs.map +1 -0
- package/dist/esm/fhirpath/{date.js → date.mjs} +1 -1
- package/dist/esm/fhirpath/date.mjs.map +1 -0
- package/dist/esm/fhirpath/{functions.js → functions.mjs} +16 -22
- package/dist/esm/fhirpath/functions.mjs.map +1 -0
- package/dist/esm/fhirpath/parse.d.ts +37 -0
- package/dist/esm/fhirpath/{parse.js → parse.mjs} +38 -42
- package/dist/esm/fhirpath/parse.mjs.map +1 -0
- package/dist/esm/fhirpath/{tokenize.js → tokenize.mjs} +4 -4
- package/dist/esm/fhirpath/tokenize.mjs.map +1 -0
- package/dist/esm/fhirpath/{utils.js → utils.mjs} +6 -7
- package/dist/esm/fhirpath/utils.mjs.map +1 -0
- package/dist/esm/format.d.ts +2 -1
- package/dist/esm/{format.js → format.mjs} +29 -21
- package/dist/esm/format.mjs.map +1 -0
- package/dist/esm/{hl7.js → hl7.mjs} +8 -9
- package/dist/esm/hl7.mjs.map +1 -0
- package/dist/esm/index.min.mjs +1 -0
- package/dist/esm/{index.js → index.mjs} +17 -17
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/{jwt.js → jwt.mjs} +1 -1
- package/dist/esm/jwt.mjs.map +1 -0
- package/dist/esm/{match.js → match.mjs} +12 -13
- package/dist/esm/match.mjs.map +1 -0
- package/dist/esm/node_modules/tslib/{tslib.es6.js → tslib.es6.mjs} +2 -12
- package/dist/esm/node_modules/tslib/tslib.es6.mjs.map +1 -0
- package/dist/esm/{outcomes.js → outcomes.mjs} +3 -5
- package/dist/esm/outcomes.mjs.map +1 -0
- package/dist/esm/{readablepromise.js → readablepromise.mjs} +2 -2
- package/dist/esm/readablepromise.mjs.map +1 -0
- package/dist/esm/search.d.ts +2 -1
- package/dist/esm/{search.js → search.mjs} +1 -1
- package/dist/esm/search.mjs.map +1 -0
- package/dist/esm/{searchparams.js → searchparams.mjs} +8 -9
- package/dist/esm/searchparams.mjs.map +1 -0
- package/dist/esm/{storage.js → storage.mjs} +4 -5
- package/dist/esm/storage.mjs.map +1 -0
- package/dist/esm/{types.js → types.mjs} +6 -9
- package/dist/esm/types.mjs.map +1 -0
- package/dist/esm/{utils.js → utils.mjs} +15 -26
- package/dist/esm/utils.mjs.map +1 -0
- package/package.json +5 -5
- package/rollup.config.mjs +6 -7
- package/dist/cjs/fhirmapper/atoms.d.ts +0 -67
- package/dist/cjs/fhirmapper/testall.d.ts +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/index.min.js +0 -2
- package/dist/cjs/index.min.js.map +0 -1
- package/dist/esm/cache.js.map +0 -1
- package/dist/esm/client.js.map +0 -1
- package/dist/esm/crypto.js.map +0 -1
- package/dist/esm/eventtarget.js.map +0 -1
- package/dist/esm/fhirlexer/parse.js.map +0 -1
- package/dist/esm/fhirlexer/tokenize.js.map +0 -1
- package/dist/esm/fhirmapper/atoms.d.ts +0 -67
- package/dist/esm/fhirmapper/testall.d.ts +0 -1
- package/dist/esm/fhirpath/atoms.js.map +0 -1
- package/dist/esm/fhirpath/date.js.map +0 -1
- package/dist/esm/fhirpath/functions.js.map +0 -1
- package/dist/esm/fhirpath/parse.js.map +0 -1
- package/dist/esm/fhirpath/tokenize.js.map +0 -1
- package/dist/esm/fhirpath/utils.js.map +0 -1
- package/dist/esm/format.js.map +0 -1
- package/dist/esm/hl7.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.min.js +0 -2
- package/dist/esm/index.min.js.map +0 -1
- package/dist/esm/jwt.js.map +0 -1
- package/dist/esm/match.js.map +0 -1
- package/dist/esm/node_modules/tslib/tslib.es6.js.map +0 -1
- package/dist/esm/outcomes.js.map +0 -1
- package/dist/esm/readablepromise.js.map +0 -1
- package/dist/esm/search.js.map +0 -1
- package/dist/esm/searchparams.js.map +0 -1
- package/dist/esm/storage.js.map +0 -1
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/utils.js.map +0 -1
|
@@ -1,102 +1,82 @@
|
|
|
1
|
-
import { Atom } from '../fhirlexer';
|
|
1
|
+
import { Atom, InfixOperatorAtom, PrefixOperatorAtom } from '../fhirlexer';
|
|
2
2
|
import { TypedValue } from '../types';
|
|
3
|
-
import { FhirPathFunction } from './functions';
|
|
4
3
|
export declare class FhirPathAtom implements Atom {
|
|
5
4
|
readonly original: string;
|
|
6
5
|
readonly child: Atom;
|
|
7
6
|
constructor(original: string, child: Atom);
|
|
8
7
|
eval(context: TypedValue[]): TypedValue[];
|
|
8
|
+
toString(): string;
|
|
9
9
|
}
|
|
10
10
|
export declare class LiteralAtom implements Atom {
|
|
11
11
|
readonly value: TypedValue;
|
|
12
12
|
constructor(value: TypedValue);
|
|
13
13
|
eval(): TypedValue[];
|
|
14
|
+
toString(): string;
|
|
14
15
|
}
|
|
15
16
|
export declare class SymbolAtom implements Atom {
|
|
16
17
|
#private;
|
|
17
18
|
readonly name: string;
|
|
18
19
|
constructor(name: string);
|
|
19
20
|
eval(context: TypedValue[]): TypedValue[];
|
|
21
|
+
toString(): string;
|
|
20
22
|
}
|
|
21
23
|
export declare class EmptySetAtom implements Atom {
|
|
22
24
|
eval(): [];
|
|
25
|
+
toString(): string;
|
|
23
26
|
}
|
|
24
|
-
export declare class UnaryOperatorAtom
|
|
25
|
-
readonly child: Atom;
|
|
27
|
+
export declare class UnaryOperatorAtom extends PrefixOperatorAtom {
|
|
26
28
|
readonly impl: (x: TypedValue[]) => TypedValue[];
|
|
27
|
-
constructor(child: Atom, impl: (x: TypedValue[]) => TypedValue[]);
|
|
29
|
+
constructor(operator: string, child: Atom, impl: (x: TypedValue[]) => TypedValue[]);
|
|
28
30
|
eval(context: TypedValue[]): TypedValue[];
|
|
31
|
+
toString(): string;
|
|
29
32
|
}
|
|
30
|
-
export declare class AsAtom
|
|
31
|
-
readonly left: Atom;
|
|
32
|
-
readonly right: Atom;
|
|
33
|
+
export declare class AsAtom extends InfixOperatorAtom {
|
|
33
34
|
constructor(left: Atom, right: Atom);
|
|
34
35
|
eval(context: TypedValue[]): TypedValue[];
|
|
35
36
|
}
|
|
36
|
-
export declare class ArithemticOperatorAtom
|
|
37
|
-
readonly left: Atom;
|
|
38
|
-
readonly right: Atom;
|
|
37
|
+
export declare class ArithemticOperatorAtom extends InfixOperatorAtom {
|
|
39
38
|
readonly impl: (x: number, y: number) => number | boolean;
|
|
40
|
-
constructor(left: Atom, right: Atom, impl: (x: number, y: number) => number | boolean);
|
|
39
|
+
constructor(operator: string, left: Atom, right: Atom, impl: (x: number, y: number) => number | boolean);
|
|
41
40
|
eval(context: TypedValue[]): TypedValue[];
|
|
42
41
|
}
|
|
43
|
-
export declare class ConcatAtom
|
|
44
|
-
readonly left: Atom;
|
|
45
|
-
readonly right: Atom;
|
|
42
|
+
export declare class ConcatAtom extends InfixOperatorAtom {
|
|
46
43
|
constructor(left: Atom, right: Atom);
|
|
47
44
|
eval(context: TypedValue[]): TypedValue[];
|
|
48
45
|
}
|
|
49
|
-
export declare class ContainsAtom
|
|
50
|
-
readonly left: Atom;
|
|
51
|
-
readonly right: Atom;
|
|
46
|
+
export declare class ContainsAtom extends InfixOperatorAtom {
|
|
52
47
|
constructor(left: Atom, right: Atom);
|
|
53
48
|
eval(context: TypedValue[]): TypedValue[];
|
|
54
49
|
}
|
|
55
|
-
export declare class InAtom
|
|
56
|
-
readonly left: Atom;
|
|
57
|
-
readonly right: Atom;
|
|
50
|
+
export declare class InAtom extends InfixOperatorAtom {
|
|
58
51
|
constructor(left: Atom, right: Atom);
|
|
59
52
|
eval(context: TypedValue[]): TypedValue[];
|
|
60
53
|
}
|
|
61
|
-
export declare class DotAtom
|
|
62
|
-
readonly left: Atom;
|
|
63
|
-
readonly right: Atom;
|
|
54
|
+
export declare class DotAtom extends InfixOperatorAtom {
|
|
64
55
|
constructor(left: Atom, right: Atom);
|
|
65
56
|
eval(context: TypedValue[]): TypedValue[];
|
|
57
|
+
toString(): string;
|
|
66
58
|
}
|
|
67
|
-
export declare class UnionAtom
|
|
68
|
-
readonly left: Atom;
|
|
69
|
-
readonly right: Atom;
|
|
59
|
+
export declare class UnionAtom extends InfixOperatorAtom {
|
|
70
60
|
constructor(left: Atom, right: Atom);
|
|
71
61
|
eval(context: TypedValue[]): TypedValue[];
|
|
72
62
|
}
|
|
73
|
-
export declare class EqualsAtom
|
|
74
|
-
readonly left: Atom;
|
|
75
|
-
readonly right: Atom;
|
|
63
|
+
export declare class EqualsAtom extends InfixOperatorAtom {
|
|
76
64
|
constructor(left: Atom, right: Atom);
|
|
77
65
|
eval(context: TypedValue[]): TypedValue[];
|
|
78
66
|
}
|
|
79
|
-
export declare class NotEqualsAtom
|
|
80
|
-
readonly left: Atom;
|
|
81
|
-
readonly right: Atom;
|
|
67
|
+
export declare class NotEqualsAtom extends InfixOperatorAtom {
|
|
82
68
|
constructor(left: Atom, right: Atom);
|
|
83
69
|
eval(context: TypedValue[]): TypedValue[];
|
|
84
70
|
}
|
|
85
|
-
export declare class EquivalentAtom
|
|
86
|
-
readonly left: Atom;
|
|
87
|
-
readonly right: Atom;
|
|
71
|
+
export declare class EquivalentAtom extends InfixOperatorAtom {
|
|
88
72
|
constructor(left: Atom, right: Atom);
|
|
89
73
|
eval(context: TypedValue[]): TypedValue[];
|
|
90
74
|
}
|
|
91
|
-
export declare class NotEquivalentAtom
|
|
92
|
-
readonly left: Atom;
|
|
93
|
-
readonly right: Atom;
|
|
75
|
+
export declare class NotEquivalentAtom extends InfixOperatorAtom {
|
|
94
76
|
constructor(left: Atom, right: Atom);
|
|
95
77
|
eval(context: TypedValue[]): TypedValue[];
|
|
96
78
|
}
|
|
97
|
-
export declare class IsAtom
|
|
98
|
-
readonly left: Atom;
|
|
99
|
-
readonly right: Atom;
|
|
79
|
+
export declare class IsAtom extends InfixOperatorAtom {
|
|
100
80
|
constructor(left: Atom, right: Atom);
|
|
101
81
|
eval(context: TypedValue[]): TypedValue[];
|
|
102
82
|
}
|
|
@@ -106,15 +86,11 @@ export declare class IsAtom implements Atom {
|
|
|
106
86
|
* false if either operand evaluates to false,
|
|
107
87
|
* and the empty collection otherwise.
|
|
108
88
|
*/
|
|
109
|
-
export declare class AndAtom
|
|
110
|
-
readonly left: Atom;
|
|
111
|
-
readonly right: Atom;
|
|
89
|
+
export declare class AndAtom extends InfixOperatorAtom {
|
|
112
90
|
constructor(left: Atom, right: Atom);
|
|
113
91
|
eval(context: TypedValue[]): TypedValue[];
|
|
114
92
|
}
|
|
115
|
-
export declare class OrAtom
|
|
116
|
-
readonly left: Atom;
|
|
117
|
-
readonly right: Atom;
|
|
93
|
+
export declare class OrAtom extends InfixOperatorAtom {
|
|
118
94
|
constructor(left: Atom, right: Atom);
|
|
119
95
|
eval(context: TypedValue[]): TypedValue[];
|
|
120
96
|
}
|
|
@@ -124,22 +100,21 @@ export declare class OrAtom implements Atom {
|
|
|
124
100
|
* false if either both operands evaluate to true or both operands evaluate to false,
|
|
125
101
|
* and the empty collection otherwise.
|
|
126
102
|
*/
|
|
127
|
-
export declare class XorAtom
|
|
128
|
-
readonly left: Atom;
|
|
129
|
-
readonly right: Atom;
|
|
103
|
+
export declare class XorAtom extends InfixOperatorAtom {
|
|
130
104
|
constructor(left: Atom, right: Atom);
|
|
131
105
|
eval(context: TypedValue[]): TypedValue[];
|
|
132
106
|
}
|
|
133
107
|
export declare class FunctionAtom implements Atom {
|
|
134
108
|
readonly name: string;
|
|
135
109
|
readonly args: Atom[];
|
|
136
|
-
|
|
137
|
-
constructor(name: string, args: Atom[], impl: FhirPathFunction);
|
|
110
|
+
constructor(name: string, args: Atom[]);
|
|
138
111
|
eval(context: TypedValue[]): TypedValue[];
|
|
112
|
+
toString(): string;
|
|
139
113
|
}
|
|
140
114
|
export declare class IndexerAtom implements Atom {
|
|
141
115
|
readonly left: Atom;
|
|
142
116
|
readonly expr: Atom;
|
|
143
117
|
constructor(left: Atom, expr: Atom);
|
|
144
118
|
eval(context: TypedValue[]): TypedValue[];
|
|
119
|
+
toString(): string;
|
|
145
120
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { __classPrivateFieldGet } from '../node_modules/tslib/tslib.es6.
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
1
|
+
import { __classPrivateFieldGet } from '../node_modules/tslib/tslib.es6.mjs';
|
|
2
|
+
import { PrefixOperatorAtom, InfixOperatorAtom } from '../fhirlexer/parse.mjs';
|
|
3
|
+
import '../fhirlexer/tokenize.mjs';
|
|
4
|
+
import { PropertyType } from '../types.mjs';
|
|
5
|
+
import { functions } from './functions.mjs';
|
|
6
|
+
import { isQuantity, booleanToTypedValue, toTypedValue, removeDuplicates, fhirPathArrayEquals, fhirPathNot, fhirPathArrayEquivalent, fhirPathIs, toJsBoolean, getTypedPropertyValue } from './utils.mjs';
|
|
5
7
|
|
|
6
8
|
var _SymbolAtom_instances, _SymbolAtom_evalValue;
|
|
7
9
|
class FhirPathAtom {
|
|
@@ -22,6 +24,9 @@ class FhirPathAtom {
|
|
|
22
24
|
throw new Error(`FhirPathError on "${this.original}": ${error}`);
|
|
23
25
|
}
|
|
24
26
|
}
|
|
27
|
+
toString() {
|
|
28
|
+
return this.child.toString();
|
|
29
|
+
}
|
|
25
30
|
}
|
|
26
31
|
class LiteralAtom {
|
|
27
32
|
constructor(value) {
|
|
@@ -30,6 +35,13 @@ class LiteralAtom {
|
|
|
30
35
|
eval() {
|
|
31
36
|
return [this.value];
|
|
32
37
|
}
|
|
38
|
+
toString() {
|
|
39
|
+
const value = this.value.value;
|
|
40
|
+
if (typeof value === 'string') {
|
|
41
|
+
return `'${value}'`;
|
|
42
|
+
}
|
|
43
|
+
return value.toString();
|
|
44
|
+
}
|
|
33
45
|
}
|
|
34
46
|
class SymbolAtom {
|
|
35
47
|
constructor(name) {
|
|
@@ -43,7 +55,10 @@ class SymbolAtom {
|
|
|
43
55
|
return context
|
|
44
56
|
.map((e) => __classPrivateFieldGet(this, _SymbolAtom_instances, "m", _SymbolAtom_evalValue).call(this, e))
|
|
45
57
|
.flat()
|
|
46
|
-
.filter((e) =>
|
|
58
|
+
.filter((e) => e?.value !== undefined);
|
|
59
|
+
}
|
|
60
|
+
toString() {
|
|
61
|
+
return this.name;
|
|
47
62
|
}
|
|
48
63
|
}
|
|
49
64
|
_SymbolAtom_instances = new WeakSet(), _SymbolAtom_evalValue = function _SymbolAtom_evalValue(typedValue) {
|
|
@@ -60,29 +75,33 @@ class EmptySetAtom {
|
|
|
60
75
|
eval() {
|
|
61
76
|
return [];
|
|
62
77
|
}
|
|
78
|
+
toString() {
|
|
79
|
+
return '{}';
|
|
80
|
+
}
|
|
63
81
|
}
|
|
64
|
-
class UnaryOperatorAtom {
|
|
65
|
-
constructor(child, impl) {
|
|
66
|
-
|
|
82
|
+
class UnaryOperatorAtom extends PrefixOperatorAtom {
|
|
83
|
+
constructor(operator, child, impl) {
|
|
84
|
+
super(operator, child);
|
|
67
85
|
this.impl = impl;
|
|
68
86
|
}
|
|
69
87
|
eval(context) {
|
|
70
88
|
return this.impl(this.child.eval(context));
|
|
71
89
|
}
|
|
90
|
+
toString() {
|
|
91
|
+
return this.child.toString();
|
|
92
|
+
}
|
|
72
93
|
}
|
|
73
|
-
class AsAtom {
|
|
94
|
+
class AsAtom extends InfixOperatorAtom {
|
|
74
95
|
constructor(left, right) {
|
|
75
|
-
|
|
76
|
-
this.right = right;
|
|
96
|
+
super('as', left, right);
|
|
77
97
|
}
|
|
78
98
|
eval(context) {
|
|
79
99
|
return functions.ofType(this.left.eval(context), this.right);
|
|
80
100
|
}
|
|
81
101
|
}
|
|
82
|
-
class ArithemticOperatorAtom {
|
|
83
|
-
constructor(left, right, impl) {
|
|
84
|
-
|
|
85
|
-
this.right = right;
|
|
102
|
+
class ArithemticOperatorAtom extends InfixOperatorAtom {
|
|
103
|
+
constructor(operator, left, right, impl) {
|
|
104
|
+
super(operator, left, right);
|
|
86
105
|
this.impl = impl;
|
|
87
106
|
}
|
|
88
107
|
eval(context) {
|
|
@@ -103,17 +122,16 @@ class ArithemticOperatorAtom {
|
|
|
103
122
|
return booleanToTypedValue(result);
|
|
104
123
|
}
|
|
105
124
|
else if (isQuantity(leftValue)) {
|
|
106
|
-
return [{ type: PropertyType.Quantity, value:
|
|
125
|
+
return [{ type: PropertyType.Quantity, value: { ...leftValue, value: result } }];
|
|
107
126
|
}
|
|
108
127
|
else {
|
|
109
128
|
return [toTypedValue(result)];
|
|
110
129
|
}
|
|
111
130
|
}
|
|
112
131
|
}
|
|
113
|
-
class ConcatAtom {
|
|
132
|
+
class ConcatAtom extends InfixOperatorAtom {
|
|
114
133
|
constructor(left, right) {
|
|
115
|
-
|
|
116
|
-
this.right = right;
|
|
134
|
+
super('&', left, right);
|
|
117
135
|
}
|
|
118
136
|
eval(context) {
|
|
119
137
|
const leftValue = this.left.eval(context);
|
|
@@ -125,10 +143,9 @@ class ConcatAtom {
|
|
|
125
143
|
return result;
|
|
126
144
|
}
|
|
127
145
|
}
|
|
128
|
-
class ContainsAtom {
|
|
146
|
+
class ContainsAtom extends InfixOperatorAtom {
|
|
129
147
|
constructor(left, right) {
|
|
130
|
-
|
|
131
|
-
this.right = right;
|
|
148
|
+
super('contains', left, right);
|
|
132
149
|
}
|
|
133
150
|
eval(context) {
|
|
134
151
|
const leftValue = this.left.eval(context);
|
|
@@ -136,10 +153,9 @@ class ContainsAtom {
|
|
|
136
153
|
return booleanToTypedValue(leftValue.some((e) => e.value === rightValue[0].value));
|
|
137
154
|
}
|
|
138
155
|
}
|
|
139
|
-
class InAtom {
|
|
156
|
+
class InAtom extends InfixOperatorAtom {
|
|
140
157
|
constructor(left, right) {
|
|
141
|
-
|
|
142
|
-
this.right = right;
|
|
158
|
+
super('in', left, right);
|
|
143
159
|
}
|
|
144
160
|
eval(context) {
|
|
145
161
|
const leftValue = this.left.eval(context);
|
|
@@ -147,19 +163,20 @@ class InAtom {
|
|
|
147
163
|
return booleanToTypedValue(rightValue.some((e) => e.value === leftValue[0].value));
|
|
148
164
|
}
|
|
149
165
|
}
|
|
150
|
-
class DotAtom {
|
|
166
|
+
class DotAtom extends InfixOperatorAtom {
|
|
151
167
|
constructor(left, right) {
|
|
152
|
-
|
|
153
|
-
this.right = right;
|
|
168
|
+
super('.', left, right);
|
|
154
169
|
}
|
|
155
170
|
eval(context) {
|
|
156
171
|
return this.right.eval(this.left.eval(context));
|
|
157
172
|
}
|
|
173
|
+
toString() {
|
|
174
|
+
return `${this.left.toString()}.${this.right.toString()}`;
|
|
175
|
+
}
|
|
158
176
|
}
|
|
159
|
-
class UnionAtom {
|
|
177
|
+
class UnionAtom extends InfixOperatorAtom {
|
|
160
178
|
constructor(left, right) {
|
|
161
|
-
|
|
162
|
-
this.right = right;
|
|
179
|
+
super('|', left, right);
|
|
163
180
|
}
|
|
164
181
|
eval(context) {
|
|
165
182
|
const leftResult = this.left.eval(context);
|
|
@@ -167,10 +184,9 @@ class UnionAtom {
|
|
|
167
184
|
return removeDuplicates([...leftResult, ...rightResult]);
|
|
168
185
|
}
|
|
169
186
|
}
|
|
170
|
-
class EqualsAtom {
|
|
187
|
+
class EqualsAtom extends InfixOperatorAtom {
|
|
171
188
|
constructor(left, right) {
|
|
172
|
-
|
|
173
|
-
this.right = right;
|
|
189
|
+
super('=', left, right);
|
|
174
190
|
}
|
|
175
191
|
eval(context) {
|
|
176
192
|
const leftValue = this.left.eval(context);
|
|
@@ -178,10 +194,9 @@ class EqualsAtom {
|
|
|
178
194
|
return fhirPathArrayEquals(leftValue, rightValue);
|
|
179
195
|
}
|
|
180
196
|
}
|
|
181
|
-
class NotEqualsAtom {
|
|
197
|
+
class NotEqualsAtom extends InfixOperatorAtom {
|
|
182
198
|
constructor(left, right) {
|
|
183
|
-
|
|
184
|
-
this.right = right;
|
|
199
|
+
super('!=', left, right);
|
|
185
200
|
}
|
|
186
201
|
eval(context) {
|
|
187
202
|
const leftValue = this.left.eval(context);
|
|
@@ -189,10 +204,9 @@ class NotEqualsAtom {
|
|
|
189
204
|
return fhirPathNot(fhirPathArrayEquals(leftValue, rightValue));
|
|
190
205
|
}
|
|
191
206
|
}
|
|
192
|
-
class EquivalentAtom {
|
|
207
|
+
class EquivalentAtom extends InfixOperatorAtom {
|
|
193
208
|
constructor(left, right) {
|
|
194
|
-
|
|
195
|
-
this.right = right;
|
|
209
|
+
super('~', left, right);
|
|
196
210
|
}
|
|
197
211
|
eval(context) {
|
|
198
212
|
const leftValue = this.left.eval(context);
|
|
@@ -200,10 +214,9 @@ class EquivalentAtom {
|
|
|
200
214
|
return fhirPathArrayEquivalent(leftValue, rightValue);
|
|
201
215
|
}
|
|
202
216
|
}
|
|
203
|
-
class NotEquivalentAtom {
|
|
217
|
+
class NotEquivalentAtom extends InfixOperatorAtom {
|
|
204
218
|
constructor(left, right) {
|
|
205
|
-
|
|
206
|
-
this.right = right;
|
|
219
|
+
super('!~', left, right);
|
|
207
220
|
}
|
|
208
221
|
eval(context) {
|
|
209
222
|
const leftValue = this.left.eval(context);
|
|
@@ -211,10 +224,9 @@ class NotEquivalentAtom {
|
|
|
211
224
|
return fhirPathNot(fhirPathArrayEquivalent(leftValue, rightValue));
|
|
212
225
|
}
|
|
213
226
|
}
|
|
214
|
-
class IsAtom {
|
|
227
|
+
class IsAtom extends InfixOperatorAtom {
|
|
215
228
|
constructor(left, right) {
|
|
216
|
-
|
|
217
|
-
this.right = right;
|
|
229
|
+
super('is', left, right);
|
|
218
230
|
}
|
|
219
231
|
eval(context) {
|
|
220
232
|
const leftValue = this.left.eval(context);
|
|
@@ -231,28 +243,25 @@ class IsAtom {
|
|
|
231
243
|
* false if either operand evaluates to false,
|
|
232
244
|
* and the empty collection otherwise.
|
|
233
245
|
*/
|
|
234
|
-
class AndAtom {
|
|
246
|
+
class AndAtom extends InfixOperatorAtom {
|
|
235
247
|
constructor(left, right) {
|
|
236
|
-
|
|
237
|
-
this.right = right;
|
|
248
|
+
super('and', left, right);
|
|
238
249
|
}
|
|
239
250
|
eval(context) {
|
|
240
|
-
var _a, _b, _c, _d;
|
|
241
251
|
const leftValue = this.left.eval(context);
|
|
242
252
|
const rightValue = this.right.eval(context);
|
|
243
|
-
if (
|
|
253
|
+
if (leftValue[0]?.value === true && rightValue[0]?.value === true) {
|
|
244
254
|
return booleanToTypedValue(true);
|
|
245
255
|
}
|
|
246
|
-
if (
|
|
256
|
+
if (leftValue[0]?.value === false || rightValue[0]?.value === false) {
|
|
247
257
|
return booleanToTypedValue(false);
|
|
248
258
|
}
|
|
249
259
|
return [];
|
|
250
260
|
}
|
|
251
261
|
}
|
|
252
|
-
class OrAtom {
|
|
262
|
+
class OrAtom extends InfixOperatorAtom {
|
|
253
263
|
constructor(left, right) {
|
|
254
|
-
|
|
255
|
-
this.right = right;
|
|
264
|
+
super('or', left, right);
|
|
256
265
|
}
|
|
257
266
|
eval(context) {
|
|
258
267
|
const leftValue = this.left.eval(context);
|
|
@@ -272,10 +281,9 @@ class OrAtom {
|
|
|
272
281
|
* false if either both operands evaluate to true or both operands evaluate to false,
|
|
273
282
|
* and the empty collection otherwise.
|
|
274
283
|
*/
|
|
275
|
-
class XorAtom {
|
|
284
|
+
class XorAtom extends InfixOperatorAtom {
|
|
276
285
|
constructor(left, right) {
|
|
277
|
-
|
|
278
|
-
this.right = right;
|
|
286
|
+
super('xor', left, right);
|
|
279
287
|
}
|
|
280
288
|
eval(context) {
|
|
281
289
|
const leftResult = this.left.eval(context);
|
|
@@ -295,13 +303,19 @@ class XorAtom {
|
|
|
295
303
|
}
|
|
296
304
|
}
|
|
297
305
|
class FunctionAtom {
|
|
298
|
-
constructor(name, args
|
|
306
|
+
constructor(name, args) {
|
|
299
307
|
this.name = name;
|
|
300
308
|
this.args = args;
|
|
301
|
-
this.impl = impl;
|
|
302
309
|
}
|
|
303
310
|
eval(context) {
|
|
304
|
-
|
|
311
|
+
const impl = functions[this.name];
|
|
312
|
+
if (!impl) {
|
|
313
|
+
throw new Error('Unrecognized function: ' + this.name);
|
|
314
|
+
}
|
|
315
|
+
return impl(context, ...this.args);
|
|
316
|
+
}
|
|
317
|
+
toString() {
|
|
318
|
+
return `${this.name}(${this.args.map((arg) => arg.toString()).join(', ')})`;
|
|
305
319
|
}
|
|
306
320
|
}
|
|
307
321
|
class IndexerAtom {
|
|
@@ -324,7 +338,10 @@ class IndexerAtom {
|
|
|
324
338
|
}
|
|
325
339
|
return [leftResult[index]];
|
|
326
340
|
}
|
|
341
|
+
toString() {
|
|
342
|
+
return `${this.left.toString()}[${this.expr.toString()}]`;
|
|
343
|
+
}
|
|
327
344
|
}
|
|
328
345
|
|
|
329
346
|
export { AndAtom, ArithemticOperatorAtom, AsAtom, ConcatAtom, ContainsAtom, DotAtom, EmptySetAtom, EqualsAtom, EquivalentAtom, FhirPathAtom, FunctionAtom, InAtom, IndexerAtom, IsAtom, LiteralAtom, NotEqualsAtom, NotEquivalentAtom, OrAtom, SymbolAtom, UnaryOperatorAtom, UnionAtom, XorAtom };
|
|
330
|
-
//# sourceMappingURL=atoms.
|
|
347
|
+
//# sourceMappingURL=atoms.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atoms.mjs","sources":["../../../src/fhirpath/atoms.ts"],"sourcesContent":["import { Resource } from '@medplum/fhirtypes';\nimport { Atom, InfixOperatorAtom, PrefixOperatorAtom } from '../fhirlexer';\nimport { PropertyType, TypedValue } from '../types';\nimport { functions } from './functions';\nimport {\n booleanToTypedValue,\n fhirPathArrayEquals,\n fhirPathArrayEquivalent,\n fhirPathIs,\n fhirPathNot,\n getTypedPropertyValue,\n isQuantity,\n removeDuplicates,\n toJsBoolean,\n toTypedValue,\n} from './utils';\n\nexport class FhirPathAtom implements Atom {\n constructor(public readonly original: string, public readonly child: Atom) {}\n\n eval(context: TypedValue[]): TypedValue[] {\n try {\n if (context.length > 0) {\n return context.map((e) => this.child.eval([e])).flat();\n } else {\n return this.child.eval([]);\n }\n } catch (error) {\n throw new Error(`FhirPathError on \"${this.original}\": ${error}`);\n }\n }\n\n toString(): string {\n return this.child.toString();\n }\n}\n\nexport class LiteralAtom implements Atom {\n constructor(public readonly value: TypedValue) {}\n eval(): TypedValue[] {\n return [this.value];\n }\n\n toString(): string {\n const value = this.value.value;\n if (typeof value === 'string') {\n return `'${value}'`;\n }\n return value.toString();\n }\n}\n\nexport class SymbolAtom implements Atom {\n constructor(public readonly name: string) {}\n eval(context: TypedValue[]): TypedValue[] {\n if (this.name === '$this') {\n return context;\n }\n return context\n .map((e) => this.#evalValue(e))\n .flat()\n .filter((e) => e?.value !== undefined) as TypedValue[];\n }\n\n #evalValue(typedValue: TypedValue): TypedValue[] | TypedValue | undefined {\n const input = typedValue.value;\n if (!input || typeof input !== 'object') {\n return undefined;\n }\n\n if ('resourceType' in input && (input as Resource).resourceType === this.name) {\n return typedValue;\n }\n\n return getTypedPropertyValue(typedValue, this.name);\n }\n\n toString(): string {\n return this.name;\n }\n}\n\nexport class EmptySetAtom implements Atom {\n eval(): [] {\n return [];\n }\n\n toString(): string {\n return '{}';\n }\n}\n\nexport class UnaryOperatorAtom extends PrefixOperatorAtom {\n constructor(operator: string, child: Atom, public readonly impl: (x: TypedValue[]) => TypedValue[]) {\n super(operator, child);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n return this.impl(this.child.eval(context));\n }\n\n toString(): string {\n return this.child.toString();\n }\n}\n\nexport class AsAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('as', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n return functions.ofType(this.left.eval(context), this.right);\n }\n}\n\nexport class ArithemticOperatorAtom extends InfixOperatorAtom {\n constructor(\n operator: string,\n left: Atom,\n right: Atom,\n public readonly impl: (x: number, y: number) => number | boolean\n ) {\n super(operator, left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftEvalResult = this.left.eval(context);\n if (leftEvalResult.length !== 1) {\n return [];\n }\n const rightEvalResult = this.right.eval(context);\n if (rightEvalResult.length !== 1) {\n return [];\n }\n const leftValue = leftEvalResult[0].value;\n const rightValue = rightEvalResult[0].value;\n const leftNumber = isQuantity(leftValue) ? leftValue.value : leftValue;\n const rightNumber = isQuantity(rightValue) ? rightValue.value : rightValue;\n const result = this.impl(leftNumber, rightNumber);\n if (typeof result === 'boolean') {\n return booleanToTypedValue(result);\n } else if (isQuantity(leftValue)) {\n return [{ type: PropertyType.Quantity, value: { ...leftValue, value: result } }];\n } else {\n return [toTypedValue(result)];\n }\n }\n}\n\nexport class ConcatAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('&', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n const result = [...leftValue, ...rightValue];\n if (result.length > 0 && result.every((e) => typeof e.value === 'string')) {\n return [{ type: PropertyType.string, value: result.map((e) => e.value as string).join('') }];\n }\n return result;\n }\n}\n\nexport class ContainsAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('contains', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return booleanToTypedValue(leftValue.some((e) => e.value === rightValue[0].value));\n }\n}\n\nexport class InAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('in', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return booleanToTypedValue(rightValue.some((e) => e.value === leftValue[0].value));\n }\n}\n\nexport class DotAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('.', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n return this.right.eval(this.left.eval(context));\n }\n\n toString(): string {\n return `${this.left.toString()}.${this.right.toString()}`;\n }\n}\n\nexport class UnionAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('|', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftResult = this.left.eval(context);\n const rightResult = this.right.eval(context);\n return removeDuplicates([...leftResult, ...rightResult]);\n }\n}\n\nexport class EqualsAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('=', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return fhirPathArrayEquals(leftValue, rightValue);\n }\n}\n\nexport class NotEqualsAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('!=', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return fhirPathNot(fhirPathArrayEquals(leftValue, rightValue));\n }\n}\n\nexport class EquivalentAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('~', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return fhirPathArrayEquivalent(leftValue, rightValue);\n }\n}\n\nexport class NotEquivalentAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('!~', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n return fhirPathNot(fhirPathArrayEquivalent(leftValue, rightValue));\n }\n}\n\nexport class IsAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('is', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n if (leftValue.length !== 1) {\n return [];\n }\n const typeName = (this.right as SymbolAtom).name;\n return booleanToTypedValue(fhirPathIs(leftValue[0], typeName));\n }\n}\n\n/**\n * 6.5.1. and\n * Returns true if both operands evaluate to true,\n * false if either operand evaluates to false,\n * and the empty collection otherwise.\n */\nexport class AndAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('and', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n const rightValue = this.right.eval(context);\n if (leftValue[0]?.value === true && rightValue[0]?.value === true) {\n return booleanToTypedValue(true);\n }\n if (leftValue[0]?.value === false || rightValue[0]?.value === false) {\n return booleanToTypedValue(false);\n }\n return [];\n }\n}\n\nexport class OrAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('or', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftValue = this.left.eval(context);\n if (toJsBoolean(leftValue)) {\n return leftValue;\n }\n\n const rightValue = this.right.eval(context);\n if (toJsBoolean(rightValue)) {\n return rightValue;\n }\n\n return [];\n }\n}\n\n/**\n * 6.5.4. xor\n * Returns true if exactly one of the operands evaluates to true,\n * false if either both operands evaluate to true or both operands evaluate to false,\n * and the empty collection otherwise.\n */\nexport class XorAtom extends InfixOperatorAtom {\n constructor(left: Atom, right: Atom) {\n super('xor', left, right);\n }\n\n eval(context: TypedValue[]): TypedValue[] {\n const leftResult = this.left.eval(context);\n const rightResult = this.right.eval(context);\n if (leftResult.length === 0 && rightResult.length === 0) {\n return [];\n }\n const leftValue = leftResult.length === 0 ? null : leftResult[0].value;\n const rightValue = rightResult.length === 0 ? null : rightResult[0].value;\n if ((leftValue === true && rightValue !== true) || (leftValue !== true && rightValue === true)) {\n return booleanToTypedValue(true);\n }\n if ((leftValue === true && rightValue === true) || (leftValue === false && rightValue === false)) {\n return booleanToTypedValue(false);\n }\n return [];\n }\n}\n\nexport class FunctionAtom implements Atom {\n constructor(public readonly name: string, public readonly args: Atom[]) {}\n eval(context: TypedValue[]): TypedValue[] {\n const impl = functions[this.name];\n if (!impl) {\n throw new Error('Unrecognized function: ' + this.name);\n }\n return impl(context, ...this.args);\n }\n\n toString(): string {\n return `${this.name}(${this.args.map((arg) => arg.toString()).join(', ')})`;\n }\n}\n\nexport class IndexerAtom implements Atom {\n constructor(public readonly left: Atom, public readonly expr: Atom) {}\n eval(context: TypedValue[]): TypedValue[] {\n const evalResult = this.expr.eval(context);\n if (evalResult.length !== 1) {\n return [];\n }\n const index = evalResult[0].value;\n if (typeof index !== 'number') {\n throw new Error(`Invalid indexer expression: should return integer}`);\n }\n const leftResult = this.left.eval(context);\n if (!(index in leftResult)) {\n return [];\n }\n return [leftResult[index]];\n }\n\n toString(): string {\n return `${this.left.toString()}[${this.expr.toString()}]`;\n }\n}\n"],"names":[],"mappings":";;;;;;;;MAiBa,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U,CAAC,EAAE;AAC1B,YAAA,OAAO,EAAE,CAAC;AACX,SAAA;AACD,QAAA,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;KAC5B;IAED,QAAQ,GAAA;AACN,QAAA,OAAO,CAAG,EAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAI,CAAA,EAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;KAC3D;AACF;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.mjs","sources":["../../../src/fhirpath/date.ts"],"sourcesContent":["export function parseDateString(str: string): string {\n if (str.startsWith('T')) {\n // If a time string,\n // then normalize to full length.\n return str + 'T00:00:00.000Z'.substring(str.length);\n }\n\n if (str.length <= 10) {\n // If a local date (i.e., \"2021-01-01\"),\n // then return as-is.\n return str;\n }\n\n try {\n // Try to normalize to UTC\n return new Date(str).toISOString();\n } catch (e) {\n // Fallback to original input\n // This happens on unsupported time formats such as \"2021-01-01T12\"\n return str;\n }\n}\n"],"names":[],"mappings":"AAAM,SAAU,eAAe,CAAC,GAAW,EAAA;AACzC,IAAA,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;;;QAGvB,OAAO,GAAG,GAAG,gBAAgB,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACrD,KAAA;AAED,IAAA,IAAI,GAAG,CAAC,MAAM,IAAI,EAAE,EAAE;;;AAGpB,QAAA,OAAO,GAAG,CAAC;AACZ,KAAA;IAED,IAAI;;QAEF,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;AACpC,KAAA;AAAC,IAAA,OAAO,CAAC,EAAE;;;AAGV,QAAA,OAAO,GAAG,CAAC;AACZ,KAAA;AACH;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { PropertyType } from '../types.
|
|
2
|
-
import { calculateAge } from '../utils.
|
|
3
|
-
import { SymbolAtom, DotAtom } from './atoms.
|
|
4
|
-
import { parseDateString } from './date.
|
|
5
|
-
import { booleanToTypedValue, toJsBoolean, removeDuplicates, isQuantity, fhirPathIs, toTypedValue } from './utils.
|
|
1
|
+
import { PropertyType } from '../types.mjs';
|
|
2
|
+
import { calculateAge } from '../utils.mjs';
|
|
3
|
+
import { SymbolAtom, DotAtom } from './atoms.mjs';
|
|
4
|
+
import { parseDateString } from './date.mjs';
|
|
5
|
+
import { booleanToTypedValue, toJsBoolean, removeDuplicates, isQuantity, fhirPathIs, toTypedValue } from './utils.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Temporary placholder for unimplemented methods.
|
|
@@ -335,8 +335,7 @@ const functions = {
|
|
|
335
335
|
* @returns A collection containing all but the first item in the input collection.
|
|
336
336
|
*/
|
|
337
337
|
skip: (input, num) => {
|
|
338
|
-
|
|
339
|
-
const numValue = (_a = num.eval(input)[0]) === null || _a === void 0 ? void 0 : _a.value;
|
|
338
|
+
const numValue = num.eval(input)[0]?.value;
|
|
340
339
|
if (typeof numValue !== 'number') {
|
|
341
340
|
throw new Error('Expected a number for skip(num)');
|
|
342
341
|
}
|
|
@@ -360,8 +359,7 @@ const functions = {
|
|
|
360
359
|
* @returns A collection containing the first num items in the input collection.
|
|
361
360
|
*/
|
|
362
361
|
take: (input, num) => {
|
|
363
|
-
|
|
364
|
-
const numValue = (_a = num.eval(input)[0]) === null || _a === void 0 ? void 0 : _a.value;
|
|
362
|
+
const numValue = num.eval(input)[0]?.value;
|
|
365
363
|
if (typeof numValue !== 'number') {
|
|
366
364
|
throw new Error('Expected a number for take(num)');
|
|
367
365
|
}
|
|
@@ -1305,7 +1303,6 @@ const functions = {
|
|
|
1305
1303
|
* IBM FHIR PR: https://github.com/IBM/FHIR/pull/1023
|
|
1306
1304
|
*/
|
|
1307
1305
|
between: (input, startAtom, endAtom, unitsAtom) => {
|
|
1308
|
-
var _a;
|
|
1309
1306
|
const startDate = functions.toDateTime(startAtom.eval(input));
|
|
1310
1307
|
if (startDate.length === 0) {
|
|
1311
1308
|
throw new Error('Invalid start date');
|
|
@@ -1314,7 +1311,7 @@ const functions = {
|
|
|
1314
1311
|
if (endDate.length === 0) {
|
|
1315
1312
|
throw new Error('Invalid end date');
|
|
1316
1313
|
}
|
|
1317
|
-
const unit =
|
|
1314
|
+
const unit = unitsAtom.eval(input)[0]?.value;
|
|
1318
1315
|
if (unit !== 'years' && unit !== 'months' && unit !== 'days') {
|
|
1319
1316
|
throw new Error('Invalid units');
|
|
1320
1317
|
}
|
|
@@ -1445,13 +1442,10 @@ const functions = {
|
|
|
1445
1442
|
throw new Error('Expected a StructureDefinition URL');
|
|
1446
1443
|
}
|
|
1447
1444
|
const expectedResourceType = system.replace('http://hl7.org/fhir/StructureDefinition/', '');
|
|
1448
|
-
return input.map((value) => {
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
value: ((_a = value.value) === null || _a === void 0 ? void 0 : _a.resourceType) === expectedResourceType,
|
|
1453
|
-
});
|
|
1454
|
-
});
|
|
1445
|
+
return input.map((value) => ({
|
|
1446
|
+
type: PropertyType.boolean,
|
|
1447
|
+
value: value.value?.resourceType === expectedResourceType,
|
|
1448
|
+
}));
|
|
1455
1449
|
},
|
|
1456
1450
|
};
|
|
1457
1451
|
/*
|
|
@@ -1465,7 +1459,7 @@ function applyStringFunc(func, input, ...argsAtoms) {
|
|
|
1465
1459
|
if (typeof value !== 'string') {
|
|
1466
1460
|
throw new Error('String function cannot be called with non-string');
|
|
1467
1461
|
}
|
|
1468
|
-
const result = func(value, ...argsAtoms.map((atom) =>
|
|
1462
|
+
const result = func(value, ...argsAtoms.map((atom) => atom && atom.eval(input)?.[0]?.value));
|
|
1469
1463
|
if (result === undefined) {
|
|
1470
1464
|
return [];
|
|
1471
1465
|
}
|
|
@@ -1484,9 +1478,9 @@ function applyMathFunc(func, input, ...argsAtoms) {
|
|
|
1484
1478
|
if (typeof numberInput !== 'number') {
|
|
1485
1479
|
throw new Error('Math function cannot be called with non-number');
|
|
1486
1480
|
}
|
|
1487
|
-
const result = func(numberInput, ...argsAtoms.map((atom) =>
|
|
1481
|
+
const result = func(numberInput, ...argsAtoms.map((atom) => atom.eval(input)?.[0]?.value));
|
|
1488
1482
|
const type = quantity ? PropertyType.Quantity : input[0].type;
|
|
1489
|
-
const returnValue = quantity ?
|
|
1483
|
+
const returnValue = quantity ? { ...value, value: result } : result;
|
|
1490
1484
|
return [{ type, value: returnValue }];
|
|
1491
1485
|
}
|
|
1492
1486
|
function validateInput(input, count) {
|
|
@@ -1502,4 +1496,4 @@ function validateInput(input, count) {
|
|
|
1502
1496
|
}
|
|
1503
1497
|
|
|
1504
1498
|
export { functions };
|
|
1505
|
-
//# sourceMappingURL=functions.
|
|
1499
|
+
//# sourceMappingURL=functions.mjs.map
|