| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * The MIT License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * Copyright 2016 Julien Fastré <[email protected]>. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * Permission is hereby granted, free of charge, to any person obtaining a copy | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * of this software and associated documentation files (the "Software"), to deal | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * in the Software without restriction, including without limitation the rights | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * copies of the Software, and to permit persons to whom the Software is | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * furnished to do so, subject to the following conditions: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * The above copyright notice and this permission notice shall be included in | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * all copies or substantial portions of the Software. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * THE SOFTWARE. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | namespace PHPHealth\CDA; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | use PHPHealth\CDA\DataType\Quantity\DateAndTime\TimeStamp; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | use PHPHealth\CDA\DataType\Identifier\InstanceIdentifier; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | use PHPHealth\CDA\DataType\Code\CodedValue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | use PHPHealth\CDA\Elements\Code; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | use PHPHealth\CDA\Elements\Title; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | use PHPHealth\CDA\Elements\EffectiveTime; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | use PHPHealth\CDA\Elements\Id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | use PHPHealth\CDA\Elements\ConfidentialityCode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | use PHPHealth\CDA\Elements\TypeId; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | use PHPHealth\CDA\RIM\Participation\RecordTarget; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  * Root class for clinical document | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  * @author Julien Fastré <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | class ClinicalDocument | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     const NS_CDA = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |      * the templateId of the document. Will be inserted into doc, like | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * ``` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      * <typeId> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      * ``` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      * TODO : always equals to '2.16.840.1.113883.3.27.1776' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * @var TypeId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     private $typeId; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      * the title of the document | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * @var Title | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     private $title; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |      * the root component | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |      * @var Component\RootBodyComponent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     private $rootComponent; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |      * @var EffectiveTime | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     private $effectiveTime; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      * @var Id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     private $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |      * @var Code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     private $code; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      * @var RecordTarget | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     private $recordTarget; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |      * @var ConfidentialityCode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     private $confidentialityCode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     public function __construct() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         $this->rootComponent = new Component\RootBodyComponent(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         $typeIdIdentifier = new InstanceIdentifier( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |             "2.16.840.1.113883.1.3", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |             "POCD_HD000040" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |         $this->typeId = new TypeId($typeIdIdentifier); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     public function getTitle() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         return $this->title; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |      * @param \PHPHealth\CDA\Elements\Title $title | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |      * @return \PHPHealth\CDA2\ClinicalDocument | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |     public function setTitle(Title $title) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |         $this->title = $title; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |      * @return EffectiveTime | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 141 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 142 |  |  |     public function getEffectiveTime() | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  |         return $this->effectiveTime; | 
            
                                                                        
                            
            
                                    
            
            
                | 145 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |      * @param EffectiveTime $effectiveTime | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     public function setEffectiveTime(EffectiveTime $effectiveTime) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |         $this->effectiveTime = $effectiveTime; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |      * @return Id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |     public function getId() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |         return $this->id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |      * @param Id $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     public function setId(Id $id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |         $this->id = $id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |      * Get the code of the document | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |      * @return Code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |     public function getCode() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |         return $this->code; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |      * Set the code of the document | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |      * @param Code $code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |     public function setCode(Code $code) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |         $this->code = $code; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |      * @return ConfidentialityCode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |     public function getConfidentialityCode() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |         return $this->confidentialityCode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |      * @param ConfidentialityCode $confidentialityCode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |      * @return $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |     public function setConfidentialityCode(ConfidentialityCode $confidentialityCode) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |         $this->confidentialityCode = $confidentialityCode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |      * @return Component\RootBodyComponent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |     public function getRootComponent() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |         return $this->rootComponent; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |     public function getRecordTarget() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |         return $this->recordTarget; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |     public function setRecordTarget(RecordTarget $recordTarget) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |         $this->recordTarget = $recordTarget; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |      * @return \DOMDocument | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |     public function toDOMDocument() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |         $dom = new \DOMDocument('1.0', 'UTF-8'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |         $doc = $dom->createElementNS('urn:hl7-org:v3', 'ClinicalDocument'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |         $dom->appendChild($doc); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |         // set the NS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |         $doc->setAttributeNS( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |             'http://www.w3.org/2001/XMLSchema-instance', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |             'xsi:schemaLocation', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |             'urn:hl7-org:v3 CDA.xsd' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |         // add typeId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |         $doc->appendChild($this->typeId->toDOMElement($dom)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |         // add id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |         if ($this->getId() !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |             $doc->appendChild($this->getId()->toDOMElement($dom)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |         // add code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |         if ($this->getCode() !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |             $doc->appendChild($this->getCode()->toDOMElement($dom)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |       | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |         // add title | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |         if ($this->getTitle() !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |             $doc->appendChild($this->getTitle()->toDOMElement($dom)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |         //add effective time | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |         if ($this->getEffectiveTime() !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |             $doc->appendChild($this->getEffectiveTime()->toDOMElement($dom)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |         // add confidentialityCode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |         if ($this->getConfidentialityCode() !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |             $doc->appendChild($this->confidentialityCode->toDOMElement($dom)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |         // add recordTarget | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |         if ($this->getRecordTarget() !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |             $doc->appendChild($this->recordTarget->toDOMElement($dom)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |         // add components | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |         if (!$this->getRootComponent()->isEmpty()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |             $doc->appendChild($this->getRootComponent()->toDOMElement($dom)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |         return $dom; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 301 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 302 |  |  |  |