fhirkit 0.1.0

FHIR R4 for Rust: typed models for every resource and datatype generated from the official specification, lossless JSON with path-precise validation, typed search queries, FHIRPath
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
// @generated by fhirkit-gen from hl7.fhir.r4.core 4.0.1. Do not edit.
//! The FHIR R4 `TestReport` resource.

#![allow(
    unused_imports,
    clippy::large_enum_variant,
    clippy::too_many_lines,
    clippy::doc_markdown
)]

use crate::decode::{
    choice_key, required, required_list, resource_type, Choice, Decoder, FhirJson, Obj, ObjWriter,
};
use crate::json::Json;
use crate::primitive::{Decimal, Kind, Primitive};
use crate::r4::*;

/// A summary of information based on the results of executing a TestScript.
///
/// FHIR path: `TestReport`.
#[cfg(feature = "specialized")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct TestReport {
    /// `id` (0..1): Logical id of this artifact
    pub id: Option<String>,
    /// `meta` (0..1): Metadata about the resource
    pub meta: Option<Meta>,
    /// `implicitRules` (0..1): A set of rules under which this content was created
    pub implicit_rules: Option<Primitive<String>>,
    /// `language` (0..1): Language of the resource content
    pub language: Option<Primitive<String>>,
    /// `text` (0..1): Text summary of the resource, for human interpretation
    pub text: Option<Narrative>,
    /// `contained` (0..*): Contained, inline Resources
    pub contained: Vec<Resource>,
    /// `extension` (0..*): Additional content defined by implementations
    pub extension: Vec<Extension>,
    /// `modifierExtension` (0..*): Extensions that cannot be ignored
    pub modifier_extension: Vec<Extension>,
    /// `identifier` (0..1): External identifier
    pub identifier: Option<Identifier>,
    /// `name` (0..1): Informal name of the executed TestScript
    pub name: Option<Primitive<String>>,
    /// `status` (1..1): completed | in-progress | waiting | stopped | entered-in-error
    pub status: Option<Primitive<String>>,
    /// `testScript` (1..1): Reference to the version-specific TestScript that was executed to produce this TestReport
    pub test_script: Option<Reference>,
    /// `result` (1..1): pass | fail | pending
    pub result: Option<Primitive<String>>,
    /// `score` (0..1): The final score (percentage of tests passed) resulting from the execution of the TestScript
    pub score: Option<Primitive<Decimal>>,
    /// `tester` (0..1): Name of the tester producing this report (Organization or individual)
    pub tester: Option<Primitive<String>>,
    /// `issued` (0..1): When the TestScript was executed and this TestReport was generated
    pub issued: Option<Primitive<String>>,
    /// `participant` (0..*): A participant in the test execution, either the execution engine, a client, or a server
    pub participant: Vec<TestReportParticipant>,
    /// `setup` (0..1): The results of the series of required setup operations before the tests were executed
    pub setup: Option<TestReportSetup>,
    /// `test` (0..*): A test executed from the test script
    pub test: Vec<TestReportTest>,
    /// `teardown` (0..1): The results of running the series of required clean up steps
    pub teardown: Option<TestReportTeardown>,
}

#[cfg(feature = "specialized")]
impl FhirJson for TestReport {
    const TYPE_NAME: &'static str = "TestReport";

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        resource_type(&mut o, d, "TestReport");
        let r = TestReport {
            id: o.string(d, "id"),
            meta: o.one(d, "meta"),
            implicit_rules: o.prim(d, "implicitRules", Kind::Uri),
            language: o.prim(d, "language", Kind::Code),
            text: o.one(d, "text"),
            contained: o.list(d, "contained"),
            extension: o.list(d, "extension"),
            modifier_extension: o.list(d, "modifierExtension"),
            identifier: o.one(d, "identifier"),
            name: o.prim(d, "name", Kind::String),
            status: o.prim(d, "status", Kind::Code),
            test_script: o.one(d, "testScript"),
            result: o.prim(d, "result", Kind::Code),
            score: o.prim(d, "score", Kind::Decimal),
            tester: o.prim(d, "tester", Kind::String),
            issued: o.prim(d, "issued", Kind::DateTime),
            participant: o.list(d, "participant"),
            setup: o.one(d, "setup"),
            test: o.list(d, "test"),
            teardown: o.one(d, "teardown"),
        };
        required(d, "status", &r.status);
        required(d, "testScript", &r.test_script);
        required(d, "result", &r.result);
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.raw("resourceType", Json::String("TestReport".into()));
        w.string("id", &self.id);
        w.one("meta", &self.meta);
        w.prim("implicitRules", &self.implicit_rules);
        w.prim("language", &self.language);
        w.one("text", &self.text);
        w.list("contained", &self.contained);
        w.list("extension", &self.extension);
        w.list("modifierExtension", &self.modifier_extension);
        w.one("identifier", &self.identifier);
        w.prim("name", &self.name);
        w.prim("status", &self.status);
        w.one("testScript", &self.test_script);
        w.prim("result", &self.result);
        w.prim("score", &self.score);
        w.prim("tester", &self.tester);
        w.prim("issued", &self.issued);
        w.list("participant", &self.participant);
        w.one("setup", &self.setup);
        w.list("test", &self.test);
        w.one("teardown", &self.teardown);
        w.finish()
    }
}

