示例#1
0
文件: File.php 项目: nagyist/tutus
 /**
  *
  * $params->pid int
  * $params->eid int
  * $params->uid int
  * $params->docType string
  * $params->document string Base64
  *
  * @param object $params
  *
  * @return array
  */
 public function savePatientBase64Document($params)
 {
     $this->validateParams($params);
     if ($this->error) {
         return array('success' => false, 'error' => $this->errorMsg);
     }
     $dir = $this->getDocumentDirByPidAndDocType($params->pid, $params->docType);
     if ($this->error) {
         return array('success' => false, 'error' => $this->errorMsg);
     }
     $file = explode(',', $params->document);
     $ext = $this->fileExt($file[0]);
     if ($this->error) {
         return array('success' => false, 'error' => $this->errorMsg);
     }
     $params->name = $this->getNewFileName($dir, $ext);
     if ($this->error) {
         return array('success' => false, 'error' => $this->errorMsg);
     }
     $src = $this->saveBase64File($dir . $params->name, $file[1]);
     if ($this->error) {
         return array('success' => false, 'error' => $this->errorMsg);
     }
     unset($params->file);
     $params->title = 'No title';
     $params->date = date('Y-m-d H:i:s');
     $params->hash = sha1_file($src);
     $params->url = $this->buildDocumentUrl($params->pid, $params->docType, $params->name);
     $params->encrypted = $this->encrypt;
     $rec = $this->d->save($params);
     if ($rec === false) {
         return array('success' => false, 'error' => 'Unable to save document record');
     }
     return array('success' => true, 'id' => $rec['data']->id);
 }
示例#2
0
文件: Globals.php 项目: nagyist/tutus
 /**
  * @param stdClass $params
  * @return stdClass
  */
 public function updateGlobals($params)
 {
     if (self::$g == null) {
         self::$g = MatchaModel::setSenchaModel('App.model.administration.Globals');
     }
     $params = self::$g->save($params);
     $this->setGlobals();
     return $params;
 }
示例#3
0
 public function setLog(stdClass $params)
 {
     $params->date = date('Y-m-d H:i:s');
     $params->fid = $_SESSION['user']['facility'];
     $params->uid = $_SESSION['user']['id'];
     Matcha::pauseLog(true);
     $record = $this->l->save($params);
     Matcha::pauseLog(false);
     return $record;
 }
示例#4
0
 public function logoutInactiveUsers()
 {
     $now = time();
     $users = array();
     $params = new stdClass();
     $params->filter[0] = new stdClass();
     $params->filter[0]->property = 'last_request';
     $params->filter[0]->operator = '<';
     $params->filter[0]->value = $now - $_SESSION['inactive']['time'];
     $params->filter[1] = new stdClass();
     $params->filter[1]->property = 'logout';
     $params->filter[1]->value = null;
     $sessions = $this->s->load($params)->all();
     foreach ($sessions as $session) {
         if (isset($user['id'])) {
             $users[] = array('uid' => $session['uid']);
             $data = new stdClass();
             $data->id = $session['id'];
             $data->logout = $now;
             $this->s->save($data);
             unset($data);
         }
     }
     unset($params);
     return $users;
 }
示例#5
0
 public function uploadDocument($params, $file)
 {
     $this->setPatientDocumentModel();
     $params = (object) $params;
     $src = $this->getPatientDir($params) . $this->reNameFile($file);
     if (move_uploaded_file($file['filePath']['tmp_name'], $src)) {
         if (isset($params->encrypted) && $params->encrypted) {
             file_put_contents($src, Crypt::encrypt(file_get_contents($src)), LOCK_EX);
         }
         $data = new stdClass();
         $data->pid = $this->pid;
         $data->eid = isset($params->eid) ? $params->eid : 0;
         $data->uid = isset($params->uid) ? $params->uid : $_SESSION['user']['id'];
         $data->docType = $this->docType;
         $data->name = $this->fileName;
         $data->url = $this->getDocumentUrl();
         $data->date = date('Y-m-d H:i:s');
         $data->hash = hash_file('sha256', $src);
         $data->encrypted = $params->encrypted;
         $data = $this->d->save($data);
         return ['success' => true, 'doc' => ['id' => $data['id'], 'name' => $this->fileName, 'url' => $this->getDocumentUrl()]];
     } else {
         return ['success' => false, 'error' => 'File could not be uploaded'];
     }
 }
