HIMS / views / process.php
process.php
Raw
<?php 

require_once '../library/config.php';
require_once '../library/functions.php';

$cmd = isset($_GET['cmd']) ? $_GET['cmd'] : '';

switch($cmd) {
	
	case 'register':
		registerPatient();
	break;
        
    case 'admission':
		admissionPatient();
	break;
        
    case 'discharge':
		dischargePatient();
	break;

	default :
	break;
}



function registerPatient() {
    $icnum 	= $_POST['icnum'];
    $name 	= $_POST['name'];
    $address 	= $_POST['address'];
    $gender 	= $_POST['gender'];
    $race 	= $_POST['race'];
    $nationality 	= $_POST['nationality'];
    $birthdate 	= $_POST['birthdate'];
    $telephone 	= $_POST['telephone'];
    $religion 	= $_POST['religion'];
    $marrital 	= $_POST['marrital'];
    $w_name 	= $_POST['w_name'];
    $relation 	= $_POST['relation'];
    $w_telephone 	= $_POST['w_telephone'];
    $w_address 	= $_POST['w_address'];
    $status 	= $_POST['status'];
    
    $refsource 	    ="";
    $admitdate 	    ="";
    $discipline 	="";
    $wad 	        ="";
    $chargecode 	="";
    $legal 	        ="";
    
    $p_date 	= "";
    $charge 	= "";
    $pay 	    = "";
    $exc 	    = "";
    $bal 	    = "";
    $status 	= "";
    
    
    
    
    $age = floor((time() - strtotime($birthdate)) / 31556926);
    

	$sql1 = "INSERT INTO patient_data (ic_num, name, age, address, gender, race, nationality, birthdate, telephone, religion, marrital, w_name, relation, w_telephone, w_address, status)
			VALUES ('$icnum', '$name', '$age', '$address', '$gender', '$race', '$nationality', '$birthdate', '$telephone', '$religion', '$marrital', '$w_name', '$relation', '$w_telephone', '$w_address', '$status')";	
    
    $sql2 = "INSERT INTO admit (ic_num, r_source, ad_date, discp, wad, c_code, legal)
			VALUES ('$icnum', '$refsource', '$admitdate', '$discipline', '$wad', '$chargecode', '$legal')";
    
    $sql3 = "INSERT INTO bill (p_date, c_ward, payment, exc, bal, dis_status)
			VALUES ('$p_date', '$charge', '$pay', '$exc', '$bal', '$status' )";
    
	dbQuery($sql1);
    dbQuery($sql2);
    dbQuery($sql3);
    header('Location: ../views/?v=REG&msg=' . urlencode('Patient has successfully registered.'));
	exit();
}

function admissionPatient() {
    $icnum 	= $_POST['icnum'];
    $name 	= $_POST['name'];
    $age 	= $_POST['age'];
    $address 	= $_POST['address'];
    $gender 	= $_POST['gender'];
    $race 	= $_POST['race'];
    $nationality 	= $_POST['nationality'];
    $birthdate 	= $_POST['birthdate'];
    $telephone 	= $_POST['telephone'];
    $religion 	= $_POST['religion'];
    $marrital 	= $_POST['marrital'];
    $status 	= $_POST['status'];
    
    /*$w_name 	= $_POST['w_name'];
    $relation 	= $_POST['relation'];
    $w_telephone 	= $_POST['w_telephone'];
    $w_address 	= $_POST['w_address'];*/
    
    $refsource 	    = $_POST['refsource'];
    $admitdate 	    = $_POST['admitdate'];
    $discipline 	= $_POST['discipline'];
    $wad 	        = $_POST['wad'];
    $chargecode 	= $_POST['chargecode'];
    $legal 	        = $_POST['legal'];
    
    
  
	

	$sql1 = "UPDATE patient_data SET name = '$name', age = '$age', address = '$address', gender = '$gender', race = '$race', nationality = '$nationality', birthdate = '$birthdate', telephone = '$telephone', religion ='$religion' , marrital = '$marrital', status = '$status' WHERE ic_num = $icnum";
    
    
    $sql2 = "UPDATE admit SET r_source = '$refsource', ad_date = '$admitdate', discp = '$discipline', wad = '$wad', c_code = '$chargecode', legal = '$legal' WHERE ic_num = $icnum";
    
    
   
	dbQuery($sql1);
    dbQuery($sql2);
    header('Location: ../views/?v=ADM&msg=' . urlencode('Patient has successfully admitted.'));
	exit();
}

function dischargePatient() {
    $sn 	    = $_POST['sn'];
    $p_date 	= $_POST['p_date'];
    $charge 	= $_POST['charge'];
    $pay 	    = $_POST['pay'];
    $exc 	    = $_POST['exc'];
    $bal 	    = $_POST['bal'];
    $status 	= $_POST['status'];
    $status 	= "DISCHARGED";
    
    
    
    
    $sql1 = "UPDATE bill SET p_date = '$p_date', c_ward = '$charge', payment = '$pay', exc = '$exc', bal = '$bal', dis_status = '$status' WHERE serial_num = '$sn'";
    
    
    $sql2 = "UPDATE patient_data SET status = '$status' WHERE serial_num = $sn";
    
    
   
	dbQuery($sql1);
    dbQuery($sql2);
    header('Location: ../views/?v=ADM&msg=' . urlencode('Patient has successfully discharged.'));
	exit();
}

?>