public function deleteBed($bed_id) { $bed = new BedModel($bed_id); $bed_status = $bed->getStatus(); if ($bed_status == OCCUPIED) { $response = array(P_STATUS => STATUS_ERROR, P_MESSAGE => "Cannot remove bed that is currently occupied!"); return $response; } $feedback = $bed->delete(); if (!$feedback) { $response = array(P_STATUS => STATUS_ERROR, P_MESSAGE => "Unable to delete bed!"); return $response; } return $feedback; }
public function switchBed($admission_id, $bed_id) { $admission_model = new AdmissionModel(); $bed = new BedModel($bed_id); $bed_status = $bed->getStatus(); if ($bed_status == OCCUPIED) { $response = array(P_STATUS => STATUS_ERROR, P_MESSAGE => "Cannot assign bed that is currently occupied!"); return $response; } $feedback = $admission_model->switchBed($admission_id, $bed_id); if (!$feedback) { $response = array(P_STATUS => STATUS_ERROR, P_MESSAGE => "Unable to assign bed!"); return $response; } return $feedback; }
public function dischargePatient($discharge_data) { $admission_details = AdmissionModel::getAdmissionDetails($discharge_data[AdmissionTable::patient_id]); $admission_id = $admission_details[AdmissionTable::admission_id]; $bed_id = $admission_details[AdmissionBedTable::bed_id]; $begin = $this->conn->beginTransaction(); if ($begin) { // Discharge patient...Set admission active flag to INACTIVE $stmt = AdmissionSqlStatement::DISCHARGE; $data = array(); $data[AdmissionTable::admission_id] = $admission_id; $data[AdmissionTable::discharged_by] = $discharge_data[AdmissionTable::discharged_by]; $discharged = $this->conn->execute($stmt, $data, true); if ($discharged) { //Remove bed assignments $stmt = AdmissionSqlStatement::REMOVE_FROM_BED; $data = array(); $data[AdmissionBedTable::admission_id] = $admission_details[AdmissionTable::admission_id]; $data[AdmissionBedTable::bed_id] = $bed_id; $removed = $this->conn->execute($stmt, $data, true); if ($removed) { $bed_model = new BedModel($bed_id, $this->conn); $vacated = $bed_model->vacate(); if ($vacated) { $this->conn->commit(); return true; } else { $this->conn->rollBack(); return false; } } else { $this->conn->rollBack(); return false; } } else { $this->conn->rollBack(); return false; } } else { return false; } }