home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1999 September
/
CHIPCD_9_99.iso
/
software
/
uaktualnienia
/
OptionPackPL
/
iis4_07.cab
/
ExAirBenefits.sql
< prev
next >
Wrap
Text File
|
1998-04-27
|
40KB
|
1,180 lines
/***** Make sure we are in Master database ******/
use master
GO
/***** Create the database ******/
create database ExAirBenefits
on ExAirBenefitsDev = 4
GO
use ExAirBenefits
go
/****** Object: Stored Procedure dbo.sp_AddEBD Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_AddEBD') and sysstat & 0xf = 4)
drop procedure dbo.sp_AddEBD
GO
/****** Object: Stored Procedure dbo.sp_InactivateDependents Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_InactivateDependents') and sysstat & 0xf = 4)
drop procedure dbo.sp_InactivateDependents
GO
/****** Object: Stored Procedure dbo.sp_ListCoveredPersons Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_ListCoveredPersons') and sysstat & 0xf = 4)
drop procedure dbo.sp_ListCoveredPersons
GO
/****** Object: Stored Procedure dbo.sp_ListDependents Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_ListDependents') and sysstat & 0xf = 4)
drop procedure dbo.sp_ListDependents
GO
/****** Object: Stored Procedure dbo.sp_SaveDependents Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_SaveDependents') and sysstat & 0xf = 4)
drop procedure dbo.sp_SaveDependents
GO
/****** Object: Stored Procedure dbo.sp_AddBenefitInsert Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_AddBenefitInsert') and sysstat & 0xf = 4)
drop procedure dbo.sp_AddBenefitInsert
GO
/****** Object: Stored Procedure dbo.sp_AddBenefitSelect1 Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_AddBenefitSelect1') and sysstat & 0xf = 4)
drop procedure dbo.sp_AddBenefitSelect1
GO
/****** Object: Stored Procedure dbo.sp_AddBenefitSelect2 Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_AddBenefitSelect2') and sysstat & 0xf = 4)
drop procedure dbo.sp_AddBenefitSelect2
GO
/****** Object: Stored Procedure dbo.sp_AddQualifier Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_AddQualifier') and sysstat & 0xf = 4)
drop procedure dbo.sp_AddQualifier
GO
/****** Object: Stored Procedure dbo.sp_BenefitsForID Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_BenefitsForID') and sysstat & 0xf = 4)
drop procedure dbo.sp_BenefitsForID
GO
/****** Object: Stored Procedure dbo.sp_ChangeQualifierList1 Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_ChangeQualifierList1') and sysstat & 0xf = 4)
drop procedure dbo.sp_ChangeQualifierList1
GO
/****** Object: Stored Procedure dbo.sp_CheckQualifier Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_CheckQualifier') and sysstat & 0xf = 4)
drop procedure dbo.sp_CheckQualifier
GO
/****** Object: Stored Procedure dbo.sp_CurrentPlan Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_CurrentPlan') and sysstat & 0xf = 4)
drop procedure dbo.sp_CurrentPlan
GO
/****** Object: Stored Procedure dbo.sp_GetTotalCost Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_GetTotalCost') and sysstat & 0xf = 4)
drop procedure dbo.sp_GetTotalCost
GO
/****** Object: Stored Procedure dbo.sp_GetTotalCredits Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_GetTotalCredits') and sysstat & 0xf = 4)
drop procedure dbo.sp_GetTotalCredits
GO
/****** Object: Stored Procedure dbo.sp_PlanField Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_PlanField') and sysstat & 0xf = 4)
drop procedure dbo.sp_PlanField
GO
/****** Object: Stored Procedure dbo.sp_PlanInfo Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_PlanInfo') and sysstat & 0xf = 4)
drop procedure dbo.sp_PlanInfo
GO
/****** Object: Stored Procedure dbo.sp_PlanList Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_PlanList') and sysstat & 0xf = 4)
drop procedure dbo.sp_PlanList
GO
/****** Object: Stored Procedure dbo.sp_SummaryForID Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_SummaryForID') and sysstat & 0xf = 4)
drop procedure dbo.sp_SummaryForID
GO
/****** Object: Stored Procedure dbo.sp_TaxStatusList Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_TaxStatusList') and sysstat & 0xf = 4)
drop procedure dbo.sp_TaxStatusList
GO
/****** Object: Stored Procedure dbo.sp_Update Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_Update') and sysstat & 0xf = 4)
drop procedure dbo.sp_Update
GO
/****** Object: Stored Procedure dbo.sp_ChangeQualifierList2 Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_ChangeQualifierList2') and sysstat & 0xf = 4)
drop procedure dbo.sp_ChangeQualifierList2
GO
/****** Object: Stored Procedure dbo.sp_GetTotalPaycheck Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_GetTotalPaycheck') and sysstat & 0xf = 4)
drop procedure dbo.sp_GetTotalPaycheck
GO
/****** Object: Stored Procedure dbo.sp_DependentTypeList Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_DependentTypeList') and sysstat & 0xf = 4)
drop procedure dbo.sp_DependentTypeList
GO
/****** Object: Stored Procedure dbo.sp_GenderList Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_GenderList') and sysstat & 0xf = 4)
drop procedure dbo.sp_GenderList
GO
/****** Object: Stored Procedure dbo.sp_PhysicianList Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.sp_PhysicianList') and sysstat & 0xf = 4)
drop procedure dbo.sp_PhysicianList
GO
/****** Object: Table dbo.EmployeeBenefitDependent Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.EmployeeBenefitDependent') and sysstat & 0xf = 3)
drop table dbo.EmployeeBenefitDependent
GO
/****** Object: Table dbo.BenefitPlan Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.BenefitPlan') and sysstat & 0xf = 3)
drop table dbo.BenefitPlan
GO
/****** Object: Table dbo.BenefitQualifier Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.BenefitQualifier') and sysstat & 0xf = 3)
drop table dbo.BenefitQualifier
GO
/****** Object: Table dbo.BenefitTaxStatus Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.BenefitTaxStatus') and sysstat & 0xf = 3)
drop table dbo.BenefitTaxStatus
GO
/****** Object: Table dbo.EmployeeBenefit Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.EmployeeBenefit') and sysstat & 0xf = 3)
drop table dbo.EmployeeBenefit
GO
/****** Object: Table dbo.EmployeeDependent Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.EmployeeDependent') and sysstat & 0xf = 3)
drop table dbo.EmployeeDependent
GO
/****** Object: Table dbo.EmployeeQualifier Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.EmployeeQualifier') and sysstat & 0xf = 3)
drop table dbo.EmployeeQualifier
GO
/****** Object: Table dbo.PlanField Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.PlanField') and sysstat & 0xf = 3)
drop table dbo.PlanField
GO
/****** Object: Table dbo.PlanGeoArea Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.PlanGeoArea') and sysstat & 0xf = 3)
drop table dbo.PlanGeoArea
GO
/****** Object: Table dbo.Benefit Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.Benefit') and sysstat & 0xf = 3)
drop table dbo.Benefit
GO
/****** Object: Table dbo.Dependent Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.Dependent') and sysstat & 0xf = 3)
drop table dbo.Dependent
GO
/****** Object: Table dbo.Employee Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.Employee') and sysstat & 0xf = 3)
drop table dbo.Employee
GO
/****** Object: Table dbo.Plans Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.Plans') and sysstat & 0xf = 3)
drop table dbo.Plans
GO
/****** Object: Table dbo.Qualifier Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.Qualifier') and sysstat & 0xf = 3)
drop table dbo.Qualifier
GO
/****** Object: Table dbo.BenefitStatus Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.BenefitStatus') and sysstat & 0xf = 3)
drop table dbo.BenefitStatus
GO
/****** Object: Table dbo.DependentType Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.DependentType') and sysstat & 0xf = 3)
drop table dbo.DependentType
GO
/****** Object: Table dbo.EBDStatus Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.EBDStatus') and sysstat & 0xf = 3)
drop table dbo.EBDStatus
GO
/****** Object: Table dbo.EDStatus Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.EDStatus') and sysstat & 0xf = 3)
drop table dbo.EDStatus
GO
/****** Object: Table dbo.EmployeeStatus Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.EmployeeStatus') and sysstat & 0xf = 3)
drop table dbo.EmployeeStatus
GO
/****** Object: Table dbo.Field Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.Field') and sysstat & 0xf = 3)
drop table dbo.Field
GO
/****** Object: Table dbo.Gender Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.Gender') and sysstat & 0xf = 3)
drop table dbo.Gender
GO
/****** Object: Table dbo.GeoArea Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.GeoArea') and sysstat & 0xf = 3)
drop table dbo.GeoArea
GO
/****** Object: Table dbo.Physician Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.Physician') and sysstat & 0xf = 3)
drop table dbo.Physician
GO
/****** Object: Table dbo.PlanStatus Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.PlanStatus') and sysstat & 0xf = 3)
drop table dbo.PlanStatus
GO
/****** Object: Table dbo.QualifierClass Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.QualifierClass') and sysstat & 0xf = 3)
drop table dbo.QualifierClass
GO
/****** Object: Table dbo.QualifierStatus Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.QualifierStatus') and sysstat & 0xf = 3)
drop table dbo.QualifierStatus
GO
/****** Object: Table dbo.TaxStatus Script Date: 10/18/97 12:03:55 PM ******/
if exists (select * from sysobjects where id = object_id('dbo.TaxStatus') and sysstat & 0xf = 3)
drop table dbo.TaxStatus
GO
/****** Object: Table dbo.BenefitStatus Script Date: 10/18/97 12:03:55 PM ******/
CREATE TABLE dbo.BenefitStatus (
BenefitStatusId tinyint IDENTITY (1, 1) NOT NULL ,
BenefitStatusName varchar (100) NULL ,
BenefitStatusLabel varchar (100) NULL ,
CONSTRAINT PK_BenefitStatus PRIMARY KEY NONCLUSTERED
(
BenefitStatusId
)
)
GO
/****** Object: Table dbo.DependentType Script Date: 10/18/97 12:03:56 PM ******/
CREATE TABLE dbo.DependentType (
DependentTypeId int IDENTITY (1, 1) NOT NULL ,
DependentTypeName varchar (100) NULL ,
DependentTypeLabel varchar (100) NULL ,
DependentTypeRank int NULL ,
CONSTRAINT PK_DependentType PRIMARY KEY NONCLUSTERED
(
DependentTypeId
)
)
GO
/****** Object: Table dbo.EBDStatus Script Date: 10/18/97 12:03:56 PM ******/
CREATE TABLE dbo.EBDStatus (
EBDStatusId tinyint IDENTITY (1, 1) NOT NULL ,
EBDStatusName varchar (100) NULL ,
EBDStatusLabel varchar (100) NULL ,
CONSTRAINT PK_EBDStatus PRIMARY KEY NONCLUSTERED
(
EBDStatusId
)
)
GO
/****** Object: Table dbo.EDStatus Script Date: 10/18/97 12:03:56 PM ******/
CREATE TABLE dbo.EDStatus (
DependentStatusId tinyint IDENTITY (1, 1) NOT NULL ,
DependentStatusName varchar (100) NULL ,
DependentStatusLabel varchar (100) NULL ,
CONSTRAINT PK_EDStatus PRIMARY KEY NONCLUSTERED
(
DependentStatusId
)
)
GO
/****** Object: Table dbo.EmployeeStatus Script Date: 10/18/97 12:03:56 PM ******/
CREATE TABLE dbo.EmployeeStatus (
EmployeeStatusId tinyint IDENTITY (1, 1) NOT NULL ,
EmployeeStatusName varchar (100) NULL ,
EmployeeStatusLabel varchar (100) NULL ,
CONSTRAINT PK_EmployeeStatus PRIMARY KEY NONCLUSTERED
(
EmployeeStatusId
)
)
GO
/****** Object: Table dbo.Field Script Date: 10/18/97 12:03:56 PM ******/
CREATE TABLE dbo.Field (
FieldId int IDENTITY (1, 1) NOT NULL ,
FieldName varchar (100) NULL ,
FieldLabel varchar (100) NULL ,
CONSTRAINT PK_Field PRIMARY KEY NONCLUSTERED
(
FieldId
)
)
GO
/****** Object: Table dbo.Gender Script Date: 10/18/97 12:03:56 PM ******/
CREATE TABLE dbo.Gender (
GenderId int IDENTITY (1, 1) NOT NULL ,
GenderName varchar (100) NULL ,
GenderLabel varchar (100) NULL ,
GenderRank int NULL ,
CONSTRAINT PK_Gender PRIMARY KEY NONCLUSTERED
(
GenderId
)
)
GO
/****** Object: Table dbo.GeoArea Script Date: 10/18/97 12:03:56 PM ******/
CREATE TABLE dbo.GeoArea (
GeoAreaId int IDENTITY (1, 1) NOT NULL ,
GeoAreaName varchar (100) NULL ,
GeoAreaLabel varchar (100) NULL ,
CONSTRAINT PK_GeoArea PRIMARY KEY NONCLUSTERED
(
GeoAreaId
)
)
GO
/****** Object: Table dbo.Physician Script Date: 10/18/97 12:03:56 PM ******/
CREATE TABLE dbo.Physician (
PhysicianId int IDENTITY (1, 1) NOT NULL ,
PhysicianName varchar (100) NULL ,
PhysicianLabel varchar (100) NULL ,
CONSTRAINT PK_Physician PRIMARY KEY NONCLUSTERED
(
PhysicianId
)
)
GO
/****** Object: Table dbo.PlanStatus Script Date: 10/18/97 12:03:57 PM ******/
CREATE TABLE dbo.PlanStatus (
PlanStatusId tinyint IDENTITY (1, 1) NOT NULL ,
PlanStatusName varchar (100) NULL ,
PlanStatusLabel varchar (100) NULL ,
CONSTRAINT PK_PlanStatus PRIMARY KEY NONCLUSTERED
(
PlanStatusId
)
)
GO
/****** Object: Table dbo.QualifierClass Script Date: 10/18/97 12:03:57 PM ******/
CREATE TABLE dbo.QualifierClass (
QualifierClassId int IDENTITY (1, 1) NOT NULL ,
QualifierClassName varchar (100) NULL ,
QualifierClassLabel varchar (100) NULL ,
CONSTRAINT PK_QualifierClass PRIMARY KEY NONCLUSTERED
(
QualifierClassId
)
)
GO
/****** Object: Table dbo.QualifierStatus Script Date: 10/18/97 12:03:57 PM ******/
CREATE TABLE dbo.QualifierStatus (
QualifierStatusId int IDENTITY (1, 1) NOT NULL ,
QualifierStatusName varchar (100) NULL ,
QualifierStatusLabel varchar (100) NULL ,
CONSTRAINT PK_QualifierStatus PRIMARY KEY NONCLUSTERED
(
QualifierStatusId
)
)
GO
/****** Object: Table dbo.TaxStatus Script Date: 10/18/97 12:03:57 PM ******/
CREATE TABLE dbo.TaxStatus (
TaxStatusId int IDENTITY (1, 1) NOT NULL ,
TaxStatusName varchar (100) NULL ,
TaxStatusLabel varchar (100) NULL ,
CONSTRAINT PK_TaxStatus PRIMARY KEY NONCLUSTERED
(
TaxStatusId
)
)
GO
/****** Object: Table dbo.Benefit Script Date: 10/18/97 12:03:57 PM ******/
CREATE TABLE dbo.Benefit (
BenefitId int IDENTITY (1, 1) NOT NULL ,
BenefitYear int NOT NULL ,
BenefitName varchar (100) NULL ,
BenefitLabel varchar (100) NULL ,
BenefitDesc varchar (255) NULL ,
BenefitText text NULL ,
BenefitRank int NULL ,
DetailTemplate varchar (100) NULL ,
MinimumPlanRanking int NULL ,
QualifierRequired tinyint NULL ,
DependentCovered tinyint NULL ,
SignatureRequired tinyint NULL ,
BenefitStatusId tinyint NULL CONSTRAINT DF_Benefit_BenefitStatus DEFAULT (1),
CONSTRAINT PK_Benefit PRIMARY KEY NONCLUSTERED
(
BenefitId
),
CONSTRAINT FK_Benefit_BenefitStatus FOREIGN KEY
(
BenefitStatusId
) REFERENCES dbo.BenefitStatus (
BenefitStatusId
)
)
GO
/****** Object: Table dbo.Dependent Script Date: 10/18/97 12:03:57 PM ******/
CREATE TABLE dbo.Dependent (
DependentId int IDENTITY (1, 1) NOT NULL ,
LastName varchar (100) NULL ,
FirstName varchar (100) NULL ,
MiddleName varchar (100) NULL ,
DependentBirthdate datetime NULL ,
DependentGenderId int NULL CONSTRAINT DF_Dependent_DependentGenderId DEFAULT (1),
DependentSSN varchar (11) NULL ,
CONSTRAINT PK_Dependent PRIMARY KEY NONCLUSTERED
(
DependentId
),
CONSTRAINT FK_Dependent_Gender FOREIGN KEY
(
DependentGenderId
) REFERENCES dbo.Gender (
GenderId
)
)
GO
/****** Object: Table dbo.Employee Script Date: 10/18/97 12:03:57 PM ******/
CREATE TABLE dbo.Employee (
EmployeeId int IDENTITY (1, 1) NOT NULL ,
KnownAs varchar (100) NULL ,
NTUserName varchar (100) NOT NULL ,
Address1 varchar (100) NULL ,
Address2 varchar (100) NULL ,
City varchar (100) NULL ,
State varchar (100) NULL ,
PostCode varchar (100) NULL ,
Country varchar (100) NULL ,
HomePhone varchar (100) NULL ,
BusinessPhone varchar (100) NULL ,
Fax varchar (100) NULL ,
Email varchar (100) NULL ,
PeriodEarnings money NULL CONSTRAINT DF_Employee_PeriodEarnings DEFAULT (2000.00),
Exemptions int NULL CONSTRAINT DF_Employee_Exemptions DEFAULT (1),
EmployeeGeoAreaId int NULL ,
EmployeeStatusId tinyint NULL CONSTRAINT DF_Employee_EmployeeStatus DEFAULT (1),
CONSTRAINT PK_Employee PRIMARY KEY NONCLUSTERED
(
EmployeeId
),
CONSTRAINT IX_Employee UNIQUE NONCLUSTERED
(
NTUserName
),
CONSTRAINT FK_Employee_EmployeeStatus FOREIGN KEY
(
EmployeeStatusId
) REFERENCES dbo.EmployeeStatus (
EmployeeStatusId
),
CONSTRAINT FK_Employee_GeoArea FOREIGN KEY
(
EmployeeGeoAreaId
) REFERENCES dbo.GeoArea (
GeoAreaId
)
)
GO
/****** Object: Table dbo.Plans Script Date: 10/18/97 12:03:57 PM ******/
CREATE TABLE dbo.Plans (
PlanId int IDENTITY (1, 1) NOT NULL ,
PlanName varchar (100) NULL ,
PlanLabel varchar (100) NULL ,
PlanDesc varchar (255) NULL ,
PlanText text NULL ,
PlanCost money NULL ,
PhysicianRequired tinyint NULL ,
PlanStatusId tinyint NULL CONSTRAINT DF_Plans_PlanStatus DEFAULT (1),
CONSTRAINT PK_Plans PRIMARY KEY NONCLUSTERED
(
PlanId
),
CONSTRAINT FK_Plans_PlanStatus FOREIGN KEY
(
PlanStatusId
) REFERENCES dbo.PlanStatus (
PlanStatusId
)
)
GO
/****** Object: Table dbo.Qualifier Script Date: 10/18/97 12:03:58 PM ******/
CREATE TABLE dbo.Qualifier (
QualifierId int IDENTITY (1, 1) NOT NULL ,
QualifierName varchar (100) NULL ,
QualifierLabel varchar (100) NULL ,
QualifierClassId int NULL ,
QualifierRank int NULL ,
QualifierStatusId int NULL ,
CONSTRAINT PK_Qualifier PRIMARY KEY NONCLUSTERED
(
QualifierId
),
CONSTRAINT FK_Qualifier_QualifierClass FOREIGN KEY
(
QualifierClassId
) REFERENCES dbo.QualifierClass (
QualifierClassId
),
CONSTRAINT FK_Qualifier_QualifierStatus FOREIGN KEY
(
QualifierStatusId
) REFERENCES dbo.QualifierStatus (
QualifierStatusId
)
)
GO
/****** Object: Table dbo.BenefitPlan Script Date: 10/18/97 12:03:58 PM ******/
CREATE TABLE dbo.BenefitPlan (
BenefitId int NOT NULL ,
PlanId int NOT NULL ,
PlanRank int NULL ,
CONSTRAINT PK_BenefitPlan PRIMARY KEY NONCLUSTERED
(
BenefitId,
PlanId
),
CONSTRAINT FK_BenefitPlan_Benefit FOREIGN KEY
(
BenefitId
) REFERENCES dbo.Benefit (
BenefitId
),
CONSTRAINT FK_BenefitPlan_Plans FOREIGN KEY
(
PlanId
) REFERENCES dbo.Plans (
PlanId
)
)
GO
/****** Object: Table dbo.BenefitQualifier Script Date: 10/18/97 12:03:58 PM ******/
CREATE TABLE dbo.BenefitQualifier (
BenefitId int NOT NULL ,
QualifierId int NOT NULL ,
ChangeDays int NULL ,
CONSTRAINT PK_BenefitQualifier PRIMARY KEY NONCLUSTERED
(
BenefitId,
QualifierId
),
CONSTRAINT FK_BenefitQualifier_Benefit FOREIGN KEY
(
BenefitId
) REFERENCES dbo.Benefit (
BenefitId
),
CONSTRAINT FK_BenefitQualifier_Qualifier FOREIGN KEY
(
QualifierId
) REFERENCES dbo.Qualifier (
QualifierId
)
)
GO
/****** Object: Table dbo.BenefitTaxStatus Script Date: 10/18/97 12:03:58 PM ******/
CREATE TABLE dbo.BenefitTaxStatus (
BenefitId int NOT NULL ,
TaxStatusId int NOT NULL ,
TaxDefault tinyint NULL ,
CONSTRAINT PK_BenefitTaxStatus PRIMARY KEY NONCLUSTERED
(
BenefitId,
TaxStatusId
),
CONSTRAINT FK_BenefitTaxStatus_Benefit FOREIGN KEY
(
BenefitId
) REFERENCES dbo.Benefit (
BenefitId
),
CONSTRAINT FK_BenefitTaxStatus_TaxStatus FOREIGN KEY
(
TaxStatusId
) REFERENCES dbo.TaxStatus (
TaxStatusId
)
)
GO
/****** Object: Table dbo.EmployeeBenefit Script Date: 10/18/97 12:03:58 PM ******/
CREATE TABLE dbo.EmployeeBenefit (
EmployeeId int NOT NULL ,
BenefitId int NOT NULL ,
PlanId int NULL ,
CreditAmount money NULL ,
TaxStatusId int NULL ,
EligibilityDate datetime NULL ,
CONSTRAINT PK_EmployeeBenefit PRIMARY KEY NONCLUSTERED
(
EmployeeId,
BenefitId
),
CONSTRAINT FK_EmployeeBenefit_Benefit FOREIGN KEY
(
BenefitId
) REFERENCES dbo.Benefit (
BenefitId
),
CONSTRAINT FK_EmployeeBenefit_Employee FOREIGN KEY
(
EmployeeId
) REFERENCES dbo.Employee (
EmployeeId
),
CONSTRAINT FK_EmployeeBenefit_Plans1 FOREIGN KEY
(
PlanId
) REFERENCES dbo.Plans (
PlanId
),
CONSTRAINT FK_EmployeeBenefit_TaxStatus FOREIGN KEY
(
TaxStatusId
) REFERENCES dbo.TaxStatus (
TaxStatusId
)
)
GO
/****** Object: Table dbo.EmployeeDependent Script Date: 10/18/97 12:03:58 PM ******/
CREATE TABLE dbo.EmployeeDependent (
EmployeeId int NOT NULL ,
DependentId int NOT NULL ,
DependentTypeId int NULL ,
DependentStatusId tinyint NULL CONSTRAINT DF_EmployeeDep_DependentSt DEFAULT (1),
CONSTRAINT PK_EmployeeDependent PRIMARY KEY NONCLUSTERED
(
EmployeeId,
DependentId
),
CONSTRAINT FK_EmployeeDep_DependentTy FOREIGN KEY
(
DependentTypeId
) REFERENCES dbo.DependentType (
DependentTypeId
),
CONSTRAINT FK_EmployeeDependent_Dependent FOREIGN KEY
(
DependentId
) REFERENCES dbo.Dependent (
DependentId
),
CONSTRAINT FK_EmployeeDependent_EDStatus FOREIGN KEY
(
DependentStatusId
) REFERENCES dbo.EDStatus (
DependentStatusId
),
CONSTRAINT FK_EmployeeDependent_Employee FOREIGN KEY
(
EmployeeId
) REFERENCES dbo.Employee (
EmployeeId
)
)
GO
/****** Object: Table dbo.EmployeeQualifier Script Date: 10/18/97 12:03:58 PM ******/
CREATE TABLE dbo.EmployeeQualifier (
EmployeeQualifierId int IDENTITY (1, 1) NOT NULL ,
EmployeeId int NOT NULL ,
QualifierId int NOT NULL ,
QualifierDate datetime NOT NULL ,
CONSTRAINT PK_EmployeeQualifier PRIMARY KEY NONCLUSTERED
(
EmployeeQualifierId
),
CONSTRAINT FK_EmployeeQualifier_Employee FOREIGN KEY
(
EmployeeId
) REFERENCES dbo.Employee (
EmployeeId
),
CONSTRAINT FK_EmployeeQualifier_Qualifier FOREIGN KEY
(
QualifierId
) REFERENCES dbo.Qualifier (
QualifierId
)
)
GO
CREATE CLUSTERED INDEX IX_EmployeeQualifier ON dbo.EmployeeQualifier(EmployeeId) WITH ALLOW_DUP_ROW
GO
/****** Object: Table dbo.PlanField Script Date: 10/18/97 12:03:59 PM ******/
CREATE TABLE dbo.PlanField (
PlanId int NOT NULL ,
FieldId int NOT NULL ,
FieldValue varchar (255) NULL ,
FieldRank int NULL ,
CONSTRAINT PK_PlanField PRIMARY KEY NONCLUSTERED
(
PlanId,
FieldId
),
CONSTRAINT FK_PlanField_Field FOREIGN KEY
(
FieldId
) REFERENCES dbo.Field (
FieldId
),
CONSTRAINT FK_PlanField_Plans FOREIGN KEY
(
PlanId
) REFERENCES dbo.Plans (
PlanId
)
)
GO
/****** Object: Table dbo.PlanGeoArea Script Date: 10/18/97 12:03:59 PM ******/
CREATE TABLE dbo.PlanGeoArea (
PlanId int NOT NULL ,
GeoAreaId int NOT NULL ,
CONSTRAINT PK_PlanGeoArea PRIMARY KEY NONCLUSTERED
(
PlanId,
GeoAreaId
),
CONSTRAINT FK_PlanGeoArea_GeoArea FOREIGN KEY
(
GeoAreaId
) REFERENCES dbo.GeoArea (
GeoAreaId
),
CONSTRAINT FK_PlanGeoArea_Plans FOREIGN KEY
(
PlanId
) REFERENCES dbo.Plans (
PlanId
)
)
GO
/****** Object: Table dbo.EmployeeBenefitDependent Script Date: 10/18/97 12:03:59 PM ******/
CREATE TABLE dbo.EmployeeBenefitDependent (
EmployeeId int NOT NULL ,
BenefitId int NOT NULL ,
DependentId int NOT NULL ,
PhysicianId int NULL ,
EBDStatusId tinyint NULL CONSTRAINT DF_EmployeeBen_EBDStatus DEFAULT (1),
CONSTRAINT PK_EmployeeBenefitDependent PRIMARY KEY NONCLUSTERED
(
EmployeeId,
BenefitId,
DependentId
),
CONSTRAINT FK_EmployeeBen_Dependent FOREIGN KEY
(
DependentId
) REFERENCES dbo.Dependent (
DependentId
),
CONSTRAINT FK_EmployeeBen_EBDStatus FOREIGN KEY
(
EBDStatusId
) REFERENCES dbo.EBDStatus (
EBDStatusId
),
CONSTRAINT FK_EmployeeBen_EmployeeBen1 FOREIGN KEY
(
EmployeeId,
BenefitId
) REFERENCES dbo.EmployeeBenefit (
EmployeeId,
BenefitId
),
CONSTRAINT FK_EmployeeBen_Physician FOREIGN KEY
(
PhysicianId
) REFERENCES dbo.Physician (
PhysicianId
)
)
GO
/****** Object: Stored Procedure dbo.sp_DependentTypeList Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_DependentTypeList Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_DependentTypeList AS
SELECT dt.DependentTypeId, dt.DependentTypeLabel, dt.DependentTypeRank
FROM DependentType dt
ORDER BY dt.DependentTypeRank
GO
/****** Object: Stored Procedure dbo.sp_GenderList Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_GenderList Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_GenderList AS
SELECT g.GenderId, g.GenderLabel, g.GenderRank
FROM Gender g
ORDER BY g.GenderRank
GO
/****** Object: Stored Procedure dbo.sp_PhysicianList Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_PhysicianList Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_PhysicianList AS
SELECT ph.PhysicianId, ph.PhysicianLabel
FROM Physician ph
GO
/****** Object: Stored Procedure dbo.sp_ChangeQualifierList2 Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_ChangeQualifierList2 Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_ChangeQualifierList2 (@lngQualifierClassId int) AS
SELECT q.QualifierId, q.QualifierLabel, q.QualifierRank
FROM Qualifier q
WHERE q.QualifierStatusId = 1
AND q.QualifierClassId = @lngQualifierClassId
ORDER BY q.QualifierRank
GO
/****** Object: Stored Procedure dbo.sp_GetTotalPaycheck Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_GetTotalPaycheck Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_GetTotalPaycheck (@lngEmployeeId int) AS
SELECT e.PeriodEarnings, e.Exemptions
FROM Employee e
WHERE e.EmployeeId = @lngEmployeeId
GO
/****** Object: Stored Procedure dbo.sp_AddBenefitInsert Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_AddBenefitInsert Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_AddBenefitInsert (@lngEmployeeId int, @lngBenefitId int, @PlanId int,
@PlanCost int, @TaxStatusId int) AS
INSERT INTO EmployeeBenefit
(EmployeeId, BenefitId, PlanId, CreditAmount, TaxStatusId)
VALUES (@lngEmployeeId, @lngBenefitId, @PlanId, @PlanCost, @TaxStatusId)
GO
/****** Object: Stored Procedure dbo.sp_AddBenefitSelect1 Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_AddBenefitSelect1 Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_AddBenefitSelect1 (@lngBenefitId int) AS
SELECT bp.PlanId, p.PlanCost, bts.TaxStatusId
FROM Benefit b, BenefitPlan bp, BenefitTaxStatus bts, Plans p
WHERE b.BenefitId = @lngBenefitId
AND bp.BenefitId = b.BenefitId
AND bp.PlanRank = b.MinimumPlanRanking
AND p.PlanId = bp.PlanId
AND bts.BenefitId = b.BenefitId
AND bts.TaxDefault = 1
GO
/****** Object: Stored Procedure dbo.sp_AddBenefitSelect2 Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_AddBenefitSelect2 Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_AddBenefitSelect2 (@lngEmployeeId int) AS
SELECT ed.DependentId, ed.DependentTypeId
FROM EmployeeDependent ed
WHERE ed.EmployeeId = @lngEmployeeId
GO
/****** Object: Stored Procedure dbo.sp_AddQualifier Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_AddQualifier Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_AddQualifier (@lngEmployeeId int, @lngQualifierId int, @datQualifierDate datetime) AS
INSERT INTO EmployeeQualifier
(EmployeeId, QualifierId, QualifierDate)
VALUES (@lngEmployeeId, @lngQualifierId, @datQualifierDate)
GO
/****** Object: Stored Procedure dbo.sp_BenefitsForID Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_BenefitsForID Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_BenefitsForID (@lngEmployeeId int, @intBenefitYear int) AS
SELECT b.BenefitId
FROM Benefit b
JOIN EmployeeBenefit eb ON eb.BenefitId = b.BenefitId
AND eb.EmployeeId = @lngEmployeeId
WHERE b.BenefitYear = @intBenefitYear
GO
/****** Object: Stored Procedure dbo.sp_ChangeQualifierList1 Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_ChangeQualifierList1 Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_ChangeQualifierList1 (@lngQualifierClassId int, @lngBenefitId int) AS
SELECT bq.QualifierId, q.QualifierLabel, q.QualifierRank, bq.ChangeDays
FROM BenefitQualifier bq
JOIN Qualifier q ON q.QualifierId = bq.QualifierId
AND q.QualifierClassId = @lngQualifierClassId
WHERE q.QualifierStatusId = 1
AND bq.BenefitId = @lngBenefitId
ORDER BY q.QualifierRank
GO
/****** Object: Stored Procedure dbo.sp_CheckQualifier Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_CheckQualifier Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_CheckQualifier (@lngEmployeeId int, @lngBenefitId int) AS
SELECT eq.QualifierId
FROM EmployeeQualifier eq
JOIN BenefitQualifier bq ON bq.QualifierId = eq.QualifierId
AND bq.BenefitId = @lngBenefitId
WHERE eq.EmployeeId = @lngEmployeeId
AND GETDATE() <= DATEADD(day, bq.ChangeDays, eq.QualifierDate)
GO
/****** Object: Stored Procedure dbo.sp_CurrentPlan Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_CurrentPlan Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_CurrentPlan (@lngEmployeeId int, @lngBenefitId int) AS
SELECT b.BenefitLabel, p.PlanId, b.DependentCovered, eb.TaxStatusId, ts.TaxStatusLabel
FROM EmployeeBenefit eb
JOIN Benefit b ON b.BenefitId = eb.BenefitId
JOIN Plans p ON p.PlanId = eb.PlanId
JOIN TaxStatus ts ON ts.TaxStatusId = eb.TaxStatusId
WHERE eb.EmployeeId = @lngEmployeeId
AND eb.BenefitId = @lngBenefitId
GO
/****** Object: Stored Procedure dbo.sp_GetTotalCost Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_GetTotalCost Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_GetTotalCost (@lngEmployeeId int, @intBenefitYear int, @lngTaxStatusId int)AS
SELECT Sum(p.PlanCost) as TotalCost
FROM EmployeeBenefit eb, Benefit b,
Plans p
WHERE eb.BenefitId = b.BenefitId
AND eb.PlanId = p.PlanId
AND eb.EmployeeId = @lngEmployeeId
AND b.BenefitYear = @intBenefitYear
AND eb.TaxStatusId = @lngTaxStatusId
GO
/****** Object: Stored Procedure dbo.sp_GetTotalCredits Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_GetTotalCredits Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_GetTotalCredits (@lngEmployeeId int, @intBenefitYear int) AS
SELECT Sum(eb.CreditAmount) as TotalCredits
FROM EmployeeBenefit eb, Benefit b
WHERE eb.EmployeeId = @lngEmployeeId
AND b.BenefitYear = @intBenefitYear
AND b.BenefitId = eb.BenefitId
GO
/****** Object: Stored Procedure dbo.sp_PlanField Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_PlanField Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_PlanField (@lngPlanId int) AS
SELECT f.FieldLabel, pf.FieldValue
FROM Plans p, PlanField pf,
Field f
WHERE pf.PlanId = p.PlanId
AND pf.FieldId = f.FieldId
AND p.PlanId = @lngPlanId
ORDER BY pf.FieldRank
GO
/****** Object: Stored Procedure dbo.sp_PlanInfo Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_PlanInfo Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_PlanInfo (@lngBenefitId int, @lngPlanId int) AS
SELECT p.PlanLabel, p.PlanDesc, p.PlanCost,
p.PhysicianRequired, bp.PlanRank
FROM Plans p
JOIN BenefitPlan bp ON bp.BenefitId = @lngBenefitId
AND bp.PlanId = p.PlanId
WHERE p.PlanId = @lngPlanId
GO
/****** Object: Stored Procedure dbo.sp_PlanList Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_PlanList Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_PlanList (@lngBenefitId int) AS
SELECT p.PlanId, p.PlanLabel, bp.PlanRank
FROM Benefit b, BenefitPlan bp, Plans p
WHERE p.PlanId = bp.PlanId
AND bp.BenefitId = b.BenefitId
AND b.BenefitId = @lngBenefitId
ORDER BY bp.PlanRank
GO
/****** Object: Stored Procedure dbo.sp_SummaryForID Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_SummaryForID Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_SummaryForID (@lngEmployeeId int, @intBenefitYear int) AS
SELECT b.BenefitId, b.BenefitLabel, b.DetailTemplate,
p.PlanLabel, p.PlanCost, ts.TaxStatusLabel
FROM Benefit b
LEFT OUTER JOIN EmployeeBenefit eb ON eb.BenefitId = b.BenefitId
AND eb.EmployeeId = @lngEmployeeId
LEFT OUTER JOIN Plans p ON p.PlanId = eb.PlanId
LEFT OUTER JOIN TaxStatus ts ON ts.TaxStatusId = eb.TaxStatusId
WHERE b.BenefitYear = @intBenefitYear
ORDER BY b.BenefitRank
GO
/****** Object: Stored Procedure dbo.sp_TaxStatusList Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_TaxStatusList Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_TaxStatusList (@lngBenefitId int) AS
SELECT ts.TaxStatusId, ts.TaxStatusLabel, bts.TaxDefault
FROM BenefitTaxStatus bts, TaxStatus ts
WHERE ts.TaxStatusId = bts.TaxStatusId
AND bts.BenefitId = @lngBenefitId
ORDER BY ts.TaxStatusLabel
GO
/****** Object: Stored Procedure dbo.sp_Update Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_Update Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_Update (@lngPlanId int, @lngTaxStatusId int, @lngEmployeeId int, @lngBenefitId int) AS
UPDATE EmployeeBenefit
SET PlanId = @lngPlanId, TaxStatusId = @lngTaxStatusId
WHERE EmployeeId = @lngEmployeeId
AND BenefitId = @lngBenefitId
GO
/****** Object: Stored Procedure dbo.sp_AddEBD Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_AddEBD Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_AddEBD (@lngEmployeeId int, @lngBenefitId int, @lngDependentId int, @intEBDStatusId int) AS
INSERT INTO EmployeeBenefitDependent
(EmployeeId, BenefitId, DependentId, EBDStatusId)
VALUES (@lngEmployeeId, @lngBenefitId, @lngDependentId, @intEBDStatusId)
GO
/****** Object: Stored Procedure dbo.sp_InactivateDependents Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_InactivateDependents Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_InactivateDependents (@lngEmployeeId int, @lngBenefitId int) AS
UPDATE EmployeeBenefitDependent
SET EBDStatusId = 2
WHERE EmployeeId = @lngEmployeeId
AND BenefitId = @lngBenefitId
GO
/****** Object: Stored Procedure dbo.sp_ListCoveredPersons Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_ListCoveredPersons Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_ListCoveredPersons (@lngEmployeeId int, @lngBenefitId int) AS
SELECT dt.DependentTypeLabel, d.FirstName, d.LastName, ph.PhysicianLabel
FROM EmployeeBenefitDependent ebd,
EmployeeDependent ed, Physician ph,
DependentType dt, Dependent d
WHERE dt.DependentTypeId = ed.DependentTypeId
AND ed.DependentId = ebd.DependentId
AND ed.EmployeeId = ebd.EmployeeId
AND d.DependentId = ebd.DependentId
AND ebd.PhysicianId *= ph.PhysicianId
AND ebd.EmployeeId = @lngEmployeeId
AND ebd.BenefitId = @lngBenefitId
ORDER BY dt.DependentTypeRank
GO
/****** Object: Stored Procedure dbo.sp_ListDependents Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_ListDependents Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_ListDependents (@lngEmployeeId int, @lngBenefitId int) AS
SELECT ed.DependentId, ebd.EBDStatusId, dt.DependentTypeLabel, d.LastName,
d.FirstName , ebd.PhysicianId
FROM EmployeeDependent ed
JOIN DependentType dt
ON dt.DependentTypeId = ed.DependentTypeId
JOIN EmployeeBenefitDependent ebd
ON ebd.EmployeeId = ed.EmployeeId
AND ebd.DependentId = ed.DependentId
AND ebd.BenefitId = @lngBenefitId
JOIN Dependent d
ON d.DependentId = ed.DependentId
WHERE ed.EmployeeId = @lngEmployeeId
AND ed.DependentStatusId = 1
ORDER BY dt.DependentTypeRank
GO
/****** Object: Stored Procedure dbo.sp_SaveDependents Script Date: 10/18/97 12:03:59 PM ******/
/****** Object: Stored Procedure dbo.sp_SaveDependents Script Date: 9/28/97 12:08:30 PM ******/
CREATE PROCEDURE sp_SaveDependents (@lngPhysicianId int, @lngEmployeeId int, @lngBenefitId int, @lngDependentId int) AS
UPDATE EmployeeBenefitDependent
SET EBDStatusId = 1,
PhysicianId = @lngPhysicianId
WHERE EmployeeId = @lngEmployeeId
AND BenefitId = @lngBenefitId
AND DependentId = @lngDependentId
GO