select 
	mp.id as id_id, mp.nomr as id_nomr, mp.noktp as id_noktp, mp.no_kartu as id_nomorkartu, mp.sim as id_sim, mp.paspor as id_paspor,
	mp.title as nm_title, mp.nama as nm_nama, 
	mp.no_hp as te_teleponhp, mp.notelprumah1 as te_teleponrumah1, mp.notelprumah2 as te_teleponrumah2, mp.notelpkantor as te_telkantor, 
	mp.tgllahir as bd_tgllahir,
	mp.jeniskelamin as jk_jeniskelamin,
	mp.alamat as ad_alamat, mp.alamat_ktp as ad_alamatktp, mp.txt_kelurahan as ad_kelurahan, 
	mp.txt_kecamatan as ad_kecamatan, mp.txt_kelurahan as ad_kelurahan, mp.txt_kota as ad_kota, mp.txt_provinsi as ad_provinsi,
	mp.kdkecamatan as adid_kecamatan, mp.kelurahan as adid_kelurahan, mp.kota as adid_kota, mp.kdprovinsi as adid_provinsi,
	mp.penanggungjawab_nama as ctpj_nama, mp.penanggungjawab_hubungan as ctpj_hubungan, mp.penanggungjawab_alamat as ctpj_alamat, 
	mp.penanggungjawab_phone as ctpj_telepon, mp.nama_ayah as ctpj_namaayah, mp.nama_ibu as ctpj_namaayah, 
	mp.pendidikan_ayah as ctpjid_pendidikanayah, mpp2.nama_pendidikan as ctpj_pendidikanayah,
	mp.pendidikan_ibu as ctpj_pendidikanibu, mpp3.nama_pendidikan as ctpj_pendidikanibu,
	mp.ktp_file as pt_ktpfile, mp.kk_file as pt_kkfile, 
	mp.bahasa as com_bahasa,
	mp.pendidikan as exid_pendidikan, mpp.nama_pendidikan as ex_pendidikan, mp.disabilitas as ex_disabiltas, mp.kebangsaan as ex_kebangsaan, mp.suku as ex_suku, mp.agama as exid_agama, map.nama_agama as ex_agama, mp.created_at as ex_createat, mp.updated_at as ex_updateat
	from m_pasien mp 
	join m_pendidikan_pasien mpp on mp.pendidikan = mpp.id_pendidikan
	join m_agama_pasien map on mp.agama = map.id_agama 
	join m_pendidikan_pasien mpp2 on cast(mp.pendidikan_ayah as int8) = mpp2.id_pendidikan
	left join m_pendidikan_pasien mpp3 on cast(mp.pendidikan_ibu as int8) = mpp3.id_pendidikan