Example #1
0
 public function nsdrPersist($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'];
             }
             $gd = new self();
             $gd->objectClass = $objectClass;
             $gd->objectId = $clinicalNoteId;
             $gd->name = $nsdrNamespace;
             $gd->revisionId = $revisionId;
             $gd->loadValue();
             $gd->dateTime = date('Y-m-d H:i:s');
             if (is_array($data)) {
                 $data = array_shift($data);
             }
             $gd->value = $data;
             return $gd->persist();
         } else {
             // all
             $ret = false;
             if (isset($data[0])) {
                 $ret = true;
                 foreach ($data as $row) {
                     $gd = new self();
                     $gd->populateWithArray($row);
                     $gd->persist();
                 }
             }
             return $ret;
         }
     }
     $gd = new self();
     $gd->genericDataId = $context;
     $gd->populate();
     $gd->populateWithArray($data);
     return $gd->persist();
 }
Example #2
0
 public static function checkDuplicatePerson(self $person)
 {
     $db = Zend_Registry::get('dbAdapter');
     $lastName = $person->lastName;
     $firstName = $person->firstName;
     $firstInitial = substr($firstName, 0, 1);
     $gender = $person->gender;
     $dob = $person->dateOfBirth;
     $sqlSelect = $db->select()->from($person->_table)->where('last_name LIKE ' . $db->quote($lastName) . ' OR last_name LIKE ' . $db->quote($lastName . '%'))->where('first_name LIKE ' . $db->quote($firstName) . ' OR first_name LIKE ' . $db->quote($firstName . '%') . ' OR (SUBSTRING(first_name,1,1) LIKE ' . $db->quote($firstInitial) . ' AND gender=' . $db->quote($gender) . ') OR date_of_birth=' . $db->quote($dob))->order('last_name')->order('first_name')->order('middle_name')->order('date_of_birth');
     $duplicates = array();
     if ($rows = $db->fetchAll($sqlSelect)) {
         foreach ($rows as $row) {
             $p = new self();
             $p->populateWithArray($row);
             $tmp = array();
             $tmp['personId'] = $p->personId;
             $tmp['name'] = $p->displayName;
             $tmp['dateOfBirth'] = $p->dateOfBirth;
             $tmp['gender'] = $p->displayGender;
             $tmp['ssn'] = $p->identifier;
             $duplicates[] = $tmp;
         }
     }
     return $duplicates;
 }
Example #3
0
 public static function mostRecentClaim($visitId, $idOnly = false)
 {
     $db = Zend_Registry::get('dbAdapter');
     $orm = new self();
     $fields = array('claimId');
     $sqlSelect = $db->select()->where('visitId = ?', (int) $visitId)->order('claimId DESC')->group('claimId')->limit(1);
     if ($idOnly) {
         $sqlSelect->from($orm->_table, array('claimId'));
     } else {
         $sqlSelect->from($orm->_table);
     }
     $claimId = 0;
     if ($row = $db->fetchRow($sqlSelect)) {
         $claimId = (int) $row['claimId'];
         if (!$idOnly) {
             $orm->populateWithArray($row);
         }
     }
     if ($idOnly) {
         return $claimId;
     }
     return $orm;
 }