#7914 - Fix for contacts being empty or s tring (#7915)
[openemr.git] / src / FHIR / R4 / FHIRElement / FHIRReference.php
bloba89c7a392673c3fcfbe51e14a88ebaf912b7294e
1 <?php
3 namespace OpenEMR\FHIR\R4\FHIRElement;
5 /*!
6 * This class was generated with the PHPFHIR library (https://github.com/dcarbone/php-fhir) using
7 * class definitions from HL7 FHIR (https://www.hl7.org/fhir/)
9 * Class creation date: June 14th, 2019
11 * PHPFHIR Copyright:
13 * Copyright 2016-2017 Daniel Carbone (daniel.p.carbone@gmail.com)
15 * Licensed under the Apache License, Version 2.0 (the "License");
16 * you may not use this file except in compliance with the License.
17 * You may obtain a copy of the License at
19 * http://www.apache.org/licenses/LICENSE-2.0
21 * Unless required by applicable law or agreed to in writing, software
22 * distributed under the License is distributed on an "AS IS" BASIS,
23 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 * See the License for the specific language governing permissions and
25 * limitations under the License.
28 * FHIR Copyright Notice:
30 * Copyright (c) 2011+, HL7, Inc.
31 * All rights reserved.
33 * Redistribution and use in source and binary forms, with or without modification,
34 * are permitted provided that the following conditions are met:
36 * * Redistributions of source code must retain the above copyright notice, this
37 * list of conditions and the following disclaimer.
38 * * Redistributions in binary form must reproduce the above copyright notice,
39 * this list of conditions and the following disclaimer in the documentation
40 * and/or other materials provided with the distribution.
41 * * Neither the name of HL7 nor the names of its contributors may be used to
42 * endorse or promote products derived from this software without specific
43 * prior written permission.
45 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
46 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
47 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
48 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
49 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
51 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
52 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
53 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
54 * POSSIBILITY OF SUCH DAMAGE.
57 * Generated on Thu, Dec 27, 2018 22:37+1100 for FHIR v4.0.0
59 * Note: the schemas & schematrons do not contain all of the rules about what makes resources
60 * valid. Implementers will still need to be familiar with the content of the specification and with
61 * any profiles that apply to the resources in order to make a conformant implementation.
65 use OpenEMR\FHIR\R4\FHIRElement;
67 /**
68 * A reference from one resource to another.
69 * If the element is present, it must have a value for at least one of the defined elements, an @id referenced from the Narrative, or extensions
71 class FHIRReference extends FHIRElement implements \JsonSerializable
73 /**
74 * A reference to a location at which the other resource is found. The reference may be a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources.
75 * @var \OpenEMR\FHIR\R4\FHIRElement\FHIRString
77 public $reference = null;
79 /**
80 * The expected type of the target of the reference. If both Reference.type and Reference.reference are populated and Reference.reference is a FHIR URL, both SHALL be consistent.
82 The type is the Canonical URL of Resource Definition that is the type this reference refers to. References are URLs that are relative to http://hl7.org/fhir/StructureDefinition/ e.g. "Patient" is a reference to http://hl7.org/fhir/StructureDefinition/Patient. Absolute URLs are only allowed for logical models (and can only be used in references in logical models, not resources).
83 * @var \OpenEMR\FHIR\R4\FHIRElement\FHIRUri
85 public $type = null;
87 /**
88 * An identifier for the target resource. This is used when there is no way to reference the other resource directly, either because the entity it represents is not available through a FHIR server, or because there is no way for the author of the resource to convert a known identifier to an actual location. There is no requirement that a Reference.identifier point to something that is actually exposed as a FHIR instance, but it SHALL point to a business concept that would be expected to be exposed as a FHIR instance, and that instance would need to be of a FHIR resource type allowed by the reference.
89 * @var \OpenEMR\FHIR\R4\FHIRElement\FHIRIdentifier
91 public $identifier = null;
93 /**
94 * Plain text narrative that identifies the resource in addition to the resource reference.
95 * @var \OpenEMR\FHIR\R4\FHIRElement\FHIRString
97 public $display = null;
99 /**
100 * @var string
102 private $_fhirElementName = 'Reference';
105 * A reference to a location at which the other resource is found. The reference may be a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources.
106 * @return \OpenEMR\FHIR\R4\FHIRElement\FHIRString
108 public function getReference()
110 return $this->reference;
114 * A reference to a location at which the other resource is found. The reference may be a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources.
115 * @param \OpenEMR\FHIR\R4\FHIRElement\FHIRString $reference
116 * @return $this
118 public function setReference($reference)
120 $this->reference = $reference;
121 return $this;
125 * The expected type of the target of the reference. If both Reference.type and Reference.reference are populated and Reference.reference is a FHIR URL, both SHALL be consistent.
127 The type is the Canonical URL of Resource Definition that is the type this reference refers to. References are URLs that are relative to http://hl7.org/fhir/StructureDefinition/ e.g. "Patient" is a reference to http://hl7.org/fhir/StructureDefinition/Patient. Absolute URLs are only allowed for logical models (and can only be used in references in logical models, not resources).
128 * @return \OpenEMR\FHIR\R4\FHIRElement\FHIRUri
130 public function getType()
132 return $this->type;
136 * The expected type of the target of the reference. If both Reference.type and Reference.reference are populated and Reference.reference is a FHIR URL, both SHALL be consistent.
138 The type is the Canonical URL of Resource Definition that is the type this reference refers to. References are URLs that are relative to http://hl7.org/fhir/StructureDefinition/ e.g. "Patient" is a reference to http://hl7.org/fhir/StructureDefinition/Patient. Absolute URLs are only allowed for logical models (and can only be used in references in logical models, not resources).
139 * @param \OpenEMR\FHIR\R4\FHIRElement\FHIRUri $type
140 * @return $this
142 public function setType($type)
144 $this->type = $type;
145 return $this;
149 * An identifier for the target resource. This is used when there is no way to reference the other resource directly, either because the entity it represents is not available through a FHIR server, or because there is no way for the author of the resource to convert a known identifier to an actual location. There is no requirement that a Reference.identifier point to something that is actually exposed as a FHIR instance, but it SHALL point to a business concept that would be expected to be exposed as a FHIR instance, and that instance would need to be of a FHIR resource type allowed by the reference.
150 * @return \OpenEMR\FHIR\R4\FHIRElement\FHIRIdentifier
152 public function getIdentifier()
154 return $this->identifier;
158 * An identifier for the target resource. This is used when there is no way to reference the other resource directly, either because the entity it represents is not available through a FHIR server, or because there is no way for the author of the resource to convert a known identifier to an actual location. There is no requirement that a Reference.identifier point to something that is actually exposed as a FHIR instance, but it SHALL point to a business concept that would be expected to be exposed as a FHIR instance, and that instance would need to be of a FHIR resource type allowed by the reference.
159 * @param \OpenEMR\FHIR\R4\FHIRElement\FHIRIdentifier $identifier
160 * @return $this
162 public function setIdentifier($identifier)
164 $this->identifier = $identifier;
165 return $this;
169 * Plain text narrative that identifies the resource in addition to the resource reference.
170 * @return \OpenEMR\FHIR\R4\FHIRElement\FHIRString
172 public function getDisplay()
174 return $this->display;
178 * Plain text narrative that identifies the resource in addition to the resource reference.
179 * @param \OpenEMR\FHIR\R4\FHIRElement\FHIRString $display
180 * @return $this
182 public function setDisplay($display)
184 $this->display = $display;
185 return $this;
189 * @return string
191 public function get_fhirElementName()
193 return $this->_fhirElementName;
197 * @param mixed $data
199 public function __construct($data = [])
201 if (is_array($data)) {
202 if (isset($data['reference'])) {
203 $this->setReference($data['reference']);
205 if (isset($data['type'])) {
206 $this->setType($data['type']);
208 if (isset($data['identifier'])) {
209 $this->setIdentifier($data['identifier']);
211 if (isset($data['display'])) {
212 $this->setDisplay($data['display']);
214 } elseif (null !== $data) {
215 throw new \InvalidArgumentException('$data expected to be array of values, saw "' . gettype($data) . '"');
217 parent::__construct($data);
221 * @return string
223 public function __toString()
225 return $this->get_fhirElementName();
229 * @return array
231 public function jsonSerialize(): mixed
233 $json = parent::jsonSerialize();
234 if (isset($this->reference)) {
235 $json['reference'] = $this->reference;
237 if (isset($this->type)) {
238 $json['type'] = $this->type;
240 if (isset($this->identifier)) {
241 $json['identifier'] = $this->identifier;
243 if (isset($this->display)) {
244 $json['display'] = $this->display;
246 return $json;
250 * @param boolean $returnSXE
251 * @param \SimpleXMLElement $sxe
252 * @return string|\SimpleXMLElement
254 public function xmlSerialize($returnSXE = false, $sxe = null)
256 if (null === $sxe) {
257 $sxe = new \SimpleXMLElement('<Reference xmlns="http://hl7.org/fhir"></Reference>');
259 parent::xmlSerialize(true, $sxe);
260 if (isset($this->reference)) {
261 $this->reference->xmlSerialize(true, $sxe->addChild('reference'));
263 if (isset($this->type)) {
264 $this->type->xmlSerialize(true, $sxe->addChild('type'));
266 if (isset($this->identifier)) {
267 $this->identifier->xmlSerialize(true, $sxe->addChild('identifier'));
269 if (isset($this->display)) {
270 $this->display->xmlSerialize(true, $sxe->addChild('display'));
272 if ($returnSXE) {
273 return $sxe;
275 return $sxe->saveXML();