13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Gdata |
16 * @package Zend_Gdata |
17 * @subpackage Health |
17 * @subpackage Health |
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 * @version $Id: Ccr.php 20096 2010-01-06 02:05:09Z bkarwin $ |
20 * @version $Id: Ccr.php 24779 2012-05-08 19:13:59Z adamlundrigan $ |
21 */ |
21 */ |
|
22 |
|
23 /** |
|
24 * @see Zend_Exception |
|
25 */ |
|
26 require_once 'Zend/Exception.php'; |
22 |
27 |
23 /** |
28 /** |
24 * @see Zend_Gdata_App_Extension_Element |
29 * @see Zend_Gdata_App_Extension_Element |
25 */ |
30 */ |
26 require_once 'Zend/Gdata/App/Extension/Element.php'; |
31 require_once 'Zend/Gdata/App/Extension/Element.php'; |
29 * Concrete class for working with CCR elements. |
34 * Concrete class for working with CCR elements. |
30 * |
35 * |
31 * @category Zend |
36 * @category Zend |
32 * @package Zend_Gdata |
37 * @package Zend_Gdata |
33 * @subpackage Health |
38 * @subpackage Health |
34 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
39 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
35 * @license http://framework.zend.com/license/new-bsd New BSD License |
40 * @license http://framework.zend.com/license/new-bsd New BSD License |
36 */ |
41 */ |
37 class Zend_Gdata_Health_Extension_Ccr extends Zend_Gdata_App_Extension_Element |
42 class Zend_Gdata_Health_Extension_Ccr extends Zend_Gdata_App_Extension_Element |
38 { |
43 { |
39 protected $_rootNamespace = 'ccr'; |
|
40 protected $_rootElement = 'ContinuityOfCareRecord'; |
|
41 protected $_ccrDom = null; |
|
42 |
|
43 /** |
44 /** |
44 * Creates a Zend_Gdata_Health_Extension_Ccr entry, representing CCR data |
45 * Creates a Zend_Gdata_Health_Extension_Ccr entry, representing CCR data |
45 * |
46 * |
46 * @param DOMElement $element (optional) DOMElement from which this |
47 * @param DOMElement $element (optional) DOMElement from which this |
47 * object should be constructed. |
48 * object should be constructed. |
48 */ |
49 */ |
49 public function __construct($element = null) |
50 public function __construct($element = null) |
50 { |
51 { |
51 foreach (Zend_Gdata_Health::$namespaces as $nsPrefix => $nsUri) { |
52 throw new Zend_Exception( |
52 $this->registerNamespace($nsPrefix, $nsUri); |
53 'Google Health API has been discontinued by Google and was removed' |
53 } |
54 . ' from Zend Framework in 1.12.0. For more information see: ' |
54 } |
55 . 'http://googleblog.blogspot.ca/2011/06/update-on-google-health-and-google.html' |
55 |
56 ); |
56 /** |
|
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. |
|
60 * |
|
61 * @param DOMNode $node The DOMNode that represents this object's data |
|
62 */ |
|
63 public function transferFromDOM($node) |
|
64 { |
|
65 $this->_ccrDom = $node; |
|
66 } |
|
67 |
|
68 /** |
|
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. |
|
73 * |
|
74 * @param DOMDocument $doc The DOMDocument used to construct DOMElements |
|
75 * @return DOMElement The DOMElement representing this element and all |
|
76 * child properties. |
|
77 */ |
|
78 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) |
|
79 { |
|
80 if ($doc === null) { |
|
81 $doc = new DOMDocument('1.0', 'utf-8'); |
|
82 } |
|
83 $domElement = $doc->importNode($this->_ccrDom, true); |
|
84 return $domElement; |
|
85 } |
|
86 |
|
87 /** |
|
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. |
|
93 * |
|
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 |
|
97 */ |
|
98 public function __call($name, $args) |
|
99 { |
|
100 if (substr($name, 0, 3) === 'get') { |
|
101 $category = substr($name, 3); |
|
102 |
|
103 switch ($category) { |
|
104 case 'Conditions': |
|
105 $category = 'Problems'; |
|
106 break; |
|
107 case 'Allergies': |
|
108 $category = 'Alerts'; |
|
109 break; |
|
110 case 'TestResults': |
|
111 // TestResults is an alias for LabResults |
|
112 case 'LabResults': |
|
113 $category = 'Results'; |
|
114 break; |
|
115 default: |
|
116 // $category is already well formatted |
|
117 } |
|
118 |
|
119 return $this->_ccrDom->getElementsByTagNameNS($this->lookupNamespace('ccr'), $category); |
|
120 } else { |
|
121 return null; |
|
122 } |
|
123 } |
57 } |
124 } |
58 } |