/** * getPagesByCategory * @author Cornelius Hansjakob <*****@*****.**> * @version 1.0 */ public function getPagesByCategory() { try { $this->getModelPages(); $intCategoryId = $this->objGenericData->Setup()->getField('top_category')->getValue(); $intLabelId = $this->objGenericData->Setup()->getField('top_label')->getValue(); $intLimitNumber = $this->objGenericData->Setup()->getField('top_number')->getValue(); $intSortType = $this->objGenericData->Setup()->getField('top_sorttype')->getValue(); $intSortOrder = $this->objGenericData->Setup()->getField('top_sortorder')->getValue(); $objPages = $this->objModelPages->loadsByCategory($this->intRootLevelId, $intCategoryId, $intLabelId, $intLimitNumber, $intSortType, $intSortOrder); return $objPages; } catch (Exception $exc) { $this->core->logger->err($exc); } }
/** * addFolderStartGlobal * @param array $arrArgs * @return boolean * @author Thomas Schedler <*****@*****.**> * @version 1.0 */ private function addFolderStartGlobal($arrArgs) { try { if (array_key_exists('GenericSetup', $arrArgs) && $arrArgs['GenericSetup'] instanceof GenericSetup) { $objGenericSetup = $arrArgs['GenericSetup']; $strGlobalType = $this->strRootLevelGroupKey . '_overview'; $intTemplateId = $this->core->sysConfig->global_types->{$strGlobalType}->default_templateId; $objTemplateData = $this->getModelTemplates()->loadTemplateById($intTemplateId); if (count($objTemplateData) == 1) { $objTemplate = $objTemplateData->current(); /** * set form id from template */ $strFormId = $objTemplate->genericFormId; $intFormVersion = $objTemplate->version; $intFormTypeId = $objTemplate->formTypeId; } else { throw new Exception('Not able to create a generic data object, because there is no form id!'); } $objGenericData = new GenericData(); $objGenericData->Setup()->setFormId($strFormId); $objGenericData->Setup()->setFormVersion($intFormVersion); $objGenericData->Setup()->setFormTypeId($intFormTypeId); $objGenericData->Setup()->setTemplateId($intTemplateId); $objGenericData->Setup()->setActionType($this->core->sysConfig->generic->actions->add); $objGenericData->Setup()->setLanguageId($arrArgs['LanguageId']); $objGenericData->Setup()->setFormLanguageId($this->core->intZooluLanguageId); $objGenericData->Setup()->setParentId($arrArgs['ParentId']); $objGenericData->Setup()->setRootLevelId($objGenericSetup->getRootLevelId()); $objGenericData->Setup()->setRootLevelGroupId($this->intRootLevelGroupId); $objGenericData->Setup()->setElementTypeId($this->core->sysConfig->global_types->{$strGlobalType}->id); $objGenericData->Setup()->setCreatorId($objGenericSetup->getCreatorId()); $objGenericData->Setup()->setStatusId($objGenericSetup->getStatusId()); $objGenericData->Setup()->setShowInNavigation($objGenericSetup->getShowInNavigation()); $objGenericData->Setup()->setModelSubPath('global/models/'); $objGenericData->addFolderStartElement($objGenericSetup->getCoreField('title')->getValue()); return true; } else { throw new Exception('There ist now GenericSetup in the args array!'); } } catch (Exception $exc) { $this->core->logger->err($exc); return false; } }
function listNotesAction() { $personId = 0; $personId = (int) $this->_getParam('personId'); $filter = $this->_getParam('filter'); $clinicalNoteIterator = new ClinicalNoteIterator(); $custom = $this->_getParam('custom'); if (count($custom) > 0) { $custom = $this->_getParam('custom'); $custom['personId'] = $personId; $clinicalNoteIterator->customView($custom); } else { $data = array(); $data['personId'] = $personId; if ($filter == 'byAuthoringPersonId') { $data['authoringPersonId'] = $this->_getParam('authoringPersonId'); } if ($filter == 'byDateRange') { $data['dateRange'] = $this->_getParam('dateRange'); } if ($filter == 'byCurrentPractice' || $filter == 'bySelectedVisit') { $visitId = (int) $this->_getParam('visitId'); $visit = new Visit(); $visit->visitId = $visitId; $visit->populate(); $building = new Building(); $building->buildingId = $visit->buildingId; $building->populate(); $data['locationId'] = $building->buildingId; $data['selectedVisit'] = date('Y-m-d', strtotime($visit->timestamp)); } if ($filter == 'byVisitPractice' || $filter == 'byVisitBuilding') { $practiceId = 0; $buildingId = 0; $identity = Zend_Auth::getInstance()->getIdentity(); $userId = $identity->userId; $user = new User(); $user->userId = $userId; $user->populate(); if (strlen($user->preferences) > 0) { $this->xmlPreferences = new SimpleXMLElement($user->preferences); $currentLocation = (string) $this->xmlPreferences->currentLocation; $locationId = (int) $currentLocation; if ($locationId > 0) { $room = new Room(); $room->roomId = $locationId; $room->populate(); $practiceId = $room->building->practiceId; $buildingId = $room->buildingId; } } $data['practiceId'] = $practiceId; $data['buildingId'] = $buildingId; } $clinicalNoteIterator->setFilter($filter, $data); } //trigger_error($cnSelect->__toString(),E_USER_NOTICE); //var_dump($db->query($cnSelect)->fetchAll());exit; $notes = array(); foreach ($clinicalNoteIterator as $note) { if ($note['eSignatureId'] > 0) { $img = 'sm-signed.png'; $alt = 'Signed'; } else { $img = 'sm-editproblem.png'; $alt = 'Editing'; } $icon = '<img src="' . Zend_Registry::get('baseUrl') . 'img/' . $img . '" alt="' . $alt . '" />'; $row = array(); $row['id'] = $note['clinicalNoteId']; $row['data'][] = ''; $row['data'][] = $icon . ' ' . date('Y-m-d', strtotime($note['dateTime'])); $row['data'][] = $note['noteTitle']; $row['data'][] = $note['last_name'] . ', ' . $note['first_name'] . ' ' . substr($note['middle_name'], 0, 1); $location = ''; $locationId = (int) $note['locationId']; if ($locationId > 0) { $location = Room::location($locationId); } $row['data'][] = $location; $row['data'][] = $row['id']; $row['data'][] = 0; $xml = simplexml_load_string($note['template']); $genericData = new GenericData(); $filters = array(); $filters['objectId'] = $note['clinicalNoteId']; $filters['objectClass'] = 'ClinicalNote'; $genericDataIterator = $genericData->getIteratorByFilters($filters); $firstData = false; $childIcon = '<img src="' . Zend_Registry::get('baseUrl') . 'img/leaf.gif" alt="-" />'; foreach ($genericDataIterator as $data) { if (!$firstData) { $firstData = true; //$row['id'] .= ':'.$data->revisionId; $row['data'][6] = $data->revisionId; continue; } $tmp = array(); $tmp['id'] = $data->revisionId; $tmp['data'][] = $data->objectId; // ''; $tmp['data'][] = ' ' . $childIcon . ' ' . date('Y-m-d', strtotime($data->dateTime)); $tmp['data'][] = $note['noteTitle']; $tmp['data'][] = ''; // Author $tmp['data'][] = ''; // Location $tmp['data'][] = $note['clinicalNoteId']; $tmp['data'][] = $tmp['id']; $row['rows'][] = $tmp; } $notes[] = $row; } $acj = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $acj->suppressExit = true; $acj->direct(array("rows" => $notes)); }
function processAction() { $clinicalNoteId = (int) $this->_getParam('clinicalNoteId'); $revisionId = (int) $this->_getParam('revisionId'); $data = $this->_getParam('namespaceData'); $saveDate = date('Y-m-d H:i:s'); $cn = new ClinicalNote(); $cn->clinicalNoteId = $clinicalNoteId; $cn->populate(); if (!$revisionId > 0) { $revisionId = GenericData::getUnsignedRevisionId(get_class($cn), $cn->clinicalNoteId); } $eSignatureId = ESignature::retrieveSignatureId(get_class($cn), $revisionId); if ($eSignatureId > 0) { $msg = __('Failed to save. Note is already signed'); } else { $cn->dateTime = date('Y-m-d H:i:s'); $cn->persist(); $msg = __('Data saved.'); $template = $cn->clinicalNoteDefinition->clinicalNoteTemplate->template; $xml = simplexml_load_string($template); $objectClass = 'ClinicalNote'; list($name, $value) = each($data); $gd = new GenericData(); $gd->objectClass = $objectClass; $gd->objectId = $clinicalNoteId; $gd->name = $name; $rowExists = $gd->doesRowExist(true); $preQueries = null; if ($rowExists) { $revisionId = (int) $gd->revisionId; $preQueries = 'DELETE FROM `' . $gd->_table . '` WHERE `revisionId`=' . $revisionId; } else { $revisionId = WebVista_Model_ORM::nextSequenceId(); } $otm = new WebVista_Model_ORMTransactionManager(); foreach ($data as $name => $value) { $gd = new GenericData(); $gd->objectClass = $objectClass; $gd->objectId = $clinicalNoteId; $gd->dateTime = $saveDate; $gd->name = $name; $gd->value = $value; $gd->revisionId = $revisionId; $otm->addORM($gd); } if (!$otm->persist($preQueries)) { $msg = __('Failed to save.'); } if ((string) $xml->attributes()->useNSDR && (string) $xml->attributes()->useNSDR == 'true') { if (!ClinicalNote::processNSDRPersist($xml, $cn, $data)) { $msg = __('Failed to save.'); } } } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct($msg); }
function listNotesAction() { $personId = 0; $personId = (int) $this->_getParam('personId'); $filter = $this->_getParam('filter'); $clinicalNoteIterator = new ClinicalNoteIterator(); $custom = $this->_getParam('custom'); if (count($custom) > 0) { $custom = $this->_getParam('custom'); $custom['personId'] = $personId; $clinicalNoteIterator->customView($custom); } else { $data = array(); $data['personId'] = $personId; if ($filter == 'byAuthoringPersonId') { $data['authoringPersonId'] = $this->_getParam('authoringPersonId'); } if ($filter == 'byDateRange') { $data['dateRange'] = $this->_getParam('dateRange'); } $clinicalNoteIterator->setFilter($filter, $data); } //trigger_error($cnSelect->__toString(),E_USER_NOTICE); //var_dump($db->query($cnSelect)->fetchAll());exit; $notes = array(); foreach ($clinicalNoteIterator as $note) { if ($note['eSignatureId'] > 0) { $img = 'sm-signed.png'; $alt = 'Signed'; } else { $img = 'sm-editproblem.png'; $alt = 'Editing'; } $icon = '<img src="' . Zend_Registry::get('baseUrl') . 'img/' . $img . '" alt="' . $alt . '" />'; $row = array(); $row['id'] = $note['clinicalNoteId']; $row['data'][] = ''; $row['data'][] = $icon . ' ' . $note['dateTime']; $row['data'][] = $note['noteTitle']; $row['data'][] = $note['last_name'] . ', ' . $note['first_name'] . ' ' . substr($note['middle_name'], 0, 1); $row['data'][] = 'Main Clinic->General Care'; // location->room temporarily hardcoded $xml = simplexml_load_string($note['template']); $genericData = new GenericData(); $filters = array(); $filters['objectId'] = $note['clinicalNoteId']; $filters['objectClass'] = 'ClinicalNote'; $genericDataIterator = $genericData->getIteratorByFilters($filters); $firstData = false; $childIcon = '<img src="' . Zend_Registry::get('baseUrl') . 'img/leaf.gif" alt="-" />'; foreach ($genericDataIterator as $data) { if (!$firstData) { $firstData = true; continue; } $tmp = array(); $tmp['id'] = $data->revisionId; $tmp['data'][] = $data->objectId; // ''; $tmp['data'][] = ' ' . $childIcon . ' ' . date('Y-m-d', strtotime($data->dateTime)); $tmp['data'][] = $note['noteTitle']; $row['rows'][] = $tmp; } $notes[] = $row; } $acj = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $acj->suppressExit = true; $acj->direct(array("rows" => $notes)); }
/** * changetemplateAction * @author Thomas Schedler <*****@*****.**> * @version 1.0 */ public function changetemplateAction() { $this->core->logger->debug('global->controllers->ElementController->changetemplateAction()'); try { $objGenericData = new GenericData(); $objGenericData->Setup()->setFormId($this->objRequest->getParam("formId")); $objGenericData->Setup()->setFormVersion($this->objRequest->getParam("formVersion")); $objGenericData->Setup()->setFormTypeId($this->objRequest->getParam("formTypeId")); $objGenericData->Setup()->setTemplateId($this->objRequest->getParam("templateId")); $objGenericData->Setup()->setElementId($this->objRequest->getParam("id")); $objGenericData->Setup()->setElementLinkId($this->objRequest->getParam("linkId", -1)); $objGenericData->Setup()->setElementTypeId($this->objRequest->getParam("elementTypeId")); $objGenericData->Setup()->setParentTypeId($this->objRequest->getParam("parentTypeId")); $objGenericData->Setup()->setRootLevelId($this->objRequest->getParam("rootLevelId")); $objGenericData->Setup()->setRootLevelGroupId($this->objRequest->getParam("rootLevelGroupId")); $objGenericData->Setup()->setParentId($this->objRequest->getParam("parentFolderId")); $objGenericData->Setup()->setActionType($this->core->sysConfig->generic->actions->edit); $objGenericData->Setup()->setLanguageId($this->getItemLanguageId()); $objGenericData->Setup()->setFormLanguageId($this->core->intZooluLanguageId); $objGenericData->Setup()->setModelSubPath('global/models/'); /** * change Template */ $objGenericData->changeTemplate($this->objRequest->getParam("newTemplateId")); $this->objRequest->setParam("formId", $objGenericData->Setup()->getFormId()); $this->objRequest->setParam("templateId", $objGenericData->Setup()->getTemplateId()); $this->objRequest->setParam("formVersion", $objGenericData->Setup()->getFormVersion()); $this->getForm($this->core->sysConfig->generic->actions->edit); /** * load generic data */ $this->objForm->setGenericSetup($objGenericData->Setup()); $this->addGlobalSpecificFormElements(); /** * set action */ if (intval($this->objRequest->getParam('id')) > 0) { $this->objForm->setAction('/zoolu/global/element/edit'); } else { $this->objForm->setAction('/zoolu/global/element/add'); } /** * prepare form (add fields and region to the Zend_Form) */ $this->objForm->prepareForm(); /** * get form title */ $this->view->formtitle = $this->objForm->Setup()->getFormTitle(); /** * output of metainformation to hidden div */ $this->setViewMetaInfos(); $this->view->form = $this->objForm; $this->renderScript('element/form.phtml'); } catch (Exception $exc) { $this->core->logger->err($exc); exit; } }
public function nsdrPopulate($tthis, $context, $data) { $context = (int) $context; $attributes = $tthis->_attributes; $nsdrNamespace = $tthis->_nsdrNamespace; $aliasedNamespace = $tthis->_aliasedNamespace; if ($context == '*') { if (isset($attributes['isDefaultContext']) && $attributes['isDefaultContext']) { // get genericData $objectClass = 'ClinicalNote'; $clinicalNoteId = 0; if (isset($attributes['clinicalNoteId'])) { $clinicalNoteId = (int) $attributes['clinicalNoteId']; } $revisionId = 0; if (isset($attributes['revisionId'])) { $revisionId = (int) $attributes['revisionId']; } if (!$revisionId > 0) { $revisionId = GenericData::getUnsignedRevisionId($objectClass, $clinicalNoteId); } $gd = new self(); $gd->objectClass = $objectClass; $gd->objectId = $clinicalNoteId; $gd->name = preg_replace('/[-\\.]/', '_', $nsdrNamespace); $gd->revisionId = $revisionId; $gd->loadValue(); return $gd->value; } else { // all $ret = array(); $gd = new self(); $gdIterator = $gd->getIterator(); foreach ($gdIterator as $g) { $ret[] = $g->toArray(); } return $ret; } } $gd = new self(); $gd->genericDataId = $context; $gd->populate(); return $gd->toArray(); }
/** * getProvincesByCountry * @author Thomas Schedler <*****@*****.**> */ public function getProvincesByCountry($strCountry) { try { $this->getModelLocations(); $intUnitId = $this->objGenericData->Setup()->getField('entry_location')->getValue(); $intTypeId = $this->objGenericData->Setup()->getField('entry_type')->getValue(); $objProvinces = $this->objModelLocations->loadProvincesByCountry($strCountry, $intUnitId, $intTypeId); return $objProvinces; } catch (Exception $exc) { $this->core->logger->err($exc); } }
/** * changetemplateAction * @author Thomas Schedler <*****@*****.**> * @version 1.0 */ public function changetemplateAction() { $this->core->logger->debug('cms->controllers->PageController->changetemplateAction()'); try { $objGenericData = new GenericData(); $objGenericData->Setup()->setFormId($this->objRequest->getParam("formId")); $objGenericData->Setup()->setFormVersion($this->objRequest->getParam("formVersion")); $objGenericData->Setup()->setFormTypeId($this->objRequest->getParam("formTypeId")); $objGenericData->Setup()->setTemplateId($this->objRequest->getParam("templateId")); $objGenericData->Setup()->setElementId($this->objRequest->getParam("id")); $objGenericData->Setup()->setActionType($this->core->sysConfig->generic->actions->edit); $objGenericData->Setup()->setLanguageId($this->objRequest->getParam("languageId", $this->core->sysConfig->languages->default->id)); $objGenericData->Setup()->setFormLanguageId(Zend_Auth::getInstance()->getIdentity()->languageId); $objGenericData->Setup()->setModelSubPath('cms/models/'); /** * change Template */ $objGenericData->changeTemplate($this->objRequest->getParam("newTemplateId")); $this->objRequest->setParam("formId", $objGenericData->Setup()->getFormId()); $this->objRequest->setParam("templateId", $objGenericData->Setup()->getTemplateId()); $this->objRequest->setParam("formVersion", $objGenericData->Setup()->getFormVersion()); $this->getForm($this->core->sysConfig->generic->actions->edit); /** * load generic data */ $this->objForm->setGenericSetup($objGenericData->Setup()); $this->addPageSpecificFormElements(); /** * set action */ $this->objForm->setAction('/zoolu/cms/page/edit'); /** * prepare form (add fields and region to the Zend_Form) */ $this->objForm->prepareForm(); /** * get form title */ $this->view->formtitle = $this->objForm->Setup()->getFormTitle(); /** * output of metainformation to hidden div */ $this->setViewMetaInfos(); $this->view->form = $this->objForm; $this->renderScript('page/form.phtml'); } catch (Exception $exc) { $this->core->logger->err($exc); exit; } }
public function buildDefaultGenericData(SimpleXMLElement $xml = null) { if ($xml === null) { if (!strlen($this->clinicalNoteDefinition->clinicalNoteTemplate->template) > 0) { $this->clinicalNoteDefinition->populate(); } $xml = new SimpleXMLElement($this->clinicalNoteDefinition->clinicalNoteTemplate->template); } $revisionId = WebVista_Model_ORM::nextSequenceId(); $nsdrData = array(); if ((string) $xml->attributes()->useNSDR && (string) $xml->attributes()->useNSDR == 'true') { $nsdrData = ClinicalNote::getNSDRData($xml, $this, $revisionId); } $dateTime = date('Y-m-d H:i:s'); foreach ($xml as $question) { foreach ($question as $key => $item) { if ($key != 'dataPoint') { continue; } $namespace = NSDR2::extractNamespace((string) $item->attributes()->namespace); $name = preg_replace('/[-\\.]/', '_', $namespace); $value = ''; if (strlen((string) $item->attributes()->templateText) > 0) { $templateName = (string) $item->attributes()->templateText; $view = Zend_Layout::getMvcInstance()->getView(); $value = $view->action('templated-text', 'template-text', null, array('personId' => $this->personId, 'templateName' => $templateName)); } if ((string) $item->attributes()->default == true) { $value = (string) $item->attributes()->value; } if (isset($nsdrData[$name])) { $value = $nsdrData[$name]; } $gd = new GenericData(); $gd->objectClass = get_class($this); $gd->objectId = $this->clinicalNoteId; $gd->dateTime = $dateTime; $gd->name = $name; $gd->value = $value; $gd->revisionId = $revisionId; $gd->persist(); //trigger_error('PERSISTED:'.print_r($gd->toArray(),true),E_USER_NOTICE); } } return $revisionId; }
/** * addAction * @author Cornelius Hansjakob <*****@*****.**> * @version 1.0 */ public function addAction() { $this->core->logger->debug('core->controllers->FolderController->addAction()'); $this->getForm($this->core->sysConfig->generic->actions->add); $this->addFolderSpecificFormElements(); /** * set action */ $this->objForm->setAction('/zoolu/core/folder/add'); if ($this->objRequest->isPost() && $this->objRequest->isXmlHttpRequest()) { $arrFormData = $this->objRequest->getPost(); $this->objForm->Setup()->setFieldValues($arrFormData); /** * prepare form (add fields and region to the Zend_Form) */ $this->objForm->prepareForm(); if ($this->objForm->isValid($arrFormData)) { /** * set action */ $this->objForm->setAction('/zoolu/core/folder/edit'); $intFolderId = $this->objForm->saveFormData(); $this->objForm->Setup()->setElementId($intFolderId); $this->objForm->getElement('id')->setValue($intFolderId); $this->objForm->Setup()->setActionType($this->core->sysConfig->generic->actions->edit); $this->view->assign('blnShowFormAlert', true); /** * add defautl start page */ if (array_key_exists("rootLevelTypeId", $arrFormData) && $arrFormData["rootLevelTypeId"] == $this->core->sysConfig->root_level_types->portals) { $intTemplateId = $this->core->sysConfig->page_types->page->startpage_templateId; $this->getModelTemplates(); $objTemplateData = $this->objModelTemplates->loadTemplateById($intTemplateId); if (count($objTemplateData) == 1) { $objTemplate = $objTemplateData->current(); /** * set form id from template */ $strFormId = $objTemplate->genericFormId; $intFormVersion = $objTemplate->version; $intFormTypeId = $objTemplate->formTypeId; } else { throw new Exception('Not able to create a generic data object, because there is no form id!'); } $objGenericData = new GenericData(); $objGenericData->Setup()->setFormId($strFormId); $objGenericData->Setup()->setFormVersion($intFormVersion); $objGenericData->Setup()->setFormTypeId($intFormTypeId); $objGenericData->Setup()->setTemplateId($intTemplateId); $objGenericData->Setup()->setActionType($this->core->sysConfig->generic->actions->add); $objGenericData->Setup()->setLanguageId($this->objRequest->getParam("languageId", $this->core->sysConfig->languages->default->id)); $objGenericData->Setup()->setFormLanguageId(Zend_Auth::getInstance()->getIdentity()->languageId); $objGenericData->Setup()->setParentId($intFolderId); $objGenericData->Setup()->setRootLevelId($this->objForm->Setup()->getRootLevelId()); $objGenericData->Setup()->setElementTypeId($this->core->sysConfig->page_types->page->id); $objGenericData->Setup()->setCreatorId($this->objForm->Setup()->getCreatorId()); $objGenericData->Setup()->setStatusId($this->objForm->Setup()->getStatusId()); $objGenericData->Setup()->setShowInNavigation($this->objForm->Setup()->getShowInNavigation()); $objGenericData->Setup()->setModelSubPath('cms/models/'); $objGenericData->addStartPage($this->objForm->Setup()->getCoreField('title')->getValue()); $this->view->assign('selectNavigationItemNow', true); $this->view->assign('itemId', 'folder' . $intFolderId); } } else { $this->view->assign('blnShowFormAlert', false); } } else { /** * prepare form (add fields and region to the Zend_Form) */ $this->objForm->prepareForm(); } /** * get form title */ $this->view->formtitle = $this->objForm->Setup()->getFormTitle(); /** * output of metainformation to hidden div */ $this->setViewMetaInfos(); $this->view->form = $this->objForm; $this->renderScript('folder/form.phtml'); }