fhir-types 0.1.109

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
// @generated by fhir-codegen from hl7.fhir.r3.core 3.0.2. DO NOT EDIT.
// Change the emitter (tools/fhir-codegen) and regenerate.
// SPDX-FileCopyrightText: Cadasto B.V.
// SPDX-License-Identifier: Apache-2.0
//! A description of decision support service functionality

/// A description of decision support service functionality
///
/// The ServiceDefinition describes a unit of decision support functionality
/// that is made available as a service, such as immunization modules or
/// drug-drug interaction checking.
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct ServiceDefinition {
    /// Logical id of this artifact
    ///
    /// The logical id of the resource, as used in the URL for the resource. Once
    /// assigned, this value never changes.
    pub id: Option<super::primitives::Id>,
    /// Metadata about the resource
    ///
    /// The metadata about the resource. This is content that is maintained by the
    /// infrastructure. Changes to the content may not always be associated with
    /// version changes to the resource.
    pub meta: Option<super::meta::Meta>,
    /// A set of rules under which this content was created
    ///
    /// A reference to a set of rules that were followed when the resource was
    /// constructed, and which must be understood when processing the content.
    pub implicit_rules: Option<super::primitives::Uri>,
    /// Language of the resource content
    ///
    /// The base language in which the resource is written.
    pub language: Option<super::primitives::Code>,
    /// Text summary of the resource, for human interpretation
    ///
    /// A human-readable narrative that contains a summary of the resource, and may
    /// be used to represent the content of the resource to a human. The narrative
    /// need not encode all the structured data, but is required to contain
    /// sufficient detail to make it "clinically safe" for a human to just read the
    /// narrative. Resource definitions may define what content should be
    /// represented in the narrative to ensure clinical safety.
    pub text: Option<super::narrative::Narrative>,
    /// Contained, inline Resources
    ///
    /// These resources do not have an independent existence apart from the resource
    /// that contains them - they cannot be identified independently, and nor can
    /// they have their own independent transaction scope.
    pub contained: Vec<super::resource::Resource>,
    /// Additional Content defined by implementations
    ///
    /// May be used to represent additional information that is not part of the
    /// basic definition of the resource. In order to make the use of extensions
    /// safe and manageable, there is a strict set of governance applied to the
    /// definition and use of extensions. Though any implementer is allowed to
    /// define an extension, there is a set of requirements that SHALL be met as
    /// part of the definition of the extension.
    pub extension: Vec<super::extension::Extension>,
    /// Extensions that cannot be ignored
    ///
    /// May be used to represent additional information that is not part of the
    /// basic definition of the resource, and that modifies the understanding of the
    /// element that contains it. Usually modifier elements provide negation or
    /// qualification. In order to make the use of extensions safe and manageable,
    /// there is a strict set of governance applied to the definition and use of
    /// extensions. Though any implementer is allowed to define an extension, there
    /// is a set of requirements that SHALL be met as part of the definition of the
    /// extension. Applications processing a resource are required to check for
    /// modifier extensions.
    pub modifier_extension: Vec<super::extension::Extension>,
    /// Logical URI to reference this service definition (globally unique)
    ///
    /// An absolute URI that is used to identify this service definition when it is
    /// referenced in a specification, model, design or an instance. This SHALL be a
    /// URL, SHOULD be globally unique, and SHOULD be an address at which this
    /// service definition is (or will be) published. The URL SHOULD include the
    /// major version of the service definition. For more information see
    /// \[Technical and Business Versions\](resource.html\#versions).
    pub url: Option<super::primitives::Uri>,
    /// Additional identifier for the service definition
    ///
    /// A formal identifier that is used to identify this service definition when it
    /// is represented in other formats, or referenced in a specification, model,
    /// design or an instance. This is used for CMS or NQF identifiers for a measure
    /// artifact. Note that at least one identifier is required for non-experimental
    /// active artifacts.
    pub identifier: Vec<super::identifier::Identifier>,
    /// Business version of the service definition
    ///
    /// The identifier that is used to identify this version of the service
    /// definition when it is referenced in a specification, model, design or
    /// instance. This is an arbitrary value managed by the service definition
    /// author and is not expected to be globally unique. For example, it might be a
    /// timestamp (e.g. yyyymmdd) if a managed version is not available. There is
    /// also no expectation that versions can be placed in a lexicographical
    /// sequence.
    pub version: Option<super::primitives::String>,
    /// Name for this service definition (computer friendly)
    ///
    /// A natural language name identifying the service definition. This name should
    /// be usable as an identifier for the module by machine processing applications
    /// such as code generation.
    pub name: Option<super::primitives::String>,
    /// Name for this service definition (human friendly)
    ///
    /// A short, descriptive, user-friendly title for the service definition.
    pub title: Option<super::primitives::String>,
    /// draft | active | retired | unknown
    ///
    /// The status of this service definition. Enables tracking the life-cycle of
    /// the content.
    pub status: super::primitives::Code,
    /// For testing purposes, not real usage
    ///
    /// A boolean value to indicate that this service definition is authored for
    /// testing purposes (or education/evaluation/marketing), and is not intended to
    /// be used for genuine usage.
    pub experimental: Option<super::primitives::Boolean>,
    /// Date this was last changed
    ///
    /// The date (and optionally time) when the service definition was published.
    /// The date must change if and when the business version changes and it must
    /// change if the status code changes. In addition, it should change when the
    /// substantive content of the service definition changes.
    pub date: Option<super::primitives::DateTime>,
    /// Name of the publisher (organization or individual)
    ///
    /// The name of the individual or organization that published the service
    /// definition.
    pub publisher: Option<super::primitives::String>,
    /// Natural language description of the service definition
    ///
    /// A free text natural language description of the service definition from a
    /// consumer's perspective.
    pub description: Option<super::primitives::Markdown>,
    /// Why this service definition is defined
    ///
    /// Explaination of why this service definition is needed and why it has been
    /// designed as it has.
    pub purpose: Option<super::primitives::Markdown>,
    /// Describes the clinical usage of the module
    ///
    /// A detailed description of how the module is used from a clinical
    /// perspective.
    pub usage: Option<super::primitives::String>,
    /// When the service definition was approved by publisher
    ///
    /// The date on which the resource content was approved by the publisher.
    /// Approval happens once when the content is officially approved for usage.
    pub approval_date: Option<super::primitives::Date>,
    /// When the service definition was last reviewed
    ///
    /// The date on which the resource content was last reviewed. Review happens
    /// periodically after approval, but doesn't change the original approval date.
    pub last_review_date: Option<super::primitives::Date>,
    /// When the service definition is expected to be used
    ///
    /// The period during which the service definition content was or is planned to
    /// be in active use.
    pub effective_period: Option<super::period::Period>,
    /// Context the content is intended to support
    ///
    /// The content was developed with a focus and intent of supporting the contexts
    /// that are listed. These terms may be used to assist with indexing and
    /// searching for appropriate service definition instances.
    pub use_context: Vec<super::usage_context::UsageContext>,
    /// Intended jurisdiction for service definition (if applicable)
    ///
    /// A legal or geographic region in which the service definition is intended to
    /// be used.
    pub jurisdiction: Vec<super::codeable_concept::CodeableConcept>,
    /// E.g. Education, Treatment, Assessment, etc
    ///
    /// Descriptive topics related to the module. Topics provide a high-level
    /// categorization of the module that can be useful for filtering and searching.
    pub topic: Vec<super::codeable_concept::CodeableConcept>,
    /// A content contributor
    ///
    /// A contributor to the content of the module, including authors, editors,
    /// reviewers, and endorsers.
    pub contributor: Vec<super::contributor::Contributor>,
    /// Contact details for the publisher
    ///
    /// Contact details to assist a user in finding and communicating with the
    /// publisher.
    pub contact: Vec<super::contact_detail::ContactDetail>,
    /// Use and/or publishing restrictions
    ///
    /// A copyright statement relating to the service definition and/or its
    /// contents. Copyright statements are generally legal restrictions on the use
    /// and publishing of the service definition.
    pub copyright: Option<super::primitives::Markdown>,
    /// Additional documentation, citations, etc
    ///
    /// Related resources such as additional documentation, justification, or
    /// bibliographic references.
    pub related_artifact: Vec<super::related_artifact::RelatedArtifact>,
    /// "when" the module should be invoked
    ///
    /// The trigger element defines when the rule should be invoked. This
    /// information is used by consumers of the rule to determine how to integrate
    /// the rule into a specific workflow.
    pub trigger: Vec<super::trigger_definition::TriggerDefinition>,
    /// What data is used by the module
    ///
    /// Data requirements are a machine processable description of the data required
    /// by the module in order to perform a successful evaluation.
    pub data_requirement: Vec<super::data_requirement::DataRequirement>,
    /// Operation to invoke
    ///
    /// A reference to the operation that is used to invoke this service.
    pub operation_definition: Option<super::reference::Reference>,
}

