public function testInvalidXMLFormat() { $data = array(); $person = array(); $person['person_id'] = 1234; $person['first_name'] = 'Test'; $person['last_name'] = 'ClearHealth'; $data['person'] = $person; // invalid XML format: close tag of xsl:template is xsl:templates $templateXSLT = <<<EOL <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="person"> <xsl:value-of select="person_id"/>-<xsl:value-of select="first_name"/>-<xsl:value-of select="last_name"/> </xsl:templates> </xsl:stylesheet> EOL; $assert = false; $msg = ''; try { $template = TemplateXSLT::render($data, $templateXSLT); } catch (Exception $e) { $assert = true; $msg = $e->getMessage(); } $this->assertTrue($assert, $msg); }
protected function _doProcess(GeneralAlertHandler $handler, Audit $audit) { $handlerName = Handler::normalizeHandlerName($handler->name); $classHandlerObject = $handlerName . 'GeneralAlertHandlerObject'; if (!parent::isParentOf($classHandlerObject, 'GeneralAlertHandlerObjectAbstract')) { trigger_error($classHandlerObject . ' is not an instance of GeneralAlertHandlerObjectAbstract', E_USER_NOTICE); return false; } $ret = false; if (call_user_func_array(array($classHandlerObject, 'matchAudit'), array($audit))) { do { $classDatasource = $handlerName . 'GeneralAlertDatasource'; if (!parent::isParentOf($classDatasource, 'GeneralAlertDatasourceAbstract')) { trigger_error($classDatasource . ' is not an instance of GeneralAlertDatasourceAbstract', E_USER_NOTICE); break; } try { $data = call_user_func_array(array($classDatasource, 'sourceData'), array($audit)); } catch (Exception $e) { trigger_error('Exception error (' . $e->getCode() . '): ' . $e->getMessage(), E_USER_NOTICE); break; } $ret = true; if (!strlen($handler->template) > 0) { $handler->template = $handler->generateDefaultTemplate(); } foreach ($data as $row) { $message = TemplateXSLT::render($row, $handler->template); $generalAlert = new GeneralAlert(); $generalAlert->message = $message; $generalAlert->urgency = 'Med'; $generalAlert->status = 'new'; $generalAlert->dateTime = date('Y-m-d H:i:s'); if (isset($row['teamId'])) { $generalAlert->teamId = $row['teamId']; } if (isset($row['signingUserId'])) { $generalAlert->userId = $row['signingUserId']; } if (isset($row['objectId'])) { $generalAlert->objectId = $row['objectId']; } if (isset($row['objectClass'])) { $generalAlert->objectClass = $row['objectClass']; } $generalAlert->persist(); } } while (false); } return $ret; }
protected function _doProcess(Handler $handler, Audit $audit) { $ret = false; $handlerName = $handler->normalizedName; $datasourceName = $handler->dataIntegrationDatasource->normalizedName; $destinationName = $handler->dataIntegrationDestination->normalizedName; $actionName = $handler->dataIntegrationAction->normalizedName; $classConditionHandler = $handlerName . 'ConditionHandler'; if (!parent::isParentOf($classConditionHandler, 'DataIntegrationConditionHandlerAbstract')) { return false; } if (call_user_func_array(array($classConditionHandler, 'matchAudit'), array($audit))) { do { $classDatasource = $datasourceName . 'DataIntegrationDatasource'; if (!parent::isParentOf($classDatasource, 'DataIntegrationDatasourceAbstract')) { return false; } $data = call_user_func_array(array($classDatasource, 'sourceData'), array($audit)); switch ($handler->direction) { case 'INCOMING': $classAction = $actionName . 'DataIntegrationAction'; if (!parent::isParentOf($classAction, 'DataIntegrationActionAbstract')) { return false; } $ret = call_user_func_array(array($classAction, 'act'), array($audit, $data)); break; case 'OUTGOING': $classDestination = $destinationName . 'DataIntegrationDestination'; if (!parent::isParentOf($classDestination, 'DataIntegrationDestinationAbstract')) { return false; } $template = new DataIntegrationTemplate(); $template->dataIntegrationTemplateId = $handler->dataIntegrationTemplateId; $template->populate(); $data['msh'] = HL7Message::generateMSHData($audit); $template->template = TemplateXSLT::render($data, $template->template); // temporarily override the template $ret = call_user_func_array(array($classDestination, 'transmit'), array($audit, $template, $data)); // temporarily set to true, transmit() skeleton does not provide boolean return $ret = true; break; } } while (false); } return $ret; }
protected function _doDailyProcess() { try { $cacheCodeObjects = Zend_Registry::get('cacheCodeObjects'); } catch (Exception $e) { $cacheCodeObjects = array(); } $handlerPatient = new HealthStatusHandlerPatient(); $handlerPatientIterator = $handlerPatient->getIterator(); foreach ($handlerPatientIterator as $row) { $handler = $row->healthStatusHandler; $patient = $row->person; $patientId = $patient->personId; $handlerObject = $handler->handlerObject; if (!strlen($handlerObject) > 0) { $handlerObject = $handler->generateDefaultHandlerObject(); } $md5 = md5($handlerObject); if (!in_array($md5, $cacheCodeObjects)) { $cacheCodeObjects[] = $md5; eval($handlerObject); // TODO: needs to be validated } $datasource = $handler->datasource; if (!strlen($datasource) > 0) { $datasource = $handler->generateDefaultDatasource(); } $md5 = md5($datasource); if (!in_array($md5, $cacheCodeObjects)) { $cacheCodeObjects[] = $md5; eval($datasource); // TODO: needs to be validated } $handlerName = Handler::normalizeHandlerName($handler->name); $classHandlerObject = $handlerName . 'HealthStatusHandlerObject'; if (!parent::isParentOf($classHandlerObject, 'HealthStatusHandlerObjectAbstract')) { trigger_error($classHandlerObject . ' is not an instance of HealthStatusHandlerObjectAbstract', E_USER_NOTICE); continue; } $retPatientMatch = call_user_func_array(array($classHandlerObject, 'patientMatch'), array($handler, $patientId)); if ($retPatientMatch !== false) { $classHealthStatusDatasource = $handlerName . 'HealthStatusDatasource'; if (!parent::isParentOf($classHealthStatusDatasource, 'HealthStatusDatasourceAbstract')) { trigger_error($classHealthStatusDatasource . ' is not an instance of HealthStatusDatasourceAbstract', E_USER_NOTICE); continue; } try { $retSourcedata = call_user_func_array(array($classHealthStatusDatasource, 'sourceData'), array($patientId, $retPatientMatch)); } catch (Exception $e) { trigger_error('Exception error (' . $e->getCode() . '): ' . $e->getMessage(), E_USER_NOTICE); continue; } if (!strlen($handler->template) > 0) { $handler->template = $handler->generateDefaultTemplate(); } $message = TemplateXSLT::render($retSourcedata, $handler->template); $healthStatusAlert = new HealthStatusAlert(); $healthStatusAlert->message = $message; $healthStatusAlert->status = 'active'; $healthStatusAlert->personId = $patientId; $healthStatusAlert->healthStatusHandlerId = $handler->healthStatusHandlerId; $healthStatusAlert->dateDue = date('Y-m-d H:i:s', strtotime($handler->timeframe)); $healthStatusAlert->persist(); } else { $retFulfill = call_user_func_array(array($classHandlerObject, 'fulfill'), array($handler, $patientId)); } } Zend_Registry::set('cacheCodeObjects', $cacheCodeObjects); }
public static function render4010A1(ClaimFile $claimFile, array $claimIds = null) { if ($claimIds == null) { $claimIds = explode(',', $claimFile->claimIds); } $claimFileId = (int) $claimFile->claimFileId; $claim = array('claimId' => $claimFileId); if (isset($claimIds[0])) { $claimId = (int) $claimIds[0]; $claimLine = new ClaimLine(); $claimLine->populateByClaimId($claimId); $visit = new Visit(); $visit->visitId = (int) $claimLine->visitId; $visit->populate(); $practiceId = (int) $visit->practiceId; } else { $practiceId = (int) $claimFile->user->person->primaryPracticeId; } $practice = new Practice(); $practice->practiceId = $practiceId; $practice->populate(); $senderId = $practice->practiceId; if (strlen($senderId) < 2) { $senderId = str_pad($senderId, 2, '0', STR_PAD_LEFT); } $phoneNumber = PhoneNumber::autoFixNumber($practice->mainPhone->number); $phoneLen = strlen($phoneNumber); if ($phoneLen < 10) { $phoneNumber = str_pad($phoneNumber, 10, '0', STR_PAD_LEFT); } else { if ($phoneLen > 10) { $phoneNumber = substr($phoneNumber, -10); } } $practiceData = array('senderId' => $senderId, 'name' => $practice->name, 'phoneNumber' => $phoneNumber); $ISA = array(); list($dateNow, $timeNow) = explode(' ', date('ymd Hi')); $ISA['dateNow'] = $dateNow; $ISA['timeNow'] = $timeNow; $ISA['claim'] = $claim; $ISA['practice'] = $practiceData; $GS = array(); list($dateNow, $timeNow) = explode(' ', date('Ymd Hi')); $GS['dateNow'] = $dateNow; $GS['timeNow'] = $timeNow; $GS['practice'] = $practiceData; $GS['claim'] = $claim; $GS['payer'] = array('identifier_type' => '46'); $HL = array(); foreach ($claimIds as $claimId) { $HL[] = self::_generate4010A1($claimId, $claim); } $data = array(); $data['HL'] = $HL; $arr = array(); $arr['ISA'] = $ISA; $arr['GS'] = $GS; $arr['data'] = $data; $basePath = Zend_Registry::get('basePath'); $template = $basePath . 'application/templates/x12_al_ens_unitedhealthcare.xsl'; $templateXSLT = file_get_contents($template); $data = explode('~', TemplateXSLT::render($arr, $templateXSLT)); return str_replace('SEGMENT_CTR', count($data) - 5, implode("~\r\n", $data)); }