@medplum/core 0.9.28 → 0.9.31
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 +1 -1
- package/dist/cjs/cache.d.ts +34 -0
- package/dist/cjs/client.d.ts +1095 -0
- package/dist/cjs/crypto.d.ts +9 -0
- package/dist/cjs/eventtarget.d.ts +13 -0
- package/dist/cjs/fhirpath/atoms.d.ts +150 -0
- package/dist/cjs/fhirpath/date.d.ts +1 -0
- package/dist/cjs/fhirpath/functions.d.ts +5 -0
- package/dist/cjs/fhirpath/index.d.ts +4 -0
- package/dist/cjs/fhirpath/parse.d.ts +24 -0
- package/dist/cjs/fhirpath/tokenize.d.ts +5 -0
- package/dist/cjs/fhirpath/utils.d.ts +95 -0
- package/dist/cjs/format.d.ts +21 -0
- package/dist/cjs/hl7.d.ts +43 -0
- package/dist/cjs/index.d.ts +12 -0
- package/dist/cjs/index.js +89 -47
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -1
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/cjs/jwt.d.ts +5 -0
- package/dist/cjs/outcomes.d.ts +30 -0
- package/dist/cjs/readablepromise.d.ts +48 -0
- package/dist/cjs/search.d.ts +64 -0
- package/dist/cjs/searchparams.d.ts +35 -0
- package/dist/cjs/storage.d.ts +47 -0
- package/dist/cjs/types.d.ts +148 -0
- package/dist/cjs/utils.d.ts +245 -0
- package/dist/esm/client.d.ts +17 -15
- package/dist/esm/client.js +40 -35
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/fhirpath/utils.js +3 -3
- package/dist/esm/fhirpath/utils.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/outcomes.d.ts +2 -1
- package/dist/esm/outcomes.js +27 -10
- package/dist/esm/outcomes.js.map +1 -1
- package/dist/esm/utils.d.ts +21 -0
- package/dist/esm/utils.js +18 -1
- package/dist/esm/utils.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface Event {
|
|
2
|
+
readonly type: string;
|
|
3
|
+
readonly defaultPrevented?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare type EventListener = (e: Event) => void;
|
|
6
|
+
export declare class EventTarget {
|
|
7
|
+
#private;
|
|
8
|
+
constructor();
|
|
9
|
+
addEventListener(type: string, callback: EventListener): void;
|
|
10
|
+
removeEventListeneer(type: string, callback: EventListener): void;
|
|
11
|
+
dispatchEvent(event: Event): boolean;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { FhirPathFunction } from './functions';
|
|
2
|
+
export interface TypedValue {
|
|
3
|
+
readonly type: string;
|
|
4
|
+
readonly value: any;
|
|
5
|
+
}
|
|
6
|
+
export interface Atom {
|
|
7
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
8
|
+
}
|
|
9
|
+
export declare class FhirPathAtom implements Atom {
|
|
10
|
+
readonly original: string;
|
|
11
|
+
readonly child: Atom;
|
|
12
|
+
constructor(original: string, child: Atom);
|
|
13
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
14
|
+
}
|
|
15
|
+
export declare class LiteralAtom implements Atom {
|
|
16
|
+
readonly value: TypedValue;
|
|
17
|
+
constructor(value: TypedValue);
|
|
18
|
+
eval(): TypedValue[];
|
|
19
|
+
}
|
|
20
|
+
export declare class SymbolAtom implements Atom {
|
|
21
|
+
#private;
|
|
22
|
+
readonly name: string;
|
|
23
|
+
constructor(name: string);
|
|
24
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
25
|
+
}
|
|
26
|
+
export declare class EmptySetAtom implements Atom {
|
|
27
|
+
eval(): [];
|
|
28
|
+
}
|
|
29
|
+
export declare class UnaryOperatorAtom implements Atom {
|
|
30
|
+
readonly child: Atom;
|
|
31
|
+
readonly impl: (x: TypedValue[]) => TypedValue[];
|
|
32
|
+
constructor(child: Atom, impl: (x: TypedValue[]) => TypedValue[]);
|
|
33
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
34
|
+
}
|
|
35
|
+
export declare class AsAtom implements Atom {
|
|
36
|
+
readonly left: Atom;
|
|
37
|
+
readonly right: Atom;
|
|
38
|
+
constructor(left: Atom, right: Atom);
|
|
39
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
40
|
+
}
|
|
41
|
+
export declare class ArithemticOperatorAtom implements Atom {
|
|
42
|
+
readonly left: Atom;
|
|
43
|
+
readonly right: Atom;
|
|
44
|
+
readonly impl: (x: number, y: number) => number | boolean;
|
|
45
|
+
constructor(left: Atom, right: Atom, impl: (x: number, y: number) => number | boolean);
|
|
46
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
47
|
+
}
|
|
48
|
+
export declare class ConcatAtom implements Atom {
|
|
49
|
+
readonly left: Atom;
|
|
50
|
+
readonly right: Atom;
|
|
51
|
+
constructor(left: Atom, right: Atom);
|
|
52
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
53
|
+
}
|
|
54
|
+
export declare class ContainsAtom implements Atom {
|
|
55
|
+
readonly left: Atom;
|
|
56
|
+
readonly right: Atom;
|
|
57
|
+
constructor(left: Atom, right: Atom);
|
|
58
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
59
|
+
}
|
|
60
|
+
export declare class InAtom implements Atom {
|
|
61
|
+
readonly left: Atom;
|
|
62
|
+
readonly right: Atom;
|
|
63
|
+
constructor(left: Atom, right: Atom);
|
|
64
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
65
|
+
}
|
|
66
|
+
export declare class DotAtom implements Atom {
|
|
67
|
+
readonly left: Atom;
|
|
68
|
+
readonly right: Atom;
|
|
69
|
+
constructor(left: Atom, right: Atom);
|
|
70
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
71
|
+
}
|
|
72
|
+
export declare class UnionAtom implements Atom {
|
|
73
|
+
readonly left: Atom;
|
|
74
|
+
readonly right: Atom;
|
|
75
|
+
constructor(left: Atom, right: Atom);
|
|
76
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
77
|
+
}
|
|
78
|
+
export declare class EqualsAtom implements Atom {
|
|
79
|
+
readonly left: Atom;
|
|
80
|
+
readonly right: Atom;
|
|
81
|
+
constructor(left: Atom, right: Atom);
|
|
82
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
83
|
+
}
|
|
84
|
+
export declare class NotEqualsAtom implements Atom {
|
|
85
|
+
readonly left: Atom;
|
|
86
|
+
readonly right: Atom;
|
|
87
|
+
constructor(left: Atom, right: Atom);
|
|
88
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
89
|
+
}
|
|
90
|
+
export declare class EquivalentAtom implements Atom {
|
|
91
|
+
readonly left: Atom;
|
|
92
|
+
readonly right: Atom;
|
|
93
|
+
constructor(left: Atom, right: Atom);
|
|
94
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
95
|
+
}
|
|
96
|
+
export declare class NotEquivalentAtom implements Atom {
|
|
97
|
+
readonly left: Atom;
|
|
98
|
+
readonly right: Atom;
|
|
99
|
+
constructor(left: Atom, right: Atom);
|
|
100
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
101
|
+
}
|
|
102
|
+
export declare class IsAtom implements Atom {
|
|
103
|
+
readonly left: Atom;
|
|
104
|
+
readonly right: Atom;
|
|
105
|
+
constructor(left: Atom, right: Atom);
|
|
106
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 6.5.1. and
|
|
110
|
+
* Returns true if both operands evaluate to true,
|
|
111
|
+
* false if either operand evaluates to false,
|
|
112
|
+
* and the empty collection otherwise.
|
|
113
|
+
*/
|
|
114
|
+
export declare class AndAtom implements Atom {
|
|
115
|
+
readonly left: Atom;
|
|
116
|
+
readonly right: Atom;
|
|
117
|
+
constructor(left: Atom, right: Atom);
|
|
118
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
119
|
+
}
|
|
120
|
+
export declare class OrAtom implements Atom {
|
|
121
|
+
readonly left: Atom;
|
|
122
|
+
readonly right: Atom;
|
|
123
|
+
constructor(left: Atom, right: Atom);
|
|
124
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* 6.5.4. xor
|
|
128
|
+
* Returns true if exactly one of the operands evaluates to true,
|
|
129
|
+
* false if either both operands evaluate to true or both operands evaluate to false,
|
|
130
|
+
* and the empty collection otherwise.
|
|
131
|
+
*/
|
|
132
|
+
export declare class XorAtom implements Atom {
|
|
133
|
+
readonly left: Atom;
|
|
134
|
+
readonly right: Atom;
|
|
135
|
+
constructor(left: Atom, right: Atom);
|
|
136
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
137
|
+
}
|
|
138
|
+
export declare class FunctionAtom implements Atom {
|
|
139
|
+
readonly name: string;
|
|
140
|
+
readonly args: Atom[];
|
|
141
|
+
readonly impl: FhirPathFunction;
|
|
142
|
+
constructor(name: string, args: Atom[], impl: FhirPathFunction);
|
|
143
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
144
|
+
}
|
|
145
|
+
export declare class IndexerAtom implements Atom {
|
|
146
|
+
readonly left: Atom;
|
|
147
|
+
readonly expr: Atom;
|
|
148
|
+
constructor(left: Atom, expr: Atom);
|
|
149
|
+
eval(context: TypedValue[]): TypedValue[];
|
|
150
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parseDateString(str: string): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FhirPathAtom, TypedValue } from './atoms';
|
|
2
|
+
/**
|
|
3
|
+
* Parses a FHIRPath expression into an AST.
|
|
4
|
+
* The result can be used to evaluate the expression against a resource or other object.
|
|
5
|
+
* This method is useful if you know that you will evaluate the same expression many times
|
|
6
|
+
* against different resources.
|
|
7
|
+
* @param input The FHIRPath expression to parse.
|
|
8
|
+
* @returns The AST representing the expression.
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseFhirPath(input: string): FhirPathAtom;
|
|
11
|
+
/**
|
|
12
|
+
* Evaluates a FHIRPath expression against a resource or other object.
|
|
13
|
+
* @param input The FHIRPath expression to parse.
|
|
14
|
+
* @param context The resource or object to evaluate the expression against.
|
|
15
|
+
* @returns The result of the FHIRPath expression against the resource or object.
|
|
16
|
+
*/
|
|
17
|
+
export declare function evalFhirPath(expression: string, input: unknown): unknown[];
|
|
18
|
+
/**
|
|
19
|
+
* Evaluates a FHIRPath expression against a resource or other object.
|
|
20
|
+
* @param input The FHIRPath expression to parse.
|
|
21
|
+
* @param context The resource or object to evaluate the expression against.
|
|
22
|
+
* @returns The result of the FHIRPath expression against the resource or object.
|
|
23
|
+
*/
|
|
24
|
+
export declare function evalFhirPathTyped(expression: string, input: TypedValue[]): TypedValue[];
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Period, Quantity } from '@medplum/fhirtypes';
|
|
2
|
+
import { TypedValue } from './atoms';
|
|
3
|
+
/**
|
|
4
|
+
* Returns a single element array with a typed boolean value.
|
|
5
|
+
* @param value The primitive boolean value.
|
|
6
|
+
* @returns Single element array with a typed boolean value.
|
|
7
|
+
*/
|
|
8
|
+
export declare function booleanToTypedValue(value: boolean): [TypedValue];
|
|
9
|
+
/**
|
|
10
|
+
* Returns a "best guess" TypedValue for a given value.
|
|
11
|
+
* @param value The unknown value to check.
|
|
12
|
+
* @returns A "best guess" TypedValue for the given value.
|
|
13
|
+
*/
|
|
14
|
+
export declare function toTypedValue(value: unknown): TypedValue;
|
|
15
|
+
/**
|
|
16
|
+
* Converts unknown object into a JavaScript boolean.
|
|
17
|
+
* Note that this is different than the FHIRPath "toBoolean",
|
|
18
|
+
* which has particular semantics around arrays, empty arrays, and type conversions.
|
|
19
|
+
* @param obj Any value or array of values.
|
|
20
|
+
* @returns The converted boolean value according to FHIRPath rules.
|
|
21
|
+
*/
|
|
22
|
+
export declare function toJsBoolean(obj: TypedValue[]): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the value of the property and the property type.
|
|
25
|
+
* Some property definitions support multiple types.
|
|
26
|
+
* For example, "Observation.value[x]" can be "valueString", "valueInteger", "valueQuantity", etc.
|
|
27
|
+
* According to the spec, there can only be one property for a given element definition.
|
|
28
|
+
* This function returns the value and the type.
|
|
29
|
+
* @param input The base context (FHIR resource or backbone element).
|
|
30
|
+
* @param path The property path.
|
|
31
|
+
* @returns The value of the property and the property type.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getTypedPropertyValue(input: TypedValue, path: string): TypedValue[] | TypedValue | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Removes duplicates in array using FHIRPath equality rules.
|
|
36
|
+
* @param arr The input array.
|
|
37
|
+
* @returns The result array with duplicates removed.
|
|
38
|
+
*/
|
|
39
|
+
export declare function removeDuplicates(arr: TypedValue[]): TypedValue[];
|
|
40
|
+
/**
|
|
41
|
+
* Returns a negated FHIRPath boolean expression.
|
|
42
|
+
* @param input The input array.
|
|
43
|
+
* @returns The negated type value array.
|
|
44
|
+
*/
|
|
45
|
+
export declare function fhirPathNot(input: TypedValue[]): TypedValue[];
|
|
46
|
+
/**
|
|
47
|
+
* Determines if two arrays are equal according to FHIRPath equality rules.
|
|
48
|
+
* @param x The first array.
|
|
49
|
+
* @param y The second array.
|
|
50
|
+
* @returns FHIRPath true if the arrays are equal.
|
|
51
|
+
*/
|
|
52
|
+
export declare function fhirPathArrayEquals(x: TypedValue[], y: TypedValue[]): TypedValue[];
|
|
53
|
+
/**
|
|
54
|
+
* Determines if two values are equal according to FHIRPath equality rules.
|
|
55
|
+
* @param x The first value.
|
|
56
|
+
* @param y The second value.
|
|
57
|
+
* @returns True if equal.
|
|
58
|
+
*/
|
|
59
|
+
export declare function fhirPathEquals(x: TypedValue, y: TypedValue): TypedValue[];
|
|
60
|
+
/**
|
|
61
|
+
* Determines if two arrays are equivalent according to FHIRPath equality rules.
|
|
62
|
+
* @param x The first array.
|
|
63
|
+
* @param y The second array.
|
|
64
|
+
* @returns FHIRPath true if the arrays are equivalent.
|
|
65
|
+
*/
|
|
66
|
+
export declare function fhirPathArrayEquivalent(x: TypedValue[], y: TypedValue[]): TypedValue[];
|
|
67
|
+
/**
|
|
68
|
+
* Determines if two values are equivalent according to FHIRPath equality rules.
|
|
69
|
+
* @param x The first value.
|
|
70
|
+
* @param y The second value.
|
|
71
|
+
* @returns True if equivalent.
|
|
72
|
+
*/
|
|
73
|
+
export declare function fhirPathEquivalent(x: TypedValue, y: TypedValue): TypedValue[];
|
|
74
|
+
/**
|
|
75
|
+
* Determines if the typed value is the desired type.
|
|
76
|
+
* @param typedValue The typed value to check.
|
|
77
|
+
* @param desiredType The desired type name.
|
|
78
|
+
* @returns True if the typed value is of the desired type.
|
|
79
|
+
*/
|
|
80
|
+
export declare function fhirPathIs(typedValue: TypedValue, desiredType: string): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Determines if the input is a Period object.
|
|
83
|
+
* This is heuristic based, as we do not have strong typing at runtime.
|
|
84
|
+
* @param input The input value.
|
|
85
|
+
* @returns True if the input is a period.
|
|
86
|
+
*/
|
|
87
|
+
export declare function isPeriod(input: unknown): input is Period;
|
|
88
|
+
/**
|
|
89
|
+
* Determines if the input is a Quantity object.
|
|
90
|
+
* This is heuristic based, as we do not have strong typing at runtime.
|
|
91
|
+
* @param input The input value.
|
|
92
|
+
* @returns True if the input is a quantity.
|
|
93
|
+
*/
|
|
94
|
+
export declare function isQuantity(input: unknown): input is Quantity;
|
|
95
|
+
export declare function isQuantityEquivalent(x: Quantity, y: Quantity): boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Address, HumanName, Period, Timing } from '@medplum/fhirtypes';
|
|
2
|
+
export interface AddressFormatOptions {
|
|
3
|
+
all?: boolean;
|
|
4
|
+
use?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface HumanNameFormatOptions {
|
|
7
|
+
all?: boolean;
|
|
8
|
+
prefix?: boolean;
|
|
9
|
+
suffix?: boolean;
|
|
10
|
+
use?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function formatAddress(address: Address, options?: AddressFormatOptions): string;
|
|
13
|
+
export declare function formatHumanName(name: HumanName, options?: HumanNameFormatOptions): string;
|
|
14
|
+
export declare function formatGivenName(name: HumanName): string;
|
|
15
|
+
export declare function formatFamilyName(name: HumanName): string;
|
|
16
|
+
export declare function isValidDate(date: Date): boolean;
|
|
17
|
+
export declare function formatDate(date: string | undefined, options?: Intl.DateTimeFormatOptions): string;
|
|
18
|
+
export declare function formatTime(time: string | undefined, options?: Intl.DateTimeFormatOptions): string;
|
|
19
|
+
export declare function formatDateTime(dateTime: string | undefined, options?: Intl.DateTimeFormatOptions): string;
|
|
20
|
+
export declare function formatPeriod(period: Period | undefined): string;
|
|
21
|
+
export declare function formatTiming(timing: Timing | undefined): string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare const SEGMENT_SEPARATOR = "\r";
|
|
2
|
+
export declare const FIELD_SEPARATOR = "|";
|
|
3
|
+
export declare const COMPONENT_SEPARATOR = "^";
|
|
4
|
+
/**
|
|
5
|
+
* The Hl7Message class represents one HL7 message.
|
|
6
|
+
* A message is a collection of segments.
|
|
7
|
+
* Note that we do not strictly parse messages, and only use default delimeters.
|
|
8
|
+
*/
|
|
9
|
+
export declare class Hl7Message {
|
|
10
|
+
readonly segments: Hl7Segment[];
|
|
11
|
+
constructor(segments: Hl7Segment[]);
|
|
12
|
+
get(index: number | string): Hl7Segment | undefined;
|
|
13
|
+
getAll(name: string): Hl7Segment[];
|
|
14
|
+
toString(): string;
|
|
15
|
+
buildAck(): Hl7Message;
|
|
16
|
+
static parse(text: string): Hl7Message;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The Hl7Segment class represents one HL7 segment.
|
|
20
|
+
* A segment is a collection of fields.
|
|
21
|
+
* The name field is the first field.
|
|
22
|
+
* Note that we do not strictly parse messages, and only use default delimeters.
|
|
23
|
+
*/
|
|
24
|
+
export declare class Hl7Segment {
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly fields: Hl7Field[];
|
|
27
|
+
constructor(fields: Hl7Field[] | string[]);
|
|
28
|
+
get(index: number): Hl7Field;
|
|
29
|
+
toString(): string;
|
|
30
|
+
static parse(text: string): Hl7Segment;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The Hl7Field class represents one HL7 field.
|
|
34
|
+
* A field is a collection of components.
|
|
35
|
+
* Note that we do not strictly parse messages, and only use default delimeters.
|
|
36
|
+
*/
|
|
37
|
+
export declare class Hl7Field {
|
|
38
|
+
readonly components: string[];
|
|
39
|
+
constructor(components: string[]);
|
|
40
|
+
get(index: number): string;
|
|
41
|
+
toString(): string;
|
|
42
|
+
static parse(text: string): Hl7Field;
|
|
43
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './cache';
|
|
2
|
+
export * from './client';
|
|
3
|
+
export * from './fhirpath';
|
|
4
|
+
export * from './format';
|
|
5
|
+
export * from './hl7';
|
|
6
|
+
export * from './jwt';
|
|
7
|
+
export * from './outcomes';
|
|
8
|
+
export * from './readablepromise';
|
|
9
|
+
export * from './search';
|
|
10
|
+
export * from './searchparams';
|
|
11
|
+
export * from './types';
|
|
12
|
+
export * from './utils';
|