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 NONINFRINGEMENT. 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
|
|
|
namespace PHPHealth\CDA\RIM\Act; |
26
|
|
|
|
27
|
|
|
use PHPHealth\CDA\DataType\Code\CodedWithEquivalents; |
28
|
|
|
use PHPHealth\CDA\DataType\Collection\Set; |
29
|
|
|
use PHPHealth\CDA\DataType\Collection\Interval; |
30
|
|
|
use PHPHealth\CDA\DataType\Quantity\PhysicalQuantity\PhysicalQuantity; |
31
|
|
|
use PHPHealth\CDA\Elements\TemplateId; |
32
|
|
|
use PHPHealth\CDA\Elements\Text; |
33
|
|
|
use PHPHealth\CDA\Elements\EffectiveTime; |
34
|
|
|
use PHPHealth\CDA\Elements\RouteCode; |
35
|
|
|
use PHPHealth\CDA\RIM\Participation\Consumable; |
36
|
|
|
use PHPHealth\CDA\Elements\DoseQuantity; |
37
|
|
|
use PHPHealth\CDA\DataType\Identifier\InstanceIdentifier; |
38
|
|
|
use PHPHealth\CDA\DataType\TextAndMultimedia\CharacterString; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* |
42
|
|
|
* |
43
|
|
|
* @author Julien Fastré <[email protected]> |
44
|
|
|
*/ |
45
|
|
|
class SubstanceAdministration extends Act |
46
|
|
|
{ |
47
|
|
|
/** |
48
|
|
|
* |
49
|
|
|
* @var CodedWithEquivalents |
50
|
|
|
*/ |
51
|
|
|
private $routeCode; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* |
55
|
|
|
* @var Set|CodedWithEquivalents |
56
|
|
|
*/ |
57
|
|
|
private $approachSiteCode; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* |
61
|
|
|
* @var Interval|PhysicalQuantity |
62
|
|
|
*/ |
63
|
|
|
private $doseQuantity; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* |
67
|
|
|
* @var Interval|PhysicalQuantity |
68
|
|
|
*/ |
69
|
|
|
private $rateQuantity; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* |
73
|
|
|
* @var Consumable |
74
|
|
|
*/ |
75
|
|
|
private $consumable; |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
public function getClassCode(): string |
79
|
|
|
{ |
80
|
|
|
return 'SBADM'; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
protected function getElementTag(): string |
84
|
|
|
{ |
85
|
|
|
return 'substanceAdministration'; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* |
90
|
|
|
* @return CodedWithEquivalents |
91
|
|
|
*/ |
92
|
|
|
public function getRouteCode(): CodedWithEquivalents |
93
|
|
|
{ |
94
|
|
|
return $this->routeCode; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* |
99
|
|
|
* @return Set|CodedWithEquivalents |
100
|
|
|
*/ |
101
|
|
|
public function getApproachSiteCode() |
102
|
|
|
{ |
103
|
|
|
return $this->approachSiteCode; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* |
108
|
|
|
* @return Interval|PhysicalQuantity |
109
|
|
|
*/ |
110
|
|
|
public function getDoseQuantity() |
111
|
|
|
{ |
112
|
|
|
return $this->doseQuantity; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* |
117
|
|
|
* @return Interval|PhysicalQuantity |
118
|
|
|
*/ |
119
|
|
|
public function getRateQuantity() |
120
|
|
|
{ |
121
|
|
|
return $this->rateQuantity; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* |
126
|
|
|
* @return Consumable |
127
|
|
|
*/ |
128
|
|
|
public function getConsumable() |
129
|
|
|
{ |
130
|
|
|
return $this->consumable; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* |
135
|
|
|
* @param CodedWithEquivalents $routeCode |
136
|
|
|
* @return $this |
137
|
|
|
*/ |
138
|
|
|
public function setRouteCode(CodedWithEquivalents $routeCode) |
139
|
|
|
{ |
140
|
|
|
$this->routeCode = $routeCode; |
141
|
|
|
return $this; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* |
146
|
|
|
* @param Set|CodedWithEquivalents $approachSiteCode |
147
|
|
|
* @return $this |
148
|
|
|
*/ |
149
|
|
|
public function setApproachSiteCode($approachSiteCode) |
150
|
|
|
{ |
151
|
|
|
$this->approachSiteCode = $approachSiteCode; |
152
|
|
|
return $this; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* |
157
|
|
|
* @param Interval|PhysicalQuantity $doseQuantity |
158
|
|
|
* @return $this |
159
|
|
|
*/ |
160
|
|
|
public function setDoseQuantity($doseQuantity) |
161
|
|
|
{ |
162
|
|
|
$this->doseQuantity = $doseQuantity; |
163
|
|
|
return $this; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* |
168
|
|
|
* @param Interval|PhysicalQuantity $rateQuantity |
169
|
|
|
* @return $this |
170
|
|
|
*/ |
171
|
|
|
public function setRateQuantity($rateQuantity) |
172
|
|
|
{ |
173
|
|
|
$this->rateQuantity = $rateQuantity; |
174
|
|
|
return $this; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
|
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* |
181
|
|
|
* @param Consumable $consumable |
182
|
|
|
* @return $this |
183
|
|
|
*/ |
184
|
|
|
function setConsumable(Consumable $consumable) |
|
|
|
|
185
|
|
|
{ |
186
|
|
|
$this->consumable = $consumable; |
187
|
|
|
return $this; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
public function toDOMElement(\DOMDocument $doc): \DOMElement |
191
|
|
|
{ |
192
|
|
|
$el = $this->createElement($doc); |
193
|
|
|
|
194
|
|
View Code Duplication |
if ($this->getTemplateIds() !== null) { |
|
|
|
|
195
|
|
|
foreach ($this->templateIds as $id) { |
196
|
|
|
$el->appendChild((new TemplateId($id))->toDOMElement($doc)); |
197
|
|
|
} |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
if ($this->getIds() !== null) { |
201
|
|
|
foreach ($this->getIds()->getIterator() as $id) { |
202
|
|
|
/* @var $id InstanceIdentifier */ |
203
|
|
|
$el->appendChild((new \PHPHealth\CDA\Elements\Id($id)) |
204
|
|
|
->toDOMElement($doc)); |
205
|
|
|
} |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
if ($this->getText() !== null) { |
209
|
|
|
$el->appendChild((new Text($this->getText()))->toDOMElement($doc)); |
|
|
|
|
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
if ($this->getStatusCode() !== null) { |
213
|
|
|
$el->appendChild( |
214
|
|
|
(new \PHPHealth\CDA\Elements\StatusCode($this->getStatusCode())) |
215
|
|
|
->toDOMElement($doc) |
216
|
|
|
); |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
$first = true; |
220
|
|
|
foreach ($this->getEffectiveTime() as $time) { |
221
|
|
|
$effectiveTime = new EffectiveTime($time); |
222
|
|
|
|
223
|
|
|
if (! $first) { |
224
|
|
|
$effectiveTime->setOperatorAppend(); |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
$el->appendChild($effectiveTime |
228
|
|
|
->toDOMElement($doc)); |
229
|
|
|
|
230
|
|
|
$first = false; |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
if ($this->getRouteCode() !== null) { |
234
|
|
|
$el->appendChild((new RouteCode($this->getRouteCode())) |
235
|
|
|
->toDOMElement($doc)); |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
if ($this->getDoseQuantity() !== null) { |
239
|
|
|
$el->appendChild((new DoseQuantity($this->getDoseQuantity())) |
240
|
|
|
->toDOMElement($doc)); |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
if ($this->getConsumable() !== null) { |
244
|
|
|
$el->appendChild($this->getConsumable()->toDOMElement($doc)); |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
return $el; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
} |
251
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.