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\RIM\Entity; |
28
|
|
|
|
29
|
|
|
use PHPHealth\CDA\ElementInterface; |
30
|
|
|
use PHPHealth\CDA\ClinicalDocument as CDA; |
31
|
|
|
use PHPHealth\CDA\DataType\Quantity\DateAndTime\TimeStamp; |
32
|
|
|
use PHPHealth\CDA\DataType\Collection\Set; |
33
|
|
|
use PHPHealth\CDA\Elements\AdministrativeGenderCode; |
34
|
|
|
use PHPHealth\CDA\DataType\Code\CodedValue; |
35
|
|
|
use PHPHealth\CDA\Elements\BirthTime; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* |
39
|
|
|
* |
40
|
|
|
* @author Julien Fastré <[email protected]> |
41
|
|
|
*/ |
42
|
|
|
abstract class Person implements ElementInterface |
43
|
|
|
{ |
44
|
|
|
/** |
45
|
|
|
* |
46
|
|
|
* @var Set|\PHPHealth\CDA\DataType\Name\PersonName[] |
47
|
|
|
*/ |
48
|
|
|
protected $names; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* |
52
|
|
|
* @var TimeStamp |
53
|
|
|
*/ |
54
|
|
|
protected $birthtime; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* |
58
|
|
|
* @var CodedValue |
59
|
|
|
*/ |
60
|
|
|
protected $administrativeGenderCode; |
61
|
|
|
|
62
|
|
|
public function __construct( |
63
|
|
|
Set $names = null, |
64
|
|
|
TimeStamp $birthtime = null, |
65
|
|
|
CodedValue $administrativeGenderCode = null |
66
|
|
|
) { |
67
|
|
|
if ($names !== null) { |
68
|
|
|
$this->setNames($names); |
69
|
|
|
} |
70
|
|
|
if ($birthtime !== null) { |
71
|
|
|
$this->setBirthtime($birthtime); |
72
|
|
|
} |
73
|
|
|
if ($administrativeGenderCode !== null) { |
74
|
|
|
$this->setAdministrativeGenderCode($administrativeGenderCode); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function getNames() |
79
|
|
|
{ |
80
|
|
|
return $this->names; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function getBirthtime() |
84
|
|
|
{ |
85
|
|
|
return $this->birthtime; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function setNames(Set $names) |
89
|
|
|
{ |
90
|
|
|
$this->names = $names; |
91
|
|
|
|
92
|
|
|
return $this; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function setBirthtime(TimeStamp $birthtime) |
96
|
|
|
{ |
97
|
|
|
$this->birthtime = $birthtime; |
98
|
|
|
|
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function getAdministrativeGenderCode() |
103
|
|
|
{ |
104
|
|
|
return $this->administrativeGenderCode; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function setAdministrativeGenderCode(CodedValue $administrativeGenderCode) |
108
|
|
|
{ |
109
|
|
|
$this->administrativeGenderCode = $administrativeGenderCode; |
110
|
|
|
|
111
|
|
|
return $this; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
abstract protected function getTagName(); |
115
|
|
|
|
116
|
|
|
|
117
|
|
|
public function toDOMElement(\DOMDocument $doc) |
118
|
|
|
{ |
119
|
|
|
$el = $doc->createElement(CDA::NS_CDA.$this->getTagName()); |
120
|
|
|
//add names |
121
|
|
|
if ($this->getNames() !== null) { |
122
|
|
|
$this->getNames()->setValueToElement($el, $doc); |
123
|
|
|
} |
124
|
|
|
// add administrative gender code |
125
|
|
|
if ($this->getAdministrativeGenderCode() !== null) { |
126
|
|
|
$adm = new AdministrativeGenderCode($this->administrativeGenderCode); |
127
|
|
|
$el->appendChild($adm->toDOMElement($doc)); |
128
|
|
|
} |
129
|
|
|
// add birthtime |
130
|
|
|
if ($this->getBirthtime() !== null) { |
131
|
|
|
$bir = new BirthTime($this->birthtime); |
132
|
|
|
$el->appendChild($bir->toDOMElement($doc)); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
return $el; |
136
|
|
|
} |
137
|
|
|
} |
138
|
|
|
|