52 lines
2.1 KiB
PHP
52 lines
2.1 KiB
PHP
|
<?php
|
||
|
error_reporting(E_ERROR | E_PARSE);
|
||
|
include('includes/config/config.php');
|
||
|
include('includes/functions.php');
|
||
|
|
||
|
if (!empty($_POST['med_arr'])) {
|
||
|
$med = implode(",", $_POST['med_arr']);
|
||
|
|
||
|
$med = preg_replace('/,+/', ',', $med);
|
||
|
$med = rtrim($med, ',');
|
||
|
error_log("med " . $med);
|
||
|
$sql_med = "select * from tbl_items where item_id in ($med)";
|
||
|
|
||
|
error_log("query " . $sql_med);
|
||
|
|
||
|
if (!$result_med = @mysqli_query($conn, $sql_med)) {
|
||
|
exit(mysqli_error($conn));
|
||
|
}
|
||
|
$data = array();
|
||
|
|
||
|
if (mysqli_num_rows($result_med) > 0) {
|
||
|
while ($row_med = mysqli_fetch_assoc($result_med)) {
|
||
|
//extract($row);
|
||
|
$alternate = getCommaSeperatedValuesForInClause("select item_name from tbl_items", "item_id", $row_med['item_alternate']);
|
||
|
|
||
|
$composition = getCommaSeperatedValuesForInClause("select composition_name from composition", "composition_id", $row_med['composition']);
|
||
|
|
||
|
$indication = getCommaSeperatedValuesForInClause("select indication_name from indication", "indication_id", $row_med['indication']);
|
||
|
|
||
|
$contra_indication = getCommaSeperatedValuesForInClause("select cindication_name from contra_indication", "cindication_id", $row_med['contra_indication']);
|
||
|
|
||
|
$sideeffects = getCommaSeperatedValuesForInClause("select sideeffect_name from side_effects", "sideeffect_id", $row_med['side_effects']);
|
||
|
|
||
|
$data[$row_med['item_id']] = array(
|
||
|
'item_name' => $row_med['item_name'],
|
||
|
'item_precaution' => $row_med['item_precaution'],
|
||
|
'item_alternate' => $alternate,
|
||
|
'composition' => $composition,
|
||
|
'indication' => $indication,
|
||
|
'contraIndication' => $contra_indication,
|
||
|
'effect' => $sideeffects,
|
||
|
'is_prescription' => $row['is_prescription'] == '1' ? "Yes" : "No",
|
||
|
'interaction' => "test"
|
||
|
);
|
||
|
}
|
||
|
} else {
|
||
|
$data['status'] = 200;
|
||
|
$data['message'] = "Data not found!";
|
||
|
}
|
||
|
}
|
||
|
error_log("data " . print_r($data, true));
|
||
|
echo json_encode($data);
|