impl super::super::codec::Json for ServiceDefinition {
    fn to_json(&self) -> Result<super::super::codec::Object, super::super::codec::EncodeError> {
        let mut object = super::super::codec::Object::new();
        object.insert(
            std::string::String::from("resourceType"),
            super::super::codec::Value::String(std::string::String::from("ServiceDefinition")),
        );
        if let Some(item) = &self.id {
            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
                object.insert(std::string::String::from("id"), v);
            }
            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
                object.insert(std::string::String::from("_id"), e);
            }
        }
        if let Some(item) = &self.meta {
            object.insert(
                std::string::String::from("meta"),
                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
            );
        }
        if let Some(item) = &self.implicit_rules {
            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
                object.insert(std::string::String::from("implicitRules"), v);
            }
            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
                object.insert(std::string::String::from("_implicitRules"), e);
            }
        }
        if let Some(item) = &self.language {
            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
                object.insert(std::string::String::from("language"), v);
            }
            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
                object.insert(std::string::String::from("_language"), e);
            }
        }
        if let Some(item) = &self.text {
            object.insert(
                std::string::String::from("text"),
                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
            );
        }
        if !self.contained.is_empty() {
            let mut items = Vec::with_capacity(self.contained.len());
            for item in &self.contained {
                items.push(super::super::codec::Value::Object(
                    super::super::codec::Json::to_json(item)?,
                ));
            }
            object.insert(
                std::string::String::from("contained"),
                super::super::codec::Value::Array(items),
            );
        }
        if !self.extension.is_empty() {
            let mut items = Vec::with_capacity(self.extension.len());
            for item in &self.extension {
                items.push(super::super::codec::Value::Object(
                    super::super::codec::Json::to_json(item)?,
                ));
            }
            object.insert(
                std::string::String::from("extension"),
                super::super::codec::Value::Array(items),
            );
        }
        if !self.modifier_extension.is_empty() {
            let mut items = Vec::with_capacity(self.modifier_extension.len());
            for item in &self.modifier_extension {
                items.push(super::super::codec::Value::Object(
                    super::super::codec::Json::to_json(item)?,
                ));
            }
            object.insert(
                std::string::String::from("modifierExtension"),
                super::super::codec::Value::Array(items),
            );
        }
        if let Some(item) = &self.url {
            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
                object.insert(std::string::String::from("url"), v);
            }
            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
                object.insert(std::string::String::from("_url"), e);
            }
        }
        if !self.identifier.is_empty() {
            let mut items = Vec::with_capacity(self.identifier.len());
            for item in &self.identifier {
                items.push(super::super::codec::Value::Object(
                    super::super::codec::Json::to_json(item)?,
                ));
            }
            object.insert(
                std::string::String::from("identifier"),
                super::super::codec::Value::Array(items),
            );
        }
        if let Some(item) = &self.version {
            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
                object.insert(std::string::String::from("version"), v);
            }
            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
                object.insert(std::string::String::from("_version"), e);
            }
        }
        if let Some(item) = &self.name {
            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
                object.insert(std::string::String::from("name"), v);
            }
            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
                object.insert(std::string::String::from("_name"), e);
            }
        }
        if let Some(item) = &self.title {
            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
                object.insert(std::string::String::from("title"), v);
            }
            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
                object.insert(std::string::String::from("_title"), e);
            }
        }
        if let Some(v) = super::super::codec::Primitive::value_json(&self.status)? {
            object.insert(std::string::String::from("status"), v);
        }
        if let Some(e) = super::super::codec::Primitive::element_json(&self.status)? {
            object.insert(std::string::String::from("_status"), e);
        }
        if let Some(item) = &self.experimental {
            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
                object.insert(std::string::String::from("experimental"), v);
            }
            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
                object.insert(std::string::String::from("_experimental"), e);
            }
        }
        if let Some(item) = &self.date {
            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
                object.insert(std::string::String::from("date"), v);
            }
            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
                object.insert(std::string::String::from("_date"), e);
            }
        }
        if let Some(item) = &self.publisher {
            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
                object.insert(std::string::String::from("publisher"), v);
            }
            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
                object.insert(std::string::String::from("_publisher"), e);
            }
        }
        if let Some(item) = &self.description {
            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
                object.insert(std::string::String::from("description"), v);
            }
            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
                object.insert(std::string::String::from("_description"), e);
            }
        }
        if let Some(item) = &self.purpose {
            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
                object.insert(std::string::String::from("purpose"), v);
            }
            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
                object.insert(std::string::String::from("_purpose"), e);
            }
        }
        if let Some(item) = &self.usage {
            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
                object.insert(std::string::String::from("usage"), v);
            }
            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
                object.insert(std::string::String::from("_usage"), e);
            }
        }
        if let Some(item) = &self.approval_date {
            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
                object.insert(std::string::String::from("approvalDate"), v);
            }
            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
                object.insert(std::string::String::from("_approvalDate"), e);
            }
        }
        if let Some(item) = &self.last_review_date {
            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
                object.insert(std::string::String::from("lastReviewDate"), v);
            }
            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
                object.insert(std::string::String::from("_lastReviewDate"), e);
            }
        }
        if let Some(item) = &self.effective_period {
            object.insert(
                std::string::String::from("effectivePeriod"),
                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
            );
        }
        if !self.use_context.is_empty() {
            let mut items = Vec::with_capacity(self.use_context.len());
            for item in &self.use_context {
                items.push(super::super::codec::Value::Object(
                    super::super::codec::Json::to_json(item)?,
                ));
            }
            object.insert(
                std::string::String::from("useContext"),
                super::super::codec::Value::Array(items),
            );
        }
        if !self.jurisdiction.is_empty() {
            let mut items = Vec::with_capacity(self.jurisdiction.len());
            for item in &self.jurisdiction {
                items.push(super::super::codec::Value::Object(
                    super::super::codec::Json::to_json(item)?,
                ));
            }
            object.insert(
                std::string::String::from("jurisdiction"),
                super::super::codec::Value::Array(items),
            );
        }
        if !self.topic.is_empty() {
            let mut items = Vec::with_capacity(self.topic.len());
            for item in &self.topic {
                items.push(super::super::codec::Value::Object(
                    super::super::codec::Json::to_json(item)?,
                ));
            }
            object.insert(
                std::string::String::from("topic"),
                super::super::codec::Value::Array(items),
            );
        }
        if !self.contributor.is_empty() {
            let mut items = Vec::with_capacity(self.contributor.len());
            for item in &self.contributor {
                items.push(super::super::codec::Value::Object(
                    super::super::codec::Json::to_json(item)?,
                ));
            }
            object.insert(
                std::string::String::from("contributor"),
                super::super::codec::Value::Array(items),
            );
        }
        if !self.contact.is_empty() {
            let mut items = Vec::with_capacity(self.contact.len());
            for item in &self.contact {
                items.push(super::super::codec::Value::Object(
                    super::super::codec::Json::to_json(item)?,
                ));
            }
            object.insert(
                std::string::String::from("contact"),
                super::super::codec::Value::Array(items),
            );
        }
        if let Some(item) = &self.copyright {
            if let Some(v) = super::super::codec::Primitive::value_json(item)? {
                object.insert(std::string::String::from("copyright"), v);
            }
            if let Some(e) = super::super::codec::Primitive::element_json(item)? {
                object.insert(std::string::String::from("_copyright"), e);
            }
        }
        if !self.related_artifact.is_empty() {
            let mut items = Vec::with_capacity(self.related_artifact.len());
            for item in &self.related_artifact {
                items.push(super::super::codec::Value::Object(
                    super::super::codec::Json::to_json(item)?,
                ));
            }
            object.insert(
                std::string::String::from("relatedArtifact"),
                super::super::codec::Value::Array(items),
            );
        }
        if !self.trigger.is_empty() {
            let mut items = Vec::with_capacity(self.trigger.len());
            for item in &self.trigger {
                items.push(super::super::codec::Value::Object(
                    super::super::codec::Json::to_json(item)?,
                ));
            }
            object.insert(
                std::string::String::from("trigger"),
                super::super::codec::Value::Array(items),
            );
        }
        if !self.data_requirement.is_empty() {
            let mut items = Vec::with_capacity(self.data_requirement.len());
            for item in &self.data_requirement {
                items.push(super::super::codec::Value::Object(
                    super::super::codec::Json::to_json(item)?,
                ));
            }
            object.insert(
                std::string::String::from("dataRequirement"),
                super::super::codec::Value::Array(items),
            );
        }
        if let Some(item) = &self.operation_definition {
            object.insert(
                std::string::String::from("operationDefinition"),
                super::super::codec::Value::Object(super::super::codec::Json::to_json(item)?),
            );
        }
        Ok(object)
    }

    fn from_json(
        object: &super::super::codec::Object,
        path: &mut super::super::codec::Path,
    ) -> Result<Self, super::super::codec::DecodeError> {
        let mut raw_id: Option<&super::super::codec::Value> = None;
        let mut raw_id_element: Option<&super::super::codec::Value> = None;
        let mut raw_meta: Option<&super::super::codec::Value> = None;
        let mut raw_implicit_rules: Option<&super::super::codec::Value> = None;
        let mut raw_implicit_rules_element: Option<&super::super::codec::Value> = None;
        let mut raw_language: Option<&super::super::codec::Value> = None;
        let mut raw_language_element: Option<&super::super::codec::Value> = None;
        let mut raw_text: Option<&super::super::codec::Value> = None;
        let mut raw_contained: Option<&super::super::codec::Value> = None;
        let mut raw_extension: Option<&super::super::codec::Value> = None;
        let mut raw_modifier_extension: Option<&super::super::codec::Value> = None;
        let mut raw_url: Option<&super::super::codec::Value> = None;
        let mut raw_url_element: Option<&super::super::codec::Value> = None;
        let mut raw_identifier: Option<&super::super::codec::Value> = None;
        let mut raw_version: Option<&super::super::codec::Value> = None;
        let mut raw_version_element: Option<&super::super::codec::Value> = None;
        let mut raw_name: Option<&super::super::codec::Value> = None;
        let mut raw_name_element: Option<&super::super::codec::Value> = None;
        let mut raw_title: Option<&super::super::codec::Value> = None;
        let mut raw_title_element: Option<&super::super::codec::Value> = None;
        let mut raw_status: Option<&super::super::codec::Value> = None;
        let mut raw_status_element: Option<&super::super::codec::Value> = None;
        let mut raw_experimental: Option<&super::super::codec::Value> = None;
        let mut raw_experimental_element: Option<&super::super::codec::Value> = None;
        let mut raw_date: Option<&super::super::codec::Value> = None;
        let mut raw_date_element: Option<&super::super::codec::Value> = None;
        let mut raw_publisher: Option<&super::super::codec::Value> = None;
        let mut raw_publisher_element: Option<&super::super::codec::Value> = None;
        let mut raw_description: Option<&super::super::codec::Value> = None;
        let mut raw_description_element: Option<&super::super::codec::Value> = None;
        let mut raw_purpose: Option<&super::super::codec::Value> = None;
        let mut raw_purpose_element: Option<&super::super::codec::Value> = None;
        let mut raw_usage: Option<&super::super::codec::Value> = None;
        let mut raw_usage_element: Option<&super::super::codec::Value> = None;
        let mut raw_approval_date: Option<&super::super::codec::Value> = None;
        let mut raw_approval_date_element: Option<&super::super::codec::Value> = None;
        let mut raw_last_review_date: Option<&super::super::codec::Value> = None;
        let mut raw_last_review_date_element: Option<&super::super::codec::Value> = None;
        let mut raw_effective_period: Option<&super::super::codec::Value> = None;
        let mut raw_use_context: Option<&super::super::codec::Value> = None;
        let mut raw_jurisdiction: Option<&super::super::codec::Value> = None;
        let mut raw_topic: Option<&super::super::codec::Value> = None;
        let mut raw_contributor: Option<&super::super::codec::Value> = None;
        let mut raw_contact: Option<&super::super::codec::Value> = None;
        let mut raw_copyright: Option<&super::super::codec::Value> = None;
        let mut raw_copyright_element: Option<&super::super::codec::Value> = None;
        let mut raw_related_artifact: Option<&super::super::codec::Value> = None;
        let mut raw_trigger: Option<&super::super::codec::Value> = None;
        let mut raw_data_requirement: Option<&super::super::codec::Value> = None;
        let mut raw_operation_definition: Option<&super::super::codec::Value> = None;
        for (key, value) in object {
            match key.as_str() {
                "resourceType" => {
                    if value.as_str() != Some("ServiceDefinition") {
                        return Err(path.error(super::super::codec::DecodeErrorKind::ResourceType));
                    }
                }
                "id" => {
                    raw_id = Some(value);
                }
                "_id" => {
                    raw_id_element = Some(value);
                }
                "meta" => {
                    raw_meta = Some(value);
                }
                "implicitRules" => {
                    raw_implicit_rules = Some(value);
                }
                "_implicitRules" => {
                    raw_implicit_rules_element = Some(value);
                }
                "language" => {
                    raw_language = Some(value);
                }
                "_language" => {
                    raw_language_element = Some(value);
                }
                "text" => {
                    raw_text = Some(value);
                }
                "contained" => {
                    raw_contained = Some(value);
                }
                "extension" => {
                    raw_extension = Some(value);
                }
                "modifierExtension" => {
                    raw_modifier_extension = Some(value);
                }
                "url" => {
                    raw_url = Some(value);
                }
                "_url" => {
                    raw_url_element = Some(value);
                }
                "identifier" => {
                    raw_identifier = Some(value);
                }
                "version" => {
                    raw_version = Some(value);
                }
                "_version" => {
                    raw_version_element = Some(value);
                }
                "name" => {
                    raw_name = Some(value);
                }
                "_name" => {
                    raw_name_element = Some(value);
                }
                "title" => {
                    raw_title = Some(value);
                }
                "_title" => {
                    raw_title_element = Some(value);
                }
                "status" => {
                    raw_status = Some(value);
                }
                "_status" => {
                    raw_status_element = Some(value);
                }
                "experimental" => {
                    raw_experimental = Some(value);
                }
                "_experimental" => {
                    raw_experimental_element = Some(value);
                }
                "date" => {
                    raw_date = Some(value);
                }
                "_date" => {
                    raw_date_element = Some(value);
                }
                "publisher" => {
                    raw_publisher = Some(value);
                }
                "_publisher" => {
                    raw_publisher_element = Some(value);
                }
                "description" => {
                    raw_description = Some(value);
                }
                "_description" => {
                    raw_description_element = Some(value);
                }
                "purpose" => {
                    raw_purpose = Some(value);
                }
                "_purpose" => {
                    raw_purpose_element = Some(value);
                }
                "usage" => {
                    raw_usage = Some(value);
                }
                "_usage" => {
                    raw_usage_element = Some(value);
                }
                "approvalDate" => {
                    raw_approval_date = Some(value);
                }
                "_approvalDate" => {
                    raw_approval_date_element = Some(value);
                }
                "lastReviewDate" => {
                    raw_last_review_date = Some(value);
                }
                "_lastReviewDate" => {
                    raw_last_review_date_element = Some(value);
                }
                "effectivePeriod" => {
                    raw_effective_period = Some(value);
                }
                "useContext" => {
                    raw_use_context = Some(value);
                }
                "jurisdiction" => {
                    raw_jurisdiction = Some(value);
                }
                "topic" => {
                    raw_topic = Some(value);
                }
                "contributor" => {
                    raw_contributor = Some(value);
                }
                "contact" => {
                    raw_contact = Some(value);
                }
                "copyright" => {
                    raw_copyright = Some(value);
                }
                "_copyright" => {
                    raw_copyright_element = Some(value);
                }
                "relatedArtifact" => {
                    raw_related_artifact = Some(value);
                }
                "trigger" => {
                    raw_trigger = Some(value);
                }
                "dataRequirement" => {
                    raw_data_requirement = Some(value);
                }
                "operationDefinition" => {
                    raw_operation_definition = Some(value);
                }
                other => {
                    return path.with(other, |path| {
                        Err(path.error(super::super::codec::DecodeErrorKind::UnknownProperty))
                    });
                }
            }
        }
        let field_id = match (raw_id, raw_id_element) {
            (None, None) => None,
            (value, element) => Some(path.with("id", |path| {
                super::super::codec::Primitive::from_json_parts(value, element, path)
            })?),
        };
        let field_meta = raw_meta
            .map(|value| {
                path.with("meta", |path| {
                    super::super::codec::Json::from_json(
                        super::super::codec::expect_object(
                            super::super::codec::expect_single(value, path)?,
                            path,
                        )?,
                        path,
                    )
                })
            })
            .transpose()?;
        let field_implicit_rules = match (raw_implicit_rules, raw_implicit_rules_element) {
            (None, None) => None,
            (value, element) => Some(path.with("implicitRules", |path| {
                super::super::codec::Primitive::from_json_parts(value, element, path)
            })?),
        };
        let field_language = match (raw_language, raw_language_element) {
            (None, None) => None,
            (value, element) => Some(path.with("language", |path| {
                super::super::codec::Primitive::from_json_parts(value, element, path)
            })?),
        };
        let field_text = raw_text
            .map(|value| {
                path.with("text", |path| {
                    super::super::codec::Json::from_json(
                        super::super::codec::expect_object(
                            super::super::codec::expect_single(value, path)?,
                            path,
                        )?,
                        path,
                    )
                })
            })
            .transpose()?;
        let mut field_contained = Vec::new();
        if let Some(raw) = raw_contained {
            for (index, value) in super::super::codec::expect_array(raw, path)?
                .iter()
                .enumerate()
            {
                field_contained.push(path.with_index("contained", index, |path| {
                    super::super::codec::Json::from_json(
                        super::super::codec::expect_object(value, path)?,
                        path,
                    )
                })?);
            }
        }
        let mut field_extension = Vec::new();
        if let Some(raw) = raw_extension {
            for (index, value) in super::super::codec::expect_array(raw, path)?
                .iter()
                .enumerate()
            {
                field_extension.push(path.with_index("extension", index, |path| {
                    super::super::codec::Json::from_json(
                        super::super::codec::expect_object(value, path)?,
                        path,
                    )
                })?);
            }
        }
        let mut field_modifier_extension = Vec::new();
        if let Some(raw) = raw_modifier_extension {
            for (index, value) in super::super::codec::expect_array(raw, path)?
                .iter()
                .enumerate()
            {
                field_modifier_extension.push(path.with_index(
                    "modifierExtension",
                    index,
                    |path| {
                        super::super::codec::Json::from_json(
                            super::super::codec::expect_object(value, path)?,
                            path,
                        )
                    },
                )?);
            }
        }
        let field_url = match (raw_url, raw_url_element) {
            (None, None) => None,
            (value, element) => Some(path.with("url", |path| {
                super::super::codec::Primitive::from_json_parts(value, element, path)
            })?),
        };
        let mut field_identifier = Vec::new();
        if let Some(raw) = raw_identifier {
            for (index, value) in super::super::codec::expect_array(raw, path)?
                .iter()
                .enumerate()
            {
                field_identifier.push(path.with_index("identifier", index, |path| {
                    super::super::codec::Json::from_json(
                        super::super::codec::expect_object(value, path)?,
                        path,
                    )
                })?);
            }
        }
        let field_version = match (raw_version, raw_version_element) {
            (None, None) => None,
            (value, element) => Some(path.with("version", |path| {
                super::super::codec::Primitive::from_json_parts(value, element, path)
            })?),
        };
        let field_name = match (raw_name, raw_name_element) {
            (None, None) => None,
            (value, element) => Some(path.with("name", |path| {
                super::super::codec::Primitive::from_json_parts(value, element, path)
            })?),
        };
        let field_title = match (raw_title, raw_title_element) {
            (None, None) => None,
            (value, element) => Some(path.with("title", |path| {
                super::super::codec::Primitive::from_json_parts(value, element, path)
            })?),
        };
        let field_status = path.with("status", |path| {
            super::super::codec::Primitive::from_json_parts(raw_status, raw_status_element, path)
        })?;
        let field_experimental = match (raw_experimental, raw_experimental_element) {
            (None, None) => None,
            (value, element) => Some(path.with("experimental", |path| {
                super::super::codec::Primitive::from_json_parts(value, element, path)
            })?),
        };
        let field_date = match (raw_date, raw_date_element) {
            (None, None) => None,
            (value, element) => Some(path.with("date", |path| {
                super::super::codec::Primitive::from_json_parts(value, element, path)
            })?),
        };
        let field_publisher = match (raw_publisher, raw_publisher_element) {
            (None, None) => None,
            (value, element) => Some(path.with("publisher", |path| {
                super::super::codec::Primitive::from_json_parts(value, element, path)
            })?),
        };
        let field_description = match (raw_description, raw_description_element) {
            (None, None) => None,
            (value, element) => Some(path.with("description", |path| {
                super::super::codec::Primitive::from_json_parts(value, element, path)
            })?),
        };
        let field_purpose = match (raw_purpose, raw_purpose_element) {
            (None, None) => None,
            (value, element) => Some(path.with("purpose", |path| {
                super::super::codec::Primitive::from_json_parts(value, element, path)
            })?),
        };
        let field_usage = match (raw_usage, raw_usage_element) {
            (None, None) => None,
            (value, element) => Some(path.with("usage", |path| {
                super::super::codec::Primitive::from_json_parts(value, element, path)
            })?),
        };
        let field_approval_date = match (raw_approval_date, raw_approval_date_element) {
            (None, None) => None,
            (value, element) => Some(path.with("approvalDate", |path| {
                super::super::codec::Primitive::from_json_parts(value, element, path)
            })?),
        };
        let field_last_review_date = match (raw_last_review_date, raw_last_review_date_element) {
            (None, None) => None,
            (value, element) => Some(path.with("lastReviewDate", |path| {
                super::super::codec::Primitive::from_json_parts(value, element, path)
            })?),
        };
        let field_effective_period = raw_effective_period
            .map(|value| {
                path.with("effectivePeriod", |path| {
                    super::super::codec::Json::from_json(
                        super::super::codec::expect_object(
                            super::super::codec::expect_single(value, path)?,
                            path,
                        )?,
                        path,
                    )
                })
            })
            .transpose()?;
        let mut field_use_context = Vec::new();
        if let Some(raw) = raw_use_context {
            for (index, value) in super::super::codec::expect_array(raw, path)?
                .iter()
                .enumerate()
            {
                field_use_context.push(path.with_index("useContext", index, |path| {
                    super::super::codec::Json::from_json(
                        super::super::codec::expect_object(value, path)?,
                        path,
                    )
                })?);
            }
        }
        let mut field_jurisdiction = Vec::new();
        if let Some(raw) = raw_jurisdiction {
            for (index, value) in super::super::codec::expect_array(raw, path)?
                .iter()
                .enumerate()
            {
                field_jurisdiction.push(path.with_index("jurisdiction", index, |path| {
                    super::super::codec::Json::from_json(
                        super::super::codec::expect_object(value, path)?,
                        path,
                    )
                })?);
            }
        }
        let mut field_topic = Vec::new();
        if let Some(raw) = raw_topic {
            for (index, value) in super::super::codec::expect_array(raw, path)?
                .iter()
                .enumerate()
            {
                field_topic.push(path.with_index("topic", index, |path| {
                    super::super::codec::Json::from_json(
                        super::super::codec::expect_object(value, path)?,
                        path,
                    )
                })?);
            }
        }
        let mut field_contributor = Vec::new();
        if let Some(raw) = raw_contributor {
            for (index, value) in super::super::codec::expect_array(raw, path)?
                .iter()
                .enumerate()
            {
                field_contributor.push(path.with_index("contributor", index, |path| {
                    super::super::codec::Json::from_json(
                        super::super::codec::expect_object(value, path)?,
                        path,
                    )
                })?);
            }
        }
        let mut field_contact = Vec::new();
        if let Some(raw) = raw_contact {
            for (index, value) in super::super::codec::expect_array(raw, path)?
                .iter()
                .enumerate()
            {
                field_contact.push(path.with_index("contact", index, |path| {
                    super::super::codec::Json::from_json(
                        super::super::codec::expect_object(value, path)?,
                        path,
                    )
                })?);
            }
        }
        let field_copyright = match (raw_copyright, raw_copyright_element) {
            (None, None) => None,
            (value, element) => Some(path.with("copyright", |path| {
                super::super::codec::Primitive::from_json_parts(value, element, path)
            })?),
        };
        let mut field_related_artifact = Vec::new();
        if let Some(raw) = raw_related_artifact {
            for (index, value) in super::super::codec::expect_array(raw, path)?
                .iter()
                .enumerate()
            {
                field_related_artifact.push(path.with_index("relatedArtifact", index, |path| {
                    super::super::codec::Json::from_json(
                        super::super::codec::expect_object(value, path)?,
                        path,
                    )
                })?);
            }
        }
        let mut field_trigger = Vec::new();
        if let Some(raw) = raw_trigger {
            for (index, value) in super::super::codec::expect_array(raw, path)?
                .iter()
                .enumerate()
            {
                field_trigger.push(path.with_index("trigger", index, |path| {
                    super::super::codec::Json::from_json(
                        super::super::codec::expect_object(value, path)?,
                        path,
                    )
                })?);
            }
        }
        let mut field_data_requirement = Vec::new();
        if let Some(raw) = raw_data_requirement {
            for (index, value) in super::super::codec::expect_array(raw, path)?
                .iter()
                .enumerate()
            {
                field_data_requirement.push(path.with_index("dataRequirement", index, |path| {
                    super::super::codec::Json::from_json(
                        super::super::codec::expect_object(value, path)?,
                        path,
                    )
                })?);
            }
        }
        let field_operation_definition = raw_operation_definition
            .map(|value| {
                path.with("operationDefinition", |path| {
                    super::super::codec::Json::from_json(
                        super::super::codec::expect_object(
                            super::super::codec::expect_single(value, path)?,
                            path,
                        )?,
                        path,
                    )
                })
            })
            .transpose()?;
        Ok(Self {
            id: field_id,
            meta: field_meta,
            implicit_rules: field_implicit_rules,
            language: field_language,
            text: field_text,
            contained: field_contained,
            extension: field_extension,
            modifier_extension: field_modifier_extension,
            url: field_url,
            identifier: field_identifier,
            version: field_version,
            name: field_name,
            title: field_title,
            status: field_status,
            experimental: field_experimental,
            date: field_date,
            publisher: field_publisher,
            description: field_description,
            purpose: field_purpose,
            usage: field_usage,
            approval_date: field_approval_date,
            last_review_date: field_last_review_date,
            effective_period: field_effective_period,
            use_context: field_use_context,
            jurisdiction: field_jurisdiction,
            topic: field_topic,
            contributor: field_contributor,
            contact: field_contact,
            copyright: field_copyright,
            related_artifact: field_related_artifact,
            trigger: field_trigger,
            data_requirement: field_data_requirement,
            operation_definition: field_operation_definition,
        })
    }
}

