|
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\Extensions; |
|
37
|
|
|
|
|
38
|
|
|
use i3Soft\CDA\ClinicalDocument as CDA; |
|
39
|
|
|
use i3Soft\CDA\Interfaces\ClassCodeInterface; |
|
40
|
|
|
use i3Soft\CDA\Interfaces\ElementInterface; |
|
41
|
|
|
use i3Soft\CDA\Interfaces\MoodCodeInterface; |
|
42
|
|
|
use i3Soft\CDA\Interfaces\NullFlavourInterface; |
|
43
|
|
|
use i3Soft\CDA\Interfaces\TypeCodeInterface; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* this abstract element class does not have the realmcode typecode present in AbstractElement. |
|
47
|
|
|
*/ |
|
48
|
|
|
abstract class ExtAbstractElement implements ElementInterface, NullFlavourInterface |
|
49
|
|
|
{ |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @param \DOMDocument $doc |
|
53
|
|
|
* |
|
54
|
|
|
* @return \DOMElement |
|
55
|
|
|
*/ |
|
56
|
|
|
protected function createElement (\DOMDocument $doc): \DOMElement |
|
57
|
|
|
{ |
|
58
|
|
|
/* @var $el \DOMElement */ |
|
59
|
|
|
$el = $doc->createElement(CDA::getNS() . $this->getElementTag()); |
|
60
|
|
|
/** @noinspection PhpUndefinedMethodInspection */ |
|
61
|
|
|
if ($this->hasNullFlavour()) |
|
|
|
|
|
|
62
|
|
|
{ |
|
63
|
|
|
$el->setAttribute(CDA::getNS() . 'nullFlavor', $this->getNullFlavour()); |
|
|
|
|
|
|
64
|
|
|
return $el; |
|
65
|
|
|
} |
|
66
|
|
|
// tag can have class code or type code, but not both. |
|
67
|
|
|
// can have a class code and a mood code, but not type code and mood code |
|
68
|
|
|
/** @noinspection PhpUndefinedMethodInspection */ |
|
69
|
|
|
if ($this instanceof ClassCodeInterface |
|
70
|
|
|
&& $this->hasClassCode()) |
|
|
|
|
|
|
71
|
|
|
{ |
|
72
|
|
|
$el->setAttribute(CDA::getNS() . 'classCode', $this->getClassCode()); |
|
73
|
|
|
/** @noinspection PhpUndefinedMethodInspection */ |
|
74
|
|
|
if ($this instanceof MoodCodeInterface |
|
75
|
|
|
&& $this->hasMoodCode()) |
|
|
|
|
|
|
76
|
|
|
{ |
|
77
|
|
|
$el->setAttribute(CDA::getNS() . 'moodCode', $this->getMoodCode()); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
/** @noinspection PhpUndefinedMethodInspection */ |
|
81
|
|
|
elseif ($this instanceof TypeCodeInterface && $this->hasTypeCode()) |
|
|
|
|
|
|
82
|
|
|
{ |
|
83
|
|
|
$el->setAttribute(CDA::getNS() . 'typeCode', $this->getTypeCode()); |
|
84
|
|
|
} |
|
85
|
|
|
return $el; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* get the element tag name |
|
90
|
|
|
* |
|
91
|
|
|
* @return string |
|
92
|
|
|
*/ |
|
93
|
|
|
abstract protected function getElementTag (): string; |
|
94
|
|
|
} |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.