-- step 1 ----------------------------------------------
USE [GrpInsurance]
GO

DECLARE	@return_value int

EXEC	@return_value = [dbo].[proc_CreateKlaimToAdMedika]
		@TglBuat1 = '2014-10-01',
		@TglBuat2 = '2014-10-04',
		@TglBuat1Ya = 1,
		@TglBuat2Ya = 1,
		@NoKlaim = '',
		@CreateBy = 'SUP'

SELECT	'Return Value' = @return_value

GO

-- step 2 ----------------------------------------------
USE [GrpInsurance]
GO

DECLARE	@return_value int

EXEC	@return_value = [dbo].[proc_CreateKlaimToAdMedikaText]
		@TglProses1 = '2014-10-01',
		@TglProses2 = '2014-10-04',
		@PisahYa = 0,
		@PolisYa = 0,
		@Status = 'G',
		@TglProses1Ya = 1,
		@TglProses2Ya = 1

SELECT	'Return Value' = @return_value

GO
-- hasilnya ada di --------------------------------------
-- header:
SELECT Nama_Payor, Nama_File FROM TmpInsurance.dbo.Tmp_KlaimTo_Header
GROUP BY Nama_Payor, Nama_File
     
SELECT
    Member_Id,
    Claim_Type,
    Claim_Ref,
    Policy_No,
    Member_Name,
    Coverage_Type,
    Provider_Code,
    Admission_Date,
    Discharge_Date,
    Duration_Days,
    Claim_Process_Status,
    App_Date,
    App_By,
    Diagnosis_Code,
    Diagnosis_Desc,
    Plan_Id,
    Tot_Amt_Incurred,
    Tot_Amt_Approved,
    Tot_Amt_Disapproved,
    AdMedika_Klaim_Id,
    Ref_No
FROM TmpInsurance.dbo.Tmp_KlaimTo_Header
WHERE
    (Nama_Payor = '') AND (Nama_File = '')  -- Nama_Payor & Nama_File menggunakan hasil query diatas



SELECT
    Claim_Ref,
    Member_Id,
    Benefit_Code,
    Benefit_Desc,
    Benefit_Limit,
    Amt_Incurred,
    Amt_Approved,
    Amt_Not_Approved,
    Coverage_Type,
    Plan_Id,
    AdMedika_Klaim_Id,
    Ref_No
FROM
    TmpInsurance.dbo.Tmp_KlaimTo_Detail
WHERE
    (Nama_Payor = '') AND (Nama_File = '')  -- Nama_Payor & Nama_File menggunakan hasil query diatas