/// A participant in the test execution, either the execution engine, a client, or a server
///
/// FHIR path: `TestReport.participant`.
#[cfg(feature = "specialized")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct TestReportParticipant {
    /// `id` (0..1): Unique id for inter-element referencing
    pub id: Option<String>,
    /// `extension` (0..*): Additional content defined by implementations
    pub extension: Vec<Extension>,
    /// `modifierExtension` (0..*): Extensions that cannot be ignored even if unrecognized
    pub modifier_extension: Vec<Extension>,
    /// `type` (1..1): test-engine | client | server
    pub type_: Option<Primitive<String>>,
    /// `uri` (1..1): The uri of the participant. An absolute URL is preferred
    pub uri: Option<Primitive<String>>,
    /// `display` (0..1): The display name of the participant
    pub display: Option<Primitive<String>>,
}

#[cfg(feature = "specialized")]
impl FhirJson for TestReportParticipant {
    const TYPE_NAME: &'static str = "TestReportParticipant";

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        let r = TestReportParticipant {
            id: o.string(d, "id"),
            extension: o.list(d, "extension"),
            modifier_extension: o.list(d, "modifierExtension"),
            type_: o.prim(d, "type", Kind::Code),
            uri: o.prim(d, "uri", Kind::Uri),
            display: o.prim(d, "display", Kind::String),
        };
        required(d, "type", &r.type_);
        required(d, "uri", &r.uri);
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.string("id", &self.id);
        w.list("extension", &self.extension);
        w.list("modifierExtension", &self.modifier_extension);
        w.prim("type", &self.type_);
        w.prim("uri", &self.uri);
        w.prim("display", &self.display);
        w.finish()
    }
}

/// The results of the series of required setup operations before the tests were executed
///
/// FHIR path: `TestReport.setup`.
#[cfg(feature = "specialized")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct TestReportSetup {
    /// `id` (0..1): Unique id for inter-element referencing
    pub id: Option<String>,
    /// `extension` (0..*): Additional content defined by implementations
    pub extension: Vec<Extension>,
    /// `modifierExtension` (0..*): Extensions that cannot be ignored even if unrecognized
    pub modifier_extension: Vec<Extension>,
    /// `action` (1..*): A setup operation or assert that was executed
    pub action: Vec<TestReportSetupAction>,
}

#[cfg(feature = "specialized")]
impl FhirJson for TestReportSetup {
    const TYPE_NAME: &'static str = "TestReportSetup";

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        let r = TestReportSetup {
            id: o.string(d, "id"),
            extension: o.list(d, "extension"),
            modifier_extension: o.list(d, "modifierExtension"),
            action: o.list(d, "action"),
        };
        required_list(d, "action", &r.action, 1);
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.string("id", &self.id);
        w.list("extension", &self.extension);
        w.list("modifierExtension", &self.modifier_extension);
        w.list("action", &self.action);
        w.finish()
    }
}

/// A setup operation or assert that was executed
///
/// FHIR path: `TestReport.setup.action`.
#[cfg(feature = "specialized")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct TestReportSetupAction {
    /// `id` (0..1): Unique id for inter-element referencing
    pub id: Option<String>,
    /// `extension` (0..*): Additional content defined by implementations
    pub extension: Vec<Extension>,
    /// `modifierExtension` (0..*): Extensions that cannot be ignored even if unrecognized
    pub modifier_extension: Vec<Extension>,
    /// `operation` (0..1): The operation to perform
    pub operation: Option<TestReportSetupActionOperation>,
    /// `assert` (0..1): The assertion to perform
    pub assert: Option<TestReportSetupActionAssert>,
}

