<?php
include('koneksi.php');
$mr=$la="";
$mr=$_POST['NoRM'];
//$la=$_POST['Tgl'];
//$sql="select * from patientmaster where mrno='$mr' and dob='$la'";
$sql="select MRNo,Patname,addr1, Phone,dob   from patientmaster where mrno='$mr' union all select MRNo,nama,addr1, telp,dob from daftar where mrno = '$mr'";
//$sql="select * from patientmaster where mrno='RL653778'";
//$sql="select * from patientmaster where mrno='$mr'";
//echo($_POST['NoRM']);
//echo($sql);
//$sql="select * from patientmaster where mrno='A1' ";
//echo("<script>alert('Anda Belum Terdaftar Sebagai Pasien Rumah Sakit NU Demak')</script>");	
//$result =  $koneksi->query($sql);
$result = sqlsrv_query($koneksi, $sql);
//$level=mysqli_num_rows($result);
$level=sqlsrv_num_rows($result);
//$r=mysqli_fetch_array($result);
$r=sqlsrv_fetch_array($result);
//echo($level);
//echo($result);
if ($level >= 0){
session_start();
isset($_SESSION['MRNo']);
isset($_SESSION['Patname']);
isset($_SESSION['addr1']);
isset($_SESSION['Phone']);
isset($_SESSION['dob']);
$_SESSION['MRNo'] = $r['MRNo'];
	//echo($r['Patname']);
$_SESSION['Patname'] = $r['Patname'];
	//echo($_SESSION['Patname']);
$_SESSION['addr1'] = $r['addr1'];
$_SESSION['Phone']= $r['Phone'];
$_SESSION['dob']= $r['dob'];
//header('location:Konfirm.php');
	echo("<script>location='Konfirmantrian.php'</script>");
}
else{
echo("<script>alert('Maaf Nomor Rekam Medik $mr Tidak Ditemukan. Pastikan Sudah Mengisi Nomor Rekam Medik Dengan Benar dan Lengkap')</script>");	
//header('location:index.php');
	//echo("<script>location='index.php'</script>");
	echo "<script>window.history.back()</script>";
}
?>