示例#6
0
 private function updatePhones($params, $foreignType = '')
 {
     $p = new stdClass();
     $p->id = $params->phone_id;
     $p->country_code = $params->phone_country_code;
     $p->area_code = $params->phone_area_code;
     $p->prefix = $params->phone_prefix;
     $p->number = $params->phone_number;
     $p->number_type = 'phone';
     $p->foreign_type = $foreignType;
     $p->foreign_id = $params->id;
     $record = $this->phone->save($p);
     $params->phone_full = Phone::fullPhone($record['country_code'], $record['area_code'], $record['prefix'], $record['number']);
     unset($p, $record);
     $f = new stdClass();
     $f->id = $params->fax_id;
     $f->country_code = $params->fax_country_code;
     $f->area_code = $params->fax_area_code;
     $f->prefix = $params->fax_prefix;
     $f->number = $params->fax_number;
     $f->number_type = 'fax';
     $f->foreign_type = $foreignType;
     $f->foreign_id = $params->id;
     $record = $this->phone->save($f);
     $params->fax_full = Phone::fullPhone($record['country_code'], $record['area_code'], $record['prefix'], $record['number']);
     unset($f, $record);
     return $params;
 }
示例#7
0
文件: PoolArea.php 项目: igez/gaiaehr
 public function updateCurrentPatientPoolAreaByPid($data, $pid)
 {
     $this->setPpModel();
     $area = $this->getCurrentPatientPoolAreaByPid($pid);
     $data['id'] = $area['id'];
     $this->pp->save((object) $data);
     return;
 }
示例#8
0
文件: Services.php 项目: igez/gaiaehr
 public function updateEncounterService($params)
 {
     include_once ROOT . '/dataProvider/HL7Messages.php';
     $HL7Messages = new HL7Messages();
     if (is_array($params)) {
         $services = array();
         foreach ($params as $param) {
             $service = $this->s->save($param);
             $service = (object) $service;
             $HL7Messages->sendServiceORM(1, 1, $service, 'XX');
             $services[] = $service;
         }
     } else {
         $service = $this->s->save($params);
         $service = (object) $service;
         $HL7Messages->sendServiceORM(1, 1, $service, 'XX');
         $services = $service;
     }
     return $services;
 }
示例#9
0
 /**
  * @param stdClass $params
  * @return stdClass
  */
 public function updateVitals($params)
 {
     $record = $this->v->save($params);
     if (is_array($params)) {
         foreach ($record as $i => $rec) {
             $record[$i] = $rec = (object) $rec;
             if (isset($rec->uid)) {
                 $record[$i]->administer_by = $rec->uid != 0 ? $this->User->getUserNameById($rec->uid) : '';
             }
             if (isset($rec->auth_uid)) {
                 $record[$i]->authorized_by = $rec->auth_uid != 0 ? $this->User->getUserNameById($rec->auth_uid) : '';
             }
         }
     } else {
         $record = (object) $record;
         if (isset($record->uid)) {
             $record->administer_by = $record->uid != 0 ? $this->User->getUserNameById($record->uid) : '';
         }
         if (isset($record->auth_uid)) {
             $record->authorized_by = $record->auth_uid != 0 ? $this->User->getUserNameById($record->auth_uid) : '';
         }
     }
     return $record;
 }
