|
chrisww2
Starting Member
4 Posts |
Posted - 2005-10-25 : 11:54:18
|
| Please help if you can:Here is a brief description from the dev document:Purpose: Provide a flag for the generation procedures to use to remove records from batches that do not meet the minimum requirements as defined by the campaign. Examples would be valid Gender, on drug question, and age validation. Generation procedures will require a ‘1’ for generation to take place. This will also be used for reporting purposes.The eligible flag state is determined at the campaign level by having all required business rules to receive communications as having been met. A daily maintenance SPROC for each campaign will be run which will check all of the information on participants which has been updated in the last day and set their Eligibility status accordingly.Note 1: The Eligible flag is channel independent.Note 2: If someone was eligible at one time then they could have received 1 or more communications and could be anywhere in the stream.Participant TableCreate a new column in Participants table named “Campaign_Eligibility” as a small int. NULL (default) = Unknown: required data is missing from the profile such as required questions or email address.0 = Ineligible: participant has specific information that makes them ineligible such as an off drug question.1 = Eligible: participant meets all of the minimum user data requirements and business rules necessary to be included in the generation of the first communication for a specific campaign, not to include opt status. This does include required demographic data and survey questions. 2 = Complete: participant has received all communications for a specific campaign and has graduated or finished the campaign.Create a new column in Participants table named Date_Eligible as Datetime. This is set the first time when the Campaign_Eligibility state changes from NULL or 0 to 1.Create a new column in Participants table named Date_Became_Ineligible as Datetime. This date is set when the Campaign_Eligibility state changes from NULL, 1, 2 to 0 for ineligible.Create a new column in Participants table named Date_Campaign_Finished as Datetime. This date is set when the Campaign_Eligibility state changes from NULL, 0, 1, to 2.Different States for the Campaign_Eligibility Column:THIS IS WHERE I NEED SOME ASSISTANCE. I NEED HELP DETERMINING THE LOGIC OF THE TABLE BELOW.Three columns here: Initial Value New value Allowed?Null 0 YesNull 1 YesNull 2 Yes0 Null No0 1 Yes*0 2 Yes**1 Null No1 0 Yes1 2 Yes2 Null No2 0 No2 1 No*This may happen but must be evaluated by campaign. It may require that no communications have been sent yet and/or a reset of enrollment date may need to occur.**Only if a participant has received a prior communication and the final date has passed.Here is the script that this needs to be added to. I am not the greatest at programming in thsi stuff so any help or guidance is apperciated:/************************************************** ************************/-- ---- Returns a table of Campaign_Eligibility, Date_Eligible, Date_Became_Ineligible,-- Date_Campaign_Finished ---- 0 for non-qualified-- 1 for qualified, eligibe participant; -- 2 for campaign complete-------- Transaction Mgt: None done by this procedure.---- Returns: boolean 1 for qualified, 0 if not qualified, 2 for graduated./************************************************** ************************/create function Eligibility_Test (@Campaign_ID smallint,@Person_ID int,@Todays_Date datetime)returns @Eligibility_Info table (Campaign_Eligibility smallint, Date_Eligible datetime, Date_Became_Ineligible datetime, Date_Campaign_Finished datetime) ASBEGINDeclare @Campaign_Eligibility smallintSelect @Campaign_Eligibility = CASE When pt.Mail_Date_Opt_In < DATEADD(dd, -180, @Todays_Date) Then 2When (Select Count(*)From Person p inner join participant pt on p.person_id = pt.person_idinner join Address a on p.person_id = a.person_idinner join participant_answers pa1 on p.person_id = pa1.person_idinner join participant_answers pa2 on p.person_id = pa2.person_idinner join participant_answers pa3 on p.person_id = pa3.person_idinner join participant_answers pa4 on p.person_id = pa4.person_idinner join participant_answers pa5 on p.person_id = pa5.person_idinner join participant_answers pa6 on p.person_id = pa6.person_idWhere pt.campaign_id = @Campaign_IDand p.person_id = @Person_IDand LEN(First_Name) > 0 -- First Name CheckAnd LEN(Last_Name) > 0 -- Last Name CheckAnd valid_address = 1 -- Mailing Address CheckAnd CASEWHEN dateadd(year, datediff (year, Date_Of_Birth, @Todays_Date), Date_Of_Birth) > @Todays_DateTHEN datediff (year, Date_Of_Birth, @Todays_Date) - 1ELSE datediff (year, Date_Of_Birth, @Todays_Date)END>= 18And Gender IN ('M', 'F') -- not accepting 'U' for BPSZAnd pa1.Answer_ID IN (1011, 1014, 1008) --Diovan, Diovan HCT, LotrelAnd ( pa2.Answer_ID IN (3042, 3043) -- DiovanOR pa2.Answer_ID IN (3044, 3045) -- Diovan HCTOR pa2.Answer_ID IN (3046, 3047)) -- LotrelAnd pa3.Answer_ID IN (3055, 3056, 3057, 3058, 3059, 3060) --ILOC/ELOCAnd pa4.Answer_ID IN (3062, 3063, 3064, 3065, 3066, 3067, 3068)And pa5.Answer_ID IN (3069, 3070, 3071, 3072, 3073, 3074, 3075)And pa6.Answer_ID IN (3076, 3077, 3078, 3079, 3080, 3081, 3082)and Comm_Track is not nulland Media_Status is not nulland Comm_Track != 'Online') = 1 Then 1 --EligibleElse 0EndFrom Person p inner join participant pt on p.person_id = pt.person_idWhere pt.campaign_id = @Campaign_IDand p.person_id = @Person_IDInsert @Eligibility_Info(Campaign_Eligibility) --initialize the temp tableValues (@Campaign_Eligibility)--now set the datesIf (Select Campaign_Eligibility From @Eligibility_Info) = 0BeginUpdate @Eligibility_Info Set Date_Became_Ineligible = @Todays_DateEndElse If (Select Campaign_Eligibility From @Eligibility_Info) = 1BeginUpdate @Eligibility_Info Set Date_Eligible = @Todays_DateEndElse If (Select Campaign_Eligibility From @Eligibility_Info) = 2BeginUpdate @Eligibility_Info Set Date_Campaign_Finished = @Todays_DateEnd--Select Campaign_Eligibility, Date_Eligible, Date_Became_Ineligible, Date_Campaign_Finished from @Eligibility_InfoReturnend/**** End of function Eligibility_Test ****/--Select * from Eligibility_Test (65, 228,'10/5/05')ANY HELP IS APPERCIATED!Thanks |
|