This repository has been archived by the owner on Sep 4, 2024. It is now read-only.
forked from Vermonster/fhir-kit-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
1063 lines (1052 loc) · 37.3 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { HeadersInit, RequestInit } from 'node-fetch';
import { OpPatch } from 'json-patch';
type HttpMethods = 'GET'
| 'HEAD'
| 'POST'
| 'PUT'
| 'DELETE'
| 'CONNECT'
| 'OPTIONS'
| 'TRACE'
| 'PATCH';
interface RequestInitWithoutMethod extends Omit<RequestInit, 'method'> {}
interface RequestResponse {
request: Request;
response: Response;
}
interface FhirResource extends Record<string, any> {
resourceType: ResourceType
}
interface SmartAuthMetadata {
authorizeUrl?: URL;
tokenUrl?: URL;
registerUrl?: URL;
manageUrl?: URL;
}
interface SearchParams {
[key: string]: string|number|boolean|Array<string|number|boolean>;
}
interface Compartment {
id: string;
resourceType: string;
}
type ResourceType = string;
/**
* Access capabilities
* @param capabilityStatement - capability statement FHIR resource
*/
declare class CapabilityTool {
constructor(capabilityStatement: FhirResource);
/**
* Return server-level interaction support information based on the capability statement.
* @example
* const capabilities = new CapabilityTool(capabilityStatement);
* const serverBatchSupport = capabilities.serverCan('batch');
* console.log(serverBatchSupport);
* @param interaction - The interaction to check server-level capability for.
* @returns Whether or not the interaction is supported by the server.
*/
serverCan(interaction: string): boolean;
/**
* Return resource-level interaction support information based on the capability statement.
* @example
* const capabilities = new CapabilityTool(capabilityStatement);
* const patientReadSupport = capabilities.resourceCan('Patient', 'read');
* console.log(patientReadSupport);
* @param resource - The resource to check interaction support for.
* @param interaction - The interaction to check resource-level capability for.
* @returns Whether or not the interaction is supported for the given resource.
*/
resourceCan(resource: string, interaction: string): boolean;
/**
* Return server-level searchParam support information based on the capability statement.
* @example
* const capabilities = new CapabilityTool(capabilityStatement);
* const lastUpdatedSupport = capabilities.serverSearch('_lastUpdated');
* console.log(lastUpdatedSupport);
* @param searchParam - The searchParam to check server-level capability for.
* @returns Whether or not the searchParam is supported by the server.
*/
serverSearch(searchParam: string): boolean;
/**
* Return resource-level searchParam support information based on the capability statement.
* @example
* const capabilities = new CapabilityTool(capabilityStatement);
* const patientGenderSearchSupport = capabilities.resourceSearch('Patient', 'gender');
* console.log(patientGenderSearchSupport);
* @param resource - The resource to check searchParam support for.
* @param searchParam - The searchParam to check resource-level capability for.
* @returns Whether or not the searchParam is supported for the given resource.
*/
resourceSearch(resource: string, searchParam: string): boolean;
/**
* Return capability support information based on the capability statement.
* @example
* const capabilities = new CapabilityTool(capabilityStatement);
*
* // Server-level capability support
* const interactionSupport = capabilities.supportFor({
* capabilityType: 'interaction'
* });
* console.log(interactionSupport);
*
* // Server-level capability support for specific code
* const interactionSupport = capabilities.supportFor({
* capabilityType: 'interaction',
* where: { code: 'history-system' }
* });
* console.log(interactionSupport);
*
* // Resource-level capability support
* const patientConditionalCreateSupport = capabilities.supportFor({
* resourceType: 'Patient',
* capabilityType: 'conditionalCreate'
* });
* console.log(patientConditionalCreateSupport);
*
* // Capability support for specific code
* const patientReadSupport = capabilities.supportFor({
* resourceType: 'Patient',
* capabilityType: 'interaction',
* where: { code: 'read' }
* });
* console.log(patientReadSupport);
*
* // Capability support for specific name
* const patientBirthDateSearchSupport = capabilities.supportFor({
* resourceType: 'Patient',
* capabilityType: 'searchParam',
* where: { name: 'birthdate' }
* });
* console.log(patientBirthDateSearchSupport);
* @param params - The capability parameters.
* @param [params.resourceType] - Resource type (e.g. 'Patient', 'Observation'), optional.
* @param params.capabilityType - Capability type (e.g. 'interaction', 'searchParam').
* @param [params.where] - Check additional level of compatibility, optional.
* @param [params.where.code] - Specify a code (e.g., 'read' for interaction), optional.
* @param [params.where.name] - Specify a name (e.g., 'type' for searchParam), optional.
* @returns If the capability, code, or name is supported for the resource.
*/
supportFor(params: {
resourceType?: ResourceType;
capabilityType: string;
where?: {
code?: string;
name?: string;
};
}): boolean;
/**
* Return interactions available for a resource type based on the capability statement.
* @example
* const capabilities = new CapabilityTool(capabilityStatement);
* const supportedPatientInteractions = capabilities.interactionsFor({ resourceType: 'Patient'});
* console.log(supportedPatientInteractions);
* @param params - The capability parameters.
* @param params.resourceType - Resource type (e.g. 'Patient', 'Observation').
* @returns A list of supported interactions for the given resource type.
*/
interactionsFor(params: {
resourceType: ResourceType;
}): string[];
/**
* Return searchParams available for a resource type based on the capability statement.
* @example
* const capabilities = new CapabilityTool(capabilityStatement);
* const supportedPatientSearchParams = capabilities.searchParamsFor({ resourceType: 'Patient'});
* console.log(supportedPatientSearchParams);
* @param params - The capability parameters.
* @param params.resourceType - Resource type (e.g. 'Patient', 'Observation').
* @returns A list of supported searchParams for the given resource type.
*/
searchParamsFor(params: {
resourceType: ResourceType;
}): string[];
/**
* Return all capabilities for a given resource from the capability statement.
* @example
* const capabilities = new CapabilityTool(capabilityStatement);
* const patientCapabilities = capabilities.resourceCapabilities({ resourceType: 'Patient'});
* console.log(patientCapabilities);
* @param params - The capability parameters.
* @param params.resourceType - Resource type (e.g. 'Patient', 'Observation').
* @returns The contents of a given resource as listed in the capability statement.
*/
resourceCapabilities(params: {
resourceType: ResourceType;
}): any;
/**
* Return the contents of a specific resource capability from the capability statement.
* @example
* const capabilities = new CapabilityTool(capabilityStatement);
* const conditionalDeleteSupport = capabilities.capabilityContents({
* resourceType: 'Patient',
* capabilityType: 'conditionalDelete'
* });
* console.log(conditionalDeleteSupport);
* @param params - The capability parameters.
* @param params.resourceType - Resource type (e.g. 'Patient', 'Observation').
* @param params.capabilityType - Capability type (e.g. 'interaction', 'searchParam').
* @returns The contents of a given capability as listed in the capability statement.
*/
capabilityContents(params: {
resourceType: ResourceType;
capabilityType: any;
}): any;
/**
* Return all server-level capabilities.
* @example
* const capabilities = new CapabilityTool(capabilityStatement);
* const serverCapabilities = capabilities.serverCapabilities();
* console.log(serverCapabilities);
* @returns All REST capabilities for the mode 'server'.
*/
serverCapabilities(): any;
}
/**
* Create a FHIR client.
*
* For details on what requestOptions are available, see the node `request`
* documentation at https://github.com/request/request
* @example
* const options = {
* baseUrl: 'http://fhir.com',
* customHeaders: {
* 'x-some-header': 'value'
* },
* requestOptions: {
* cert: certFileContent,
* key: keyFileContent,
* ca: caFileContent
* },
* bearerToken: 'eyJhbGci...dQssw5c',
* requestSigner: (url, requestOptions) => {
* const signed = aws4.sign({
* path: requestOptions.path,
* service: 'healthlake',
* region: 'us-west-2'
* method: requestOptions.method
* });
* Object.keys(signed.headers).forEach((key) => {
* requestOptions.headers.set(key, signed[key]);
* });
* }
* };
* };
*
* const client = new Client(options);
* @param config - Client configuration
* @param config.baseUrl - ISS for FHIR server
* @param [config.customHeaders] - Optional custom headers to send with
* each request
* @param [config.requestOptions] - Optional custom request options for
* instantiating the HTTP connection
* @param [config.requestSigner] Optional pass in a function to sign the request.
*/
export default class Client {
baseUrl: string;
customHeaders: HeadersInit;
bearerToken: string | undefined;
constructor(config: {
baseUrl: string;
customHeaders?: HeadersInit;
requestOptions?: RequestInit;
requestSigner?: (string, RequestInit) => void
bearerToken?: string | undefined;
});
/**
* Given a Client response, returns the underlying HTTP request and response
* objects.
* @example
* const Client = require('fhir-kit-client');
*
* fhirClient.read({
* resourceType: 'Patient',
* id: 12345,
* }).then((data) => {
* const { response, request } = Client.httpFor(data);
* console.log(response.status);
* console.log(request.headers);
* });
* @param requestResponse - to one of the FHIR Kit Client requests
* @returns object containing http request and response
*/
static httpFor(requestResponse: Response): RequestResponse;
/**
* Resolve a reference and return FHIR resource
*
* From: http://hl7.org/fhir/STU3/references.html, a reference can be: 1)
* absolute URL, 2) relative URL or 3) an internal fragement. In the case of
* (2), there are rules on resolving references that are in a FHIR bundle.
* @example
* // Always does a new http request
* client.resolve({ reference: 'http://test.com/fhir/Patient/1' }).then((patient) => {
* console.log(patient);
* });
*
* // Always does a new http request, using the client.baseUrl
* client.resolve({ reference: 'Patient/1' }).then((patient) => {
* console.log(patient);
* });
*
* // Try to resolve a patient in the bundle, otherwise build request
* // at client.baseUrl
* client.resolve({ reference: 'Patient/1', context: bundle }).then((patient) => {
* console.log(patient);
* });
*
* // Resolve a patient contained in someResource (see:
* // http://hl7.org/fhir/STU3/references.html#contained)
* client.resolve({ reference: '#patient-1', context: someResource }).then((patient) => {
* console.log(patient);
* });
* @param params - The request parameters.
* @param params.reference - FHIR reference
* @param [params.context] - Optional bundle or FHIR resource
* @param [params.headers] - DEPRECATED Optional custom headers to
* add to the request
* @param [params.options] - Optional options object
* @param [params.options.headers] - Optional headers to add to the
* request
* @returns FHIR resource
*/
resolve(params: {
reference: string;
context?: FhirResource;
headers?: HeadersInit;
options?: RequestInit;
}): Promise<FhirResource>;
/**
* Obtain the SMART OAuth URLs from the Capability Statement, or
* any of the .well-known addresses.
*
* See: http://docs.smarthealthit.org/authorization/conformance-statement/
* @example
* // Using promises
* fhirClient.smartAuthMetadata().then((data) => { console.log(data); });
*
* // Using async
* let response = await fhirClient.smartAuthMetadata();
* console.log(response);
* @param [params] - The request parameters.
* @param [params.headers] - DEPRECATED Optional custom headers to
* add to the request
* @param [params.options] - Optional options object
* @param [params.options.headers] - Optional headers to add to the
* request
* @returns contains the following SMART URL: authorizeUrl,
* tokenUrl, registerUrl, manageUrl
*/
smartAuthMetadata(params?: {
headers?: HeadersInit;
options?: RequestInit;
}): Promise<SmartAuthMetadata>;
/**
* Get the capability statement.
* @example
* // Using promises
* fhirClient.capabilityStatement().then((data) => { console.log(data); });
*
* // Using async
* let response = await fhirClient.capabilityStatement();
* console.log(response);
* @param [params] - The request parameters.
* @param [params.headers] - DEPRECATED Optional custom headers to
* add to the request
* @param [params.options] - Optional options object
* @param [params.options.headers] - Optional headers to add to the
* request
* @returns capability statement FHIR resource.
*/
capabilityStatement(params?: {
headers?: HeadersInit;
options?: RequestInit;
}): Promise<FhirResource>;
/**
* Run a request.
* @example
* // Defaults to GET
* fhirClient.request('Patient/123')
* .then(data => console.log(data));
*
* fhirClient.request('Patient/123', { method: 'DELETE'})
* .then(data => console.log(data));
*
* fhirClient.request('Patient', { method: 'POST', body: myNewPatient })
* .then(data => console.log(data));
* @param requestUrl - URL, can be relative to base or absolute
* @param params - (optional) Request params
* @param params.method - (optional) HTTP method (defaults to GET)
* @param params.options - (optional) additional request options (e.g. headers)
* @param params.body - (optional) request body
* @returns Response
*/
request(requestUrl: string, params?: {
method?: HttpMethods;
headers?: HeadersInit;
options?: RequestInitWithoutMethod;
body?: BodyInit;
}): Promise<object>;
/**
* Get a resource by FHIR id.
* @example
* // Using promises
* fhirClient.read({
* resourceType: 'Patient',
* id: 12345,
* }).then((data) => { console.log(data); });
*
* // Using async
* let response = await fhirClient.read({ resourceType: 'Patient', id: 12345 });
* console.log(response);
* @param params - The request parameters.
* @param params.resourceType - The resource type (e.g. "Patient",
* "Observation").
* @param params.id - The FHIR id for the resource.
* @param [params.headers] - DEPRECATED Optional custom headers to
* add to the request
* @param [params.options] - Optional options object
* @param [params.options.headers] - Optional headers to add to the
* request
* @returns FHIR resource
*/
read(params: {
resourceType: ResourceType;
id: string;
headers?: HeadersInit;
options?: RequestInit;
}): Promise<FhirResource>;
/**
* Get a resource by id and version.
* @example
* // Using promises
* fhirClient.vread({
* resourceType: 'Patient',
* id: '12345',
* version: '1',
* }).then(data => console.log(data));
*
* // Using async
* let response = await fhirClient.vread({
* resourceType: 'Patient',
* id: '12345',
* version: '1',
* });
* console.log(response);
* @param params - The request parameters.
* @param params.resourceType - The resource type (e.g. "Patient",
* "Observation").
* @param params.id - The FHIR id for the resource.
* @param params.version - The version id for the resource.
* @param [params.headers] - DEPRECATED Optional custom headers to
* add to the request
* @param [params.options] - Optional options object
* @param [params.options.headers] - Optional headers to add to the
* request
* @returns FHIR resource
*/
vread(params: {
resourceType: ResourceType;
id: string;
version: string;
headers?: HeadersInit;
options?: RequestInit;
}): Promise<FhirResource>;
/**
* Create a resource.
* @example
* const newPatient = {
* resourceType: 'Patient',
* active: true,
* name: [{ use: 'official', family: 'Coleman', given: ['Lisa', 'P.'] }],
* gender: 'female',
* birthDate: '1948-04-14',
* }
*
* // Using promises
* fhirClient.create({
* resourceType: 'Patient',
* body: newPatient,
* }).then((data) => { console.log(data); });
*
* // Using async
* let response = await fhirClient.create({
* resourceType: 'Patient',
* body: newPatient,
* })
* console.log(response);
* @param params - The request parameters.
* @param params.resourceType - The FHIR resource type.
* @param params.body - The new resource data to create.
* @param [params.headers] - DEPRECATED Optional custom headers to
* add to the request
* @param [params.options] - Optional options object
* @param [params.options.headers] - Optional headers to add to the
* request
* @returns FHIR resource
*/
create<T extends FhirResource>(params: {
resourceType: ResourceType;
body: T;
headers?: HeadersInit;
options?: RequestInit;
}): Promise<FhirResource | T>;
/**
* Delete a resource by FHIR id.
* @example
* // Using promises
* fhirClient.delete({
* resourceType: 'Patient',
* id: 12345,
* }).then((data) => { console.log(data); });
*
* // Using async
* let response = await fhirClient.delete({ resourceType: 'Patient', id: 12345 });
* console.log(response);
* @param params - The request parameters.
* @param params.resourceType - The resource type (e.g. "Patient", "Observation").
* @param params.id - The FHIR id for the resource.
* @param [params.headers] - DEPRECATED Optional custom headers to
* add to the request
* @param [params.options] - Optional options object
* @param [params.options.headers] - Optional headers to add to the
* request
* @returns Operation Outcome FHIR resource
*/
delete(params: {
resourceType: ResourceType;
id: string;
headers?: HeadersInit;
options?: RequestInit;
}): Promise<FhirResource>;
/**
* Update a resource by FHIR id.
* @example
* const updatedPatient = {
* resourceType: 'Patient',
* birthDate: '1948-04-14',
* }
*
* // Using promises
* fhirClient.update({
* resourceType: 'Patient',
* id: 12345,
* body: updatedPatient,
* }).then((data) => { console.log(data); });
*
* // Using async
* let response = await fhirClient.update({
* resourceType: 'Patient',
* id: 12345,
* body: updatedPatient,
* });
* console.log(response);
* @param params - The request parameters.
* @param params.resourceType - The resource type (e.g. "Patient",
* "Observation").
* @param params.id - The FHIR id for the resource.
* @param params.body - The resource to be updated.
* @param [params.headers] - DEPRECATED Optional custom headers to
* add to the request
* @param [params.options] - Optional options object
* @param [params.options.headers] - Optional headers to add to the
* request
* @returns FHIR resource
*/
update<T extends FhirResource>(params: {
resourceType: ResourceType;
id: string;
body: T;
headers?: HeadersInit;
options?: RequestInit;
}): Promise<FhirResource | T>
/**
* Patch a resource by FHIR id.
*
* From http://hl7.org/fhir/STU3/http.html#patch:
* Content-Type is 'application/json-patch+json'
* Expects a JSON Patch document format, see http://jsonpatch.com/
* @example
* // JSON Patch document format from http://jsonpatch.com/
* const JSONPatch = [{ op: 'replace', path: '/gender', value: 'male' }];
*
* // Using promises
* fhirClient.patch({
* resourceType: 'Patient',
* id: 12345,
* JSONPatch,
* }).then((data) => { console.log(data); });
*
* // Using async
* let response = await fhirClient.patch({
* resourceType: 'Patient',
* id: 12345,
* JSONPatch
* });
* console.log(response);
* @param params - The request parameters.
* @param params.resourceType - The resource type (e.g. "Patient",
* "Observation").
* @param params.id - The FHIR id for the resource.
* @param params.JSONPatch - A JSON Patch document containing an array
* of patch operations, formatted according to http://jsonpatch.com/.
* @param [params.headers] - DEPRECATED Optional custom headers to
* add to the request
* @param [params.options] - Optional options object
* @param [params.options.headers] - Optional headers to add to the
* request
* @returns FHIR resource
*/
patch(params: {
resourceType: ResourceType;
id: string;
JSONPatch: OpPatch[];
headers?: HeadersInit;
options?: RequestInit;
}): Promise<FhirResource>;
/**
* Submit a set of actions to perform independently as a batch.
*
* Update, create or delete a set of resources in a single interaction.
* There should be no interdependencies between entries in the bundle.
* @example
* const requestBundle = {
* 'resourceType': 'Bundle',
* 'type': 'batch',
* 'entry': [
* {
* 'fullUrl': 'http://example.org/fhir/Patient/123',
* 'resource': {
* 'resourceType': 'Patient',
* 'id': '123',
* 'active': true
* },
* 'request': {
* 'method': 'PUT',
* 'url': 'Patient/123'
* }
* },
* {
* 'request': {
* 'method': 'DELETE',
* 'url': 'Patient/2e27c71e-30c8-4ceb-8c1c-5641e066c0a4'
* }
* },
* {
* 'request': {
* 'method': 'GET',
* 'url': 'Patient?name=peter'
* }
* }
* ]
* }
*
* // Using promises
* fhirClient.batch({
* body: requestBundle
* }).then((data) => { console.log(data); });
*
* // Using async
* let response = await fhirClient.batch({
* body: requestBundle
* });
* console.log(response);
* @param params - The request parameters.
* @param params.body - The request body with a type of 'batch'.
* @param [params.headers] - DEPRECATED Optional custom headers to
* add to the request
* @param [params.options] - Optional options object
* @param [params.options.headers] - Optional headers to add to the
* request
* @returns FHIR resources in a FHIR Bundle structure.
*/
batch(params: {
body: FhirResource & { type: "batch" };
headers?: HeadersInit;
options?: RequestInit;
}): Promise<FhirResource | FhirResource & { type: "batch-response" }>;
/**
* Submit a set of actions to perform independently as a transaction.
*
* Update, create or delete a set of resources in a single interaction.
* The entire set of changes should succeed or fail as a single entity.
* Multiple actions on multiple resources different types may be submitted.
* The outcome should not depend on the order of the resources loaded.
* Order of processing actions: DELETE, POST, PUT, and GET.
* The transaction fails if any resource overlap in DELETE, POST and PUT.
* @example
* const requestBundle = {
* 'resourceType': 'Bundle',
* 'type': 'transaction',
* 'entry': [
* {
* 'fullUrl': 'http://example.org/fhir/Patient/123',
* 'resource': {
* 'resourceType': 'Patient',
* 'id': '123',
* 'active': true
* },
* 'request': {
* 'method': 'PUT',
* 'url': 'Patient/123'
* }
* },
* {
* 'request': {
* 'method': 'DELETE',
* 'url': 'Patient/2e27c71e-30c8-4ceb-8c1c-5641e066c0a4'
* }
* },
* {
* 'request': {
* 'method': 'GET',
* 'url': 'Patient?name=peter'
* }
* }
* ]
* }
*
* // Using promises
* fhirClient.transaction({
* body: requestBundle
* }).then((data) => { console.log(data); });
*
* // Using async
* let response = await fhirClient.transaction({
* body: requestBundle
* });
* console.log(response);
* @param params - The request parameters.
* @param params.body - The request body with a type of
* 'transaction'.
* @param [params.headers] - DEPRECATED Optional custom headers to
* add to the request
* @param [params.options] - Optional options object
* @param [params.options.headers] - Optional headers to add to the
* request
* @returns FHIR resources in a FHIR Bundle structure.
*/
transaction(params: {
body: FhirResource & { type: "transaction" };
headers?: HeadersInit;
options?: RequestInit;
}): Promise<FhirResource | FhirResource & { type: "transaction-response" }>;
/**
* Run a custom FHIR operation on system, resource type or instance level.
*
* - To run a system-level operation, omit the resourceType and id parameters.
* - To run a type-level operatiion, include the resourceType and omit the id parameter.
* - To run an instance-type operation, include both the resourceType and id.
* @example
* client.operation({ resourceType: 'ConceptMap', name: '$apply' }).
* then(result => console.log(result).
* catch(e => console.error(e));
*
*
* const input = {
* system: 'http://hl7.org/fhir/composition-status',
* code: 'preliminary',
* source: 'http://hl7.org/fhir/ValueSet/composition-status',
* target: 'http://hl7.org/fhir/ValueSet/v3-ActStatus'
* };
*
* client.operation({resourceType: 'ConceptMap', name: 'translate', method: 'get', input}).
* then(result => console.log(result)).
* catch(e => console.error(e));
* @param params - The request parameters.
* @param params.name - The name of the operation (will get
* prepended with $ if missing.
* @param [params.resourceType] - Optional The resource type (e.g. "Patient",
* "Observation")
* @param [params.id] - Optional FHIR id for the resource
* @param [params.method] - Optional The HTTP method (POST or GET, defaults to post)
* @param [params.input] - Optional input object for the operation
* @param [params.options] - Optional options object
* @returns Result of opeartion (e.g. FHIR Parameter)
*/
operation(params: {
name: string;
resourceType?: ResourceType;
id?: string;
method?: 'POST' | 'GET' | undefined;
input?: any;
options?: RequestInitWithoutMethod;
}): Promise<FhirResource | any>;
/**
* Return the next page of results.
* @param params - The request parameters. Passing the bundle as the
* first parameter is DEPRECATED
* @param params.bundle - Bundle result of a FHIR search
* @param [params.options] - Optional options object
* @param [params.options.headers] - Optional headers to add to the
* request
* @param [headers] - DEPRECATED Optional custom headers to add to
* the request
* @returns FHIR resources in a FHIR Bundle structure.
*/
nextPage<T extends string>(params: {
bundle: FhirResource & {type: T};
options?: RequestInit;
}): Promise<FhirResource | FhirResource & {type: T}>;
/**
* Return the previous page of results.
* @param params - The request parameters. Passing the bundle as the
* first parameter is DEPRECATED
* @param params.bundle - Bundle result of a FHIR search
* @param [params.options] - Optional options object
* @param [params.options.headers] - Optional headers to add to the
* request
* @param [headers] - DEPRECATED Optional custom headers to add to
* the request
* @returns FHIR resources in a FHIR Bundle structure.
*/
prevPage<T extends string>(params: {
bundle: FhirResource & {type: T};
options?: RequestInit;
}): Promise<FhirResource | FhirResource & {type: T}>;
/**
* Search for a FHIR resource, with or without compartments, or the entire
* system
* @example
* // Using promises
* fhirClient.search({
* resourceType: 'Observation',
* compartment: { resourceType: 'Patient', id: 123 },
* searchParams: { code: 'abc', _include: ['Observation:encounter', 'Observation:performer'] },
* }).then((data) => { console.log(data); });
*
* // Using async
* let response = await fhirClient.search({
* resourceType: 'Observation',
* compartment: { resourceType: 'Patient', id: 123 },
* searchParams: { code: 'abc', _include: ['Observation:encounter', 'Observation:performer'] },
* });
* console.log(response);
* @param params - The request parameters.
* @param [params.resourceType] - The resource type
* (e.g. "Patient", "Observation"), optional.
* @param [params.compartment] - The search compartment, optional.
* @param [params.searchParams] - The search parameters, optional.
* @param [params.headers] - DEPRECATED Optional custom headers to
* add to the request
* @param [params.options] - Optional options object
* @param [params.options.headers] - Optional headers to add to the
* request
* @param [params.options.postSearch] - if true, all `searchParams`
* will be placed in the request body rather than the url, and the search
* will use POST rather than GET
* @returns FHIR resources in a Bundle
*/
search(params: {
resourceType: ResourceType;
compartment?: Compartment;
searchParams?: SearchParams;
headers?: HeadersInit;
options?: RequestInit;
}): Promise<FhirResource | FhirResource & { type: "searchset" }>;
/**
* Search for a FHIR resource.
* @example
* // Using promises
* fhirClient.resourceSearch({
* resourceType: 'Patient',
* searchParams: { name: 'Smith' },
* }).then((data) => { console.log(data); });
*
* // Using async
* let response = await fhirClient.resourceSearch({
* resourceType: 'Patient',
* searchParams: { name: 'Smith' },
* });
* console.log(response);
* @param params - The request parameters.
* @param params.resourceType - The resource type (e.g. "Patient",
* "Observation").
* @param params.searchParams - The search parameters.
* @param [params.headers] - DEPRECATED Optional custom headers to
* add to the request
* @param [params.options] - Optional options object
* @param [params.options.headers] - Optional headers to add to the
* request
* @param [params.options.postSearch] - if true, all `searchParams`
* will be placed in the request body rather than the url, and the search
* will use POST rather than GET
* @returns FHIR resources in a Bundle
*/
resourceSearch(params: {
resourceType: ResourceType;
searchParams: SearchParams;
headers?: HeadersInit;
options?: RequestInit;
}): Promise<FhirResource| FhirResource & { type: "searchset" }>;
/**
* Search across all FHIR resource types in the system.
* Only the parameters defined for all resources can be used.
* @example
* // Using promises
* fhirClient.systemSearch({
* searchParams: { name: 'smith' }
* }).then((data) => { console.log(data); });
*
* // Using async
* let response = await fhirClient.systemSearch({ searchParams: { name: 'smith' } });
* console.log(response);
* @param params - The request parameters.
* @param params.searchParams - The search parameters.
* @param [params.headers] - DEPRECATED Optional custom headers to
* add to the request
* @param [params.options] - Optional options object
* @param [params.options.headers] - Optional headers to add to the
* request
* @param [params.options.postSearch] - if true, all `searchParams`
* will be placed in the request body rather than the url, and the search
* will use POST rather than GET
* @returns FHIR resources in a Bundle
*/
systemSearch(params: {
searchParams: SearchParams;
headers?: HeadersInit;
options?: RequestInit;
}): Promise<FhirResource| FhirResource & { type: "searchset" }>;
/**
* Search for FHIR resources within a compartment.
* The resourceType and id must be specified.
* @example
* // Using promises
* fhirClient.compartmentSearch({
* resourceType: 'Observation',
* compartment: { resourceType: 'Patient', id: 123 },
* searchParams: { code: 'abc' }
* }).then((data) => { console.log(data); });
*
* // Using async
* let response = await fhirClient.compartmentSearch({
* resourceType: 'Observation',
* compartment: { resourceType: 'Patient', id: 123 },
* searchParams: { code: 'abc' }
* });
* console.log(response);
* @param params - The request parameters.
* @param params.resourceType - The resource type (e.g. "Patient",
* "Observation").
* @param params.compartment - The search compartment.
* @param [params.searchParams] - The search parameters, optional.
* @param [params.headers] - DEPRECATED Optional custom headers to
* add to the request
* @param [params.options] - Optional options object
* @param [params.options.headers] - Optional headers to add to the
* request
* @param [params.options.postSearch] - if true, all `searchParams`
* will be placed in the request body rather than the url, and the search
* will use POST rather than GET
* @returns FHIR resources in a Bundle
*/
compartmentSearch(params: {
resourceType: ResourceType,
compartment: Compartment,
searchParams?: SearchParams,
headers?: HeadersInit;
options?: RequestInit;
}): Promise<FhirResource| FhirResource & { type: "searchset" }> ;
/**
* Retrieve the change history for a FHIR resource id, a resource type or the
* entire system
* @example
* // Using promises
* fhirClient.history({ resourceType: 'Patient', id: '12345' });
* .then((data) => { console.log(data); });
*
* // Using async
* let response = await fhirClient.history({ resourceType: 'Patient', id: '12345' });
* console.log(response);
* @param params - The request parameters.
* @param [params.resourceType] - The resource type
* (e.g. "Patient", "Observation"), optional.
* @param [params.id] - The FHIR id for the resource, optional.
* @param [params.headers] - DEPRECATED Optional custom headers to
* add to the request
* @param [params.options] - Optional options object
* @param [params.options.headers] - Optional headers to add to the
* request
* @returns FHIR resources in a FHIR Bundle structure.
*/
history(params?: {
resourceType?: ResourceType;
id?: string;
headers?: HeadersInit;
options?: RequestInit;
}): Promise<FhirResource| FhirResource & { type: "history" }>;
/**
* Retrieve the change history for a particular resource FHIR id.
* @example
* // Using promises
* fhirClient.resourceHistory({ resourceType: 'Patient', id: '12345' });
* .then((data) => { console.log(data); });
*
* // Using async
* let response = await fhirClient.resourceHistory({ resourceType: 'Patient', id: '12345' });
* console.log(response);
* @param params - The request parameters.
* @param params.resourceType - The resource type (e.g. "Patient",