Issues (113)

lib/RIM/Act/EntryRelationship.php (1 issue)

1
<?php
2
3
/**
4
 * The MIT License
5
 *
6
 * Copyright 2018  Peter Gee <https://github.com/pgee70>.
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 NON INFRINGEMENT. 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
/**
28
 *
29
 * @package     i3Soft\CDA
30
 * @author      Peter Gee <https://github.com/pgee70>
31
 * @link        https://github.com/pgee70/cda
32
 *
33
 */
34
35
36
namespace i3Soft\CDA\RIM\Act;
37
38
39
use i3Soft\CDA\Elements\AbstractElement;
40
use i3Soft\CDA\Interfaces\ContextConductionIndInterface;
41
use i3Soft\CDA\Interfaces\InversionIndInterface;
42
use i3Soft\CDA\Interfaces\NegationInterface;
43
use i3Soft\CDA\Interfaces\TypeCodeInterface;
44
use i3Soft\CDA\Traits\ActTrait;
45
use i3Soft\CDA\Traits\ContextConductionIndTrait;
46
use i3Soft\CDA\Traits\EncounterTrait;
47
use i3Soft\CDA\Traits\InversionIndTrait;
48
use i3Soft\CDA\Traits\NegationIndTrait;
49
use i3Soft\CDA\Traits\ObservationMediaTrait;
50
use i3Soft\CDA\Traits\ObservationTrait;
51
use i3Soft\CDA\Traits\OrganizerTrait;
52
use i3Soft\CDA\Traits\ProcedureTrait;
53
use i3Soft\CDA\Traits\RegionOfInterestTrait;
54
use i3Soft\CDA\Traits\SeperatableIndTrait;
55
use i3Soft\CDA\Traits\SequenceNumberTrait;
56
use i3Soft\CDA\Traits\SubstanceAdministrationTrait;
57
use i3Soft\CDA\Traits\SupplyTrait;
58
use i3Soft\CDA\Traits\TypeCodeTrait;
59
60
/**
61
 * Class EntryRelationship
62
 *
63
 * @package i3Soft\CDA\RIM\Act
64
 */
65
class EntryRelationship extends AbstractElement implements TypeCodeInterface, InversionIndInterface, ContextConductionIndInterface, NegationInterface
66
{
67
  use SequenceNumberTrait;
68
  use SeperatableIndTrait;
69
  use ActTrait;
70
  use EncounterTrait;
71
  use ObservationTrait;
72
  use ObservationMediaTrait;
73
  use OrganizerTrait;
74
  use ProcedureTrait;
75
  use RegionOfInterestTrait;
76
  use SubstanceAdministrationTrait;
77
  use SupplyTrait;
78
79
  use TypeCodeTrait;
80
  use NegationIndTrait;
81
  use ContextConductionIndTrait;
82
  use InversionIndTrait;
83
84
  /**
85
   * EntryRelationship constructor.
86
   * type code is required.
87
   *
88
   * @param null   $choice
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $choice is correct as it would always require null to be passed?
Loading history...
89
   * @param string $type_code
90
   */
91
  public function __construct ($choice = NULL, string $type_code = '')
92
  {
93
    $this->setAcceptableTypeCodes(TypeCodeInterface::x_ActRelationshipEntryRelationship)
94
      ->setTypeCode(TypeCodeInterface::CAUSE);
95
    $this->templateIds = array();
96
    if ($choice instanceof Act)
97
    {
98
      $this->setAct($choice);
99
    }
100
    elseif ($choice instanceof Encounter)
101
    {
102
      $this->setEncounter($choice);
103
    }
104
    elseif ($choice instanceof Observation)
105
    {
106
      $this->setObservation($choice);
107
    }
108
    elseif ($choice instanceof ObservationMedia)
109
    {
110
      $this->setObservationMedia($choice);
111
    }
112
    elseif ($choice instanceof Organizer)
113
    {
114
      $this->setOrganizer($choice);
115
    }
116
    elseif ($choice instanceof SubstanceAdministration)
117
    {
118
      $this->setSubstanceAdministration($choice);
119
    }
120
    if ($type_code)
121
    {
122
      $this->setTypeCode($type_code);
123
    }
124
  }
125
126
127
  /**
128
   * Transforms the element into a DOMElement, which will be included
129
   * into the final CDA XML
130
   *
131
   * @param \DOMDocument $doc
132
   *
133
   * @return \DOMElement
134
   */
135
  public function toDOMElement (\DOMDocument $doc): \DOMElement
136
  {
137
    $el = $this->createElement($doc);
138
139
    if ($this->hasSequenceNumber())
140
    {
141
      $this->renderSequenceNumber($el, $doc);
142
    }
143
    if ($this->hasSeperatableInd())
144
    {
145
      $this->renderSeperatableInd($el, $doc);
146
    }
147
    if ($this->hasAct())
148
    {
149
      $this->renderAct($el, $doc);
150
    }
151
    elseif ($this->hasEncounter())
152
    {
153
      $this->renderEncounter($el, $doc);
154
    }
155
    elseif ($this->hasObservation())
156
    {
157
      $this->renderObservation($el, $doc);
158
    }
159
    elseif ($this->hasObservationMedia())
160
    {
161
      $this->renderObservationMedia($el, $doc);
162
    }
163
    elseif ($this->hasOrganizer())
164
    {
165
      $this->renderOrganizer($el, $doc);
166
    }
167
    elseif ($this->hasSubstanceAdministration())
168
    {
169
      $this->renderSubstanceAdministration($el, $doc);
170
    }
171
    return $el;
172
  }
173
174
  /**
175
   * get the element tag name
176
   *
177
   * @return string
178
   */
179
  protected function getElementTag (): string
180
  {
181
    return 'entryRelationship';
182
  }
183
}