$username = $_REQUEST['username'];
    $password = $_REQUEST['password'];
    $confirm_password = $_REQUEST['confirmPassword'];
    $result = $setup->createAdminUser($username, $password, $confirm_password);
    if ($result) {
        echo JsonResponse::success('Successfully created admin user');
        exit;
    } else {
        echo JsonResponse::error('Error creating admin user');
        exit;
    }
} elseif ($intent == 'addHospitalInfoAndUnits') {
    $hospital_name = $_REQUEST['name'];
    $hospital_address = $_REQUEST['address'];
    $values = $_REQUEST['values'];
    $hospital = new HospitalDetailsController();
    $result = $hospital->createHospitalDetails($hospital_name, $hospital_address);
    if ($result) {
        $units = new PharmacistController();
        $units_added = $units->addDrugUnits($values);
        if ($units_added) {
            echo JsonResponse::success('Successfully added hospital information and drug units');
            exit;
        } else {
            echo JsonResponse::error('Could not add drug units');
            exit;
        }
    } else {
        echo JsonResponse::error('Adding hospital information unsuccessful');
        exit;
    }
Example #2
0
    }
} elseif ($intent == 'getHospitalDetails') {
    $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') {