impl serde::Serialize for ServiceDefinition {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        let mut map = serde::Serializer::serialize_map(serializer, None)?;
        if let Some(item) = &self.approval_date {
            super::super::codec::element_entry(&mut map, "_approvalDate", item)?;
        }
        if let Some(item) = &self.copyright {
            super::super::codec::element_entry(&mut map, "_copyright", item)?;
        }
        if let Some(item) = &self.date {
            super::super::codec::element_entry(&mut map, "_date", item)?;
        }
        if let Some(item) = &self.description {
            super::super::codec::element_entry(&mut map, "_description", item)?;
        }
        if let Some(item) = &self.experimental {
            super::super::codec::element_entry(&mut map, "_experimental", item)?;
        }
        if let Some(item) = &self.id {
            super::super::codec::element_entry(&mut map, "_id", item)?;
        }
        if let Some(item) = &self.implicit_rules {
            super::super::codec::element_entry(&mut map, "_implicitRules", item)?;
        }
        if let Some(item) = &self.language {
            super::super::codec::element_entry(&mut map, "_language", item)?;
        }
        if let Some(item) = &self.last_review_date {
            super::super::codec::element_entry(&mut map, "_lastReviewDate", item)?;
        }
        if let Some(item) = &self.name {
            super::super::codec::element_entry(&mut map, "_name", item)?;
        }
        if let Some(item) = &self.publisher {
            super::super::codec::element_entry(&mut map, "_publisher", item)?;
        }
        if let Some(item) = &self.purpose {
            super::super::codec::element_entry(&mut map, "_purpose", item)?;
        }
        super::super::codec::element_entry(&mut map, "_status", &self.status)?;
        if let Some(item) = &self.title {
            super::super::codec::element_entry(&mut map, "_title", item)?;
        }
        if let Some(item) = &self.url {
            super::super::codec::element_entry(&mut map, "_url", item)?;
        }
        if let Some(item) = &self.usage {
            super::super::codec::element_entry(&mut map, "_usage", item)?;
        }
        if let Some(item) = &self.version {
            super::super::codec::element_entry(&mut map, "_version", item)?;
        }
        if let Some(item) = &self.approval_date {
            super::super::codec::value_entry(&mut map, "approvalDate", item)?;
        }
        if !self.contact.is_empty() {
            serde::ser::SerializeMap::serialize_entry(&mut map, "contact", &self.contact)?;
        }
        if !self.contained.is_empty() {
            serde::ser::SerializeMap::serialize_entry(&mut map, "contained", &self.contained)?;
        }
        if !self.contributor.is_empty() {
            serde::ser::SerializeMap::serialize_entry(&mut map, "contributor", &self.contributor)?;
        }
        if let Some(item) = &self.copyright {
            super::super::codec::value_entry(&mut map, "copyright", item)?;
        }
        if !self.data_requirement.is_empty() {
            serde::ser::SerializeMap::serialize_entry(
                &mut map,
                "dataRequirement",
                &self.data_requirement,
            )?;
        }
        if let Some(item) = &self.date {
            super::super::codec::value_entry(&mut map, "date", item)?;
        }
        if let Some(item) = &self.description {
            super::super::codec::value_entry(&mut map, "description", item)?;
        }
        if let Some(item) = &self.effective_period {
            serde::ser::SerializeMap::serialize_entry(&mut map, "effectivePeriod", item)?;
        }
        if let Some(item) = &self.experimental {
            super::super::codec::value_entry(&mut map, "experimental", item)?;
        }
        if !self.extension.is_empty() {
            serde::ser::SerializeMap::serialize_entry(&mut map, "extension", &self.extension)?;
        }
        if let Some(item) = &self.id {
            super::super::codec::value_entry(&mut map, "id", item)?;
        }
        if !self.identifier.is_empty() {
            serde::ser::SerializeMap::serialize_entry(&mut map, "identifier", &self.identifier)?;
        }
        if let Some(item) = &self.implicit_rules {
            super::super::codec::value_entry(&mut map, "implicitRules", item)?;
        }
        if !self.jurisdiction.is_empty() {
            serde::ser::SerializeMap::serialize_entry(
                &mut map,
                "jurisdiction",
                &self.jurisdiction,
            )?;
        }
        if let Some(item) = &self.language {
            super::super::codec::value_entry(&mut map, "language", item)?;
        }
        if let Some(item) = &self.last_review_date {
            super::super::codec::value_entry(&mut map, "lastReviewDate", item)?;
        }
        if let Some(item) = &self.meta {
            serde::ser::SerializeMap::serialize_entry(&mut map, "meta", item)?;
        }
        if !self.modifier_extension.is_empty() {
            serde::ser::SerializeMap::serialize_entry(
                &mut map,
                "modifierExtension",
                &self.modifier_extension,
            )?;
        }
        if let Some(item) = &self.name {
            super::super::codec::value_entry(&mut map, "name", item)?;
        }
        if let Some(item) = &self.operation_definition {
            serde::ser::SerializeMap::serialize_entry(&mut map, "operationDefinition", item)?;
        }
        if let Some(item) = &self.publisher {
            super::super::codec::value_entry(&mut map, "publisher", item)?;
        }
        if let Some(item) = &self.purpose {
            super::super::codec::value_entry(&mut map, "purpose", item)?;
        }
        if !self.related_artifact.is_empty() {
            serde::ser::SerializeMap::serialize_entry(
                &mut map,
                "relatedArtifact",
                &self.related_artifact,
            )?;
        }
        serde::ser::SerializeMap::serialize_entry(&mut map, "resourceType", "ServiceDefinition")?;
        super::super::codec::value_entry(&mut map, "status", &self.status)?;
        if let Some(item) = &self.text {
            serde::ser::SerializeMap::serialize_entry(&mut map, "text", item)?;
        }
        if let Some(item) = &self.title {
            super::super::codec::value_entry(&mut map, "title", item)?;
        }
        if !self.topic.is_empty() {
            serde::ser::SerializeMap::serialize_entry(&mut map, "topic", &self.topic)?;
        }
        if !self.trigger.is_empty() {
            serde::ser::SerializeMap::serialize_entry(&mut map, "trigger", &self.trigger)?;
        }
        if let Some(item) = &self.url {
            super::super::codec::value_entry(&mut map, "url", item)?;
        }
        if let Some(item) = &self.usage {
            super::super::codec::value_entry(&mut map, "usage", item)?;
        }
        if !self.use_context.is_empty() {
            serde::ser::SerializeMap::serialize_entry(&mut map, "useContext", &self.use_context)?;
        }
        if let Some(item) = &self.version {
            super::super::codec::value_entry(&mut map, "version", item)?;
        }
        serde::ser::SerializeMap::end(map)
    }
}

impl<'de> serde::Deserialize<'de> for ServiceDefinition {
    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("ServiceDefinition");
        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)
    }
}