Exemple #1
0
 public function newEDT($data)
 {
     if (!$this->isPatient($data['pid']) || !checkFilled($data) || !verifyDate($data['dateperf']) || !checkNumber($data['cost']) || !checkNumber($data['duration']) || !checkNumber($data['pid'])) {
         return false;
     }
     // Verify the physicians mentioned are valid
     $a = new Admin();
     $physicians = $a->getAllPhysicians();
     $enames = explode(',', $data['enames']);
     foreach ($enames as $e) {
         if (!array_search(trim($e), $physicians)) {
             printError("A physician specified in the Physician Names field does not exist.");
             return false;
         }
     }
     $success = true;
     $pid = $data['pid'];
     unset($data['pid']);
     $newEDT = 0;
     if (!$this->dbh->insert('EDTRecords', $data)) {
         $success = false;
     } else {
         $result = $this->dbh->query('SELECT MAX(edtid) AS last FROM EDTRecords');
         $newEDT = $result[0]['last'];
         // Could potentially be bad, if the ordering of insertions between users interferes
     }
     if (!$this->dbh->insert('PatientExaminations', array('pid' => $pid, 'edtid' => $newEDT))) {
         $success = false;
     }
     return $success;
 }
Exemple #2
0
 public function checkOutPatient($data)
 {
     if (!$this->isPatient($data['pid']) || !checkFilled($data) || !verifyDate($data['outdate']) || !checkNumber($data['eidout']) || !checkNumber($data['pid']) || !$this->isCheckedIn($data['pid'])) {
         return false;
     }
     $where = array('field' => 'pid', 'value' => $data['pid']);
     // Add up costs of EDT records for that visit
     $total = 0;
     $t = new Treatment();
     $edts = $t->getEDTRecords($data['pid'], true);
     foreach ($edts as $e) {
         $total = $total + $e['cost'];
     }
     $data['totalbill'] = $total;
     unset($data['pid']);
     // remove pid from elements
     return $this->dbh->update('CheckInOuts', $data, $where, true);
 }