Пример #1
0
 public function persist()
 {
     if (!$this->dateTime || $this->dateTime == '0000-00-00 00:00:00') {
         $this->dateTime = date('Y-m-d H:i:s');
     }
     return parent::persist();
 }
Пример #2
0
 public function persist()
 {
     if (!strlen($this->guid) > 0) {
         $this->guid = str_replace('-', '', NSDR::create_guid());
     }
     return parent::persist();
 }
Пример #3
0
 public function persist()
 {
     $this->homeAddress->type = 'HOME';
     $this->billingAddress->type = 'BILL';
     parent::persist();
     $this->person->persist();
 }
Пример #4
0
 public function persist()
 {
     if ($this->_persistMode != WebVista_Model_ORM::DELETE && (int) $this->program_order === 0) {
         $this->program_order = self::maxProgramOrder($this) + 1;
     }
     return parent::persist();
 }
Пример #5
0
 public function persist()
 {
     $claimFileId = (int) $this->claimFileId;
     if (!$claimFileId > 0) {
         $this->claimFileId = $this->nextSequenceId('claimSequences');
     }
     return parent::persist();
 }
 public function persist()
 {
     if ($this->_persistMode == WebVista_Model_ORM::DELETE) {
         $db = Zend_Registry::get("dbAdapter");
         $db->delete($this->_table, 'healthStatusHandlerId=' . $this->healthStatusHandlerId . ' AND personId=' . $this->personId);
         return;
     }
     parent::persist();
 }
Пример #7
0
 public function persist()
 {
     if (!$this->dateTime || $this->dateTime == '0000-00-00 00:00:00') {
         $this->dateTime = date('Y-m-d H:i:s');
     }
     if (!$this->patientProcedureId > 0) {
         $this->populateVisitDiagnoses();
     }
     return parent::persist();
 }
Пример #8
0
 public function persist()
 {
     if ($this->_ormPersist) {
         return parent::persist();
     }
     if ($this->shouldAudit()) {
         $sql = $this->toSQL();
         AuditLog::appendSql($sql);
     }
 }
Пример #9
0
 /**
  * Overrides WebVista_Model_ORM::persist()
  */
 public function persist()
 {
     $order = (int) $this->order;
     if (!$order > 0 && $this->_persistMode != WebVista_Model_ORM::DELETE) {
         $db = Zend_Registry::get("dbAdapter");
         $dbSelect = $db->select()->from($this->_table, "MAX(`order`) AS order");
         $result = $db->fetchRow($dbSelect);
         $this->order = $result['order'] + 1;
     }
     parent::persist();
 }
Пример #10
0
 public function persist()
 {
     parent::persist();
     $storageString = new StorageString();
     $storageString->setPersistMode($this->_persistMode);
     $storageString->foreignKey = $this->companyId;
     $storageString->valueKey = 'email';
     $storageString->value = $this->_companyEmail;
     $storageString->arrayIndex = 1;
     // start index at 1, may have problem with ORM
     $storageString->persist();
 }
Пример #11
0
 public function persist()
 {
     $filename = $this->getUploadFilename();
     $version = (int) $this->version;
     if ($version <= 0) {
         $this->version = $this->getLatestVersion() + 1;
     }
     $ret = parent::persist();
     if ($ret && $this->_persistMode == self::DELETE && file_exists($filename)) {
         unlink($filename);
     }
     return $ret;
 }
Пример #12
0
 public function persist()
 {
     $cascadePersist = null;
     if (!$this->numberId > 0) {
         $this->number->persist();
         $this->numberId = $this->number->numberId;
         $cascadePersist = $this->number->_cascadePersist;
         $this->number->_cascadePersist = false;
     }
     parent::persist();
     if ($cascadePersist !== null) {
         $this->number->_cascadePersist = $cascadePersist;
     }
 }
