fhir-types 0.1.106

Generated per-version FHIR types and terminology operation contracts
Documentation
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
// @generated by fhir-codegen from hl7.fhir.r6.core 6.0.0-ballot5. DO NOT EDIT.
// Change the emitter (tools/fhir-codegen) and regenerate.
// SPDX-FileCopyrightText: Vernum Projecten B.V.
// SPDX-License-Identifier: Apache-2.0
//! The abstract `Resource` type as an enum over the root set.

/// A resource of the root set, or an unknown resource carried as JSON.
///
/// The abstract Resource type (<https://hl7.org/fhir/R6/resource.html>) as the
/// root set closes over it: one variant per root-set resource the enabled
/// features select, and UnknownResource for any other resource type met inside
/// a Bundle entry or a contained list.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Resource {
    /// A `Account` resource.
    #[cfg(feature = "resources")]
    Account(Box<super::account::Account>),
    /// A `ActivityDefinition` resource.
    #[cfg(feature = "resources")]
    ActivityDefinition(Box<super::activity_definition::ActivityDefinition>),
    /// A `ActorDefinition` resource.
    #[cfg(feature = "resources")]
    ActorDefinition(Box<super::actor_definition::ActorDefinition>),
    /// A `AdministrableProductDefinition` resource.
    #[cfg(feature = "resources")]
    AdministrableProductDefinition(
        Box<super::administrable_product_definition::AdministrableProductDefinition>,
    ),
    /// A `AdverseEvent` resource.
    #[cfg(feature = "resources")]
    AdverseEvent(Box<super::adverse_event::AdverseEvent>),
    /// A `AllergyIntolerance` resource.
    #[cfg(feature = "resources")]
    AllergyIntolerance(Box<super::allergy_intolerance::AllergyIntolerance>),
    /// A `Appointment` resource.
    #[cfg(feature = "resources")]
    Appointment(Box<super::appointment::Appointment>),
    /// A `AppointmentResponse` resource.
    #[cfg(feature = "resources")]
    AppointmentResponse(Box<super::appointment_response::AppointmentResponse>),
    /// A `ArtifactAssessment` resource.
    #[cfg(feature = "resources")]
    ArtifactAssessment(Box<super::artifact_assessment::ArtifactAssessment>),
    /// A `AuditEvent` resource.
    #[cfg(feature = "resources")]
    AuditEvent(Box<super::audit_event::AuditEvent>),
    /// A `Basic` resource.
    #[cfg(feature = "resources")]
    Basic(Box<super::basic::Basic>),
    /// A `Binary` resource.
    #[cfg(feature = "resources")]
    Binary(Box<super::binary::Binary>),
    /// A `BiologicallyDerivedProduct` resource.
    #[cfg(feature = "resources")]
    BiologicallyDerivedProduct(
        Box<super::biologically_derived_product::BiologicallyDerivedProduct>,
    ),
    /// A `BodyStructure` resource.
    #[cfg(feature = "resources")]
    BodyStructure(Box<super::body_structure::BodyStructure>),
    /// A `Bundle` resource.
    #[cfg(feature = "terminology")]
    Bundle(Box<super::bundle::Bundle>),
    /// A `CapabilityStatement` resource.
    #[cfg(feature = "terminology")]
    CapabilityStatement(Box<super::capability_statement::CapabilityStatement>),
    /// A `CarePlan` resource.
    #[cfg(feature = "resources")]
    CarePlan(Box<super::care_plan::CarePlan>),
    /// A `CareTeam` resource.
    #[cfg(feature = "resources")]
    CareTeam(Box<super::care_team::CareTeam>),
    /// A `Claim` resource.
    #[cfg(feature = "resources")]
    Claim(Box<super::claim::Claim>),
    /// A `ClaimResponse` resource.
    #[cfg(feature = "resources")]
    ClaimResponse(Box<super::claim_response::ClaimResponse>),
    /// A `ClinicalUseDefinition` resource.
    #[cfg(feature = "resources")]
    ClinicalUseDefinition(Box<super::clinical_use_definition::ClinicalUseDefinition>),
    /// A `CodeSystem` resource.
    #[cfg(feature = "terminology")]
    CodeSystem(Box<super::code_system::CodeSystem>),
    /// A `Communication` resource.
    #[cfg(feature = "resources")]
    Communication(Box<super::communication::Communication>),
    /// A `CommunicationRequest` resource.
    #[cfg(feature = "resources")]
    CommunicationRequest(Box<super::communication_request::CommunicationRequest>),
    /// A `CompartmentDefinition` resource.
    #[cfg(feature = "resources")]
    CompartmentDefinition(Box<super::compartment_definition::CompartmentDefinition>),
    /// A `Composition` resource.
    #[cfg(feature = "resources")]
    Composition(Box<super::composition::Composition>),
    /// A `ConceptMap` resource.
    #[cfg(feature = "terminology")]
    ConceptMap(Box<super::concept_map::ConceptMap>),
    /// A `Condition` resource.
    #[cfg(feature = "resources")]
    Condition(Box<super::condition::Condition>),
    /// A `Consent` resource.
    #[cfg(feature = "resources")]
    Consent(Box<super::consent::Consent>),
    /// A `Contract` resource.
    #[cfg(feature = "resources")]
    Contract(Box<super::contract::Contract>),
    /// A `Coverage` resource.
    #[cfg(feature = "resources")]
    Coverage(Box<super::coverage::Coverage>),
    /// A `CoverageEligibilityRequest` resource.
    #[cfg(feature = "resources")]
    CoverageEligibilityRequest(
        Box<super::coverage_eligibility_request::CoverageEligibilityRequest>,
    ),
    /// A `CoverageEligibilityResponse` resource.
    #[cfg(feature = "resources")]
    CoverageEligibilityResponse(
        Box<super::coverage_eligibility_response::CoverageEligibilityResponse>,
    ),
    /// A `DetectedIssue` resource.
    #[cfg(feature = "resources")]
    DetectedIssue(Box<super::detected_issue::DetectedIssue>),
    /// A `Device` resource.
    #[cfg(feature = "resources")]
    Device(Box<super::device::Device>),
    /// A `DeviceAlert` resource.
    #[cfg(feature = "resources")]
    DeviceAlert(Box<super::device_alert::DeviceAlert>),
    /// A `DeviceAssociation` resource.
    #[cfg(feature = "resources")]
    DeviceAssociation(Box<super::device_association::DeviceAssociation>),
    /// A `DeviceDefinition` resource.
    #[cfg(feature = "resources")]
    DeviceDefinition(Box<super::device_definition::DeviceDefinition>),
    /// A `DeviceMetric` resource.
    #[cfg(feature = "resources")]
    DeviceMetric(Box<super::device_metric::DeviceMetric>),
    /// A `DeviceRequest` resource.
    #[cfg(feature = "resources")]
    DeviceRequest(Box<super::device_request::DeviceRequest>),
    /// A `DiagnosticReport` resource.
    #[cfg(feature = "resources")]
    DiagnosticReport(Box<super::diagnostic_report::DiagnosticReport>),
    /// A `DocumentReference` resource.
    #[cfg(feature = "resources")]
    DocumentReference(Box<super::document_reference::DocumentReference>),
    /// A `Encounter` resource.
    #[cfg(feature = "resources")]
    Encounter(Box<super::encounter::Encounter>),
    /// A `Endpoint` resource.
    #[cfg(feature = "resources")]
    Endpoint(Box<super::endpoint::Endpoint>),
    /// A `EnrollmentRequest` resource.
    #[cfg(feature = "resources")]
    EnrollmentRequest(Box<super::enrollment_request::EnrollmentRequest>),
    /// A `EnrollmentResponse` resource.
    #[cfg(feature = "resources")]
    EnrollmentResponse(Box<super::enrollment_response::EnrollmentResponse>),
    /// A `EpisodeOfCare` resource.
    #[cfg(feature = "resources")]
    EpisodeOfCare(Box<super::episode_of_care::EpisodeOfCare>),
    /// A `EventDefinition` resource.
    #[cfg(feature = "resources")]
    EventDefinition(Box<super::event_definition::EventDefinition>),
    /// A `Evidence` resource.
    #[cfg(feature = "resources")]
    Evidence(Box<super::evidence::Evidence>),
    /// A `EvidenceVariable` resource.
    #[cfg(feature = "resources")]
    EvidenceVariable(Box<super::evidence_variable::EvidenceVariable>),
    /// A `ExampleScenario` resource.
    #[cfg(feature = "resources")]
    ExampleScenario(Box<super::example_scenario::ExampleScenario>),
    /// A `ExplanationOfBenefit` resource.
    #[cfg(feature = "resources")]
    ExplanationOfBenefit(Box<super::explanation_of_benefit::ExplanationOfBenefit>),
    /// A `FamilyMemberHistory` resource.
    #[cfg(feature = "resources")]
    FamilyMemberHistory(Box<super::family_member_history::FamilyMemberHistory>),
    /// A `Flag` resource.
    #[cfg(feature = "resources")]
    Flag(Box<super::flag::Flag>),
    /// A `Goal` resource.
    #[cfg(feature = "resources")]
    Goal(Box<super::goal::Goal>),
    /// A `Group` resource.
    #[cfg(feature = "resources")]
    Group(Box<super::group::Group>),
    /// A `GuidanceResponse` resource.
    #[cfg(feature = "resources")]
    GuidanceResponse(Box<super::guidance_response::GuidanceResponse>),
    /// A `HealthcareService` resource.
    #[cfg(feature = "resources")]
    HealthcareService(Box<super::healthcare_service::HealthcareService>),
    /// A `ImagingSelection` resource.
    #[cfg(feature = "resources")]
    ImagingSelection(Box<super::imaging_selection::ImagingSelection>),
    /// A `ImagingStudy` resource.
    #[cfg(feature = "resources")]
    ImagingStudy(Box<super::imaging_study::ImagingStudy>),
    /// A `Immunization` resource.
    #[cfg(feature = "resources")]
    Immunization(Box<super::immunization::Immunization>),
    /// A `ImplementationGuide` resource.
    #[cfg(feature = "resources")]
    ImplementationGuide(Box<super::implementation_guide::ImplementationGuide>),
    /// A `Ingredient` resource.
    #[cfg(feature = "resources")]
    Ingredient(Box<super::ingredient::Ingredient>),
    /// A `InsurancePlan` resource.
    #[cfg(feature = "resources")]
    InsurancePlan(Box<super::insurance_plan::InsurancePlan>),
    /// A `InsuranceProduct` resource.
    #[cfg(feature = "resources")]
    InsuranceProduct(Box<super::insurance_product::InsuranceProduct>),
    /// A `Invoice` resource.
    #[cfg(feature = "resources")]
    Invoice(Box<super::invoice::Invoice>),
    /// A `Library` resource.
    #[cfg(feature = "resources")]
    Library(Box<super::library::Library>),
    /// A `List` resource.
    #[cfg(feature = "resources")]
    List(Box<super::list::List>),
    /// A `Location` resource.
    #[cfg(feature = "resources")]
    Location(Box<super::location::Location>),
    /// A `ManufacturedItemDefinition` resource.
    #[cfg(feature = "resources")]
    ManufacturedItemDefinition(
        Box<super::manufactured_item_definition::ManufacturedItemDefinition>,
    ),
    /// A `Measure` resource.
    #[cfg(feature = "resources")]
    Measure(Box<super::measure::Measure>),
    /// A `MeasureReport` resource.
    #[cfg(feature = "resources")]
    MeasureReport(Box<super::measure_report::MeasureReport>),
    /// A `Medication` resource.
    #[cfg(feature = "resources")]
    Medication(Box<super::medication::Medication>),
    /// A `MedicationAdministration` resource.
    #[cfg(feature = "resources")]
    MedicationAdministration(Box<super::medication_administration::MedicationAdministration>),
    /// A `MedicationDispense` resource.
    #[cfg(feature = "resources")]
    MedicationDispense(Box<super::medication_dispense::MedicationDispense>),
    /// A `MedicationRequest` resource.
    #[cfg(feature = "resources")]
    MedicationRequest(Box<super::medication_request::MedicationRequest>),
    /// A `MedicationStatement` resource.
    #[cfg(feature = "resources")]
    MedicationStatement(Box<super::medication_statement::MedicationStatement>),
    /// A `MedicinalProductDefinition` resource.
    #[cfg(feature = "resources")]
    MedicinalProductDefinition(
        Box<super::medicinal_product_definition::MedicinalProductDefinition>,
    ),
    /// A `MessageDefinition` resource.
    #[cfg(feature = "resources")]
    MessageDefinition(Box<super::message_definition::MessageDefinition>),
    /// A `MessageHeader` resource.
    #[cfg(feature = "resources")]
    MessageHeader(Box<super::message_header::MessageHeader>),
    /// A `NamingSystem` resource.
    #[cfg(feature = "resources")]
    NamingSystem(Box<super::naming_system::NamingSystem>),
    /// A `NutritionIntake` resource.
    #[cfg(feature = "resources")]
    NutritionIntake(Box<super::nutrition_intake::NutritionIntake>),
    /// A `NutritionOrder` resource.
    #[cfg(feature = "resources")]
    NutritionOrder(Box<super::nutrition_order::NutritionOrder>),
    /// A `NutritionProduct` resource.
    #[cfg(feature = "resources")]
    NutritionProduct(Box<super::nutrition_product::NutritionProduct>),
    /// A `Observation` resource.
    #[cfg(feature = "resources")]
    Observation(Box<super::observation::Observation>),
    /// A `ObservationDefinition` resource.
    #[cfg(feature = "resources")]
    ObservationDefinition(Box<super::observation_definition::ObservationDefinition>),
    /// A `OperationDefinition` resource.
    #[cfg(feature = "resources")]
    OperationDefinition(Box<super::operation_definition::OperationDefinition>),
    /// A `OperationOutcome` resource.
    #[cfg(feature = "terminology")]
    OperationOutcome(Box<super::operation_outcome::OperationOutcome>),
    /// A `Organization` resource.
    #[cfg(feature = "resources")]
    Organization(Box<super::organization::Organization>),
    /// A `OrganizationAffiliation` resource.
    #[cfg(feature = "resources")]
    OrganizationAffiliation(Box<super::organization_affiliation::OrganizationAffiliation>),
    /// A `PackagedProductDefinition` resource.
    #[cfg(feature = "resources")]
    PackagedProductDefinition(Box<super::packaged_product_definition::PackagedProductDefinition>),
    /// A `Parameters` resource.
    #[cfg(feature = "terminology")]
    Parameters(Box<super::parameters::Parameters>),
    /// A `Patient` resource.
    #[cfg(feature = "resources")]
    Patient(Box<super::patient::Patient>),
    /// A `PaymentNotice` resource.
    #[cfg(feature = "resources")]
    PaymentNotice(Box<super::payment_notice::PaymentNotice>),
    /// A `PaymentReconciliation` resource.
    #[cfg(feature = "resources")]
    PaymentReconciliation(Box<super::payment_reconciliation::PaymentReconciliation>),
    /// A `Person` resource.
    #[cfg(feature = "resources")]
    Person(Box<super::person::Person>),
    /// A `PlanDefinition` resource.
    #[cfg(feature = "resources")]
    PlanDefinition(Box<super::plan_definition::PlanDefinition>),
    /// A `Practitioner` resource.
    #[cfg(feature = "resources")]
    Practitioner(Box<super::practitioner::Practitioner>),
    /// A `PractitionerRole` resource.
    #[cfg(feature = "resources")]
    PractitionerRole(Box<super::practitioner_role::PractitionerRole>),
    /// A `Procedure` resource.
    #[cfg(feature = "resources")]
    Procedure(Box<super::procedure::Procedure>),
    /// A `Provenance` resource.
    #[cfg(feature = "resources")]
    Provenance(Box<super::provenance::Provenance>),
    /// A `Questionnaire` resource.
    #[cfg(feature = "resources")]
    Questionnaire(Box<super::questionnaire::Questionnaire>),
    /// A `QuestionnaireResponse` resource.
    #[cfg(feature = "resources")]
    QuestionnaireResponse(Box<super::questionnaire_response::QuestionnaireResponse>),
    /// A `RegulatedAuthorization` resource.
    #[cfg(feature = "resources")]
    RegulatedAuthorization(Box<super::regulated_authorization::RegulatedAuthorization>),
    /// A `RelatedPerson` resource.
    #[cfg(feature = "resources")]
    RelatedPerson(Box<super::related_person::RelatedPerson>),
    /// A `RequestOrchestration` resource.
    #[cfg(feature = "resources")]
    RequestOrchestration(Box<super::request_orchestration::RequestOrchestration>),
    /// A `Requirements` resource.
    #[cfg(feature = "resources")]
    Requirements(Box<super::requirements::Requirements>),
    /// A `ResearchStudy` resource.
    #[cfg(feature = "resources")]
    ResearchStudy(Box<super::research_study::ResearchStudy>),
    /// A `ResearchSubject` resource.
    #[cfg(feature = "resources")]
    ResearchSubject(Box<super::research_subject::ResearchSubject>),
    /// A `RiskAssessment` resource.
    #[cfg(feature = "resources")]
    RiskAssessment(Box<super::risk_assessment::RiskAssessment>),
    /// A `Schedule` resource.
    #[cfg(feature = "resources")]
    Schedule(Box<super::schedule::Schedule>),
    /// A `SearchParameter` resource.
    #[cfg(feature = "resources")]
    SearchParameter(Box<super::search_parameter::SearchParameter>),
    /// A `ServiceRequest` resource.
    #[cfg(feature = "resources")]
    ServiceRequest(Box<super::service_request::ServiceRequest>),
    /// A `Slot` resource.
    #[cfg(feature = "resources")]
    Slot(Box<super::slot::Slot>),
    /// A `Specimen` resource.
    #[cfg(feature = "resources")]
    Specimen(Box<super::specimen::Specimen>),
    /// A `SpecimenDefinition` resource.
    #[cfg(feature = "resources")]
    SpecimenDefinition(Box<super::specimen_definition::SpecimenDefinition>),
    /// A `StructureDefinition` resource.
    #[cfg(feature = "resources")]
    StructureDefinition(Box<super::structure_definition::StructureDefinition>),
    /// A `StructureMap` resource.
    #[cfg(feature = "resources")]
    StructureMap(Box<super::structure_map::StructureMap>),
    /// A `Subscription` resource.
    #[cfg(feature = "resources")]
    Subscription(Box<super::subscription::Subscription>),
    /// A `SubscriptionStatus` resource.
    #[cfg(feature = "resources")]
    SubscriptionStatus(Box<super::subscription_status::SubscriptionStatus>),
    /// A `SubscriptionTopic` resource.
    #[cfg(feature = "resources")]
    SubscriptionTopic(Box<super::subscription_topic::SubscriptionTopic>),
    /// A `Substance` resource.
    #[cfg(feature = "resources")]
    Substance(Box<super::substance::Substance>),
    /// A `SubstanceDefinition` resource.
    #[cfg(feature = "resources")]
    SubstanceDefinition(Box<super::substance_definition::SubstanceDefinition>),
    /// A `Task` resource.
    #[cfg(feature = "resources")]
    Task(Box<super::task::Task>),
    /// A `TerminologyCapabilities` resource.
    #[cfg(feature = "terminology")]
    TerminologyCapabilities(Box<super::terminology_capabilities::TerminologyCapabilities>),
    /// A `ValueSet` resource.
    #[cfg(feature = "terminology")]
    ValueSet(Box<super::value_set::ValueSet>),
    /// A `VisionPrescription` resource.
    #[cfg(feature = "resources")]
    VisionPrescription(Box<super::vision_prescription::VisionPrescription>),
    /// A resource of a type outside the root set.
    Unknown(UnknownResource),
}

