Exemplo n.º 1
0
    $hospitalDetailsController = new HospitalDetailsController();
    $hospitalInfo = $hospitalDetailsController->getHospitalDetails();
    if ($hospitalInfo) {
        echo JsonResponse::success($hospitalInfo);
        exit;
    } else {
        echo JsonResponse::error("Could not fetch hospital details.");
        exit;
    }
} elseif ($intent == 'updateHospitalDetails') {
    $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
    $name = isset($_REQUEST['name']) ? $_REQUEST['name'] : "";
    $address = isset($_REQUEST['address']) ? $_REQUEST['address'] : "";
    $hospitalDetailsController = new HospitalDetailsController();
    if ($id) {
        $hospitalInfo = $hospitalDetailsController->updateHospitalDetails($id, $name, $address);
    } else {
        $hospitalInfo = $hospitalDetailsController->createHospitalDetails($name, $address);
    }
    if ($hospitalInfo) {
        CxSessionHandler::setItem(HOSPITAL_NAME, $name);
        // RESETS THE HOSPITAL NAME IN SESSION
        echo JsonResponse::success("Successfully updated  hospital details");
        exit;
    } else {
        echo JsonResponse::error("Could not update hospital details.");
        exit;
    }
} elseif ($intent == 'addDrugUnits') {
    $values = $_REQUEST['values'];
    $units = new PharmacistController();