示例#10
0
 /**
  *
  * $params->pid int
  * $params->eid int
  * $params->uid int
  * $params->docType string
  * $params->document string Base64
  *
  * @param object $params
  *
  * @return array
  */
 public function savePatientBase64Document($params)
 {
     $this->validateParams($params);
     if ($this->error) {
         return array('success' => false, 'error' => $this->errorMsg);
     }
     if ($this->fileSystemStore) {
         $dir = $this->getDocumentDirByPidAndDocType($params->pid, $params->docType);
         if ($this->error) {
             return array('success' => false, 'error' => $this->errorMsg);
         }
     }
     $file = explode(',', $params->document);
     $ext = $this->fileExt($file[0]);
     if ($this->error) {
         return array('success' => false, 'error' => $this->errorMsg);
     }
     if (isset($dir)) {
         $params->name = $this->getNewFileName($dir, $ext);
         if ($this->error) {
             return array('success' => false, 'error' => $this->errorMsg);
         }
         $src = $this->saveBase64File($dir . $params->name, $file[1]);
         if ($this->error) {
             return array('success' => false, 'error' => $this->errorMsg);
         }
     }
     unset($params->file);
     $params->title = isset($params->title) ? $params->title : '';
     $params->date = date('Y-m-d H:i:s');
     $params->hash = isset($src) ? sha1_file($src) : sha1($file[1]);
     $params->name = isset($params->name) ? $params->name : 'unnamed' . $ext;
     $params->encrypted = $this->encrypt;
     if ($this->fileSystemStore) {
         $params->url = $this->buildDocumentUrl($params->pid, $params->docType, $params->name);
     } else {
         $params->document = $this->encrypt ? MatchaUtils::__encrypt($file[1]) : $file[1];
     }
     $rec = $this->d->save($params);
     if ($rec === false) {
         return array('success' => false, 'error' => 'Unable to save document record');
     }
     return array('success' => true, 'id' => $rec['data']->id);
 }
示例#11
0
文件: Patient.php 项目: igez/gaiaehr
 public function patientChartInByUserId($uid)
 {
     $this->setChartCheckoutModel();
     $filters = new stdClass();
     $filters->filter[0] = new stdClass();
     $filters->filter[0]->property = 'uid';
     $filters->filter[0]->value = $uid;
     $filters->filter[1] = new stdClass();
     $filters->filter[1]->property = 'chart_in_time';
     $filters->filter[1]->value = null;
     $chart = $this->c->load($filters)->one();
     unset($filters);
     if ($chart !== false) {
         $chart = (object) $chart;
         $chart->chart_in_time = date('Y-m-d H:i:s');
         return $this->c->save($chart);
     }
     return false;
 }
示例#12
0
文件: Modules.php 项目: igez/gaiaehr
 /**
  * this method will insert the new active modules in site database if
  * does not exist
  */
 private function setNewModules()
 {
     Matcha::pauseLog(true);
     foreach (FileManager::scanDir($this->modulesDir) as $module) {
         $ModuleConfig = $this->getModuleConfig($module);
         if ($ModuleConfig['active']) {
             $moduleRecord = $this->m->load(['name' => $ModuleConfig['name']])->one();
             if (empty($moduleRecord)) {
                 $data = new stdClass();
                 $data->title = $ModuleConfig['title'];
                 $data->name = $ModuleConfig['name'];
                 $data->description = $ModuleConfig['description'];
                 $data->enable = '0';
                 $data->installed_version = $ModuleConfig['version'];
                 $this->m->save($data);
             }
         }
     }
     Matcha::pauseLog(false);
     return;
 }
示例#13
0
文件: CPT.php 项目: igez/gaiaehr
 public function updateCPT($params)
 {
     return $this->c->save($params);
 }
示例#14
0
 public function updatePatientMedication($params)
 {
     return $this->m->save($params);
 }
示例#15
0
 public function updatePatientCarePlanGoal($params)
 {
     return $this->c->save($params);
 }
示例#16
0
文件: Snippets.php 项目: igez/gaiaehr
 public function updateSoapSnippets($params)
 {
     $this->setSnippetModel();
     return $this->Snippet->save($params);
 }
示例#17
0
 /**
  * @param $params
  * @return array
  */
 public function updateInsurance($params)
 {
     return $this->pi->save($params);
 }
示例#18
0
 public function updateProviderCredentialization($params)
 {
     $this->getProviderCredentializationModel();
     return $this->pc->save($params);
 }
示例#19
0
文件: Medical.php 项目: igez/gaiaehr
 public function updatePatientAllergies($params)
 {
     return $this->a->save($params);
 }
示例#20
0
 public function updateNote($params)
 {
     return $this->n->save($params);
 }
示例#21
0
 public function saveProcedure($params)
 {
     return $this->p->save($params);
 }
示例#22
0
 /**
  * @param $params
  *
  * @return array
  */
 public function updateContact($params)
 {
     return $this->a->save($params);
 }
示例#23
0
 public function updateReminder($params)
 {
     return $this->r->save($params);
 }
示例#24
0
 public function updateMyAccount(stdClass $params)
 {
     $data = new $params();
     unset($data->password, $data->pwd_history1, $data->pwd_history2);
     return $this->u->save($data);
 }
