@medplum/core 2.1.3 → 2.1.5
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/dist/cjs/index.cjs +15 -6
- package/dist/cjs/index.cjs.map +4 -4
- package/dist/esm/index.mjs +15 -6
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/base-schema.d.ts +7 -0
- package/dist/types/client.d.ts +41 -13
- package/dist/types/constants.d.ts +6 -0
- package/dist/types/eventtarget.d.ts +6 -0
- package/dist/types/fhircast/index.d.ts +115 -0
- package/dist/types/fhircast/test-utils.d.ts +2 -0
- package/dist/types/fhirmapper/tokenize.d.ts +1 -1
- package/dist/types/fhirpath/atoms.d.ts +1 -1
- package/dist/types/fhirpath/functions.d.ts +1 -1
- package/dist/types/fhirpath/parse.d.ts +1 -1
- package/dist/types/fhirpath/tokenize.d.ts +1 -1
- package/dist/types/filter/tokenize.d.ts +1 -1
- package/dist/types/index.d.ts +9 -4
- package/dist/types/schema.d.ts +1 -104
- package/dist/types/search/details.d.ts +4 -3
- package/dist/types/search/search.d.ts +11 -0
- package/dist/types/types.d.ts +80 -92
- package/dist/types/typeschema/types.d.ts +32 -10
- package/dist/types/utils.d.ts +19 -1
- package/package.json +3 -2
- package/dist/types/fhirlexer/index.d.ts +0 -2
- package/dist/types/fhirmapper/index.d.ts +0 -1
- package/dist/types/fhirpath/index.d.ts +0 -4
- package/dist/types/filter/index.d.ts +0 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InternalSchemaElement, InternalTypeSchema } from './typeschema/types';
|
|
2
|
+
export type BaseSchema = Record<string, {
|
|
3
|
+
elements: Record<string, Partial<InternalSchemaElement>>;
|
|
4
|
+
}>;
|
|
5
|
+
export declare function compressElement(element: InternalSchemaElement): Partial<InternalSchemaElement>;
|
|
6
|
+
export declare function inflateElement(partial: Partial<InternalSchemaElement>): InternalSchemaElement;
|
|
7
|
+
export declare function inflateBaseSchema(base: BaseSchema): Record<string, InternalTypeSchema>;
|
package/dist/types/client.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { AccessPolicy, Agent, Attachment, Binary, BulkDataExport, Bundle, Commun
|
|
|
2
2
|
/** @ts-ignore */
|
|
3
3
|
import type { CustomTableLayout, TDocumentDefinitions, TFontDictionary } from 'pdfmake/interfaces';
|
|
4
4
|
import { EventTarget } from './eventtarget';
|
|
5
|
+
import { FhircastConnection, FhircastEventContext, FhircastEventName, SubscriptionRequest } from './fhircast';
|
|
5
6
|
import { Hl7Message } from './hl7';
|
|
6
7
|
import { ReadablePromise } from './readablepromise';
|
|
7
8
|
import { ClientStorage } from './storage';
|
|
8
|
-
import { IndexedStructureDefinition } from './types';
|
|
9
9
|
import { CodeChallengeMethod, ProfileResource } from './utils';
|
|
10
10
|
export declare const MEDPLUM_VERSION: string;
|
|
11
11
|
/**
|
|
@@ -907,15 +907,6 @@ export declare class MedplumClient extends EventTarget {
|
|
|
907
907
|
* @returns The resource if available; undefined otherwise.
|
|
908
908
|
*/
|
|
909
909
|
readReference<T extends Resource>(reference: Reference<T>, options?: RequestInit): ReadablePromise<T>;
|
|
910
|
-
/**
|
|
911
|
-
* Returns a cached schema for a resource type.
|
|
912
|
-
* If the schema is not cached, returns undefined.
|
|
913
|
-
* It is assumed that a client will call requestSchema before using this method.
|
|
914
|
-
* @category Schema
|
|
915
|
-
* @returns The schema if immediately available, undefined otherwise.
|
|
916
|
-
* @deprecated Use globalSchema instead.
|
|
917
|
-
*/
|
|
918
|
-
getSchema(): IndexedStructureDefinition;
|
|
919
910
|
/**
|
|
920
911
|
* Requests the schema for a resource type.
|
|
921
912
|
* If the schema is already cached, the promise is resolved immediately.
|
|
@@ -923,7 +914,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
923
914
|
* @param resourceType The FHIR resource type.
|
|
924
915
|
* @returns Promise to a schema with the requested resource type.
|
|
925
916
|
*/
|
|
926
|
-
requestSchema(resourceType: string): Promise<
|
|
917
|
+
requestSchema(resourceType: string): Promise<void>;
|
|
927
918
|
/**
|
|
928
919
|
* Reads resource history by resource type and ID.
|
|
929
920
|
*
|
|
@@ -1455,9 +1446,9 @@ export declare class MedplumClient extends EventTarget {
|
|
|
1455
1446
|
*/
|
|
1456
1447
|
getProfile(): ProfileResource | undefined;
|
|
1457
1448
|
/**
|
|
1458
|
-
* Returns the current user profile resource if
|
|
1449
|
+
* Returns the current user profile resource, retrieving form the server if necessary.
|
|
1459
1450
|
* This method waits for loading promises.
|
|
1460
|
-
* @returns The current user profile resource
|
|
1451
|
+
* @returns The current user profile resource.
|
|
1461
1452
|
* @category User Profile
|
|
1462
1453
|
*/
|
|
1463
1454
|
getProfileAsync(): Promise<ProfileResource | undefined>;
|
|
@@ -1667,6 +1658,43 @@ export declare class MedplumClient extends EventTarget {
|
|
|
1667
1658
|
* @param clientSecret The client secret.
|
|
1668
1659
|
*/
|
|
1669
1660
|
setBasicAuth(clientId: string, clientSecret: string): void;
|
|
1661
|
+
/**
|
|
1662
|
+
* Subscribes to a specified topic, listening for a list of specified events.
|
|
1663
|
+
*
|
|
1664
|
+
* Once you have the `SubscriptionRequest` returned from this method, you can call `fhircastConnect(subscriptionRequest)` to connect to the subscription stream.
|
|
1665
|
+
*
|
|
1666
|
+
* @category FHIRcast
|
|
1667
|
+
* @param topic The topic to publish to. Usually a UUID.
|
|
1668
|
+
* @param events An array of event names to listen for.
|
|
1669
|
+
* @returns A `Promise` that resolves once the request completes, or rejects if it fails.
|
|
1670
|
+
*/
|
|
1671
|
+
fhircastSubscribe(topic: string, events: FhircastEventName[]): Promise<SubscriptionRequest>;
|
|
1672
|
+
/**
|
|
1673
|
+
* Unsubscribes from the specified topic.
|
|
1674
|
+
*
|
|
1675
|
+
* @category FHIRcast
|
|
1676
|
+
* @param subRequest A `SubscriptionRequest` representing a subscription to cancel. Mode will be set to `unsubscribe` automatically.
|
|
1677
|
+
* @returns A `Promise` that resolves when request to unsubscribe is completed.
|
|
1678
|
+
*/
|
|
1679
|
+
fhircastUnsubscribe(subRequest: SubscriptionRequest): Promise<void>;
|
|
1680
|
+
/**
|
|
1681
|
+
* Connects to a `FHIRcast` session.
|
|
1682
|
+
*
|
|
1683
|
+
* @category FHIRcast
|
|
1684
|
+
* @param subRequest The `SubscriptionRequest` to use for connecting.
|
|
1685
|
+
* @returns A `FhircastConnection` which emits lifecycle events for the `FHIRcast` WebSocket connection.
|
|
1686
|
+
*/
|
|
1687
|
+
fhircastConnect(subRequest: SubscriptionRequest): FhircastConnection;
|
|
1688
|
+
/**
|
|
1689
|
+
* Publishes a new context to a given topic for a specified event type.
|
|
1690
|
+
*
|
|
1691
|
+
* @category FHIRcast
|
|
1692
|
+
* @param topic The topic to publish to. Usually a UUID.
|
|
1693
|
+
* @param event The name of the event to publish an updated context for, ie. `patient-open`.
|
|
1694
|
+
* @param context The updated context containing resources relevant to this event.
|
|
1695
|
+
* @returns A `Promise` that resolves once the request completes, or rejects if it fails.
|
|
1696
|
+
*/
|
|
1697
|
+
fhircastPublish(topic: string, event: FhircastEventName, context: FhircastEventContext | FhircastEventContext[]): Promise<void>;
|
|
1670
1698
|
/**
|
|
1671
1699
|
* Invite a user to a project.
|
|
1672
1700
|
* @param projectId The project ID.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const UCUM = "http://unitsofmeasure.org";
|
|
2
|
+
export declare const LOINC = "http://loinc.org";
|
|
3
|
+
export declare const SNOMED = "http://snomed.info/sct";
|
|
4
|
+
export declare const RXNORM = "http://www.nlm.nih.gov/research/umls/rxnorm";
|
|
5
|
+
export declare const CPT = "http://www.ama-assn.org/go/cpt";
|
|
6
|
+
export declare const ICD10 = "http://hl7.org/fhir/sid/icd-10";
|
|
@@ -10,3 +10,9 @@ export declare class EventTarget {
|
|
|
10
10
|
removeEventListener(type: string, callback: EventListener): void;
|
|
11
11
|
dispatchEvent(event: Event): boolean;
|
|
12
12
|
}
|
|
13
|
+
export declare class TypedEventTarget<TEvents extends Record<string, Event>> {
|
|
14
|
+
private emitter;
|
|
15
|
+
dispatchEvent<TEventType extends keyof TEvents & string>(event: TEvents[TEventType]): void;
|
|
16
|
+
addEventListener<TEventType extends keyof TEvents & string>(type: TEventType, handler: (event: TEvents[TEventType]) => void): void;
|
|
17
|
+
removeEventListener<TEventType extends keyof TEvents & string>(type: TEventType, handler: (event: TEvents[TEventType]) => void): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { Resource } from '@medplum/fhirtypes';
|
|
2
|
+
import { TypedEventTarget } from '../eventtarget';
|
|
3
|
+
declare const FHIRCAST_EVENT_NAMES: {
|
|
4
|
+
readonly 'patient-open': "patient-open";
|
|
5
|
+
readonly 'patient-close': "patient-close";
|
|
6
|
+
readonly 'imagingstudy-open': "imagingstudy-open";
|
|
7
|
+
readonly 'imagingstudy-close': "imagingstudy-close";
|
|
8
|
+
};
|
|
9
|
+
declare const FHIRCAST_RESOURCE_TYPES: readonly ["Patient", "Encounter", "ImagingStudy"];
|
|
10
|
+
export type FhircastEventName = keyof typeof FHIRCAST_EVENT_NAMES;
|
|
11
|
+
export type FhircastResourceType = (typeof FHIRCAST_RESOURCE_TYPES)[number];
|
|
12
|
+
/**
|
|
13
|
+
* Checks if a `ResourceType` can be used in a `FHIRcast` context.
|
|
14
|
+
*
|
|
15
|
+
* @param resourceType A `ResourceType` to test.
|
|
16
|
+
* @returns `true` if this is a resource type associated with `FHIRcast` contexts, otherwise returns `false`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isFhircastResourceType(resourceType: FhircastResourceType): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* A `FHIRcast` subscription request.
|
|
21
|
+
*
|
|
22
|
+
* Can be passed to `MedplumClient.fhircastConnect` or `MedplumClient.fhircastUnsubscribe` to either open a `FHIRcast` connection, or unsubscribe from the subscription.
|
|
23
|
+
*/
|
|
24
|
+
export type SubscriptionRequest = {
|
|
25
|
+
channelType: 'websocket';
|
|
26
|
+
mode: 'subscribe' | 'unsubscribe';
|
|
27
|
+
events: FhircastEventName[];
|
|
28
|
+
topic: string;
|
|
29
|
+
endpoint: string;
|
|
30
|
+
};
|
|
31
|
+
export type PendingSubscriptionRequest = Omit<SubscriptionRequest, 'endpoint'>;
|
|
32
|
+
declare const FHIRCAST_CONTEXT_KEY_LOOKUP: {
|
|
33
|
+
readonly study: "ImagingStudy";
|
|
34
|
+
readonly patient: "Patient";
|
|
35
|
+
readonly encounter: "Encounter";
|
|
36
|
+
};
|
|
37
|
+
type FhircastEventContextMap = typeof FHIRCAST_CONTEXT_KEY_LOOKUP;
|
|
38
|
+
type FhircastEventContextKey = keyof FhircastEventContextMap;
|
|
39
|
+
export type FhircastEventContext<K extends FhircastEventContextKey = FhircastEventContextKey> = {
|
|
40
|
+
key: K;
|
|
41
|
+
resource: Resource & {
|
|
42
|
+
resourceType: FhircastEventContextMap[K];
|
|
43
|
+
id: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export type FhircastEventPayload = {
|
|
47
|
+
'hub.topic': string;
|
|
48
|
+
'hub.event': string;
|
|
49
|
+
context: FhircastEventContext[];
|
|
50
|
+
};
|
|
51
|
+
export type FhircastMessagePayload = {
|
|
52
|
+
timestamp: string;
|
|
53
|
+
id: string;
|
|
54
|
+
event: FhircastEventPayload;
|
|
55
|
+
};
|
|
56
|
+
export declare function isCompletedSubscriptionRequest(subscriptionRequest: SubscriptionRequest | PendingSubscriptionRequest): subscriptionRequest is SubscriptionRequest;
|
|
57
|
+
/**
|
|
58
|
+
* Creates a serialized url-encoded payload for a `FHIRcast` subscription from a `SubscriptionRequest` object that can be directly used in an HTTP request to the Hub.
|
|
59
|
+
*
|
|
60
|
+
* @param subscriptionRequest An object representing a subscription request.
|
|
61
|
+
* @returns A serialized subscription in url-encoded form.
|
|
62
|
+
*/
|
|
63
|
+
export declare function serializeFhircastSubscriptionRequest(subscriptionRequest: SubscriptionRequest | PendingSubscriptionRequest): string;
|
|
64
|
+
/**
|
|
65
|
+
* Validates that a `SubscriptionRequest`.
|
|
66
|
+
*
|
|
67
|
+
* @param subscriptionRequest The `SubscriptionRequest` to validate.
|
|
68
|
+
* @returns A `boolean` indicating whether or not the `SubscriptionRequest` is valid.
|
|
69
|
+
*/
|
|
70
|
+
export declare function validateFhircastSubscriptionRequest(subscriptionRequest: SubscriptionRequest | PendingSubscriptionRequest): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Creates a serializable JSON payload for the `FHIRcast` protocol
|
|
73
|
+
*
|
|
74
|
+
* @param topic The topic that this message will be published on. Usually a UUID.
|
|
75
|
+
* @param event The event name, ie. "patient-open" or "patient-close".
|
|
76
|
+
* @param context The updated context, containing new versions of resources related to this event.
|
|
77
|
+
* @returns A serializable `FhircastMessagePayload`.
|
|
78
|
+
*/
|
|
79
|
+
export declare function createFhircastMessagePayload(topic: string, event: FhircastEventName, context: FhircastEventContext | FhircastEventContext[]): FhircastMessagePayload;
|
|
80
|
+
export type FhircastConnectEvent = {
|
|
81
|
+
type: 'connect';
|
|
82
|
+
};
|
|
83
|
+
export type FhircastMessageEvent = {
|
|
84
|
+
type: 'message';
|
|
85
|
+
payload: FhircastMessagePayload;
|
|
86
|
+
};
|
|
87
|
+
export type FhircastDisconnectEvent = {
|
|
88
|
+
type: 'disconnect';
|
|
89
|
+
};
|
|
90
|
+
export type FhircastSubscriptionEventMap = {
|
|
91
|
+
connect: FhircastConnectEvent;
|
|
92
|
+
message: FhircastMessageEvent;
|
|
93
|
+
disconnect: FhircastDisconnectEvent;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* A class representing a `FHIRcast` connection.
|
|
97
|
+
*
|
|
98
|
+
* `FhircastConnection` extends `EventTarget` and emits 3 lifecycle events:
|
|
99
|
+
* 1. `connect` - An event to signal when a WebSocket connection has been opened. Fired as soon as a WebSocket emits `open`.
|
|
100
|
+
* 2. `message` - Contains a `payload` field containing a `FHIRcast` message payload exactly as it comes in over WebSockets.
|
|
101
|
+
* 3. `disconnect` - An event to signal when a WebSocket connection has been closed. Fired as soon as a WebSocket emits `close`.
|
|
102
|
+
*
|
|
103
|
+
* To close the connection, call `connection.disconnect()` and listen to the `disconnect` event to know when the connection has been disconnected.
|
|
104
|
+
*/
|
|
105
|
+
export declare class FhircastConnection extends TypedEventTarget<FhircastSubscriptionEventMap> {
|
|
106
|
+
subRequest: SubscriptionRequest;
|
|
107
|
+
private websocket;
|
|
108
|
+
/**
|
|
109
|
+
* Creates a new `FhircastConnection`.
|
|
110
|
+
* @param subRequest The subscription request to initialize the connection from.
|
|
111
|
+
*/
|
|
112
|
+
constructor(subRequest: SubscriptionRequest);
|
|
113
|
+
disconnect(): void;
|
|
114
|
+
}
|
|
115
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Token } from '../fhirlexer';
|
|
1
|
+
import { Token } from '../fhirlexer/tokenize';
|
|
2
2
|
export declare function tokenize(str: string): Token[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Atom, AtomContext, InfixOperatorAtom, PrefixOperatorAtom } from '../fhirlexer';
|
|
1
|
+
import { Atom, AtomContext, InfixOperatorAtom, PrefixOperatorAtom } from '../fhirlexer/parse';
|
|
2
2
|
import { TypedValue } from '../types';
|
|
3
3
|
export declare class FhirPathAtom implements Atom {
|
|
4
4
|
readonly original: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Atom, AtomContext } from '../fhirlexer';
|
|
1
|
+
import { Atom, AtomContext } from '../fhirlexer/parse';
|
|
2
2
|
import { TypedValue } from '../types';
|
|
3
3
|
export type FhirPathFunction = (context: AtomContext, input: TypedValue[], ...args: Atom[]) => TypedValue[];
|
|
4
4
|
export declare const functions: Record<string, FhirPathFunction>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Token } from '../fhirlexer';
|
|
1
|
+
import { Token } from '../fhirlexer/tokenize';
|
|
2
2
|
export declare function tokenize(str: string): Token[];
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
export * from './access';
|
|
2
2
|
export * from './base64';
|
|
3
|
+
export * from './base-schema';
|
|
3
4
|
export * from './bundle';
|
|
4
5
|
export * from './cache';
|
|
5
6
|
export * from './client';
|
|
6
7
|
export * from './config';
|
|
8
|
+
export * from './constants';
|
|
7
9
|
export * from './contenttype';
|
|
8
10
|
export * from './crypto';
|
|
9
11
|
export * from './eventtarget';
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './
|
|
12
|
+
export * from './fhircast';
|
|
13
|
+
export * from './fhirlexer/parse';
|
|
14
|
+
export * from './fhirmapper/parse';
|
|
15
|
+
export * from './fhirpath/parse';
|
|
16
|
+
export * from './fhirpath/utils';
|
|
17
|
+
export * from './filter/parse';
|
|
18
|
+
export * from './filter/types';
|
|
14
19
|
export * from './format';
|
|
15
20
|
export * from './hl7';
|
|
16
21
|
export * from './jwt';
|
package/dist/types/schema.d.ts
CHANGED
|
@@ -1,36 +1,4 @@
|
|
|
1
|
-
import { OperationOutcomeIssue
|
|
2
|
-
/**
|
|
3
|
-
* Returns true if the given string is a valid FHIR resource type.
|
|
4
|
-
*
|
|
5
|
-
* ```ts
|
|
6
|
-
* isResourceType('Patient'); // true
|
|
7
|
-
* isResourceType('XYZ'); // false
|
|
8
|
-
* ```
|
|
9
|
-
*
|
|
10
|
-
* Note that this depends on globalSchema, which is populated by the StructureDefinition loader.
|
|
11
|
-
*
|
|
12
|
-
* In a server context, you can load all schema definitions:
|
|
13
|
-
*
|
|
14
|
-
* ```ts
|
|
15
|
-
* import { indexStructureDefinitionBundle } from '@medplum/core';
|
|
16
|
-
* import { readJson } from '@medplum/definitions';
|
|
17
|
-
* import { Bundle } from '@medplum/fhirtypes';
|
|
18
|
-
*
|
|
19
|
-
* indexStructureDefinitionBundle(readJson('fhir/r4/profiles-resources.json') as Bundle);
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* In a client context, you can load the schema definitions using MedplumClient:
|
|
23
|
-
*
|
|
24
|
-
* ```ts
|
|
25
|
-
* import { MedplumClient } from '@medplum/core';
|
|
26
|
-
*
|
|
27
|
-
* const medplum = new MedplumClient();
|
|
28
|
-
* await medplum.requestSchema('Patient');
|
|
29
|
-
* ```
|
|
30
|
-
* @param resourceType The candidate resource type string.
|
|
31
|
-
* @returns True if the resource type is a valid FHIR resource type.
|
|
32
|
-
*/
|
|
33
|
-
export declare function isResourceType(resourceType: string): boolean;
|
|
1
|
+
import { OperationOutcomeIssue } from '@medplum/fhirtypes';
|
|
34
2
|
/**
|
|
35
3
|
* Validates that the given string is a valid FHIR resource type.
|
|
36
4
|
* On success, silently returns void.
|
|
@@ -64,77 +32,6 @@ export declare function isResourceType(resourceType: string): boolean;
|
|
|
64
32
|
* @param resourceType The candidate resource type string.
|
|
65
33
|
*/
|
|
66
34
|
export declare function validateResourceType(resourceType: string): void;
|
|
67
|
-
/**
|
|
68
|
-
* Validates a candidate FHIR resource object.
|
|
69
|
-
* On success, silently returns void.
|
|
70
|
-
* On failure, throws an OperationOutcomeError with issues for each violation.
|
|
71
|
-
*
|
|
72
|
-
* ```ts
|
|
73
|
-
* validateResource({ resourceType: 'Patient' }); // nothing
|
|
74
|
-
* validateResource({ resourceType: 'XYZ' }); // throws OperationOutcomeError
|
|
75
|
-
* ```
|
|
76
|
-
*
|
|
77
|
-
* Note that this depends on globalSchema, which is populated by the StructureDefinition loader.
|
|
78
|
-
*
|
|
79
|
-
* In a server context, you can load all schema definitions:
|
|
80
|
-
*
|
|
81
|
-
* ```ts
|
|
82
|
-
* import { indexStructureDefinitionBundle } from '@medplum/core';
|
|
83
|
-
* import { readJson } from '@medplum/definitions';
|
|
84
|
-
* import { Bundle } from '@medplum/fhirtypes';
|
|
85
|
-
*
|
|
86
|
-
* indexStructureDefinitionBundle(readJson('fhir/r4/profiles-resources.json') as Bundle);
|
|
87
|
-
* ```
|
|
88
|
-
*
|
|
89
|
-
* In a client context, you can load the schema definitions using MedplumClient:
|
|
90
|
-
*
|
|
91
|
-
* ```ts
|
|
92
|
-
* import { MedplumClient } from '@medplum/core';
|
|
93
|
-
*
|
|
94
|
-
* const medplum = new MedplumClient();
|
|
95
|
-
* await medplum.requestSchema('Patient');
|
|
96
|
-
* ```
|
|
97
|
-
* @param resource The candidate resource.
|
|
98
|
-
* @deprecated use validate() instead
|
|
99
|
-
*/
|
|
100
|
-
export declare function validateResource<T extends Resource>(resource: T): void;
|
|
101
|
-
export declare class FhirSchemaValidator<T extends Resource> {
|
|
102
|
-
private readonly issues;
|
|
103
|
-
private readonly root;
|
|
104
|
-
constructor(root: T);
|
|
105
|
-
validate(): void;
|
|
106
|
-
private validateObject;
|
|
107
|
-
private checkProperties;
|
|
108
|
-
private checkProperty;
|
|
109
|
-
private checkPropertyValue;
|
|
110
|
-
private validatePrimitiveType;
|
|
111
|
-
private validateString;
|
|
112
|
-
private validateNumber;
|
|
113
|
-
private checkAdditionalProperties;
|
|
114
|
-
/**
|
|
115
|
-
* Checks if the given property is allowed on the given object.
|
|
116
|
-
* @param path The path of the current object.
|
|
117
|
-
* @param key The key of a property to check.
|
|
118
|
-
* @param typedValue The current object.
|
|
119
|
-
* @param propertyDefinitions The property definitions of the current object.
|
|
120
|
-
*/
|
|
121
|
-
private checkAdditionalProperty;
|
|
122
|
-
/**
|
|
123
|
-
* Checks the element for a primitive.
|
|
124
|
-
*
|
|
125
|
-
* FHIR elements with primitive data types are represented in two parts:
|
|
126
|
-
* 1) A JSON property with the name of the element, which has a JSON type of number, boolean, or string
|
|
127
|
-
* 2) a JSON property with _ prepended to the name of the element, which, if present, contains the value's id and/or extensions
|
|
128
|
-
*
|
|
129
|
-
* See: https://hl7.org/fhir/json.html#primitive
|
|
130
|
-
* @param path The path to the property
|
|
131
|
-
* @param key The key in the current typed value.
|
|
132
|
-
* @param typedValue The current typed value.
|
|
133
|
-
* @returns True if the primitive element is valid.
|
|
134
|
-
*/
|
|
135
|
-
private checkPrimitiveElement;
|
|
136
|
-
private createIssue;
|
|
137
|
-
}
|
|
138
35
|
/**
|
|
139
36
|
* Recursively checks for null values in an object.
|
|
140
37
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Atom } from '../fhirlexer';
|
|
1
|
+
import { SearchParameter } from '@medplum/fhirtypes';
|
|
2
|
+
import { Atom } from '../fhirlexer/parse';
|
|
3
|
+
import { InternalSchemaElement } from '../typeschema/types';
|
|
3
4
|
export declare enum SearchParameterType {
|
|
4
5
|
BOOLEAN = "BOOLEAN",
|
|
5
6
|
NUMBER = "NUMBER",
|
|
@@ -15,7 +16,7 @@ export declare enum SearchParameterType {
|
|
|
15
16
|
export interface SearchParameterDetails {
|
|
16
17
|
readonly columnName: string;
|
|
17
18
|
readonly type: SearchParameterType;
|
|
18
|
-
readonly elementDefinitions?:
|
|
19
|
+
readonly elementDefinitions?: InternalSchemaElement[];
|
|
19
20
|
readonly array?: boolean;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Resource } from '@medplum/fhirtypes';
|
|
2
|
+
import { TypedValue } from '../types';
|
|
2
3
|
export declare const DEFAULT_SEARCH_COUNT = 20;
|
|
3
4
|
export interface SearchRequest<T extends Resource = Resource> {
|
|
4
5
|
readonly resourceType: T['resourceType'];
|
|
@@ -82,6 +83,16 @@ export declare function parseSearchDefinition<T extends Resource = Resource>(url
|
|
|
82
83
|
* @returns Parsed search definition.
|
|
83
84
|
*/
|
|
84
85
|
export declare function parseCriteriaAsSearchRequest(criteria: string): SearchRequest;
|
|
86
|
+
/**
|
|
87
|
+
* Parses an extended FHIR search criteria string (i.e. application/x-fhir-query), evaluating
|
|
88
|
+
* any embedded FHIRPath subexpressions (e.g. `{{ %patient.id }}`) with the provided variables.
|
|
89
|
+
*
|
|
90
|
+
* @see https://hl7.org/fhir/fhir-xquery.html
|
|
91
|
+
* @param query The X-Fhir-Query string to parse
|
|
92
|
+
* @param variables Values to pass into embedded FHIRPath expressions
|
|
93
|
+
* @returns The parsed search request
|
|
94
|
+
*/
|
|
95
|
+
export declare function parseXFhirQuery(query: string, variables: Record<string, TypedValue>): SearchRequest;
|
|
85
96
|
/**
|
|
86
97
|
* Formats a search definition object into a query string.
|
|
87
98
|
* Note: The return value does not include the resource type.
|