#7914 - Fix for contacts being empty or s tring (#7915)
[openemr.git] / src / FHIR / R4 / FHIRElement / FHIRDataRequirement.php
blobad491906858b2c0ad742d1250e1dea821010e8f2
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 * Describes a required data item for evaluation in terms of the type of data, and optional code or date-based filters of the data.
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 FHIRDataRequirement extends FHIRElement implements \JsonSerializable
73 /**
74 * The type of the required data, specified as the type name of a resource. For profiles, this value is set to the type of the base resource of the profile.
75 * @var \OpenEMR\FHIR\R4\FHIRElement\FHIRCode
77 public $type = null;
79 /**
80 * The profile of the required data, specified as the uri of the profile definition.
81 * @var \OpenEMR\FHIR\R4\FHIRElement\FHIRCanonical[]
83 public $profile = [];
85 /**
86 * @var \OpenEMR\FHIR\R4\FHIRElement\FHIRCodeableConcept
88 public $subjectCodeableConcept = null;
90 /**
91 * @var \OpenEMR\FHIR\R4\FHIRElement\FHIRReference
93 public $subjectReference = null;
95 /**
96 * Indicates that specific elements of the type are referenced by the knowledge module and must be supported by the consumer in order to obtain an effective evaluation. This does not mean that a value is required for this element, only that the consuming system must understand the element and be able to provide values for it if they are available.
98 The value of mustSupport SHALL be a FHIRPath resolveable on the type of the DataRequirement. The path SHALL consist only of identifiers, constant indexers, and .resolve() (see the [Simple FHIRPath Profile](fhirpath.html#simple) for full details).
99 * @var \OpenEMR\FHIR\R4\FHIRElement\FHIRString[]
101 public $mustSupport = [];
104 * Code filters specify additional constraints on the data, specifying the value set of interest for a particular element of the data. Each code filter defines an additional constraint on the data, i.e. code filters are AND'ed, not OR'ed.
105 * @var \OpenEMR\FHIR\R4\FHIRResource\FHIRDataRequirement\FHIRDataRequirementCodeFilter[]
107 public $codeFilter = [];
110 * Date filters specify additional constraints on the data in terms of the applicable date range for specific elements. Each date filter specifies an additional constraint on the data, i.e. date filters are AND'ed, not OR'ed.
111 * @var \OpenEMR\FHIR\R4\FHIRResource\FHIRDataRequirement\FHIRDataRequirementDateFilter[]
113 public $dateFilter = [];
116 * Specifies a maximum number of results that are required (uses the _count search parameter).
117 * @var \OpenEMR\FHIR\R4\FHIRElement\FHIRPositiveInt
119 public $limit = null;
122 * Specifies the order of the results to be returned.
123 * @var \OpenEMR\FHIR\R4\FHIRResource\FHIRDataRequirement\FHIRDataRequirementSort[]
125 public $sort = [];
128 * @var string
130 private $_fhirElementName = 'DataRequirement';
133 * The type of the required data, specified as the type name of a resource. For profiles, this value is set to the type of the base resource of the profile.
134 * @return \OpenEMR\FHIR\R4\FHIRElement\FHIRCode
136 public function getType()
138 return $this->type;
142 * The type of the required data, specified as the type name of a resource. For profiles, this value is set to the type of the base resource of the profile.
143 * @param \OpenEMR\FHIR\R4\FHIRElement\FHIRCode $type
144 * @return $this
146 public function setType($type)
148 $this->type = $type;
149 return $this;
153 * The profile of the required data, specified as the uri of the profile definition.
154 * @return \OpenEMR\FHIR\R4\FHIRElement\FHIRCanonical[]
156 public function getProfile()
158 return $this->profile;
162 * The profile of the required data, specified as the uri of the profile definition.
163 * @param \OpenEMR\FHIR\R4\FHIRElement\FHIRCanonical $profile
164 * @return $this
166 public function addProfile($profile)
168 $this->profile[] = $profile;
169 return $this;
173 * @return \OpenEMR\FHIR\R4\FHIRElement\FHIRCodeableConcept
175 public function getSubjectCodeableConcept()
177 return $this->subjectCodeableConcept;
181 * @param \OpenEMR\FHIR\R4\FHIRElement\FHIRCodeableConcept $subjectCodeableConcept
182 * @return $this
184 public function setSubjectCodeableConcept($subjectCodeableConcept)
186 $this->subjectCodeableConcept = $subjectCodeableConcept;
187 return $this;
191 * @return \OpenEMR\FHIR\R4\FHIRElement\FHIRReference
193 public function getSubjectReference()
195 return $this->subjectReference;
199 * @param \OpenEMR\FHIR\R4\FHIRElement\FHIRReference $subjectReference
200 * @return $this
202 public function setSubjectReference($subjectReference)
204 $this->subjectReference = $subjectReference;
205 return $this;
209 * Indicates that specific elements of the type are referenced by the knowledge module and must be supported by the consumer in order to obtain an effective evaluation. This does not mean that a value is required for this element, only that the consuming system must understand the element and be able to provide values for it if they are available.
211 The value of mustSupport SHALL be a FHIRPath resolveable on the type of the DataRequirement. The path SHALL consist only of identifiers, constant indexers, and .resolve() (see the [Simple FHIRPath Profile](fhirpath.html#simple) for full details).
212 * @return \OpenEMR\FHIR\R4\FHIRElement\FHIRString[]
214 public function getMustSupport()
216 return $this->mustSupport;
220 * Indicates that specific elements of the type are referenced by the knowledge module and must be supported by the consumer in order to obtain an effective evaluation. This does not mean that a value is required for this element, only that the consuming system must understand the element and be able to provide values for it if they are available.
222 The value of mustSupport SHALL be a FHIRPath resolveable on the type of the DataRequirement. The path SHALL consist only of identifiers, constant indexers, and .resolve() (see the [Simple FHIRPath Profile](fhirpath.html#simple) for full details).
223 * @param \OpenEMR\FHIR\R4\FHIRElement\FHIRString $mustSupport
224 * @return $this
226 public function addMustSupport($mustSupport)
228 $this->mustSupport[] = $mustSupport;
229 return $this;
233 * Code filters specify additional constraints on the data, specifying the value set of interest for a particular element of the data. Each code filter defines an additional constraint on the data, i.e. code filters are AND'ed, not OR'ed.
234 * @return \OpenEMR\FHIR\R4\FHIRResource\FHIRDataRequirement\FHIRDataRequirementCodeFilter[]
236 public function getCodeFilter()
238 return $this->codeFilter;
242 * Code filters specify additional constraints on the data, specifying the value set of interest for a particular element of the data. Each code filter defines an additional constraint on the data, i.e. code filters are AND'ed, not OR'ed.
243 * @param \OpenEMR\FHIR\R4\FHIRResource\FHIRDataRequirement\FHIRDataRequirementCodeFilter $codeFilter
244 * @return $this
246 public function addCodeFilter($codeFilter)
248 $this->codeFilter[] = $codeFilter;
249 return $this;
253 * Date filters specify additional constraints on the data in terms of the applicable date range for specific elements. Each date filter specifies an additional constraint on the data, i.e. date filters are AND'ed, not OR'ed.
254 * @return \OpenEMR\FHIR\R4\FHIRResource\FHIRDataRequirement\FHIRDataRequirementDateFilter[]
256 public function getDateFilter()
258 return $this->dateFilter;
262 * Date filters specify additional constraints on the data in terms of the applicable date range for specific elements. Each date filter specifies an additional constraint on the data, i.e. date filters are AND'ed, not OR'ed.
263 * @param \OpenEMR\FHIR\R4\FHIRResource\FHIRDataRequirement\FHIRDataRequirementDateFilter $dateFilter
264 * @return $this
266 public function addDateFilter($dateFilter)
268 $this->dateFilter[] = $dateFilter;
269 return $this;
273 * Specifies a maximum number of results that are required (uses the _count search parameter).
274 * @return \OpenEMR\FHIR\R4\FHIRElement\FHIRPositiveInt
276 public function getLimit()
278 return $this->limit;
282 * Specifies a maximum number of results that are required (uses the _count search parameter).
283 * @param \OpenEMR\FHIR\R4\FHIRElement\FHIRPositiveInt $limit
284 * @return $this
286 public function setLimit($limit)
288 $this->limit = $limit;
289 return $this;
293 * Specifies the order of the results to be returned.
294 * @return \OpenEMR\FHIR\R4\FHIRResource\FHIRDataRequirement\FHIRDataRequirementSort[]
296 public function getSort()
298 return $this->sort;
302 * Specifies the order of the results to be returned.
303 * @param \OpenEMR\FHIR\R4\FHIRResource\FHIRDataRequirement\FHIRDataRequirementSort $sort
304 * @return $this
306 public function addSort($sort)
308 $this->sort[] = $sort;
309 return $this;
313 * @return string
315 public function get_fhirElementName()
317 return $this->_fhirElementName;
321 * @param mixed $data
323 public function __construct($data = [])
325 if (is_array($data)) {
326 if (isset($data['type'])) {
327 $this->setType($data['type']);
329 if (isset($data['profile'])) {
330 if (is_array($data['profile'])) {
331 foreach ($data['profile'] as $d) {
332 $this->addProfile($d);
334 } else {
335 throw new \InvalidArgumentException('"profile" must be array of objects or null, ' . gettype($data['profile']) . ' seen.');
338 if (isset($data['subjectCodeableConcept'])) {
339 $this->setSubjectCodeableConcept($data['subjectCodeableConcept']);
341 if (isset($data['subjectReference'])) {
342 $this->setSubjectReference($data['subjectReference']);
344 if (isset($data['mustSupport'])) {
345 if (is_array($data['mustSupport'])) {
346 foreach ($data['mustSupport'] as $d) {
347 $this->addMustSupport($d);
349 } else {
350 throw new \InvalidArgumentException('"mustSupport" must be array of objects or null, ' . gettype($data['mustSupport']) . ' seen.');
353 if (isset($data['codeFilter'])) {
354 if (is_array($data['codeFilter'])) {
355 foreach ($data['codeFilter'] as $d) {
356 $this->addCodeFilter($d);
358 } else {
359 throw new \InvalidArgumentException('"codeFilter" must be array of objects or null, ' . gettype($data['codeFilter']) . ' seen.');
362 if (isset($data['dateFilter'])) {
363 if (is_array($data['dateFilter'])) {
364 foreach ($data['dateFilter'] as $d) {
365 $this->addDateFilter($d);
367 } else {
368 throw new \InvalidArgumentException('"dateFilter" must be array of objects or null, ' . gettype($data['dateFilter']) . ' seen.');
371 if (isset($data['limit'])) {
372 $this->setLimit($data['limit']);
374 if (isset($data['sort'])) {
375 if (is_array($data['sort'])) {
376 foreach ($data['sort'] as $d) {
377 $this->addSort($d);
379 } else {
380 throw new \InvalidArgumentException('"sort" must be array of objects or null, ' . gettype($data['sort']) . ' seen.');
383 } elseif (null !== $data) {
384 throw new \InvalidArgumentException('$data expected to be array of values, saw "' . gettype($data) . '"');
386 parent::__construct($data);
390 * @return string
392 public function __toString()
394 return $this->get_fhirElementName();
398 * @return array
400 public function jsonSerialize(): mixed
402 $json = parent::jsonSerialize();
403 if (isset($this->type)) {
404 $json['type'] = $this->type;
406 if (0 < count($this->profile)) {
407 $json['profile'] = [];
408 foreach ($this->profile as $profile) {
409 $json['profile'][] = $profile;
412 if (isset($this->subjectCodeableConcept)) {
413 $json['subjectCodeableConcept'] = $this->subjectCodeableConcept;
415 if (isset($this->subjectReference)) {
416 $json['subjectReference'] = $this->subjectReference;
418 if (0 < count($this->mustSupport)) {
419 $json['mustSupport'] = [];
420 foreach ($this->mustSupport as $mustSupport) {
421 $json['mustSupport'][] = $mustSupport;
424 if (0 < count($this->codeFilter)) {
425 $json['codeFilter'] = [];
426 foreach ($this->codeFilter as $codeFilter) {
427 $json['codeFilter'][] = $codeFilter;
430 if (0 < count($this->dateFilter)) {
431 $json['dateFilter'] = [];
432 foreach ($this->dateFilter as $dateFilter) {
433 $json['dateFilter'][] = $dateFilter;
436 if (isset($this->limit)) {
437 $json['limit'] = $this->limit;
439 if (0 < count($this->sort)) {
440 $json['sort'] = [];
441 foreach ($this->sort as $sort) {
442 $json['sort'][] = $sort;
445 return $json;
449 * @param boolean $returnSXE
450 * @param \SimpleXMLElement $sxe
451 * @return string|\SimpleXMLElement
453 public function xmlSerialize($returnSXE = false, $sxe = null)
455 if (null === $sxe) {
456 $sxe = new \SimpleXMLElement('<DataRequirement xmlns="http://hl7.org/fhir"></DataRequirement>');
458 parent::xmlSerialize(true, $sxe);
459 if (isset($this->type)) {
460 $this->type->xmlSerialize(true, $sxe->addChild('type'));
462 if (0 < count($this->profile)) {
463 foreach ($this->profile as $profile) {
464 $profile->xmlSerialize(true, $sxe->addChild('profile'));
467 if (isset($this->subjectCodeableConcept)) {
468 $this->subjectCodeableConcept->xmlSerialize(true, $sxe->addChild('subjectCodeableConcept'));
470 if (isset($this->subjectReference)) {
471 $this->subjectReference->xmlSerialize(true, $sxe->addChild('subjectReference'));
473 if (0 < count($this->mustSupport)) {
474 foreach ($this->mustSupport as $mustSupport) {
475 $mustSupport->xmlSerialize(true, $sxe->addChild('mustSupport'));
478 if (0 < count($this->codeFilter)) {
479 foreach ($this->codeFilter as $codeFilter) {
480 $codeFilter->xmlSerialize(true, $sxe->addChild('codeFilter'));
483 if (0 < count($this->dateFilter)) {
484 foreach ($this->dateFilter as $dateFilter) {
485 $dateFilter->xmlSerialize(true, $sxe->addChild('dateFilter'));
488 if (isset($this->limit)) {
489 $this->limit->xmlSerialize(true, $sxe->addChild('limit'));
491 if (0 < count($this->sort)) {
492 foreach ($this->sort as $sort) {
493 $sort->xmlSerialize(true, $sxe->addChild('sort'));
496 if ($returnSXE) {
497 return $sxe;
499 return $sxe->saveXML();