Skip to content

Commit

Permalink
Added Dosages Working properly now
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadbk committed Sep 11, 2016
1 parent 48ceb46 commit cf0624e
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 8 deletions.
40 changes: 40 additions & 0 deletions AddDosage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
require "conn.php";
$tag_id = $_POST["tag_id"];
$nurse_tag = $_POST["nurse_tag"];
$t = $_POST["time"];
$prescription_id = $_POST["prescription_id"];

$patient_id = "";
$nurse_id = "";

$mysql_qry1 = "SELECT `patient_id` FROM `patient` WHERE tag_id='$tag_id'";
if ($result1=mysqli_query($conn,$mysql_qry1))
{
while($row1=mysqli_fetch_row($result1))
{
$patient_id = $row1[0];
}
}

$mysql_qry2 = "SELECT `nurse_id` FROM `nurse` WHERE tag_id='$nurse_tag'";
if ($result2=mysqli_query($conn,$mysql_qry2))
{
while($row2=mysqli_fetch_row($result2))
{
$nurse_id = $row2[0];
}
}

$mysql_qry = "INSERT INTO `hospital`.`dosage` (`dosage_id`, `time`, `patient_id`, `nurse_id`, `prescription_id`) VALUES (NULL, '$t','$patient_id','$nurse_id','$prescription_id')";

if ($result=mysqli_query($conn,$mysql_qry))
{
echo "success";
}
else
{
echo "failed";
}
mysqli_close($conn);
?>
14 changes: 11 additions & 3 deletions AddPrescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
$tag_id = $_POST["tag_id"];
$doctor_tag = $_POST["doctor_tag"];
$medicine_name = $_POST["medicine_name"];
$quantity_per_day = $_POST["quantity_per_day"];
$frequency_per_day = $_POST["frequency_per_day"];
$quantity_per_dosage = $_POST["quantity_per_dosage"];
$end_date = $_POST["end_date"];
$morning = $_POST["morning"];
$afternoon = $_POST["afternoon"];
$evening = $_POST["evening"];
$mealRelation = $_POST["mealRelation"];


$patient_id = "";
$doctor_id = "";
Expand Down Expand Up @@ -45,11 +49,15 @@

$status = "active";

$mysql_qry = "INSERT INTO `hospital`.`prescription` (`prescription_id`, `patient_id`, `doctor_id`, `medicine_id`, `quantity_per_day`, `frequency_per_day`, `start_date`, `end_date`, `status`) VALUES (NULL, '$patient_id', '$doctor_id','$medicine_id' ,'$quantity_per_day', '$frequency_per_day', '$curr_date', '$end_date', '$status')";
$mysql_qry = "INSERT INTO `hospital`.`prescription` (`prescription_id`, `patient_id`, `doctor_id`, `medicine_id`, `quantity_per_dosage`, `start_date`, `end_date`, `status`, `morning`, `afternoon`, `evening`, `mealRelation`) VALUES (NULL, '$patient_id','$doctor_id','$medicine_id','$quantity_per_dosage','$curr_date', '$end_date', '$status', '$morning', '$afternoon', '$evening', '$mealRelation')";

if ($result=mysqli_query($conn,$mysql_qry))
{
echo "success";
}
else
{
echo "failed";
}
mysqli_close($conn);
?>
32 changes: 27 additions & 5 deletions NextDosage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
}

$current_hour = date("H");
$current_date = date("YYYY-mm-dd");

$status = "active";

Expand All @@ -37,17 +38,38 @@
}
}

if($current_hour > "5" and $current_hour < "11" and $row2[3] == $t)
if($current_hour > "-1" and $current_hour < "11" and $row2[3] == $t)
{
array_push($response, array("medName"=>$medName,"quantity_per_dosage"=>$row2[1], "mealRelation"=>$row2[6],"prescription_id"=>$row2[7]));
$mysql_qry5 = "SELECT * FROM `dosage` WHERE prescription_id = '$row2[7]' AND DATE(time) = cast(now() as date) AND HOUR(time) > -1 AND HOUR(time) < 11 ";
$result5=mysqli_query($conn,$mysql_qry5);
if(!$result5 || mysqli_num_rows($result5)>0)
{}
else
{
array_push($response, array("medName"=>$medName,"quantity_per_dosage"=>$row2[1], "mealRelation"=>$row2[6],"prescription_id"=>$row2[7]));
}
}
elseif($current_hour > "10" and $current_hour < "17" and $row2[4] == $t)
{
array_push($response, array("medName"=>$medName,"quantity_per_dosage"=>$row2[1], "mealRelation"=>$row2[6],"prescription_id"=>$row2[7]));
$mysql_qry6 = "SELECT * FROM `dosage` WHERE prescription_id = '$row2[7]' AND DATE(time) = cast(now() as date) AND HOUR(time) > 10 AND HOUR(time) < 17 ";
$result6=mysqli_query($conn,$mysql_qry6);
if(!$result6 || mysqli_num_rows($result6)>0)
{}
else
{
array_push($response, array("medName"=>$medName,"quantity_per_dosage"=>$row2[1], "mealRelation"=>$row2[6],"prescription_id"=>$row2[7]));
}
}
elseif($current_hour > "17" and $current_hour < "23" and $row2[5] == $t)
elseif($current_hour > "17" and $current_hour < "24" and $row2[5] == $t)
{
array_push($response, array("medName"=>$medName,"quantity_per_dosage"=>$row2[1], "mealRelation"=>$row2[6],"prescription_id"=>$row2[7]));
$mysql_qry7 = "SELECT * FROM `dosage` WHERE prescription_id = '$row2[7]' AND DATE(time) = cast(now() as date) AND HOUR(time) > 17 AND HOUR(time) < 24 ";
$result7=mysqli_query($conn,$mysql_qry7);
if(!$result7 || mysqli_num_rows($result7)>0)
{}
else
{
array_push($response, array("medName"=>$medName,"quantity_per_dosage"=>$row2[1], "mealRelation"=>$row2[6],"prescription_id"=>$row2[7]));
}
}

}
Expand Down

0 comments on commit cf0624e

Please sign in to comment.