%@ LANGUAGE="VBSCRIPT" TRANSACTION=REQUIRED %>
<% Option Explicit %>
<%
Dim m_ReturnTitle1, m_ReturnTitle2, m_EnrollPrompt, m_BenefitLabel, m_DependentCovered, _
m_PlanId, m_PlanLabel, m_PlanDesc, m_PlanCost, m_TaxStatusId, m_TaxStatusLabel, _
m_Change, m_CurrentPlanId, m_ShowPlanId, m_ShowPlanRank, m_PhysicianRequired, _
m_CoveredPrompt, m_TaxStatusPrompt, m_Review, m_BenefitId, m_RequestPlanId, _
m_intRequestPlanId, m_intTaxStatus, m_BenefitYear, m_ActiveQualifier, _
m_NoPhysician, strURL, m_strMainPrompt, m_UpdateMessage
' Move Input parameters to working variables
m_Review = Request("Review")
m_BenefitId = Request("BenefitId")
m_RequestPlanId = Request("RequestPlanId")
' Get the Physician Id that represents 'No Physician Selected'
m_NoPhysician = CInt(Application("NoPhysician"))
' Handle if Review or Open Enrollment and Qualified to change or not
If m_Review = 0 Then
m_Change = 1
m_BenefitYear = Year(Date) + 1
m_ReturnTitle1 = "Return to Open Enrollment"
m_ReturnTitle2 = "OPEN ENROLLMENT"
m_EnrollPrompt = "To change your Insurance, select a Plan, make any other changes, " & _
"and then click Save." & _
" Any changes you make will take effect at the beginning of next year.
"
m_CoveredPrompt = " " & _
"
To add or remove coverage, click the check box next to the " & _
"person whose coverage you want to change. " & _
"You can also add a dependent
"
' Set prompt about tax status
m_TaxStatusPrompt = " " & _
"
To choose whether to spend Pre-tax dollars or After-tax dollars " & _
"on this benefit, select the appropriate button.
"
Else
' Deal with records for this year
m_BenefitYear = Year(Date)
' Find out if Employee has a qualifying event in effect for this benefit
CheckQualifier
If m_ActiveQualifier = 1 Then
m_Change = 1
m_ReturnTitle1 = "Return to Review or Change Current Benefits"
m_ReturnTitle2 = "REVIEW OR CHANGE CURRENT BENEFITS"
m_EnrollPrompt = "To change your Insurance, select a Plan, make any other changes, " & _
"and then click Save." & _
" Any changes you make will take effect at the beginning of next month.
"
' Set prompt about maintaining covered persons
m_CoveredPrompt = " " & _
"
To add or remove coverage, click the check box next to the " & _
"person whose coverage you want to change. " & _
"You can also add a dependent
"
' Set prompt about tax status
m_TaxStatusPrompt = " " & _
"
To choose whether to spend Pre-tax dollars or After-tax dollars " & _
"on this benefit, select the appropriate button.
"
Else
m_ReturnTitle1 = "Return to Review or Change Current Benefits"
m_ReturnTitle2 = "REVIEW OR CHANGE CURRENT BENEFITS"
m_EnrollPrompt = "To change your Insurance, click Change.
"
' Set prompt about maintaining covered persons
m_CoveredPrompt = " " & _
"
"
End If
End If
m_UpdateMessage = ""
If Request.Form("SubmitPlan") <> "" Then
If Request.Form("SubmitPlan") = "Save" Then
GetValuesFromForm
UpdateBenefit
GetCurrentPlan
m_ShowPlanId = m_CurrentPlanId
GetPlanInfo(m_ShowPlanId)
m_UpdateMessage = " Language=JavaScript " & _
"onLoad=" & Chr(34) & "{ alert ('Your Insurance Plan was updated.');}" & Chr(34)
' User clicked Change, so need to get qualifying change info and then update
Else
strURL = "Change.asp?BenefitId=" & m_BenefitId
Response.Redirect(strURL)
Response.End
End If
Else
' If the Request included a "RequestPlan" then show its info
If m_RequestPlanId > 0 Then
GetCurrentPlan
m_ShowPlanId = CInt(m_RequestPlanId)
GetPlanInfo(m_ShowPlanId)
' Else show the current plan info
Else
GetCurrentPlan
m_ShowPlanId = m_CurrentPlanId
GetPlanInfo(m_ShowPlanId)
End If
End If
%>
<%= m_BenefitLabel %>
>
<% 'Conditional Script for RDS
If Session("UseRDS") = "True" Then
%>
<% 'End of conditional Script for RDS
End If
%>
<%
'
'Determine if employee has a qualifier in effect
'
Sub CheckQualifier
Dim Benefit, rstActiveQualifier
Set Benefit = Server.CreateObject("Benefit.BenefitList")
Set rstActiveQualifier = Benefit.CheckQualifier(Application("DSNBenefits"), _
Session("EmployeeId"), m_BenefitId)
If Not rstActiveQualifier.EOF Then
m_ActiveQualifier = 1
End If
End Sub
'
' Get Current Plan
'
Sub GetCurrentPlan
Dim BenefitList, rstCurrentPlan
Set BenefitList = Server.CreateObject("Benefit.BenefitList")
Set rstCurrentPlan = BenefitList.CurrentPlan(Application("DSNBenefits"), Session("EmployeeID"), _
m_BenefitId)
If Not rstCurrentPlan.EOF Then
m_BenefitLabel = rstCurrentPlan("BenefitLabel")
m_CurrentPlanId = rstCurrentPlan("PlanId")
m_DependentCovered = rstCurrentPlan("DependentCovered")
m_TaxStatusId = rstCurrentPlan("TaxStatusId")
m_TaxStatusLabel = rstCurrentPlan("TaxStatusLabel")
End If
End Sub
'
' Get Plan info
'
Sub GetPlanInfo(byval PlanId)
Dim BenefitList, rstPlanInfo
Set BenefitList = Server.CreateObject("Benefit.BenefitList")
Set rstPlanInfo = BenefitList.PlanInfo(Application("DSNBenefits"), _
m_BenefitId, PlanId)
If Not rstPlanInfo.EOF Then
m_PlanLabel = rstPlanInfo("PlanLabel")
m_PlanDesc = rstPlanInfo("PlanDesc")
m_PlanCost = rstPlanInfo("PlanCost")
m_PhysicianRequired = rstPlanInfo("PhysicianRequired")
m_ShowPlanRank = rstPlanInfo("PlanRank")
End If
End Sub
'
' Create Select list of available Plans
'
Sub BuildPlanList
Dim BenefitList, rstPlanList
Set BenefitList = Server.CreateObject("Benefit.BenefitList")
Set rstPlanList = BenefitList.PlanList(Application("DSNBenefits"), m_BenefitId)
Response.Write "" & Chr(13)
End Sub
'
' Generate the rows of the Fields for the current Plan.
'
Sub ListPlanField(byval PlanId)
Dim BenefitList, rstPlanField
Set BenefitList = Server.CreateObject("Benefit.BenefitList")
Set rstPlanField = BenefitList.PlanField(Application("DSNBenefits"), PlanId)
Do Until rstPlanField.EOF
Response.Write "
" & Chr(13)
Response.Write "
" & rstPlanField("FieldLabel") & "
" & Chr(13)
Response.Write "
" & rstPlanField("FieldValue") & "
" & Chr(13)
Response.Write "
" & Chr(13)
rstPlanField.MoveNext
Loop
End Sub
'
' Generate the rows for a table consisting of the Dependent info for the current Benefit.
'
Sub ListDependents
Dim BenefitList, rstDependents
Set BenefitList = Server.CreateObject("Benefit.BenefitList")
Set rstDependents = BenefitList.ListDependents(Application("DSNBenefits"), Session("EmployeeId"), _
m_BenefitId)
Do Until rstDependents.EOF
Response.Write "
" & Chr(13)
Response.Write "
" & Chr(13)
Else
Response.Write ">" & Chr(13)
End If
Response.Write "
" & Chr(13)
rstDependents.MoveNext
Loop
End Sub
'
' Generate the rows for a table consisting of the Covered Persons for the current Benefit.
'
Sub ListCoveredPersons
Dim BenefitList, rstCovered
Set BenefitList = Server.CreateObject("Benefit.BenefitList")
Set rstCovered = BenefitList.ListCoveredPersons(Application("DSNBenefits"), _
Session("EmployeeId"), m_BenefitId)
Do Until rstCovered.EOF
Response.Write "
" & Chr(13)
rstCovered.MoveNext
Loop
End Sub
'
' Create Select list of Physicians
'
Sub BuildPhysicianList (ByVal DependentPhysicianId)
Dim BenefitList, rstPhysicianList
Set BenefitList = Server.CreateObject("Benefit.BenefitList")
Set rstPhysicianList = BenefitList.PhysicianList(Application("DSNBenefits"))
Response.Write "" & Chr(13)
End Sub
'
' Determine count of available Tax Statuses
'
Function FindTaxChoice()
FindTaxChoice = True
Dim BenefitList, rstTaxStatusList
Set BenefitList = Server.CreateObject("Benefit.BenefitList")
Set rstTaxStatusList = BenefitList.TaxStatusList(Application("DSNBenefits"), m_BenefitId)
If rstTaxStatusList.RecordCount <2 And Not rstTaxStatusList.EOF Then
FindTaxChoice = False
End If
End Function
'
' Create Radio buttons of available Tax Statuses (or just output the only available status)
'
Sub BuildTaxStatusList
Dim BenefitList, rstTaxStatusList
Set BenefitList = Server.CreateObject("Benefit.BenefitList")
Set rstTaxStatusList = BenefitList.TaxStatusList(Application("DSNBenefits"), m_BenefitId)
If rstTaxStatusList.RecordCount <2 And Not rstTaxStatusList.EOF Then
Response.Write rstTaxStatusList("TaxStatusLabel")
Else
Do Until rstTaxStatusList.EOF
Response.Write "" & rstTaxStatusList("TaxStatusLabel") & Chr(13)
rstTaxStatusList.MoveNext
Loop
End If
End Sub
'
' Take values from the submitted form and assign to page level variables.
'
Sub GetValuesFromForm
m_intRequestPlanId = Trim(Request.Form("RequestPlanId"))
'If "No Plan Selected" then Tax Status will not be on form
If Trim(Request.Form("TaxStatus")) <> "" Then
m_intTaxStatus = Trim(Request.Form("TaxStatus"))
Else
m_intTaxStatus = 1
End If
End Sub
'
' Update the database. Return 0 if successful or 1 if an error is encountered.
'
Function UpdateBenefit
On Error Resume Next
GetValuesFromForm
Dim Benefit, i
Set Benefit = Server.CreateObject("Benefit.BenefitList")
Benefit.Update Application("DSNBenefits"), Session("EmployeeId"), m_BenefitId, _
m_intRequestPlanId, m_intTaxStatus
' Mark all Dependents as Not Covered (Change status to 2 for InActive )
Benefit.InactivateDependents Application("DSNBenefits"), Session("EmployeeId"), _
m_BenefitId
' Process any Dependents marked as Covered (Change status to 1 for Active )
For i = 1 to Request.Form("DepCovered").Count
' PhysicianId is not included with some plans. If not bound, Count will be 0.
If Request.Form("PhysicianId").Count > 0 Then
Benefit.SaveDependents Application("DSNBenefits"), Session("EmployeeId"), _
m_BenefitId, Request.Form("DepCovered")(i), Request.Form("PhysicianId")(i)
Else
Benefit.SaveDependents Application("DSNBenefits"), Session("EmployeeId"), _
m_BenefitId, Request.Form("DepCovered")(i), m_NoPhysician
End If
Next
If Err.Number = 0 Then
UpdateBenefit = 0
Else
ContextObject.SetAbort
UpdateBenefit = 1
End If
End Function
Sub OnTransactionCommit
End Sub
Sub OnTransactionAbort
m_strMainPrompt = "A problem occurred while trying to update the database. Please try again later. "
End Sub
%>