@medplum/core 0.9.0 → 0.9.3

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.
Files changed (53) hide show
  1. package/README.md +158 -29
  2. package/dist/cjs/index.js +370 -251
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/index.min.js +1 -15
  5. package/dist/cjs/index.min.js.map +1 -1
  6. package/dist/esm/index.js +357 -251
  7. package/dist/esm/index.js.map +1 -1
  8. package/dist/esm/index.min.js +1 -15
  9. package/dist/esm/index.min.js.map +1 -1
  10. package/dist/types/cache.d.ts +1 -0
  11. package/dist/types/client.d.ts +33 -8
  12. package/dist/types/hl7.d.ts +43 -0
  13. package/dist/types/index.d.ts +3 -1
  14. package/dist/types/readablepromise.d.ts +43 -0
  15. package/dist/types/search.d.ts +2 -1
  16. package/dist/types/utils.d.ts +33 -3
  17. package/package.json +2 -2
  18. package/dist/types/repo.d.ts +0 -116
  19. package/docs/.nojekyll +0 -1
  20. package/docs/assets/highlight.css +0 -92
  21. package/docs/assets/icons.css +0 -1043
  22. package/docs/assets/icons.png +0 -0
  23. package/docs/assets/icons@2x.png +0 -0
  24. package/docs/assets/main.js +0 -52
  25. package/docs/assets/search.js +0 -1
  26. package/docs/assets/style.css +0 -1414
  27. package/docs/assets/widgets.png +0 -0
  28. package/docs/assets/widgets@2x.png +0 -0
  29. package/docs/classes/LegacyRepositoryClient.html +0 -71
  30. package/docs/classes/MedplumClient.html +0 -324
  31. package/docs/classes/OperationOutcomeError.html +0 -6
  32. package/docs/enums/Operator.html +0 -5
  33. package/docs/enums/PropertyType.html +0 -5
  34. package/docs/enums/SearchParameterType.html +0 -1
  35. package/docs/index.html +0 -89
  36. package/docs/interfaces/AddressFormatOptions.html +0 -1
  37. package/docs/interfaces/FetchLike.html +0 -1
  38. package/docs/interfaces/Filter.html +0 -1
  39. package/docs/interfaces/GoogleCredentialResponse.html +0 -1
  40. package/docs/interfaces/HumanNameFormatOptions.html +0 -1
  41. package/docs/interfaces/IndexedStructureDefinition.html +0 -19
  42. package/docs/interfaces/LoginAuthenticationResponse.html +0 -1
  43. package/docs/interfaces/LoginProfileResponse.html +0 -1
  44. package/docs/interfaces/LoginScopeResponse.html +0 -1
  45. package/docs/interfaces/LoginState.html +0 -1
  46. package/docs/interfaces/MedplumClientOptions.html +0 -33
  47. package/docs/interfaces/RegisterRequest.html +0 -1
  48. package/docs/interfaces/SearchParameterDetails.html +0 -1
  49. package/docs/interfaces/SearchRequest.html +0 -1
  50. package/docs/interfaces/SortRule.html +0 -1
  51. package/docs/interfaces/TokenResponse.html +0 -1
  52. package/docs/interfaces/TypeSchema.html +0 -10
  53. package/docs/modules.html +0 -138
package/README.md CHANGED
@@ -1,7 +1,3 @@
1
- # Medplum
2
-
3
- Medplum is a healthcare platform that helps you quickly develop high-quality compliant applications. Medplum includes a FHIR server, React component library, and developer app.
4
-
5
1
  # Medplum JS Client Library
6
2
 
7
3
  The Medplum JS Client Library is a pure TypeScript library for calling a FHIR server from the browser.
@@ -16,13 +12,25 @@ The Medplum JS Client Library is a pure TypeScript library for calling a FHIR se
16
12
 
17
13
  ## Installation
18
14
 
19
- ```
20
- npm install medplum
15
+ Add as a dependency:
16
+
17
+ ```bash
18
+ npm install @medplum/core
21
19
  ```
22
20
 
23
21
  ## Basic Usage
24
22
 
25
- ```typescript
23
+ Create a new `MedplumClient`:
24
+
25
+ ```ts
26
+ import { MedplumClient } from '@medplum/core';
27
+
28
+ const medplum = new MedplumClient();
29
+ ```
30
+
31
+ Create a `MedplumClient` with additional configuration options:
32
+
33
+ ```ts
26
34
  import { MedplumClient } from '@medplum/core';
27
35
 
28
36
  const medplum = new MedplumClient({
@@ -31,12 +39,11 @@ const medplum = new MedplumClient({
31
39
  });
32
40
  ```
33
41
 
34
- ## Authenticating with OAuth
35
-
36
- Authenticate with a FHIR server via OAuth2 redirect:
42
+ ## Authenticate with client credenials
37
43
 
38
- ```typescript
39
- medplum.signInWithRedirect().then((user) => console.log(user));
44
+ ```ts
45
+ const medplum = new MedplumClient();
46
+ medplum.clientCredentials(MY_CLIENT_ID, MY_CLIENT_SECRET);
40
47
  ```
41
48
 
42
49
  ## Authenticating with Medplum
@@ -50,25 +57,39 @@ Before you begin
50
57
 
51
58
  After that, you can use the `startLogin()` method:
52
59
 
53
- ```typescript
60
+ ```ts
54
61
  const loginResult = await medplum.startLogin(email, password, remember);
55
62
  const profile = await medplum.processCode(loginResult.code);
56
63
  console.log(profile);
57
64
  ```
58
65
 
66
+ ## Authenticating with OAuth
67
+
68
+ Authenticate with a FHIR server via OAuth2 redirect:
69
+
70
+ ```ts
71
+ medplum.signInWithRedirect().then((user) => console.log(user));
72
+ ```
73
+
59
74
  ## Search
