@medplum/mock 0.4.0

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.
@@ -0,0 +1,1158 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@medplum/core')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@medplum/core'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.medplum = global.medplum || {}, global.medplum.mock = {}), global.medplum.core));
5
+ })(this, (function (exports, core) { 'use strict';
6
+
7
+ const TestOrganization = {
8
+ resourceType: 'Organization',
9
+ id: '123',
10
+ meta: {
11
+ versionId: '1',
12
+ },
13
+ name: 'Test Organization',
14
+ };
15
+ const DifferentOrganization = {
16
+ resourceType: 'Organization',
17
+ id: '456',
18
+ meta: {
19
+ versionId: '1',
20
+ },
21
+ name: 'Different',
22
+ };
23
+ const OrganizationSearchBundle = {
24
+ resourceType: 'Bundle',
25
+ type: 'searchset',
26
+ entry: [
27
+ {
28
+ resource: DifferentOrganization,
29
+ },
30
+ ],
31
+ };
32
+ const DrAliceSmith = {
33
+ resourceType: 'Practitioner',
34
+ id: '123',
35
+ meta: {
36
+ versionId: '2',
37
+ lastUpdated: '2021-01-02T12:00:00Z',
38
+ author: {
39
+ reference: 'Practitioner/123',
40
+ },
41
+ },
42
+ name: [
43
+ {
44
+ given: ['Alice'],
45
+ family: 'Smith',
46
+ },
47
+ ],
48
+ };
49
+ const DrAliceSmithHistoryBundle = {
50
+ resourceType: 'Bundle',
51
+ type: 'history',
52
+ entry: [
53
+ {
54
+ resource: DrAliceSmith,
55
+ },
56
+ {
57
+ resource: {
58
+ resourceType: 'Practitioner',
59
+ id: '123',
60
+ meta: {
61
+ versionId: '1',
62
+ lastUpdated: '2021-01-01T12:00:00Z',
63
+ author: {
64
+ reference: 'Practitioner/123',
65
+ },
66
+ },
67
+ name: [{ given: ['Medplum'], family: 'Admin' }],
68
+ },
69
+ },
70
+ ],
71
+ };
72
+
73
+ const ExampleBot = {
74
+ resourceType: 'Bot',
75
+ id: '123',
76
+ name: 'Test Bot',
77
+ code: 'console.log("hello world");',
78
+ };
79
+
80
+ const ExampleQuestionnaire = {
81
+ resourceType: 'Questionnaire',
82
+ id: '123',
83
+ name: 'Vitals',
84
+ title: 'Vitals',
85
+ item: [
86
+ {
87
+ linkId: '1',
88
+ text: 'First question',
89
+ type: 'string',
90
+ },
91
+ ],
92
+ };
93
+ const ExampleQuestionnaireBundle = {
94
+ resourceType: 'Bundle',
95
+ type: 'searchset',
96
+ entry: [
97
+ {
98
+ resource: ExampleQuestionnaire,
99
+ },
100
+ ],
101
+ };
102
+ const ExampleQuestionnaireResponse = {
103
+ resourceType: 'QuestionnaireResponse',
104
+ id: '123',
105
+ questionnaire: 'Questionnaire/123',
106
+ subject: {
107
+ reference: 'Patient/123',
108
+ },
109
+ source: {
110
+ reference: 'Practitioner/123',
111
+ },
112
+ };
113
+
114
+ const HomerSimpson = {
115
+ resourceType: 'Patient',
116
+ id: '123',
117
+ meta: {
118
+ versionId: '2',
119
+ lastUpdated: '2020-01-02T00:00:00.000Z',
120
+ author: {
121
+ reference: 'Practitioner/123',
122
+ },
123
+ },
124
+ identifier: [
125
+ { system: 'abc', value: '123' },
126
+ { system: 'def', value: '456' },
127
+ ],
128
+ name: [
129
+ {
130
+ given: ['Homer'],
131
+ family: 'Simpson',
132
+ },
133
+ ],
134
+ photo: [
135
+ {
136
+ contentType: 'image/jpeg',
137
+ url: 'https://example.com/picture.jpg',
138
+ },
139
+ ],
140
+ };
141
+ const HomerSimpsonHistory = {
142
+ resourceType: 'Bundle',
143
+ type: 'history',
144
+ entry: [
145
+ {
146
+ resource: HomerSimpson,
147
+ },
148
+ {
149
+ resource: {
150
+ resourceType: 'Patient',
151
+ id: '123',
152
+ meta: {
153
+ versionId: '1',
154
+ lastUpdated: '2020-01-01T00:00:00.000Z',
155
+ author: {
156
+ reference: 'Practitioner/123',
157
+ },
158
+ },
159
+ name: [
160
+ {
161
+ given: ['Homer'],
162
+ family: 'Simpson',
163
+ },
164
+ ],
165
+ photo: [
166
+ {
167
+ contentType: 'image/jpeg',
168
+ url: 'https://example.com/picture.jpg',
169
+ },
170
+ ],
171
+ },
172
+ },
173
+ ],
174
+ };
175
+ const HomerEncounter = {
176
+ resourceType: 'Encounter',
177
+ id: '123',
178
+ meta: {
179
+ versionId: '456',
180
+ },
181
+ };
182
+ const HomerEncounterHistory = {
183
+ resourceType: 'Bundle',
184
+ type: 'history',
185
+ entry: [
186
+ {
187
+ resource: HomerEncounter,
188
+ },
189
+ ],
190
+ };
191
+ const HomerCommunications = {
192
+ resourceType: 'Bundle',
193
+ entry: [
194
+ {
195
+ resource: {
196
+ resourceType: 'Communication',
197
+ id: '123',
198
+ meta: {
199
+ lastUpdated: '2020-01-01T12:00:00Z',
200
+ author: {
201
+ reference: 'Practitioner/123',
202
+ },
203
+ },
204
+ payload: [
205
+ {
206
+ contentString: 'Hello world',
207
+ },
208
+ ],
209
+ },
210
+ },
211
+ ],
212
+ };
213
+ const HomerMedia = {
214
+ resourceType: 'Bundle',
215
+ entry: [
216
+ {
217
+ resource: {
218
+ resourceType: 'Media',
219
+ id: '123',
220
+ meta: {
221
+ lastUpdated: '2020-01-01T12:00:00Z',
222
+ author: {
223
+ reference: 'Practitioner/123',
224
+ },
225
+ },
226
+ content: {
227
+ contentType: 'text/plain',
228
+ url: 'https://example.com/test.txt',
229
+ },
230
+ },
231
+ },
232
+ ],
233
+ };
234
+ const HomerDiagnosticReport = {
235
+ resourceType: 'DiagnosticReport',
236
+ id: '123',
237
+ subject: {
238
+ reference: 'Patient/123',
239
+ display: 'Homer Simpson',
240
+ },
241
+ resultsInterpreter: [
242
+ {
243
+ reference: 'Practitioner/123',
244
+ display: 'Dr. Alice Smith',
245
+ },
246
+ ],
247
+ result: [
248
+ { reference: 'Observation/1' },
249
+ { reference: 'Observation/2' },
250
+ { reference: 'Observation/3' },
251
+ { reference: 'Observation/4' },
252
+ { reference: 'Observation/5' },
253
+ { reference: 'Observation/6' },
254
+ ],
255
+ };
256
+ const HomerDiagnosticReportBundle = {
257
+ resourceType: 'Bundle',
258
+ type: 'searchset',
259
+ entry: [
260
+ {
261
+ resource: HomerDiagnosticReport,
262
+ },
263
+ ],
264
+ };
265
+ const HomerObservation1 = {
266
+ resourceType: 'Observation',
267
+ id: '1',
268
+ valueString: 'test',
269
+ };
270
+ const HomerObservation2 = {
271
+ resourceType: 'Observation',
272
+ id: '2',
273
+ valueQuantity: {
274
+ value: 20,
275
+ unit: 'x',
276
+ },
277
+ referenceRange: [
278
+ {
279
+ low: {
280
+ value: 10,
281
+ },
282
+ },
283
+ ],
284
+ };
285
+ const HomerObservation3 = {
286
+ resourceType: 'Observation',
287
+ id: '3',
288
+ valueQuantity: {
289
+ value: 30,
290
+ unit: 'x',
291
+ },
292
+ referenceRange: [
293
+ {
294
+ high: {
295
+ value: 50,
296
+ },
297
+ },
298
+ ],
299
+ };
300
+ const HomerObservation4 = {
301
+ resourceType: 'Observation',
302
+ id: '4',
303
+ valueQuantity: {
304
+ value: 50,
305
+ unit: 'x',
306
+ },
307
+ referenceRange: [
308
+ {
309
+ low: {
310
+ value: 10,
311
+ },
312
+ high: {
313
+ value: 50,
314
+ },
315
+ },
316
+ ],
317
+ interpretation: [
318
+ {
319
+ text: 'HIGH',
320
+ },
321
+ ],
322
+ };
323
+ const HomerObservation5 = {
324
+ resourceType: 'Observation',
325
+ id: '5',
326
+ valueQuantity: {
327
+ value: 100,
328
+ unit: 'x',
329
+ },
330
+ referenceRange: [{}],
331
+ interpretation: [{}],
332
+ };
333
+ const HomerObservation6 = {
334
+ resourceType: 'Observation',
335
+ component: [
336
+ {
337
+ valueQuantity: {
338
+ value: 110,
339
+ unit: 'mmHg',
340
+ system: 'http://unitsofmeasure.org',
341
+ },
342
+ },
343
+ {
344
+ valueQuantity: {
345
+ value: 75,
346
+ unit: 'mmHg',
347
+ system: 'http://unitsofmeasure.org',
348
+ },
349
+ },
350
+ ],
351
+ };
352
+ const HomerObservationSearchBundle = {
353
+ resourceType: 'Bundle',
354
+ total: 1,
355
+ entry: [
356
+ {
357
+ resource: HomerObservation3,
358
+ },
359
+ ],
360
+ };
361
+ const HomerServiceRequest = {
362
+ resourceType: 'ServiceRequest',
363
+ id: '123',
364
+ meta: {
365
+ versionId: '1',
366
+ lastUpdated: '2020-01-01T12:00:00Z',
367
+ author: {
368
+ reference: 'Practitioner/123',
369
+ },
370
+ },
371
+ code: {
372
+ coding: [
373
+ {
374
+ system: 'http://snomed.info/sct',
375
+ code: 'SERVICE_REQUEST_CODE',
376
+ },
377
+ ],
378
+ },
379
+ subject: {
380
+ reference: 'Patient/123',
381
+ display: 'Homer Simpson',
382
+ },
383
+ };
384
+ const HomerServiceRequestHistoryBundle = {
385
+ resourceType: 'Bundle',
386
+ type: 'history',
387
+ entry: [
388
+ {
389
+ resource: HomerServiceRequest,
390
+ },
391
+ ],
392
+ };
393
+ const HomerServiceRequestSearchBundle = {
394
+ resourceType: 'Bundle',
395
+ type: 'searchset',
396
+ entry: [
397
+ {
398
+ resource: HomerServiceRequest,
399
+ },
400
+ ],
401
+ };
402
+ const BartSimpson = {
403
+ resourceType: 'Patient',
404
+ id: '555',
405
+ meta: {
406
+ versionId: '1',
407
+ lastUpdated: '2020-01-01T12:00:00Z',
408
+ author: {
409
+ reference: 'Practitioner/123',
410
+ },
411
+ },
412
+ name: [
413
+ {
414
+ given: ['Bart'],
415
+ family: 'Simpson',
416
+ },
417
+ ],
418
+ photo: [
419
+ {
420
+ contentType: 'image/jpeg',
421
+ url: 'https://example.com/picture.jpg',
422
+ },
423
+ ],
424
+ };
425
+ const SimpsonSearchBundle = {
426
+ resourceType: 'Bundle',
427
+ type: 'searchset',
428
+ total: 2,
429
+ entry: [
430
+ {
431
+ resource: HomerSimpson,
432
+ },
433
+ {
434
+ resource: BartSimpson,
435
+ },
436
+ ],
437
+ };
438
+
439
+ const ExampleSubscription = {
440
+ resourceType: 'Subscription',
441
+ id: '123',
442
+ meta: {
443
+ versionId: '456',
444
+ },
445
+ };
446
+ const ExampleSubscriptionHistory = {
447
+ resourceType: 'Bundle',
448
+ type: 'history',
449
+ entry: [
450
+ {
451
+ resource: ExampleSubscription,
452
+ },
453
+ ],
454
+ };
455
+ const ExampleAuditEvent = {
456
+ resourceType: 'AuditEvent',
457
+ id: '123',
458
+ meta: {
459
+ lastUpdated: new Date().toISOString(),
460
+ versionId: '456',
461
+ author: {
462
+ reference: 'Practitioner/123',
463
+ },
464
+ },
465
+ };
466
+ const ExampleAuditEventBundle = {
467
+ resourceType: 'Bundle',
468
+ entry: [
469
+ {
470
+ resource: ExampleAuditEvent,
471
+ },
472
+ ],
473
+ };
474
+
475
+ const EmptySearchBundle = {
476
+ resourceType: 'Bundle',
477
+ type: 'searchset',
478
+ total: 0,
479
+ entry: [],
480
+ };
481
+ const ObservationStructureDefinition = {
482
+ resourceType: 'StructureDefinition',
483
+ name: 'Observation',
484
+ snapshot: {
485
+ element: [
486
+ {
487
+ path: 'Observation.id',
488
+ type: [
489
+ {
490
+ code: 'code',
491
+ },
492
+ ],
493
+ },
494
+ {
495
+ path: 'Observation.value[x]',
496
+ min: 0,
497
+ max: '1',
498
+ type: [
499
+ {
500
+ code: 'Quantity',
501
+ },
502
+ {
503
+ code: 'CodeableConcept',
504
+ },
505
+ {
506
+ code: 'string',
507
+ },
508
+ {
509
+ code: 'boolean',
510
+ },
511
+ {
512
+ code: 'integer',
513
+ },
514
+ {
515
+ code: 'Range',
516
+ },
517
+ {
518
+ code: 'Ratio',
519
+ },
520
+ {
521
+ code: 'SampledData',
522
+ },
523
+ {
524
+ code: 'time',
525
+ },
526
+ {
527
+ code: 'dateTime',
528
+ },
529
+ {
530
+ code: 'Period',
531
+ },
532
+ ],
533
+ },
534
+ ],
535
+ },
536
+ };
537
+ const PatientStructureDefinition = {
538
+ resourceType: 'StructureDefinition',
539
+ id: '123',
540
+ name: 'Patient',
541
+ snapshot: {
542
+ element: [
543
+ {
544
+ id: 'Patient.name',
545
+ path: 'Patient.name',
546
+ type: [
547
+ {
548
+ code: 'HumanName',
549
+ },
550
+ ],
551
+ max: '*',
552
+ },
553
+ ],
554
+ },
555
+ };
556
+ const PatientSearchParameters = [
557
+ {
558
+ resourceType: 'SearchParameter',
559
+ id: 'Patient-name',
560
+ base: ['Patient'],
561
+ code: 'name',
562
+ name: 'name',
563
+ type: 'string',
564
+ expression: 'Patient.name',
565
+ },
566
+ {
567
+ resourceType: 'SearchParameter',
568
+ id: 'Patient-birthdate',
569
+ base: ['Patient'],
570
+ code: 'birthdate',
571
+ name: 'birthdate',
572
+ type: 'date',
573
+ expression: 'Patient.birthdate',
574
+ },
575
+ {
576
+ resourceType: 'SearchParameter',
577
+ id: 'Patient-organization',
578
+ base: ['Patient'],
579
+ code: 'organization',
580
+ name: 'organization',
581
+ type: 'reference',
582
+ expression: 'Patient.organization',
583
+ target: ['Organization'],
584
+ },
585
+ ];
586
+ const PractitionerStructureDefinition = {
587
+ resourceType: 'StructureDefinition',
588
+ name: 'Practitioner',
589
+ snapshot: {
590
+ element: [
591
+ {
592
+ path: 'Practitioner.id',
593
+ type: [
594
+ {
595
+ code: 'code',
596
+ },
597
+ ],
598
+ },
599
+ {
600
+ path: 'Practitioner.name',
601
+ type: [
602
+ {
603
+ code: 'HumanName',
604
+ },
605
+ ],
606
+ max: '*',
607
+ },
608
+ {
609
+ path: 'Practitioner.gender',
610
+ type: [
611
+ {
612
+ code: 'code',
613
+ },
614
+ ],
615
+ },
616
+ ],
617
+ },
618
+ };
619
+ const QuestionnaireStructureDefinition = {
620
+ resourceType: 'StructureDefinition',
621
+ name: 'Questionnaire',
622
+ snapshot: {
623
+ element: [
624
+ {
625
+ id: 'Questionnaire.item',
626
+ path: 'Questionnaire.item',
627
+ type: [
628
+ {
629
+ code: 'BackboneElement',
630
+ },
631
+ ],
632
+ },
633
+ {
634
+ id: 'Questionnaire.item.answerOption',
635
+ path: 'Questionnaire.item.answerOption',
636
+ type: [
637
+ {
638
+ code: 'BackboneElement',
639
+ },
640
+ ],
641
+ },
642
+ {
643
+ id: 'Questionnaire.item.answerOption.value[x]',
644
+ path: 'Questionnaire.item.answerOption.value[x]',
645
+ min: 1,
646
+ max: '1',
647
+ type: [
648
+ {
649
+ code: 'integer',
650
+ },
651
+ {
652
+ code: 'date',
653
+ },
654
+ {
655
+ code: 'time',
656
+ },
657
+ {
658
+ code: 'string',
659
+ },
660
+ {
661
+ code: 'Coding',
662
+ },
663
+ {
664
+ code: 'Reference',
665
+ targetProfile: ['http://hl7.org/fhir/StructureDefinition/Resource'],
666
+ },
667
+ ],
668
+ },
669
+ ],
670
+ },
671
+ };
672
+ const ServiceRequestServiceDefinition = {
673
+ resourceType: 'StructureDefinition',
674
+ name: 'ServiceRequest',
675
+ snapshot: {
676
+ element: [
677
+ {
678
+ path: 'ServiceRequest.id',
679
+ type: [
680
+ {
681
+ code: 'code',
682
+ },
683
+ ],
684
+ },
685
+ {
686
+ path: 'ServiceRequest.code',
687
+ type: [
688
+ {
689
+ code: 'CodeableConcept',
690
+ },
691
+ ],
692
+ },
693
+ ],
694
+ },
695
+ };
696
+ const GraphQLSchemaResponse = {
697
+ data: {
698
+ StructureDefinitionList: [
699
+ ObservationStructureDefinition,
700
+ PatientStructureDefinition,
701
+ PractitionerStructureDefinition,
702
+ QuestionnaireStructureDefinition,
703
+ ServiceRequestServiceDefinition,
704
+ ],
705
+ SearchParameterList: [...PatientSearchParameters],
706
+ },
707
+ };
708
+
709
+ const exampleValueSet = {
710
+ resourceType: 'ValueSet',
711
+ expansion: {
712
+ contains: [
713
+ {
714
+ system: 'x',
715
+ code: 'test-code',
716
+ display: 'Test Display',
717
+ },
718
+ ],
719
+ },
720
+ };
721
+
722
+ const ExampleAccessPolicy = {
723
+ resourceType: 'AccessPolicy',
724
+ id: '123',
725
+ name: 'Example Access Policy',
726
+ };
727
+ const ExampleAccessPolicySearchBundle = {
728
+ resourceType: 'Bundle',
729
+ type: 'searchset',
730
+ entry: [
731
+ {
732
+ resource: ExampleAccessPolicy,
733
+ },
734
+ ],
735
+ };
736
+
737
+ const newComment = {
738
+ resourceType: 'Communication',
739
+ id: 'new-comment',
740
+ payload: [
741
+ {
742
+ contentString: 'Test comment',
743
+ },
744
+ ],
745
+ };
746
+ const newMedia = {
747
+ resourceType: 'Media',
748
+ id: 'new-media',
749
+ content: {
750
+ contentType: 'text/plain',
751
+ url: 'https://example.com/test2.txt',
752
+ },
753
+ };
754
+ const routes = {
755
+ 'admin/projects/123': {
756
+ GET: {
757
+ project: { id: '123', name: 'Project 123' },
758
+ members: [{ profile: 'Practitioner/123', name: 'Alice Smith' }],
759
+ },
760
+ },
761
+ 'admin/super/structuredefinitions': {
762
+ POST: {
763
+ ok: true,
764
+ },
765
+ },
766
+ 'admin/super/valuesets': {
767
+ POST: {
768
+ ok: true,
769
+ },
770
+ },
771
+ 'admin/super/reindex': {
772
+ POST: {
773
+ ok: true,
774
+ },
775
+ },
776
+ 'auth/changepassword': {
777
+ POST: (body) => {
778
+ const { oldPassword } = JSON.parse(body);
779
+ if (oldPassword === 'orange') {
780
+ return core.allOk;
781
+ }
782
+ else {
783
+ return {
784
+ resourceType: 'OperationOutcome',
785
+ issue: [
786
+ {
787
+ expression: ['oldPassword'],
788
+ details: {
789
+ text: 'Incorrect password',
790
+ },
791
+ },
792
+ ],
793
+ };
794
+ }
795
+ },
796
+ },
797
+ 'auth/login': {
798
+ POST: {
799
+ profile: { reference: 'Practitioner/123' },
800
+ },
801
+ },
802
+ 'auth/setpassword': {
803
+ POST: (body) => {
804
+ const { password } = JSON.parse(body);
805
+ if (password === 'orange') {
806
+ return core.allOk;
807
+ }
808
+ else {
809
+ return {
810
+ resourceType: 'OperationOutcome',
811
+ issue: [
812
+ {
813
+ expression: ['password'],
814
+ details: {
815
+ text: 'Invalid password',
816
+ },
817
+ },
818
+ ],
819
+ };
820
+ }
821
+ },
822
+ },
823
+ 'auth/register': {
824
+ POST: (body) => {
825
+ const { email, password } = JSON.parse(body);
826
+ if (email === 'george@example.com' && password === 'password') {
827
+ return core.allOk;
828
+ }
829
+ else {
830
+ return {
831
+ resourceType: 'OperationOutcome',
832
+ issue: [
833
+ {
834
+ details: {
835
+ text: 'Invalid',
836
+ },
837
+ },
838
+ ],
839
+ };
840
+ }
841
+ },
842
+ },
843
+ 'auth/resetpassword': {
844
+ POST: (body) => {
845
+ const { email } = JSON.parse(body);
846
+ if (email === 'admin@example.com') {
847
+ return core.allOk;
848
+ }
849
+ else {
850
+ return {
851
+ resourceType: 'OperationOutcome',
852
+ issue: [
853
+ {
854
+ expression: ['email'],
855
+ details: {
856
+ text: 'Email not found',
857
+ },
858
+ },
859
+ ],
860
+ };
861
+ }
862
+ },
863
+ },
864
+ 'fhir/R4/AccessPolicy?name=Example%20Access%20Policy': {
865
+ GET: ExampleAccessPolicySearchBundle,
866
+ },
867
+ 'fhir/R4/AccessPolicy/123': {
868
+ GET: ExampleAccessPolicy,
869
+ },
870
+ 'fhir/R4/AuditEvent?entity=Subscription/123&_count=20&_sort=-_lastUpdated': {
871
+ GET: ExampleAuditEventBundle,
872
+ },
873
+ 'fhir/R4/Binary?_filename=hello.exe': {
874
+ POST: core.badRequest('Invalid file type'),
875
+ },
876
+ 'fhir/R4/Bot/123': {
877
+ GET: ExampleBot,
878
+ },
879
+ 'fhir/R4/Communication': {
880
+ POST: newComment,
881
+ },
882
+ 'fhir/R4/Communication?based-on=ServiceRequest/123': {
883
+ GET: HomerCommunications,
884
+ },
885
+ 'fhir/R4/Communication?encounter=Encounter/123': {
886
+ GET: HomerCommunications,
887
+ },
888
+ 'fhir/R4/Communication?subject=Patient/123': {
889
+ GET: HomerCommunications,
890
+ },
891
+ 'fhir/R4/Device?subject=Patient/123': {
892
+ GET: EmptySearchBundle,
893
+ },
894
+ 'fhir/R4/DeviceRequest?patient=Patient/123': {
895
+ GET: EmptySearchBundle,
896
+ },
897
+ 'fhir/R4/DiagnosticReport/123': {
898
+ GET: HomerDiagnosticReport,
899
+ },
900
+ 'fhir/R4/DiagnosticReport/123/_history': {
901
+ GET: HomerDiagnosticReportBundle,
902
+ },
903
+ 'fhir/R4/DiagnosticReport?based-on=ServiceRequest/123': {
904
+ GET: HomerDiagnosticReportBundle,
905
+ },
906
+ 'fhir/R4/DiagnosticReport?subject=Patient/123': {
907
+ GET: HomerDiagnosticReportBundle,
908
+ },
909
+ 'fhir/R4/Encounter/123': {
910
+ GET: HomerEncounter,
911
+ },
912
+ 'fhir/R4/Encounter/123/_history': {
913
+ GET: HomerEncounterHistory,
914
+ },
915
+ 'fhir/R4/Media': {
916
+ POST: newMedia,
917
+ },
918
+ 'fhir/R4/Media?based-on=ServiceRequest/123': {
919
+ GET: HomerMedia,
920
+ },
921
+ 'fhir/R4/Media?encounter=Encounter/123': {
922
+ GET: HomerMedia,
923
+ },
924
+ 'fhir/R4/Media?subject=Patient/123': {
925
+ GET: HomerMedia,
926
+ },
927
+ 'fhir/R4/Observation?_fields=value[x]': {
928
+ GET: HomerObservationSearchBundle,
929
+ },
930
+ 'fhir/R4/Observation/1': {
931
+ GET: HomerObservation1,
932
+ },
933
+ 'fhir/R4/Observation/2': {
934
+ GET: HomerObservation2,
935
+ },
936
+ 'fhir/R4/Observation/3': {
937
+ GET: HomerObservation3,
938
+ },
939
+ 'fhir/R4/Observation/4': {
940
+ GET: HomerObservation4,
941
+ },
942
+ 'fhir/R4/Observation/5': {
943
+ GET: HomerObservation5,
944
+ },
945
+ 'fhir/R4/Observation/6': {
946
+ GET: HomerObservation6,
947
+ },
948
+ 'fhir/R4/Organization?name=Different': {
949
+ GET: OrganizationSearchBundle,
950
+ },
951
+ 'fhir/R4/Organization/123': {
952
+ GET: TestOrganization,
953
+ },
954
+ 'fhir/R4/Organization/456': {
955
+ GET: DifferentOrganization,
956
+ },
957
+ 'fhir/R4/Patient?name=Simpson': {
958
+ GET: SimpsonSearchBundle,
959
+ },
960
+ 'fhir/R4/Patient?_fields=id,_lastUpdated,name&name=Simpson': {
961
+ GET: SimpsonSearchBundle,
962
+ },
963
+ 'fhir/R4/Patient?_count=20&_fields=id,_lastUpdated,name,birthDate,gender&_sort=-_lastUpdated': {
964
+ GET: SimpsonSearchBundle,
965
+ },
966
+ 'fhir/R4/Patient?_fields=id,_lastUpdated,name&_lastUpdated=ge2021-12-01T00%3A00%3A00.000Z': {
967
+ GET: SimpsonSearchBundle,
968
+ },
969
+ 'fhir/R4/Patient?name=Bob': {
970
+ GET: EmptySearchBundle,
971
+ },
972
+ 'fhir/R4/Patient/123': {
973
+ GET: HomerSimpson,
974
+ },
975
+ 'fhir/R4/Patient/123/_history': {
976
+ GET: HomerSimpsonHistory,
977
+ },
978
+ 'fhir/R4/Practitioner': {
979
+ POST: HomerSimpson,
980
+ },
981
+ 'fhir/R4/Practitioner/123': {
982
+ GET: DrAliceSmith,
983
+ },
984
+ 'fhir/R4/Practitioner/123/_history': {
985
+ GET: DrAliceSmithHistoryBundle,
986
+ },
987
+ 'fhir/R4/Practitioner/123/_history/1': {
988
+ GET: DrAliceSmith,
989
+ },
990
+ 'fhir/R4/Practitioner/not-found/_history': {
991
+ GET: core.notFound,
992
+ },
993
+ 'fhir/R4/Questionnaire?subject-type=Patient': {
994
+ GET: ExampleQuestionnaireBundle,
995
+ },
996
+ 'fhir/R4/Questionnaire/not-found': {
997
+ GET: core.notFound,
998
+ },
999
+ 'fhir/R4/Questionnaire/123': {
1000
+ GET: ExampleQuestionnaire,
1001
+ },
1002
+ 'fhir/R4/QuestionnaireResponse': {
1003
+ POST: ExampleQuestionnaireResponse,
1004
+ },
1005
+ 'fhir/R4/QuestionnaireResponse/123': {
1006
+ GET: ExampleQuestionnaireResponse,
1007
+ },
1008
+ 'fhir/R4/ServiceRequest/123': {
1009
+ GET: HomerServiceRequest,
1010
+ },
1011
+ 'fhir/R4/ServiceRequest/123/_history': {
1012
+ GET: HomerServiceRequestHistoryBundle,
1013
+ },
1014
+ 'fhir/R4/ServiceRequest?subject=Patient/123': {
1015
+ GET: HomerServiceRequestSearchBundle,
1016
+ },
1017
+ 'fhir/R4/Subscription/123': {
1018
+ GET: ExampleSubscription,
1019
+ },
1020
+ 'fhir/R4/Subscription/123/_history': {
1021
+ GET: ExampleSubscriptionHistory,
1022
+ },
1023
+ 'fhir/R4/ValueSet/%24expand?url=https%3A%2F%2Fexample.com%2Ftest&filter=xyz': {
1024
+ GET: exampleValueSet,
1025
+ },
1026
+ 'fhir/R4/%24graphql': {
1027
+ POST: GraphQLSchemaResponse,
1028
+ },
1029
+ 'fhir/R4': {
1030
+ POST: (body) => {
1031
+ var _a;
1032
+ const request = JSON.parse(body);
1033
+ return {
1034
+ resourceType: 'Bundle',
1035
+ type: 'batch-response',
1036
+ entry: (_a = request.entry) === null || _a === void 0 ? void 0 : _a.map((e) => {
1037
+ var _a, _b, _c;
1038
+ const url = 'fhir/R4/' + ((_a = e === null || e === void 0 ? void 0 : e.request) === null || _a === void 0 ? void 0 : _a.url);
1039
+ const method = (_b = e === null || e === void 0 ? void 0 : e.request) === null || _b === void 0 ? void 0 : _b.method;
1040
+ const resource = (_c = routes[url]) === null || _c === void 0 ? void 0 : _c[method];
1041
+ if ((resource === null || resource === void 0 ? void 0 : resource.resourceType) === 'OperationOutcome') {
1042
+ return { resource, response: { status: core.getStatus(resource).toString() } };
1043
+ }
1044
+ else if (resource) {
1045
+ return { resource, response: { status: '200' } };
1046
+ }
1047
+ else {
1048
+ return { resource: core.notFound, response: { status: '404' } };
1049
+ }
1050
+ }),
1051
+ };
1052
+ },
1053
+ },
1054
+ };
1055
+ class MockClient extends core.MedplumClient {
1056
+ constructor(clientOptions) {
1057
+ super({
1058
+ baseUrl: 'https://example.com/',
1059
+ clientId: 'my-client-id',
1060
+ fetch: (url, options) => {
1061
+ var _a;
1062
+ const method = options.method;
1063
+ const path = url.replace('https://example.com/', '');
1064
+ if (clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.debug) {
1065
+ console.log('MockClient', method, path);
1066
+ }
1067
+ let result = (_a = routes[path]) === null || _a === void 0 ? void 0 : _a[method];
1068
+ if (typeof result === 'function') {
1069
+ result = result(options.body);
1070
+ }
1071
+ if ((clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.debug) && !result) {
1072
+ console.log('MockClient: not found', method, path);
1073
+ }
1074
+ const response = Object.assign({ request: {
1075
+ url,
1076
+ options,
1077
+ } }, result);
1078
+ if (clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.debug) {
1079
+ console.log('MockClient', JSON.stringify(response, null, 2));
1080
+ }
1081
+ return Promise.resolve({
1082
+ json: () => Promise.resolve(response),
1083
+ });
1084
+ },
1085
+ });
1086
+ }
1087
+ clear() {
1088
+ super.clear();
1089
+ this.activeLoginOverride = undefined;
1090
+ }
1091
+ getProfile() {
1092
+ return {
1093
+ resourceType: 'Practitioner',
1094
+ id: '123',
1095
+ meta: {
1096
+ versionId: '456',
1097
+ },
1098
+ };
1099
+ }
1100
+ setActiveLoginOverride(activeLoginOverride) {
1101
+ this.activeLoginOverride = activeLoginOverride;
1102
+ }
1103
+ getActiveLogin() {
1104
+ if (this.activeLoginOverride !== undefined) {
1105
+ return this.activeLoginOverride;
1106
+ }
1107
+ return super.getActiveLogin();
1108
+ }
1109
+ }
1110
+
1111
+ exports.BartSimpson = BartSimpson;
1112
+ exports.DifferentOrganization = DifferentOrganization;
1113
+ exports.DrAliceSmith = DrAliceSmith;
1114
+ exports.DrAliceSmithHistoryBundle = DrAliceSmithHistoryBundle;
1115
+ exports.EmptySearchBundle = EmptySearchBundle;
1116
+ exports.ExampleAuditEvent = ExampleAuditEvent;
1117
+ exports.ExampleAuditEventBundle = ExampleAuditEventBundle;
1118
+ exports.ExampleBot = ExampleBot;
1119
+ exports.ExampleQuestionnaire = ExampleQuestionnaire;
1120
+ exports.ExampleQuestionnaireBundle = ExampleQuestionnaireBundle;
1121
+ exports.ExampleQuestionnaireResponse = ExampleQuestionnaireResponse;
1122
+ exports.ExampleSubscription = ExampleSubscription;
1123
+ exports.ExampleSubscriptionHistory = ExampleSubscriptionHistory;
1124
+ exports.GraphQLSchemaResponse = GraphQLSchemaResponse;
1125
+ exports.HomerCommunications = HomerCommunications;
1126
+ exports.HomerDiagnosticReport = HomerDiagnosticReport;
1127
+ exports.HomerDiagnosticReportBundle = HomerDiagnosticReportBundle;
1128
+ exports.HomerEncounter = HomerEncounter;
1129
+ exports.HomerEncounterHistory = HomerEncounterHistory;
1130
+ exports.HomerMedia = HomerMedia;
1131
+ exports.HomerObservation1 = HomerObservation1;
1132
+ exports.HomerObservation2 = HomerObservation2;
1133
+ exports.HomerObservation3 = HomerObservation3;
1134
+ exports.HomerObservation4 = HomerObservation4;
1135
+ exports.HomerObservation5 = HomerObservation5;
1136
+ exports.HomerObservation6 = HomerObservation6;
1137
+ exports.HomerObservationSearchBundle = HomerObservationSearchBundle;
1138
+ exports.HomerServiceRequest = HomerServiceRequest;
1139
+ exports.HomerServiceRequestHistoryBundle = HomerServiceRequestHistoryBundle;
1140
+ exports.HomerServiceRequestSearchBundle = HomerServiceRequestSearchBundle;
1141
+ exports.HomerSimpson = HomerSimpson;
1142
+ exports.HomerSimpsonHistory = HomerSimpsonHistory;
1143
+ exports.MockClient = MockClient;
1144
+ exports.ObservationStructureDefinition = ObservationStructureDefinition;
1145
+ exports.OrganizationSearchBundle = OrganizationSearchBundle;
1146
+ exports.PatientSearchParameters = PatientSearchParameters;
1147
+ exports.PatientStructureDefinition = PatientStructureDefinition;
1148
+ exports.PractitionerStructureDefinition = PractitionerStructureDefinition;
1149
+ exports.QuestionnaireStructureDefinition = QuestionnaireStructureDefinition;
1150
+ exports.ServiceRequestServiceDefinition = ServiceRequestServiceDefinition;
1151
+ exports.SimpsonSearchBundle = SimpsonSearchBundle;
1152
+ exports.TestOrganization = TestOrganization;
1153
+ exports.exampleValueSet = exampleValueSet;
1154
+
1155
+ Object.defineProperty(exports, '__esModule', { value: true });
1156
+
1157
+ }));
1158
+ //# sourceMappingURL=index.js.map