/
careplan.py
878 lines (813 loc) · 31.4 KB
/
careplan.py
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
# -*- coding: utf-8 -*-
"""
Profile: http://hl7.org/fhir/StructureDefinition/CarePlan
Release: R4
Version: 4.0.1
Build ID: 9346c8cc45
Last updated: 2019-11-01T09:29:23.356+11:00
"""
from typing import Any, Dict
from typing import List as ListType
from typing import Union
from pydantic import Field, root_validator
from . import backboneelement, domainresource, fhirtypes
class CarePlan(domainresource.DomainResource):
"""Disclaimer: Any field name ends with ``__ext`` does't part of
Resource StructureDefinition, instead used to enable Extensibility feature
for FHIR Primitive Data Types.
Healthcare plan for patient or group.
Describes the intention of how one or more practitioners intend to deliver
care for a particular patient, group or community for a period of time,
possibly limited to care for a specific condition or set of conditions.
"""
resource_type = Field("CarePlan", const=True)
activity: ListType[fhirtypes.CarePlanActivityType] = Field(
None,
alias="activity",
title="Action to occur as part of plan",
description=(
"Identifies a planned action to occur as part of the plan. For "
"example, a medication to be used, lab tests to perform, self-"
"monitoring, education, etc."
),
# if property is element of this resource.
element_property=True,
)
addresses: ListType[fhirtypes.ReferenceType] = Field(
None,
alias="addresses",
title="Health issues this plan addresses",
description=(
"Identifies the conditions/problems/concerns/diagnoses/etc. whose "
"management and/or mitigation are handled by this plan."
),
# if property is element of this resource.
element_property=True,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=["Condition"],
)
author: fhirtypes.ReferenceType = Field(
None,
alias="author",
title="Who is the designated responsible party",
description=(
"When populated, the author is responsible for the care plan. The care"
" plan is attributed to the author."
),
# if property is element of this resource.
element_property=True,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=[
"Patient",
"Practitioner",
"PractitionerRole",
"Device",
"RelatedPerson",
"Organization",
"CareTeam",
],
)
basedOn: ListType[fhirtypes.ReferenceType] = Field(
None,
alias="basedOn",
title="Fulfills CarePlan",
description="A care plan that is fulfilled in whole or in part by this care plan.",
# if property is element of this resource.
element_property=True,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=["CarePlan"],
)
careTeam: ListType[fhirtypes.ReferenceType] = Field(
None,
alias="careTeam",
title="Who's involved in plan?",
description=(
"Identifies all people and organizations who are expected to be "
"involved in the care envisioned by this plan."
),
# if property is element of this resource.
element_property=True,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=["CareTeam"],
)
category: ListType[fhirtypes.CodeableConceptType] = Field(
None,
alias="category",
title="Type of plan",
description=(
'Identifies what "kind" of plan this is to support differentiation '
'between multiple co-existing plans; e.g. "Home health", "psychiatric",'
' "asthma", "disease management", "wellness plan", etc.'
),
# if property is element of this resource.
element_property=True,
)
contributor: ListType[fhirtypes.ReferenceType] = Field(
None,
alias="contributor",
title="Who provided the content of the care plan",
description=(
"Identifies the individual(s) or organization who provided the contents"
" of the care plan."
),
# if property is element of this resource.
element_property=True,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=[
"Patient",
"Practitioner",
"PractitionerRole",
"Device",
"RelatedPerson",
"Organization",
"CareTeam",
],
)
created: fhirtypes.DateTime = Field(
None,
alias="created",
title="Date record was first recorded",
description=(
"Represents when this particular CarePlan record was created in the "
"system, which is often a system-generated date."
),
# if property is element of this resource.
element_property=True,
)
created__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
None, alias="_created", title="Extension field for ``created``."
)
description: fhirtypes.String = Field(
None,
alias="description",
title="Summary of nature of plan",
description="A description of the scope and nature of the plan.",
# if property is element of this resource.
element_property=True,
)
description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
None, alias="_description", title="Extension field for ``description``."
)
encounter: fhirtypes.ReferenceType = Field(
None,
alias="encounter",
title="Encounter created as part of",
description=(
"The Encounter during which this CarePlan was created or to which the "
"creation of this record is tightly associated."
),
# if property is element of this resource.
element_property=True,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=["Encounter"],
)
goal: ListType[fhirtypes.ReferenceType] = Field(
None,
alias="goal",
title="Desired outcome of plan",
description="Describes the intended objective(s) of carrying out the care plan.",
# if property is element of this resource.
element_property=True,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=["Goal"],
)
identifier: ListType[fhirtypes.IdentifierType] = Field(
None,
alias="identifier",
title="External Ids for this plan",
description=(
"Business identifiers assigned to this care plan by the performer or "
"other systems which remain constant as the resource is updated and "
"propagates from server to server."
),
# if property is element of this resource.
element_property=True,
)
instantiatesCanonical: ListType[fhirtypes.Canonical] = Field(
None,
alias="instantiatesCanonical",
title="Instantiates FHIR protocol or definition",
description=(
"The URL pointing to a FHIR-defined protocol, guideline, questionnaire "
"or other definition that is adhered to in whole or in part by this "
"CarePlan."
),
# if property is element of this resource.
element_property=True,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=[
"PlanDefinition",
"Questionnaire",
"Measure",
"ActivityDefinition",
"OperationDefinition",
],
)
instantiatesCanonical__ext: ListType[
Union[fhirtypes.FHIRPrimitiveExtensionType, None]
] = Field(
None,
alias="_instantiatesCanonical",
title="Extension field for ``instantiatesCanonical``.",
)
instantiatesUri: ListType[fhirtypes.Uri] = Field(
None,
alias="instantiatesUri",
title="Instantiates external protocol or definition",
description=(
"The URL pointing to an externally maintained protocol, guideline, "
"questionnaire or other definition that is adhered to in whole or in "
"part by this CarePlan."
),
# if property is element of this resource.
element_property=True,
)
instantiatesUri__ext: ListType[
Union[fhirtypes.FHIRPrimitiveExtensionType, None]
] = Field(
None, alias="_instantiatesUri", title="Extension field for ``instantiatesUri``."
)
intent: fhirtypes.Code = Field(
...,
alias="intent",
title="proposal | plan | order | option",
description=(
"Indicates the level of authority/intentionality associated with the "
"care plan and where the care plan fits into the workflow chain."
),
# if property is element of this resource.
element_property=True,
# note: Enum values can be used in validation,
# but use in your own responsibilities, read official FHIR documentation.
enum_values=["proposal", "plan", "order", "option"],
)
intent__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
None, alias="_intent", title="Extension field for ``intent``."
)
note: ListType[fhirtypes.AnnotationType] = Field(
None,
alias="note",
title="Comments about the plan",
description="General notes about the care plan not covered elsewhere.",
# if property is element of this resource.
element_property=True,
)
partOf: ListType[fhirtypes.ReferenceType] = Field(
None,
alias="partOf",
title="Part of referenced CarePlan",
description=(
"A larger care plan of which this particular care plan is a component "
"or step."
),
# if property is element of this resource.
element_property=True,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=["CarePlan"],
)
period: fhirtypes.PeriodType = Field(
None,
alias="period",
title="Time period plan covers",
description=(
"Indicates when the plan did (or is intended to) come into effect and "
"end."
),
# if property is element of this resource.
element_property=True,
)
replaces: ListType[fhirtypes.ReferenceType] = Field(
None,
alias="replaces",
title="CarePlan replaced by this CarePlan",
description=(
"Completed or terminated care plan whose function is taken by this new "
"care plan."
),
# if property is element of this resource.
element_property=True,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=["CarePlan"],
)
status: fhirtypes.Code = Field(
...,
alias="status",
title=(
"draft | active | on-hold | revoked | completed | entered-in-error | "
"unknown"
),
description=(
"Indicates whether the plan is currently being acted upon, represents "
"future intentions or is now a historical record."
),
# if property is element of this resource.
element_property=True,
# note: Enum values can be used in validation,
# but use in your own responsibilities, read official FHIR documentation.
enum_values=[
"draft",
"active",
"on-hold",
"revoked",
"completed",
"entered-in-error",
"unknown",
],
)
status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
None, alias="_status", title="Extension field for ``status``."
)
subject: fhirtypes.ReferenceType = Field(
...,
alias="subject",
title="Who the care plan is for",
description=(
"Identifies the patient or group whose intended care is described by "
"the plan."
),
# if property is element of this resource.
element_property=True,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=["Patient", "Group"],
)
supportingInfo: ListType[fhirtypes.ReferenceType] = Field(
None,
alias="supportingInfo",
title="Information considered as part of plan",
description=(
"Identifies portions of the patient's record that specifically "
"influenced the formation of the plan. These might include "
"comorbidities, recent procedures, limitations, recent assessments, "
"etc."
),
# if property is element of this resource.
element_property=True,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=["Resource"],
)
title: fhirtypes.String = Field(
None,
alias="title",
title="Human-friendly name for the care plan",
description=None,
# if property is element of this resource.
element_property=True,
)
title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
None, alias="_title", title="Extension field for ``title``."
)
class CarePlanActivity(backboneelement.BackboneElement):
"""Disclaimer: Any field name ends with ``__ext`` does't part of
Resource StructureDefinition, instead used to enable Extensibility feature
for FHIR Primitive Data Types.
Action to occur as part of plan.
Identifies a planned action to occur as part of the plan. For example, a
medication to be used, lab tests to perform, self-monitoring, education,
etc.
"""
resource_type = Field("CarePlanActivity", const=True)
detail: fhirtypes.CarePlanActivityDetailType = Field(
None,
alias="detail",
title="In-line definition of activity",
description=(
"A simple summary of a planned activity suitable for a general care "
"plan system (e.g. form driven) that doesn't know about specific "
"resources such as procedure etc."
),
# if property is element of this resource.
element_property=True,
)
outcomeCodeableConcept: ListType[fhirtypes.CodeableConceptType] = Field(
None,
alias="outcomeCodeableConcept",
title="Results of the activity",
description=(
"Identifies the outcome at the point when the status of the activity is"
" assessed. For example, the outcome of an education activity could be"
" patient understands (or not)."
),
# if property is element of this resource.
element_property=True,
)
outcomeReference: ListType[fhirtypes.ReferenceType] = Field(
None,
alias="outcomeReference",
title="Appointment, Encounter, Procedure, etc.",
description=(
"Details of the outcome or action resulting from the activity. The "
'reference to an "event" resource, such as Procedure or Encounter or '
"Observation, is the result/outcome of the activity itself. The "
"activity can be conveyed using CarePlan.activity.detail OR using the "
"CarePlan.activity.reference (a reference to a \u201crequest\u201d resource)."
),
# if property is element of this resource.
element_property=True,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=["Resource"],
)
progress: ListType[fhirtypes.AnnotationType] = Field(
None,
alias="progress",
title="Comments about the activity status/progress",
description="Notes about the adherence/status/progress of the activity.",
# if property is element of this resource.
element_property=True,
)
reference: fhirtypes.ReferenceType = Field(
None,
alias="reference",
title="Activity details defined in specific resource",
description=(
"The details of the proposed activity represented in a specific "
"resource."
),
# if property is element of this resource.
element_property=True,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=[
"Appointment",
"CommunicationRequest",
"DeviceRequest",
"MedicationRequest",
"NutritionOrder",
"Task",
"ServiceRequest",
"VisionPrescription",
"RequestGroup",
],
)
class CarePlanActivityDetail(backboneelement.BackboneElement):
"""Disclaimer: Any field name ends with ``__ext`` does't part of
Resource StructureDefinition, instead used to enable Extensibility feature
for FHIR Primitive Data Types.
In-line definition of activity.
A simple summary of a planned activity suitable for a general care plan
system (e.g. form driven) that doesn't know about specific resources such
as procedure etc.
"""
resource_type = Field("CarePlanActivityDetail", const=True)
code: fhirtypes.CodeableConceptType = Field(
None,
alias="code",
title="Detail type of activity",
description=(
"Detailed description of the type of planned activity; e.g. what lab "
"test, what procedure, what kind of encounter."
),
# if property is element of this resource.
element_property=True,
)
dailyAmount: fhirtypes.QuantityType = Field(
None,
alias="dailyAmount",
title="How to consume/day?",
description="Identifies the quantity expected to be consumed in a given day.",
# if property is element of this resource.
element_property=True,
)
description: fhirtypes.String = Field(
None,
alias="description",
title="Extra info describing activity to perform",
description=(
"This provides a textual description of constraints on the intended "
"activity occurrence, including relation to other activities. It may "
"also include objectives, pre-conditions and end-conditions. Finally, "
"it may convey specifics about the activity such as body site, method, "
"route, etc."
),
# if property is element of this resource.
element_property=True,
)
description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
None, alias="_description", title="Extension field for ``description``."
)
doNotPerform: bool = Field(
None,
alias="doNotPerform",
title="If true, activity is prohibiting action",
description=(
"If true, indicates that the described activity is one that must NOT be"
" engaged in when following the plan. If false, or missing, indicates "
"that the described activity is one that should be engaged in when "
"following the plan."
),
# if property is element of this resource.
element_property=True,
)
doNotPerform__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
None, alias="_doNotPerform", title="Extension field for ``doNotPerform``."
)
goal: ListType[fhirtypes.ReferenceType] = Field(
None,
alias="goal",
title="Goals this activity relates to",
description=(
"Internal reference that identifies the goals that this activity is "
"intended to contribute towards meeting."
),
# if property is element of this resource.
element_property=True,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=["Goal"],
)
instantiatesCanonical: ListType[fhirtypes.Canonical] = Field(
None,
alias="instantiatesCanonical",
title="Instantiates FHIR protocol or definition",
description=(
"The URL pointing to a FHIR-defined protocol, guideline, questionnaire "
"or other definition that is adhered to in whole or in part by this "
"CarePlan activity."
),
# if property is element of this resource.
element_property=True,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=[
"PlanDefinition",
"ActivityDefinition",
"Questionnaire",
"Measure",
"OperationDefinition",
],
)
instantiatesCanonical__ext: ListType[
Union[fhirtypes.FHIRPrimitiveExtensionType, None]
] = Field(
None,
alias="_instantiatesCanonical",
title="Extension field for ``instantiatesCanonical``.",
)
instantiatesUri: ListType[fhirtypes.Uri] = Field(
None,
alias="instantiatesUri",
title="Instantiates external protocol or definition",
description=(
"The URL pointing to an externally maintained protocol, guideline, "
"questionnaire or other definition that is adhered to in whole or in "
"part by this CarePlan activity."
),
# if property is element of this resource.
element_property=True,
)
instantiatesUri__ext: ListType[
Union[fhirtypes.FHIRPrimitiveExtensionType, None]
] = Field(
None, alias="_instantiatesUri", title="Extension field for ``instantiatesUri``."
)
kind: fhirtypes.Code = Field(
None,
alias="kind",
title=(
"Appointment | CommunicationRequest | DeviceRequest | MedicationRequest"
" | NutritionOrder | Task | ServiceRequest | VisionPrescription"
),
description=(
"A description of the kind of resource the in-line definition of a care"
" plan activity is representing. The CarePlan.activity.detail is an "
"in-line definition when a resource is not referenced using "
"CarePlan.activity.reference. For example, a MedicationRequest, a "
"ServiceRequest, or a CommunicationRequest."
),
# if property is element of this resource.
element_property=True,
# note: Enum values can be used in validation,
# but use in your own responsibilities, read official FHIR documentation.
enum_values=[
"Appointment",
"CommunicationRequest",
"DeviceRequest",
"MedicationRequest",
"NutritionOrder",
"Task",
"ServiceRequest",
"VisionPrescription",
],
)
kind__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
None, alias="_kind", title="Extension field for ``kind``."
)
location: fhirtypes.ReferenceType = Field(
None,
alias="location",
title="Where it should happen",
description=(
"Identifies the facility where the activity will occur; e.g. home, "
"hospital, specific clinic, etc."
),
# if property is element of this resource.
element_property=True,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=["Location"],
)
performer: ListType[fhirtypes.ReferenceType] = Field(
None,
alias="performer",
title="Who will be responsible?",
description="Identifies who's expected to be involved in the activity.",
# if property is element of this resource.
element_property=True,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=[
"Practitioner",
"PractitionerRole",
"Organization",
"RelatedPerson",
"Patient",
"CareTeam",
"HealthcareService",
"Device",
],
)
productCodeableConcept: fhirtypes.CodeableConceptType = Field(
None,
alias="productCodeableConcept",
title="What is to be administered/supplied",
description=(
"Identifies the food, drug or other product to be consumed or supplied "
"in the activity."
),
# if property is element of this resource.
element_property=True,
# Choice of Data Types. i.e product[x]
one_of_many="product",
one_of_many_required=False,
)
productReference: fhirtypes.ReferenceType = Field(
None,
alias="productReference",
title="What is to be administered/supplied",
description=(
"Identifies the food, drug or other product to be consumed or supplied "
"in the activity."
),
# if property is element of this resource.
element_property=True,
# Choice of Data Types. i.e product[x]
one_of_many="product",
one_of_many_required=False,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=["Medication", "Substance"],
)
quantity: fhirtypes.QuantityType = Field(
None,
alias="quantity",
title="How much to administer/supply/consume",
description=(
"Identifies the quantity expected to be supplied, administered or "
"consumed by the subject."
),
# if property is element of this resource.
element_property=True,
)
reasonCode: ListType[fhirtypes.CodeableConceptType] = Field(
None,
alias="reasonCode",
title="Why activity should be done or why activity was prohibited",
description=(
"Provides the rationale that drove the inclusion of this particular "
"activity as part of the plan or the reason why the activity was "
"prohibited."
),
# if property is element of this resource.
element_property=True,
)
reasonReference: ListType[fhirtypes.ReferenceType] = Field(
None,
alias="reasonReference",
title="Why activity is needed",
description=(
"Indicates another resource, such as the health condition(s), whose "
"existence justifies this request and drove the inclusion of this "
"particular activity as part of the plan."
),
# if property is element of this resource.
element_property=True,
# note: Listed Resource Type(s) should be allowed as Reference.
enum_reference_types=[
"Condition",
"Observation",
"DiagnosticReport",
"DocumentReference",
],
)
scheduledPeriod: fhirtypes.PeriodType = Field(
None,
alias="scheduledPeriod",
title="When activity is to occur",
description=(
"The period, timing or frequency upon which the described activity is "
"to occur."
),
# if property is element of this resource.
element_property=True,
# Choice of Data Types. i.e scheduled[x]
one_of_many="scheduled",
one_of_many_required=False,
)
scheduledString: fhirtypes.String = Field(
None,
alias="scheduledString",
title="When activity is to occur",
description=(
"The period, timing or frequency upon which the described activity is "
"to occur."
),
# if property is element of this resource.
element_property=True,
# Choice of Data Types. i.e scheduled[x]
one_of_many="scheduled",
one_of_many_required=False,
)
scheduledString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
None, alias="_scheduledString", title="Extension field for ``scheduledString``."
)
scheduledTiming: fhirtypes.TimingType = Field(
None,
alias="scheduledTiming",
title="When activity is to occur",
description=(
"The period, timing or frequency upon which the described activity is "
"to occur."
),
# if property is element of this resource.
element_property=True,
# Choice of Data Types. i.e scheduled[x]
one_of_many="scheduled",
one_of_many_required=False,
)
status: fhirtypes.Code = Field(
...,
alias="status",
title=(
"not-started | scheduled | in-progress | on-hold | completed | "
"cancelled | stopped | unknown | entered-in-error"
),
description="Identifies what progress is being made for the specific activity.",
# if property is element of this resource.
element_property=True,
# note: Enum values can be used in validation,
# but use in your own responsibilities, read official FHIR documentation.
enum_values=[
"not-started",
"scheduled",
"in-progress",
"on-hold",
"completed",
"cancelled",
"stopped",
"unknown",
"entered-in-error",
],
)
status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field(
None, alias="_status", title="Extension field for ``status``."
)
statusReason: fhirtypes.CodeableConceptType = Field(
None,
alias="statusReason",
title="Reason for current status",
description=(
"Provides reason why the activity isn't yet started, is on hold, was "
"cancelled, etc."
),
# if property is element of this resource.
element_property=True,
)
@root_validator(pre=True)
def validate_one_of_many(cls, values: Dict[str, Any]) -> Dict[str, Any]:
"""https://www.hl7.org/fhir/formats.html#choice
A few elements have a choice of more than one data type for their content.
All such elements have a name that takes the form nnn[x].
The "nnn" part of the name is constant, and the "[x]" is replaced with
the title-cased name of the type that is actually used.
The table view shows each of these names explicitly.
Elements that have a choice of data type cannot repeat - they must have a
maximum cardinality of 1. When constructing an instance of an element with a
choice of types, the authoring system must create a single element with a
data type chosen from among the list of permitted data types.
"""
one_of_many_fields = {
"product": ["productCodeableConcept", "productReference"],
"scheduled": ["scheduledPeriod", "scheduledString", "scheduledTiming"],
}
for prefix, fields in one_of_many_fields.items():
assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix
required = (
cls.__fields__[fields[0]].field_info.extra["one_of_many_required"]
is True
)
found = False
for field in fields:
if field in values and values[field] is not None:
if found is True:
raise ValueError(
"Any of one field value is expected from "
f"this list {fields}, but got multiple!"
)
else:
found = True
if required is True and found is False:
raise ValueError(f"Expect any of field value from this list {fields}.")
return values