SELECT
	DATE_FORMAT(a.created_date, %Y-%m-%d ) as tanggal_pendaftaran,
	UPPER(b.nama_depan) AS nama_pasien,
	b.no_rekam_medis,
	a.no_sEP,
	UPPER(b.jenis_kelamin) as jenis_kelamin,
	CONCAT( TIMESTAMPDIFF( YEAR, b.tgl_lahir, CURDATE()),   tahun  ) AS usia,
	UPPER(c.nama_cluster) as poli,
	a.tipe_pembayaran
FROM
	pendaftaran a
	JOIN m_penduduk b ON a.no_rekam_medis = b.no_rekam_medis
	JOIN cluster c ON a.id_cluster = c.id_cluster
WHERE
	a.status_pelayanan =  done  AND
	YEAR(a.created_date) = YEAR(CURDATE())
ORDER BY
	a.created_date DESC