function test_insert_dbProfileActivity($profileActivity)
{
    $retVal = insert_ProfileActivity($profileActivity);
    if ($retVal == true) {
        echo "</br> Insert succeeded </br>";
    } else {
        echo "</br> Insert failed </br>";
    }
    echo "Profile Activity Request ID: " . $profileActivity->get_profileActivityRequestID();
}
function updateFamilyProfile(Family $familyProfile)
{
    error_log("in updateFamilyProfile will do the actual insert to the database");
    $activityType = "Edit";
    //retrieves the sw, and gets id, firstname and lastname
    $currentUser = getUserProfileID();
    $swID = "";
    $swFirstName = "";
    $swLastName = "";
    $rmhStaffProfileId = "";
    $rmhStaffFirstName = "";
    $rmhStaffLastName = "";
    $dateSWSubmit = 'NULL';
    $dateRMHApproved = 'NULL';
    // if the person doing the edit is a social worker, add their name and id to the reservation
    // activity record
    if (getUserAccessLevel() == 1) {
        $rmhStaffProfileId = 'NULL';
        $sw = retrieve_UserProfile_SW($currentUser);
        $swObject = current($sw);
        // there is only one record in the returned array, so get it
        // consider changing this code
        $swID = $swObject->get_swProfileId();
        //   $swFirstName = $swObject->get_swFirstName();
        //   $swLastName=$swObject->get_swLastName();
        $status = "Unconfirmed";
        $dateSWSubmit = date("Y-m-d H:i:s");
    } else {
        if (getUserAccessLevel() == 2) {
            $rmhStaff = retrieve_UserProfile_RMHApprover_OBJ($currentUser);
            $rmhStaffProfileId = $rmhStaff->get_rmhStaffProfileId();
            //    $rmhStaffFirstName = $rmhStaff->get_rmhStaffFirstName();
            //  $rmhStaffLastName = $rmhStaff->get_rmhStaffLastName();
            $status = "Confirmed";
            $dateRMHApproved = date("Y-m-d H:i:s");
        }
    }
    // only if this is an RMH staff approval
    // insert_FamilyProfile($familyProfile);
    error_log('in updateFamilyProfile, familyProfileId is ' . $familyProfile->get_familyProfileId());
    // only insert an activity record - will insert change into FamilyProfile table only if
    // approved
    $currentProfileActivity = new ProfileActivity(0, 0, $familyProfile->get_familyProfileId(), $swID, $rmhStaffProfileId, $dateSWSubmit, $dateRMHApproved, $activityType, $status, $familyProfile->get_parentfname(), $familyProfile->get_parentlname(), $familyProfile->get_parentemail(), $familyProfile->get_parentphone1(), $familyProfile->get_parentphone2(), $familyProfile->get_parentaddress(), $familyProfile->get_parentcity(), $familyProfile->get_parentstate(), $familyProfile->get_parentzip(), $familyProfile->get_parentcountry(), $familyProfile->get_patientfname(), $familyProfile->get_patientlname(), $familyProfile->get_patientrelation(), $familyProfile->get_patientdob(), $familyProfile->get_patientformpdf(), $familyProfile->get_patientnotes(), $familyProfile->get_patientnotes());
    $retval = insert_ProfileActivity($currentProfileActivity);
    return $retval;
}
     }
     if ($_POST['text_patientnotes'] != $Profile['patientnotes']) {
         $patientnotes = sanitize($_POST['text_patientnotes']);
         $change = true;
     } else {
         $patientnotes = $Profile['patientnotes'];
     }
     if (isset($_POST['text_swnotes'])) {
         $profileActityNotes = sanitize($_POST['text_swnotes']);
     } else {
         $profileActityNotes = "";
     }
     $current_activity = new ProfileActivity(0, 0, $familyID, $sw_id, $sw_lname, $sw_fname, 0, "", "", $dateSubmit, 0, $activityType, $profileActitivityStatus, $parentfname, $parentlname, $parentemail, $parentphone1, $parentphone2, $parentAddr, $parentcity, $parentstate, $parentzip, $parentcountry, $patientfname, $patientlname, $patientrelation, $patientdob, $patientformpdf, $patientnotes, $profileActityNotes);
     //if there is a change, insert a new profileActivity object
     if ($change) {
         if (insert_ProfileActivity($current_activity)) {
             echo "Successfully inserted a profile activity request";
             //Send email to notify the rmh approvers
             $RequestKey = $current_activity->get_profileActivityRequestId();
             if (newFamilyMod($RequestKey, $familyID, $dateSubmit)) {
                 echo "An email is sent to the RMH Approver";
             }
             echo '<a href="' . BASE_DIR . '/referralForm.php?family=' . $familyID . '">Create Room Reservation</a>';
             exit;
         }
     } else {
         if (!$change) {
             echo "You did not make any changes.";
         }
     }
 } else {