Пример #13
0
 public function persist()
 {
     $ret = parent::persist();
     if ($this->_persistMode !== WebVista_Model_ORM::DELETE) {
         return $ret;
     }
     $method = new NSDRDefinitionMethod();
     $methodIterator = $method->getIteratorByParentId($this->uuid);
     $methods = $methodIterator->toArray('uuid', 'uuid');
     foreach ($methods as $key => $val) {
         $item = clone $method;
         $item->uuid = $key;
         $item->setPersistMode($this->_persistMode);
         $item->persist();
     }
     return $ret;
 }
 public function persist()
 {
     if ($this->_persistMode === WebVista_Model_ORM::DELETE) {
         $db = Zend_Registry::get('dbAdapter');
         $sql = $this->toSQL();
         $code = preg_replace('/[^a-z_0-9- \\.]/i', '', $this->code);
         $sql .= " AND `code` = '{$code}'";
         $db->query($sql);
         $this->postPersist();
         if ($this->shouldAudit()) {
             WebVista_Model_ORM::audit($this);
         }
     } else {
         parent::persist();
     }
     return $this;
 }
Пример #15
0
 public function persist()
 {
     if ($this->_persistMode == WebVista_Model_ORM::DELETE) {
         return parent::persist();
     }
     $db = Zend_Registry::get('dbAdapter');
     $clinicalNoteTemplateId = (int) $this->clinicalNoteTemplateId;
     $data = $this->toArray();
     if ($clinicalNoteTemplateId > 0) {
         $ret = $db->update($this->_table, $data, 'clinicalNoteTemplateId = ' . $clinicalNoteTemplateId);
     } else {
         $this->clinicalNoteTemplateId = WebVista_Model_ORM::nextSequenceId();
         $data['clinicalNoteTemplateId'] = $this->clinicalNoteTemplateId;
         $ret = $db->insert($this->_table, $data);
     }
     return $this;
 }
Пример #16
0
 public function persist()
 {
     $visit = new self();
     $visit->visitId = $this->encounter_id;
     $visit->populate();
     $oldClosed = $visit->closed;
     $ret = parent::persist();
     $newClosed = $this->closed;
     if ($newClosed) {
         $newClaim = false;
         if ($newClosed && $oldClosed !== $newClosed && !ClaimLine::mostRecentClaim($this->encounter_id, true) > 0) {
             // recalculate claim lines if closed visit is new/reopened
             $newClaim = true;
         }
         $ret = self::recalculateClaims($this, $newClaim);
     }
     return $ret;
 }
Пример #17
0
    public function persist($single = true)
    {
        if ($single) {
            return parent::persist();
        }
        $db = Zend_Registry::get('dbAdapter');
        if ($this->_persistMode == WebVista_Model_ORM::DELETE) {
            $sql = 'DELETE FROM `' . $this->_table . '` WHERE (`guid` = ' . $db->quote($this->guid) . ')';
            $db->query($sql);
            return $this;
        }
        if (!strlen($this->guid) > 0) {
            $this->guid = str_replace('-', '', NSDR::create_guid());
        }
        // Multiple fee schedule cannot be set for the same insurance programs for the same dates of service
        if ($this->hasConflicts()) {
            $error = __('Please choose different insurance programs or date of service.');
            throw new Exception($error);
        }
        if (!$this->dateObsolete || $this->dateObsolete == '0000-00-00') {
            $this->dateObsolete = $this->dateOfServiceEnd;
        }
        $updates = array();
        $fields = array();
        $values = array();
        $columns = array('name', 'guid', 'insuranceProgramIds', 'dateOfServiceStart', 'dateOfServiceEnd', 'procedureCode', 'fee', 'dateObsolete');
        foreach ($columns as $col) {
            $fields[$col] = '`' . $col . '`';
            $values[$col] = $db->quote($this->{$col});
            $updates[$col] = $fields[$col] . ' = ' . $values[$col];
        }
        $values['procedureCode'] = '`code`';
        unset($updates['guid']);
        unset($updates['procedureCode']);
        unset($updates['fee']);
        unset($updates['dateObsolete']);
        // name, guid, insuranceProgramIds, dateOfServiceStart, dateOfServiceEnd
        $sql = 'INSERT INTO `feeSchedules` (' . implode(', ', $fields) . ')
				SELECT ' . implode(', ', $values) . ' FROM procedureCodesCPT
			ON DUPLICATE KEY UPDATE ' . implode(', ', $updates);
        WebVista::debug($sql);
        $db->query($sql);
        return $this;
    }
