function S_WorkerUpdate()
{
    $user_profile_id = sanitize($_GET['view']);
    if (isset($_POST['go'])) {
        $profileObjArray = retrieve_UserProfile_RMHAdmin($user_profile_id);
        $profileObj = is_array($profileObjArray) ? current($profileObjArray) : false;
        if ($profileObj) {
            $profileObj->set_usernameId($_POST["SW_Username"]);
            $profileObj->set_userCategory($_POST["SW_Category"]);
            $profileObj->set_userEmail($_POST["SW_Email"]);
            $ReturnValue = update_UserProfile($user_profile_id);
            if ($ReturnValue) {
                $profileObj->set_swTitle($_POST["SW_Title"]);
                $profileObj->set_swFirstName($_POST["SW_FirstName"]);
                $profileObj->set_swLastName($_POST["SW_LastName"]);
                $profileObj->set_swPhone($_POST["SW_Phone"]);
                $ReturnValue1 = update_SocialWorkerProfile($user_profile_id);
                if ($ReturnValue1) {
                    header('Location: admin/listUsers.php');
                } else {
                    $errors['invalid_profile'] = "Could not complete request";
                }
            } else {
                $errors['invalid_profile'] = "Could not update admin information";
            }
        } else {
            $errors['invalid_profile'] = "Could not update profile information";
        }
    }
}
/**
 * Inserts a new Social Worker Profile into the SocialWorkerProfile table
 * @param $userprofile = the userprofile to insert
 *
 * @author: Linda Shek
 */
function insert_SocialWorkerProfile($userprofile)
{
    if (!$userprofile instanceof UserProfile) {
        return false;
    }
    connect();
    //Check if the social worker profile already exists
    $query = "SELECT * FROM socialworkerprofile WHERE SocialWorkerProfileID =" . $userprofile->get_swProfileId() . " \r\n            AND UserProfileID =" . $userprofile->get_userProfileId();
    $result = mysql_query($query) or die(mysql_error());
    if (mysql_num_rows($result) > 0) {
        //Need to return an update function if already exists.
        return update_SocialWorkerProfile($userprofile);
    }
    $query = "INSERT INTO socialworkerprofile (UserProfileID, Title, FirstName, LastName, HospitalAffiliation, Phone,\r\n              EmailNotification) VALUES (" . $userprofile->get_userProfileId() . ",'" . $userprofile->get_swTitle() . "','" . $userprofile->get_swFirstName() . "','" . $userprofile->get_swLastName() . "','" . $userprofile->get_hospitalAff() . "','" . $userprofile->get_swphone() . "','" . $userprofile->get_email_notification() . "')";
    $result = mysql_query($query);
    if (!$result) {
        echo mysql_error() . " Sorry unable to insert into SocialWorkerProfile.";
        mysql_close();
        return false;
    }
    mysql_close();
    return true;
}