60
75
 
61
76
  Search for any resource using a [FHIR search](https://www.hl7.org/fhir/search.html) string:
62
77
 
63
- ```typescript
78
+ ```ts
79
+ search<T extends Resource>(query: string | SearchRequest, options: RequestInit = {}): Promise<Bundle<T>>
80
+ ```
81
+
82
+ Example:
83
+
84
+ ```ts
64
85
  medplum.search('Patient?given=eve').then((bundle) => {
65
86
  bundle.entry.forEach((entry) => console.log(entry.resource));
66
87
  });
67
88
  ```
68
89
 
69
- Search using a structured object:
90
+ Example using a structured object:
70
91
 
71
- ```typescript
92
+ ```ts
72
93
  medplum
73
94
  .search({
74
95
  resourceType: 'Patient',
@@ -87,10 +108,16 @@ medplum
87
108
 
88
109
  ## Create
89
110
 
90
- Create a new resource:
111
+ [Create resource](https://www.hl7.org/fhir/http.html#create):
112
+
113
+ ```ts
114
+ createResource<T extends Resource>(resource: T): Promise<T>
115
+ ```
91
116
 
92
- ```typescript
93
- medplum.create({
117
+ Example:
118
+
119
+ ```ts
120
+ medplum.createResource({
94
121
  resourceType: 'Observation',
95
122
  subject: {
96
123
  reference: 'Patient/123',
@@ -102,26 +129,128 @@ medplum.create({
102
129
  });
103
130
  ```
104
131
 
105
- ## Read
132
+ ## Read a resource
133
+
134
+ [Read a resource by ID](https://www.hl7.org/fhir/http.html#read):
135
+
136
+ ```ts
137
+ readResource<T extends Resource>(resourceType: string, id: string): Promise<T>
138
+ ```
139
+
140
+ Example:
141
+
142
+ ```ts
143
+ const patient = await medplum.readResource('Patient', '123');
144
+ ```
145
+
146
+ ## Read resource history
147
+
148
+ [Read resource history](https://www.hl7.org/fhir/http.html#history):
149
+
150
+ ```ts
151
+ readHistory<T extends Resource>(resourceType: string, id: string): Promise<Bundle<T>>
152
+ ```
153
+
154
+ Example:
155
+
156
+ ```ts
157
+ const historyBundle = await medplum.readHistory('Patient', '123');
158
+ ```
159
+
160
+ ## Read resource version
161
+
162
+ [Read a specific version](https://www.hl7.org/fhir/http.html#vread):
163
+
164
+ ```ts
165
+ readVersion<T extends Resource>(resourceType: string, id: string, vid: string): Promise<T>
166
+ ```
167
+
168
+ Example:
169
+
170
+ ```ts
171
+ const version = await medplum.readVersion('Patient', '123', '456');
172
+ ```
173
+
174
+ ## Update a resource
175
+
176
+ [Update a resource](https://www.hl7.org/fhir/http.html#update):
177
+
178
+ ```ts
179
+ updateResource<T extends Resource>(resource: T): Promise<T>
180
+ ```
181
+
182
+ Example:
183
+
184
+ ```ts
185
+ const result = await medplum.updateResource({
186
+ resourceType: 'Patient',
187
+ id: '123',
188
+ name: [{
189
+ family: 'Smith',
190
+ given: ['John']
191
+ }]
192
+ });
193
+ console.log(result.meta.versionId);
194
+ ```
195
+
196
+ ## Delete a resource
106
197
 
107
- Read a resource by ID:
198
+ [Delete a resource](https://www.hl7.org/fhir/http.html#delete):
108
199
 
109
- ```typescript
110
- medplum.read('Patient', '123');
200
+ ```ts
201
+ deleteResource(resourceType: string, id: string): Promise<any>
111
202
  ```
112
203
 
113
- Read resource history:
204
+ Example:
114
205
 
115
- ```typescript
116
- medplum.readHistory('Patient', '123');
206
+ ```ts
207
+ await medplum.deleteResource('Patient', '123');
117
208
  ```
118
209
 
119
- Read a specific version:
210
+ ## Patch a resource
211
+
212
+ [Patch a resource](https://www.hl7.org/fhir/http.html#patch):
120
213
 
121
- ```typescript
122
- medplum.readVersion('Patient', '123', '456');
214
+ ```ts
215
+ patchResource<T extends Resource>(resourceType: string, id: string, operations: Operation[]): Promise<T>
123
216
  ```
124
217
 
218
+ Example:
219
+
220
+ ```ts
221
+ const result = await medplum.patchResource('Patient', '123', [
222
+ {op: 'replace', path: '/name/0/family', value: 'Smith'},
223
+ ]);
224
+ console.log(result.meta.versionId);
225
+ ```
226
+
227
+ ## GraphQL
228
+
229
+ [Execute a GraphQL query](https://www.hl7.org/fhir/graphql.html):
230
+
231
+ ```ts
232
+ graphql(query: string, options?: RequestInit): Promise<any>
233
+ ```
234
+
235
+ Example:
236
+
237
+ ```ts
238
+ const result = await graphql(`
239
+ {
240
+ PatientList(name: "Alice") {
241
+ name {
242
+ given,
243
+ family
244
+ }
245
+ }
246
+ }
247
+ `);
248
+ ```
249
+
250
+ ## About Medplum
251
+
252
+ Medplum is a healthcare platform that helps you quickly develop high-quality compliant applications. Medplum includes a FHIR server, React component library, and developer app.
253
+
125
254
  ## License
126
255
 
127
256
  Apache 2.0. Copyright &copy; Medplum 2022