Пример #18
0
 public function persist()
 {
     if ($this->_persistMode == WebVista_Model_ORM::DELETE) {
         return parent::persist();
     }
     $db = Zend_Registry::get('dbAdapter');
     $reportViewId = (int) $this->reportViewId;
     $data = $this->toArray();
     unset($data['reportBase']);
     if ($reportViewId > 0) {
         $ret = $db->update($this->_table, $data, 'reportViewId = ' . $reportViewId);
     } else {
         $this->reportViewId = WebVista_Model_ORM::nextSequenceId();
         $data['reportViewId'] = $this->reportViewId;
         $data['viewOrder'] = $this->_getNextViewOrder();
         $ret = $db->insert($this->_table, $data);
     }
     return $this;
 }
Пример #19
0
 public function persist()
 {
     if ($this->_persistMode == WebVista_Model_ORM::DELETE) {
         return parent::persist();
     }
     $db = Zend_Registry::get('dbAdapter');
     $genericDataId = (int) $this->genericDataId;
     $data = $this->toArray();
     if ($genericDataId > 0) {
         $ret = $db->update($this->_table, $data, 'genericDataId = ' . $genericDataId);
     } else {
         $this->genericDataId = WebVista_Model_ORM::nextSequenceId();
         $data['genericDataId'] = $this->genericDataId;
         $ret = $db->insert($this->_table, $data);
     }
     if ($this->shouldAudit()) {
         WebVista_Model_ORM::audit($this);
     }
     return $this;
 }
 public function persist()
 {
     $db = Zend_Registry::get('dbAdapter');
     if ($this->_persistMode == WebVista_Model_ORM::DELETE) {
         if (!strlen($this->name) > 0) {
             $this->populate();
         }
         $sql = 'ALTER TABLE `patientStatistics` DROP COLUMN `' . $this->name . '`';
     } else {
         $dataType = $this->_dataTypes[$this->type];
         $sql = 'ALTER TABLE `patientStatistics` ADD `' . $this->name . '` ' . $dataType . ' NOT NULL';
         if (strlen($this->_origName) > 0) {
             $sql = 'ALTER TABLE `patientStatistics` CHANGE `' . $this->_origName . '` `' . $this->name . '` ' . $dataType . ' NOT NULL';
         }
     }
     try {
         $db->query($sql);
         parent::persist();
     } catch (Exception $e) {
         trigger_error($e->getMessage(), E_USER_ERROR);
     }
 }
Пример #21
0
 public function persist()
 {
     $db = Zend_Registry::get('dbAdapter');
     if ($this->_persistMode == WebVista_Model_ORM::DELETE) {
         return parent::persist();
     }
     $data = $this->toArray();
     if (!strlen($data['uuid']) > 0) {
         $this->uuid = NSDR::create_guid();
         $data['uuid'] = $this->uuid;
         $db->insert($this->_table, $data);
     } else {
         $db->update($this->_table, $data, 'uuid = ' . $db->quote($data['uuid']));
     }
     if ($this->shouldAudit()) {
         $audit = array();
         $audit['objectClass'] = get_class($this);
         $audit['objectId'] = $data['uuid'];
         $audit['auditValues'] = $data;
         Audit::persistManualAuditArray($audit);
     }
     return $this;
 }
