/** * @param \stdClass $params * @internal param $pid * @return mixed */ public function currPatientSet(stdClass $params) { include_once $_SESSION['root'] . '/dataProvider/PoolArea.php'; $poolArea = new PoolArea(); $_SESSION['patient']['pid'] = $params->pid; $_SESSION['patient']['name'] = $this->getPatientFullNameByPid($params->pid); $p = $this->isPatientChartOutByPid($params->pid); $area = $poolArea->getCurrentPatientPoolAreaByPid($params->pid); if ($p === false || is_array($p) && $p['uid'] == $_SESSION['user']['id']) { $this->patientChartOutByPid($params->pid, $area['area_id']); $_SESSION['patient']['readOnly'] = false; } else { $_SESSION['patient']['readOnly'] = true; } return array('patient' => array('pid' => $params->pid, 'name' => $_SESSION['patient']['name'], 'pic' => $this->getPatientPhotoSrcIdByPid($params->pid), 'sex' => $this->getPatientSexByPid($params->pid), 'dob' => $dob = $this->getPatientDOBByPid($params->pid), 'age' => $this->getPatientAgeByDOB($dob), 'area' => $p === false ? null : $poolArea->getAreaTitleById($p['pool_area_id']), 'priority' => empty($area) ? null : $area['priority']), 'readOnly' => $_SESSION['patient']['readOnly'], 'overrideReadOnly' => $this->acl->hasPermission('override_readonly'), 'user' => $p === false ? null : $this->user->getUserFullNameById($p['uid']), 'area' => $p === false ? null : $poolArea->getAreaTitleById($p['pool_area_id'])); }
public function updateEncounterPriority($params) { $data['priority'] = $params->priority; $this->db->setSQL($this->db->sqlBind($data, 'encounters', 'U', array('eid' => $params->eid))); $this->db->execLog(); $this->poolArea->updateCurrentPatientPoolAreaByPid(array('eid' => $params->eid, 'priority' => $params->priority), $params->pid); }
public function getPatientsZonesByFloorPlanId($FloorPlanId) { $Patient = new Patient(); $Pool = new PoolArea(); $zones = $this->pz->sql("SELECT pz.id AS patientZoneId,\n\t\t\t\t\t\t\t\t pz.pid,\n\t\t\t\t\t\t\t\t pz.uid,\n\t\t\t\t\t\t\t\t pz.zone_id AS zoneId,\n\t\t\t\t\t\t\t\t time_in AS zoneTimerIn,\n\t\t\t\t\t\t\t\t fpz.floor_plan_id AS floorPlanId\n\t\t\t\t\t\t\t FROM patient_zone AS pz\n\t\t\t\t\t\tLEFT JOIN floor_plans_zones AS fpz ON pz.zone_id = fpz.id\n\t\t\t\t\t\t\tWHERE fpz.floor_plan_id = {$FloorPlanId} AND pz.time_out IS NULL")->all(); foreach ($zones as $i => $zone) { $zone['patient'] = $Patient->getPatientDemographicDataByPid($zone['pid']); $zone['name'] = $Patient->getPatientFullName(); $zone['warning'] = $Patient->getPatientArrivalLogWarningByPid($zone['pid']); $pool = $Pool->getCurrentPatientPoolAreaByPid($zone['pid']); $zone['poolArea'] = $pool['poolArea']; $zone['priority'] = $pool['priority']; $zone['eid'] = $pool['eid']; $zones[$i] = $zone; } unset($Patient, $Pool); return $zones; }
public function createNewEmergency() { $patient = $this->patient->createNewPatientOnlyName('EMER'); if ($patient['success']) { $this->pid = $patient['patient']['pid']; /** * send new patient to the emergency pool area */ $params = new stdClass(); $params->pid = $this->pid; $params->priority = $this->priority; $params->sendTo = 3; $this->poolArea->sendPatientToPoolArea($params); /** * create new encounter */ $params = new stdClass(); $params->pid = $this->pid; $params->brief_description = '***EMERGENCY***'; $params->visit_category = 'Emergency'; $params->priority = $this->priority; $params->service_date = Time::getLocalTime(); $params->open_uid = $_SESSION['user']['id']; $encounter = $this->encounter->createEncounter($params); $this->eid = $encounter['encounter']['eid']; /** * log the emergency */ $this->logEmergency(); /* * update patient first name to EMERGENCY- encounter id */ $data['fname'] = 'EMER-' . $this->emergencyId; $this->db->setSQL($this->db->sqlBind($data, 'patient', 'U', array('pid' => $this->pid))); $this->db->execOnly(); return array('success' => true, 'emergency' => array('pid' => $this->pid, 'eid' => $this->eid, 'name' => 'EMER-' . $this->emergencyId, 'priority' => $params->priority)); } else { return array('success' => false, 'error' => $patient['error']); } }
/** * @param $params * * @return array */ public function getPatientSetDataByPid($params) { include_once ROOT . '/dataProvider/PoolArea.php'; $this->setPatient($params->pid); $poolArea = new PoolArea(); $area = $poolArea->getCurrentPatientPoolAreaByPid($this->patient['pid']); $chart = $this->patientChartOutByPid($this->patient['pid'], $area['area_id']); return ['patient' => ['pid' => $this->patient['pid'], 'pubpid' => $this->patient['pubpid'], 'name' => $this->getPatientFullName(), 'pic' => $this->patient['image'], 'sex' => $this->getPatientSex(), 'dob' => $this->getPatientDOB(), 'age' => $this->getPatientAge(), 'area' => $area['poolArea'], 'priority' => empty($area) ? null : $area['priority'], 'rating' => isset($this->patient['rating']) ? $this->patient['rating'] : 0, 'record' => $this->patient], 'chart' => ['readOnly' => $chart->read_only == '1', 'overrideReadOnly' => $this->acl->hasPermission('override_readonly'), 'outUser' => isset($chart->outChart->uid) ? $this->user->getUserFullNameById($chart->outChart->uid) : 0, 'outArea' => isset($chart->outChart->pool_area_id) ? $poolArea->getAreaTitleById($chart->outChart->pool_area_id) : 0]]; }
public function updateEncounterPriority($params) { $this->updateEncounter($params); $this->poolArea->updateCurrentPatientPoolAreaByPid(['eid' => $params->eid, 'priority' => $params->priority], $params->pid); }
/** * @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; }