home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / ExAirBenefits.sql < prev    next >
Text File  |  1997-11-01  |  40KB  |  1,180 lines

  1. /***** Make sure we are in Master database ******/
  2. use master
  3. GO
  4.  
  5. /***** Create the database ******/
  6. create database ExAirBenefits
  7.     on ExAirBenefitsDev = 4
  8. GO
  9.  
  10. use ExAirBenefits
  11. go
  12.  
  13. /****** Object:  Stored Procedure dbo.sp_AddEBD    Script Date: 10/18/97 12:03:55 PM ******/
  14. if exists (select * from sysobjects where id = object_id('dbo.sp_AddEBD') and sysstat & 0xf = 4)
  15.     drop procedure dbo.sp_AddEBD
  16. GO
  17.  
  18. /****** Object:  Stored Procedure dbo.sp_InactivateDependents    Script Date: 10/18/97 12:03:55 PM ******/
  19. if exists (select * from sysobjects where id = object_id('dbo.sp_InactivateDependents') and sysstat & 0xf = 4)
  20.     drop procedure dbo.sp_InactivateDependents
  21. GO
  22.  
  23. /****** Object:  Stored Procedure dbo.sp_ListCoveredPersons    Script Date: 10/18/97 12:03:55 PM ******/
  24. if exists (select * from sysobjects where id = object_id('dbo.sp_ListCoveredPersons') and sysstat & 0xf = 4)
  25.     drop procedure dbo.sp_ListCoveredPersons
  26. GO
  27.  
  28. /****** Object:  Stored Procedure dbo.sp_ListDependents    Script Date: 10/18/97 12:03:55 PM ******/
  29. if exists (select * from sysobjects where id = object_id('dbo.sp_ListDependents') and sysstat & 0xf = 4)
  30.     drop procedure dbo.sp_ListDependents
  31. GO
  32.  
  33. /****** Object:  Stored Procedure dbo.sp_SaveDependents    Script Date: 10/18/97 12:03:55 PM ******/
  34. if exists (select * from sysobjects where id = object_id('dbo.sp_SaveDependents') and sysstat & 0xf = 4)
  35.     drop procedure dbo.sp_SaveDependents
  36. GO
  37.  
  38. /****** Object:  Stored Procedure dbo.sp_AddBenefitInsert    Script Date: 10/18/97 12:03:55 PM ******/
  39. if exists (select * from sysobjects where id = object_id('dbo.sp_AddBenefitInsert') and sysstat & 0xf = 4)
  40.     drop procedure dbo.sp_AddBenefitInsert
  41. GO
  42.  
  43. /****** Object:  Stored Procedure dbo.sp_AddBenefitSelect1    Script Date: 10/18/97 12:03:55 PM ******/
  44. if exists (select * from sysobjects where id = object_id('dbo.sp_AddBenefitSelect1') and sysstat & 0xf = 4)
  45.     drop procedure dbo.sp_AddBenefitSelect1
  46. GO
  47.  
  48. /****** Object:  Stored Procedure dbo.sp_AddBenefitSelect2    Script Date: 10/18/97 12:03:55 PM ******/
  49. if exists (select * from sysobjects where id = object_id('dbo.sp_AddBenefitSelect2') and sysstat & 0xf = 4)
  50.     drop procedure dbo.sp_AddBenefitSelect2
  51. GO
  52.  
  53. /****** Object:  Stored Procedure dbo.sp_AddQualifier    Script Date: 10/18/97 12:03:55 PM ******/
  54. if exists (select * from sysobjects where id = object_id('dbo.sp_AddQualifier') and sysstat & 0xf = 4)
  55.     drop procedure dbo.sp_AddQualifier
  56. GO
  57.  
  58. /****** Object:  Stored Procedure dbo.sp_BenefitsForID    Script Date: 10/18/97 12:03:55 PM ******/
  59. if exists (select * from sysobjects where id = object_id('dbo.sp_BenefitsForID') and sysstat & 0xf = 4)
  60.     drop procedure dbo.sp_BenefitsForID
  61. GO
  62.  
  63. /****** Object:  Stored Procedure dbo.sp_ChangeQualifierList1    Script Date: 10/18/97 12:03:55 PM ******/
  64. if exists (select * from sysobjects where id = object_id('dbo.sp_ChangeQualifierList1') and sysstat & 0xf = 4)
  65.     drop procedure dbo.sp_ChangeQualifierList1
  66. GO
  67.  
  68. /****** Object:  Stored Procedure dbo.sp_CheckQualifier    Script Date: 10/18/97 12:03:55 PM ******/
  69. if exists (select * from sysobjects where id = object_id('dbo.sp_CheckQualifier') and sysstat & 0xf = 4)
  70.     drop procedure dbo.sp_CheckQualifier
  71. GO
  72.  
  73. /****** Object:  Stored Procedure dbo.sp_CurrentPlan    Script Date: 10/18/97 12:03:55 PM ******/
  74. if exists (select * from sysobjects where id = object_id('dbo.sp_CurrentPlan') and sysstat & 0xf = 4)
  75.     drop procedure dbo.sp_CurrentPlan
  76. GO
  77.  
  78. /****** Object:  Stored Procedure dbo.sp_GetTotalCost    Script Date: 10/18/97 12:03:55 PM ******/
  79. if exists (select * from sysobjects where id = object_id('dbo.sp_GetTotalCost') and sysstat & 0xf = 4)
  80.     drop procedure dbo.sp_GetTotalCost
  81. GO
  82.  
  83. /****** Object:  Stored Procedure dbo.sp_GetTotalCredits    Script Date: 10/18/97 12:03:55 PM ******/
  84. if exists (select * from sysobjects where id = object_id('dbo.sp_GetTotalCredits') and sysstat & 0xf = 4)
  85.     drop procedure dbo.sp_GetTotalCredits
  86. GO
  87.  
  88. /****** Object:  Stored Procedure dbo.sp_PlanField    Script Date: 10/18/97 12:03:55 PM ******/
  89. if exists (select * from sysobjects where id = object_id('dbo.sp_PlanField') and sysstat & 0xf = 4)
  90.     drop procedure dbo.sp_PlanField
  91. GO
  92.  
  93. /****** Object:  Stored Procedure dbo.sp_PlanInfo    Script Date: 10/18/97 12:03:55 PM ******/
  94. if exists (select * from sysobjects where id = object_id('dbo.sp_PlanInfo') and sysstat & 0xf = 4)
  95.     drop procedure dbo.sp_PlanInfo
  96. GO
  97.  
  98. /****** Object:  Stored Procedure dbo.sp_PlanList    Script Date: 10/18/97 12:03:55 PM ******/
  99. if exists (select * from sysobjects where id = object_id('dbo.sp_PlanList') and sysstat & 0xf = 4)
  100.     drop procedure dbo.sp_PlanList
  101. GO
  102.  
  103. /****** Object:  Stored Procedure dbo.sp_SummaryForID    Script Date: 10/18/97 12:03:55 PM ******/
  104. if exists (select * from sysobjects where id = object_id('dbo.sp_SummaryForID') and sysstat & 0xf = 4)
  105.     drop procedure dbo.sp_SummaryForID
  106. GO
  107.  
  108. /****** Object:  Stored Procedure dbo.sp_TaxStatusList    Script Date: 10/18/97 12:03:55 PM ******/
  109. if exists (select * from sysobjects where id = object_id('dbo.sp_TaxStatusList') and sysstat & 0xf = 4)
  110.     drop procedure dbo.sp_TaxStatusList
  111. GO
  112.  
  113. /****** Object:  Stored Procedure dbo.sp_Update    Script Date: 10/18/97 12:03:55 PM ******/
  114. if exists (select * from sysobjects where id = object_id('dbo.sp_Update') and sysstat & 0xf = 4)
  115.     drop procedure dbo.sp_Update
  116. GO
  117.  
  118. /****** Object:  Stored Procedure dbo.sp_ChangeQualifierList2    Script Date: 10/18/97 12:03:55 PM ******/
  119. if exists (select * from sysobjects where id = object_id('dbo.sp_ChangeQualifierList2') and sysstat & 0xf = 4)
  120.     drop procedure dbo.sp_ChangeQualifierList2
  121. GO
  122.  
  123. /****** Object:  Stored Procedure dbo.sp_GetTotalPaycheck    Script Date: 10/18/97 12:03:55 PM ******/
  124. if exists (select * from sysobjects where id = object_id('dbo.sp_GetTotalPaycheck') and sysstat & 0xf = 4)
  125.     drop procedure dbo.sp_GetTotalPaycheck
  126. GO
  127.  
  128. /****** Object:  Stored Procedure dbo.sp_DependentTypeList    Script Date: 10/18/97 12:03:55 PM ******/
  129. if exists (select * from sysobjects where id = object_id('dbo.sp_DependentTypeList') and sysstat & 0xf = 4)
  130.     drop procedure dbo.sp_DependentTypeList
  131. GO
  132.  
  133. /****** Object:  Stored Procedure dbo.sp_GenderList    Script Date: 10/18/97 12:03:55 PM ******/
  134. if exists (select * from sysobjects where id = object_id('dbo.sp_GenderList') and sysstat & 0xf = 4)
  135.     drop procedure dbo.sp_GenderList
  136. GO
  137.  
  138. /****** Object:  Stored Procedure dbo.sp_PhysicianList    Script Date: 10/18/97 12:03:55 PM ******/
  139. if exists (select * from sysobjects where id = object_id('dbo.sp_PhysicianList') and sysstat & 0xf = 4)
  140.     drop procedure dbo.sp_PhysicianList
  141. GO
  142.  
  143. /****** Object:  Table dbo.EmployeeBenefitDependent    Script Date: 10/18/97 12:03:55 PM ******/
  144. if exists (select * from sysobjects where id = object_id('dbo.EmployeeBenefitDependent') and sysstat & 0xf = 3)
  145.     drop table dbo.EmployeeBenefitDependent
  146. GO
  147.  
  148. /****** Object:  Table dbo.BenefitPlan    Script Date: 10/18/97 12:03:55 PM ******/
  149. if exists (select * from sysobjects where id = object_id('dbo.BenefitPlan') and sysstat & 0xf = 3)
  150.     drop table dbo.BenefitPlan
  151. GO
  152.  
  153. /****** Object:  Table dbo.BenefitQualifier    Script Date: 10/18/97 12:03:55 PM ******/
  154. if exists (select * from sysobjects where id = object_id('dbo.BenefitQualifier') and sysstat & 0xf = 3)
  155.     drop table dbo.BenefitQualifier
  156. GO
  157.  
  158. /****** Object:  Table dbo.BenefitTaxStatus    Script Date: 10/18/97 12:03:55 PM ******/
  159. if exists (select * from sysobjects where id = object_id('dbo.BenefitTaxStatus') and sysstat & 0xf = 3)
  160.     drop table dbo.BenefitTaxStatus
  161. GO
  162.  
  163. /****** Object:  Table dbo.EmployeeBenefit    Script Date: 10/18/97 12:03:55 PM ******/
  164. if exists (select * from sysobjects where id = object_id('dbo.EmployeeBenefit') and sysstat & 0xf = 3)
  165.     drop table dbo.EmployeeBenefit
  166. GO
  167.  
  168. /****** Object:  Table dbo.EmployeeDependent    Script Date: 10/18/97 12:03:55 PM ******/
  169. if exists (select * from sysobjects where id = object_id('dbo.EmployeeDependent') and sysstat & 0xf = 3)
  170.     drop table dbo.EmployeeDependent
  171. GO
  172.  
  173. /****** Object:  Table dbo.EmployeeQualifier    Script Date: 10/18/97 12:03:55 PM ******/
  174. if exists (select * from sysobjects where id = object_id('dbo.EmployeeQualifier') and sysstat & 0xf = 3)
  175.     drop table dbo.EmployeeQualifier
  176. GO
  177.  
  178. /****** Object:  Table dbo.PlanField    Script Date: 10/18/97 12:03:55 PM ******/
  179. if exists (select * from sysobjects where id = object_id('dbo.PlanField') and sysstat & 0xf = 3)
  180.     drop table dbo.PlanField
  181. GO
  182.  
  183. /****** Object:  Table dbo.PlanGeoArea    Script Date: 10/18/97 12:03:55 PM ******/
  184. if exists (select * from sysobjects where id = object_id('dbo.PlanGeoArea') and sysstat & 0xf = 3)
  185.     drop table dbo.PlanGeoArea
  186. GO
  187.  
  188. /****** Object:  Table dbo.Benefit    Script Date: 10/18/97 12:03:55 PM ******/
  189. if exists (select * from sysobjects where id = object_id('dbo.Benefit') and sysstat & 0xf = 3)
  190.     drop table dbo.Benefit
  191. GO
  192.  
  193. /****** Object:  Table dbo.Dependent    Script Date: 10/18/97 12:03:55 PM ******/
  194. if exists (select * from sysobjects where id = object_id('dbo.Dependent') and sysstat & 0xf = 3)
  195.     drop table dbo.Dependent
  196. GO
  197.  
  198. /****** Object:  Table dbo.Employee    Script Date: 10/18/97 12:03:55 PM ******/
  199. if exists (select * from sysobjects where id = object_id('dbo.Employee') and sysstat & 0xf = 3)
  200.     drop table dbo.Employee
  201. GO
  202.  
  203. /****** Object:  Table dbo.Plans    Script Date: 10/18/97 12:03:55 PM ******/
  204. if exists (select * from sysobjects where id = object_id('dbo.Plans') and sysstat & 0xf = 3)
  205.     drop table dbo.Plans
  206. GO
  207.  
  208. /****** Object:  Table dbo.Qualifier    Script Date: 10/18/97 12:03:55 PM ******/
  209. if exists (select * from sysobjects where id = object_id('dbo.Qualifier') and sysstat & 0xf = 3)
  210.     drop table dbo.Qualifier
  211. GO
  212.  
  213. /****** Object:  Table dbo.BenefitStatus    Script Date: 10/18/97 12:03:55 PM ******/
  214. if exists (select * from sysobjects where id = object_id('dbo.BenefitStatus') and sysstat & 0xf = 3)
  215.     drop table dbo.BenefitStatus
  216. GO
  217.  
  218. /****** Object:  Table dbo.DependentType    Script Date: 10/18/97 12:03:55 PM ******/
  219. if exists (select * from sysobjects where id = object_id('dbo.DependentType') and sysstat & 0xf = 3)
  220.     drop table dbo.DependentType
  221. GO
  222.  
  223. /****** Object:  Table dbo.EBDStatus    Script Date: 10/18/97 12:03:55 PM ******/
  224. if exists (select * from sysobjects where id = object_id('dbo.EBDStatus') and sysstat & 0xf = 3)
  225.     drop table dbo.EBDStatus
  226. GO
  227.  
  228. /****** Object:  Table dbo.EDStatus    Script Date: 10/18/97 12:03:55 PM ******/
  229. if exists (select * from sysobjects where id = object_id('dbo.EDStatus') and sysstat & 0xf = 3)
  230.     drop table dbo.EDStatus
  231. GO
  232.  
  233. /****** Object:  Table dbo.EmployeeStatus    Script Date: 10/18/97 12:03:55 PM ******/
  234. if exists (select * from sysobjects where id = object_id('dbo.EmployeeStatus') and sysstat & 0xf = 3)
  235.     drop table dbo.EmployeeStatus
  236. GO
  237.  
  238. /****** Object:  Table dbo.Field    Script Date: 10/18/97 12:03:55 PM ******/
  239. if exists (select * from sysobjects where id = object_id('dbo.Field') and sysstat & 0xf = 3)
  240.     drop table dbo.Field
  241. GO
  242.  
  243. /****** Object:  Table dbo.Gender    Script Date: 10/18/97 12:03:55 PM ******/
  244. if exists (select * from sysobjects where id = object_id('dbo.Gender') and sysstat & 0xf = 3)
  245.     drop table dbo.Gender
  246. GO
  247.  
  248. /****** Object:  Table dbo.GeoArea    Script Date: 10/18/97 12:03:55 PM ******/
  249. if exists (select * from sysobjects where id = object_id('dbo.GeoArea') and sysstat & 0xf = 3)
  250.     drop table dbo.GeoArea
  251. GO
  252.  
  253. /****** Object:  Table dbo.Physician    Script Date: 10/18/97 12:03:55 PM ******/
  254. if exists (select * from sysobjects where id = object_id('dbo.Physician') and sysstat & 0xf = 3)
  255.     drop table dbo.Physician
  256. GO
  257.  
  258. /****** Object:  Table dbo.PlanStatus    Script Date: 10/18/97 12:03:55 PM ******/
  259. if exists (select * from sysobjects where id = object_id('dbo.PlanStatus') and sysstat & 0xf = 3)
  260.     drop table dbo.PlanStatus
  261. GO
  262.  
  263. /****** Object:  Table dbo.QualifierClass    Script Date: 10/18/97 12:03:55 PM ******/
  264. if exists (select * from sysobjects where id = object_id('dbo.QualifierClass') and sysstat & 0xf = 3)
  265.     drop table dbo.QualifierClass
  266. GO
  267.  
  268. /****** Object:  Table dbo.QualifierStatus    Script Date: 10/18/97 12:03:55 PM ******/
  269. if exists (select * from sysobjects where id = object_id('dbo.QualifierStatus') and sysstat & 0xf = 3)
  270.     drop table dbo.QualifierStatus
  271. GO
  272.  
  273. /****** Object:  Table dbo.TaxStatus    Script Date: 10/18/97 12:03:55 PM ******/
  274. if exists (select * from sysobjects where id = object_id('dbo.TaxStatus') and sysstat & 0xf = 3)
  275.     drop table dbo.TaxStatus
  276. GO
  277.  
  278. /****** Object:  Table dbo.BenefitStatus    Script Date: 10/18/97 12:03:55 PM ******/
  279. CREATE TABLE dbo.BenefitStatus (
  280.     BenefitStatusId tinyint IDENTITY (1, 1) NOT NULL ,
  281.     BenefitStatusName varchar (100) NULL ,
  282.     BenefitStatusLabel varchar (100) NULL ,
  283.     CONSTRAINT PK_BenefitStatus PRIMARY KEY  NONCLUSTERED 
  284.     (
  285.         BenefitStatusId
  286.     )
  287. )
  288. GO
  289.  
  290. /****** Object:  Table dbo.DependentType    Script Date: 10/18/97 12:03:56 PM ******/
  291. CREATE TABLE dbo.DependentType (
  292.     DependentTypeId int IDENTITY (1, 1) NOT NULL ,
  293.     DependentTypeName varchar (100) NULL ,
  294.     DependentTypeLabel varchar (100) NULL ,
  295.     DependentTypeRank int NULL ,
  296.     CONSTRAINT PK_DependentType PRIMARY KEY  NONCLUSTERED 
  297.     (
  298.         DependentTypeId
  299.     )
  300. )
  301. GO
  302.  
  303. /****** Object:  Table dbo.EBDStatus    Script Date: 10/18/97 12:03:56 PM ******/
  304. CREATE TABLE dbo.EBDStatus (
  305.     EBDStatusId tinyint IDENTITY (1, 1) NOT NULL ,
  306.     EBDStatusName varchar (100) NULL ,
  307.     EBDStatusLabel varchar (100) NULL ,
  308.     CONSTRAINT PK_EBDStatus PRIMARY KEY  NONCLUSTERED 
  309.     (
  310.         EBDStatusId
  311.     )
  312. )
  313. GO
  314.  
  315. /****** Object:  Table dbo.EDStatus    Script Date: 10/18/97 12:03:56 PM ******/
  316. CREATE TABLE dbo.EDStatus (
  317.     DependentStatusId tinyint IDENTITY (1, 1) NOT NULL ,
  318.     DependentStatusName varchar (100) NULL ,
  319.     DependentStatusLabel varchar (100) NULL ,
  320.     CONSTRAINT PK_EDStatus PRIMARY KEY  NONCLUSTERED 
  321.     (
  322.         DependentStatusId
  323.     )
  324. )
  325. GO
  326.  
  327. /****** Object:  Table dbo.EmployeeStatus    Script Date: 10/18/97 12:03:56 PM ******/
  328. CREATE TABLE dbo.EmployeeStatus (
  329.     EmployeeStatusId tinyint IDENTITY (1, 1) NOT NULL ,
  330.     EmployeeStatusName varchar (100) NULL ,
  331.     EmployeeStatusLabel varchar (100) NULL ,
  332.     CONSTRAINT PK_EmployeeStatus PRIMARY KEY  NONCLUSTERED 
  333.     (
  334.         EmployeeStatusId
  335.     )
  336. )
  337. GO
  338.  
  339. /****** Object:  Table dbo.Field    Script Date: 10/18/97 12:03:56 PM ******/
  340. CREATE TABLE dbo.Field (
  341.     FieldId int IDENTITY (1, 1) NOT NULL ,
  342.     FieldName varchar (100) NULL ,
  343.     FieldLabel varchar (100) NULL ,
  344.     CONSTRAINT PK_Field PRIMARY KEY  NONCLUSTERED 
  345.     (
  346.         FieldId
  347.     )
  348. )
  349. GO
  350.  
  351. /****** Object:  Table dbo.Gender    Script Date: 10/18/97 12:03:56 PM ******/
  352. CREATE TABLE dbo.Gender (
  353.     GenderId int IDENTITY (1, 1) NOT NULL ,
  354.     GenderName varchar (100) NULL ,
  355.     GenderLabel varchar (100) NULL ,
  356.     GenderRank int NULL ,
  357.     CONSTRAINT PK_Gender PRIMARY KEY  NONCLUSTERED 
  358.     (
  359.         GenderId
  360.     )
  361. )
  362. GO
  363.  
  364. /****** Object:  Table dbo.GeoArea    Script Date: 10/18/97 12:03:56 PM ******/
  365. CREATE TABLE dbo.GeoArea (
  366.     GeoAreaId int IDENTITY (1, 1) NOT NULL ,
  367.     GeoAreaName varchar (100) NULL ,
  368.     GeoAreaLabel varchar (100) NULL ,
  369.     CONSTRAINT PK_GeoArea PRIMARY KEY  NONCLUSTERED 
  370.     (
  371.         GeoAreaId
  372.     )
  373. )
  374. GO
  375.  
  376. /****** Object:  Table dbo.Physician    Script Date: 10/18/97 12:03:56 PM ******/
  377. CREATE TABLE dbo.Physician (
  378.     PhysicianId int IDENTITY (1, 1) NOT NULL ,
  379.     PhysicianName varchar (100) NULL ,
  380.     PhysicianLabel varchar (100) NULL ,
  381.     CONSTRAINT PK_Physician PRIMARY KEY  NONCLUSTERED 
  382.     (
  383.         PhysicianId
  384.     )
  385. )
  386. GO
  387.  
  388. /****** Object:  Table dbo.PlanStatus    Script Date: 10/18/97 12:03:57 PM ******/
  389. CREATE TABLE dbo.PlanStatus (
  390.     PlanStatusId tinyint IDENTITY (1, 1) NOT NULL ,
  391.     PlanStatusName varchar (100) NULL ,
  392.     PlanStatusLabel varchar (100) NULL ,
  393.     CONSTRAINT PK_PlanStatus PRIMARY KEY  NONCLUSTERED 
  394.     (
  395.         PlanStatusId
  396.     )
  397. )
  398. GO
  399.  
  400. /****** Object:  Table dbo.QualifierClass    Script Date: 10/18/97 12:03:57 PM ******/
  401. CREATE TABLE dbo.QualifierClass (
  402.     QualifierClassId int IDENTITY (1, 1) NOT NULL ,
  403.     QualifierClassName varchar (100) NULL ,
  404.     QualifierClassLabel varchar (100) NULL ,
  405.     CONSTRAINT PK_QualifierClass PRIMARY KEY  NONCLUSTERED 
  406.     (
  407.         QualifierClassId
  408.     )
  409. )
  410. GO
  411.  
  412. /****** Object:  Table dbo.QualifierStatus    Script Date: 10/18/97 12:03:57 PM ******/
  413. CREATE TABLE dbo.QualifierStatus (
  414.     QualifierStatusId int IDENTITY (1, 1) NOT NULL ,
  415.     QualifierStatusName varchar (100) NULL ,
  416.     QualifierStatusLabel varchar (100) NULL ,
  417.     CONSTRAINT PK_QualifierStatus PRIMARY KEY  NONCLUSTERED 
  418.     (
  419.         QualifierStatusId
  420.     )
  421. )
  422. GO
  423.  
  424. /****** Object:  Table dbo.TaxStatus    Script Date: 10/18/97 12:03:57 PM ******/
  425. CREATE TABLE dbo.TaxStatus (
  426.     TaxStatusId int IDENTITY (1, 1) NOT NULL ,
  427.     TaxStatusName varchar (100) NULL ,
  428.     TaxStatusLabel varchar (100) NULL ,
  429.     CONSTRAINT PK_TaxStatus PRIMARY KEY  NONCLUSTERED 
  430.     (
  431.         TaxStatusId
  432.     )
  433. )
  434. GO
  435.  
  436. /****** Object:  Table dbo.Benefit    Script Date: 10/18/97 12:03:57 PM ******/
  437. CREATE TABLE dbo.Benefit (
  438.     BenefitId int IDENTITY (1, 1) NOT NULL ,
  439.     BenefitYear int NOT NULL ,
  440.     BenefitName varchar (100) NULL ,
  441.     BenefitLabel varchar (100) NULL ,
  442.     BenefitDesc varchar (255) NULL ,
  443.     BenefitText text NULL ,
  444.     BenefitRank int NULL ,
  445.     DetailTemplate varchar (100) NULL ,
  446.     MinimumPlanRanking int NULL ,
  447.     QualifierRequired tinyint NULL ,
  448.     DependentCovered tinyint NULL ,
  449.     SignatureRequired tinyint NULL ,
  450.     BenefitStatusId tinyint NULL CONSTRAINT DF_Benefit_BenefitStatus DEFAULT (1),
  451.     CONSTRAINT PK_Benefit PRIMARY KEY  NONCLUSTERED 
  452.     (
  453.         BenefitId
  454.     ),
  455.     CONSTRAINT FK_Benefit_BenefitStatus FOREIGN KEY 
  456.     (
  457.         BenefitStatusId
  458.     ) REFERENCES dbo.BenefitStatus (
  459.         BenefitStatusId
  460.     )
  461. )
  462. GO
  463.  
  464. /****** Object:  Table dbo.Dependent    Script Date: 10/18/97 12:03:57 PM ******/
  465. CREATE TABLE dbo.Dependent (
  466.     DependentId int IDENTITY (1, 1) NOT NULL ,
  467.     LastName varchar (100) NULL ,
  468.     FirstName varchar (100) NULL ,
  469.     MiddleName varchar (100) NULL ,
  470.     DependentBirthdate datetime NULL ,
  471.     DependentGenderId int NULL CONSTRAINT DF_Dependent_DependentGenderId DEFAULT (1),
  472.     DependentSSN varchar (11) NULL ,
  473.     CONSTRAINT PK_Dependent PRIMARY KEY  NONCLUSTERED 
  474.     (
  475.         DependentId
  476.     ),
  477.     CONSTRAINT FK_Dependent_Gender FOREIGN KEY 
  478.     (
  479.         DependentGenderId
  480.     ) REFERENCES dbo.Gender (
  481.         GenderId
  482.     )
  483. )
  484. GO
  485.  
  486. /****** Object:  Table dbo.Employee    Script Date: 10/18/97 12:03:57 PM ******/
  487. CREATE TABLE dbo.Employee (
  488.     EmployeeId int IDENTITY (1, 1) NOT NULL ,
  489.     KnownAs varchar (100) NULL ,
  490.     NTUserName varchar (100) NOT NULL ,
  491.     Address1 varchar (100) NULL ,
  492.     Address2 varchar (100) NULL ,
  493.     City varchar (100) NULL ,
  494.     State varchar (100) NULL ,
  495.     PostCode varchar (100) NULL ,
  496.     Country varchar (100) NULL ,
  497.     HomePhone varchar (100) NULL ,
  498.     BusinessPhone varchar (100) NULL ,
  499.     Fax varchar (100) NULL ,
  500.     Email varchar (100) NULL ,
  501.     PeriodEarnings money NULL CONSTRAINT DF_Employee_PeriodEarnings DEFAULT (2000.00),
  502.     Exemptions int NULL CONSTRAINT DF_Employee_Exemptions DEFAULT (1),
  503.     EmployeeGeoAreaId int NULL ,
  504.     EmployeeStatusId tinyint NULL CONSTRAINT DF_Employee_EmployeeStatus DEFAULT (1),
  505.     CONSTRAINT PK_Employee PRIMARY KEY  NONCLUSTERED 
  506.     (
  507.         EmployeeId
  508.     ),
  509.     CONSTRAINT IX_Employee UNIQUE  NONCLUSTERED 
  510.     (
  511.         NTUserName
  512.     ),
  513.     CONSTRAINT FK_Employee_EmployeeStatus FOREIGN KEY 
  514.     (
  515.         EmployeeStatusId
  516.     ) REFERENCES dbo.EmployeeStatus (
  517.         EmployeeStatusId
  518.     ),
  519.     CONSTRAINT FK_Employee_GeoArea FOREIGN KEY 
  520.     (
  521.         EmployeeGeoAreaId
  522.     ) REFERENCES dbo.GeoArea (
  523.         GeoAreaId
  524.     )
  525. )
  526. GO
  527.  
  528. /****** Object:  Table dbo.Plans    Script Date: 10/18/97 12:03:57 PM ******/
  529. CREATE TABLE dbo.Plans (
  530.     PlanId int IDENTITY (1, 1) NOT NULL ,
  531.     PlanName varchar (100) NULL ,
  532.     PlanLabel varchar (100) NULL ,
  533.     PlanDesc varchar (255) NULL ,
  534.     PlanText text NULL ,
  535.     PlanCost money NULL ,
  536.     PhysicianRequired tinyint NULL ,
  537.     PlanStatusId tinyint NULL CONSTRAINT DF_Plans_PlanStatus DEFAULT (1),
  538.     CONSTRAINT PK_Plans PRIMARY KEY  NONCLUSTERED 
  539.     (
  540.         PlanId
  541.     ),
  542.     CONSTRAINT FK_Plans_PlanStatus FOREIGN KEY 
  543.     (
  544.         PlanStatusId
  545.     ) REFERENCES dbo.PlanStatus (
  546.         PlanStatusId
  547.     )
  548. )
  549. GO
  550.  
  551. /****** Object:  Table dbo.Qualifier    Script Date: 10/18/97 12:03:58 PM ******/
  552. CREATE TABLE dbo.Qualifier (
  553.     QualifierId int IDENTITY (1, 1) NOT NULL ,
  554.     QualifierName varchar (100) NULL ,
  555.     QualifierLabel varchar (100) NULL ,
  556.     QualifierClassId int NULL ,
  557.     QualifierRank int NULL ,
  558.     QualifierStatusId int NULL ,
  559.     CONSTRAINT PK_Qualifier PRIMARY KEY  NONCLUSTERED 
  560.     (
  561.         QualifierId
  562.     ),
  563.     CONSTRAINT FK_Qualifier_QualifierClass FOREIGN KEY 
  564.     (
  565.         QualifierClassId
  566.     ) REFERENCES dbo.QualifierClass (
  567.         QualifierClassId
  568.     ),
  569.     CONSTRAINT FK_Qualifier_QualifierStatus FOREIGN KEY 
  570.     (
  571.         QualifierStatusId
  572.     ) REFERENCES dbo.QualifierStatus (
  573.         QualifierStatusId
  574.     )
  575. )
  576. GO
  577.  
  578. /****** Object:  Table dbo.BenefitPlan    Script Date: 10/18/97 12:03:58 PM ******/
  579. CREATE TABLE dbo.BenefitPlan (
  580.     BenefitId int NOT NULL ,
  581.     PlanId int NOT NULL ,
  582.     PlanRank int NULL ,
  583.     CONSTRAINT PK_BenefitPlan PRIMARY KEY  NONCLUSTERED 
  584.     (
  585.         BenefitId,
  586.         PlanId
  587.     ),
  588.     CONSTRAINT FK_BenefitPlan_Benefit FOREIGN KEY 
  589.     (
  590.         BenefitId
  591.     ) REFERENCES dbo.Benefit (
  592.         BenefitId
  593.     ),
  594.     CONSTRAINT FK_BenefitPlan_Plans FOREIGN KEY 
  595.     (
  596.         PlanId
  597.     ) REFERENCES dbo.Plans (
  598.         PlanId
  599.     )
  600. )
  601. GO
  602.  
  603. /****** Object:  Table dbo.BenefitQualifier    Script Date: 10/18/97 12:03:58 PM ******/
  604. CREATE TABLE dbo.BenefitQualifier (
  605.     BenefitId int NOT NULL ,
  606.     QualifierId int NOT NULL ,
  607.     ChangeDays int NULL ,
  608.     CONSTRAINT PK_BenefitQualifier PRIMARY KEY  NONCLUSTERED 
  609.     (
  610.         BenefitId,
  611.         QualifierId
  612.     ),
  613.     CONSTRAINT FK_BenefitQualifier_Benefit FOREIGN KEY 
  614.     (
  615.         BenefitId
  616.     ) REFERENCES dbo.Benefit (
  617.         BenefitId
  618.     ),
  619.     CONSTRAINT FK_BenefitQualifier_Qualifier FOREIGN KEY 
  620.     (
  621.         QualifierId
  622.     ) REFERENCES dbo.Qualifier (
  623.         QualifierId
  624.     )
  625. )
  626. GO
  627.  
  628. /****** Object:  Table dbo.BenefitTaxStatus    Script Date: 10/18/97 12:03:58 PM ******/
  629. CREATE TABLE dbo.BenefitTaxStatus (
  630.     BenefitId int NOT NULL ,
  631.     TaxStatusId int NOT NULL ,
  632.     TaxDefault tinyint NULL ,
  633.     CONSTRAINT PK_BenefitTaxStatus PRIMARY KEY  NONCLUSTERED 
  634.     (
  635.         BenefitId,
  636.         TaxStatusId
  637.     ),
  638.     CONSTRAINT FK_BenefitTaxStatus_Benefit FOREIGN KEY 
  639.     (
  640.         BenefitId
  641.     ) REFERENCES dbo.Benefit (
  642.         BenefitId
  643.     ),
  644.     CONSTRAINT FK_BenefitTaxStatus_TaxStatus FOREIGN KEY 
  645.     (
  646.         TaxStatusId
  647.     ) REFERENCES dbo.TaxStatus (
  648.         TaxStatusId
  649.     )
  650. )
  651. GO
  652.  
  653. /****** Object:  Table dbo.EmployeeBenefit    Script Date: 10/18/97 12:03:58 PM ******/
  654. CREATE TABLE dbo.EmployeeBenefit (
  655.     EmployeeId int NOT NULL ,
  656.     BenefitId int NOT NULL ,
  657.     PlanId int NULL ,
  658.     CreditAmount money NULL ,
  659.     TaxStatusId int NULL ,
  660.     EligibilityDate datetime NULL ,
  661.     CONSTRAINT PK_EmployeeBenefit PRIMARY KEY  NONCLUSTERED 
  662.     (
  663.         EmployeeId,
  664.         BenefitId
  665.     ),
  666.     CONSTRAINT FK_EmployeeBenefit_Benefit FOREIGN KEY 
  667.     (
  668.         BenefitId
  669.     ) REFERENCES dbo.Benefit (
  670.         BenefitId
  671.     ),
  672.     CONSTRAINT FK_EmployeeBenefit_Employee FOREIGN KEY 
  673.     (
  674.         EmployeeId
  675.     ) REFERENCES dbo.Employee (
  676.         EmployeeId
  677.     ),
  678.     CONSTRAINT FK_EmployeeBenefit_Plans1 FOREIGN KEY 
  679.     (
  680.         PlanId
  681.     ) REFERENCES dbo.Plans (
  682.         PlanId
  683.     ),
  684.     CONSTRAINT FK_EmployeeBenefit_TaxStatus FOREIGN KEY 
  685.     (
  686.         TaxStatusId
  687.     ) REFERENCES dbo.TaxStatus (
  688.         TaxStatusId
  689.     )
  690. )
  691. GO
  692.  
  693. /****** Object:  Table dbo.EmployeeDependent    Script Date: 10/18/97 12:03:58 PM ******/
  694. CREATE TABLE dbo.EmployeeDependent (
  695.     EmployeeId int NOT NULL ,
  696.     DependentId int NOT NULL ,
  697.     DependentTypeId int NULL ,
  698.     DependentStatusId tinyint NULL CONSTRAINT DF_EmployeeDep_DependentSt DEFAULT (1),
  699.     CONSTRAINT PK_EmployeeDependent PRIMARY KEY  NONCLUSTERED 
  700.     (
  701.         EmployeeId,
  702.         DependentId
  703.     ),
  704.     CONSTRAINT FK_EmployeeDep_DependentTy FOREIGN KEY 
  705.     (
  706.         DependentTypeId
  707.     ) REFERENCES dbo.DependentType (
  708.         DependentTypeId
  709.     ),
  710.     CONSTRAINT FK_EmployeeDependent_Dependent FOREIGN KEY 
  711.     (
  712.         DependentId
  713.     ) REFERENCES dbo.Dependent (
  714.         DependentId
  715.     ),
  716.     CONSTRAINT FK_EmployeeDependent_EDStatus FOREIGN KEY 
  717.     (
  718.         DependentStatusId
  719.     ) REFERENCES dbo.EDStatus (
  720.         DependentStatusId
  721.     ),
  722.     CONSTRAINT FK_EmployeeDependent_Employee FOREIGN KEY 
  723.     (
  724.         EmployeeId
  725.     ) REFERENCES dbo.Employee (
  726.         EmployeeId
  727.     )
  728. )
  729. GO
  730.  
  731. /****** Object:  Table dbo.EmployeeQualifier    Script Date: 10/18/97 12:03:58 PM ******/
  732. CREATE TABLE dbo.EmployeeQualifier (
  733.     EmployeeQualifierId int IDENTITY (1, 1) NOT NULL ,
  734.     EmployeeId int NOT NULL ,
  735.     QualifierId int NOT NULL ,
  736.     QualifierDate datetime NOT NULL ,
  737.     CONSTRAINT PK_EmployeeQualifier PRIMARY KEY  NONCLUSTERED 
  738.     (
  739.         EmployeeQualifierId
  740.     ),
  741.     CONSTRAINT FK_EmployeeQualifier_Employee FOREIGN KEY 
  742.     (
  743.         EmployeeId
  744.     ) REFERENCES dbo.Employee (
  745.         EmployeeId
  746.     ),
  747.     CONSTRAINT FK_EmployeeQualifier_Qualifier FOREIGN KEY 
  748.     (
  749.         QualifierId
  750.     ) REFERENCES dbo.Qualifier (
  751.         QualifierId
  752.     )
  753. )
  754. GO
  755.  
  756.  CREATE  CLUSTERED  INDEX IX_EmployeeQualifier ON dbo.EmployeeQualifier(EmployeeId) WITH  ALLOW_DUP_ROW 
  757. GO
  758.  
  759. /****** Object:  Table dbo.PlanField    Script Date: 10/18/97 12:03:59 PM ******/
  760. CREATE TABLE dbo.PlanField (
  761.     PlanId int NOT NULL ,
  762.     FieldId int NOT NULL ,
  763.     FieldValue varchar (255) NULL ,
  764.     FieldRank int NULL ,
  765.     CONSTRAINT PK_PlanField PRIMARY KEY  NONCLUSTERED 
  766.     (
  767.         PlanId,
  768.         FieldId
  769.     ),
  770.     CONSTRAINT FK_PlanField_Field FOREIGN KEY 
  771.     (
  772.         FieldId
  773.     ) REFERENCES dbo.Field (
  774.         FieldId
  775.     ),
  776.     CONSTRAINT FK_PlanField_Plans FOREIGN KEY 
  777.     (
  778.         PlanId
  779.     ) REFERENCES dbo.Plans (
  780.         PlanId
  781.     )
  782. )
  783. GO
  784.  
  785. /****** Object:  Table dbo.PlanGeoArea    Script Date: 10/18/97 12:03:59 PM ******/
  786. CREATE TABLE dbo.PlanGeoArea (
  787.     PlanId int NOT NULL ,
  788.     GeoAreaId int NOT NULL ,
  789.     CONSTRAINT PK_PlanGeoArea PRIMARY KEY  NONCLUSTERED 
  790.     (
  791.         PlanId,
  792.         GeoAreaId
  793.     ),
  794.     CONSTRAINT FK_PlanGeoArea_GeoArea FOREIGN KEY 
  795.     (
  796.         GeoAreaId
  797.     ) REFERENCES dbo.GeoArea (
  798.         GeoAreaId
  799.     ),
  800.     CONSTRAINT FK_PlanGeoArea_Plans FOREIGN KEY 
  801.     (
  802.         PlanId
  803.     ) REFERENCES dbo.Plans (
  804.         PlanId
  805.     )
  806. )
  807. GO
  808.  
  809. /****** Object:  Table dbo.EmployeeBenefitDependent    Script Date: 10/18/97 12:03:59 PM ******/
  810. CREATE TABLE dbo.EmployeeBenefitDependent (
  811.     EmployeeId int NOT NULL ,
  812.     BenefitId int NOT NULL ,
  813.     DependentId int NOT NULL ,
  814.     PhysicianId int NULL ,
  815.     EBDStatusId tinyint NULL CONSTRAINT DF_EmployeeBen_EBDStatus DEFAULT (1),
  816.     CONSTRAINT PK_EmployeeBenefitDependent PRIMARY KEY  NONCLUSTERED 
  817.     (
  818.         EmployeeId,
  819.         BenefitId,
  820.         DependentId
  821.     ),
  822.     CONSTRAINT FK_EmployeeBen_Dependent FOREIGN KEY 
  823.     (
  824.         DependentId
  825.     ) REFERENCES dbo.Dependent (
  826.         DependentId
  827.     ),
  828.     CONSTRAINT FK_EmployeeBen_EBDStatus FOREIGN KEY 
  829.     (
  830.         EBDStatusId
  831.     ) REFERENCES dbo.EBDStatus (
  832.         EBDStatusId
  833.     ),
  834.     CONSTRAINT FK_EmployeeBen_EmployeeBen1 FOREIGN KEY 
  835.     (
  836.         EmployeeId,
  837.         BenefitId
  838.     ) REFERENCES dbo.EmployeeBenefit (
  839.         EmployeeId,
  840.         BenefitId
  841.     ),
  842.     CONSTRAINT FK_EmployeeBen_Physician FOREIGN KEY 
  843.     (
  844.         PhysicianId
  845.     ) REFERENCES dbo.Physician (
  846.         PhysicianId
  847.     )
  848. )
  849. GO
  850.  
  851. /****** Object:  Stored Procedure dbo.sp_DependentTypeList    Script Date: 10/18/97 12:03:59 PM ******/
  852.  
  853. /****** Object:  Stored Procedure dbo.sp_DependentTypeList    Script Date: 9/28/97 12:08:30 PM ******/
  854. CREATE PROCEDURE sp_DependentTypeList AS
  855. SELECT dt.DependentTypeId, dt.DependentTypeLabel, dt.DependentTypeRank 
  856. FROM DependentType dt 
  857. ORDER BY dt.DependentTypeRank
  858.  
  859. GO
  860.  
  861. /****** Object:  Stored Procedure dbo.sp_GenderList    Script Date: 10/18/97 12:03:59 PM ******/
  862. /****** Object:  Stored Procedure dbo.sp_GenderList    Script Date: 9/28/97 12:08:30 PM ******/
  863. CREATE PROCEDURE sp_GenderList AS
  864. SELECT g.GenderId, g.GenderLabel, g.GenderRank 
  865. FROM Gender g
  866. ORDER BY g.GenderRank
  867. GO
  868.  
  869. /****** Object:  Stored Procedure dbo.sp_PhysicianList    Script Date: 10/18/97 12:03:59 PM ******/
  870.  
  871. /****** Object:  Stored Procedure dbo.sp_PhysicianList    Script Date: 9/28/97 12:08:30 PM ******/
  872. CREATE PROCEDURE sp_PhysicianList AS
  873. SELECT ph.PhysicianId, ph.PhysicianLabel 
  874. FROM Physician ph
  875.  
  876. GO
  877.  
  878. /****** Object:  Stored Procedure dbo.sp_ChangeQualifierList2    Script Date: 10/18/97 12:03:59 PM ******/
  879.  
  880. /****** Object:  Stored Procedure dbo.sp_ChangeQualifierList2    Script Date: 9/28/97 12:08:30 PM ******/
  881. CREATE PROCEDURE sp_ChangeQualifierList2 (@lngQualifierClassId  int) AS
  882. SELECT q.QualifierId, q.QualifierLabel, q.QualifierRank 
  883. FROM Qualifier q 
  884. WHERE q.QualifierStatusId = 1 
  885. AND q.QualifierClassId = @lngQualifierClassId
  886. ORDER BY q.QualifierRank
  887.  
  888. GO
  889.  
  890. /****** Object:  Stored Procedure dbo.sp_GetTotalPaycheck    Script Date: 10/18/97 12:03:59 PM ******/
  891.  
  892. /****** Object:  Stored Procedure dbo.sp_GetTotalPaycheck    Script Date: 9/28/97 12:08:30 PM ******/
  893. CREATE PROCEDURE sp_GetTotalPaycheck (@lngEmployeeId int) AS
  894. SELECT e.PeriodEarnings, e.Exemptions
  895. FROM Employee e
  896. WHERE e.EmployeeId = @lngEmployeeId
  897.  
  898. GO
  899.  
  900. /****** Object:  Stored Procedure dbo.sp_AddBenefitInsert    Script Date: 10/18/97 12:03:59 PM ******/
  901.  
  902. /****** Object:  Stored Procedure dbo.sp_AddBenefitInsert    Script Date: 9/28/97 12:08:30 PM ******/
  903. CREATE PROCEDURE sp_AddBenefitInsert (@lngEmployeeId int, @lngBenefitId int, @PlanId int, 
  904.     @PlanCost int, @TaxStatusId int) AS
  905. INSERT INTO EmployeeBenefit 
  906. (EmployeeId, BenefitId, PlanId, CreditAmount, TaxStatusId)
  907. VALUES (@lngEmployeeId, @lngBenefitId, @PlanId, @PlanCost, @TaxStatusId)
  908.  
  909. GO
  910.  
  911. /****** Object:  Stored Procedure dbo.sp_AddBenefitSelect1    Script Date: 10/18/97 12:03:59 PM ******/
  912.  
  913. /****** Object:  Stored Procedure dbo.sp_AddBenefitSelect1    Script Date: 9/28/97 12:08:30 PM ******/
  914. CREATE PROCEDURE sp_AddBenefitSelect1 (@lngBenefitId int) AS
  915. SELECT bp.PlanId, p.PlanCost, bts.TaxStatusId 
  916. FROM Benefit b, BenefitPlan bp, BenefitTaxStatus bts, Plans p
  917. WHERE b.BenefitId = @lngBenefitId
  918. AND bp.BenefitId = b.BenefitId
  919. AND bp.PlanRank = b.MinimumPlanRanking 
  920. AND p.PlanId = bp.PlanId 
  921. AND bts.BenefitId = b.BenefitId 
  922. AND bts.TaxDefault = 1
  923.  
  924. GO
  925.  
  926. /****** Object:  Stored Procedure dbo.sp_AddBenefitSelect2    Script Date: 10/18/97 12:03:59 PM ******/
  927.  
  928. /****** Object:  Stored Procedure dbo.sp_AddBenefitSelect2    Script Date: 9/28/97 12:08:30 PM ******/
  929. CREATE PROCEDURE sp_AddBenefitSelect2 (@lngEmployeeId int) AS
  930. SELECT ed.DependentId, ed.DependentTypeId 
  931. FROM EmployeeDependent ed 
  932. WHERE ed.EmployeeId = @lngEmployeeId
  933.  
  934. GO
  935.  
  936. /****** Object:  Stored Procedure dbo.sp_AddQualifier    Script Date: 10/18/97 12:03:59 PM ******/
  937.  
  938. /****** Object:  Stored Procedure dbo.sp_AddQualifier    Script Date: 9/28/97 12:08:30 PM ******/
  939. CREATE PROCEDURE sp_AddQualifier (@lngEmployeeId int, @lngQualifierId int, @datQualifierDate datetime) AS
  940. INSERT INTO EmployeeQualifier 
  941. (EmployeeId, QualifierId, QualifierDate) 
  942. VALUES (@lngEmployeeId, @lngQualifierId, @datQualifierDate)
  943.  
  944. GO
  945.  
  946. /****** Object:  Stored Procedure dbo.sp_BenefitsForID    Script Date: 10/18/97 12:03:59 PM ******/
  947.  
  948. /****** Object:  Stored Procedure dbo.sp_BenefitsForID    Script Date: 9/28/97 12:08:30 PM ******/
  949. CREATE PROCEDURE sp_BenefitsForID (@lngEmployeeId int, @intBenefitYear int) AS
  950. SELECT b.BenefitId 
  951. FROM Benefit b 
  952. JOIN EmployeeBenefit eb ON eb.BenefitId = b.BenefitId 
  953. AND eb.EmployeeId = @lngEmployeeId 
  954. WHERE b.BenefitYear = @intBenefitYear
  955.  
  956. GO
  957.  
  958. /****** Object:  Stored Procedure dbo.sp_ChangeQualifierList1    Script Date: 10/18/97 12:03:59 PM ******/
  959.  
  960. /****** Object:  Stored Procedure dbo.sp_ChangeQualifierList1    Script Date: 9/28/97 12:08:30 PM ******/
  961. CREATE PROCEDURE sp_ChangeQualifierList1 (@lngQualifierClassId  int, @lngBenefitId int) AS
  962. SELECT bq.QualifierId, q.QualifierLabel, q.QualifierRank, bq.ChangeDays 
  963. FROM BenefitQualifier bq 
  964. JOIN Qualifier q ON q.QualifierId = bq.QualifierId 
  965. AND q.QualifierClassId = @lngQualifierClassId  
  966. WHERE q.QualifierStatusId = 1 
  967. AND bq.BenefitId = @lngBenefitId 
  968. ORDER BY q.QualifierRank
  969.  
  970. GO
  971.  
  972. /****** Object:  Stored Procedure dbo.sp_CheckQualifier    Script Date: 10/18/97 12:03:59 PM ******/
  973.  
  974. /****** Object:  Stored Procedure dbo.sp_CheckQualifier    Script Date: 9/28/97 12:08:30 PM ******/
  975. CREATE PROCEDURE sp_CheckQualifier (@lngEmployeeId int, @lngBenefitId int) AS
  976. SELECT eq.QualifierId 
  977. FROM EmployeeQualifier eq 
  978. JOIN BenefitQualifier bq ON bq.QualifierId = eq.QualifierId 
  979. AND bq.BenefitId = @lngBenefitId
  980. WHERE eq.EmployeeId = @lngEmployeeId
  981. AND GETDATE() <= DATEADD(day, bq.ChangeDays, eq.QualifierDate)
  982.  
  983. GO
  984.  
  985. /****** Object:  Stored Procedure dbo.sp_CurrentPlan    Script Date: 10/18/97 12:03:59 PM ******/
  986.  
  987. /****** Object:  Stored Procedure dbo.sp_CurrentPlan    Script Date: 9/28/97 12:08:30 PM ******/
  988. CREATE PROCEDURE sp_CurrentPlan (@lngEmployeeId int, @lngBenefitId int) AS
  989. SELECT b.BenefitLabel, p.PlanId, b.DependentCovered, eb.TaxStatusId, ts.TaxStatusLabel 
  990. FROM EmployeeBenefit eb 
  991. JOIN Benefit b ON b.BenefitId = eb.BenefitId 
  992. JOIN Plans p ON p.PlanId = eb.PlanId 
  993. JOIN TaxStatus ts ON ts.TaxStatusId = eb.TaxStatusId 
  994. WHERE eb.EmployeeId = @lngEmployeeId
  995. AND eb.BenefitId = @lngBenefitId
  996.  
  997. GO
  998.  
  999. /****** Object:  Stored Procedure dbo.sp_GetTotalCost    Script Date: 10/18/97 12:03:59 PM ******/
  1000.  
  1001. /****** Object:  Stored Procedure dbo.sp_GetTotalCost    Script Date: 9/28/97 12:08:30 PM ******/
  1002. CREATE PROCEDURE sp_GetTotalCost (@lngEmployeeId int, @intBenefitYear int, @lngTaxStatusId int)AS
  1003.  
  1004. SELECT Sum(p.PlanCost) as TotalCost 
  1005. FROM EmployeeBenefit eb, Benefit b, 
  1006. Plans p
  1007. WHERE eb.BenefitId = b.BenefitId 
  1008. AND eb.PlanId = p.PlanId 
  1009. AND eb.EmployeeId = @lngEmployeeId 
  1010. AND b.BenefitYear = @intBenefitYear 
  1011. AND eb.TaxStatusId = @lngTaxStatusId
  1012.  
  1013. GO
  1014.  
  1015. /****** Object:  Stored Procedure dbo.sp_GetTotalCredits    Script Date: 10/18/97 12:03:59 PM ******/
  1016.  
  1017. /****** Object:  Stored Procedure dbo.sp_GetTotalCredits    Script Date: 9/28/97 12:08:30 PM ******/
  1018. CREATE PROCEDURE sp_GetTotalCredits (@lngEmployeeId int, @intBenefitYear int) AS
  1019. SELECT Sum(eb.CreditAmount) as TotalCredits 
  1020. FROM EmployeeBenefit eb, Benefit b 
  1021. WHERE eb.EmployeeId = @lngEmployeeId
  1022. AND b.BenefitYear = @intBenefitYear
  1023. AND b.BenefitId = eb.BenefitId
  1024.  
  1025. GO
  1026.  
  1027. /****** Object:  Stored Procedure dbo.sp_PlanField    Script Date: 10/18/97 12:03:59 PM ******/
  1028.  
  1029. /****** Object:  Stored Procedure dbo.sp_PlanField    Script Date: 9/28/97 12:08:30 PM ******/
  1030. CREATE PROCEDURE sp_PlanField (@lngPlanId int) AS
  1031. SELECT f.FieldLabel, pf.FieldValue 
  1032. FROM Plans p, PlanField pf, 
  1033. Field f 
  1034. WHERE pf.PlanId = p.PlanId 
  1035. AND pf.FieldId = f.FieldId 
  1036. AND p.PlanId = @lngPlanId 
  1037. ORDER BY pf.FieldRank
  1038.  
  1039. GO
  1040.  
  1041. /****** Object:  Stored Procedure dbo.sp_PlanInfo    Script Date: 10/18/97 12:03:59 PM ******/
  1042.  
  1043. /****** Object:  Stored Procedure dbo.sp_PlanInfo    Script Date: 9/28/97 12:08:30 PM ******/
  1044. CREATE PROCEDURE sp_PlanInfo (@lngBenefitId int, @lngPlanId int) AS
  1045. SELECT p.PlanLabel, p.PlanDesc, p.PlanCost, 
  1046. p.PhysicianRequired, bp.PlanRank 
  1047. FROM Plans p 
  1048. JOIN BenefitPlan bp ON bp.BenefitId = @lngBenefitId 
  1049. AND bp.PlanId = p.PlanId 
  1050. WHERE p.PlanId = @lngPlanId
  1051.  
  1052. GO
  1053.  
  1054. /****** Object:  Stored Procedure dbo.sp_PlanList    Script Date: 10/18/97 12:03:59 PM ******/
  1055.  
  1056. /****** Object:  Stored Procedure dbo.sp_PlanList    Script Date: 9/28/97 12:08:30 PM ******/
  1057. CREATE PROCEDURE sp_PlanList (@lngBenefitId int) AS
  1058. SELECT p.PlanId, p.PlanLabel, bp.PlanRank 
  1059. FROM Benefit b, BenefitPlan bp, Plans p 
  1060. WHERE p.PlanId = bp.PlanId 
  1061. AND bp.BenefitId = b.BenefitId 
  1062. AND b.BenefitId = @lngBenefitId 
  1063. ORDER BY bp.PlanRank
  1064.  
  1065. GO
  1066.  
  1067. /****** Object:  Stored Procedure dbo.sp_SummaryForID    Script Date: 10/18/97 12:03:59 PM ******/
  1068.  
  1069. /****** Object:  Stored Procedure dbo.sp_SummaryForID    Script Date: 9/28/97 12:08:30 PM ******/
  1070. CREATE PROCEDURE sp_SummaryForID (@lngEmployeeId int, @intBenefitYear int) AS
  1071. SELECT b.BenefitId, b.BenefitLabel, b.DetailTemplate, 
  1072. p.PlanLabel, p.PlanCost, ts.TaxStatusLabel 
  1073. FROM Benefit b 
  1074. LEFT OUTER JOIN EmployeeBenefit eb ON eb.BenefitId = b.BenefitId 
  1075. AND eb.EmployeeId = @lngEmployeeId 
  1076. LEFT OUTER JOIN Plans p ON p.PlanId = eb.PlanId 
  1077. LEFT OUTER JOIN TaxStatus ts ON ts.TaxStatusId = eb.TaxStatusId 
  1078. WHERE b.BenefitYear = @intBenefitYear 
  1079. ORDER BY b.BenefitRank
  1080.  
  1081. GO
  1082.  
  1083. /****** Object:  Stored Procedure dbo.sp_TaxStatusList    Script Date: 10/18/97 12:03:59 PM ******/
  1084.  
  1085. /****** Object:  Stored Procedure dbo.sp_TaxStatusList    Script Date: 9/28/97 12:08:30 PM ******/
  1086. CREATE PROCEDURE sp_TaxStatusList (@lngBenefitId int) AS
  1087. SELECT ts.TaxStatusId, ts.TaxStatusLabel, bts.TaxDefault 
  1088. FROM BenefitTaxStatus bts, TaxStatus ts 
  1089. WHERE ts.TaxStatusId = bts.TaxStatusId 
  1090. AND bts.BenefitId = @lngBenefitId 
  1091. ORDER BY ts.TaxStatusLabel
  1092.  
  1093. GO
  1094.  
  1095. /****** Object:  Stored Procedure dbo.sp_Update    Script Date: 10/18/97 12:03:59 PM ******/
  1096.  
  1097. /****** Object:  Stored Procedure dbo.sp_Update    Script Date: 9/28/97 12:08:30 PM ******/
  1098. CREATE PROCEDURE sp_Update (@lngPlanId int, @lngTaxStatusId int, @lngEmployeeId int, @lngBenefitId int) AS
  1099. UPDATE EmployeeBenefit
  1100. SET PlanId = @lngPlanId, TaxStatusId = @lngTaxStatusId
  1101. WHERE EmployeeId = @lngEmployeeId
  1102. AND BenefitId = @lngBenefitId
  1103.  
  1104. GO
  1105.  
  1106. /****** Object:  Stored Procedure dbo.sp_AddEBD    Script Date: 10/18/97 12:03:59 PM ******/
  1107.  
  1108. /****** Object:  Stored Procedure dbo.sp_AddEBD    Script Date: 9/28/97 12:08:30 PM ******/
  1109. CREATE PROCEDURE sp_AddEBD (@lngEmployeeId int, @lngBenefitId int, @lngDependentId int, @intEBDStatusId int) AS
  1110. INSERT INTO EmployeeBenefitDependent 
  1111. (EmployeeId, BenefitId, DependentId, EBDStatusId) 
  1112. VALUES (@lngEmployeeId, @lngBenefitId, @lngDependentId, @intEBDStatusId)
  1113.  
  1114. GO
  1115.  
  1116. /****** Object:  Stored Procedure dbo.sp_InactivateDependents    Script Date: 10/18/97 12:03:59 PM ******/
  1117.  
  1118. /****** Object:  Stored Procedure dbo.sp_InactivateDependents    Script Date: 9/28/97 12:08:30 PM ******/
  1119. CREATE PROCEDURE sp_InactivateDependents (@lngEmployeeId int, @lngBenefitId int) AS
  1120. UPDATE EmployeeBenefitDependent
  1121. SET EBDStatusId = 2 
  1122. WHERE EmployeeId = @lngEmployeeId
  1123. AND BenefitId = @lngBenefitId
  1124.  
  1125. GO
  1126.  
  1127. /****** Object:  Stored Procedure dbo.sp_ListCoveredPersons    Script Date: 10/18/97 12:03:59 PM ******/
  1128.  
  1129. /****** Object:  Stored Procedure dbo.sp_ListCoveredPersons    Script Date: 9/28/97 12:08:30 PM ******/
  1130. CREATE PROCEDURE sp_ListCoveredPersons (@lngEmployeeId int, @lngBenefitId int) AS
  1131. SELECT dt.DependentTypeLabel, d.FirstName, d.LastName, ph.PhysicianLabel 
  1132. FROM EmployeeBenefitDependent ebd, 
  1133. EmployeeDependent ed, Physician ph, 
  1134. DependentType dt, Dependent d 
  1135. WHERE dt.DependentTypeId = ed.DependentTypeId 
  1136. AND ed.DependentId = ebd.DependentId 
  1137. AND ed.EmployeeId = ebd.EmployeeId 
  1138. AND d.DependentId = ebd.DependentId 
  1139. AND ebd.PhysicianId *= ph.PhysicianId 
  1140. AND ebd.EmployeeId = @lngEmployeeId 
  1141. AND ebd.BenefitId = @lngBenefitId
  1142. ORDER BY dt.DependentTypeRank
  1143.  
  1144. GO
  1145.  
  1146. /****** Object:  Stored Procedure dbo.sp_ListDependents    Script Date: 10/18/97 12:03:59 PM ******/
  1147.  
  1148. /****** Object:  Stored Procedure dbo.sp_ListDependents    Script Date: 9/28/97 12:08:30 PM ******/
  1149. CREATE PROCEDURE sp_ListDependents (@lngEmployeeId int, @lngBenefitId int) AS
  1150. SELECT ed.DependentId, ebd.EBDStatusId, dt.DependentTypeLabel, d.LastName, 
  1151. d.FirstName , ebd.PhysicianId 
  1152. FROM EmployeeDependent ed 
  1153. JOIN DependentType dt 
  1154. ON dt.DependentTypeId = ed.DependentTypeId 
  1155. JOIN EmployeeBenefitDependent ebd 
  1156. ON ebd.EmployeeId = ed.EmployeeId 
  1157. AND ebd.DependentId = ed.DependentId 
  1158. AND ebd.BenefitId = @lngBenefitId 
  1159. JOIN Dependent d 
  1160. ON d.DependentId = ed.DependentId 
  1161. WHERE ed.EmployeeId = @lngEmployeeId 
  1162. AND ed.DependentStatusId = 1 
  1163. ORDER BY dt.DependentTypeRank
  1164.  
  1165. GO
  1166.  
  1167. /****** Object:  Stored Procedure dbo.sp_SaveDependents    Script Date: 10/18/97 12:03:59 PM ******/
  1168.  
  1169. /****** Object:  Stored Procedure dbo.sp_SaveDependents    Script Date: 9/28/97 12:08:30 PM ******/
  1170. CREATE PROCEDURE sp_SaveDependents (@lngPhysicianId int, @lngEmployeeId int, @lngBenefitId int, @lngDependentId int) AS
  1171. UPDATE EmployeeBenefitDependent 
  1172. SET EBDStatusId = 1,
  1173. PhysicianId = @lngPhysicianId 
  1174. WHERE EmployeeId = @lngEmployeeId
  1175. AND BenefitId = @lngBenefitId
  1176. AND DependentId = @lngDependentId
  1177.  
  1178. GO
  1179.  
  1180.