DELIMITER $$

ALTER ALGORITHM=UNDEFINED DEFINER=`khanza_ip`@`%` SQL SECURITY DEFINER VIEW `kamar_inap_v` AS (
SELECT
  IF(TO_DAYS(`kamar_inap`.`tgl_keluar`) - TO_DAYS(`kamar_inap`.`tgl_masuk`) = '0','1',TO_DAYS(`kamar_inap`.`tgl_keluar`) - TO_DAYS(`kamar_inap`.`tgl_masuk`)) AS `lama_rawat`,
  `kamar_inap`.`lama`           AS `hari_rawat`,
  `kamar_inap`.`no_rawat`       AS `no_rawat`,
  `kamar_inap`.`kd_kamar`       AS `kd_kamar`,
  `kamar_inap`.`trf_kamar`      AS `trf_kamar`,
  `kamar_inap`.`diagnosa_awal`  AS `diagnosa_awal`,
  `kamar_inap`.`diagnosa_akhir` AS `diagnosa_akhir`,
  `kamar_inap`.`tgl_masuk`      AS `tgl_masuk`,
  `kamar_inap`.`jam_masuk`      AS `jam_masuk`,
  `kamar_inap`.`tgl_keluar`     AS `tgl_keluar`,
  `kamar_inap`.`jam_keluar`     AS `jam_keluar`,
  `kamar_inap`.`ttl_biaya`      AS `ttl_biaya`,
  `kamar_inap`.`stts_pulang`    AS `stts_pulang`
FROM `kamar_inap`)$$

DELIMITER ;