<commit_before><commit_msg>PR-3851 Modified stored proc sp_GetFacility<commit_after>USE [Reach_Dev]

GO

/****** Object:  StoredProcedure [prsystem].[sp_GetFacility]    Script Date: 3/16/2016 12:34:45 PM ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER PROCEDURE [prsystem].[sp_GetFacility]

	@UserName nvarchar(50),

	@VisnId int = NULL

AS

BEGIN

	-- SET NOCOUNT ON added to prevent extra result sets from

	-- interfering with SELECT statements.

	 SET NOCOUNT ON;

	 DECLARE @UserRole AS INT

	 

	 SELECT @UserRole = UserRole FROM prsystem.Users

	 WHERE UserName = @UserName



	 IF @UserRole = 6

	 BEGIN

		 SELECT [TotalPatients] AS Total,

					[AtRisk],

					[VISN],

					[STA3N],

					[VAMC_Name],

					[StateAbbr]

		 FROM [dbo].[vw_FacilityRoster]

		 WHERE STA3N IN (SELECT FacilityID FROM prsystem.UserFacilityMap uf

		 INNER JOIN prsystem.Users u

		 on uf.UserID = u.UserID

		 WHERE u.UserName = @UserName)

		 ORDER BY STA3N ASC;

	 END

	 ELSE

	 BEGIN

		SELECT [TotalPatients] AS Total,

					[AtRisk],

					[VISN],

					[STA3N],

					[VAMC_Name],

					[StateAbbr]

			FROM [dbo].[vw_FacilityRoster]

			WHERE (@VisnId IS NULL OR (VISN = @VisnId))

			ORDER BY STA3N ASC;

	 END



END




{'fraction_non_alphanumeric': 0.5333611342785655, 'fraction_numerical': 0.010425354462051709, 'mean_word_length': 6.404320987654321, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4032237', 'n_tokens_mistral': 2344, 'n_tokens_neox': 2340, 'n_words': 126}