function listItemsAction() { $eSignIterator = new ESignatureIterator(); $objectId = (int) $this->_getParam('objectId'); if ($objectId > 0) { $eSignIterator->setFilter($objectId, 'objectId'); } else { $eSignIterator->setFilter((int) Zend_Auth::getInstance()->getIdentity()->personId, 'signList'); } //var_dump($db->query($cnSelect)->fetchAll());exit; $baseStr = "<?xml version='1.0' standalone='yes'?><rows></rows>"; $xml = new SimpleXMLElement($baseStr); $currentCat = null; $category = null; // override the include_path to include controllers path set_include_path(realpath(Zend_Registry::get('basePath') . '/application/controllers') . PATH_SEPARATOR . get_include_path()); foreach ($eSignIterator as $row) { $row = $row->toArray(); if ($currentCat != $row['objectClass']) { $currentCat = $row['objectClass']; $category = $xml->addChild("row"); $category->addAttribute("id", $row['objectClass']); $cell = $category->addChild("cell", call_user_func($currentCat . "::" . "getPrettyName", array())); $cell = $category->addChild("cell", ''); $controllerName = call_user_func($currentCat . "::" . "getControllerName"); $jumpLink = call_user_func_array($controllerName . "::" . "buildJSJumpLink", array($row['objectId'], $row['signingUserId'], $row['objectClass'])); //$jumpLink = $this->buildJSJumpLink($row['objectId'],$row['signingUserId'],$row['objectClass']); $js = "function jumpLink{$row['objectClass']}(objectId,patientId) {\n{$jumpLink}\n}"; $cell = $category->addChild('cell', $js); } $leaf = $category->addChild("row"); $leaf->addAttribute('id', $row['eSignatureId']); $leaf->addChild('cell', $row['dateTime'] . " " . $row['summary']); $leaf->addChild('cell', ''); // hidden column that will load the correct tab $leaf->addChild('cell', $row['objectId']); // temporary set to objectId //$leaf->addChild('cell',$this->buildJSJumpLink($row['objectId'],$row['signingUserId'])); // for patientId hidden column, not sure if this is the correct field. //$leaf->addChild('cell',$row['signingUserId']); $obj = new $row['objectClass'](); foreach ($obj->_primaryKeys as $key) { $obj->{$key} = $row['objectId']; } $obj->populate(); $patientId = $obj->personId; $leaf->addChild('cell', $patientId); } header('content-type: text/xml'); $this->view->content = $xml->asXml(); $this->render(); }
function listItemsAction() { $eSignIterator = new ESignatureIterator(); $objectId = (int) $this->_getParam('objectId'); if ($objectId > 0) { $eSignIterator->setFilter($objectId, 'objectId'); } else { $eSignIterator->setFilter((int) Zend_Auth::getInstance()->getIdentity()->personId, 'signList'); } //var_dump($db->query($cnSelect)->fetchAll());exit; $baseStr = "<?xml version='1.0' standalone='yes'?><rows></rows>"; $xml = new SimpleXMLElement($baseStr); $currentCat = null; $category = null; // override the include_path to include controllers path set_include_path(realpath(Zend_Registry::get('basePath') . '/application/controllers') . PATH_SEPARATOR . get_include_path()); foreach ($eSignIterator as $row) { $row = $row->toArray(); $obj = new $row['objectClass'](); foreach ($obj->_primaryKeys as $key) { $obj->{$key} = $row['objectId']; } if (!$obj->populate()) { continue; } // signing but actual object does not exists if ($currentCat != $row['objectClass']) { $currentCat = $row['objectClass']; $category = $xml->addChild("row"); $category->addAttribute("style", 'height:20px;'); $category->addAttribute("id", $row['objectClass']); $cell = $category->addChild("cell", call_user_func($currentCat . "::" . "getPrettyName", array())); $cell = $category->addChild("cell", ''); $controllerName = call_user_func($currentCat . "::" . "getControllerName"); $jumpLink = call_user_func_array($controllerName . "::" . "buildJSJumpLink", array($row['objectId'], $row['signingUserId'], $row['objectClass'])); //$jumpLink = $this->buildJSJumpLink($row['objectId'],$row['signingUserId'],$row['objectClass']); $js = "function jumpLink{$row['objectClass']}(objectId,patientId) {\n{$jumpLink}\n}"; // $cell = $category->addChild('cell',$js); $userdata = $category->addChild('userdata', $js); $userdata->addAttribute('name', 'js'); } $leaf = $category->addChild("row"); $leaf->addAttribute('id', $row['eSignatureId']); $leaf->addChild('cell', $row['dateTime'] . " " . preg_replace('/[<>]/', '', $row['summary'])); $leaf->addChild('cell', ''); $userdata = $leaf->addChild('userdata', $row['objectId']); $userdata->addAttribute('name', 'objectId'); // hidden column that will load the correct tab // $leaf->addChild('cell',$row['objectId']); // temporary set to objectId //$leaf->addChild('cell',$this->buildJSJumpLink($row['objectId'],$row['signingUserId'])); // for patientId hidden column, not sure if this is the correct field. //$leaf->addChild('cell',$row['signingUserId']); $patientId = $obj->personId; $userdata = $leaf->addChild('userdata', $patientId); $userdata->addAttribute('name', 'patientId'); //$leaf->addChild('cell',$patientId); // add a subrow for other info if ($row['objectClass'] == 'Medication') { $pharmacyInfo = array(); // $obj refers to Medication ORM if ($obj->isScheduled()) { $pharmacyInfo[] = 'Medication is a controlled substance, it cannot be sent electronically. The Rx will be printed and needs a wet signature before it can be faxed to the pharmacy or handed to the patient.'; } else { $pharmacy = $obj->pharmacy; if (strlen($pharmacy->StoreName) > 0) { $pharmacyInfo[] = $pharmacy->StoreName; $address = $pharmacy->AddressLine1; if (strlen($pharmacy->AddressLine2) > 0) { $address .= ' ' . $pharmacy->AddressLine2; } $address .= ', ' . $pharmacy->City; $address .= ', ' . $pharmacy->State; $address .= ', ' . $pharmacy->Zip; $pharmacyInfo[] = $address; $phones = array(); $phones[] = $pharmacy->PhonePrimary; if (strlen($pharmacy->Fax) > 0) { $phones[] = $pharmacy->Fax; } if (strlen($pharmacy->PhoneAlt1) > 0) { $phones[] = $pharmacy->PhoneAlt1; } if (strlen($pharmacy->PhoneAlt2) > 0) { $phones[] = $pharmacy->PhoneAlt2; } if (strlen($pharmacy->PhoneAlt3) > 0) { $phones[] = $pharmacy->PhoneAlt3; } if (strlen($pharmacy->PhoneAlt4) > 0) { $phones[] = $pharmacy->PhoneAlt4; } if (strlen($pharmacy->PhoneAlt5) > 0) { $phones[] = $pharmacy->PhoneAlt5; } $pharmacyInfo[] = implode(', ', $phones); } else { $pharmacyInfo[] = 'No pharmacy selected'; } } $pharmacyInfo = implode(" <br /> ", $pharmacyInfo); $patient = new Patient(); $patient->personId = $obj->personId; $patient->populate(); $patientInfo = $patient->lastName . ", " . $patient->firstName . " " . strtoupper(substr($patient->middleName, 0, 1)) . " #" . $patient->recordNumber; $qualifiers = Medication::listQuantityQualifiersMapping(); $medicationInfo = array(); $rxn = $obj->rxReferenceNumber; if (strlen($rxn) > 0) { $medicationInfo[] = 'Rx Reference Number: ' . $rxn; } $medicationInfo[] = 'Description: ' . htmlspecialchars($obj->description); $medicationInfo[] = 'Directions: ' . htmlspecialchars($obj->directions); $medicationInfo[] = 'Quantity: ' . $obj->quantity . ' ' . $qualifiers[$obj->quantityQualifier]; //$medicationInfo[] = 'Quantity: '.$obj->quantity.' '.$obj->quantityQualifier; $medicationInfo[] = 'Strength: ' . $obj->dose . ' ' . $qualifiers[$obj->quantityQualifier]; //$medicationInfo[] = 'Strength: '.$obj->dose.' '.$obj->quantityQualifier; $medicationInfo[] = 'Days Supply: ' . $obj->daysSupply; $refills = $obj->refills; if ($obj->prn) { $refills = 'PRN'; } $medicationInfo[] = 'Refills: ' . $refills; $substitution = 'Permitted'; if ($obj->substitution == 0) { $substitution = 'Not Permitted'; } $medicationInfo[] = 'Substitutions: ' . $substitution; $medicationInfo[] = 'Date Prescribed: ' . date('Y-m-d', strtotime($obj->datePrescribed)); //$medicationInfo[] = 'NDC: '.$obj->hipaaNDC; //$medicationInfo[] = 'Dosage Form: '.DataTables::getDosageForm($obj->chmedDose); //$medicationInfo[] = 'DB Code: '.$obj->pkey; $medicationInfo[] = 'Note: ' . htmlspecialchars($obj->comment); $medicationInfo = implode(' <br /> ', $medicationInfo); $info = '<div style="margin-left:75px;margin-top:-18px;margin-bottom:5px;"> <fieldset> <legend title="' . htmlspecialchars($patientInfo) . '">' . __('Patient') . '</legend>' . htmlspecialchars($patientInfo) . ' </fieldset> <fieldset> <legend title="' . htmlspecialchars($pharmacyInfo) . '">' . __('Pharmacy') . '</legend>' . htmlspecialchars($pharmacyInfo) . ' </fieldset> <fieldset title="' . htmlspecialchars($medicationInfo) . '"> <legend>' . __('Medication') . '</legend>' . htmlspecialchars($medicationInfo) . ' </fieldset></div>'; $node = $leaf->addChild('row'); $guid = NSDR::create_guid(); $node->addAttribute('id', $guid); // $node->addAttribute('style','vertical-align:top;height:50px;'); $node->addChild('cell', '<![CDATA[' . $info . ']]>'); $node->addChild('cell', ''); $node->addChild('cell', ''); $node->addChild('cell', ''); } } header('content-type: text/xml'); $this->view->content = $xml->asXml(); $this->view->content = html_entity_decode($this->view->content); file_put_contents('/tmp/esign.xml', $this->view->content); $this->render(); }
function deleteNoteAction() { $clinicalNoteId = $this->_getParam('clinicalNoteId'); $db = Zend_Registry::get('dbAdapter'); $signatureIterator = new ESignatureIterator(); $signatureIterator->setFilter($clinicalNoteId); $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $clinicalNote = new ClinicalNote(); $clinicalNote->clinicalNoteId = (int) $clinicalNoteId; if (!$clinicalNote->populate()) { // just remove the revision history $db->delete("genericData", "objectClass = 'ClinicalNote' and revisionId = " . (int) $clinicalNoteId); $json->direct(true); return; } if (!$signatureIterator->valid()) { $db->beginTransaction(); try { $db->delete("eSignatures", "objectClass = 'ClinicalNote' and objectId = " . (int) $clinicalNoteId); // TODO: objectId refers to genericData.revisionId $db->delete("clinicalNotes", "clinicalNoteId = " . (int) $clinicalNoteId); $db->delete("genericData", "objectClass = 'ClinicalNote' and objectId = " . (int) $clinicalNoteId); $db->commit(); } catch (Exception $e) { $db->rollBack(); $this->getResponse()->setHttpResponseCode(500); $json->direct(array('error' => $e->getMessage())); return; } $json->direct(true); return; } $this->getResponse()->setHttpResponseCode(500); $json->direct(array('error' => "You cannot delete a note which has previously been signed.")); }