@medplum/core 0.10.2 → 1.0.1
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/client.d.ts +60 -15
- package/dist/cjs/format.d.ts +13 -1
- package/dist/cjs/hl7.d.ts +106 -13
- package/dist/cjs/index.js +304 -69
- 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/search.d.ts +1 -0
- package/dist/cjs/utils.d.ts +8 -1
- package/dist/esm/client.d.ts +60 -15
- package/dist/esm/client.js +87 -10
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/format.d.ts +13 -1
- package/dist/esm/format.js +49 -1
- package/dist/esm/format.js.map +1 -1
- package/dist/esm/hl7.d.ts +106 -13
- package/dist/esm/hl7.js +135 -25
- package/dist/esm/hl7.js.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/match.js +6 -15
- package/dist/esm/match.js.map +1 -1
- package/dist/esm/search.d.ts +1 -0
- package/dist/esm/search.js.map +1 -1
- package/dist/esm/utils.d.ts +8 -1
- package/dist/esm/utils.js +26 -16
- package/dist/esm/utils.js.map +1 -1
- package/package.json +5 -5
- package/rollup.config.mjs +104 -0
- package/stats.html +0 -4034
package/dist/cjs/client.d.ts
CHANGED
|
@@ -136,16 +136,21 @@ export interface CreatePdfFunction {
|
|
|
136
136
|
[name: string]: CustomTableLayout;
|
|
137
137
|
} | undefined, fonts?: TFontDictionary | undefined): Promise<any>;
|
|
138
138
|
}
|
|
139
|
-
export interface
|
|
140
|
-
readonly email: string;
|
|
141
|
-
readonly password: string;
|
|
142
|
-
readonly remember?: boolean;
|
|
139
|
+
export interface BaseLoginRequest {
|
|
143
140
|
readonly projectId?: string;
|
|
144
141
|
readonly clientId?: string;
|
|
142
|
+
readonly resourceType?: string;
|
|
145
143
|
readonly scope?: string;
|
|
146
144
|
readonly nonce?: string;
|
|
147
145
|
readonly codeChallenge?: string;
|
|
148
146
|
readonly codeChallengeMethod?: string;
|
|
147
|
+
readonly googleClientId?: string;
|
|
148
|
+
readonly launch?: string;
|
|
149
|
+
}
|
|
150
|
+
export interface EmailPasswordLoginRequest extends BaseLoginRequest {
|
|
151
|
+
readonly email: string;
|
|
152
|
+
readonly password: string;
|
|
153
|
+
readonly remember?: boolean;
|
|
149
154
|
}
|
|
150
155
|
export interface NewUserRequest {
|
|
151
156
|
readonly firstName: string;
|
|
@@ -169,15 +174,9 @@ export interface GoogleCredentialResponse {
|
|
|
169
174
|
readonly clientId: string;
|
|
170
175
|
readonly credential: string;
|
|
171
176
|
}
|
|
172
|
-
export interface GoogleLoginRequest {
|
|
177
|
+
export interface GoogleLoginRequest extends BaseLoginRequest {
|
|
173
178
|
readonly googleClientId: string;
|
|
174
179
|
readonly googleCredential: string;
|
|
175
|
-
readonly projectId?: string;
|
|
176
|
-
readonly clientId?: string;
|
|
177
|
-
readonly scope?: string;
|
|
178
|
-
readonly nonce?: string;
|
|
179
|
-
readonly codeChallenge?: string;
|
|
180
|
-
readonly codeChallengeMethod?: string;
|
|
181
180
|
readonly createUser?: boolean;
|
|
182
181
|
}
|
|
183
182
|
export interface LoginAuthenticationResponse {
|
|
@@ -316,6 +315,11 @@ export interface MailOptions {
|
|
|
316
315
|
* const bundle = await medplum.search('Patient', 'name=Alice');
|
|
317
316
|
* console.log(bundle.total);
|
|
318
317
|
* ```
|
|
318
|
+
*
|
|
319
|
+
* <head>
|
|
320
|
+
* <meta name="algolia:pageRank" content="100" />
|
|
321
|
+
* </head>
|
|
322
|
+
|
|
319
323
|
*/
|
|
320
324
|
export declare class MedplumClient extends EventTarget {
|
|
321
325
|
#private;
|
|
@@ -452,7 +456,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
452
456
|
* @param loginRequest Login request including email and password.
|
|
453
457
|
* @returns Promise to the authentication response.
|
|
454
458
|
*/
|
|
455
|
-
startLogin(loginRequest:
|
|
459
|
+
startLogin(loginRequest: EmailPasswordLoginRequest): Promise<LoginAuthenticationResponse>;
|
|
456
460
|
/**
|
|
457
461
|
* Tries to sign in with Google authentication.
|
|
458
462
|
* The response parameter is the result of a Google authentication.
|
|
@@ -462,7 +466,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
462
466
|
* @returns Promise to the authentication response.
|
|
463
467
|
*/
|
|
464
468
|
startGoogleLogin(loginRequest: GoogleLoginRequest): Promise<LoginAuthenticationResponse>;
|
|
465
|
-
getCodeChallenge(loginRequest:
|
|
469
|
+
getCodeChallenge(loginRequest: BaseLoginRequest): {
|
|
466
470
|
codeChallenge?: string;
|
|
467
471
|
codeChallengeMethod?: string;
|
|
468
472
|
};
|
|
@@ -544,7 +548,9 @@ export declare class MedplumClient extends EventTarget {
|
|
|
544
548
|
* See FHIR search for full details: https://www.hl7.org/fhir/search.html
|
|
545
549
|
*
|
|
546
550
|
* @category Search
|
|
551
|
+
* @param resourceType The FHIR resource type.
|
|
547
552
|
* @param query The search query as either a string or a structured search object.
|
|
553
|
+
* @param options Optional fetch options.
|
|
548
554
|
* @returns Promise to the search result bundle.
|
|
549
555
|
*/
|
|
550
556
|
search<K extends ResourceType>(resourceType: K, query?: URLSearchParams | string, options?: RequestInit): ReadablePromise<Bundle<ExtractResource<K>>>;
|
|
@@ -565,7 +571,9 @@ export declare class MedplumClient extends EventTarget {
|
|
|
565
571
|
* See FHIR search for full details: https://www.hl7.org/fhir/search.html
|
|
566
572
|
*
|
|
567
573
|
* @category Search
|
|
574
|
+
* @param resourceType The FHIR resource type.
|
|
568
575
|
* @param query The search query as either a string or a structured search object.
|
|
576
|
+
* @param options Optional fetch options.
|
|
569
577
|
* @returns Promise to the search result bundle.
|
|
570
578
|
*/
|
|
571
579
|
searchOne<K extends ResourceType>(resourceType: K, query?: URLSearchParams | string, options?: RequestInit): ReadablePromise<ExtractResource<K> | undefined>;
|
|
@@ -586,7 +594,9 @@ export declare class MedplumClient extends EventTarget {
|
|
|
586
594
|
* See FHIR search for full details: https://www.hl7.org/fhir/search.html
|
|
587
595
|
*
|
|
588
596
|
* @category Search
|
|
597
|
+
* @param resourceType The FHIR resource type.
|
|
589
598
|
* @param query The search query as either a string or a structured search object.
|
|
599
|
+
* @param options Optional fetch options.
|
|
590
600
|
* @returns Promise to the search result bundle.
|
|
591
601
|
*/
|
|
592
602
|
searchResources<K extends ResourceType>(resourceType: K, query?: URLSearchParams | string, options?: RequestInit): ReadablePromise<ExtractResource<K>[]>;
|
|
@@ -597,6 +607,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
597
607
|
* @category Search
|
|
598
608
|
* @param system The ValueSet system url.
|
|
599
609
|
* @param filter The search string.
|
|
610
|
+
* @param options Optional fetch options.
|
|
600
611
|
* @returns Promise to expanded ValueSet.
|
|
601
612
|
*/
|
|
602
613
|
searchValueSet(system: string, filter: string, options?: RequestInit): ReadablePromise<ValueSet>;
|
|
@@ -631,6 +642,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
631
642
|
* @category Read
|
|
632
643
|
* @param resourceType The FHIR resource type.
|
|
633
644
|
* @param id The resource ID.
|
|
645
|
+
* @param options Optional fetch options.
|
|
634
646
|
* @returns The resource if available; undefined otherwise.
|
|
635
647
|
*/
|
|
636
648
|
readResource<K extends ResourceType>(resourceType: K, id: string, options?: RequestInit): ReadablePromise<ExtractResource<K>>;
|
|
@@ -651,6 +663,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
651
663
|
*
|
|
652
664
|
* @category Read
|
|
653
665
|
* @param reference The FHIR reference object.
|
|
666
|
+
* @param options Optional fetch options.
|
|
654
667
|
* @returns The resource if available; undefined otherwise.
|
|
655
668
|
*/
|
|
656
669
|
readReference<T extends Resource>(reference: Reference<T>, options?: RequestInit): ReadablePromise<T>;
|
|
@@ -659,7 +672,6 @@ export declare class MedplumClient extends EventTarget {
|
|
|
659
672
|
* If the schema is not cached, returns undefined.
|
|
660
673
|
* It is assumed that a client will call requestSchema before using this method.
|
|
661
674
|
* @category Schema
|
|
662
|
-
* @param resourceType The FHIR resource type.
|
|
663
675
|
* @returns The schema if immediately available, undefined otherwise.
|
|
664
676
|
* @deprecated Use globalSchema instead.
|
|
665
677
|
*/
|
|
@@ -689,6 +701,7 @@ export declare class MedplumClient extends EventTarget {
|
|
|
689
701
|
* @category Read
|
|
690
702
|
* @param resourceType The FHIR resource type.
|
|
691
703
|
* @param id The resource ID.
|
|
704
|
+
* @param options Optional fetch options.
|
|
692
705
|
* @returns Promise to the resource history.
|
|
693
706
|
*/
|
|
694
707
|
readHistory<K extends ResourceType>(resourceType: K, id: string, options?: RequestInit): ReadablePromise<Bundle<ExtractResource<K>>>;
|
|
@@ -707,13 +720,26 @@ export declare class MedplumClient extends EventTarget {
|
|
|
707
720
|
* @category Read
|
|
708
721
|
* @param resourceType The FHIR resource type.
|
|
709
722
|
* @param id The resource ID.
|
|
723
|
+
* @param vid The version ID.
|
|
724
|
+
* @param options Optional fetch options.
|
|
710
725
|
* @returns The resource if available; undefined otherwise.
|
|
711
726
|
*/
|
|
712
727
|
readVersion<K extends ResourceType>(resourceType: K, id: string, vid: string, options?: RequestInit): ReadablePromise<ExtractResource<K>>;
|
|
713
728
|
/**
|
|
729
|
+
* Executes the Patient "everything" operation for a patient.
|
|
730
|
+
*
|
|
731
|
+
* Example:
|
|
732
|
+
*
|
|
733
|
+
* ```typescript
|
|
734
|
+
* const bundle = await medplum.readPatientEverything('123');
|
|
735
|
+
* console.log(bundle);
|
|
736
|
+
* ```
|
|
737
|
+
*
|
|
738
|
+
* See the FHIR "patient-everything" operation for full details: https://hl7.org/fhir/operation-patient-everything.html
|
|
714
739
|
*
|
|
715
740
|
* @category Read
|
|
716
741
|
* @param id The Patient Id
|
|
742
|
+
* @param options Optional fetch options.
|
|
717
743
|
* @returns A Bundle of all Resources related to the Patient
|
|
718
744
|
*/
|
|
719
745
|
readPatientEverything(id: string, options?: RequestInit): ReadablePromise<Bundle>;
|
|
@@ -807,7 +833,8 @@ export declare class MedplumClient extends EventTarget {
|
|
|
807
833
|
* @param contentType Content type for the binary.
|
|
808
834
|
* @returns The result of the create operation.
|
|
809
835
|
*/
|
|
810
|
-
createBinary(data: string | File | Blob | Uint8Array, filename: string | undefined, contentType: string): Promise<Binary>;
|
|
836
|
+
createBinary(data: string | File | Blob | Uint8Array, filename: string | undefined, contentType: string, onProgress?: (e: ProgressEvent) => void): Promise<Binary>;
|
|
837
|
+
uploadwithProgress(url: URL, data: string | File | Blob | Uint8Array, contentType: string, onProgress: (e: ProgressEvent) => void): Promise<any>;
|
|
811
838
|
/**
|
|
812
839
|
* Creates a PDF as a FHIR `Binary` resource based on pdfmake document definition.
|
|
813
840
|
*
|
|
@@ -912,6 +939,24 @@ export declare class MedplumClient extends EventTarget {
|
|
|
912
939
|
* @returns The result of the delete operation.
|
|
913
940
|
*/
|
|
914
941
|
deleteResource(resourceType: ResourceType, id: string): Promise<any>;
|
|
942
|
+
/**
|
|
943
|
+
* Executes the validate operation with the provided resource.
|
|
944
|
+
*
|
|
945
|
+
* Example:
|
|
946
|
+
*
|
|
947
|
+
* ```typescript
|
|
948
|
+
* const result = await medplum.validateResource({
|
|
949
|
+
* resourceType: 'Patient',
|
|
950
|
+
* name: [{ given: ['Alice'], family: 'Smith' }],
|
|
951
|
+
* });
|
|
952
|
+
* ```
|
|
953
|
+
*
|
|
954
|
+
* See the FHIR "$validate" operation for full details: https://www.hl7.org/fhir/resource-operation-validate.html
|
|
955
|
+
*
|
|
956
|
+
* @param resource The FHIR resource.
|
|
957
|
+
* @returns The validate operation outcome.
|
|
958
|
+
*/
|
|
959
|
+
validateResource<T extends Resource>(resource: T): Promise<OperationOutcome>;
|
|
915
960
|
/**
|
|
916
961
|
* Executes a batch or transaction of FHIR operations.
|
|
917
962
|
*
|
package/dist/cjs/format.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Address, HumanName, Period, Timing } from '@medplum/fhirtypes';
|
|
1
|
+
import { Address, HumanName, Period, Timing, Range, Quantity } from '@medplum/fhirtypes';
|
|
2
2
|
export interface AddressFormatOptions {
|
|
3
3
|
all?: boolean;
|
|
4
4
|
use?: boolean;
|
|
@@ -19,3 +19,15 @@ export declare function formatTime(time: string | undefined, options?: Intl.Date
|
|
|
19
19
|
export declare function formatDateTime(dateTime: string | undefined, options?: Intl.DateTimeFormatOptions): string;
|
|
20
20
|
export declare function formatPeriod(period: Period | undefined): string;
|
|
21
21
|
export declare function formatTiming(timing: Timing | undefined): string;
|
|
22
|
+
/**
|
|
23
|
+
* Returns a human-readable string for a FHIR Range datatype, taking into account comparators and one-sided ranges
|
|
24
|
+
* @param range A FHIR Range element
|
|
25
|
+
* @returns A human-readable string representation of the Range
|
|
26
|
+
*/
|
|
27
|
+
export declare function formatRange(range: Range | undefined): string;
|
|
28
|
+
/**
|
|
29
|
+
* Returns a human-readable string for a FHIR Quantity datatype, taking into account units and comparators
|
|
30
|
+
* @param quantity A FHIR Quantity element
|
|
31
|
+
* @returns A human-readable string representation of the Quantity
|
|
32
|
+
*/
|
|
33
|
+
export declare function formatQuantity(quantity: Quantity | undefined, precision?: number): string;
|
package/dist/cjs/hl7.d.ts
CHANGED
|
@@ -1,43 +1,136 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The Hl7Context class represents the parsing context for an HL7 message.
|
|
3
|
+
*
|
|
4
|
+
* MSH-1:
|
|
5
|
+
* https://hl7-definition.caristix.com/v2/HL7v2.6/Fields/MSH.1
|
|
6
|
+
*
|
|
7
|
+
* MSH-2:
|
|
8
|
+
* https://hl7-definition.caristix.com/v2/HL7v2.6/Fields/MSH.2
|
|
9
|
+
*
|
|
10
|
+
* See this tutorial on MSH, and why it's a bad idea to use anything other than the default values:
|
|
11
|
+
* https://www.hl7soup.com/HL7TutorialMSH.html
|
|
12
|
+
*/
|
|
13
|
+
export declare class Hl7Context {
|
|
14
|
+
readonly segmentSeparator: string;
|
|
15
|
+
readonly fieldSeparator: string;
|
|
16
|
+
readonly componentSeparator: string;
|
|
17
|
+
readonly repetitionSeparator: string;
|
|
18
|
+
readonly escapeCharacter: string;
|
|
19
|
+
readonly subcomponentSeparator: string;
|
|
20
|
+
constructor(segmentSeparator?: string, fieldSeparator?: string, componentSeparator?: string, repetitionSeparator?: string, escapeCharacter?: string, subcomponentSeparator?: string);
|
|
21
|
+
/**
|
|
22
|
+
* Returns the MSH-2 field value based on the configured separators.
|
|
23
|
+
* @returns The HL7 MSH-2 field value.
|
|
24
|
+
*/
|
|
25
|
+
getMsh2(): string;
|
|
26
|
+
}
|
|
4
27
|
/**
|
|
5
28
|
* The Hl7Message class represents one HL7 message.
|
|
6
29
|
* A message is a collection of segments.
|
|
7
|
-
* Note that we do not strictly parse messages, and only use default delimeters.
|
|
8
30
|
*/
|
|
9
31
|
export declare class Hl7Message {
|
|
32
|
+
readonly context: Hl7Context;
|
|
10
33
|
readonly segments: Hl7Segment[];
|
|
11
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new HL7 message.
|
|
36
|
+
* @param segments The HL7 segments.
|
|
37
|
+
* @param context Optional HL7 parsing context.
|
|
38
|
+
*/
|
|
39
|
+
constructor(segments: Hl7Segment[], context?: Hl7Context);
|
|
40
|
+
/**
|
|
41
|
+
* Returns an HL7 segment by index or by name.
|
|
42
|
+
* @param index The HL7 segment index or name.
|
|
43
|
+
* @returns The HL7 segment if found; otherwise, undefined.
|
|
44
|
+
*/
|
|
12
45
|
get(index: number | string): Hl7Segment | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Returns all HL7 segments of a given name.
|
|
48
|
+
* @param name The HL7 segment name.
|
|
49
|
+
* @returns An array of HL7 segments with the specified name.
|
|
50
|
+
*/
|
|
13
51
|
getAll(name: string): Hl7Segment[];
|
|
52
|
+
/**
|
|
53
|
+
* Returns the HL7 message as a string.
|
|
54
|
+
* @returns The HL7 message as a string.
|
|
55
|
+
*/
|
|
14
56
|
toString(): string;
|
|
57
|
+
/**
|
|
58
|
+
* Returns an HL7 "ACK" (acknowledgement) message for this message.
|
|
59
|
+
* @returns The HL7 "ACK" message.
|
|
60
|
+
*/
|
|
15
61
|
buildAck(): Hl7Message;
|
|
62
|
+
/**
|
|
63
|
+
* Parses an HL7 message string into an Hl7Message object.
|
|
64
|
+
* @param text The HL7 message text.
|
|
65
|
+
* @returns The parsed HL7 message.
|
|
66
|
+
*/
|
|
16
67
|
static parse(text: string): Hl7Message;
|
|
17
68
|
}
|
|
18
69
|
/**
|
|
19
70
|
* The Hl7Segment class represents one HL7 segment.
|
|
20
71
|
* A segment is a collection of fields.
|
|
21
72
|
* The name field is the first field.
|
|
22
|
-
* Note that we do not strictly parse messages, and only use default delimeters.
|
|
23
73
|
*/
|
|
24
74
|
export declare class Hl7Segment {
|
|
75
|
+
readonly context: Hl7Context;
|
|
25
76
|
readonly name: string;
|
|
26
77
|
readonly fields: Hl7Field[];
|
|
27
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Creates a new HL7 segment.
|
|
80
|
+
* @param fields The HL7 fields.
|
|
81
|
+
* @param context Optional HL7 parsing context.
|
|
82
|
+
*/
|
|
83
|
+
constructor(fields: Hl7Field[] | string[], context?: Hl7Context);
|
|
84
|
+
/**
|
|
85
|
+
* Returns an HL7 field by index.
|
|
86
|
+
* @param index The HL7 field index.
|
|
87
|
+
* @returns The HL7 field.
|
|
88
|
+
*/
|
|
28
89
|
get(index: number): Hl7Field;
|
|
90
|
+
/**
|
|
91
|
+
* Returns the HL7 segment as a string.
|
|
92
|
+
* @returns The HL7 segment as a string.
|
|
93
|
+
*/
|
|
29
94
|
toString(): string;
|
|
30
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Parses an HL7 segment string into an Hl7Segment object.
|
|
97
|
+
* @param text The HL7 segment text.
|
|
98
|
+
* @param context Optional HL7 parsing context.
|
|
99
|
+
* @returns The parsed HL7 segment.
|
|
100
|
+
*/
|
|
101
|
+
static parse(text: string, context?: Hl7Context): Hl7Segment;
|
|
31
102
|
}
|
|
32
103
|
/**
|
|
33
104
|
* The Hl7Field class represents one HL7 field.
|
|
34
105
|
* A field is a collection of components.
|
|
35
|
-
* Note that we do not strictly parse messages, and only use default delimeters.
|
|
36
106
|
*/
|
|
37
107
|
export declare class Hl7Field {
|
|
38
|
-
readonly
|
|
39
|
-
|
|
40
|
-
|
|
108
|
+
readonly context: Hl7Context;
|
|
109
|
+
readonly components: string[][];
|
|
110
|
+
/**
|
|
111
|
+
* Creates a new HL7 field.
|
|
112
|
+
* @param components The HL7 components.
|
|
113
|
+
* @param context Optional HL7 parsing context.
|
|
114
|
+
*/
|
|
115
|
+
constructor(components: string[][], context?: Hl7Context);
|
|
116
|
+
/**
|
|
117
|
+
* Returns an HL7 component by index.
|
|
118
|
+
* @param component The component index.
|
|
119
|
+
* @param subcomponent Optional subcomponent index.
|
|
120
|
+
* @param repetition Optional repetition index.
|
|
121
|
+
* @returns The string value of the specified component.
|
|
122
|
+
*/
|
|
123
|
+
get(component: number, subcomponent?: number, repetition?: number): string;
|
|
124
|
+
/**
|
|
125
|
+
* Returns the HL7 field as a string.
|
|
126
|
+
* @returns The HL7 field as a string.
|
|
127
|
+
*/
|
|
41
128
|
toString(): string;
|
|
42
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Parses an HL7 field string into an Hl7Field object.
|
|
131
|
+
* @param text The HL7 field text.
|
|
132
|
+
* @param context Optional HL7 parsing context.
|
|
133
|
+
* @returns The parsed HL7 field.
|
|
134
|
+
*/
|
|
135
|
+
static parse(text: string, context?: Hl7Context): Hl7Field;
|
|
43
136
|
}
|