1 | <?php
|
---|
2 | /**
|
---|
3 | * Zend Framework
|
---|
4 | *
|
---|
5 | * LICENSE
|
---|
6 | *
|
---|
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.
|
---|
14 | *
|
---|
15 | * @category Zend
|
---|
16 | * @package Zend_Gdata
|
---|
17 | * @subpackage Health
|
---|
18 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
19 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
20 | * @version $Id: Ccr.php 13522 2009-01-06 16:35:55Z thomas $
|
---|
21 | */
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * @see Zend_Gdata_App_Extension_Element
|
---|
25 | */
|
---|
26 | require_once 'Zend/Gdata/App/Extension/Element.php';
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Concrete class for working with CCR elements.
|
---|
30 | *
|
---|
31 | * @category Zend
|
---|
32 | * @package Zend_Gdata
|
---|
33 | * @subpackage Health
|
---|
34 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
35 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
36 | */
|
---|
37 | class Zend_Gdata_Health_Extension_Ccr extends Zend_Gdata_App_Extension_Element
|
---|
38 | {
|
---|
39 | protected $_rootNamespace = 'ccr';
|
---|
40 | protected $_rootElement = 'ContinuityOfCareRecord';
|
---|
41 | protected $_ccrDom = null;
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Creates a Zend_Gdata_Health_Extension_Ccr entry, representing CCR data
|
---|
45 | *
|
---|
46 | * @param DOMElement $element (optional) DOMElement from which this
|
---|
47 | * object should be constructed.
|
---|
48 | */
|
---|
49 | public function __construct($element = null)
|
---|
50 | {
|
---|
51 | foreach (Zend_Gdata_Health::$namespaces as $nsPrefix => $nsUri) {
|
---|
52 | $this->registerNamespace($nsPrefix, $nsUri);
|
---|
53 | }
|
---|
54 | }
|
---|
55 |
|
---|
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 | * @return array.<DOMElement> A list of the appropriate CCR data
|
---|
96 | */
|
---|
97 | public function __call($name, $args)
|
---|
98 | {
|
---|
99 | $matches = array();
|
---|
100 |
|
---|
101 | if (substr($name, 0, 3) === 'get') {
|
---|
102 | $category = substr($name, 3);
|
---|
103 |
|
---|
104 | switch ($category) {
|
---|
105 | case 'Conditions':
|
---|
106 | $category = 'Problems';
|
---|
107 | break;
|
---|
108 | case 'Allergies':
|
---|
109 | $category = 'Alerts';
|
---|
110 | break;
|
---|
111 | case 'TestResults':
|
---|
112 | // TestResults is an alias for LabResults
|
---|
113 | case 'LabResults':
|
---|
114 | $category = 'Results';
|
---|
115 | break;
|
---|
116 | default:
|
---|
117 | // $category is already well formatted
|
---|
118 | }
|
---|
119 |
|
---|
120 | return $this->_ccrDom->getElementsByTagNameNS($this->lookupNamespace('ccr'), $category);
|
---|
121 | } else {
|
---|
122 | return null;
|
---|
123 | }
|
---|
124 | }
|
---|
125 | }
|
---|