示例#25
0
 /**
  * @param HL7 $hl7
  * @param ADT $msg
  * @param stdClass $msgRecord
  */
 protected function ProcessADT($hl7, $msg, $msgRecord)
 {
     $evt = $hl7->getMsgEventType();
     if ($evt == 'A01') {
         /**
          * Admit Visit
          */
     } elseif ($evt == 'A04') {
         /**
          * Register a Patient
          */
         $patientData = $this->PidToPatient($msg->data['PID'], $hl7);
         $patient = $this->p->load($patientData[$this->updateKey])->one();
         if ($patient === false) {
             $this->ackStatus = 'AR';
             $this->ackMessage = 'Unable to find patient ' . $patientData[$this->updateKey];
         }
         $patient = array_merge($patient, $patientData);
         $patient = $this->p->save((object) $patient);
         $this->InsuranceGroupHandler($msg->data['INSURANCE'], $hl7, $patient);
         return;
     } elseif ($evt == 'A08') {
         /**
          * Update Patient Information
          */
         $patientData = $this->PidToPatient($msg->data['PID'], $hl7);
         $patient = $this->p->load($patientData[$this->updateKey])->one();
         if ($patient === false) {
             $this->ackStatus = 'AR';
             $this->ackMessage = 'Unable to find patient ' . $patientData[$this->updateKey];
         }
         $patient = array_merge($patient, $patientData);
         $patient = $this->p->save((object) $patient);
         $this->InsuranceGroupHandler($msg->data['INSURANCE'], $hl7, $patient);
         return;
     } elseif ($evt == 'A09') {
         /**
          * Patient Departing - Tracking
          * PV1-3 - Assigned Patient Location
          * PV1-6 - Prior Patient Location
          * PV1-11 - Temporary Location
          * PV1-42 - Pending Location
          * PV1-43 - Prior Temporary Location
          */
         $PID = $msg->data['PID'];
         $PV1 = $msg->data['PV1'];
         $filter = array();
         if ($PID[3][4][1] == $this->getAssigningAuthority()) {
             $filter['pid'] = $PID[3][1];
         } else {
             $filter['pubpid'] = $PID[3][1];
         }
         $patient = $this->p->load($filter)->one();
         if ($patient === false) {
             $this->ackStatus = 'AR';
             $this->ackMessage = 'Unable to find patient ' . $PID[3][1];
         }
         $newAreaId = $PV1[3][1];
         //$oldAreaId = $PV1[6][1];
         $PoolArea = new PoolArea();
         $areas = $PoolArea->getAreasArray();
         if (!array_key_exists($newAreaId, $areas)) {
             $this->ackStatus = 'AR';
             $this->ackMessage = 'Unable to find Area ID ' . $newAreaId;
             return;
         }
         $params = new stdClass();
         $params->pid = $patient['pid'];
         $params->sendTo = $newAreaId;
         $PoolArea->sendPatientToPoolArea($params);
         unset($params);
         return;
     } elseif ($evt == 'A10') {
         /**
          * Patient Arriving - Tracking
          * PV1-3  - As signed Patient Location
          * PV1-6  - Prior Patient Location
          * PV1-11 - Temporary Location
          * PV1-43 - Prior Temporary Location
          */
         $PID = $msg->data['PID'];
         $PV1 = $msg->data['PV1'];
         $filter = array();
         if ($PID[3][4][1] == $this->getAssigningAuthority()) {
             $filter['pid'] = $PID[3][1];
         } else {
             $filter['pubpid'] = $PID[3][1];
         }
         $patient = $this->p->load($filter)->one();
         if ($patient === false) {
             $this->ackStatus = 'AR';
             $this->ackMessage = 'Unable to find patient ' . $PID[3][1];
         }
         $newAreaId = $PV1[3][1];
         //$oldAreaId = $PV1[6][1];
         $PoolArea = new PoolArea();
         $areas = $PoolArea->getAreasArray();
         if (!array_key_exists($newAreaId, $areas)) {
             $this->ackStatus = 'AR';
             $this->ackMessage = 'Unable to find Area ID ' . $newAreaId;
             return;
         }
         $params = new stdClass();
         $params->pid = $patient['pid'];
         $params->sendTo = $newAreaId;
         $PoolArea->sendPatientToPoolArea($params);
         unset($params);
         return;
     } elseif ($evt == 'A18') {
         /**
          * Merge Patient Information
          * PID-2.1 <= MRG-4.1
          */
         $pid = $msg->data['PATIENT']['PID'][2][1];
         $mrg = $msg->data['PATIENT']['MRG'][4][1];
         $aPatient = $this->p->load(array('pubpid' => $pid))->one();
         $bPatient = $this->p->load(array('pubpid' => $mrg))->one();
         $this->MergeHandler($aPatient, $bPatient, $pid, $mrg);
         return;
     } elseif ($evt == 'A28') {
         /**
          * Add Person or Patient Information
          * PID-2.1 <= MRG-4.1
          */
         $patientData = $this->PidToPatient($msg->data['PID'], $hl7);
         $patientData['pubpid'] = $patientData['pid'];
         $patientData['pid'] = 0;
         $patient = $this->p->save((object) $patientData);
         $this->InsuranceGroupHandler($msg->data['INSURANCE'], $hl7, $patient);
         return;
     } elseif ($evt == 'A29') {
         /**
          * Delete Person Information
          */
     } elseif ($evt == 'A31') {
         /**
          * Update Person Information
          */
         $patientData = $this->PidToPatient($msg->data['PID'], $hl7);
         $patient = $this->p->load($patientData[$this->updateKey])->one();
         if ($patient === false) {
             $this->ackStatus = 'AR';
             $this->ackMessage = 'Unable to find patient ' . $patientData[$this->updateKey];
         }
         $patient = array_merge($patient, $patientData);
         $patient = $this->p->save((object) $patient);
         $this->InsuranceGroupHandler($msg->data['INSURANCE'], $hl7, $patient);
         return;
     } elseif ($evt == 'A32') {
         /** Cancel Patient Arriving - Tracking **/
         return;
     } elseif ($evt == 'A33') {
         /** Cancel Patient Departing - Tracking **/
         return;
     } elseif ($evt == 'A39') {
         /**
          * Merge Person - Patient ID (Using External ID)
          * PID-2.1 <= MRG-4.1
          */
         $pid = $msg->data['PATIENT']['PID'][2][1];
         $mrg = $msg->data['PATIENT']['MRG'][4][1];
         $aPatient = $this->p->load(array('pubpid' => $pid))->one();
         $bPatient = $this->p->load(array('pubpid' => $mrg))->one();
         $this->MergeHandler($aPatient, $bPatient, $pid, $mrg);
         return;
     } elseif ($evt == 'A40') {
         /**
          * Merge Patient - Patient Identifier List
          * PID-3.1 <= MRG-1.1
          */
         $pid = $msg->data['PATIENT']['PID'][3][1];
         $mrg = $msg->data['PATIENT']['MRG'][1][1];
         $aPatient = $this->p->load(array('pid' => $pid))->one();
         $bPatient = $this->p->load(array('pid' => $mrg))->one();
         $this->MergeHandler($aPatient, $bPatient, $pid, $mrg);
         return;
     } elseif ($evt == 'A41') {
         /**
          * Merge Account - Patient Account Number
          * PID-18.1 <= MRG-3.1
          */
         $pid = $msg->data['PATIENT']['PID'][18][1];
         $mrg = $msg->data['PATIENT']['MRG'][3][1];
         $aPatient = $this->p->load(array('pubaccount' => $pid))->one();
         $bPatient = $this->p->load(array('pubaccount' => $mrg))->one();
         $this->MergeHandler($aPatient, $bPatient, $pid, $mrg);
         return;
     }
     /**
      * Un handle event error
      */
     $this->ackStatus = 'AR';
     $this->ackMessage = 'Unable to handle ADT_' . $evt;
 }
示例#26
0
 public function updatePatientReferral($params)
 {
     return $this->r->save($params);
 }
示例#27
0
 public function updateEncounterDx($params)
 {
     return $this->edx->save($params);
 }
示例#28
0
 public function updateTemplatePanelTemplate($params)
 {
     return $this->i->save($params);
 }
示例#29
0
 public function updateSpecialty($params)
 {
     return $this->s->save($params);
 }
示例#30
0
 public function updatePatientAdvanceDirective($params)
 {
     return $this->a->save($params);
 }