#[cfg(feature = "specialized")]
impl FhirJson for TestReportSetupAction {
    const TYPE_NAME: &'static str = "TestReportSetupAction";

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        let r = TestReportSetupAction {
            id: o.string(d, "id"),
            extension: o.list(d, "extension"),
            modifier_extension: o.list(d, "modifierExtension"),
            operation: o.one(d, "operation"),
            assert: o.one(d, "assert"),
        };
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.string("id", &self.id);
        w.list("extension", &self.extension);
        w.list("modifierExtension", &self.modifier_extension);
        w.one("operation", &self.operation);
        w.one("assert", &self.assert);
        w.finish()
    }
}

/// The operation to perform
///
/// FHIR path: `TestReport.setup.action.operation`.
#[cfg(feature = "specialized")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct TestReportSetupActionOperation {
    /// `id` (0..1): Unique id for inter-element referencing
    pub id: Option<String>,
    /// `extension` (0..*): Additional content defined by implementations
    pub extension: Vec<Extension>,
    /// `modifierExtension` (0..*): Extensions that cannot be ignored even if unrecognized
    pub modifier_extension: Vec<Extension>,
    /// `result` (1..1): pass | skip | fail | warning | error
    pub result: Option<Primitive<String>>,
    /// `message` (0..1): A message associated with the result
    pub message: Option<Primitive<String>>,
    /// `detail` (0..1): A link to further details on the result
    pub detail: Option<Primitive<String>>,
}

#[cfg(feature = "specialized")]
impl FhirJson for TestReportSetupActionOperation {
    const TYPE_NAME: &'static str = "TestReportSetupActionOperation";

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        let r = TestReportSetupActionOperation {
            id: o.string(d, "id"),
            extension: o.list(d, "extension"),
            modifier_extension: o.list(d, "modifierExtension"),
            result: o.prim(d, "result", Kind::Code),
            message: o.prim(d, "message", Kind::Markdown),
            detail: o.prim(d, "detail", Kind::Uri),
        };
        required(d, "result", &r.result);
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.string("id", &self.id);
        w.list("extension", &self.extension);
        w.list("modifierExtension", &self.modifier_extension);
        w.prim("result", &self.result);
        w.prim("message", &self.message);
        w.prim("detail", &self.detail);
        w.finish()
    }
}

/// The assertion to perform
///
/// FHIR path: `TestReport.setup.action.assert`.
#[cfg(feature = "specialized")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct TestReportSetupActionAssert {
    /// `id` (0..1): Unique id for inter-element referencing
    pub id: Option<String>,
    /// `extension` (0..*): Additional content defined by implementations
    pub extension: Vec<Extension>,
    /// `modifierExtension` (0..*): Extensions that cannot be ignored even if unrecognized
    pub modifier_extension: Vec<Extension>,
    /// `result` (1..1): pass | skip | fail | warning | error
    pub result: Option<Primitive<String>>,
    /// `message` (0..1): A message associated with the result
    pub message: Option<Primitive<String>>,
    /// `detail` (0..1): A link to further details on the result
    pub detail: Option<Primitive<String>>,
}

#[cfg(feature = "specialized")]
impl FhirJson for TestReportSetupActionAssert {
    const TYPE_NAME: &'static str = "TestReportSetupActionAssert";

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        let r = TestReportSetupActionAssert {
            id: o.string(d, "id"),
            extension: o.list(d, "extension"),
            modifier_extension: o.list(d, "modifierExtension"),
            result: o.prim(d, "result", Kind::Code),
            message: o.prim(d, "message", Kind::Markdown),
            detail: o.prim(d, "detail", Kind::String),
        };
        required(d, "result", &r.result);
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.string("id", &self.id);
        w.list("extension", &self.extension);
        w.list("modifierExtension", &self.modifier_extension);
        w.prim("result", &self.result);
        w.prim("message", &self.message);
        w.prim("detail", &self.detail);
        w.finish()
    }
}

/// A test executed from the test script
///
/// FHIR path: `TestReport.test`.
#[cfg(feature = "specialized")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct TestReportTest {
    /// `id` (0..1): Unique id for inter-element referencing
    pub id: Option<String>,
    /// `extension` (0..*): Additional content defined by implementations
    pub extension: Vec<Extension>,
    /// `modifierExtension` (0..*): Extensions that cannot be ignored even if unrecognized
    pub modifier_extension: Vec<Extension>,
    /// `name` (0..1): Tracking/logging name of this test
    pub name: Option<Primitive<String>>,
    /// `description` (0..1): Tracking/reporting short description of the test
    pub description: Option<Primitive<String>>,
    /// `action` (1..*): A test operation or assert that was performed
    pub action: Vec<TestReportTestAction>,
}

