@medplum/mock 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +296 -463
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/cjs/index.min.cjs.map +1 -1
- package/dist/esm/index.min.mjs +1 -1
- package/dist/esm/index.min.mjs.map +1 -1
- package/dist/esm/index.mjs +295 -461
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/client.d.ts +30 -0
- package/dist/types/mocks/index.d.ts +0 -1
- package/package.json +6 -4
- package/tsconfig.build.json +9 -0
- package/dist/cjs/client.d.ts +0 -16
- package/dist/cjs/index.d.ts +0 -2
- package/dist/cjs/mocks/accesspolicy.d.ts +0 -4
- package/dist/cjs/mocks/alice.d.ts +0 -7
- package/dist/cjs/mocks/bot.d.ts +0 -3
- package/dist/cjs/mocks/index.d.ts +0 -9
- package/dist/cjs/mocks/questionnaire.d.ts +0 -3
- package/dist/cjs/mocks/simpsons.d.ts +0 -23
- package/dist/cjs/mocks/smart.d.ts +0 -2
- package/dist/cjs/mocks/subscription.d.ts +0 -3
- package/dist/cjs/mocks/types.d.ts +0 -81
- package/dist/cjs/mocks/valueset.d.ts +0 -2
- package/dist/cjs/mocks/workflow.d.ts +0 -10
- package/dist/cjs/repo.d.ts +0 -16
- package/dist/esm/client.d.ts +0 -16
- package/dist/esm/index.d.ts +0 -2
- package/dist/esm/mocks/accesspolicy.d.ts +0 -4
- package/dist/esm/mocks/alice.d.ts +0 -7
- package/dist/esm/mocks/bot.d.ts +0 -3
- package/dist/esm/mocks/index.d.ts +0 -9
- package/dist/esm/mocks/questionnaire.d.ts +0 -3
- package/dist/esm/mocks/simpsons.d.ts +0 -23
- package/dist/esm/mocks/smart.d.ts +0 -2
- package/dist/esm/mocks/subscription.d.ts +0 -3
- package/dist/esm/mocks/types.d.ts +0 -81
- package/dist/esm/mocks/valueset.d.ts +0 -2
- package/dist/esm/mocks/workflow.d.ts +0 -10
- package/dist/esm/repo.d.ts +0 -16
- package/dist/types/mocks/types.d.ts +0 -81
- package/dist/types/repo.d.ts +0 -16
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createReference, getReferenceString,
|
|
2
|
-
import {
|
|
1
|
+
import { createReference, getReferenceString, MedplumClient, badRequest, isOk, getStatus, allOk, indexStructureDefinition, OperationOutcomeError } from '@medplum/core';
|
|
2
|
+
import { FhirRouter, MemoryRepository } from '@medplum/fhir-router';
|
|
3
3
|
|
|
4
4
|
const ExampleAccessPolicy = {
|
|
5
5
|
resourceType: 'AccessPolicy',
|
|
@@ -782,6 +782,134 @@ const ExampleAuditEvent = {
|
|
|
782
782
|
},
|
|
783
783
|
};
|
|
784
784
|
|
|
785
|
+
const exampleValueSet = {
|
|
786
|
+
resourceType: 'ValueSet',
|
|
787
|
+
expansion: {
|
|
788
|
+
contains: [
|
|
789
|
+
{
|
|
790
|
+
system: 'x',
|
|
791
|
+
code: 'test-code',
|
|
792
|
+
display: 'Test Display',
|
|
793
|
+
},
|
|
794
|
+
],
|
|
795
|
+
},
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
const ExampleWorkflowQuestionnaire1 = {
|
|
799
|
+
resourceType: 'Questionnaire',
|
|
800
|
+
id: 'workflow-questionnaire-1',
|
|
801
|
+
name: 'Patient Registration',
|
|
802
|
+
title: 'Patient Registration',
|
|
803
|
+
subjectType: ['Patient'],
|
|
804
|
+
item: [
|
|
805
|
+
{
|
|
806
|
+
linkId: '1',
|
|
807
|
+
text: 'First question',
|
|
808
|
+
type: 'string',
|
|
809
|
+
},
|
|
810
|
+
],
|
|
811
|
+
};
|
|
812
|
+
const ExampleWorkflowQuestionnaire2 = {
|
|
813
|
+
resourceType: 'Questionnaire',
|
|
814
|
+
id: 'workflow-questionnaire-2',
|
|
815
|
+
name: 'Surgery History',
|
|
816
|
+
title: 'Surgery History',
|
|
817
|
+
subjectType: ['Patient'],
|
|
818
|
+
item: [
|
|
819
|
+
{
|
|
820
|
+
linkId: '1',
|
|
821
|
+
text: 'First question',
|
|
822
|
+
type: 'string',
|
|
823
|
+
},
|
|
824
|
+
],
|
|
825
|
+
};
|
|
826
|
+
const ExampleWorkflowQuestionnaire3 = {
|
|
827
|
+
resourceType: 'Questionnaire',
|
|
828
|
+
id: 'workflow-questionnaire-3',
|
|
829
|
+
name: 'Family Health History',
|
|
830
|
+
title: 'Family Health History',
|
|
831
|
+
subjectType: ['Patient'],
|
|
832
|
+
item: [
|
|
833
|
+
{
|
|
834
|
+
linkId: '1',
|
|
835
|
+
text: 'First question',
|
|
836
|
+
type: 'string',
|
|
837
|
+
},
|
|
838
|
+
],
|
|
839
|
+
};
|
|
840
|
+
const ExampleWorkflowPlanDefinition = {
|
|
841
|
+
resourceType: 'PlanDefinition',
|
|
842
|
+
id: 'workflow-plan-definition-1',
|
|
843
|
+
title: 'Example Plan Definition',
|
|
844
|
+
action: [
|
|
845
|
+
{
|
|
846
|
+
title: ExampleWorkflowQuestionnaire1.title,
|
|
847
|
+
definitionCanonical: getReferenceString(ExampleWorkflowQuestionnaire1),
|
|
848
|
+
},
|
|
849
|
+
{
|
|
850
|
+
title: ExampleWorkflowQuestionnaire2.title,
|
|
851
|
+
definitionCanonical: getReferenceString(ExampleWorkflowQuestionnaire2),
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
title: ExampleWorkflowQuestionnaire3.title,
|
|
855
|
+
definitionCanonical: getReferenceString(ExampleWorkflowQuestionnaire3),
|
|
856
|
+
},
|
|
857
|
+
],
|
|
858
|
+
};
|
|
859
|
+
const ExampleWorkflowQuestionnaireResponse1 = {
|
|
860
|
+
resourceType: 'QuestionnaireResponse',
|
|
861
|
+
id: 'workflow-questionnaire-response-1',
|
|
862
|
+
questionnaire: getReferenceString(ExampleWorkflowQuestionnaire1),
|
|
863
|
+
subject: createReference(HomerSimpson),
|
|
864
|
+
source: createReference(HomerSimpson),
|
|
865
|
+
};
|
|
866
|
+
// Based on: http://build.fhir.org/ig/HL7/sdc/Task-example.json.html
|
|
867
|
+
const ExampleWorkflowTask1 = {
|
|
868
|
+
resourceType: 'Task',
|
|
869
|
+
id: 'workflow-task-1',
|
|
870
|
+
status: 'completed',
|
|
871
|
+
meta: { author: createReference(HomerSimpson) },
|
|
872
|
+
requester: createReference(DrAliceSmith),
|
|
873
|
+
input: [{ valueReference: createReference(ExampleWorkflowQuestionnaire1) }],
|
|
874
|
+
output: [{ valueReference: createReference(ExampleWorkflowQuestionnaireResponse1) }],
|
|
875
|
+
};
|
|
876
|
+
const ExampleWorkflowTask2 = {
|
|
877
|
+
resourceType: 'Task',
|
|
878
|
+
id: 'workflow-task-2',
|
|
879
|
+
status: 'requested',
|
|
880
|
+
meta: { author: createReference(DrAliceSmith) },
|
|
881
|
+
requester: createReference(DrAliceSmith),
|
|
882
|
+
input: [{ valueReference: createReference(ExampleWorkflowQuestionnaire2) }],
|
|
883
|
+
};
|
|
884
|
+
const ExampleWorkflowTask3 = {
|
|
885
|
+
resourceType: 'Task',
|
|
886
|
+
id: 'workflow-task-3',
|
|
887
|
+
status: 'requested',
|
|
888
|
+
meta: { author: createReference(DrAliceSmith) },
|
|
889
|
+
requester: createReference(DrAliceSmith),
|
|
890
|
+
input: [{ valueReference: createReference(ExampleWorkflowQuestionnaire3) }],
|
|
891
|
+
};
|
|
892
|
+
const ExampleWorkflowRequestGroup = {
|
|
893
|
+
resourceType: 'RequestGroup',
|
|
894
|
+
id: 'workflow-request-group-1',
|
|
895
|
+
instantiatesCanonical: [getReferenceString(ExampleWorkflowPlanDefinition)],
|
|
896
|
+
status: 'active',
|
|
897
|
+
action: [
|
|
898
|
+
{
|
|
899
|
+
title: ExampleWorkflowQuestionnaire1.title,
|
|
900
|
+
resource: createReference(ExampleWorkflowTask1),
|
|
901
|
+
},
|
|
902
|
+
{
|
|
903
|
+
title: ExampleWorkflowQuestionnaire2.title,
|
|
904
|
+
resource: createReference(ExampleWorkflowTask2),
|
|
905
|
+
},
|
|
906
|
+
{
|
|
907
|
+
title: ExampleWorkflowQuestionnaire3.title,
|
|
908
|
+
resource: createReference(ExampleWorkflowTask3),
|
|
909
|
+
},
|
|
910
|
+
],
|
|
911
|
+
};
|
|
912
|
+
|
|
785
913
|
var SearchParameterList = [
|
|
786
914
|
{
|
|
787
915
|
resourceType: "SearchParameter",
|
|
@@ -1034,6 +1162,15 @@ var SearchParameterList = [
|
|
|
1034
1162
|
}
|
|
1035
1163
|
];
|
|
1036
1164
|
|
|
1165
|
+
const ExampleSmartClientApplication = {
|
|
1166
|
+
resourceType: 'ClientApplication',
|
|
1167
|
+
id: 'smart-client-app',
|
|
1168
|
+
name: 'Inferno Client',
|
|
1169
|
+
description: 'Client application used for Inferno ONC compliance testing',
|
|
1170
|
+
redirectUri: 'https://inferno.healthit.gov/suites/custom/smart/redirect',
|
|
1171
|
+
launchUri: 'https://inferno.healthit.gov/suites/custom/smart/launch',
|
|
1172
|
+
};
|
|
1173
|
+
|
|
1037
1174
|
var StructureDefinitionList = [
|
|
1038
1175
|
{
|
|
1039
1176
|
resourceType: "StructureDefinition",
|
|
@@ -6009,7 +6146,8 @@ var StructureDefinitionList = [
|
|
|
6009
6146
|
path: "Observation.component.referenceRange",
|
|
6010
6147
|
min: 0,
|
|
6011
6148
|
max: "*"
|
|
6012
|
-
}
|
|
6149
|
+
},
|
|
6150
|
+
contentReference: "#Observation.referenceRange"
|
|
6013
6151
|
}
|
|
6014
6152
|
]
|
|
6015
6153
|
}
|
|
@@ -9622,7 +9760,8 @@ var StructureDefinitionList = [
|
|
|
9622
9760
|
path: "PlanDefinition.action.action",
|
|
9623
9761
|
min: 0,
|
|
9624
9762
|
max: "*"
|
|
9625
|
-
}
|
|
9763
|
+
},
|
|
9764
|
+
contentReference: "#PlanDefinition.action"
|
|
9626
9765
|
}
|
|
9627
9766
|
]
|
|
9628
9767
|
}
|
|
@@ -11176,7 +11315,8 @@ var StructureDefinitionList = [
|
|
|
11176
11315
|
path: "Questionnaire.item.item",
|
|
11177
11316
|
min: 0,
|
|
11178
11317
|
max: "*"
|
|
11179
|
-
}
|
|
11318
|
+
},
|
|
11319
|
+
contentReference: "#Questionnaire.item"
|
|
11180
11320
|
}
|
|
11181
11321
|
]
|
|
11182
11322
|
}
|
|
@@ -11755,7 +11895,8 @@ var StructureDefinitionList = [
|
|
|
11755
11895
|
path: "QuestionnaireResponse.item.answer.item",
|
|
11756
11896
|
min: 0,
|
|
11757
11897
|
max: "*"
|
|
11758
|
-
}
|
|
11898
|
+
},
|
|
11899
|
+
contentReference: "#QuestionnaireResponse.item"
|
|
11759
11900
|
},
|
|
11760
11901
|
{
|
|
11761
11902
|
id: "QuestionnaireResponse.item.item",
|
|
@@ -11766,7 +11907,8 @@ var StructureDefinitionList = [
|
|
|
11766
11907
|
path: "QuestionnaireResponse.item.item",
|
|
11767
11908
|
min: 0,
|
|
11768
11909
|
max: "*"
|
|
11769
|
-
}
|
|
11910
|
+
},
|
|
11911
|
+
contentReference: "#QuestionnaireResponse.item"
|
|
11770
11912
|
}
|
|
11771
11913
|
]
|
|
11772
11914
|
}
|
|
@@ -15998,6 +16140,11 @@ var StructureDefinitionList = [
|
|
|
15998
16140
|
path: "Project.id",
|
|
15999
16141
|
min: 0,
|
|
16000
16142
|
max: "1",
|
|
16143
|
+
base: {
|
|
16144
|
+
path: "Resource.id",
|
|
16145
|
+
min: 0,
|
|
16146
|
+
max: "1"
|
|
16147
|
+
},
|
|
16001
16148
|
type: [
|
|
16002
16149
|
{
|
|
16003
16150
|
code: "string"
|
|
@@ -16009,6 +16156,11 @@ var StructureDefinitionList = [
|
|
|
16009
16156
|
path: "Project.meta",
|
|
16010
16157
|
min: 0,
|
|
16011
16158
|
max: "1",
|
|
16159
|
+
base: {
|
|
16160
|
+
path: "Resource.meta",
|
|
16161
|
+
min: 0,
|
|
16162
|
+
max: "1"
|
|
16163
|
+
},
|
|
16012
16164
|
type: [
|
|
16013
16165
|
{
|
|
16014
16166
|
code: "Meta"
|
|
@@ -16020,6 +16172,11 @@ var StructureDefinitionList = [
|
|
|
16020
16172
|
path: "Project.implicitRules",
|
|
16021
16173
|
min: 0,
|
|
16022
16174
|
max: "1",
|
|
16175
|
+
base: {
|
|
16176
|
+
path: "Resource.implicitRules",
|
|
16177
|
+
min: 0,
|
|
16178
|
+
max: "1"
|
|
16179
|
+
},
|
|
16023
16180
|
type: [
|
|
16024
16181
|
{
|
|
16025
16182
|
code: "uri"
|
|
@@ -16031,6 +16188,11 @@ var StructureDefinitionList = [
|
|
|
16031
16188
|
path: "Project.language",
|
|
16032
16189
|
min: 0,
|
|
16033
16190
|
max: "1",
|
|
16191
|
+
base: {
|
|
16192
|
+
path: "Resource.language",
|
|
16193
|
+
min: 0,
|
|
16194
|
+
max: "1"
|
|
16195
|
+
},
|
|
16034
16196
|
type: [
|
|
16035
16197
|
{
|
|
16036
16198
|
code: "code"
|
|
@@ -16081,6 +16243,17 @@ var StructureDefinitionList = [
|
|
|
16081
16243
|
}
|
|
16082
16244
|
]
|
|
16083
16245
|
},
|
|
16246
|
+
{
|
|
16247
|
+
id: "Project.checkReferencesOnWrite",
|
|
16248
|
+
path: "Project.checkReferencesOnWrite",
|
|
16249
|
+
min: 0,
|
|
16250
|
+
max: "1",
|
|
16251
|
+
type: [
|
|
16252
|
+
{
|
|
16253
|
+
code: "boolean"
|
|
16254
|
+
}
|
|
16255
|
+
]
|
|
16256
|
+
},
|
|
16084
16257
|
{
|
|
16085
16258
|
id: "Project.owner",
|
|
16086
16259
|
path: "Project.owner",
|
|
@@ -16260,6 +16433,11 @@ var StructureDefinitionList = [
|
|
|
16260
16433
|
path: "Bot.id",
|
|
16261
16434
|
min: 0,
|
|
16262
16435
|
max: "1",
|
|
16436
|
+
base: {
|
|
16437
|
+
path: "Resource.id",
|
|
16438
|
+
min: 0,
|
|
16439
|
+
max: "1"
|
|
16440
|
+
},
|
|
16263
16441
|
type: [
|
|
16264
16442
|
{
|
|
16265
16443
|
code: "string"
|
|
@@ -16271,6 +16449,11 @@ var StructureDefinitionList = [
|
|
|
16271
16449
|
path: "Bot.meta",
|
|
16272
16450
|
min: 0,
|
|
16273
16451
|
max: "1",
|
|
16452
|
+
base: {
|
|
16453
|
+
path: "Resource.meta",
|
|
16454
|
+
min: 0,
|
|
16455
|
+
max: "1"
|
|
16456
|
+
},
|
|
16274
16457
|
type: [
|
|
16275
16458
|
{
|
|
16276
16459
|
code: "Meta"
|
|
@@ -16282,6 +16465,11 @@ var StructureDefinitionList = [
|
|
|
16282
16465
|
path: "Bot.implicitRules",
|
|
16283
16466
|
min: 0,
|
|
16284
16467
|
max: "1",
|
|
16468
|
+
base: {
|
|
16469
|
+
path: "Resource.implicitRules",
|
|
16470
|
+
min: 0,
|
|
16471
|
+
max: "1"
|
|
16472
|
+
},
|
|
16285
16473
|
type: [
|
|
16286
16474
|
{
|
|
16287
16475
|
code: "uri"
|
|
@@ -16293,6 +16481,11 @@ var StructureDefinitionList = [
|
|
|
16293
16481
|
path: "Bot.language",
|
|
16294
16482
|
min: 0,
|
|
16295
16483
|
max: "1",
|
|
16484
|
+
base: {
|
|
16485
|
+
path: "Resource.language",
|
|
16486
|
+
min: 0,
|
|
16487
|
+
max: "1"
|
|
16488
|
+
},
|
|
16296
16489
|
type: [
|
|
16297
16490
|
{
|
|
16298
16491
|
code: "code"
|
|
@@ -16370,303 +16563,22 @@ var StructureDefinitionList = [
|
|
|
16370
16563
|
}
|
|
16371
16564
|
];
|
|
16372
16565
|
|
|
16373
|
-
const GraphQLSchemaResponse = {
|
|
16374
|
-
data: {
|
|
16375
|
-
StructureDefinitionList,
|
|
16376
|
-
SearchParameterList,
|
|
16377
|
-
},
|
|
16378
|
-
};
|
|
16379
|
-
|
|
16380
|
-
const exampleValueSet = {
|
|
16381
|
-
resourceType: 'ValueSet',
|
|
16382
|
-
expansion: {
|
|
16383
|
-
contains: [
|
|
16384
|
-
{
|
|
16385
|
-
system: 'x',
|
|
16386
|
-
code: 'test-code',
|
|
16387
|
-
display: 'Test Display',
|
|
16388
|
-
},
|
|
16389
|
-
],
|
|
16390
|
-
},
|
|
16391
|
-
};
|
|
16392
|
-
|
|
16393
|
-
const ExampleWorkflowQuestionnaire1 = {
|
|
16394
|
-
resourceType: 'Questionnaire',
|
|
16395
|
-
id: 'workflow-questionnaire-1',
|
|
16396
|
-
name: 'Patient Registration',
|
|
16397
|
-
title: 'Patient Registration',
|
|
16398
|
-
subjectType: ['Patient'],
|
|
16399
|
-
item: [
|
|
16400
|
-
{
|
|
16401
|
-
linkId: '1',
|
|
16402
|
-
text: 'First question',
|
|
16403
|
-
type: 'string',
|
|
16404
|
-
},
|
|
16405
|
-
],
|
|
16406
|
-
};
|
|
16407
|
-
const ExampleWorkflowQuestionnaire2 = {
|
|
16408
|
-
resourceType: 'Questionnaire',
|
|
16409
|
-
id: 'workflow-questionnaire-2',
|
|
16410
|
-
name: 'Surgery History',
|
|
16411
|
-
title: 'Surgery History',
|
|
16412
|
-
subjectType: ['Patient'],
|
|
16413
|
-
item: [
|
|
16414
|
-
{
|
|
16415
|
-
linkId: '1',
|
|
16416
|
-
text: 'First question',
|
|
16417
|
-
type: 'string',
|
|
16418
|
-
},
|
|
16419
|
-
],
|
|
16420
|
-
};
|
|
16421
|
-
const ExampleWorkflowQuestionnaire3 = {
|
|
16422
|
-
resourceType: 'Questionnaire',
|
|
16423
|
-
id: 'workflow-questionnaire-3',
|
|
16424
|
-
name: 'Family Health History',
|
|
16425
|
-
title: 'Family Health History',
|
|
16426
|
-
subjectType: ['Patient'],
|
|
16427
|
-
item: [
|
|
16428
|
-
{
|
|
16429
|
-
linkId: '1',
|
|
16430
|
-
text: 'First question',
|
|
16431
|
-
type: 'string',
|
|
16432
|
-
},
|
|
16433
|
-
],
|
|
16434
|
-
};
|
|
16435
|
-
const ExampleWorkflowPlanDefinition = {
|
|
16436
|
-
resourceType: 'PlanDefinition',
|
|
16437
|
-
id: 'workflow-plan-definition-1',
|
|
16438
|
-
title: 'Example Plan Definition',
|
|
16439
|
-
action: [
|
|
16440
|
-
{
|
|
16441
|
-
title: ExampleWorkflowQuestionnaire1.title,
|
|
16442
|
-
definitionCanonical: getReferenceString(ExampleWorkflowQuestionnaire1),
|
|
16443
|
-
},
|
|
16444
|
-
{
|
|
16445
|
-
title: ExampleWorkflowQuestionnaire2.title,
|
|
16446
|
-
definitionCanonical: getReferenceString(ExampleWorkflowQuestionnaire2),
|
|
16447
|
-
},
|
|
16448
|
-
{
|
|
16449
|
-
title: ExampleWorkflowQuestionnaire3.title,
|
|
16450
|
-
definitionCanonical: getReferenceString(ExampleWorkflowQuestionnaire3),
|
|
16451
|
-
},
|
|
16452
|
-
],
|
|
16453
|
-
};
|
|
16454
|
-
const ExampleWorkflowQuestionnaireResponse1 = {
|
|
16455
|
-
resourceType: 'QuestionnaireResponse',
|
|
16456
|
-
id: 'workflow-questionnaire-response-1',
|
|
16457
|
-
questionnaire: getReferenceString(ExampleWorkflowQuestionnaire1),
|
|
16458
|
-
subject: createReference(HomerSimpson),
|
|
16459
|
-
source: createReference(HomerSimpson),
|
|
16460
|
-
};
|
|
16461
|
-
// Based on: http://build.fhir.org/ig/HL7/sdc/Task-example.json.html
|
|
16462
|
-
const ExampleWorkflowTask1 = {
|
|
16463
|
-
resourceType: 'Task',
|
|
16464
|
-
id: 'workflow-task-1',
|
|
16465
|
-
status: 'completed',
|
|
16466
|
-
meta: { author: createReference(HomerSimpson) },
|
|
16467
|
-
requester: createReference(DrAliceSmith),
|
|
16468
|
-
input: [{ valueReference: createReference(ExampleWorkflowQuestionnaire1) }],
|
|
16469
|
-
output: [{ valueReference: createReference(ExampleWorkflowQuestionnaireResponse1) }],
|
|
16470
|
-
};
|
|
16471
|
-
const ExampleWorkflowTask2 = {
|
|
16472
|
-
resourceType: 'Task',
|
|
16473
|
-
id: 'workflow-task-2',
|
|
16474
|
-
status: 'requested',
|
|
16475
|
-
meta: { author: createReference(DrAliceSmith) },
|
|
16476
|
-
requester: createReference(DrAliceSmith),
|
|
16477
|
-
input: [{ valueReference: createReference(ExampleWorkflowQuestionnaire2) }],
|
|
16478
|
-
};
|
|
16479
|
-
const ExampleWorkflowTask3 = {
|
|
16480
|
-
resourceType: 'Task',
|
|
16481
|
-
id: 'workflow-task-3',
|
|
16482
|
-
status: 'requested',
|
|
16483
|
-
meta: { author: createReference(DrAliceSmith) },
|
|
16484
|
-
requester: createReference(DrAliceSmith),
|
|
16485
|
-
input: [{ valueReference: createReference(ExampleWorkflowQuestionnaire3) }],
|
|
16486
|
-
};
|
|
16487
|
-
const ExampleWorkflowRequestGroup = {
|
|
16488
|
-
resourceType: 'RequestGroup',
|
|
16489
|
-
id: 'workflow-request-group-1',
|
|
16490
|
-
instantiatesCanonical: [getReferenceString(ExampleWorkflowPlanDefinition)],
|
|
16491
|
-
status: 'active',
|
|
16492
|
-
action: [
|
|
16493
|
-
{
|
|
16494
|
-
title: ExampleWorkflowQuestionnaire1.title,
|
|
16495
|
-
resource: createReference(ExampleWorkflowTask1),
|
|
16496
|
-
},
|
|
16497
|
-
{
|
|
16498
|
-
title: ExampleWorkflowQuestionnaire2.title,
|
|
16499
|
-
resource: createReference(ExampleWorkflowTask2),
|
|
16500
|
-
},
|
|
16501
|
-
{
|
|
16502
|
-
title: ExampleWorkflowQuestionnaire3.title,
|
|
16503
|
-
resource: createReference(ExampleWorkflowTask3),
|
|
16504
|
-
},
|
|
16505
|
-
],
|
|
16506
|
-
};
|
|
16507
|
-
|
|
16508
|
-
const ExampleSmartClientApplication = {
|
|
16509
|
-
resourceType: 'ClientApplication',
|
|
16510
|
-
id: 'smart-client-app',
|
|
16511
|
-
name: 'Inferno Client',
|
|
16512
|
-
description: 'Client application used for Inferno ONC compliance testing',
|
|
16513
|
-
redirectUri: 'https://inferno.healthit.gov/suites/custom/smart/redirect',
|
|
16514
|
-
launchUri: 'https://inferno.healthit.gov/suites/custom/smart/launch',
|
|
16515
|
-
};
|
|
16516
|
-
|
|
16517
|
-
/******************************************************************************
|
|
16518
|
-
Copyright (c) Microsoft Corporation.
|
|
16519
|
-
|
|
16520
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
16521
|
-
purpose with or without fee is hereby granted.
|
|
16522
|
-
|
|
16523
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
16524
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
16525
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16526
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
16527
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
16528
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
16529
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
16530
|
-
***************************************************************************** */
|
|
16531
|
-
|
|
16532
|
-
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
16533
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
16534
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
16535
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
16536
|
-
}
|
|
16537
|
-
|
|
16538
|
-
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
16539
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
16540
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
16541
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
16542
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16543
|
-
}
|
|
16544
|
-
|
|
16545
|
-
var _MemoryRepository_resources, _MemoryRepository_history;
|
|
16546
|
-
class MemoryRepository {
|
|
16547
|
-
constructor() {
|
|
16548
|
-
_MemoryRepository_resources.set(this, void 0);
|
|
16549
|
-
_MemoryRepository_history.set(this, void 0);
|
|
16550
|
-
__classPrivateFieldSet(this, _MemoryRepository_resources, {}, "f");
|
|
16551
|
-
__classPrivateFieldSet(this, _MemoryRepository_history, {}, "f");
|
|
16552
|
-
}
|
|
16553
|
-
createResource(resource) {
|
|
16554
|
-
const result = deepClone(resource);
|
|
16555
|
-
if (!result.id) {
|
|
16556
|
-
result.id = this.generateId();
|
|
16557
|
-
}
|
|
16558
|
-
if (!result.meta) {
|
|
16559
|
-
result.meta = {};
|
|
16560
|
-
}
|
|
16561
|
-
if (!result.meta?.versionId) {
|
|
16562
|
-
result.meta.versionId = this.generateId();
|
|
16563
|
-
}
|
|
16564
|
-
if (!result.meta?.lastUpdated) {
|
|
16565
|
-
result.meta.lastUpdated = new Date().toISOString();
|
|
16566
|
-
}
|
|
16567
|
-
const { resourceType, id } = result;
|
|
16568
|
-
if (!(resourceType in __classPrivateFieldGet(this, _MemoryRepository_resources, "f"))) {
|
|
16569
|
-
__classPrivateFieldGet(this, _MemoryRepository_resources, "f")[resourceType] = {};
|
|
16570
|
-
}
|
|
16571
|
-
if (!(resourceType in __classPrivateFieldGet(this, _MemoryRepository_history, "f"))) {
|
|
16572
|
-
__classPrivateFieldGet(this, _MemoryRepository_history, "f")[resourceType] = {};
|
|
16573
|
-
}
|
|
16574
|
-
if (!(id in __classPrivateFieldGet(this, _MemoryRepository_history, "f")[resourceType])) {
|
|
16575
|
-
__classPrivateFieldGet(this, _MemoryRepository_history, "f")[resourceType][id] = [];
|
|
16576
|
-
}
|
|
16577
|
-
__classPrivateFieldGet(this, _MemoryRepository_resources, "f")[resourceType][id] = result;
|
|
16578
|
-
__classPrivateFieldGet(this, _MemoryRepository_history, "f")[resourceType][id].push(result);
|
|
16579
|
-
return deepClone(result);
|
|
16580
|
-
}
|
|
16581
|
-
updateResource(resource) {
|
|
16582
|
-
const result = JSON.parse(JSON.stringify(resource));
|
|
16583
|
-
if (result.meta) {
|
|
16584
|
-
if (result.meta.versionId) {
|
|
16585
|
-
delete result.meta.versionId;
|
|
16586
|
-
}
|
|
16587
|
-
if (result.meta.lastUpdated) {
|
|
16588
|
-
delete result.meta.lastUpdated;
|
|
16589
|
-
}
|
|
16590
|
-
}
|
|
16591
|
-
return this.createResource(result);
|
|
16592
|
-
}
|
|
16593
|
-
async patchResource(resourceType, id, patch) {
|
|
16594
|
-
const resource = this.readResource(resourceType, id);
|
|
16595
|
-
const patchErrors = applyPatch(resource, patch);
|
|
16596
|
-
for (const error of patchErrors) {
|
|
16597
|
-
if (error) {
|
|
16598
|
-
const message = error.message?.split('\n')?.[0] || 'JSONPatch error';
|
|
16599
|
-
throw badRequest(message);
|
|
16600
|
-
}
|
|
16601
|
-
}
|
|
16602
|
-
return this.updateResource(resource);
|
|
16603
|
-
}
|
|
16604
|
-
readResource(resourceType, id) {
|
|
16605
|
-
const resource = __classPrivateFieldGet(this, _MemoryRepository_resources, "f")?.[resourceType]?.[id];
|
|
16606
|
-
if (!resource) {
|
|
16607
|
-
throw notFound;
|
|
16608
|
-
}
|
|
16609
|
-
return deepClone(resource);
|
|
16610
|
-
}
|
|
16611
|
-
readHistory(resourceType, id) {
|
|
16612
|
-
this.readResource(resourceType, id);
|
|
16613
|
-
return {
|
|
16614
|
-
resourceType: 'Bundle',
|
|
16615
|
-
type: 'history',
|
|
16616
|
-
entry: (__classPrivateFieldGet(this, _MemoryRepository_history, "f")?.[resourceType]?.[id] ?? [])
|
|
16617
|
-
.reverse()
|
|
16618
|
-
.map((version) => ({ resource: deepClone(version) })),
|
|
16619
|
-
};
|
|
16620
|
-
}
|
|
16621
|
-
readVersion(resourceType, id, versionId) {
|
|
16622
|
-
this.readResource(resourceType, id);
|
|
16623
|
-
const version = __classPrivateFieldGet(this, _MemoryRepository_history, "f")?.[resourceType]?.[id]?.find((v) => v.meta?.versionId === versionId);
|
|
16624
|
-
if (!version) {
|
|
16625
|
-
throw notFound;
|
|
16626
|
-
}
|
|
16627
|
-
return deepClone(version);
|
|
16628
|
-
}
|
|
16629
|
-
search(searchRequest) {
|
|
16630
|
-
const { resourceType } = searchRequest;
|
|
16631
|
-
const resources = __classPrivateFieldGet(this, _MemoryRepository_resources, "f")[resourceType] ?? {};
|
|
16632
|
-
const result = Object.values(resources).filter((resource) => matchesSearchRequest(resource, searchRequest));
|
|
16633
|
-
return {
|
|
16634
|
-
resourceType: 'Bundle',
|
|
16635
|
-
type: 'searchset',
|
|
16636
|
-
entry: result.map((resource) => ({ resource: deepClone(resource) })),
|
|
16637
|
-
total: result.length,
|
|
16638
|
-
};
|
|
16639
|
-
}
|
|
16640
|
-
deleteResource(resourceType, id) {
|
|
16641
|
-
if (__classPrivateFieldGet(this, _MemoryRepository_resources, "f")?.[resourceType]?.[id]) {
|
|
16642
|
-
delete __classPrivateFieldGet(this, _MemoryRepository_resources, "f")[resourceType][id];
|
|
16643
|
-
}
|
|
16644
|
-
}
|
|
16645
|
-
generateId() {
|
|
16646
|
-
// Cross platform random UUID generator
|
|
16647
|
-
// Note that this is not intended for production use, but rather for testing
|
|
16648
|
-
// This should be replaced when crypto.randomUUID is fully supported
|
|
16649
|
-
// https://stackoverflow.com/revisions/2117523/28
|
|
16650
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
16651
|
-
const r = (Math.random() * 16) | 0;
|
|
16652
|
-
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
16653
|
-
return v.toString(16);
|
|
16654
|
-
});
|
|
16655
|
-
}
|
|
16656
|
-
}
|
|
16657
|
-
_MemoryRepository_resources = new WeakMap(), _MemoryRepository_history = new WeakMap();
|
|
16658
|
-
|
|
16659
16566
|
class MockClient extends MedplumClient {
|
|
16660
16567
|
constructor(clientOptions) {
|
|
16661
|
-
const
|
|
16568
|
+
const router = new FhirRouter();
|
|
16569
|
+
const repo = new MemoryRepository();
|
|
16570
|
+
const client = new MockFetchClient(router, repo, clientOptions?.debug);
|
|
16662
16571
|
super({
|
|
16663
16572
|
baseUrl: 'https://example.com/',
|
|
16664
16573
|
clientId: 'my-client-id',
|
|
16665
|
-
createPdf: (docDefinition, tableLayouts, fonts) =>
|
|
16574
|
+
createPdf: (docDefinition, tableLayouts, fonts) => client.mockCreatePdf(docDefinition, tableLayouts, fonts),
|
|
16666
16575
|
fetch: (url, options) => {
|
|
16667
|
-
return
|
|
16576
|
+
return client.mockFetch(url, options);
|
|
16668
16577
|
},
|
|
16669
16578
|
});
|
|
16579
|
+
this.router = router;
|
|
16580
|
+
this.repo = repo;
|
|
16581
|
+
this.client = client;
|
|
16670
16582
|
this.debug = !!clientOptions?.debug;
|
|
16671
16583
|
}
|
|
16672
16584
|
clear() {
|
|
@@ -16724,12 +16636,20 @@ class MockClient extends MedplumClient {
|
|
|
16724
16636
|
}
|
|
16725
16637
|
}
|
|
16726
16638
|
class MockFetchClient {
|
|
16727
|
-
constructor(debug = false) {
|
|
16639
|
+
constructor(router, repo, debug = false) {
|
|
16728
16640
|
this.debug = debug;
|
|
16729
|
-
this.
|
|
16730
|
-
this.
|
|
16641
|
+
this.initialized = false;
|
|
16642
|
+
this.router = router;
|
|
16643
|
+
this.repo = new MemoryRepository();
|
|
16731
16644
|
}
|
|
16732
16645
|
async mockFetch(url, options) {
|
|
16646
|
+
if (!this.initialized) {
|
|
16647
|
+
if (!this.initPromise) {
|
|
16648
|
+
this.initPromise = this.initMockRepo();
|
|
16649
|
+
}
|
|
16650
|
+
await this.initPromise;
|
|
16651
|
+
this.initialized = true;
|
|
16652
|
+
}
|
|
16733
16653
|
const method = options.method || 'GET';
|
|
16734
16654
|
const path = url.replace('https://example.com/', '');
|
|
16735
16655
|
if (this.debug) {
|
|
@@ -16965,179 +16885,93 @@ class MockFetchClient {
|
|
|
16965
16885
|
}
|
|
16966
16886
|
return null;
|
|
16967
16887
|
}
|
|
16968
|
-
initMockRepo() {
|
|
16969
|
-
|
|
16970
|
-
|
|
16971
|
-
|
|
16972
|
-
|
|
16973
|
-
|
|
16974
|
-
|
|
16975
|
-
|
|
16976
|
-
|
|
16977
|
-
|
|
16978
|
-
|
|
16979
|
-
|
|
16980
|
-
|
|
16981
|
-
|
|
16982
|
-
|
|
16983
|
-
|
|
16984
|
-
|
|
16985
|
-
|
|
16986
|
-
|
|
16987
|
-
|
|
16988
|
-
|
|
16989
|
-
|
|
16990
|
-
|
|
16991
|
-
|
|
16992
|
-
|
|
16993
|
-
|
|
16994
|
-
|
|
16995
|
-
|
|
16996
|
-
|
|
16997
|
-
|
|
16998
|
-
|
|
16999
|
-
|
|
17000
|
-
|
|
17001
|
-
|
|
17002
|
-
|
|
17003
|
-
|
|
17004
|
-
|
|
17005
|
-
|
|
17006
|
-
|
|
17007
|
-
|
|
17008
|
-
|
|
17009
|
-
|
|
17010
|
-
|
|
17011
|
-
|
|
17012
|
-
|
|
17013
|
-
const match = /fhir\/R4\/?([^/]+)?\/?([^/]+)?\/?([^/]+)?\/?([^/]+)?/.exec(path);
|
|
17014
|
-
const resourceType = match?.[1];
|
|
17015
|
-
const id = match?.[2];
|
|
17016
|
-
const operation = match?.[3];
|
|
17017
|
-
const versionId = match?.[4];
|
|
17018
|
-
if (path.startsWith('fhir/R4/ValueSet/$expand')) {
|
|
17019
|
-
return exampleValueSet;
|
|
16888
|
+
async initMockRepo() {
|
|
16889
|
+
const defaultResources = [
|
|
16890
|
+
HomerSimpsonPreviousVersion,
|
|
16891
|
+
HomerSimpson,
|
|
16892
|
+
ExampleAccessPolicy,
|
|
16893
|
+
ExampleStatusValueSet,
|
|
16894
|
+
ExampleUserConfiguration,
|
|
16895
|
+
ExampleBot,
|
|
16896
|
+
ExampleClient,
|
|
16897
|
+
HomerDiagnosticReport,
|
|
16898
|
+
HomerEncounter,
|
|
16899
|
+
HomerCommunication,
|
|
16900
|
+
HomerMedia,
|
|
16901
|
+
HomerObservation1,
|
|
16902
|
+
HomerObservation2,
|
|
16903
|
+
HomerObservation3,
|
|
16904
|
+
HomerObservation4,
|
|
16905
|
+
HomerObservation5,
|
|
16906
|
+
HomerObservation6,
|
|
16907
|
+
HomerObservation7,
|
|
16908
|
+
HomerObservation8,
|
|
16909
|
+
HomerSimpsonSpecimen,
|
|
16910
|
+
TestOrganization,
|
|
16911
|
+
DifferentOrganization,
|
|
16912
|
+
ExampleQuestionnaire,
|
|
16913
|
+
ExampleQuestionnaireResponse,
|
|
16914
|
+
HomerServiceRequest,
|
|
16915
|
+
ExampleSubscription,
|
|
16916
|
+
BartSimpson,
|
|
16917
|
+
DrAliceSmithPreviousVersion,
|
|
16918
|
+
DrAliceSmith,
|
|
16919
|
+
DrAliceSmithSchedule,
|
|
16920
|
+
ExampleWorkflowQuestionnaire1,
|
|
16921
|
+
ExampleWorkflowQuestionnaire2,
|
|
16922
|
+
ExampleWorkflowQuestionnaire3,
|
|
16923
|
+
ExampleWorkflowPlanDefinition,
|
|
16924
|
+
ExampleWorkflowQuestionnaireResponse1,
|
|
16925
|
+
ExampleWorkflowTask1,
|
|
16926
|
+
ExampleWorkflowTask2,
|
|
16927
|
+
ExampleWorkflowTask3,
|
|
16928
|
+
ExampleWorkflowRequestGroup,
|
|
16929
|
+
ExampleSmartClientApplication,
|
|
16930
|
+
];
|
|
16931
|
+
for (const resource of defaultResources) {
|
|
16932
|
+
await this.repo.createResource(resource);
|
|
17020
16933
|
}
|
|
17021
|
-
|
|
17022
|
-
|
|
16934
|
+
for (const structureDefinition of StructureDefinitionList) {
|
|
16935
|
+
indexStructureDefinition(structureDefinition);
|
|
16936
|
+
await this.repo.createResource(structureDefinition);
|
|
17023
16937
|
}
|
|
17024
|
-
|
|
17025
|
-
|
|
16938
|
+
for (const searchParameter of SearchParameterList) {
|
|
16939
|
+
await this.repo.createResource(searchParameter);
|
|
17026
16940
|
}
|
|
17027
|
-
|
|
17028
|
-
if (resourceType && id && operation) {
|
|
17029
|
-
return allOk;
|
|
17030
|
-
}
|
|
17031
|
-
else if (resourceType) {
|
|
17032
|
-
return this.mockRepo.createResource(JSON.parse(options.body));
|
|
17033
|
-
}
|
|
17034
|
-
else {
|
|
17035
|
-
return this.mockFhirBatchHandler(method, path, options);
|
|
17036
|
-
}
|
|
17037
|
-
}
|
|
17038
|
-
else if (method === 'GET') {
|
|
17039
|
-
if (resourceType && id && versionId) {
|
|
17040
|
-
return this.mockRepo.readVersion(resourceType, id, versionId);
|
|
17041
|
-
}
|
|
17042
|
-
else if (resourceType && id && operation === '_history') {
|
|
17043
|
-
return this.mockRepo.readHistory(resourceType, id);
|
|
17044
|
-
}
|
|
17045
|
-
else if (resourceType && id === '$csv') {
|
|
17046
|
-
return allOk;
|
|
17047
|
-
}
|
|
17048
|
-
else if (resourceType && id) {
|
|
17049
|
-
return this.mockRepo.readResource(resourceType, id);
|
|
17050
|
-
}
|
|
17051
|
-
else if (resourceType) {
|
|
17052
|
-
return this.mockRepo.search(parseSearchDefinition(url));
|
|
17053
|
-
}
|
|
17054
|
-
}
|
|
17055
|
-
else if (method === 'PUT') {
|
|
17056
|
-
return this.mockRepo.updateResource(JSON.parse(options.body));
|
|
17057
|
-
}
|
|
17058
|
-
else if (method === 'PATCH') {
|
|
17059
|
-
if (resourceType && id) {
|
|
17060
|
-
return this.mockRepo.patchResource(resourceType, id, JSON.parse(options.body));
|
|
17061
|
-
}
|
|
17062
|
-
}
|
|
17063
|
-
else if (method === 'DELETE') {
|
|
17064
|
-
if (resourceType && id) {
|
|
17065
|
-
this.mockRepo.deleteResource(resourceType, id);
|
|
17066
|
-
return allOk;
|
|
17067
|
-
}
|
|
17068
|
-
}
|
|
17069
|
-
throw notFound;
|
|
16941
|
+
DrAliceSmithSlots.forEach((slot) => this.repo.createResource(slot));
|
|
17070
16942
|
}
|
|
17071
|
-
|
|
17072
|
-
|
|
17073
|
-
|
|
17074
|
-
return {
|
|
17075
|
-
data: {
|
|
17076
|
-
ResourceList: [
|
|
17077
|
-
{
|
|
17078
|
-
...HomerServiceRequest,
|
|
17079
|
-
ObservationList: [
|
|
17080
|
-
HomerObservation1,
|
|
17081
|
-
HomerObservation2,
|
|
17082
|
-
HomerObservation3,
|
|
17083
|
-
HomerObservation4,
|
|
17084
|
-
HomerObservation5,
|
|
17085
|
-
HomerObservation6,
|
|
17086
|
-
],
|
|
17087
|
-
},
|
|
17088
|
-
],
|
|
17089
|
-
},
|
|
17090
|
-
};
|
|
16943
|
+
async mockFhirHandler(method, url, options) {
|
|
16944
|
+
if (url.startsWith('fhir/R4/ValueSet/$expand')) {
|
|
16945
|
+
return exampleValueSet;
|
|
17091
16946
|
}
|
|
17092
|
-
|
|
17093
|
-
|
|
17094
|
-
|
|
17095
|
-
|
|
17096
|
-
const request = JSON.parse(body);
|
|
17097
|
-
let entry;
|
|
17098
|
-
if (request.entry) {
|
|
17099
|
-
entry = [];
|
|
17100
|
-
for (const input of request.entry) {
|
|
17101
|
-
entry.push(await this.handleBatchEntry(input));
|
|
17102
|
-
}
|
|
16947
|
+
const parsedUrl = new URL(url, 'https://example.com');
|
|
16948
|
+
let pathname = parsedUrl.pathname;
|
|
16949
|
+
if (pathname.includes('fhir/R4')) {
|
|
16950
|
+
pathname = pathname.substring(pathname.indexOf('fhir/R4') + 7);
|
|
17103
16951
|
}
|
|
17104
|
-
|
|
17105
|
-
|
|
17106
|
-
|
|
17107
|
-
|
|
16952
|
+
let body = undefined;
|
|
16953
|
+
if (options.body) {
|
|
16954
|
+
body = JSON.parse(options.body);
|
|
16955
|
+
}
|
|
16956
|
+
const request = {
|
|
16957
|
+
method,
|
|
16958
|
+
pathname,
|
|
16959
|
+
body,
|
|
16960
|
+
params: Object.create(null),
|
|
16961
|
+
query: Object.fromEntries(parsedUrl.searchParams),
|
|
17108
16962
|
};
|
|
17109
|
-
|
|
17110
|
-
|
|
17111
|
-
|
|
17112
|
-
|
|
17113
|
-
const method = input.request?.method;
|
|
17114
|
-
const resource = await this.mockHandler(method, url, {
|
|
17115
|
-
body: input.resource ? JSON.stringify(input.resource) : undefined,
|
|
17116
|
-
});
|
|
17117
|
-
if (resource?.resourceType === 'OperationOutcome') {
|
|
17118
|
-
return {
|
|
17119
|
-
resource,
|
|
17120
|
-
response: { status: getStatus(resource).toString() },
|
|
17121
|
-
};
|
|
17122
|
-
}
|
|
17123
|
-
else if (resource) {
|
|
17124
|
-
return { resource, response: { status: '200' } };
|
|
17125
|
-
}
|
|
17126
|
-
else {
|
|
17127
|
-
return { resource: notFound, response: { status: '404' } };
|
|
16963
|
+
const result = await this.router.handleRequest(request, this.repo);
|
|
16964
|
+
if (result.length === 1) {
|
|
16965
|
+
if (!isOk(result[0])) {
|
|
16966
|
+
throw new OperationOutcomeError(result[0]);
|
|
17128
16967
|
}
|
|
16968
|
+
return result[0];
|
|
17129
16969
|
}
|
|
17130
|
-
|
|
17131
|
-
|
|
17132
|
-
return {
|
|
17133
|
-
response: {
|
|
17134
|
-
status: getStatus(outcome).toString(),
|
|
17135
|
-
outcome,
|
|
17136
|
-
},
|
|
17137
|
-
};
|
|
16970
|
+
else {
|
|
16971
|
+
return result[1];
|
|
17138
16972
|
}
|
|
17139
16973
|
}
|
|
17140
16974
|
}
|
|
17141
16975
|
|
|
17142
|
-
export { BartSimpson, DifferentOrganization, DrAliceSmith, DrAliceSmithPreviousVersion, DrAliceSmithSchedule, DrAliceSmithSlots, ExampleAccessPolicy, ExampleAuditEvent, ExampleBot, ExampleClient, ExampleQuestionnaire, ExampleQuestionnaireResponse, ExampleStatusValueSet, ExampleSubscription, ExampleUserConfiguration, ExampleWorkflowPlanDefinition, ExampleWorkflowQuestionnaire1, ExampleWorkflowQuestionnaire2, ExampleWorkflowQuestionnaire3, ExampleWorkflowQuestionnaireResponse1, ExampleWorkflowRequestGroup, ExampleWorkflowTask1, ExampleWorkflowTask2, ExampleWorkflowTask3,
|
|
16976
|
+
export { BartSimpson, DifferentOrganization, DrAliceSmith, DrAliceSmithPreviousVersion, DrAliceSmithSchedule, DrAliceSmithSlots, ExampleAccessPolicy, ExampleAuditEvent, ExampleBot, ExampleClient, ExampleQuestionnaire, ExampleQuestionnaireResponse, ExampleStatusValueSet, ExampleSubscription, ExampleUserConfiguration, ExampleWorkflowPlanDefinition, ExampleWorkflowQuestionnaire1, ExampleWorkflowQuestionnaire2, ExampleWorkflowQuestionnaire3, ExampleWorkflowQuestionnaireResponse1, ExampleWorkflowRequestGroup, ExampleWorkflowTask1, ExampleWorkflowTask2, ExampleWorkflowTask3, HomerBartRelatedPerson, HomerCommunication, HomerDiagnosticReport, HomerEncounter, HomerLisaRelatedPerson, HomerMedia, HomerObservation1, HomerObservation2, HomerObservation3, HomerObservation4, HomerObservation5, HomerObservation6, HomerObservation7, HomerObservation8, HomerServiceRequest, HomerSimpson, HomerSimpsonPreviousVersion, HomerSimpsonSpecimen, LisaSimpson, MargeSimpson, MockClient, SimpsonsFamily, TestOrganization, exampleValueSet };
|
|
17143
16977
|
//# sourceMappingURL=index.mjs.map
|