1 | <?php |
||
2 | /** |
||
3 | * The MIT License |
||
4 | * |
||
5 | * Copyright 2017 Julien Fastré <[email protected]>. |
||
6 | * |
||
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
||
8 | * of this software and associated documentation files (the "Software"), to deal |
||
9 | * in the Software without restriction, including without limitation the rights |
||
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||
11 | * copies of the Software, and to permit persons to whom the Software is |
||
12 | * furnished to do so, subject to the following conditions: |
||
13 | * |
||
14 | * The above copyright notice and this permission notice shall be included in |
||
15 | * all copies or substantial portions of the Software. |
||
16 | * |
||
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE |
||
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||
23 | * THE SOFTWARE. |
||
24 | */ |
||
25 | |||
26 | namespace i3Soft\CDA\Elements; |
||
27 | |||
28 | use i3Soft\CDA\Interfaces\TypeCodeInterface; |
||
29 | use i3Soft\CDA\RIM\Act\Act; |
||
30 | use i3Soft\CDA\RIM\Act\Encounter; |
||
31 | use i3Soft\CDA\RIM\Act\Observation; |
||
32 | use i3Soft\CDA\RIM\Act\SubstanceAdministration; |
||
33 | use i3Soft\CDA\Traits\ActTrait; |
||
34 | use i3Soft\CDA\Traits\ContextConductionIndTrait; |
||
35 | use i3Soft\CDA\Traits\EncounterTrait; |
||
36 | use i3Soft\CDA\Traits\IdsTrait; |
||
37 | use i3Soft\CDA\Traits\ObservationMediaTrait; |
||
38 | use i3Soft\CDA\Traits\ObservationTrait; |
||
39 | use i3Soft\CDA\Traits\OrganizerTrait; |
||
40 | use i3Soft\CDA\Traits\ProcedureTrait; |
||
41 | use i3Soft\CDA\Traits\RegionOfInterestTrait; |
||
42 | use i3Soft\CDA\Traits\SubstanceAdministrationTrait; |
||
43 | use i3Soft\CDA\Traits\SupplyTrait; |
||
44 | use i3Soft\CDA\Traits\TypeCodeTrait; |
||
45 | |||
46 | /** |
||
47 | * Class Entry |
||
48 | * |
||
49 | * @package i3Soft\CDA\Elements |
||
50 | */ |
||
51 | class Entry extends AbstractElement implements TypeCodeInterface |
||
52 | { |
||
53 | |||
54 | use IdsTrait; |
||
55 | use ActTrait; |
||
56 | use EncounterTrait; |
||
57 | use ObservationTrait; |
||
58 | use ObservationMediaTrait; |
||
59 | use OrganizerTrait; |
||
60 | use ProcedureTrait; |
||
61 | use RegionOfInterestTrait; |
||
62 | use SubstanceAdministrationTrait; |
||
63 | use SupplyTrait; |
||
64 | // <xs:element ref="ext:controlAct"/> |
||
65 | use TypeCodeTrait; |
||
66 | use ContextConductionIndTrait; |
||
67 | |||
68 | /** |
||
69 | * Entry constructor. |
||
70 | * |
||
71 | * @param null $choice |
||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||
72 | */ |
||
73 | public function __construct ($choice = NULL) |
||
74 | { |
||
75 | $this->setAcceptableTypeCodes(TypeCodeInterface::x_ActRelationshipEntry) |
||
76 | ->setTypeCode(TypeCodeInterface::COMPONENT); |
||
77 | if ($choice instanceof Act) |
||
78 | { |
||
79 | $this->setAct($choice); |
||
80 | } |
||
81 | elseif ($choice instanceof Encounter) |
||
82 | { |
||
83 | $this->setEncounter($choice); |
||
84 | } |
||
85 | elseif ($choice instanceof Observation) |
||
86 | { |
||
87 | $this->setObservation($choice); |
||
88 | } |
||
89 | elseif ($choice instanceof Procedure) |
||
90 | { |
||
91 | $this->setProcedure($choice); |
||
92 | } |
||
93 | elseif ($choice instanceof SubstanceAdministration) |
||
94 | { |
||
95 | $this->setSubstanceAdministration($choice); |
||
96 | } |
||
97 | |||
98 | } |
||
99 | |||
100 | |||
101 | /** |
||
102 | * @param \DOMDocument $doc |
||
103 | * |
||
104 | * @return \DOMElement |
||
105 | */ |
||
106 | public function toDOMElement (\DOMDocument $doc): \DOMElement |
||
107 | { |
||
108 | $el = $this->createElement($doc); |
||
109 | $this->renderIds($el, $doc); |
||
110 | if ($this->hasAct()) |
||
111 | { |
||
112 | $this->renderAct($el, $doc); |
||
113 | } |
||
114 | elseif ($this->hasEncounter()) |
||
115 | { |
||
116 | $this->renderEncounter($el, $doc); |
||
117 | } |
||
118 | elseif ($this->hasObservation()) |
||
119 | { |
||
120 | $this->renderObservation($el, $doc); |
||
121 | } |
||
122 | elseif ($this->hasObservationMedia()) |
||
123 | { |
||
124 | $this->renderObservationMedia($el, $doc); |
||
125 | } |
||
126 | elseif ($this->hasOrganizer()) |
||
127 | { |
||
128 | $this->renderOrganizer($el, $doc); |
||
129 | } |
||
130 | elseif ($this->hasProcedure()) |
||
131 | { |
||
132 | $this->renderProcedure($el, $doc); |
||
133 | } |
||
134 | elseif ($this->hasRegionOfInterest()) |
||
135 | { |
||
136 | $this->renderRegionOfInterest($el, $doc); |
||
137 | } |
||
138 | elseif ($this->hasSubstanceAdministration()) |
||
139 | { |
||
140 | $this->renderSubstanceAdministration($el, $doc); |
||
141 | } |
||
142 | elseif ($this->hasSupply()) |
||
143 | { |
||
144 | $this->renderSupply($el, $doc); |
||
145 | } |
||
146 | |||
147 | return $el; |
||
148 | } |
||
149 | |||
150 | |||
151 | /** |
||
152 | * @return string |
||
153 | */ |
||
154 | protected function getElementTag (): string |
||
155 | { |
||
156 | return 'entry'; |
||
157 | } |
||
158 | |||
159 | } |
||
160 |