#[cfg(feature = "specialized")]
impl FhirJson for TestReportTest {
    const TYPE_NAME: &'static str = "TestReportTest";

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        let r = TestReportTest {
            id: o.string(d, "id"),
            extension: o.list(d, "extension"),
            modifier_extension: o.list(d, "modifierExtension"),
            name: o.prim(d, "name", Kind::String),
            description: o.prim(d, "description", Kind::String),
            action: o.list(d, "action"),
        };
        required_list(d, "action", &r.action, 1);
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.string("id", &self.id);
        w.list("extension", &self.extension);
        w.list("modifierExtension", &self.modifier_extension);
        w.prim("name", &self.name);
        w.prim("description", &self.description);
        w.list("action", &self.action);
        w.finish()
    }
}

/// A test operation or assert that was performed
///
/// FHIR path: `TestReport.test.action`.
#[cfg(feature = "specialized")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct TestReportTestAction {
    /// `id` (0..1): Unique id for inter-element referencing
    pub id: Option<String>,
    /// `extension` (0..*): Additional content defined by implementations
    pub extension: Vec<Extension>,
    /// `modifierExtension` (0..*): Extensions that cannot be ignored even if unrecognized
    pub modifier_extension: Vec<Extension>,
    /// `operation` (0..1): The operation performed
    pub operation: Option<TestReportSetupActionOperation>,
    /// `assert` (0..1): The assertion performed
    pub assert: Option<TestReportSetupActionAssert>,
}

#[cfg(feature = "specialized")]
impl FhirJson for TestReportTestAction {
    const TYPE_NAME: &'static str = "TestReportTestAction";

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        let r = TestReportTestAction {
            id: o.string(d, "id"),
            extension: o.list(d, "extension"),
            modifier_extension: o.list(d, "modifierExtension"),
            operation: o.one(d, "operation"),
            assert: o.one(d, "assert"),
        };
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.string("id", &self.id);
        w.list("extension", &self.extension);
        w.list("modifierExtension", &self.modifier_extension);
        w.one("operation", &self.operation);
        w.one("assert", &self.assert);
        w.finish()
    }
}

/// The results of running the series of required clean up steps
///
/// FHIR path: `TestReport.teardown`.
#[cfg(feature = "specialized")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct TestReportTeardown {
    /// `id` (0..1): Unique id for inter-element referencing
    pub id: Option<String>,
    /// `extension` (0..*): Additional content defined by implementations
    pub extension: Vec<Extension>,
    /// `modifierExtension` (0..*): Extensions that cannot be ignored even if unrecognized
    pub modifier_extension: Vec<Extension>,
    /// `action` (1..*): One or more teardown operations performed
    pub action: Vec<TestReportTeardownAction>,
}

#[cfg(feature = "specialized")]
impl FhirJson for TestReportTeardown {
    const TYPE_NAME: &'static str = "TestReportTeardown";

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        let r = TestReportTeardown {
            id: o.string(d, "id"),
            extension: o.list(d, "extension"),
            modifier_extension: o.list(d, "modifierExtension"),
            action: o.list(d, "action"),
        };
        required_list(d, "action", &r.action, 1);
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.string("id", &self.id);
        w.list("extension", &self.extension);
        w.list("modifierExtension", &self.modifier_extension);
        w.list("action", &self.action);
        w.finish()
    }
}

/// One or more teardown operations performed
///
/// FHIR path: `TestReport.teardown.action`.
#[cfg(feature = "specialized")]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct TestReportTeardownAction {
    /// `id` (0..1): Unique id for inter-element referencing
    pub id: Option<String>,
    /// `extension` (0..*): Additional content defined by implementations
    pub extension: Vec<Extension>,
    /// `modifierExtension` (0..*): Extensions that cannot be ignored even if unrecognized
    pub modifier_extension: Vec<Extension>,
    /// `operation` (1..1): The teardown operation performed
    pub operation: Option<TestReportSetupActionOperation>,
}

#[cfg(feature = "specialized")]
impl FhirJson for TestReportTeardownAction {
    const TYPE_NAME: &'static str = "TestReportTeardownAction";

    fn decode(v: &Json, d: &mut Decoder) -> Option<Self> {
        let mut o = Obj::new(v, d)?;
        let r = TestReportTeardownAction {
            id: o.string(d, "id"),
            extension: o.list(d, "extension"),
            modifier_extension: o.list(d, "modifierExtension"),
            operation: o.one(d, "operation"),
        };
        required(d, "operation", &r.operation);
        o.finish(d);
        Some(r)
    }

    fn encode(&self) -> Json {
        let mut w = ObjWriter::new();
        w.string("id", &self.id);
        w.list("extension", &self.extension);
        w.list("modifierExtension", &self.modifier_extension);
        w.one("operation", &self.operation);
        w.finish()
    }
}