7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
24 * @see Zend_Gdata_App_Extension_Element
26 require_once 'Zend/Gdata/App/Extension/Element.php';
29 * Concrete class for working with CCR elements.
34 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
35 * @license http://framework.zend.com/license/new-bsd New BSD License
37 class Zend_Gdata_Health_Extension_Ccr extends Zend_Gdata_App_Extension_Element
39 protected $_rootNamespace = 'ccr';
40 protected $_rootElement = 'ContinuityOfCareRecord';
41 protected $_ccrDom = null;
44 * Creates a Zend_Gdata_Health_Extension_Ccr entry, representing CCR data
46 * @param DOMElement $element (optional) DOMElement from which this
47 * object should be constructed.
49 public function __construct($element = null)
51 foreach (Zend_Gdata_Health::$namespaces as $nsPrefix => $nsUri) {
52 $this->registerNamespace($nsPrefix, $nsUri);
57 * Transfers each child and attribute into member variables.
58 * This is called when XML is received over the wire and the data
59 * model needs to be built to represent this XML.
61 * @param DOMNode $node The DOMNode that represents this object's data
63 public function transferFromDOM($node)
65 $this->_ccrDom = $node;
69 * Retrieves a DOMElement which corresponds to this element and all
70 * child properties. This is used to build an entry back into a DOM
71 * and eventually XML text for sending to the server upon updates, or
72 * for application storage/persistence.
74 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
75 * @return DOMElement The DOMElement representing this element and all
78 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
81 $doc = new DOMDocument('1.0', 'utf-8');
83 $domElement = $doc->importNode($this->_ccrDom, true);
88 * Magic helper that allows drilling down and returning specific elements
89 * in the CCR. For example, to retrieve the users medications
90 * (/ContinuityOfCareRecord/Body/Medications) from the entry's CCR, call
91 * $entry->getCcr()->getMedications(). Similarly, getConditions() would
92 * return extract the user's conditions.
94 * @param string $name Name of the function to call
95 * @param unknown $args
96 * @return array.<DOMElement> A list of the appropriate CCR data
98 public function __call($name, $args)
100 if (substr($name, 0, 3) === 'get') {
101 $category = substr($name, 3);
105 $category = 'Problems';
108 $category = 'Alerts';
111 // TestResults is an alias for LabResults
113 $category = 'Results';
116 // $category is already well formatted
119 return $this->_ccrDom->getElementsByTagNameNS($this->lookupNamespace('ccr'), $category);