Пример #22
0
 public function persist()
 {
     if (!strlen($this->ipAddress) > 0 && isset($_SERVER['REMOTE_ADDR'])) {
         $this->ipAddress = $_SERVER['REMOTE_ADDR'];
     }
     if (self::$_processedAudits) {
         $this->startProcessing = date('Y-m-d H:i:s');
         $this->endProcessing = date('Y-m-d H:i:s');
     }
     if (!$this->userId) {
         $identity = Zend_Auth::getInstance()->getIdentity();
         if ($identity) {
             $this->userId = $identity->personId;
         }
     }
     if (self::$_synchronousAudits || $this->_ormPersist) {
         return parent::persist();
     }
     if ($this->shouldAudit()) {
         $sql = $this->toSQL();
         AuditLog::appendSql($sql);
     }
 }
Пример #23
0
 /**
  * Persist all the data to the datastore
  *
  * @param boolean $actual TRUE when referring to actual ORM, FALSE when referring to ConfigItem (default to TRUE)
  * @return boolean
  */
 public function persist($actual = true)
 {
     if ($actual) {
         $this->_table = $this->_name;
         parent::persist();
         return true;
     }
     $defaultTableName = $this->_defaultFormularyName;
     if ($defaultTableName == null) {
         $defaultTableName = self::getDefaultFormularyTable();
     }
     $db = Zend_Registry::get('dbAdapter');
     if ($this->_persistMode == WebVista_Model_ORM::DELETE) {
         $queries = array();
         $queries[] = "DROP TABLE {$this->_name}";
         $queries[] = "DELETE FROM {$this->_config->_table} WHERE configId='{$this->_name}'";
         $db->query(implode(';' . PHP_EOL, $queries));
     } else {
         // create new table based on default table
         $tableName = $this->_name;
         if (!self::isTableExists($tableName)) {
             $sql = 'CREATE TABLE ' . $tableName . ' LIKE ' . $defaultTableName;
             $sql .= '; INSERT INTO ' . $tableName . ' SELECT * FROM ' . $defaultTableName;
             trigger_error($sql, E_USER_NOTICE);
             $db->query($sql);
         }
         $this->_config->configId = $this->_name;
         $this->_config->value = serialize($this);
         $this->_config->setPersistMode($this->_persistMode);
         $this->_config->persist();
     }
     if ($this->_isDefaultSet) {
         // backup configId and value
         $configId = $this->_config->configId;
         $value = $this->_config->value;
         $this->_config->configId = $defaultTableName;
         $this->_config->populate();
         $formularyItem = unserialize($this->_config->value);
         if ($formularyItem !== false && $formularyItem instanceof self && $formularyItem->getName() != $this->getName()) {
             // unset the default
             $formularyItem->unsetDefault();
             $formularyItem->persist(false);
         }
         // set the default formulary table name to this table name
         $this->_config->configId = self::DEFAULTFORMULARYID;
         $this->_config->value = $this->_name;
         $this->_config->persist();
         // restore the previous data for configId and value
         $this->_config->configId = $configId;
         $this->_config->value = $value;
     }
     // temporarily return true, this might change later if needed
     return true;
 }
Пример #24
0
 public function persist()
 {
     if ($this->number_id > 0 && $this->_isv2x()) {
         // check if 2.x
         WebVista::debug('Unable to alter because 2.x phone number detected');
         return false;
     }
     if ($this->_persistMode != WebVista_Model_ORM::DELETE && (int) $this->displayOrder <= 0) {
         $this->displayOrder = self::nextDisplayOrder($this->personId);
     }
     return parent::persist();
 }
Пример #25
0
 public function persist()
 {
     parent::persist();
     $db = Zend_Registry::get('dbAdapter');
     // remove all comments to a particular problem list from db
     $sql = "DELETE FROM `problemListComments` WHERE `problemListId`='{$this->problemListId}'";
     $db->query($sql);
     // add comments one by one
     foreach ($this->problemListComments as $comment) {
         $comment->persist();
     }
 }