cp_policy_in_group answers the group-user access question by counting employer-group memberships for a policy. The retrieved body first decides whether the request should use parent-group, group-only, or group-plus-chapter logic, then returns a howMany count for the selected branch.
Each branch returns count(*); the chapter filter is added only when @UseSql = 3.
BR-VP-046 Policy-in-group membership chooses a parent, group, or group-and-chapter query path¶
Field
Value
Statement
The membership-check procedure selects a parent-group, group-only, or group-plus-chapter query path by inspecting the supplied group key and whether a chapter string was supplied.
Trigger
cp_policy_in_group executes.
Enforcement
The procedure probes WCS_EMPLOYER_GROUP to set @UseSql, then runs the matching if @UseSql = ...SELECT count(*) block.
Outcome
Only one membership-count query runs for the supplied key and chapter combination.
Source
SQL Server retrieval JSON: C:\Users\chrfre\AppData\Local\Temp\oracle-sources\cp_policy_in_group.json
When deciding whether the supplied key should be treated as a regular group key, the procedure excludes employer-group rows whose GRP_TYP_CD = 'PARNT'.
Trigger
cp_policy_in_group evaluates the group-key branch.
Enforcement
The grp_assn_key probe applies AND grp_typ_cd <> 'PARNT' before setting @UseSql = 2.
Outcome
Parent-group-only keys are not misclassified as ordinary group keys.
Source
SQL Server retrieval JSON: C:\Users\chrfre\AppData\Local\Temp\oracle-sources\cp_policy_in_group.json
BR-VP-048 Policy-in-group returns membership as a count and applies chapter filtering only in branch three¶
Field
Value
Statement
The membership-check procedure returns a numeric howMany count for every branch, and the chapter filter applies only in the group-plus-chapter branch.
Trigger
cp_policy_in_group executes.
Enforcement
Each branch selects count(*) howMany, while only the @UseSql = 3 branch adds GroupCheck.chapCd like rtrim(@chapters).
Outcome
Callers receive a count-based membership answer, with chapter filtering limited to the explicit chapter branch.
Source
SQL Server retrieval JSON: C:\Users\chrfre\AppData\Local\Temp\oracle-sources\cp_policy_in_group.json
CreateProceduredbo.cp_policy_in_group-- LIST PARAMETERS@groupIDvarchar(10),@chaptersvarchar(10),@policyNumintAS/*--------------------------------------------------------------------------------Procedure Name: cp_policy_in_groupDate Written: 8/21/2001Author: Melinda Hillier (SAIF)Installation: SAIF CorporationSource File Name: cp_policy_in_groupDescription: If the policy is a member of the group return a countModifications: 05/09/02 - Removed the where condition for plcy_eff_dt to be within 4 years of today's date. 08/13/2003 - JERTOD: replaced EIS_SAIF_EMPR with VW_EIS_SAIF_EMPR 09/17/2003 - JERTOD: replaced VW_EIS_SAIF_EMPR with WCS_Policy; changed ALTER to CREATE proc ALTER Procedure dbo.cp_policy_in_group @groupNum int, @chapters varchar(10), @policyNum int 12/01/2004 - JERTOD: changed the proc to eliminate the need to use a group pms number as a paramter changed @groupNum parameter to a string for @groupID left the old select in. DELETE IT AT NEXT MODIFICATION 02/27/2006 - JERTOD: updated for BDS Release 10 08/21/2013 - JERTOD: changed @UseSql triage to correctly evaluate group parents. they now have an extra row in the group table 8/21/2013: JERTOD changed the @GroupLevel evaluation to exclude group parents from being evaluated to a group--------------------------------------------------------------------------------*/setnocountonSETTRANSACTIONISOLATIONLEVELREADUNCOMMITTED;DECLARE@UseSqlintset@UseSql=2/* END THE PROCEDURE */------------------------------------------------RELEASE 10/************************//* INSPECT THE GROUPKEYCODE PASSED INTO PROC *//************************/--if we find the GroupKeyCode in the parent column we'll do the parent selectif(selectcount(distinctparent_grp)fromeis_prod.dbo.wcs_employer_groupwhere((parent_grp=rtrim(@groupID))and(rtrim(@groupID)!='')))>0beginset@UseSql=1end--if we find the GroupKeyCode in the group column then we'll do the group selectif(selectcount(distinctgrp_assn_key)fromeis_prod.dbo.wcs_employer_groupwheregrp_assn_key=rtrim(@groupID)ANDgrp_typ_cd<>'PARNT')>0beginset@UseSql=2end--unless the group key has only one entry, then we'll use its chapter code--to discriminate it from the other keys --if it has more than one distinct chapter then we'll check all chapters--unless the chapter code is specified/*if(select COUNT(DISTINCT WEG.pms_grp_sub_cd) from eis_prod.dbo.WCS_EMPLOYER_GROUP WEG where (WEG.grp_assn_key=@groupID) and (not weg.pms_grp_num is null))=1begin set @chapters=(select DISTINCT WEG.pms_grp_sub_cd from eis_prod.dbo.WCS_EMPLOYER_GROUP WEG where (WEG.grp_assn_key=@groupID) and (not weg.pms_grp_num is null)) set @UseSql=3end*/--if its a group and it has a chapter code we'll do the group chapter thingyif(@UseSql=2)and(rtrim(@chapters)>'')beginset@UseSql=3end/************************//* GROUP PARENT CODE PASSED IN *//************************/if@UseSql=1SELECT--@UseSql testnum,count(*)howMany--,@UseSql whichOneFROM(selectwGrp.parent_grpgKeyfromEIS_PROD.dbo.VW_WCS_POLICY_NO_SUBwPoljoinEIS_PROD.dbo.VW_WCS_POLICY_PD_NO_SUBpolPeronwPol.plcy_num=polPer.plcy_numandpolPer.MOST_RECENT_PP_COV_FL='Y'joinEIS_PROD.dbo.WCS_POLICY_PERIOD_SUMpPdSumonpPdSum.plcy_pd_id=polPer.plcy_pd_idjoinEIS_PROD.dbo.WCS_EMPLOYER_GROUPwGrponwGrp.EMP_GRP_ID=pPdSum.EMP_GRP_IDwherewPol.plcy_num=@policyNum)asGroupCheckwhereGroupCheck.gKey=@GroupId/************************//* GROUP WITHOUT A SPECIFIC CHAPTER CODE *//************************/if@UseSql=2select--@UseSql testnum,count(*)howManyFROM(selectwGrp.grp_assn_keygKeyfromEIS_PROD.dbo.VW_WCS_POLICY_NO_SUBwPoljoinEIS_PROD.dbo.VW_WCS_POLICY_PD_NO_SUBpolPeronwPol.plcy_num=polPer.plcy_numandpolPer.MOST_RECENT_PP_COV_FL='Y'joinEIS_PROD.dbo.WCS_POLICY_PERIOD_SUMpPdSumonpPdSum.plcy_pd_id=polPer.plcy_pd_idjoinEIS_PROD.dbo.WCS_EMPLOYER_GROUPwGrponwGrp.EMP_GRP_ID=pPdSum.EMP_GRP_IDwherewPol.plcy_num=@policyNum)asGroupCheckWHEREGroupCheck.gKey=@GroupId/************************//* GROUP WITH A SPECIFIC CHAPTER *//************************/if@UseSql=3select--@UseSql testnum,count(*)howManyFROM(selectwGrp.grp_assn_keygKey,wGrp.chap_cdchapCd,wGrp.emp_grp_idfromEIS_PROD.dbo.VW_WCS_POLICY_NO_SUBwPoljoinEIS_PROD.dbo.VW_WCS_POLICY_PD_NO_SUBpolPeronwPol.plcy_num=polPer.plcy_numandpolPer.MOST_RECENT_PP_COV_FL='Y'joinEIS_PROD.dbo.WCS_POLICY_PERIOD_SUMpPdSumonpPdSum.plcy_pd_id=polPer.plcy_pd_idjoinEIS_PROD.dbo.WCS_EMPLOYER_GROUPwGrponwGrp.EMP_GRP_ID=pPdSum.EMP_GRP_IDwherewPol.plcy_num=@policyNum)asGroupCheckWHEREGroupCheck.gKey=@GroupIdandGroupCheck.chapCdlikertrim(@chapters)/* END THE PROCEDURE */Return