SELECT TOP 20 
      pst.Nama AS Nama_Pasien,
      --m.No_Pasien,
      pst.No_Peserta,
      prs.Nama_Perusahaan,
      rs.Nama AS Nama_Provider,
      dbo.func_fixed_date(m.Tgl_Masuk) AS Tgl_Masuk,
      dbo.func_fixed_date(m.Tgl_Lapor) AS Tgl_Lapor,
      'No. '+dbo.func_RataKananSpace(m.No_Surat, '0', 4)+'/HCL/'+dbo.func_GetRomawi(MONTH(m.Tgl_Buat_Surat))+'/'+CAST(YEAR(m.Tgl_Buat_Surat) AS varchar(4)) AS No_Surat,
      --
      CASE m.Status WHEN 'I' THEN m.Tgl_Buat_Surat END AS 'Tgl_Surat_Penjaminan',
      CASE m.Status WHEN 'E' THEN m.Tgl_Buat_Surat END AS 'Tgl_Surat_Penundaan',
      CASE m.Status WHEN 'C' THEN m.Tgl_Buat_Surat END AS 'Tgl_Surat_Penolakan',
      --m.Tgl_Buat_Surat,
      --m.Kode_Diagnosa,
      diag.Diagnosis1,
      m.Alasan_Penolakan,
      --m.Acc_By,
      usr.Nama AS Dokter

FROM  dbo.Medical_Record m INNER JOIN
      dbo.Peserta pst ON m.No_Peserta = pst.No_Peserta AND m.No_Proposal = pst.No_Proposal INNER JOIN
      dbo.Provider rs ON m.Kode_Provider = rs.IDI INNER JOIN
      dbo.Polis_Asuransi pa ON m.No_Proposal = pa.No_Proposal INNER JOIN
      dbo.Perusahaan prs ON pa.No_Prs = prs.No_Prs LEFT JOIN
      dbo.Diagnosa diag ON m.Kode_Diagnosa = diag.Kode LEFT JOIN
      dbo.gUser_Name usr ON m.Acc_By = usr.Id_User

WHERE (prs.No_Prs NOT IN ('2012.2254','2012.2256'))  -- selain Mattel


--SELECT TOP 10 * FROM Diagnosa
--SELECT TOP 100 * FROM Medical_Record
--SELECT * FROM gUser_Name