impl super::super::codec::Json for Resource {
    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
        match self {
            #[cfg(feature = "resources")]
            Self::Account(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::ActivityDefinition(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::ActorDefinition(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::AdministrableProductDefinition(inner) => {
                super::super::codec::Json::to_json(inner.as_ref())
            }
            #[cfg(feature = "resources")]
            Self::AdverseEvent(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::AllergyIntolerance(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Appointment(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::AppointmentResponse(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::ArtifactAssessment(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::AuditEvent(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Basic(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Binary(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::BiologicallyDerivedProduct(inner) => {
                super::super::codec::Json::to_json(inner.as_ref())
            }
            #[cfg(feature = "resources")]
            Self::BodyStructure(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "terminology")]
            Self::Bundle(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "terminology")]
            Self::CapabilityStatement(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::CarePlan(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::CareTeam(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Claim(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::ClaimResponse(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::ClinicalUseDefinition(inner) => {
                super::super::codec::Json::to_json(inner.as_ref())
            }
            #[cfg(feature = "terminology")]
            Self::CodeSystem(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Communication(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::CommunicationRequest(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::CompartmentDefinition(inner) => {
                super::super::codec::Json::to_json(inner.as_ref())
            }
            #[cfg(feature = "resources")]
            Self::Composition(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "terminology")]
            Self::ConceptMap(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Condition(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Consent(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Contract(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Coverage(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::CoverageEligibilityRequest(inner) => {
                super::super::codec::Json::to_json(inner.as_ref())
            }
            #[cfg(feature = "resources")]
            Self::CoverageEligibilityResponse(inner) => {
                super::super::codec::Json::to_json(inner.as_ref())
            }
            #[cfg(feature = "resources")]
            Self::DetectedIssue(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Device(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::DeviceAlert(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::DeviceAssociation(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::DeviceDefinition(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::DeviceMetric(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::DeviceRequest(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::DiagnosticReport(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::DocumentReference(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Encounter(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Endpoint(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::EnrollmentRequest(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::EnrollmentResponse(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::EpisodeOfCare(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::EventDefinition(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Evidence(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::EvidenceVariable(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::ExampleScenario(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::ExplanationOfBenefit(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::FamilyMemberHistory(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Flag(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Goal(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Group(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::GuidanceResponse(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::HealthcareService(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::ImagingSelection(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::ImagingStudy(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Immunization(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::ImplementationGuide(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Ingredient(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::InsurancePlan(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::InsuranceProduct(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Invoice(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Library(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::List(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Location(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::ManufacturedItemDefinition(inner) => {
                super::super::codec::Json::to_json(inner.as_ref())
            }
            #[cfg(feature = "resources")]
            Self::Measure(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::MeasureReport(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Medication(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::MedicationAdministration(inner) => {
                super::super::codec::Json::to_json(inner.as_ref())
            }
            #[cfg(feature = "resources")]
            Self::MedicationDispense(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::MedicationRequest(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::MedicationStatement(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::MedicinalProductDefinition(inner) => {
                super::super::codec::Json::to_json(inner.as_ref())
            }
            #[cfg(feature = "resources")]
            Self::MessageDefinition(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::MessageHeader(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::NamingSystem(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::NutritionIntake(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::NutritionOrder(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::NutritionProduct(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Observation(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::ObservationDefinition(inner) => {
                super::super::codec::Json::to_json(inner.as_ref())
            }
            #[cfg(feature = "resources")]
            Self::OperationDefinition(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "terminology")]
            Self::OperationOutcome(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Organization(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::OrganizationAffiliation(inner) => {
                super::super::codec::Json::to_json(inner.as_ref())
            }
            #[cfg(feature = "resources")]
            Self::PackagedProductDefinition(inner) => {
                super::super::codec::Json::to_json(inner.as_ref())
            }
            #[cfg(feature = "terminology")]
            Self::Parameters(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Patient(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::PaymentNotice(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::PaymentReconciliation(inner) => {
                super::super::codec::Json::to_json(inner.as_ref())
            }
            #[cfg(feature = "resources")]
            Self::Person(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::PlanDefinition(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Practitioner(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::PractitionerRole(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Procedure(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Provenance(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Questionnaire(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::QuestionnaireResponse(inner) => {
                super::super::codec::Json::to_json(inner.as_ref())
            }
            #[cfg(feature = "resources")]
            Self::RegulatedAuthorization(inner) => {
                super::super::codec::Json::to_json(inner.as_ref())
            }
            #[cfg(feature = "resources")]
            Self::RelatedPerson(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::RequestOrchestration(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Requirements(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::ResearchStudy(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::ResearchSubject(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::RiskAssessment(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Schedule(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::SearchParameter(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::ServiceRequest(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Slot(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Specimen(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::SpecimenDefinition(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::StructureDefinition(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::StructureMap(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Subscription(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::SubscriptionStatus(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::SubscriptionTopic(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Substance(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::SubstanceDefinition(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::Task(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "terminology")]
            Self::TerminologyCapabilities(inner) => {
                super::super::codec::Json::to_json(inner.as_ref())
            }
            #[cfg(feature = "terminology")]
            Self::ValueSet(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            #[cfg(feature = "resources")]
            Self::VisionPrescription(inner) => super::super::codec::Json::to_json(inner.as_ref()),
            Self::Unknown(inner) => match &inner.body {
                super::super::codec::Value::Object(object) => Ok(object.clone()),
                _ => Err(super::super::codec::EncodeError::UnknownResourceBody),
            },
        }
    }

    fn from_json(
        object: &super::super::codec::Object,
        path: &mut super::super::codec::Path,
    ) -> Result<Self, super::super::codec::DecodeError> {
        match super::super::codec::resource_type(object, path)? {
            #[cfg(feature = "resources")]
            "Account" => Ok(Self::Account(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "ActivityDefinition" => Ok(Self::ActivityDefinition(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "ActorDefinition" => Ok(Self::ActorDefinition(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "AdministrableProductDefinition" => Ok(Self::AdministrableProductDefinition(
                super::super::codec::boxed(object, path)?,
            )),
            #[cfg(feature = "resources")]
            "AdverseEvent" => Ok(Self::AdverseEvent(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "AllergyIntolerance" => Ok(Self::AllergyIntolerance(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Appointment" => Ok(Self::Appointment(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "AppointmentResponse" => Ok(Self::AppointmentResponse(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "ArtifactAssessment" => Ok(Self::ArtifactAssessment(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "AuditEvent" => Ok(Self::AuditEvent(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "Basic" => Ok(Self::Basic(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "Binary" => Ok(Self::Binary(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "BiologicallyDerivedProduct" => Ok(Self::BiologicallyDerivedProduct(
                super::super::codec::boxed(object, path)?,
            )),
            #[cfg(feature = "resources")]
            "BodyStructure" => Ok(Self::BodyStructure(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "terminology")]
            "Bundle" => Ok(Self::Bundle(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "terminology")]
            "CapabilityStatement" => Ok(Self::CapabilityStatement(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "CarePlan" => Ok(Self::CarePlan(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "CareTeam" => Ok(Self::CareTeam(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "Claim" => Ok(Self::Claim(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "ClaimResponse" => Ok(Self::ClaimResponse(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "ClinicalUseDefinition" => Ok(Self::ClinicalUseDefinition(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "terminology")]
            "CodeSystem" => Ok(Self::CodeSystem(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "Communication" => Ok(Self::Communication(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "CommunicationRequest" => Ok(Self::CommunicationRequest(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "CompartmentDefinition" => Ok(Self::CompartmentDefinition(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Composition" => Ok(Self::Composition(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "terminology")]
            "ConceptMap" => Ok(Self::ConceptMap(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "Condition" => Ok(Self::Condition(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "Consent" => Ok(Self::Consent(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "Contract" => Ok(Self::Contract(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "Coverage" => Ok(Self::Coverage(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "CoverageEligibilityRequest" => Ok(Self::CoverageEligibilityRequest(
                super::super::codec::boxed(object, path)?,
            )),
            #[cfg(feature = "resources")]
            "CoverageEligibilityResponse" => Ok(Self::CoverageEligibilityResponse(
                super::super::codec::boxed(object, path)?,
            )),
            #[cfg(feature = "resources")]
            "DetectedIssue" => Ok(Self::DetectedIssue(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Device" => Ok(Self::Device(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "DeviceAlert" => Ok(Self::DeviceAlert(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "DeviceAssociation" => Ok(Self::DeviceAssociation(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "DeviceDefinition" => Ok(Self::DeviceDefinition(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "DeviceMetric" => Ok(Self::DeviceMetric(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "DeviceRequest" => Ok(Self::DeviceRequest(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "DiagnosticReport" => Ok(Self::DiagnosticReport(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "DocumentReference" => Ok(Self::DocumentReference(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Encounter" => Ok(Self::Encounter(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "Endpoint" => Ok(Self::Endpoint(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "EnrollmentRequest" => Ok(Self::EnrollmentRequest(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "EnrollmentResponse" => Ok(Self::EnrollmentResponse(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "EpisodeOfCare" => Ok(Self::EpisodeOfCare(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "EventDefinition" => Ok(Self::EventDefinition(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Evidence" => Ok(Self::Evidence(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "EvidenceVariable" => Ok(Self::EvidenceVariable(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "ExampleScenario" => Ok(Self::ExampleScenario(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "ExplanationOfBenefit" => Ok(Self::ExplanationOfBenefit(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "FamilyMemberHistory" => Ok(Self::FamilyMemberHistory(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Flag" => Ok(Self::Flag(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "Goal" => Ok(Self::Goal(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "Group" => Ok(Self::Group(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "GuidanceResponse" => Ok(Self::GuidanceResponse(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "HealthcareService" => Ok(Self::HealthcareService(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "ImagingSelection" => Ok(Self::ImagingSelection(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "ImagingStudy" => Ok(Self::ImagingStudy(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Immunization" => Ok(Self::Immunization(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "ImplementationGuide" => Ok(Self::ImplementationGuide(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Ingredient" => Ok(Self::Ingredient(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "InsurancePlan" => Ok(Self::InsurancePlan(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "InsuranceProduct" => Ok(Self::InsuranceProduct(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Invoice" => Ok(Self::Invoice(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "Library" => Ok(Self::Library(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "List" => Ok(Self::List(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "Location" => Ok(Self::Location(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "ManufacturedItemDefinition" => Ok(Self::ManufacturedItemDefinition(
                super::super::codec::boxed(object, path)?,
            )),
            #[cfg(feature = "resources")]
            "Measure" => Ok(Self::Measure(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "MeasureReport" => Ok(Self::MeasureReport(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Medication" => Ok(Self::Medication(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "MedicationAdministration" => Ok(Self::MedicationAdministration(
                super::super::codec::boxed(object, path)?,
            )),
            #[cfg(feature = "resources")]
            "MedicationDispense" => Ok(Self::MedicationDispense(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "MedicationRequest" => Ok(Self::MedicationRequest(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "MedicationStatement" => Ok(Self::MedicationStatement(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "MedicinalProductDefinition" => Ok(Self::MedicinalProductDefinition(
                super::super::codec::boxed(object, path)?,
            )),
            #[cfg(feature = "resources")]
            "MessageDefinition" => Ok(Self::MessageDefinition(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "MessageHeader" => Ok(Self::MessageHeader(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "NamingSystem" => Ok(Self::NamingSystem(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "NutritionIntake" => Ok(Self::NutritionIntake(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "NutritionOrder" => Ok(Self::NutritionOrder(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "NutritionProduct" => Ok(Self::NutritionProduct(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Observation" => Ok(Self::Observation(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "ObservationDefinition" => Ok(Self::ObservationDefinition(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "OperationDefinition" => Ok(Self::OperationDefinition(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "terminology")]
            "OperationOutcome" => Ok(Self::OperationOutcome(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Organization" => Ok(Self::Organization(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "OrganizationAffiliation" => Ok(Self::OrganizationAffiliation(
                super::super::codec::boxed(object, path)?,
            )),
            #[cfg(feature = "resources")]
            "PackagedProductDefinition" => Ok(Self::PackagedProductDefinition(
                super::super::codec::boxed(object, path)?,
            )),
            #[cfg(feature = "terminology")]
            "Parameters" => Ok(Self::Parameters(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "Patient" => Ok(Self::Patient(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "PaymentNotice" => Ok(Self::PaymentNotice(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "PaymentReconciliation" => Ok(Self::PaymentReconciliation(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Person" => Ok(Self::Person(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "PlanDefinition" => Ok(Self::PlanDefinition(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Practitioner" => Ok(Self::Practitioner(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "PractitionerRole" => Ok(Self::PractitionerRole(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Procedure" => Ok(Self::Procedure(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "Provenance" => Ok(Self::Provenance(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "Questionnaire" => Ok(Self::Questionnaire(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "QuestionnaireResponse" => Ok(Self::QuestionnaireResponse(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "RegulatedAuthorization" => Ok(Self::RegulatedAuthorization(
                super::super::codec::boxed(object, path)?,
            )),
            #[cfg(feature = "resources")]
            "RelatedPerson" => Ok(Self::RelatedPerson(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "RequestOrchestration" => Ok(Self::RequestOrchestration(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Requirements" => Ok(Self::Requirements(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "ResearchStudy" => Ok(Self::ResearchStudy(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "ResearchSubject" => Ok(Self::ResearchSubject(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "RiskAssessment" => Ok(Self::RiskAssessment(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Schedule" => Ok(Self::Schedule(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "SearchParameter" => Ok(Self::SearchParameter(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "ServiceRequest" => Ok(Self::ServiceRequest(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Slot" => Ok(Self::Slot(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "Specimen" => Ok(Self::Specimen(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "SpecimenDefinition" => Ok(Self::SpecimenDefinition(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "StructureDefinition" => Ok(Self::StructureDefinition(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "StructureMap" => Ok(Self::StructureMap(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Subscription" => Ok(Self::Subscription(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "SubscriptionStatus" => Ok(Self::SubscriptionStatus(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "SubscriptionTopic" => Ok(Self::SubscriptionTopic(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Substance" => Ok(Self::Substance(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "SubstanceDefinition" => Ok(Self::SubstanceDefinition(super::super::codec::boxed(
                object, path,
            )?)),
            #[cfg(feature = "resources")]
            "Task" => Ok(Self::Task(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "terminology")]
            "TerminologyCapabilities" => Ok(Self::TerminologyCapabilities(
                super::super::codec::boxed(object, path)?,
            )),
            #[cfg(feature = "terminology")]
            "ValueSet" => Ok(Self::ValueSet(super::super::codec::boxed(object, path)?)),
            #[cfg(feature = "resources")]
            "VisionPrescription" => Ok(Self::VisionPrescription(super::super::codec::boxed(
                object, path,
            )?)),
            other => Ok(Self::Unknown(UnknownResource {
                resource_type: other.to_owned(),
                body: super::super::codec::Value::Object(object.clone()),
            })),
        }
    }
}

impl serde::Serialize for Resource {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        match self {
            #[cfg(feature = "resources")]
            Self::Account(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::ActivityDefinition(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::ActorDefinition(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::AdministrableProductDefinition(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::AdverseEvent(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::AllergyIntolerance(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::Appointment(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::AppointmentResponse(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::ArtifactAssessment(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::AuditEvent(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Basic(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Binary(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::BiologicallyDerivedProduct(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::BodyStructure(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "terminology")]
            Self::Bundle(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "terminology")]
            Self::CapabilityStatement(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::CarePlan(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::CareTeam(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Claim(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::ClaimResponse(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::ClinicalUseDefinition(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "terminology")]
            Self::CodeSystem(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Communication(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::CommunicationRequest(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::CompartmentDefinition(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::Composition(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "terminology")]
            Self::ConceptMap(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Condition(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Consent(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Contract(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Coverage(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::CoverageEligibilityRequest(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::CoverageEligibilityResponse(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::DetectedIssue(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Device(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::DeviceAlert(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::DeviceAssociation(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::DeviceDefinition(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::DeviceMetric(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::DeviceRequest(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::DiagnosticReport(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::DocumentReference(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::Encounter(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Endpoint(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::EnrollmentRequest(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::EnrollmentResponse(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::EpisodeOfCare(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::EventDefinition(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Evidence(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::EvidenceVariable(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::ExampleScenario(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::ExplanationOfBenefit(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::FamilyMemberHistory(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::Flag(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Goal(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Group(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::GuidanceResponse(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::HealthcareService(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::ImagingSelection(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::ImagingStudy(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Immunization(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::ImplementationGuide(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::Ingredient(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::InsurancePlan(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::InsuranceProduct(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::Invoice(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Library(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::List(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Location(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::ManufacturedItemDefinition(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::Measure(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::MeasureReport(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Medication(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::MedicationAdministration(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::MedicationDispense(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::MedicationRequest(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::MedicationStatement(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::MedicinalProductDefinition(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::MessageDefinition(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::MessageHeader(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::NamingSystem(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::NutritionIntake(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::NutritionOrder(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::NutritionProduct(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::Observation(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::ObservationDefinition(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::OperationDefinition(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "terminology")]
            Self::OperationOutcome(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::Organization(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::OrganizationAffiliation(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::PackagedProductDefinition(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "terminology")]
            Self::Parameters(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Patient(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::PaymentNotice(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::PaymentReconciliation(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::Person(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::PlanDefinition(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Practitioner(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::PractitionerRole(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::Procedure(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Provenance(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Questionnaire(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::QuestionnaireResponse(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::RegulatedAuthorization(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::RelatedPerson(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::RequestOrchestration(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::Requirements(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::ResearchStudy(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::ResearchSubject(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::RiskAssessment(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Schedule(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::SearchParameter(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::ServiceRequest(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Slot(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Specimen(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::SpecimenDefinition(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::StructureDefinition(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::StructureMap(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::Subscription(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::SubscriptionStatus(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::SubscriptionTopic(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::Substance(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::SubstanceDefinition(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "resources")]
            Self::Task(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "terminology")]
            Self::TerminologyCapabilities(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            #[cfg(feature = "terminology")]
            Self::ValueSet(inner) => serde::Serialize::serialize(inner.as_ref(), serializer),
            #[cfg(feature = "resources")]
            Self::VisionPrescription(inner) => {
                serde::Serialize::serialize(inner.as_ref(), serializer)
            }
            Self::Unknown(inner) => match &inner.body {
                super::super::codec::Value::Object(object) => {
                    serde::Serialize::serialize(object, serializer)
                }
                _ => Err(<S::Error as serde::ser::Error>::custom(
                    super::super::codec::EncodeError::UnknownResourceBody,
                )),
            },
        }
    }
}

impl<'de> serde::Deserialize<'de> for Resource {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        let value = <super::super::codec::Value as serde::Deserialize>::deserialize(deserializer)?;
        let mut path = super::super::codec::Path::root("Resource");
        let object =
            super::super::codec::expect_object(&value, &path).map_err(serde::de::Error::custom)?;
        super::super::codec::Json::from_json(object, &mut path).map_err(serde::de::Error::custom)
    }
}

/// A resource outside the root set, kept as its JSON body.
///
/// Carries the resourceType and the complete JSON object so a Bundle or a
/// contained resource of a type outside the root set round-trips unchanged.
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct UnknownResource {
    /// The `resourceType` of the carried resource.
    pub resource_type: std::string::String,
    /// The complete JSON object, `resourceType` included.
    pub body: super::super::codec::Value,
}