Highway to PSR2
[openemr.git] / interface / modules / zend_modules / module / Carecoordination / src / Carecoordination / Model / CcdTable.php
blobb4d7c8606ab056a31f2f3576dad6ff6b610b06db
1 <?php
2 /* +-----------------------------------------------------------------------------+
3 * OpenEMR - Open Source Electronic Medical Record
4 * Copyright (C) 2014 Z&H Consultancy Services Private Limited <sam@zhservices.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * @author Riju KP <rijukp@zhservices.com>
20 * +------------------------------------------------------------------------------+
22 namespace Carecoordination\Model;
24 use Zend\Db\TableGateway\AbstractTableGateway;
25 use Application\Model\ApplicationTable;
26 use Zend\Db\Adapter\Driver\Pdo\Result;
27 use Zend\XmlRpc\Generator;
29 use DOMDocument;
30 use DOMXpath;
32 use Document;
33 use CouchDB;
35 use Documents\Model\DocumentsTable;
37 class CcdTable extends AbstractTableGateway
39 protected $ccd_data_array;
42 * Fetch the component values from the CCDA XML*
44 * @param $components Array of components
46 public function import($xml, $document_id)
48 $audit_master_approval_status = $this->ccd_data_array['approval_status'] = 1;
49 $this->ccd_data_array['ip_address'] = $_SERVER['REMOTE_ADDR'];
50 $this->ccd_data_array['type'] = '13';
52 //Patient Details
53 $this->ccd_data_array['field_name_value_array']['patient_data'][1]['fname'] = $xml['recordTarget']['patientRole']['patient']['name']['given'][0];
54 $this->ccd_data_array['field_name_value_array']['patient_data'][1]['mname'] = $xml['recordTarget']['patientRole']['patient']['name']['given'][1];
55 $this->ccd_data_array['field_name_value_array']['patient_data'][1]['lname'] = $xml['recordTarget']['patientRole']['patient']['name']['family'];
56 $this->ccd_data_array['field_name_value_array']['patient_data'][1]['DOB'] = $xml['recordTarget']['patientRole']['patient']['birthTime']['value'];
57 $this->ccd_data_array['field_name_value_array']['patient_data'][1]['sex'] = $xml['recordTarget']['patientRole']['patient']['administrativeGenderCode']['displayName'];
58 $this->ccd_data_array['field_name_value_array']['patient_data'][1]['street'] = $xml['recordTarget']['patientRole']['addr']['streetAddressLine'];
59 $this->ccd_data_array['field_name_value_array']['patient_data'][1]['city'] = $xml['recordTarget']['patientRole']['addr']['city'];
60 $this->ccd_data_array['field_name_value_array']['patient_data'][1]['state'] = $xml['recordTarget']['patientRole']['addr']['state'];
61 $this->ccd_data_array['field_name_value_array']['patient_data'][1]['postal_code'] = $xml['recordTarget']['patientRole']['addr']['postalCode'];
62 $this->ccd_data_array['field_name_value_array']['patient_data'][1]['phone_home'] = preg_replace('/[^0-9]+/i', '', $xml['recordTarget']['patientRole']['telecom']['value']);
63 $this->ccd_data_array['field_name_value_array']['patient_data'][1]['extension'] = $xml['recordTarget']['patientRole']['id']['extension'];
66 $audit_master_id = \Application\Plugin\CommonPlugin::insert_ccr_into_audit_data($this->ccd_data_array);
67 $this->update_document_table($document_id, $audit_master_id, $audit_master_approval_status);
70 public function update_document_table($document_id, $audit_master_id, $audit_master_approval_status)
72 $appTable = new ApplicationTable();
73 $query = "UPDATE documents
74 SET audit_master_id = ?,
75 imported = ?,
76 audit_master_approval_status=?
77 WHERE id = ?";
78 $appTable->zQuery($query, array($audit_master_id,
80 $audit_master_approval_status,
81 $document_id));