USE [AJK]
GO

/****** Object:  StoredProcedure [dbo].[proc_custport_claim_document]    Script Date: 20/07/2018 13:49:20 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO



-- created by Pribadi Pamungkas. 2018-07-11.
ALTER PROCEDURE [dbo].[proc_custport_claim_document]
@pi_claim_type_code VARCHAR(50) --tambahan
AS
BEGIN

	SET NOCOUNT ON;-- SET NOCOUNT ON added to prevent extra result sets from interfering with SELECT statements.

	DECLARE @v_guid VARCHAR(50);

	SELECT @v_guid = REPLACE(NEWID(),'-','');

	SELECT
		md.document_code,
		md.description,
		mcd.is_mandatory,
		mcd.claim_type_code,
		mcd.claim_document_code,
		mcd.is_active,
		@v_guid + '_' + md.document_code AS guid,
		@v_guid AS tmp_guid
	FROM
		custport_m_claim_document AS mcd INNER JOIN
		custport_m_document AS md ON mcd.document_code = md.document_code
	WHERE
		mcd.is_active = 1
		AND md.is_active = 1
		AND claim_type_code = @pi_claim_type_code --tambahan
	ORDER BY
		mcd.is_mandatory DESC,
		md.description ASC

END


GO


