public function admitPatient($patient_id, $treatment_id, $admitted_by, $bed_id, $comments) { $feedback = array(); $admitted = AdmissionController::isAdmitted($patient_id); if ($admitted) { $feedback[P_STATUS] = STATUS_ERROR; $feedback[P_MESSAGE] = "Patient already admitted!"; return $feedback; } $occupied = WardController::isOccupied($bed_id); if ($occupied) { $feedback[P_STATUS] = STATUS_ERROR; $feedback[P_MESSAGE] = "Bed already occupied!"; return $feedback; } $admission_model = new AdmissionModel(); $admission_data = array(); $admission_data[AdmissionTable::patient_id] = $patient_id; $admission_data[AdmissionTable::treatment_id] = $treatment_id; $admission_data[AdmissionTable::admitted_by] = $admitted_by; $admission_data[AdmissionTable::comments] = $comments; $admission_data[AdmissionBedTable::bed_id] = $bed_id; $response = $admission_model->admitPatient($admission_data); if ($response) { $feedback[P_STATUS] = STATUS_OK; $feedback[P_MESSAGE] = "Patient admission successful!"; } else { $feedback[P_STATUS] = STATUS_ERROR; $feedback[P_MESSAGE] = "Unable to complete patient admission!"; } return $feedback; }
} } elseif ($intent == 'getAdmissionRequests') { $response = AdmissionController::admissionRequests(); if (is_array($response)) { if (isset($response[P_MESSAGE])) { echo JsonResponse::message($response[P_STATUS], $response[P_MESSAGE]); exit; } else { echo JsonResponse::success($response[P_DATA]); exit; } } else { echo JsonResponse::error("Unable to get pending admission requests!"); exit; } } elseif ($intent == 'searchAdmissionRequests') { if (isset($_REQUEST[TERM])) { $warden = new AdmissionController(); $patient_details = $warden->searchAdmissionRequests($_REQUEST[TERM]); if (is_array($patient_details)) { echo json_encode($patient_details); exit; } else { echo JsonResponse::error("No patients match the search parameter!"); exit; } } else { echo JsonResponse::error("Incomplete request parameters!"); exit; } }
<?php /** * Created by PhpStorm. * User: olajuwon * Date: 2/16/2015 * Time: 1:10 PM */ require_once '../_core/global/_require.php'; Crave::requireAll(GLOBAL_VAR); Crave::requireAll(UTIL); Crave::requireFiles(MODEL, array('BaseModel', 'AdmissionModel', 'RoleModel', 'BedModel', 'WardModel', 'VitalsModel')); Crave::requireFiles(CONTROLLER, array('AdmissionController', 'RoleController', 'VitalsController')); $admission = new AdmissionController(); $wards = $admission->loadWards(); ?> <!DOCTYPE html> <html> <head> <meta charset='utf-8' /> <title>Admin Dashboard</title> <link href="../css/bootstrap/bootstrap.min.css" rel="stylesheet"> <link href='../css/libs/fullCalendar/fullcalendar.css' rel='stylesheet' /> <link href='../css/libs/fullCalendar/fullcalendar.print.css' rel='stylesheet' media='print' /> <link href="../css/master.css" rel="stylesheet"> </head> <body> <nav class="navbar navbar-inverse navbar-fixed-top"> <div class="container-fluid"> <div class="navbar-header">
$warden = new AdmissionController(); $response = $warden->logEncounter($personnel_id, $_REQUEST[AdmissionTable::patient_id], $_REQUEST[AdmissionTable::admission_id], $_REQUEST[EncounterTable::comments], $vitals_data); if ($response) { echo JsonResponse::message(STATUS_OK, "Encounter logged successfully!"); exit; } else { echo JsonResponse::error("Unable to log encounter!"); exit; } } else { echo JsonResponse::error("Incomplete request parameters!"); exit; } } elseif ($intent == 'switchBed') { if (isset($_POST[AdmissionBedTable::admission_id], $_POST[AdmissionBedTable::bed_id])) { $warden = new AdmissionController(); $response = $warden->switchBed($_POST[AdmissionBedTable::admission_id], $_POST[AdmissionBedTable::bed_id]); if (is_array($response)) { echo JsonResponse::error($response[P_MESSAGE]); exit; } else { echo JsonResponse::message(STATUS_OK, "Bed successfully assigned!"); exit; } } else { echo JsonResponse::error("Incomplete request parameters!"); exit; } } else { echo JsonResponse::error("Invalid intent!"); exit;