SELECT
  prs.Nama_Perusahaan,
  ck.submit_date,
  ck.no_klaim AS Claim_Register,
  karyawan.Nama AS Nama_Karyawan,
  pst.Nama AS Nama_Pasien,
  pst.No_Peserta,
  ck.tgl_berobat,
  cfah.diagnosis_code,
  --cfah.diagnosis_desc,
  CASE
    WHEN cfah.diagnosis_desc='' THEN diag.Diagnosis1
    ELSE cfah.diagnosis_desc
  END AS diagnosis_desc,
  ck.status,
  kp.No_Klaim,
  kp.Jml_Diajukan,
  kp.Jml_Ditolak,
  kp.Jml_Dibayar,
  ntm.No_Note,
  nlm.Tgl_Bayar,
  ck.remarks
FROM
  dbo.custport_klaim AS ck INNER JOIN
  dbo.Polis_Asuransi AS pa ON ck.no_proposal = pa.No_Proposal INNER JOIN
  dbo.Perusahaan AS prs ON pa.No_Prs = prs.No_Prs INNER JOIN
  dbo.Peserta AS pst ON pa.No_Proposal = pst.No_Proposal AND ck.no_peserta = pst.No_Peserta INNER JOIN
  dbo.Peserta AS karyawan ON pa.No_Proposal = pst.No_Proposal AND LEFT(ck.no_peserta,10)+'-0' = karyawan.No_Peserta LEFT JOIN
  dbo.Klaim_Peserta AS kp ON ck.core_no_klaim = kp.No_Klaim LEFT JOIN
  dbo.Klaim_Ref_Master AS krm ON kp.No_Klaim = krm.No_Klaim INNER JOIN
  dbo.Note_Terbit_Master AS ntm ON krm.No_Ref = ntm.No_Ref LEFT JOIN
  dbo.Note_Lunas_Master AS nlm ON ntm.No_Ref = nlm.No_Ref LEFT JOIN
  dbo.custport_from_aai_header AS cfah ON ck.id_from_aai_header = cfah.id_from_aai_header LEFT JOIN
  dbo.Diagnosa AS diag ON cfah.diagnosis_code = diag.Kode
WHERE
  ck.submit_date >= '2016-09-01'
  AND ck.submit_date < '2016-09-16'
ORDER BY
  ck.submit_date

SELECT * FROM dbo.custport_klaim WHERE submit_date >= '2016-09-16' AND submit_date < '2016-10-01'
SELECT * FROM dbo.custport_from_aai_header