55 lines
2.0 KiB
PHP
55 lines
2.0 KiB
PHP
<?php
|
|
include ('includes/config/config.php');
|
|
include ('includes/functions.php');
|
|
error_reporting(E_ERROR | E_PARSE);
|
|
|
|
$appointment_id =$_REQUEST['appointment_id'];
|
|
$prescription_id =$_REQUEST['prescription_id'];
|
|
$data = array();
|
|
|
|
$ailment_ids_new = implode(',',$_POST['ailment_new']);
|
|
$ailment_system_ids_new = implode(',',$_POST['ailment_system_new']);
|
|
$external_treatments=$_POST['external_treatments'];
|
|
$referral=$_POST['referral'];
|
|
$follow_up=$_POST['follow_up'];
|
|
//echo $_POST['external_treatments'];
|
|
|
|
|
|
$query="";
|
|
$query_initial ="";
|
|
$query_end=" ";
|
|
begin();
|
|
if (! empty($_REQUEST['prescription_id'])) {
|
|
|
|
$data['message']="update";
|
|
$query_initial = " update prescription ";
|
|
$query_end=" where prescription_name = '" . $_REQUEST['template_name'] . "' ";
|
|
// echo $query;
|
|
} else {
|
|
$query_initial = "insert into prescription ";
|
|
$data['message']="save";
|
|
}
|
|
|
|
$query = " SET prescription_name='" . addslashes($_POST['template_name']) . "',ailments_new='" . addslashes($ailment_system_ids_new) . "',ailment_systems_new='" . addslashes($ailment_system_ids_new) . "',external_treatments='" . addslashes($external_treatments) . "',referral='" . addslashes($referral) . "',follow_up='" . addslashes($follow_up) . "' ";
|
|
|
|
//echo $query;
|
|
|
|
|
|
$query =$query_initial." ".$query." ".$query_end;
|
|
|
|
$result = @mysqli_query($conn,$query);
|
|
$prescription_id =mysqli_insert_id();
|
|
|
|
@mysqli_query($conn,"delete from treatment_prescription where prescription_id=".$prescription_id."");
|
|
|
|
echo $insert_query=" INSERT INTO treatment_prescription(treatment_id,item_id,frequency_id,for_days,item_qty,issued_qty,dosage,dosage_category_id,is_display,group_item_id,last_modified,modified_by,prescription_id) SELECT treatment_id,item_id,frequency_id,for_days,item_qty,issued_qty,dosage,dosage_category_id,is_display,group_item_id,last_modified,modified_by,".$prescription_id." FROM treatment
|
|
WHERE appointment_id =".$appointment_id." ";
|
|
|
|
$result_insert_query = @mysqli_query($conn,$insert_query);
|
|
|
|
commit();
|
|
$data['prescription_id']=$prescription_id;
|
|
echo json_encode($data);
|
|
|
|
?>
|